abstract class SquadTask extends AIbehaviortaskScript
{
}

class CallOffReactionAction extends SquadTask
{
	editable var m_squadActionName : EAISquadAction;

	protected override function Activate( context : ScriptExecutionContext )
	{
		var i : Int32;
		var members : array< weak< Entity > >;
		var member : ScriptedPuppet;
		var smi : SquadScriptInterface;
		var stimTarget : GameObject;
		var callOffEvent : AIEvent;
		stimTarget = ScriptExecutionContext.GetArgumentObject( context, 'StimTarget' );
		if( !( stimTarget ) || !( AISquadHelper.GetSquadMemberInterface( GetPuppet( context ), smi ) ) )
		{
			return;
		}
		members = smi.ListMembersWeak();
		for( i = 0; i < members.Size(); i += 1 )
		{
			member = ( ( ScriptedPuppet )( members[ i ] ) );
			if( member == GetPuppet( context ) )
			{
				continue;
			}
			if( member.GetHighLevelStateFromBlackboard() != gamedataNPCHighLevelState.Alerted )
			{
				continue;
			}
			if( !( ScriptedPuppet.IsActive( member ) ) )
			{
				continue;
			}
			if( ( member.GetStimReactionComponent().GetActiveReactionData().stimTarget == stimTarget ) && smi.HasOrderBySquadAction( EnumValueToName( 'EAISquadAction', ( ( Int32 )( m_squadActionName ) ) ), members[ i ] ) )
			{
				callOffEvent = new AIEvent;
				callOffEvent.name = 'ExitReaction';
				member.QueueEvent( callOffEvent );
			}
		}
	}

}

class SquadAlertedSync extends SquadTask
{

	protected export override function Activate( context : ScriptExecutionContext )
	{
		var members : array< Entity >;
		var psi : PuppetSquadInterface;
		var count, i : Int32;
		AISquadHelper.GetSquadBaseInterface( ScriptExecutionContext.GetOwner( context ), psi );
		members = psi.ListMembers();
		members.Remove( ScriptExecutionContext.GetOwner( context ) );
		count = members.Size();
		for( i = 0; i < count; i += 1 )
		{
			if( ( ( ScriptedPuppet )( members[ i ] ) ).GetHighLevelStateFromBlackboard() == gamedataNPCHighLevelState.Relaxed )
			{
				NPCPuppet.ChangeHighLevelState( ( ( GameObject )( members[ i ] ) ), gamedataNPCHighLevelState.Alerted );
			}
		}
	}

}

