private static bool HandleStockSelection(
            ref Decorators.PurchaseAnimalsMenu moddedMenu,
            int x,
            int y,
            Farmer moddedPlayer)
        {
            var textureComponent = moddedMenu.GetAnimalsToPurchase().Where(o => (o.item as StardewValley.Object).Type == null)
                                   .FirstOrDefault(o => o.containsPoint(x, y));

            if (textureComponent == null)
            {
                return(true);
            }
            var amount = textureComponent.item.salePrice();

            if (!moddedPlayer.CanAfford(amount))
            {
                return(true);
            }
            var randomAnimalShopType =
                new Api.BetterFarmAnimalVariety(Mod.ReadConfig <ModConfig>()).GetRandomAnimalShopType(textureComponent.hoverText,
                                                                                                      moddedPlayer.GetOriginal());
            var farmAnimal1 = moddedPlayer.CreateFarmAnimal(randomAnimalShopType);

            SelectedStockBellsAndWhistles(ref moddedMenu);
            moddedMenu.SetOnFarm(true);
            moddedMenu.SetAnimalBeingPurchased(farmAnimal1);
            var farmAnimal2 = new Decorators.FarmAnimal(farmAnimal1);

            moddedMenu.SetPriceOfAnimal(farmAnimal2.GetPrice());
            return(false);
        }
Beispiel #2
0
        public static bool Prefix(ref StardewValley.Menus.PurchaseAnimalsMenu __instance, ref SpriteBatch b)
        {
            var purchaseAnimalsMenu = new Decorators.PurchaseAnimalsMenu(__instance);
            var farmAnimal          = new Decorators.FarmAnimal(purchaseAnimalsMenu.GetAnimalBeingPurchased());

            if (!BellsAndWhistles.IsFaded() && purchaseAnimalsMenu.IsOnFarm())
            {
                var str = Content.FormatMoneyString(farmAnimal.GetPrice());
                var x   = Game.GetViewport().Width / 2 - Content.GetWidthOfString(str) / 2;
                var y   = (int)(18.0 * SpriteText.fontPixelZoom * 2.0);
                BellsAndWhistles.DrawScroll(b, str, x, y);
            }

            return(true);
        }