Пример #1
0
        private static void HandleProduceSpawn(Decorators.FarmAnimal moddedAnimal)
        {
            if (!moddedAnimal.LaysProduce() || !moddedAnimal.HasHome())
            {
                return;
            }
            var indoors        = Paritee.StardewValley.Core.Locations.AnimalHouse.GetIndoors(moddedAnimal.GetHome());
            var tileLocation   = moddedAnimal.GetTileLocation();
            var currentProduce = moddedAnimal.GetCurrentProduce();
            var produceQuality = moddedAnimal.GetProduceQuality();
            var flag           = true;

            foreach (var @object in indoors.Objects.Values)
            {
                int num;
                if ((bool)@object.bigCraftable && (int)@object.parentSheetIndex == 165 && @object.heldObject.Value != null)
                {
                    num = (@object.heldObject.Value as Chest).addItem(
                        new StardewValley.Object(Vector2.Zero, currentProduce, null, false, true, false, false)
                    {
                        Quality = produceQuality
                    }) == null
            ? 1
            : 0;
                }
                else
                {
                    num = 0;
                }
                if (num != 0)
                {
                    @object.showNextIndex.Value = true;
                    flag = false;
                    break;
                }
            }

            if (flag && !indoors.Objects.ContainsKey(tileLocation))
            {
                var @object = new StardewValley.Object(Vector2.Zero, currentProduce, null, false, true, false, true)
                {
                    Quality = produceQuality
                };
                Location.SpawnObject(indoors, tileLocation, @object);
            }

            moddedAnimal.SetCurrentProduce(-1);
        }
Пример #2
0
        private static bool AttemptToSpawnProduce(ref Decorators.FarmAnimal moddedAnimal, Farmer who)
        {
            var translatedVector2 =
                StardewValley.Utility.getTranslatedVector2(moddedAnimal.GetTileLocation(), moddedAnimal.GetFacingDirection(),
                                                           1f);
            var currentProduce = moddedAnimal.GetCurrentProduce();

            if (!Paritee.StardewValley.Core.Characters.FarmAnimal.IsProduceAnItem(currentProduce))
            {
                return(false);
            }
            var @object = new StardewValley.Object(Vector2.Zero, currentProduce, null, false, true, false, true)
            {
                Quality = moddedAnimal.GetProduceQuality()
            };

            Location.SpawnObject(Game.GetFarm(), translatedVector2, @object);
            return(true);
        }