abstract class AINPCStateCheck extends AIbehaviorconditionScript
{
}

abstract class AINPCHighLevelStateCheck extends AINPCStateCheck
{
	var m_blackboard : weak< IBlackboard >;

	private virtual function GetStateToCheck() : gamedataNPCHighLevelState
	{
		return gamedataNPCHighLevelState.Relaxed;
	}

	private export override function Activate( context : ScriptExecutionContext )
	{
		if( !( m_blackboard ) )
		{
			m_blackboard = GetPuppet( context ).GetPuppetStateBlackboard();
		}
	}

	protected export override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		return GetStateToCheck() == ( ( gamedataNPCHighLevelState )( m_blackboard.GetInt( GetAllBlackboardDefs().PuppetState.HighLevel ) ) );
	}

}

class AINPCPreviousHighLevelStateCheck extends AINPCStateCheck
{

	private virtual function GetStateToCheck() : gamedataNPCHighLevelState
	{
		return gamedataNPCHighLevelState.Relaxed;
	}

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		var puppet : ScriptedPuppet;
		puppet = GetPuppet( context );
		return puppet.GetStatesComponent().GetPreviousHighLevelState() == GetStateToCheck();
	}

}

class IsDead extends AIbehaviorconditionScript
{
	var m_statPoolsSystem : StatPoolsSystem;
	var m_entityID : EntityID;

	private export override function Activate( context : ScriptExecutionContext )
	{
		if( !( m_statPoolsSystem ) )
		{
			m_statPoolsSystem = GameInstance.GetStatPoolsSystem( ScriptExecutionContext.GetOwner( context ).GetGame() );
			m_entityID = ScriptExecutionContext.GetOwner( context ).GetEntityID();
		}
	}

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		return m_statPoolsSystem.HasStatPoolValueReachedMin( m_entityID, gamedataStatPoolType.Health );
	}

}

class IsRagdolling extends AIbehaviorconditionScript
{
	var m_npc : weak< NPCPuppet >;

	private override function Activate( context : ScriptExecutionContext )
	{
		if( !( m_npc ) )
		{
			m_npc = ( ( weak< weak< NPCPuppet > > )( ScriptExecutionContext.GetOwner( context ) ) );
		}
	}

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		return m_npc.IsRagdolling();
	}

}

class CheckHighLevelState extends AINPCHighLevelStateCheck
{
	editable var m_state : gamedataNPCHighLevelState;

	private override function GetStateToCheck() : gamedataNPCHighLevelState
	{
		return m_state;
	}

}

class InRelaxedHighLevelState extends AINPCHighLevelStateCheck
{

	private override function GetStateToCheck() : gamedataNPCHighLevelState
	{
		return gamedataNPCHighLevelState.Relaxed;
	}

}

class InAlertedHighLevelState extends AINPCHighLevelStateCheck
{

	private override function GetStateToCheck() : gamedataNPCHighLevelState
	{
		return gamedataNPCHighLevelState.Alerted;
	}

}

class InCombatHighLevelState extends AINPCHighLevelStateCheck
{

	private override function GetStateToCheck() : gamedataNPCHighLevelState
	{
		return gamedataNPCHighLevelState.Combat;
	}

}

class InStealthHighLevelState extends AINPCHighLevelStateCheck
{

	private override function GetStateToCheck() : gamedataNPCHighLevelState
	{
		return gamedataNPCHighLevelState.Stealth;
	}

}

class InUnconsciousHighLevelState extends AINPCHighLevelStateCheck
{

	private override function GetStateToCheck() : gamedataNPCHighLevelState
	{
		return gamedataNPCHighLevelState.Unconscious;
	}

}

class InDeadHighLevelState extends AINPCHighLevelStateCheck
{

	private override function GetStateToCheck() : gamedataNPCHighLevelState
	{
		return gamedataNPCHighLevelState.Dead;
	}

}

class CheckPreviousHighLevelState extends AINPCPreviousHighLevelStateCheck
{
	editable var m_state : gamedataNPCHighLevelState;

	private override function GetStateToCheck() : gamedataNPCHighLevelState
	{
		return m_state;
	}

}

abstract class AINPCUpperBodyStateCheck extends AINPCStateCheck
{
	var m_blackboard : weak< IBlackboard >;

	private virtual function GetStateToCheck() : gamedataNPCUpperBodyState
	{
		return gamedataNPCUpperBodyState.Normal;
	}

	private override function Activate( context : ScriptExecutionContext )
	{
		if( !( m_blackboard ) )
		{
			m_blackboard = GetPuppet( context ).GetPuppetStateBlackboard();
		}
	}

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		return GetStateToCheck() == ( ( gamedataNPCUpperBodyState )( m_blackboard.GetInt( GetAllBlackboardDefs().PuppetState.UpperBody ) ) );
	}

}

