importonly abstract class IPrereq extends IScriptable
{
	public import const virtual function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool;
	public import const function RegisterEntity( game : GameInstance, entityId : EntityID ) : PrereqState;
	public import static function CreatePrereq( id : TweakDBID ) : IPrereq;
}

importonly class PrereqState extends IScriptable
{
	public import function OnChanged( newState : Bool );
	public import function OnChangedRepeated( optional callOnlyOnStateFulfilled : Bool );
	public import const function GetPrereq() : const IPrereq;
	public import const function GetContext() : IScriptable;
	public import const function IsFulfilled() : Bool;
}

importonly class PrereqStateChangedEvent extends Event
{
	public import const function GetPrereqState() : PrereqState;
}

import class IScriptablePrereq extends IPrereq
{

	protected export const virtual function IsOnRegisterSupported() : Bool
	{
		return true;
	}

	protected export const virtual function OnRegister( state : PrereqState, game : GameInstance, context : IScriptable ) : Bool
	{
		return false;
	}

	protected export const virtual function OnUnregister( state : PrereqState, game : GameInstance, context : IScriptable );
	protected export virtual function Initialize( record : TweakDBID );
	protected export const virtual function OnApplied( state : PrereqState, game : GameInstance, context : IScriptable );
}

importonly class MultiPrereqState extends PrereqState
{
	import var nestedStates : array< PrereqState >;
}

class DevelopmentCheckPrereq extends IScriptablePrereq
{
	protected editable var requiredLevel : Float;

	protected override function Initialize( recordID : TweakDBID )
	{
		var tweakID : TweakDBID;
		tweakID = recordID;
		TDBID.Append( tweakID, T".requiredLevel" );
		requiredLevel = TDB.GetFloat( tweakID );
	}

}

class SkillCheckPrereqState extends PrereqState
{

	public const function GetSkillToCheck() : gamedataProficiencyType
	{
		return ( ( SkillCheckPrereq )( GetPrereq() ) ).GetSkillToCheck();
	}

	public function UpdateSkillCheckPrereqData( obj : GameObject, newLevel : Int32 )
	{
		var checkPassed : Bool;
		checkPassed = ( ( SkillCheckPrereq )( GetPrereq() ) ).IsFulfilled( obj.GetGame(), GetContext() );
		OnChanged( checkPassed );
	}

}

class SkillCheckPrereq extends DevelopmentCheckPrereq
{
	protected editable var skillToCheck : gamedataProficiencyType;

	public const function GetSkillToCheck() : gamedataProficiencyType
	{
		return skillToCheck;
	}

	protected const override function OnRegister( state : PrereqState, game : GameInstance, context : IScriptable ) : Bool
	{
		var player : PlayerPuppet;
		var castedState : SkillCheckPrereqState;
		var request : ModifySkillCheckPrereq;
		castedState = ( ( SkillCheckPrereqState )( state ) );
		player = ( ( PlayerPuppet )( context ) );
		if( player )
		{
			request = new ModifySkillCheckPrereq;
			request.Set( player, true, castedState );
			GameInstance.GetScriptableSystemsContainer( game ).Get( 'PlayerDevelopmentSystem' ).QueueRequest( request );
			return IsFulfilled( game, context );
		}
		return false;
	}

	protected const override function OnUnregister( state : PrereqState, game : GameInstance, context : IScriptable )
	{
		var player : PlayerPuppet;
		var castedState : SkillCheckPrereqState;
		var request : ModifySkillCheckPrereq;
		castedState = ( ( SkillCheckPrereqState )( state ) );
		player = ( ( PlayerPuppet )( context ) );
		if( player )
		{
			request = new ModifySkillCheckPrereq;
			request.Set( player, false, castedState );
			GameInstance.GetScriptableSystemsContainer( game ).Get( 'PlayerDevelopmentSystem' ).QueueRequest( request );
		}
	}

	public const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var skillLevel : Int32;
		var player : PlayerPuppet;
		player = GetPlayer( game );
		skillLevel = ( ( PlayerDevelopmentSystem )( GameInstance.GetScriptableSystemsContainer( game ).Get( 'PlayerDevelopmentSystem' ) ) ).GetProficiencyLevel( player, skillToCheck );
		return ( ( Float )( skillLevel ) ) >= requiredLevel;
	}

	protected override function Initialize( recordID : TweakDBID )
	{
		var tweakID : TweakDBID;
		var type : CName;
		super.Initialize( recordID );
		tweakID = recordID;
		TDBID.Append( tweakID, T".skillToCheck" );
		type = TDB.GetCName( tweakID );
		skillToCheck = ( ( gamedataProficiencyType )( ( ( Int32 )( EnumValueFromName( 'gamedataProficiencyType', type ) ) ) ) );
	}

}

class StatCheckPrereqState extends PrereqState
{

	public const function GetStatToCheck() : gamedataStatType
	{
		return ( ( StatCheckPrereq )( GetPrereq() ) ).GetStatToCheck();
	}

	public function UpdateStatCheckPrereqData( obj : GameObject, newValue : Float )
	{
		var checkPassed : Bool;
		checkPassed = ( ( StatCheckPrereq )( GetPrereq() ) ).IsFulfilled( obj.GetGame(), GetContext() );
		OnChanged( checkPassed );
	}

}

class StatCheckPrereq extends DevelopmentCheckPrereq
{
	protected editable var statToCheck : gamedataStatType;

	public const function GetStatToCheck() : gamedataStatType
	{
		return statToCheck;
	}

	protected const override function OnRegister( state : PrereqState, game : GameInstance, context : IScriptable ) : Bool
	{
		var player : PlayerPuppet;
		var castedState : StatCheckPrereqState;
		var request : ModifyStatCheckPrereq;
		castedState = ( ( StatCheckPrereqState )( state ) );
		player = ( ( PlayerPuppet )( context ) );
		if( player )
		{
			request = new ModifyStatCheckPrereq;
			request.Set( player, true, castedState );
			GameInstance.GetScriptableSystemsContainer( GetGameInstance() ).Get( 'PlayerDevelopmentSystem' ).QueueRequest( request );
			return true;
		}
		return false;
	}

