class IsPuppetBreachedPrereqState extends PrereqState
{
	var psListener : gameScriptedPrereqPSChangeListenerWrapper;

	protected function OnPSStateChanged()
	{
		var prereq : IsPuppetBreachedPrereq;
		prereq = ( ( IsPuppetBreachedPrereq )( GetPrereq() ) );
		OnChanged( prereq.IsFulfilled( GetGameInstance(), GetContext() ) );
	}

}

class IsPuppetBreachedPrereq extends IScriptablePrereq
{
	private var m_isBreached : Bool;

	protected export override function Initialize( recordID : TweakDBID )
	{
		m_isBreached = TweakDBInterface.GetBool( recordID + T".isBreached", false );
	}

	protected const override function OnRegister( state : PrereqState, game : GameInstance, context : IScriptable ) : Bool
	{
		var castedState : IsPuppetBreachedPrereqState;
		var puppet : ScriptedPuppet;
		var persistentId : PersistentID;
		puppet = ( ( ScriptedPuppet )( context ) );
		castedState = ( ( IsPuppetBreachedPrereqState )( state ) );
		if( puppet )
		{
			persistentId = CreatePersistentID( puppet.GetEntityID(), puppet.GetPSClassName() );
			castedState.psListener = gameScriptedPrereqPSChangeListenerWrapper.CreateListener( game, persistentId, castedState );
			return false;
		}
		return false;
	}

	protected const override function OnUnregister( state : PrereqState, game : GameInstance, context : IScriptable )
	{
		var castedState : IsPuppetBreachedPrereqState;
		castedState = ( ( IsPuppetBreachedPrereqState )( state ) );
		castedState.psListener = NULL;
	}

	public const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var owner : GameObject;
		var targetPuppet : ScriptedPuppet;
		owner = ( ( GameObject )( context ) );
		targetPuppet = ( ( ScriptedPuppet )( owner ) );
		if( m_isBreached )
		{
			if( targetPuppet.IsBreached() )
			{
				return true;
			}
		}
		else
		{
			if( !( targetPuppet.IsBreached() ) )
			{
				return true;
			}
		}
		return false;
	}

}

