public static string GetRandomTypeFromIncubator(global::StardewValley.Object incubator, Dictionary <string, List <string> > restrictions)
 {
     // Search for a type by the produce
     return(incubator.heldObject.Value == null
         ? null
         : Characters.FarmAnimal.GetRandomTypeFromProduce(incubator.heldObject.Value.ParentSheetIndex, restrictions));
 }
        internal static bool Prefix(ref global::StardewValley.Object __result, int waterDepth, global::StardewValley.Farmer who)
        {
            if (Global.Config.OverrideGetSewerFishKing &&
                (Game1.random.NextDouble() < Global.Config.SewerFishKingThreshold + ((who.getTileX() > 14 && who.getTileY() > 42) ? 0.08 : 0.0)))
            {
                __result = new global::StardewValley.Object(682, 1, false, -1, 0);
                return(false);
            }

            return(true);
        }
예제 #3
0
        internal static bool Prefix(ref global::StardewValley.Object __result, int waterDepth, global::StardewValley.Farmer who)
        {
            if (Global.Config.OverrideGetFallFishKing &&
                Game1.currentSeason.Equals("fall") &&
                who.getTileLocation().Y < 15f &&
                who.FishingLevel >= 3 &&
                Game1.random.NextDouble() < Global.Config.FallFishKingThreshold)
            {
                __result = new global::StardewValley.Object(160, 1, false, -1, 0);
                return(false);
            }

            return(true);
        }
예제 #4
0
        internal static bool Prefix(ref global::StardewValley.Object __result, int waterDepth, global::StardewValley.Farmer who)
        {
            if (Global.Config.OverrideGetSummerFishKing &&
                Game1.currentSeason.Equals("summer") &&
                who.getTileX() >= 82 &&
                who.FishingLevel >= 5 &&
                waterDepth >= 3 &&
                Game1.random.NextDouble() < Global.Config.SummerFishKingThreshold)
            {
                __result = new global::StardewValley.Object(159, 1, false, -1, 0);
                return(false);
            }

            return(true);
        }
        internal static bool Prefix(ref global::StardewValley.Object __result, int waterDepth, global::StardewValley.Farmer who)
        {
            if (Global.Config.OverrideGetSpringFishKing &&
                Game1.currentSeason.Equals("spring") &&
                Game1.isRaining &&
                who.FishingLevel >= 10 &&
                waterDepth >= 4 &&
                Game1.random.NextDouble() < Global.Config.SpringFishKingThreshold)
            {
                __result = new global::StardewValley.Object(163, 1, false, -1, 0);
                return(false);
            }

            return(true);
        }
        public static global::StardewValley.Object FormatAsAnimalAvailableForPurchase(Farm farm, string name, string displayName, string[] types, string[] buildings)
        {
            Locations.AnimalShop.RequiredBuildingIsBuilt(farm, buildings, out string type);

            // Divide the first price by two because of the weird functionality
            // in Object.salePrice(). Need to use ceiling even though it may
            // exclude the lowest type if the lowest price is an odd number.
            int price = (int)Math.Ceiling(Characters.FarmAnimal.GetCheapestPrice(types.ToList()) / 2f);

            global::StardewValley.Object obj = new global::StardewValley.Object(Locations.AnimalShop.PurchaseAnimalStockParentSheetIndex, Locations.AnimalShop.PurchaseAnimalStockQuantity, false, price)
            {
                Type        = type,
                displayName = displayName
            };

            // MUST do this outside of the block because it gets overridden in
            // the constructor
            obj.Name = name;

            return(obj);
        }
        public static List <ClickableTextureComponent> GetAnimalsToPurchaseComponents(global::StardewValley.Menus.PurchaseAnimalsMenu menu, List <global::StardewValley.Object> stock, Dictionary <string, Texture2D> icons, out int iconHeight)
        {
            iconHeight = 0;

            List <ClickableTextureComponent> animalsToPurchase = new List <ClickableTextureComponent>();

            for (int index = 0; index < stock.Count; ++index)
            {
                global::StardewValley.Object obj = stock[index];

                string name      = obj.salePrice().ToString();
                string label     = (string)null;
                string hoverText = obj.Name;

                Rectangle bounds     = new Rectangle(menu.xPositionOnScreen + IClickableMenu.borderWidth + index % 3 * 64 * 2, menu.yPositionOnScreen + IClickableMenu.spaceToClearTopBorder + IClickableMenu.borderWidth / 2 + index / 3 * 85, 128, 64);
                Texture2D texture    = icons[obj.Name];
                Rectangle sourceRect = new Rectangle(0, 0, texture.Width, texture.Height);

                float scale      = 4f;
                bool  drawShadow = obj.Type == null;

                ClickableTextureComponent textureComponent = new ClickableTextureComponent(name, bounds, label, hoverText, texture, sourceRect, scale, drawShadow)
                {
                    item            = obj,
                    myID            = index,
                    rightNeighborID = index % 3 == 2 ? -1 : index + 1,
                    leftNeighborID  = index % 3 == 0 ? -1 : index - 1,
                    downNeighborID  = index + 3,
                    upNeighborID    = index - 3
                };

                animalsToPurchase.Add(textureComponent);

                // We need the icon height for the menu resize
                iconHeight = texture.Height > iconHeight ? texture.Height : iconHeight;
            }

            return(animalsToPurchase);
        }