	protected const override function OnUnregister( state : PrereqState, game : GameInstance, context : IScriptable )
	{
		var player : PlayerPuppet;
		var castedState : StatCheckPrereqState;
		var request : ModifyStatCheckPrereq;
		castedState = ( ( StatCheckPrereqState )( state ) );
		player = ( ( PlayerPuppet )( context ) );
		if( player )
		{
			request = new ModifyStatCheckPrereq;
			request.Set( player, false, castedState );
			GameInstance.GetScriptableSystemsContainer( GetGameInstance() ).Get( 'PlayerDevelopmentSystem' ).QueueRequest( request );
		}
	}

	public const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var statValue : Float;
		var player : GameObject;
		player = GetPlayer( game );
		statValue = GameInstance.GetStatsSystem( game ).GetStatValue( player.GetEntityID(), statToCheck );
		return statValue >= requiredLevel;
	}

	protected override function Initialize( recordID : TweakDBID )
	{
		var tweakID : TweakDBID;
		var type : CName;
		super.Initialize( recordID );
		tweakID = recordID;
		TDBID.Append( tweakID, T".statToCheck" );
		type = TDB.GetCName( tweakID );
		statToCheck = ( ( gamedataStatType )( ( ( Int32 )( EnumValueFromName( 'gamedataStatType', type ) ) ) ) );
	}

}

class NPCRevealedPrereqState extends PrereqState
{
	var m_listener : PuppetListener;
}

class NPCRevealedPrereq extends IScriptablePrereq
{

	protected const override function OnRegister( state : PrereqState, game : GameInstance, context : IScriptable ) : Bool
	{
		var npcOwner : NPCPuppet;
		var castedState : NPCRevealedPrereqState;
		castedState = ( ( NPCRevealedPrereqState )( state ) );
		if( ( ( NPCPuppet )( context ) ) )
		{
			npcOwner = ( ( NPCPuppet )( context ) );
		}
		castedState.m_listener = new PuppetListener;
		castedState.m_listener.RegisterOwner( castedState );
		ScriptedPuppet.AddListener( npcOwner, castedState.m_listener );
		return npcOwner.IsRevealed();
	}

	protected const override function OnUnregister( state : PrereqState, game : GameInstance, context : IScriptable )
	{
		var castedState : NPCRevealedPrereqState;
		castedState = ( ( NPCRevealedPrereqState )( state ) );
		ScriptedPuppet.RemoveListener( ( ( GameObject )( context ) ), castedState.m_listener );
		castedState.m_listener = NULL;
	}

	public const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var npcOwner : NPCPuppet;
		if( ( ( NPCPuppet )( context ) ) )
		{
			npcOwner = ( ( NPCPuppet )( context ) );
		}
		return npcOwner.IsRevealed();
	}

}

class RevealAccessPointPrereqState extends PrereqState
{
	var m_listener : GameObjectListener;
}

class RevealAccessPointPrereq extends IScriptablePrereq
{

	protected const override function OnRegister( state : PrereqState, game : GameInstance, context : IScriptable ) : Bool
	{
		var owner : GameObject;
		var castedState : RevealAccessPointPrereqState;
		castedState = ( ( RevealAccessPointPrereqState )( state ) );
		if( ( ( GameObject )( context ) ) )
		{
			owner = ( ( GameObject )( context ) );
		}
		castedState.m_listener = new GameObjectListener;
		castedState.m_listener.RegisterOwner( castedState );
		GameObject.AddListener( owner, castedState.m_listener );
		return false;
	}

	protected const override function OnUnregister( state : PrereqState, game : GameInstance, context : IScriptable )
	{
		var castedState : RevealAccessPointPrereqState;
		castedState = ( ( RevealAccessPointPrereqState )( state ) );
		GameObject.RemoveListener( ( ( GameObject )( context ) ), castedState.m_listener );
		castedState.m_listener = NULL;
	}

	public const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var accessPoint : AccessPoint;
		accessPoint = ( ( AccessPoint )( context ) );
		if( accessPoint )
		{
			return accessPoint.IsRevealed();
		}
		return false;
	}

}

class NPCDeadPrereq extends IScriptablePrereq
{

	public const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var npcOwner : NPCPuppet;
		var statPoolsSystem : StatPoolsSystem;
		var health : Float;
		var npcOwnerID : StatsObjectID;
		statPoolsSystem = GameInstance.GetStatPoolsSystem( game );
		if( ( ( NPCPuppet )( context ) ) )
		{
			npcOwner = ( ( NPCPuppet )( context ) );
			npcOwnerID = npcOwner.GetEntityID();
			health = statPoolsSystem.GetStatPoolValue( npcOwnerID, gamedataStatPoolType.Health );
			if( health <= 0.0 )
			{
				return true;
			}
		}
		return false;
	}

}

class NPCIncapacitatedPrereq extends IScriptablePrereq
{

	public export const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var npcOwner : NPCPuppet;
		var state : gamedataNPCHighLevelState;
		npcOwner = ( ( NPCPuppet )( context ) );
		if( npcOwner )
		{
			state = npcOwner.GetHighLevelStateFromBlackboard();
			if( ( ( state == gamedataNPCHighLevelState.Unconscious || state == gamedataNPCHighLevelState.Dead ) || ScriptedPuppet.IsDefeated( npcOwner ) ) || ScriptedPuppet.IsNanoWireHacked( npcOwner ) )
			{
				return true;
			}
		}
		return false;
	}

}

class NPCGrappledByPlayerPrereq extends IScriptablePrereq
{

