abstract class ReactionTransition extends DefaultTransition
{

	protected function DrawDebugText( scriptInterface : StateGameScriptInterface, out textLayerId : Uint32, const text : ref< String > )
	{
		textLayerId = GameInstance.GetDebugVisualizerSystem( scriptInterface.owner.GetGame() ).DrawText( Vector4( 500.0, 550.0, 0.0, 0.0 ), text, gameDebugViewETextAlignment.Left, Color( 255, 255, 0, 255 ) );
		GameInstance.GetDebugVisualizerSystem( scriptInterface.owner.GetGame() ).SetScale( textLayerId, Vector4( 1.0, 1.0, 0.0, 0.0 ) );
	}

	protected function ClearDebugText( scriptInterface : StateGameScriptInterface, textLayerId : Uint32 )
	{
		GameInstance.GetDebugVisualizerSystem( scriptInterface.owner.GetGame() ).ClearLayer( textLayerId );
	}

}

class StaggerDecisions extends ReactionTransition
{
	var m_textLayerId : Uint32;

	public const function EnterCondition( const stateContext : StateContext, const scriptInterface : StateGameScriptInterface ) : Bool
	{
		return GameInstance.GetStatusEffectSystem( scriptInterface.owner.GetGame() ).HasStatusEffect( scriptInterface.ownerEntityID, T"BaseStatusEffect.Stunned" );
	}

	public const function ExitCondition( const stateContext : StateContext, const scriptInterface : StateGameScriptInterface ) : Bool
	{
		return !( GameInstance.GetStatusEffectSystem( scriptInterface.owner.GetGame() ).HasStatusEffect( scriptInterface.ownerEntityID, T"BaseStatusEffect.Stunned" ) );
	}

}

class Stagger extends ReactionTransition
{
	var m_textLayerId : Uint32;

	protected function AddImpulse( scriptInterface : StateGameScriptInterface )
	{
		var direction : Vector4;
		var ev : PSMImpulse;
		var impulseDir : Vector4;
		direction = scriptInterface.GetOwnerMovingDirection();
		direction.Z = 0.0;
		direction *= -1.0;
		impulseDir = direction * GetStaticFloatParameterDefault( "moveBackImpulse", 10.0 );
		ev = new PSMImpulse;
		ev.id = 'impulse';
		ev.impulse = impulseDir;
		scriptInterface.executionOwner.QueueEvent( ev );
	}

	public function OnEnter( stateContext : StateContext, scriptInterface : StateGameScriptInterface )
	{
		AddImpulse( scriptInterface );
		StartEffect( scriptInterface, 'skif_buff' );
		scriptInterface.SetAnimationParameterFloat( 'hit_strength', 1.0 );
		scriptInterface.PushAnimationEvent( 'StaggerHit' );
		DrawDebugText( scriptInterface, m_textLayerId, "PLAYER STAGGER" );
		SetBlackboardIntVariable( scriptInterface, GetAllBlackboardDefs().PlayerStateMachine.Reaction, ( ( Int32 )( gamePSMReaction.Stagger ) ) );
	}

	public function OnExit( stateContext : StateContext, scriptInterface : StateGameScriptInterface )
	{
		ClearDebugText( scriptInterface, m_textLayerId );
		SetBlackboardIntVariable( scriptInterface, GetAllBlackboardDefs().PlayerStateMachine.Reaction, ( ( Int32 )( gamePSMReaction.Default ) ) );
	}

}

