class AICommandHandlerBase extends AIbehaviortaskScript
{
	protected editable inlined var m_inCommand : AIArgumentMapping;

	protected export override function Update( context : ScriptExecutionContext ) : AIbehaviorUpdateOutcome
	{
		var rawCommand : IScriptable;
		var typedCommand : AICommand;
		if( !( m_inCommand ) )
		{
			return AIbehaviorUpdateOutcome.FAILURE;
		}
		rawCommand = ScriptExecutionContext.GetScriptableMappingValue( context, m_inCommand );
		if( !( rawCommand ) )
		{
			return AIbehaviorUpdateOutcome.FAILURE;
		}
		typedCommand = ( ( AICommand )( rawCommand ) );
		if( !( typedCommand ) )
		{
			return AIbehaviorUpdateOutcome.FAILURE;
		}
		return UpdateCommand( context, typedCommand );
	}

	protected virtual function UpdateCommand( context : ScriptExecutionContext, command : AICommand ) : AIbehaviorUpdateOutcome
	{
		return AIbehaviorUpdateOutcome.FAILURE;
	}

	protected function CheckArgument( argument : AIArgumentMapping, argName : CName ) : Bool
	{
		if( !( argument ) )
		{
			return false;
		}
		return true;
	}

}

class CommandCleanup extends AIbehaviortaskScript
{
	protected editable inlined var m_inCommand : AIArgumentMapping;

	private export override final function Deactivate( context : ScriptExecutionContext )
	{
		ScriptExecutionContext.SetMappingValue( context, m_inCommand, NULL );
	}

}

class CompleteCommand extends AIbehaviortaskScript
{
	protected editable inlined var m_inCommand : AIArgumentMapping;

	private override final function Deactivate( context : ScriptExecutionContext )
	{
		var rawCommand : IScriptable;
		var typedCommand : AICommand;
		rawCommand = ScriptExecutionContext.GetScriptableMappingValue( context, m_inCommand );
		typedCommand = ( ( AICommand )( rawCommand ) );
		if( typedCommand && typedCommand.state == AICommandState.Executing )
		{
			GetPuppet( context ).GetAIControllerComponent().StopExecutingCommand( typedCommand, true );
		}
	}

}