	public export const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var npcOwner : NPCPuppet;
		var mountingInfo : MountingInfo;
		var mountingSlotName : CName;
		var isNPCMounted : Bool;
		npcOwner = ( ( NPCPuppet )( context ) );
		mountingInfo = GameInstance.GetMountingFacility( npcOwner.GetGame() ).GetMountingInfoSingleWithObjects( npcOwner );
		isNPCMounted = EntityID.IsDefined( mountingInfo.childId );
		mountingSlotName = mountingInfo.slotId.id;
		if( ( ( ( NPCPuppet )( context ) ) && isNPCMounted ) && mountingSlotName == 'grapple' )
		{
			return true;
		}
		return false;
	}

}

class SinglePlayerPrereq extends IScriptablePrereq
{

	public const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		return !( GameInstance.GetRuntimeInfo( game ).IsMultiplayer() );
	}

}

class NPCNotMountedToVehiclePrereq extends IScriptablePrereq
{

	public export const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var npcOwner : NPCPuppet;
		var isNPCMounted : Bool;
		npcOwner = ( ( NPCPuppet )( context ) );
		isNPCMounted = VehicleComponent.IsMountedToVehicle( game, npcOwner.GetEntityID() );
		if( ( ( NPCPuppet )( context ) ) && !( isNPCMounted ) )
		{
			return true;
		}
		return false;
	}

}

class NPCIsHumanoidPrereq extends IScriptablePrereq
{

	public const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var npcOwner : NPCPuppet;
		npcOwner = ( ( NPCPuppet )( context ) );
		if( npcOwner )
		{
			return npcOwner.GetNPCType() == gamedataNPCType.Human;
		}
		return true;
	}

}

class PuppetNotBossPrereq extends IScriptablePrereq
{

	public const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var puppet : ScriptedPuppet;
		var isBoss : Bool;
		puppet = ( ( ScriptedPuppet )( context ) );
		if( puppet )
		{
			isBoss = puppet.IsBoss();
		}
		else
		{
			isBoss = false;
		}
		return !( isBoss );
	}

}

class NotReplacerPrereq extends IScriptablePrereq
{

	public const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var playerControlledObject : GameObject;
		playerControlledObject = GameInstance.GetPlayerSystem( game ).GetLocalPlayerControlledGameObject();
		if( playerControlledObject )
		{
			if( !( playerControlledObject.IsReplacer() ) )
			{
				return true;
			}
		}
		return false;
	}

}

class NotJohnnyReplacerPrereq extends IScriptablePrereq
{

	public export const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var playerControlledObject : GameObject;
		playerControlledObject = GameInstance.GetPlayerSystem( game ).GetLocalPlayerControlledGameObject();
		if( playerControlledObject )
		{
			if( !( playerControlledObject.IsJohnnyReplacer() ) )
			{
				return true;
			}
		}
		return false;
	}

}

class NotVRReplacerPrereq extends IScriptablePrereq
{

	public const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var playerControlledObject : GameObject;
		playerControlledObject = GameInstance.GetPlayerSystem( game ).GetLocalPlayerControlledGameObject();
		if( playerControlledObject )
		{
			if( !( playerControlledObject.IsVRReplacer() ) )
			{
				return true;
			}
		}
		return false;
	}

}

class PlayerDeadPrereq extends IScriptablePrereq
{

	public const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var playerOwner : PlayerPuppet;
		playerOwner = ( ( PlayerPuppet )( context ) );
		if( playerOwner )
		{
			if( playerOwner.IsDead() )
			{
				return true;
			}
		}
		return false;
	}

}

class PuppetIncapacitatedPrereq extends IScriptablePrereq
{

	public const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var puppet : gamePuppetBase;
		puppet = ( ( gamePuppetBase )( context ) );
		if( puppet )
		{
			return puppet.IsIncapacitated();
		}
		return false;
	}

}

class PlayerNotCarryingPrereq extends IScriptablePrereq
{

	public export const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var blackboard : IBlackboard;
		var playerCarrying : Bool;
		var playerControlledObject : GameObject;
		playerControlledObject = GameInstance.GetPlayerSystem( game ).GetLocalPlayerControlledGameObject();
		if( playerControlledObject )
		{
			blackboard = GameInstance.GetBlackboardSystem( game ).GetLocalInstanced( playerControlledObject.GetEntityID(), GetAllBlackboardDefs().PlayerStateMachine );
			playerCarrying = blackboard.GetBool( GetAllBlackboardDefs().PlayerStateMachine.Carrying );
		}
		else
		{
			playerCarrying = false;
		}
		return !( playerCarrying );
	}

}

class PlayerNotGrapplingPrereq extends IScriptablePrereq
{

	public export const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var playerControlledObject : GameObject;
		var blackboard : IBlackboard;
		var playerGrappling : Bool;
		playerControlledObject = GameInstance.GetPlayerSystem( game ).GetLocalPlayerControlledGameObject();
		if( playerControlledObject )
		{
			blackboard = GameInstance.GetBlackboardSystem( game ).GetLocalInstanced( playerControlledObject.GetEntityID(), GetAllBlackboardDefs().PlayerStateMachine );
			playerGrappling = ( ( blackboard.GetInt( GetAllBlackboardDefs().PlayerStateMachine.Takedown ) == ( ( Int32 )( gamePSMTakedown.EnteringGrapple ) ) ) || ( blackboard.GetInt( GetAllBlackboardDefs().PlayerStateMachine.Takedown ) == ( ( Int32 )( gamePSMTakedown.Grapple ) ) ) ) || ( blackboard.GetInt( GetAllBlackboardDefs().PlayerStateMachine.Takedown ) == ( ( Int32 )( gamePSMTakedown.Takedown ) ) );
		}
		else
		{
			playerGrappling = false;
		}
		return !( playerGrappling );
	}

}

class DisableAllWorldInteractionsNotEnabledPrereq extends IScriptablePrereq
{

