Exemplo n.º 1
0
        public static bool Prefix(
            ref StardewValley.FarmAnimal __instance,
            ref GameTime time,
            ref GameLocation location,
            ref bool __result)
        {
            var moddedAnimal = new Decorators.FarmAnimal(__instance);

            if (!moddedAnimal.HasHome() || moddedAnimal.IsEating() || Game1.IsClient || __instance.controller != null)
            {
                return(true);
            }
            var moddedLocation = new Location(location);

            HandleFindGrassToEat(ref moddedAnimal, ref moddedLocation);
            if (HandleNightTimeRoutine(ref moddedAnimal, ref moddedLocation))
            {
                __result = true;
            }
            else
            {
                HandleFindProduce(ref moddedAnimal, ref moddedLocation);
                __result = false;
            }

            return(false);
        }
Exemplo n.º 2
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);
        }