class CheckUpperBodyState extends AINPCUpperBodyStateCheck
{
	editable var m_state : gamedataNPCUpperBodyState;

	private override function GetStateToCheck() : gamedataNPCUpperBodyState
	{
		return m_state;
	}

}

class InNormalUpperBodyState extends AINPCUpperBodyStateCheck
{

	private override function GetStateToCheck() : gamedataNPCUpperBodyState
	{
		return gamedataNPCUpperBodyState.Normal;
	}

}

class InShootUpperBodyState extends AINPCUpperBodyStateCheck
{

	private override function GetStateToCheck() : gamedataNPCUpperBodyState
	{
		return gamedataNPCUpperBodyState.Shoot;
	}

}

class InReloadUpperBodyState extends AINPCUpperBodyStateCheck
{

	private override function GetStateToCheck() : gamedataNPCUpperBodyState
	{
		return gamedataNPCUpperBodyState.Reload;
	}

}

class InDefendUpperBodyState extends AINPCUpperBodyStateCheck
{

	private override function GetStateToCheck() : gamedataNPCUpperBodyState
	{
		return gamedataNPCUpperBodyState.Defend;
	}

}

class InAttackUpperBodyState extends AINPCUpperBodyStateCheck
{

	private override function GetStateToCheck() : gamedataNPCUpperBodyState
	{
		return gamedataNPCUpperBodyState.Attack;
	}

}

class InParryUpperBodyState extends AINPCUpperBodyStateCheck
{

	private override function GetStateToCheck() : gamedataNPCUpperBodyState
	{
		return gamedataNPCUpperBodyState.Parry;
	}

}

class InTauntUpperBodyState extends AINPCUpperBodyStateCheck
{

	private override function GetStateToCheck() : gamedataNPCUpperBodyState
	{
		return gamedataNPCUpperBodyState.Taunt;
	}

}

abstract class AINPCStanceStateCheck extends AINPCStateCheck
{
	var m_blackboard : weak< IBlackboard >;

	private virtual function GetStateToCheck() : gamedataNPCStanceState
	{
		return gamedataNPCStanceState.Stand;
	}

	private override function Activate( context : ScriptExecutionContext )
	{
		if( !( m_blackboard ) )
		{
			m_blackboard = GetPuppet( context ).GetPuppetStateBlackboard();
		}
	}

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		return GetStateToCheck() == ( ( gamedataNPCStanceState )( m_blackboard.GetInt( GetAllBlackboardDefs().PuppetState.Stance ) ) );
	}

}

class CheckStanceState extends AINPCStanceStateCheck
{
	editable var m_state : gamedataNPCStanceState;

	private override function GetStateToCheck() : gamedataNPCStanceState
	{
		return m_state;
	}

}

class InStandStanceState extends AINPCStanceStateCheck
{

	private override function GetStateToCheck() : gamedataNPCStanceState
	{
		return gamedataNPCStanceState.Stand;
	}

}

class InCrouchStanceState extends AINPCStanceStateCheck
{

	private override function GetStateToCheck() : gamedataNPCStanceState
	{
		return gamedataNPCStanceState.Crouch;
	}

}

class InCoverStanceState extends AINPCStanceStateCheck
{

	private override function GetStateToCheck() : gamedataNPCStanceState
	{
		return gamedataNPCStanceState.Cover;
	}

}

class InSwimStanceState extends AINPCStanceStateCheck
{

	private override function GetStateToCheck() : gamedataNPCStanceState
	{
		return gamedataNPCStanceState.Swim;
	}

}

class IsCrowdNPC extends AIbehaviorconditionScript
{

	protected export override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		return GetPuppet( context ).IsCrowd();
	}

}

class IsAggressiveCrowd extends AIbehaviorconditionScript
{
	var m_reactionSystem : ReactionSystem;
	var m_entityID : EntityID;
	var m_npc : weak< NPCPuppet >;

	private export override function Activate( context : ScriptExecutionContext )
	{
		if( !( m_reactionSystem ) )
		{
			m_npc = ( ( weak< weak< NPCPuppet > > )( ScriptExecutionContext.GetOwner( context ) ) );
			m_entityID = m_npc.GetEntityID();
			m_reactionSystem = GameInstance.GetReactionSystem( m_npc.GetGame() );
		}
	}

	protected export override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		if( m_reactionSystem.IsRegisteredAsAggressive( m_entityID ) )
		{
			return true;
		}
		if( m_npc.GetWasAggressiveCrowd() )
		{
			return true;
		}
		return false;
	}

}

class WasNPCForcedToJoinCrowd extends AIbehaviorconditionScript
{

	protected export override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		return GetAIComponent( context ).WasForcedToEnterCrowd();
	}

}