	public export const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var playerControlledObject : GameObject;
		var isDisablingRequested : Bool;
		playerControlledObject = GameInstance.GetPlayerSystem( game ).GetLocalPlayerControlledGameObject();
		if( playerControlledObject )
		{
			isDisablingRequested = StatusEffectSystem.ObjectHasStatusEffectWithTag( playerControlledObject, 'NoWorldInteractions' );
		}
		else
		{
			isDisablingRequested = false;
		}
		return !( isDisablingRequested );
	}

}

class DisableAllVehicleInteractionsNotEnabledPrereq extends IScriptablePrereq
{

	public export const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var playerControlledObject : GameObject;
		var isDisablingRequested : Bool;
		playerControlledObject = GameInstance.GetPlayerSystem( game ).GetLocalPlayerControlledGameObject();
		if( playerControlledObject )
		{
			isDisablingRequested = StatusEffectSystem.ObjectHasStatusEffectWithTag( playerControlledObject, 'VehicleNoInteraction' );
		}
		else
		{
			isDisablingRequested = false;
		}
		return !( isDisablingRequested );
	}

}

class PlayerHasTakedownWeaponEquippedPrereq extends IScriptablePrereq
{

	public const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var playerControlledObject : GameObject;
		var weaponObj : WeaponObject;
		var record : Item_Record;
		var itemID : ItemID;
		var tags : array< CName >;
		var i : Int32;
		playerControlledObject = GameInstance.GetPlayerSystem( game ).GetLocalPlayerControlledGameObject();
		weaponObj = ( ( WeaponObject )( GameInstance.GetTransactionSystem( playerControlledObject.GetGame() ).GetItemInSlot( playerControlledObject, T"AttachmentSlots.WeaponRight" ) ) );
		itemID = weaponObj.GetItemID();
		if( playerControlledObject && ItemID.IsValid( itemID ) )
		{
			record = TDB.GetItemRecord( ItemID.GetTDBID( itemID ) );
			tags = record.Tags();
			for( i = 0; i < tags.Size(); i += 1 )
			{
				if( tags[ i ] == 'TakedownWeapon' )
				{
					return true;
				}
			}
		}
		return false;
	}

}

class PlayerHasMantisBladesEquippedPrereq extends IScriptablePrereq
{

	public const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var playerControlledObject : GameObject;
		var weaponObj : WeaponObject;
		var friendlyName : String;
		playerControlledObject = GameInstance.GetPlayerSystem( game ).GetLocalPlayerControlledGameObject();
		weaponObj = ( ( WeaponObject )( GameInstance.GetTransactionSystem( playerControlledObject.GetGame() ).GetItemInSlot( playerControlledObject, T"AttachmentSlots.WeaponRight" ) ) );
		if( playerControlledObject && weaponObj )
		{
			friendlyName = TweakDBInterface.GetItemRecord( ItemID.GetTDBID( weaponObj.GetItemID() ) ).FriendlyName();
			if( friendlyName == "mantis_blade" )
			{
				return true;
			}
		}
		return false;
	}

}

class IsNpcMountedInSlotPrereqState extends PrereqState
{
	var psListener : gameScriptedPrereqPSChangeListenerWrapper;

	protected function OnMountingStateChanged()
	{
		var prereq : IsNpcMountedInSlotPrereq;
		prereq = ( ( IsNpcMountedInSlotPrereq )( GetPrereq() ) );
		OnChanged( prereq.IsFulfilled( GetGameInstance(), GetContext() ) );
	}

}

class IsNpcMountedInSlotPrereq extends IScriptablePrereq
{
	protected var slotName : CName;
	protected var isCheckInverted : Bool;

	protected export override function Initialize( recordID : TweakDBID )
	{
		var tweakID : TweakDBID;
		tweakID = recordID;
		TDBID.Append( tweakID, T".slotname" );
		slotName = TDB.GetCName( tweakID );
		tweakID = recordID;
		TDBID.Append( tweakID, T".isCheckInverted" );
		isCheckInverted = TDB.GetBool( tweakID );
	}

	protected export const override function OnRegister( state : PrereqState, game : GameInstance, context : IScriptable ) : Bool
	{
		var castedState : IsNpcMountedInSlotPrereqState;
		var persistentId : PersistentID;
		const var vehicle : VehicleObject;
		vehicle = ( ( VehicleObject )( context ) );
		castedState = ( ( IsNpcMountedInSlotPrereqState )( state ) );
		if( vehicle )
		{
			persistentId = CreatePersistentID( vehicle.GetEntityID(), vehicle.GetPSClassName() );
			castedState.psListener = gameScriptedPrereqPSChangeListenerWrapper.CreateListener( game, persistentId, castedState );
			return false;
		}
		return false;
	}

	protected export const override function OnUnregister( state : PrereqState, game : GameInstance, context : IScriptable )
	{
		var castedState : IsNpcMountedInSlotPrereqState;
		castedState = ( ( IsNpcMountedInSlotPrereqState )( state ) );
		castedState.psListener = NULL;
	}

	public export const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		const var player : PlayerPuppet;
		const var vehicle : VehicleObject;
		player = ( ( PlayerPuppet )( GameInstance.GetPlayerSystem( game ).GetLocalPlayerMainGameObject() ) );
		vehicle = ( ( VehicleObject )( context ) );
		if( player && vehicle )
		{
			if( vehicle.GetVehiclePS().IsSlotOccupiedByNPC( slotName ) )
			{
				if( VehicleComponent.IsSlotOccupiedByActivePassenger( game, vehicle.GetEntityID(), slotName ) )
				{
					return !( isCheckInverted );
				}
			}
		}
		return isCheckInverted;
	}

}

class IsMountedByPreventionNPCPrereqState extends PrereqState
{
	var mountingListener : gameScriptedPrereqMountingListenerWrapper;

	protected export function OnMountingStateChanged()
	{
		var prereq : IsMountedByPreventionNPCPrereq;
		prereq = ( ( IsMountedByPreventionNPCPrereq )( GetPrereq() ) );
		OnChanged( prereq.IsFulfilled( GetGameInstance(), GetContext() ) );
	}

}

