abstract class AIDeathConditions extends AIbehaviorconditionScript
{
}

class GlobalDeathCondition extends AIDeathConditions
{

	protected export override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		if( GetPuppet( context ) )
		{
			if( GetPuppet( context ).GetHighLevelStateFromBlackboard() == gamedataNPCHighLevelState.Dead )
			{
				return false;
			}
			return GameInstance.GetStatPoolsSystem( GetGame( context ) ).HasStatPoolValueReachedMin( ScriptExecutionContext.GetOwner( context ).GetEntityID(), gamedataStatPoolType.Health );
		}
		else
		{
			return false;
		}
	}

}

class PassiveGlobalDeathCondition extends AIbehaviorexpressionScript
{
	protected var m_onDeathCbId : Uint32;

	protected export function Activate( context : ScriptExecutionContext )
	{
		m_onDeathCbId = ScriptExecutionContext.AddBehaviorCallback( context, 'OnDeath', this );
	}

	protected export function Deactivate( context : ScriptExecutionContext )
	{
		ScriptExecutionContext.RemoveBehaviorCallback( context, m_onDeathCbId );
	}

	protected export function CalculateValue( context : ScriptExecutionContext ) : Variant
	{
		var puppet : ScriptedPuppet;
		puppet = ( ( ScriptedPuppet )( ScriptExecutionContext.GetOwner( context ) ) );
		if( !( puppet ) )
		{
			return false;
		}
		if( puppet.GetHighLevelStateFromBlackboard() == gamedataNPCHighLevelState.Dead )
		{
			return false;
		}
		if( puppet.GetHitReactionComponent().GetDeathStimName() == 'Death' )
		{
			return false;
		}
		return GameInstance.GetStatPoolsSystem( GetGame( context ) ).HasStatPoolValueReachedMin( puppet.GetEntityID(), gamedataStatPoolType.Health );
	}

}

class DeathWithoutRagdollCondition extends AIDeathConditions
{

	protected override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		if( ( ( gamedataNPCStanceState )( GetPuppet( context ).GetPuppetStateBlackboard().GetInt( GetAllBlackboardDefs().PuppetState.Stance ) ) ) == gamedataNPCStanceState.Vehicle )
		{
			return true;
		}
		return false;
	}

}

class DeathWithoutAnimationCondition extends AIDeathConditions
{

	protected export override function Check( context : ScriptExecutionContext ) : AIbehaviorConditionOutcomes
	{
		var npc : NPCPuppet;
		npc = ( ( NPCPuppet )( ScriptExecutionContext.GetOwner( context ) ) );
		if( npc && npc.ShouldSkipDeathAnimation() )
		{
			return true;
		}
		return false;
	}

}

