class NPCTypePrereq extends IScriptablePrereq
{
	var m_allowedTypes : array< gamedataNPCType >;
	var m_invert : Bool;

	protected export override function Initialize( recordID : TweakDBID )
	{
		var prereqRecord : NPCTypePrereq_Record;
		var allowedTypeItem : weak< NPCType_Record >;
		var i : Int32;
		prereqRecord = TweakDBInterface.GetNPCTypePrereqRecord( recordID );
		for( i = 0; i < prereqRecord.GetAllowedTypesCount(); i += 1 )
		{
			allowedTypeItem = prereqRecord.GetAllowedTypesItem( i );
			m_allowedTypes.PushBack( allowedTypeItem.Type() );
		}
		m_invert = prereqRecord.Invert();
	}

	protected const override function OnApplied( state : PrereqState, game : GameInstance, context : IScriptable )
	{
		state.OnChanged( IsFulfilled( game, context ) );
	}

	public export const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var owner : GameObject;
		var targetPuppet : ScriptedPuppet;
		var targetType : gamedataNPCType;
		owner = ( ( GameObject )( context ) );
		targetPuppet = ( ( ScriptedPuppet )( owner ) );
		targetType = targetPuppet.GetNPCType();
		if( !( m_allowedTypes.Contains( targetType ) ) )
		{
			return ( ( m_invert ) ? ( true ) : ( false ) );
		}
		return ( ( m_invert ) ? ( false ) : ( true ) );
	}

}

class NPCIsChildPrereq extends IScriptablePrereq
{
	var m_invert : Bool;

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

	public export const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var targetPuppet : ScriptedPuppet;
		var isChild : Bool;
		targetPuppet = ( ( ScriptedPuppet )( context ) );
		isChild = targetPuppet.GetRecord().IsChild();
		return ( ( m_invert ) ? ( !( isChild ) ) : ( isChild ) );
	}

}

class NPCIsCrowdPrereq extends IScriptablePrereq
{
	var m_invert : Bool;

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

	public export const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var targetPuppet : ScriptedPuppet;
		var isCrowd : Bool;
		targetPuppet = ( ( ScriptedPuppet )( context ) );
		isCrowd = targetPuppet.GetRecord().IsCrowd();
		return ( ( m_invert ) ? ( !( isCrowd ) ) : ( isCrowd ) );
	}

}