class IsMountedByPreventionNPCPrereq extends IScriptablePrereq
{
	protected var isCheckInverted : Bool;

	protected export override function Initialize( recordID : TweakDBID )
	{
		var tweakID : TweakDBID;
		tweakID = recordID;
		TDBID.Append( tweakID, T".isCheckInverted" );
		isCheckInverted = TDB.GetBool( tweakID );
	}

	protected export const override function OnRegister( state : PrereqState, game : GameInstance, context : IScriptable ) : Bool
	{
		var castedState : IsMountedByPreventionNPCPrereqState;
		const var vehicle : VehicleObject;
		castedState = ( ( IsMountedByPreventionNPCPrereqState )( state ) );
		vehicle = ( ( VehicleObject )( context ) );
		if( vehicle )
		{
			castedState.mountingListener = gameScriptedPrereqMountingListenerWrapper.CreateVehicleListener( game, vehicle.GetEntityID(), castedState );
			return false;
		}
		return false;
	}

	protected export const override function OnUnregister( state : PrereqState, game : GameInstance, context : IScriptable )
	{
		var castedState : IsMountedByPreventionNPCPrereqState;
		castedState = ( ( IsMountedByPreventionNPCPrereqState )( state ) );
		castedState.mountingListener = NULL;
	}

	public export const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		const var player : PlayerPuppet;
		const var vehicle : VehicleObject;
		player = ( ( PlayerPuppet )( GameInstance.GetPlayerSystem( game ).GetLocalPlayerMainGameObject() ) );
		vehicle = ( ( VehicleObject )( context ) );
		if( ( player && vehicle ) && vehicle.IsPrevention() )
		{
			return !( isCheckInverted );
		}
		return isCheckInverted;
	}

}

class CanPlayerHijackMountedNpcPrereqState extends PrereqState
{
	var mountingListener : gameScriptedPrereqMountingListenerWrapper;

	protected export function OnMountingStateChanged()
	{
		var prereq : CanPlayerHijackMountedNpcPrereq;
		prereq = ( ( CanPlayerHijackMountedNpcPrereq )( GetPrereq() ) );
		OnChanged( prereq.IsFulfilled( GetGameInstance(), GetContext() ) );
	}

}

class CanPlayerHijackMountedNpcPrereq extends IScriptablePrereq
{
	protected var slotName : CName;
	protected var isCheckInverted : Bool;

	protected export override function Initialize( recordID : TweakDBID )
	{
		var tweakID : TweakDBID;
		tweakID = recordID;
		TDBID.Append( tweakID, T".slotname" );
		slotName = TDB.GetCName( tweakID );
		tweakID = recordID;
		TDBID.Append( tweakID, T".isCheckInverted" );
		isCheckInverted = TDB.GetBool( tweakID );
	}

	protected export const override function OnRegister( state : PrereqState, game : GameInstance, context : IScriptable ) : Bool
	{
		var castedState : CanPlayerHijackMountedNpcPrereqState;
		const var vehicle : VehicleObject;
		vehicle = ( ( VehicleObject )( context ) );
		castedState = ( ( CanPlayerHijackMountedNpcPrereqState )( state ) );
		if( vehicle )
		{
			castedState.mountingListener = gameScriptedPrereqMountingListenerWrapper.CreateVehicleListener( game, vehicle.GetEntityID(), castedState );
			return false;
		}
		return false;
	}

	protected export const override function OnUnregister( state : PrereqState, game : GameInstance, context : IScriptable )
	{
		var castedState : CanPlayerHijackMountedNpcPrereqState;
		castedState = ( ( CanPlayerHijackMountedNpcPrereqState )( state ) );
		castedState.mountingListener = NULL;
	}

	public export const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		const var player : PlayerPuppet;
		const var vehicle : VehicleObject;
		var attitude : EAIAttitude;
		var mountingSlotID : MountingSlotId;
		player = ( ( PlayerPuppet )( GameInstance.GetPlayerSystem( game ).GetLocalPlayerMainGameObject() ) );
		vehicle = ( ( VehicleObject )( context ) );
		if( player && vehicle )
		{
			if( VehicleComponent.IsSlotOccupiedByActivePassenger( game, vehicle.GetEntityID(), slotName ) )
			{
				mountingSlotID.id = slotName;
				VehicleComponent.GetAttitudeOfPassenger( game, vehicle.GetEntityID(), mountingSlotID, attitude );
				if( attitude == EAIAttitude.AIA_Neutral )
				{
					return !( isCheckInverted );
				}
			}
		}
		return isCheckInverted;
	}

}

class IsNpcPlayingMountingAnimationPrereqState extends PrereqState
{
	var psListener : gameScriptedPrereqPSChangeListenerWrapper;

	protected function OnPSStateChanged()
	{
		var prereq : IsNpcPlayingMountingAnimationPrereq;
		prereq = ( ( IsNpcPlayingMountingAnimationPrereq )( GetPrereq() ) );
		OnChanged( prereq.IsFulfilled( GetGameInstance(), GetContext() ) );
	}

}

class IsNpcPlayingMountingAnimationPrereq extends IScriptablePrereq
{
	protected var slotName : CName;
	protected var isCheckInverted : Bool;

	protected export override function Initialize( recordID : TweakDBID )
	{
		var tweakID : TweakDBID;
		tweakID = recordID;
		TDBID.Append( tweakID, T".slotname" );
		slotName = TDB.GetCName( tweakID );
		tweakID = recordID;
		TDBID.Append( tweakID, T".isCheckInverted" );
		isCheckInverted = TDB.GetBool( tweakID );
	}

