class NPCInScenePrereqState extends PrereqState
{
	var sceneListener : gameScriptedPrereqSceneInspectionListenerWrapper;

	protected export function OnSceneInspectionStateChanged( isEntityInScene : Bool )
	{
		var prereq : NPCInScenePrereq;
		prereq = ( ( NPCInScenePrereq )( GetPrereq() ) );
		OnChanged( prereq.Evaluate( isEntityInScene ) );
	}

}

class NPCInScenePrereq extends IScriptablePrereq
{
	var m_invert : Bool;

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

	protected export const override function OnRegister( state : PrereqState, game : GameInstance, context : IScriptable ) : Bool
	{
		var castedState : NPCInScenePrereqState;
		var puppet : ScriptedPuppet;
		puppet = ( ( ScriptedPuppet )( context ) );
		castedState = ( ( NPCInScenePrereqState )( state ) );
		if( puppet )
		{
			castedState.sceneListener = gameScriptedPrereqSceneInspectionListenerWrapper.CreateEntityListener( game, puppet.GetEntityID(), castedState );
			return false;
		}
		return false;
	}

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

	public export const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var targetPuppet : ScriptedPuppet;
		targetPuppet = ( ( ScriptedPuppet )( context ) );
		return Evaluate( GameInstance.GetSceneSystem( game ).GetScriptInterface().IsEntityInScene( targetPuppet.GetEntityID() ) );
	}

	public const function Evaluate( isEntityInScene : Bool ) : Bool
	{
		if( isEntityInScene )
		{
			return ( ( m_invert ) ? ( false ) : ( true ) );
		}
		else
		{
			return ( ( m_invert ) ? ( true ) : ( false ) );
		}
	}

}

