コード例 #1
0
        private List <string> DetermineHatchlingTypes(Incubator incubator)
        {
            // Grab the held item's index #
            string heldItemIndex = incubator.GetIncubatingItemIndex();

            // Randomize an eligible animal type from parents
            List <StardewValley.FarmAnimal> possibleParents = incubator.AnimalHouse.animals.Pairs.ToDictionary(pair => pair.Key, pair => pair.Value).Values.ToList <StardewValley.FarmAnimal>();
            List <string> types = this.DetermineTypesFromPossibleParents(heldItemIndex, possibleParents);

            if (types.Count <= 0)
            {
                // Try to grab anything that produces that item regardless if owned/in the coop
                // ex. Parent was sold before hatchling hatched
                types = this.DetermineTypesFromProduce(incubator.GetIncubatingItemIndex());
            }

            // ex. Roosters don't produce anything, but may still exist in the Chicken category
            if (this.RandomizeHatchlingFromCategory)
            {
                List <string> typesFromCategory = this.ConsiderTypesFromCategory(types, new string[] { heldItemIndex });

                // Check the count in case someone messed up and removed the parent from the config
                if (typesFromCategory.Count > 0)
                {
                    types = typesFromCategory;
                }
            }

            return(types);
        }