	protected export const override function OnRegister( state : PrereqState, game : GameInstance, context : IScriptable ) : Bool
	{
		var castedState : IsNpcPlayingMountingAnimationPrereqState;
		var persistentId : PersistentID;
		const var vehicle : VehicleObject;
		vehicle = ( ( VehicleObject )( context ) );
		castedState = ( ( IsNpcPlayingMountingAnimationPrereqState )( state ) );
		if( vehicle )
		{
			persistentId = CreatePersistentID( vehicle.GetEntityID(), vehicle.GetPSClassName() );
			castedState.psListener = gameScriptedPrereqPSChangeListenerWrapper.CreateListener( game, persistentId, castedState );
			return false;
		}
		return false;
	}

	protected export const override function OnUnregister( state : PrereqState, game : GameInstance, context : IScriptable )
	{
		var castedState : IsNpcPlayingMountingAnimationPrereqState;
		castedState = ( ( IsNpcPlayingMountingAnimationPrereqState )( state ) );
		castedState.psListener = NULL;
	}

	public export const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		const var player : PlayerPuppet;
		const var vehicle : VehicleObject;
		player = ( ( PlayerPuppet )( GameInstance.GetPlayerSystem( game ).GetLocalPlayerMainGameObject() ) );
		vehicle = ( ( VehicleObject )( context ) );
		if( player && vehicle )
		{
			if( VehicleComponent.IsSlotOccupied( game, vehicle.GetEntityID(), slotName ) )
			{
				if( !( vehicle.GetVehiclePS().IsSlotOccupiedByNPC( slotName ) ) )
				{
					return !( isCheckInverted );
				}
			}
		}
		return isCheckInverted;
	}

}

class IsVehicleDoorLockedState extends PrereqState
{
	var psListener : gameScriptedPrereqPSChangeListenerWrapper;

	protected function OnPSStateChanged()
	{
		var prereq : IsVehicleDoorLocked;
		prereq = ( ( IsVehicleDoorLocked )( GetPrereq() ) );
		OnChanged( prereq.IsFulfilled( GetGameInstance(), GetContext() ) );
	}

}

class IsVehicleDoorLocked extends IScriptablePrereq
{
	protected var slotName : CName;
	protected var isCheckInverted : Bool;

	protected export override function Initialize( recordID : TweakDBID )
	{
		var tweakID : TweakDBID;
		tweakID = recordID;
		TDBID.Append( tweakID, T".slotname" );
		slotName = TDB.GetCName( tweakID );
		tweakID = recordID;
		TDBID.Append( tweakID, T".isCheckInverted" );
		isCheckInverted = TDB.GetBool( tweakID );
	}

	protected export const override function OnRegister( state : PrereqState, game : GameInstance, context : IScriptable ) : Bool
	{
		var castedState : IsVehicleDoorLockedState;
		var persistentId : PersistentID;
		const var vehicle : VehicleObject;
		vehicle = ( ( VehicleObject )( context ) );
		castedState = ( ( IsVehicleDoorLockedState )( state ) );
		if( vehicle )
		{
			persistentId = CreatePersistentID( vehicle.GetEntityID(), vehicle.GetPSClassName() );
			castedState.psListener = gameScriptedPrereqPSChangeListenerWrapper.CreateListener( game, persistentId, castedState );
			return false;
		}
		return false;
	}

	protected export const override function OnUnregister( state : PrereqState, game : GameInstance, context : IScriptable )
	{
		var castedState : IsVehicleDoorLockedState;
		castedState = ( ( IsVehicleDoorLockedState )( state ) );
		castedState.psListener = NULL;
	}

	public export const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		const var player : PlayerPuppet;
		const var vehicle : VehicleObject;
		var doorEnum : EVehicleDoor;
		player = ( ( PlayerPuppet )( GameInstance.GetPlayerSystem( game ).GetLocalPlayerMainGameObject() ) );
		vehicle = ( ( VehicleObject )( context ) );
		if( player && vehicle )
		{
			vehicle.GetVehiclePS().GetVehicleDoorEnum( doorEnum, slotName );
			if( vehicle.GetVehiclePS().GetDoorInteractionState( doorEnum ) == VehicleDoorInteractionState.Locked )
			{
				return !( isCheckInverted );
			}
		}
		return isCheckInverted;
	}

}

class IsVehicleDoorQuestLockedState extends PrereqState
{
	var psListener : gameScriptedPrereqPSChangeListenerWrapper;

	protected function OnPSStateChanged()
	{
		var prereq : IsVehicleDoorQuestLocked;
		prereq = ( ( IsVehicleDoorQuestLocked )( GetPrereq() ) );
		OnChanged( prereq.IsFulfilled( GetGameInstance(), GetContext() ) );
	}

}

class IsVehicleDoorQuestLocked extends IScriptablePrereq
{
	protected var slotName : CName;
	protected var isCheckInverted : Bool;

	protected export override function Initialize( recordID : TweakDBID )
	{
		var tweakID : TweakDBID;
		tweakID = recordID;
		TDBID.Append( tweakID, T".slotname" );
		slotName = TDB.GetCName( tweakID );
		tweakID = recordID;
		TDBID.Append( tweakID, T".isCheckInverted" );
		isCheckInverted = TDB.GetBool( tweakID );
	}

	protected export const override function OnRegister( state : PrereqState, game : GameInstance, context : IScriptable ) : Bool
	{
		var castedState : IsVehicleDoorQuestLockedState;
		var persistentId : PersistentID;
		const var vehicle : VehicleObject;
		vehicle = ( ( VehicleObject )( context ) );
		castedState = ( ( IsVehicleDoorQuestLockedState )( state ) );
		if( vehicle )
		{
			persistentId = CreatePersistentID( vehicle.GetEntityID(), vehicle.GetPSClassName() );
			castedState.psListener = gameScriptedPrereqPSChangeListenerWrapper.CreateListener( game, persistentId, castedState );
			return false;
		}
		return false;
	}

	protected export const override function OnUnregister( state : PrereqState, game : GameInstance, context : IScriptable )
	{
		var castedState : IsVehicleDoorQuestLockedState;
		castedState = ( ( IsVehicleDoorQuestLockedState )( state ) );
		castedState.psListener = NULL;
	}

