예제 #1
0
        /// <summary>Get the recipe ingredients.</summary>
        /// <param name="metadata">Provides metadata that's not available from the game data directly.</param>
        /// <param name="reflectionHelper">Simplifies access to private game code.</param>
        /// <param name="translations">Provides translations stored in the mod folder.</param>
        public static RecipeModel[] GetRecipes(Metadata metadata, IReflectionHelper reflectionHelper, ITranslationHelper translations)
        {
            List <RecipeModel> recipes = new List <RecipeModel>();

            // cooking recipes
            recipes.AddRange(
                from entry in CraftingRecipe.cookingRecipes
                let recipe = new CraftingRecipe(entry.Key, isCookingRecipe: true)
                             select new RecipeModel(recipe, reflectionHelper, translations)
                );

            // crafting recipes
            recipes.AddRange(
                from entry in CraftingRecipe.craftingRecipes
                let recipe = new CraftingRecipe(entry.Key, isCookingRecipe: false)
                             select new RecipeModel(recipe, reflectionHelper, translations)
                );

            // machine recipes
            recipes.AddRange(
                from entry in metadata.MachineRecipes
                let machine = new SObject(Vector2.Zero, entry.MachineID)
                              select new RecipeModel(null, machine.DisplayName, entry.Ingredients, ingredient => DataParser.CreateRecipeItem(ingredient.ParentSheetIndex, entry.Output), false, entry.ExceptIngredients)
                );

            // building recipes
            recipes.AddRange(
                from entry in metadata.BuildingRecipes
                let building = new BluePrint(entry.BuildingKey)
                               select new RecipeModel(null, building.displayName, entry.Ingredients, ingredient => DataParser.CreateRecipeItem(ingredient.ParentSheetIndex, entry.Output), false, entry.ExceptIngredients)
                );

            return(recipes.ToArray());
        }
예제 #2
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="customFarmingRedux">The Custom Farming Redux integration.</param>
 public GameHelper(CustomFarmingReduxIntegration customFarmingRedux)
 {
     this.DataParser         = new DataParser(this);
     this.CustomFarmingRedux = customFarmingRedux;
 }
예제 #3
0
 /*********
 ** Public methods
 *********/
 /****
 ** State
 ****/
 /// <summary>Reset the low-level cache used to store expensive query results, so the data is recalculated on demand.</summary>
 /// <param name="metadata">Provides metadata that's not available from the game data directly.</param>
 /// <param name="reflectionHelper">Simplifies access to private game code.</param>
 /// <param name="translations">Provides translations stored in the mod folder.</param>
 public static void ResetCache(Metadata metadata, IReflectionHelper reflectionHelper, ITranslationHelper translations)
 {
     GameHelper.GiftTastes = new Lazy <GiftTasteModel[]>(() => DataParser.GetGiftTastes(GameHelper.Objects.Value).ToArray());
     GameHelper.Recipes    = new Lazy <RecipeModel[]>(() => DataParser.GetRecipes(metadata, reflectionHelper, translations).ToArray());
 }
예제 #4
0
 /*********
 ** Public methods
 *********/
 /// <summary>Construct an instance.</summary>
 /// <param name="customFarmingRedux">The Custom Farming Redux integration.</param>
 /// <param name="metadata">Provides metadata that's not available from the game data directly.</param>
 public GameHelper(CustomFarmingReduxIntegration customFarmingRedux, Metadata metadata)
 {
     this.DataParser         = new DataParser(this);
     this.CustomFarmingRedux = customFarmingRedux;
     this.Metadata           = metadata;
 }