Beispiel #1
0
        /// <summary>Get the items a specified NPC can receive.</summary>
        /// <param name="npc">The NPC to check.</param>
        public static IDictionary <Object, GiftTaste> GetGiftTastes(NPC npc)
        {
            if (!npc.isVillager())
            {
                return(new Dictionary <Object, GiftTaste>());
            }

            string name = npc.getName();

            return(GameHelper.GiftTastes.Value
                   .Where(p => p.Villager == name)
                   .ToDictionary(p => GameHelper.GetObjectBySpriteIndex(p.ItemID), p => p.Taste));
        }
Beispiel #2
0
        /// <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) });
        }
Beispiel #3
0
        /// <summary>Get the recipe ingredients.</summary>
        /// <param name="metadata">Provides metadata that's not available from the game data directly.</param>
        public static RecipeModel[] GetRecipes(Metadata metadata)
        {
            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)
                );

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

            // 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());
        }