	public export const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		const var player : PlayerPuppet;
		const var vehicle : VehicleObject;
		var doorEnum : EVehicleDoor;
		player = ( ( PlayerPuppet )( GameInstance.GetPlayerSystem( game ).GetLocalPlayerMainGameObject() ) );
		vehicle = ( ( VehicleObject )( context ) );
		if( player && vehicle )
		{
			vehicle.GetVehiclePS().GetVehicleDoorEnum( doorEnum, slotName );
			if( vehicle.GetVehiclePS().GetDoorInteractionState( doorEnum ) == VehicleDoorInteractionState.QuestLocked )
			{
				return !( isCheckInverted );
			}
		}
		return isCheckInverted;
	}

}

class PlayerHasNanoWiresEquippedPrereq extends IScriptablePrereq
{

	public const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var playerControlledObject : GameObject;
		var weaponObj : WeaponObject;
		var friendlyName : String;
		playerControlledObject = GameInstance.GetPlayerSystem( game ).GetLocalPlayerControlledGameObject();
		weaponObj = ( ( WeaponObject )( GameInstance.GetTransactionSystem( playerControlledObject.GetGame() ).GetItemInSlot( playerControlledObject, T"AttachmentSlots.WeaponRight" ) ) );
		if( playerControlledObject && weaponObj )
		{
			friendlyName = TweakDBInterface.GetItemRecord( ItemID.GetTDBID( weaponObj.GetItemID() ) ).FriendlyName();
			if( friendlyName == "mono_wires" )
			{
				return true;
			}
		}
		return false;
	}

}

class IsMultiplayerGamePrereq extends IScriptablePrereq
{

	public const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		return IsMultiplayer();
	}

}

class PlayerHasCPOMissionDataPrereq extends IScriptablePrereq
{

	public const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var playerPuppet : PlayerPuppet;
		playerPuppet = ( ( PlayerPuppet )( context ) );
		if( playerPuppet )
		{
			return playerPuppet.HasCPOMissionData();
		}
		return false;
	}

}

class SelectedForMultiplayerChoiceDialog extends IScriptablePrereq
{

	public const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var entity : Entity;
		var factName : String;
		if( !( GameInstance.GetRuntimeInfo( game ).IsMultiplayer() ) )
		{
			return true;
		}
		else
		{
			entity = ( ( Entity )( context ) );
			factName = GameInstance.GetSceneSystem( game ).GetPeerIdDialogChoiceFactName();
			return GameInstance.GetQuestsSystem( game ).GetFactStr( factName ) == ( ( Int32 )( entity.GetControllingPeerID() ) );
		}
	}

}

class PlayerCanTakeCPOMissionDataPrereq extends InteractionScriptedCondition
{

	public const virtual function Test( const activatorObject : weak< GameObject >, const hotSpotObject : weak< GameObject >, const hotSpotLayer : weak< HotSpotLayerDefinition > ) : Bool
	{
		const var currentDataOwner : PlayerPuppet;
		const var receivingPlayer : PlayerPuppet;
		currentDataOwner = ( ( PlayerPuppet )( hotSpotObject ) );
		receivingPlayer = ( ( PlayerPuppet )( activatorObject ) );
		if( currentDataOwner && receivingPlayer )
		{
			if( ( !( currentDataOwner.m_CPOMissionDataState.m_ownerDecidesOnTransfer ) && currentDataOwner.HasCPOMissionData() ) && !( receivingPlayer.HasCPOMissionData() ) )
			{
				return true;
			}
		}
		return false;
	}

}

class PlayerCanGiveCPOMissionDataPrereq extends InteractionScriptedCondition
{

	public const virtual function Test( const activatorObject : weak< GameObject >, const hotSpotObject : weak< GameObject >, const hotSpotLayer : weak< HotSpotLayerDefinition > ) : Bool
	{
		const var currentDataOwner : PlayerPuppet;
		const var receivingPlayer : PlayerPuppet;
		currentDataOwner = ( ( PlayerPuppet )( activatorObject ) );
		receivingPlayer = ( ( PlayerPuppet )( hotSpotObject ) );
		if( currentDataOwner && receivingPlayer )
		{
			if( ( currentDataOwner.m_CPOMissionDataState.m_ownerDecidesOnTransfer && currentDataOwner.HasCPOMissionData() ) && !( receivingPlayer.HasCPOMissionData() ) )
			{
				return true;
			}
		}
		return false;
	}

}

class AccessPointHasCPOMissionDataPrereq extends IScriptablePrereq
{

	public const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var device : CPOMissionDataAccessPoint;
		device = ( ( CPOMissionDataAccessPoint )( context ) );
		if( device )
		{
			return device.HasDataToDownload();
		}
		return false;
	}

}

class AccessPointIsBlocked extends IScriptablePrereq
{

	public const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var device : CPOMissionDevice;
		device = ( ( CPOMissionDevice )( context ) );
		if( device )
		{
			return device.IsBlocked();
		}
		return false;
	}

}

class IsScannerTarget extends IScriptablePrereq
{

	public const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var object : weak< GameObject >;
		var blackBoard : IBlackboard;
		var entityID : EntityID;
		object = ( ( GameObject )( context ) );
		if( object )
		{
			blackBoard = GameInstance.GetBlackboardSystem( game ).Get( GetAllBlackboardDefs().UI_Scanner );
			entityID = blackBoard.GetEntityID( GetAllBlackboardDefs().UI_Scanner.ScannedObject );
			return entityID == object.GetEntityID();
		}
		return false;
	}

}

class AccessPointCompatibleWithUser extends InteractionScriptedCondition
{