예제 #8
0
 public static bool IsBigCraftable(global::StardewValley.Object obj)
 {
     return(obj.bigCraftable.Value);
 }
예제 #9
0
 public static bool IsItem(global::StardewValley.Object obj, int itemIndex)
 {
     return(obj.ParentSheetIndex == itemIndex);
 }
예제 #10
0
 public static bool IsAutoGrabber(global::StardewValley.Object obj)
 {
     return(Objects.Object.IsItem(obj, Locations.AnimalHouse.AutoGrabberItemIndex) && Objects.Object.IsBigCraftable(obj));
 }
예제 #11
0
 public static bool IsReady(global::StardewValley.Object obj)
 {
     return(Objects.Object.GetMinutesUntilReady(obj) <= 0);
 }
예제 #12
0
 public static int GetMinutesUntilReady(global::StardewValley.Object obj)
 {
     return(obj.MinutesUntilReady);
 }
예제 #13
0
 public static bool IsHoldingObject(global::StardewValley.Object obj)
 {
     return(obj.heldObject.Value != null);
 }
예제 #14
0
 public static bool IsIncubator(global::StardewValley.Object obj)
 {
     return(Objects.Object.IsBigCraftable(obj) && Objects.Object.GetName(obj).Contains(Locations.AnimalHouse.Incubator));
 }
예제 #15
0
 public static string GetName(global::StardewValley.Object obj)
 {
     return(obj.Name);
 }
예제 #16
0
 public static void SpawnObject(GameLocation location, Vector2 tileLocation, global::StardewValley.Object obj)
 {
     Utility.spawnObjectAround(tileLocation, obj, location);
 }
        public static void ResetIncubator(global::StardewValley.AnimalHouse animalHouse, global::StardewValley.Object incubator)
        {
            incubator.heldObject.Value = null;
            incubator.ParentSheetIndex = Locations.AnimalHouse.DefaultIncubatorItemIndex;

            Locations.AnimalHouse.ResetIncubator(animalHouse);
        }
        public static void AutoGrabFromAnimals(global::StardewValley.AnimalHouse animalHouse, global::StardewValley.Object autoGrabber)
        {
            foreach (KeyValuePair <long, global::StardewValley.FarmAnimal> pair in animalHouse.animals.Pairs)
            {
                // Skip non-producers
                if (!Characters.FarmAnimal.IsAProducer(pair.Value))
                {
                    continue;
                }

                // Must require a tool for harvest, ..
                if (!Characters.FarmAnimal.RequiresToolForHarvest(pair.Value))
                {
                    continue;
                }

                // .. be currently producing an item (ex. not a baby) ..
                if (!Characters.FarmAnimal.IsCurrentlyProducing(pair.Value))
                {
                    continue;
                }

                // .. and must not be an animal that finds its produce (ex. Pigs)
                // This is the logic check where previously it validated solely
                // against Truffles. This may not always be the case.
                if (Characters.FarmAnimal.CanFindProduce(pair.Value))
                {
                    continue;
                }

                if (autoGrabber.heldObject.Value != null && autoGrabber.heldObject.Value is Chest chest)
                {
                    Item item = (Item) new global::StardewValley.Object(Vector2.Zero, Characters.FarmAnimal.GetCurrentProduce(pair.Value), null, false, true, false, false)
                    {
                        Quality = Characters.FarmAnimal.GetProduceQuality(pair.Value)
                    };

                    if (chest.addItem(item) == null)
                    {
                        Characters.FarmAnimal.SetCurrentProduce(pair.Value, Characters.FarmAnimal.NoProduce);

                        if (Characters.FarmAnimal.IsSheared(pair.Value))
                        {
                            Characters.FarmAnimal.ReloadSpriteTexture(pair.Value);
                        }

                        autoGrabber.showNextIndex.Value = true;
                    }
                }
            }
        }