class WoundedTriggeredPrereqState extends PrereqState
{
	var m_owner : weak< GameObject >;
	var m_listenerInt : CallbackHandle;

	protected event OnStateUpdate( value : Uint32 )
	{
		var checkPassed : Bool;
		const var prereq : WoundedTriggeredPrereq;
		prereq = ( ( WoundedTriggeredPrereq )( GetPrereq() ) );
		checkPassed = prereq.Evaluate( m_owner, value );
		OnChanged( checkPassed );
	}

}

class WoundedTriggeredPrereq extends IScriptablePrereq
{
	var m_currValue : Uint32;
	default m_currValue = 0;

	public const function Evaluate( owner : GameObject, value : Uint32 ) : Bool
	{
		var checkPassed : Bool;
		checkPassed = value != m_currValue;
		return checkPassed;
	}

	protected const override function OnRegister( state : PrereqState, game : GameInstance, context : IScriptable ) : Bool
	{
		var bb : IBlackboard;
		var castedState : WoundedTriggeredPrereqState;
		var player : weak< PlayerPuppet >;
		castedState = ( ( WoundedTriggeredPrereqState )( state ) );
		castedState.m_owner = ( ( GameObject )( context ) );
		player = ( ( PlayerPuppet )( context ) );
		if( player )
		{
			bb = GameInstance.GetBlackboardSystem( player.GetGame() ).Get( GetAllBlackboardDefs().PlayerPerkData );
			castedState.m_listenerInt = bb.RegisterListenerUint( GetAllBlackboardDefs().PlayerPerkData.WoundedInstigated, castedState, 'OnStateUpdate' );
		}
		return false;
	}

	protected const override function OnUnregister( state : PrereqState, game : GameInstance, context : IScriptable )
	{
		var bb : IBlackboard;
		var castedState : WoundedTriggeredPrereqState;
		var player : weak< PlayerPuppet >;
		player = ( ( PlayerPuppet )( context ) );
		if( player )
		{
			bb = GameInstance.GetBlackboardSystem( player.GetGame() ).Get( GetAllBlackboardDefs().PlayerPerkData );
			castedState = ( ( WoundedTriggeredPrereqState )( state ) );
			bb.UnregisterListenerUint( GetAllBlackboardDefs().PlayerPerkData.WoundedInstigated, castedState.m_listenerInt );
		}
	}

	protected const override function OnApplied( state : PrereqState, game : GameInstance, context : IScriptable )
	{
		var player : weak< PlayerPuppet >;
		var castedState : WoundedTriggeredPrereqState;
		var bb : IBlackboard;
		player = ( ( PlayerPuppet )( context ) );
		if( player )
		{
			bb = GameInstance.GetBlackboardSystem( player.GetGame() ).Get( GetAllBlackboardDefs().PlayerPerkData );
			castedState = ( ( WoundedTriggeredPrereqState )( state ) );
			castedState.OnChanged( Evaluate( player, bb.GetUint( GetAllBlackboardDefs().PlayerPerkData.WoundedInstigated ) ) );
		}
	}

}