	public const function Test( const activatorObject : weak< GameObject >, const hotSpotObject : weak< GameObject >, const hotSpotLayer : weak< HotSpotLayerDefinition > ) : Bool
	{
		const var device : CPOMissionDataAccessPoint;
		const var playerPuppet : PlayerPuppet;
		device = ( ( CPOMissionDataAccessPoint )( hotSpotObject ) );
		playerPuppet = ( ( PlayerPuppet )( activatorObject ) );
		if( device && playerPuppet )
		{
			if( device.GetCompatibleDeviceName() != '' || playerPuppet.GetCompatibleCPOMissionDeviceName() != '' )
			{
				return device.GetCompatibleDeviceName() == playerPuppet.GetCompatibleCPOMissionDeviceName();
			}
			else
			{
				return true;
			}
		}
		return false;
	}

}

class PlayerControlsDevicePrereq extends IScriptablePrereq
{
	private instanceeditable var m_inverse : Bool;
	default m_inverse = true;

	public export const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		if( m_inverse )
		{
			return !( ( ( TakeOverControlSystem )( GameInstance.GetScriptableSystemsContainer( game ).Get( 'TakeOverControlSystem' ) ) ).IsDeviceControlled() );
		}
		else
		{
			return ( ( TakeOverControlSystem )( GameInstance.GetScriptableSystemsContainer( game ).Get( 'TakeOverControlSystem' ) ) ).IsDeviceControlled();
		}
	}

	protected export override function Initialize( record : TweakDBID )
	{
		var tweakID : TweakDBID;
		tweakID = record;
		TDBID.Append( tweakID, T".invert" );
		m_inverse = TDB.GetBool( tweakID );
	}

}

class PlayerNotInBraindancePrereq extends IScriptablePrereq
{

	public export const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		return !( GameInstance.GetSceneSystem( game ).GetScriptInterface().IsRewindableSectionActive() );
	}

}

class CPOMissionPlayerVoted extends InteractionScriptedCondition
{

	public const virtual function Test( const activatorObject : weak< GameObject >, const hotSpotObject : weak< GameObject >, const hotSpotLayer : weak< HotSpotLayerDefinition > ) : Bool
	{
		const var device : CPOVotingDevice;
		const var playerPuppet : PlayerPuppet;
		device = ( ( CPOVotingDevice )( hotSpotObject ) );
		playerPuppet = ( ( PlayerPuppet )( activatorObject ) );
		if( device && playerPuppet )
		{
			if( device.GetCompatibleDeviceName() != '' )
			{
				return playerPuppet.GetCPOMissionVoted( device.GetCompatibleDeviceName() );
			}
		}
		return false;
	}

}

class CPOMissionPlayerNotVoted extends CPOMissionPlayerVoted
{

	public const override function Test( const activatorObject : weak< GameObject >, const hotSpotObject : weak< GameObject >, const hotSpotLayer : weak< HotSpotLayerDefinition > ) : Bool
	{
		return !( super.Test( activatorObject, hotSpotObject, hotSpotLayer ) );
	}

}

class PuppetMortalityListener extends ScriptStatsListener
{
	var state : PuppetMortalPrereqState;

	public export override function OnGodModeChanged( ownerID : EntityID, newType : gameGodModeType )
	{
		state.ProcessGodModeChanged( newType );
	}

}

class PuppetMortalPrereqState extends PrereqState
{
	var m_owner : weak< GameObject >;
	var m_listener : weak< PuppetMortalityListener >;

	public function ProcessGodModeChanged( newType : gameGodModeType )
	{
		var checkPassed : Bool;
		const var prereq : PuppetMortalPrereq;
		prereq = ( ( PuppetMortalPrereq )( GetPrereq() ) );
		checkPassed = prereq.Evaluate( m_owner, newType );
		OnChanged( checkPassed );
	}

}

class PuppetMortalPrereq extends IScriptablePrereq
{
	var m_invert : Bool;

	protected const override function OnRegister( state : PrereqState, game : GameInstance, context : IScriptable ) : Bool
	{
		var castedState : PuppetMortalPrereqState;
		var owner : weak< ScriptedPuppet >;
		var listener : PuppetMortalityListener;
		owner = ( ( ScriptedPuppet )( context ) );
		castedState = ( ( PuppetMortalPrereqState )( state ) );
		castedState.m_owner = ( ( GameObject )( owner ) );
		listener = new PuppetMortalityListener;
		listener.state = castedState;
		castedState.m_listener = listener;
		GameInstance.GetStatsSystem( owner.GetGame() ).RegisterListener( owner.GetEntityID(), castedState.m_listener );
		return false;
	}

	protected export const override function OnUnregister( state : PrereqState, game : GameInstance, context : IScriptable )
	{
		var owner : GameObject;
		var castedState : PuppetMortalPrereqState;
		owner = ( ( GameObject )( context ) );
		castedState = ( ( PuppetMortalPrereqState )( state ) );
		GameInstance.GetStatsSystem( game ).UnregisterListener( owner.GetEntityID(), castedState.m_listener );
		castedState.m_listener = NULL;
	}

	public const function Evaluate( owner : GameObject, godModeType : gameGodModeType ) : Bool
	{
		if( godModeType == gameGodModeType.Immortal || godModeType == gameGodModeType.Invulnerable )
		{
			return m_invert;
		}
		else
		{
			return !( m_invert );
		}
	}

	protected override function Initialize( record : TweakDBID )
	{
		var tweakID : TweakDBID;
		tweakID = record;
		TDBID.Append( tweakID, T".invert" );
		m_invert = TDB.GetBool( tweakID );
	}

	public const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var puppet : ScriptedPuppet;
		var type : gameGodModeType;
		var isGodMode : Bool;
		puppet = ( ( ScriptedPuppet )( context ) );
		if( !( puppet ) )
		{
			return ( ( m_invert ) ? ( true ) : ( false ) );
		}
		isGodMode = GetImmortality( puppet, type );
		if( !( isGodMode ) )
		{
			type = ( ( gameGodModeType )( -1 ) );
		}
		return Evaluate( puppet, type );
	}

}

