/********* ** Private methods *********/ /// <summary>Create a custom recipe output.</summary> /// <param name="inputID">The input ingredient ID.</param> /// <param name="outputID">The output item ID.</param> private static SObject CreateRecipeItem(int inputID, int outputID) { SObject item = GameHelper.GetObjectBySpriteIndex(outputID); switch (outputID) { case 342: item.preserve.Value = SObject.PreserveType.Pickle; item.preservedParentSheetIndex.Value = inputID; break; case 344: item.preserve.Value = SObject.PreserveType.Jelly; item.preservedParentSheetIndex.Value = inputID; break; case 348: item.preserve.Value = SObject.PreserveType.Wine; item.preservedParentSheetIndex.Value = inputID; break; case 350: item.preserve.Value = SObject.PreserveType.Juice; item.preservedParentSheetIndex.Value = inputID; break; } return(item); }
/// <summary>Get the items a specified NPC can receive.</summary> /// <param name="npc">The NPC to check.</param> /// <param name="metadata">Provides metadata that's not available from the game data directly.</param> public static IDictionary <SObject, GiftTaste> GetGiftTastes(NPC npc, Metadata metadata) { if (!GameHelper.IsSocialVillager(npc, metadata)) { return(new Dictionary <SObject, GiftTaste>()); } // get giftable items HashSet <int> giftableItemIDs = new HashSet <int>( from int refID in GameHelper.GiftTastes.Value.Select(p => p.RefID) from ObjectModel obj in GameHelper.Objects.Value where obj.ParentSpriteIndex == refID || obj.Category == refID select obj.ParentSpriteIndex ); // get gift tastes return (( from int itemID in giftableItemIDs let item = GameHelper.GetObjectBySpriteIndex(itemID) let taste = GameHelper.GetGiftTaste(npc, item) where taste.HasValue select new { Item = item, Taste = taste.Value } ) .ToDictionary(p => p.Item, p => p.Taste)); }
/// <summary>Get all objects matching the reference ID.</summary> /// <param name="refID">The reference ID. This can be a category (negative value) or parent sprite index (positive value).</param> public static IEnumerable <Object> GetObjectsByReferenceID(int refID) { // category if (refID < 0) { return( from pair in Game1.objectInformation where Regex.IsMatch(pair.Value, $"\b{refID}\b") select GameHelper.GetObjectBySpriteIndex(pair.Key) ); } // parent sprite index return(new[] { GameHelper.GetObjectBySpriteIndex(refID) }); }
/// <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> public static RecipeModel[] GetRecipes(Metadata metadata, IReflectionHelper reflectionHelper) { 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) ); // crafting recipes recipes.AddRange( from entry in CraftingRecipe.craftingRecipes let recipe = new CraftingRecipe(entry.Key, isCookingRecipe: false) select new RecipeModel(recipe, reflectionHelper) ); // recipes not available from game data recipes.AddRange( from entry in metadata.Recipes select new RecipeModel(entry.Name, entry.Type, entry.Ingredients, () => GameHelper.GetObjectBySpriteIndex(entry.Output), false, entry.ExceptIngredients) ); return(recipes.OrderBy(p => p.Name).ToArray()); }