class AssignRestrictMovementAreaTask extends AIbehaviortaskScript
{
	editable inlined var m_restrictMovementAreaRef : AIArgumentMapping;

	protected override function Update( context : ScriptExecutionContext ) : AIbehaviorUpdateOutcome
	{
		var gam : RestrictMovementAreaManager;
		var restrictMovementArea : NodeRef;
		gam = GameInstance.GetRestrictMovementAreaManager( GetGame( context ) );
		if( !( gam ) )
		{
			return AIbehaviorUpdateOutcome.FAILURE;
		}
		if( !( m_restrictMovementAreaRef ) )
		{
			return AIbehaviorUpdateOutcome.FAILURE;
		}
		restrictMovementArea = ( ( NodeRef )( ScriptExecutionContext.GetMappingValue( context, m_restrictMovementAreaRef ) ) );
		if( gam.AssignRestrictMovementArea( GetPuppet( context ).GetEntityID(), restrictMovementArea ) )
		{
			return AIbehaviorUpdateOutcome.SUCCESS;
		}
		return AIbehaviorUpdateOutcome.FAILURE;
	}

}

class AssignRestrictMovementAreaHandler extends AIbehaviortaskScript
{
	editable inlined var m_inCommand : AIArgumentMapping;
	editable inlined var m_resultOnNoChange : AIbehaviorCompletionStatus;
	default m_resultOnNoChange = AIbehaviorCompletionStatus.FAILURE;

	protected override function Update( context : ScriptExecutionContext ) : AIbehaviorUpdateOutcome
	{
		var rawCommand : IScriptable;
		var typedCommand : AIAssignRestrictMovementAreaCommand;
		var gam : RestrictMovementAreaManager;
		var restrictMovementArea : NodeRef;
		if( !( m_inCommand ) )
		{
			return AIbehaviorUpdateOutcome.FAILURE;
		}
		rawCommand = ScriptExecutionContext.GetScriptableMappingValue( context, m_inCommand );
		typedCommand = ( ( AIAssignRestrictMovementAreaCommand )( rawCommand ) );
		if( !( typedCommand ) )
		{
			return AIbehaviorUpdateOutcome.FAILURE;
		}
		restrictMovementArea = typedCommand.restrictMovementAreaRef;
		gam = GameInstance.GetRestrictMovementAreaManager( GetGame( context ) );
		if( !( gam ) )
		{
			return AIbehaviorUpdateOutcome.FAILURE;
		}
		if( !( gam.AssignRestrictMovementArea( GetPuppet( context ).GetEntityID(), restrictMovementArea ) ) )
		{
			if( m_resultOnNoChange == AIbehaviorCompletionStatus.SUCCESS )
			{
				return AIbehaviorUpdateOutcome.SUCCESS;
			}
			return AIbehaviorUpdateOutcome.FAILURE;
		}
		return AIbehaviorUpdateOutcome.SUCCESS;
	}

}

