class FollowerFindTeleportPositionRightBehindTarget extends AIbehaviortaskScript
{
	editable inlined var m_target : AIArgumentMapping;
	editable inlined var m_outPositionArgument : AIArgumentMapping;
	private var m_lastResultTimestamp : Float;

	protected export override function Update( context : ScriptExecutionContext ) : AIbehaviorUpdateOutcome
	{
		var followTarget : weak< GameObject >;
		var telportPosition : Vector4;
		var navigationSystem : AINavigationSystem;
		var movePoliciesComponent : MovePoliciesComponent;
		var ratioCurveName : CName;
		followTarget = ( ( weak< weak< GameObject > > )( ScriptExecutionContext.GetMappingValue( context, m_target ) ) );
		navigationSystem = GameInstance.GetAINavigationSystem( ScriptExecutionContext.GetOwner( context ).GetGame() );
		if( !( navigationSystem ) )
		{
			return AIbehaviorUpdateOutcome.FAILURE;
		}
		if( !( navigationSystem.IsPointOnNavmesh( ScriptExecutionContext.GetOwner( context ), followTarget.GetWorldPosition() ) ) )
		{
			m_lastResultTimestamp = EngineTime.ToFloat( ScriptExecutionContext.GetAITime( context ) );
			return AIbehaviorUpdateOutcome.IN_PROGRESS;
		}
		movePoliciesComponent = ( ( ScriptedPuppet )( ScriptExecutionContext.GetOwner( context ) ) ).GetMovePolicesComponent();
		if( movePoliciesComponent && movePoliciesComponent.GetTopPolicies() )
		{
			ratioCurveName = movePoliciesComponent.GetTopPolicies().GetMaxPathLengthToDirectDistanceRatioCurve();
		}
		if( !( navigationSystem.GetFurthestNavmeshPointBehind( followTarget, 3.0, 1, telportPosition, followTarget.GetWorldForward() * 5.5, true, ratioCurveName ) ) )
		{
			m_lastResultTimestamp = EngineTime.ToFloat( ScriptExecutionContext.GetAITime( context ) );
			return AIbehaviorUpdateOutcome.IN_PROGRESS;
		}
		ScriptExecutionContext.SetMappingValue( context, m_outPositionArgument, telportPosition );
		m_lastResultTimestamp = EngineTime.ToFloat( ScriptExecutionContext.GetAITime( context ) );
		return AIbehaviorUpdateOutcome.SUCCESS;
	}

}

