class PlayerDoesntHaveRecipePrereqState extends PrereqState
{
}

class PlayerDoesntHaveRecipePrereq extends IScriptablePrereq
{
	var m_recipeID : TweakDBID;
	var m_invert : Bool;

	protected override function Initialize( recordID : TweakDBID )
	{
		m_recipeID = TDBID.Create( TweakDBInterface.GetString( recordID + T".recipe", "" ) );
		m_invert = TweakDBInterface.GetBool( recordID + T".invert", false );
	}

	protected const override function OnApplied( state : PrereqState, game : GameInstance, context : IScriptable )
	{
		var result : Bool;
		var craftingSystem : CraftingSystem;
		var playerCraftBook : CraftBook;
		craftingSystem = CraftingSystem.GetInstance( game );
		playerCraftBook = craftingSystem.GetPlayerCraftBook();
		result = !( craftingSystem.IsRecipeKnown( m_recipeID, playerCraftBook ) );
		( ( PlayerDoesntHaveRecipePrereqState )( state ) ).OnChanged( result );
	}

	public const override function IsFulfilled( game : GameInstance, context : IScriptable ) : Bool
	{
		var result : Bool;
		var craftingSystem : CraftingSystem;
		var playerCraftBook : CraftBook;
		craftingSystem = CraftingSystem.GetInstance( game );
		playerCraftBook = craftingSystem.GetPlayerCraftBook();
		result = !( craftingSystem.IsRecipeKnown( m_recipeID, playerCraftBook ) );
		if( m_invert )
		{
			return !( result );
		}
		return result;
	}

}

