class LocomotionBraindance extends LocomotionTransition
{

	protected const function CanEnterFastFlying( const stateContext : StateContext, const scriptInterface : StateGameScriptInterface ) : Bool
	{
		var minLinearVelocityThreshold : Float;
		var minStickInputThreshold : Float;
		var enterAngleThreshold : Float;
		minLinearVelocityThreshold = GetStaticFloatParameterDefault( "minLinearVelocityThreshold", 0.5 );
		minStickInputThreshold = GetStaticFloatParameterDefault( "minStickInputThreshold", 0.89999998 );
		enterAngleThreshold = GetStaticFloatParameterDefault( "enterAngleThreshold", -180.0 );
		if( !( scriptInterface.HasStatFlag( gamedataStatType.CanSprint ) ) )
		{
			return false;
		}
		if( ( ( !( scriptInterface.IsMoveInputConsiderable() ) || ( AbsF( scriptInterface.GetInputHeading() ) > enterAngleThreshold ) ) || ( GetMovementInputActionValue( stateContext, scriptInterface ) <= minStickInputThreshold ) ) || ( scriptInterface.GetOwnerStateVectorParameterFloat( physicsStateValue.LinearSpeed ) < minLinearVelocityThreshold ) )
		{
			stateContext.SetConditionBoolParameter( 'SprintToggled', false, true );
			return false;
		}
		if( stateContext.GetConditionBool( 'SprintToggled' ) )
		{
			return true;
		}
		if( scriptInterface.GetActionValue( 'ToggleSprint' ) > 0.0 )
		{
			stateContext.SetConditionBoolParameter( 'SprintToggled', true, true );
		}
		if( scriptInterface.GetActionValue( 'Sprint' ) > 0.0 )
		{
			return true;
		}
		return false;
	}

	protected export function OnDetach( const stateContext : StateContext, scriptInterface : StateGameScriptInterface )
	{
		scriptInterface.SetAnimationParameterFloat( 'crouch', 0.0 );
	}

}

class LocomotionBraindanceEvents extends LocomotionEventsTransition
{

	public export override function OnForcedExit( stateContext : StateContext, scriptInterface : StateGameScriptInterface ) {}

	public override function SetLocomotionParameters( stateContext : StateContext, scriptInterface : StateGameScriptInterface ) : LocomotionParameters
	{
		var locomotionParameters : LocomotionBraindanceParameters;
		var transform : Transform;
		SetModifierGroupForState( scriptInterface );
		locomotionParameters = new LocomotionBraindanceParameters;
		GetStateDefaultLocomotionParameters( ( ( LocomotionParameters )( locomotionParameters ) ) );
		transform = scriptInterface.GetOwnerTransform();
		locomotionParameters.SetUpperMovementLimit( transform.position.Z + GetStaticFloatParameterDefault( "upperMovementLimit", 2.0 ) );
		locomotionParameters.SetLowerMovementLimit( transform.position.Z + GetStaticFloatParameterDefault( "lowerMovementLimit", -2.0 ) );
		stateContext.SetTemporaryScriptableParameter( 'locomotionParameters', locomotionParameters, true );
		return locomotionParameters;
	}

	public function EnableBraindanceCollisionFilter( scriptInterface : StateGameScriptInterface )
	{
		var simulationFilter : SimulationFilter;
		SimulationFilter.SimulationFilter_BuildFromPreset( simulationFilter, 'NPC Collision' );
		scriptInterface.SetStateVectorParameter( physicsStateValue.SimulationFilter, simulationFilter );
	}

}

class BraindanceFlyDecisions extends LocomotionBraindance
{

	protected const function EnterCondition( const stateContext : StateContext, const scriptInterface : StateGameScriptInterface ) : Bool
	{
		return !( CanEnterFastFlying( stateContext, scriptInterface ) );
	}

}

class BraindanceFlyEvents extends LocomotionBraindanceEvents
{

	protected export override function OnUpdate( timeDelta : Float, stateContext : StateContext, scriptInterface : StateGameScriptInterface ) {}

	public export override function OnEnter( stateContext : StateContext, scriptInterface : StateGameScriptInterface )
	{
		super.OnEnter( stateContext, scriptInterface );
		EnableBraindanceCollisionFilter( scriptInterface );
		scriptInterface.SetAnimationParameterFloat( 'crouch', 1.0 );
	}

	public override function OnExit( stateContext : StateContext, scriptInterface : StateGameScriptInterface )
	{
		scriptInterface.SetAnimationParameterFloat( 'crouch', 0.0 );
		SetCollisionFilter( scriptInterface );
		super.OnExit( stateContext, scriptInterface );
	}

}

class BraindanceFastFlyDecisions extends LocomotionBraindance
{

	protected export const function EnterCondition( const stateContext : StateContext, const scriptInterface : StateGameScriptInterface ) : Bool
	{
		return CanEnterFastFlying( stateContext, scriptInterface );
	}

}

class BraindanceFastFlyEvents extends LocomotionBraindanceEvents
{

	protected override function OnUpdate( timeDelta : Float, stateContext : StateContext, scriptInterface : StateGameScriptInterface ) {}

	public override function OnEnter( stateContext : StateContext, scriptInterface : StateGameScriptInterface )
	{
		super.OnEnter( stateContext, scriptInterface );
		EnableBraindanceCollisionFilter( scriptInterface );
		scriptInterface.SetAnimationParameterFloat( 'crouch', 1.0 );
	}

	public override function OnExit( stateContext : StateContext, scriptInterface : StateGameScriptInterface )
	{
		scriptInterface.SetAnimationParameterFloat( 'crouch', 0.0 );
		SetCollisionFilter( scriptInterface );
		super.OnExit( stateContext, scriptInterface );
	}

}

