Ejemplo n.º 1
0
        private static void HandleCurrentProduce(ref Decorators.FarmAnimal moddedAnimal, byte originalFullness)
        {
            var daysToLay = moddedAnimal.GetDaysToLay(moddedAnimal.GetOwner());
            var seed      = (int)moddedAnimal.GetUniqueId() / 2 + Game.GetDaysPlayed();
            var flag      = RollRandomProduceChance(moddedAnimal, originalFullness, seed);

            if (!moddedAnimal.IsAProducer() || moddedAnimal.IsBaby())
            {
                moddedAnimal.SetCurrentProduce(-1);
            }
            else
            {
                if (moddedAnimal.GetDaysSinceLastLay() < daysToLay)
                {
                    return;
                }
                if (!flag)
                {
                    moddedAnimal.SetCurrentProduce(-1);
                }
                else
                {
                    HandleGameStats(moddedAnimal);
                    var player         = Game.GetPlayer();
                    var farmAnimals    = FarmAnimals.ReadCache();
                    var typeStr        = moddedAnimal.GetTypeString();
                    var farmAnimalType = farmAnimals.Categories.SelectMany(o => (IEnumerable <FarmAnimalType>)o.Types)
                                         .Where(o => o.Type == typeStr).FirstOrDefault();
                    var deluxeProduceLuck = farmAnimalType == null ? 0.0 : farmAnimalType.DeluxeProduceLuck;
                    var produceIndex      = moddedAnimal.RollProduce(seed, player, deluxeProduceLuck);
                    moddedAnimal.SetCurrentProduce(produceIndex);
                    if (!Paritee.StardewValley.Core.Characters.FarmAnimal.IsProduceAnItem(produceIndex))
                    {
                        return;
                    }
                    moddedAnimal.SetDaysSinceLastLay(0);
                    HandleProduceQuality(moddedAnimal, seed);
                    HandleProduceSpawn(moddedAnimal);
                }
            }
        }