class LeaveCoverImmediately extends AIbehaviortaskScript
{
	editable var m_delay : Float;
	editable var m_completeOnLeave : Bool;
	var m_timeStamp : Float;
	var m_triggered : Bool;

	protected export override function Activate( context : ScriptExecutionContext )
	{
		m_triggered = false;
		m_timeStamp = EngineTime.ToFloat( ScriptExecutionContext.GetAITime( context ) );
		if( m_delay == 0.0 )
		{
			AICoverHelper.LeaveCoverImmediately( GetPuppet( context ) );
		}
		if( m_delay <= 0.0 )
		{
			SetUpdateInterval( context, 999999.0 );
		}
	}

	protected export override function Update( context : ScriptExecutionContext ) : AIbehaviorUpdateOutcome
	{
		if( ( !( m_triggered ) && ( m_delay > 0.0 ) ) && ( ( m_delay + m_timeStamp ) >= EngineTime.ToFloat( ScriptExecutionContext.GetAITime( context ) ) ) )
		{
			m_triggered = true;
			AICoverHelper.LeaveCoverImmediately( GetPuppet( context ) );
			if( m_completeOnLeave )
			{
				return AIbehaviorUpdateOutcome.SUCCESS;
			}
		}
		return AIbehaviorUpdateOutcome.IN_PROGRESS;
	}

	protected export override function Deactivate( context : ScriptExecutionContext )
	{
		if( m_delay < 0.0 )
		{
			AICoverHelper.LeaveCoverImmediately( GetPuppet( context ) );
		}
	}

}

