private static void OpenKrobusCatalogue() { var dict = new Sewer().getShadowShopStock(); AdjustPrices(ref dict, false); Game1.activeClickableMenu = new ShopMenu(dict, 0, "Krobus", null, null, null); }
/// <summary> /// When input is received, check for shop tiles to open them as necessary /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void Input_ButtonPressed(object sender, StardewModdingAPI.Events.ButtonPressedEventArgs e) { //context and button check if (!Context.CanPlayerMove) { return; } //Resets the boolean I use to check if a menu used to move the player around came from my mod //and lets me return them to their original location SourceLocation = null; PlayerPos = Vector2.Zero; //checks if i've changed marnie's stock already after opening her menu ChangedMarnieStock = false; if (!e.Button.IsActionButton()) { return; } Vector2 clickedTile = Vector2.Zero; clickedTile = Helper.Input.GetCursorPosition().GrabTile; //check if there is a tile property on Buildings layer var tileProperty = GetTileProperty(Game1.currentLocation, "Buildings", clickedTile); if (tileProperty == null) { return; } //check if there is a Shop property on clicked tile tileProperty.TryGetValue("Shop", out PropertyValue shopProperty); if (shopProperty != null) { //everything in this block is for the shop property "Shop" if (shopProperty == "Vanilla!PierreShop") { helper.Input.Suppress(e.Button); var seedShop = new SeedShop(); Game1.activeClickableMenu = new ShopMenu(seedShop.shopStock(), 0, "Pierre", null, null, null); } else if (shopProperty == "Vanilla!JojaShop") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(Utility.getJojaStock(), 0, (string)null, null, null, null); } else if (shopProperty == "Vanilla!RobinShop") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(Utility.getCarpenterStock(), 0, "Robin", null, null, null); } else if (shopProperty == "Vanilla!RobinBuildingsShop") { helper.Input.Suppress(e.Button); SourceLocation = Game1.currentLocation; PlayerPos = Game1.player.position.Get(); Game1.activeClickableMenu = new CarpenterMenu(false); } else if (shopProperty == "Vanilla!ClintShop") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(Utility.getBlacksmithStock(), 0, "Clint", null, null, null); } else if (shopProperty == "Vanilla!ClintGeodes") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new GeodeMenu(); } else if (shopProperty == "Vanilla!ClintToolUpgrades") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(Utility.getBlacksmithUpgradeStock(Game1.player), 0, "ClintUpgrade", null, null, null); } else if (shopProperty == "Vanilla!MarlonShop") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(Utility.getAdventureShopStock(), 0, "Marlon", null, null, null); } else if (shopProperty == "Vanilla!MarnieShop") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(Utility.getAnimalShopStock(), 0, "Marnie", null, null, null); } else if (shopProperty == "Vanilla!MarnieAnimalShop") { helper.Input.Suppress(e.Button); PlayerPos = Game1.player.position.Get(); SourceLocation = Game1.currentLocation; Game1.activeClickableMenu = new PurchaseAnimalsMenu(Utility.getPurchaseAnimalStock()); } else if (shopProperty == "Vanilla!TravellingMerchant") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(Utility.getTravelingMerchantStock((int)((long)Game1.uniqueIDForThisGame + (long)Game1.stats.DaysPlayed)), 0, "Traveler", new Func <ISalable, Farmer, int, bool>(Utility.onTravelingMerchantShopPurchase), null, null); } else if (shopProperty == "Vanilla!HarveyShop") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(Utility.getHospitalStock(), 0, null, null, null, null); } else if (shopProperty == "Vanilla!SandyShop") { helper.Input.Suppress(e.Button); var SandyStock = helper.Reflection.GetMethod(Game1.currentLocation, "sandyShopStock").Invoke <Dictionary <ISalable, int[]> >(); Game1.activeClickableMenu = new ShopMenu(SandyStock, 0, "Sandy", new Func <ISalable, Farmer, int, bool>(onSandyShopPurchase), null, null); } else if (shopProperty == "Vanilla!DesertTrader") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(Desert.getDesertMerchantTradeStock(Game1.player), 0, "DesertTrade", new Func <ISalable, Farmer, int, bool>(boughtTraderItem), null, null); } else if (shopProperty == "Vanilla!KrobusShop") { helper.Input.Suppress(e.Button); var sewer = new Sewer(); Game1.activeClickableMenu = new ShopMenu(sewer.getShadowShopStock(), 0, "Krobus", new Func <ISalable, Farmer, int, bool>(sewer.onShopPurchase), null, null); } else if (shopProperty == "Vanilla!DwarfShop") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(Utility.getDwarfShopStock(), 0, "Dwarf", null, null, null); } else if (shopProperty == "Vanilla!AdventureRecovery") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(Utility.getAdventureRecoveryStock(), 0, "Marlon_Recovery", null, null, null); } else if (shopProperty == "Vanilla!GusShop") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(Utility.getSaloonStock(), 0, "Gus", (item, farmer, amount) => { Game1.player.team.synchronizedShopStock.OnItemPurchased(SynchronizedShopStock.SynchedShop.Saloon, item, amount); return(false); }, null, null); } else if (shopProperty == "Vanilla!WillyShop") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(Utility.getFishShopStock(Game1.player), 0, "Willy", null, null, null); } else if (shopProperty == "Vanilla!WizardBuildings") { helper.Input.Suppress(e.Button); SourceLocation = Game1.currentLocation; PlayerPos = Game1.player.position.Get(); Game1.activeClickableMenu = new CarpenterMenu(true); } else if (shopProperty == "Vanilla!QiShop") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(Utility.getQiShopStock(), 2, null, null, null, null); } else if (shopProperty == "Vanilla!IceCreamStand") { helper.Input.Suppress(e.Button); Game1.activeClickableMenu = new ShopMenu(new Dictionary <ISalable, int[]>() { { new StardewValley.Object(233, 1, false, -1, 0), new int[2] { 250, int.MaxValue } } }, 0, null, null, null, null); } else { //Extract the tile property value string ShopName = shopProperty.ToString(); if (Shops.ContainsKey(ShopName)) { helper.Input.Suppress(e.Button); Shops[ShopName].DisplayShop(); } else { Monitor.Log($"A Shop tile was clicked, but a shop by the name \"{ShopName}\" " + $"was not found.", LogLevel.Debug); } } } else { tileProperty.TryGetValue("AnimalShop", out shopProperty); if (shopProperty == null) { return; } else { string ShopName = shopProperty.ToString(); if (AnimalShops.ContainsKey(ShopName)) { helper.Input.Suppress(e.Button); AnimalShops[ShopName].DisplayShop(); } else { Monitor.Log($"An Animal Shop tile was clicked, but a shop by the name \"{ShopName}\" " + $"was not found.", LogLevel.Debug); } } } //TODO: add another else check if no tile properties were found for bigcraftables }
static void ConstructorPostfix(Sewer __instance) { var krobusfield = AccessTools.Field(typeof(Sewer), "Krobus"); (krobusfield.GetValue(__instance) as NPC).Sprite = new AnimatedSprite("Characters\\Krobus", 0, 16, 32); }
/// <summary> /// Given the name of a shop property, return an instance of the vanilla menu that matches the property /// </summary> /// <param name="shopProperty">the name of the property, as outlined in the README.md</param> /// <param name="warpingShop">is true for animal shops and carpenter shops, which need special handling due to /// the fact it physically warps the players to hard-coded locations</param> /// <returns>An instance of the vanilla stores if the property matches, null otherwise</returns> public static IClickableMenu CheckVanillaShop(string shopProperty, out bool warpingShop) { warpingShop = false; switch (shopProperty) { case "Vanilla!PierreShop": { var seedShop = new SeedShop(); return(new ShopMenu(seedShop.shopStock(), 0, "Pierre")); } case "Vanilla!JojaShop": return(new ShopMenu(StardewValley.Utility.getJojaStock())); case "Vanilla!RobinShop": return(new ShopMenu(StardewValley.Utility.getCarpenterStock(), 0, "Robin")); case "Vanilla!RobinBuildingsShop": warpingShop = true; return(new CarpenterMenu()); case "Vanilla!ClintShop": return(new ShopMenu(StardewValley.Utility.getBlacksmithStock(), 0, "Clint")); case "Vanilla!ClintGeodes": return(new GeodeMenu()); case "Vanilla!ClintToolUpgrades": return(new ShopMenu(StardewValley.Utility.getBlacksmithUpgradeStock(Game1.player), 0, "ClintUpgrade")); case "Vanilla!MarlonShop": return(new ShopMenu(StardewValley.Utility.getAdventureShopStock(), 0, "Marlon")); case "Vanilla!MarnieShop": return(new ShopMenu(StardewValley.Utility.getAnimalShopStock(), 0, "Marnie")); case "Vanilla!MarnieAnimalShop": warpingShop = true; return(new PurchaseAnimalsMenu(StardewValley.Utility.getPurchaseAnimalStock())); case "Vanilla!TravellingMerchant": return(new ShopMenu(StardewValley.Utility.getTravelingMerchantStock((int)((long)Game1.uniqueIDForThisGame + Game1.stats.DaysPlayed)), 0, "Traveler", StardewValley.Utility.onTravelingMerchantShopPurchase)); case "Vanilla!HarveyShop": return(new ShopMenu(StardewValley.Utility.getHospitalStock())); case "Vanilla!SandyShop": { var SandyStock = ModEntry.helper.Reflection.GetMethod(Game1.currentLocation, "sandyShopStock").Invoke <Dictionary <ISalable, int[]> >(); return(new ShopMenu(SandyStock, 0, "Sandy", onSandyShopPurchase)); } case "Vanilla!DesertTrader": return(new ShopMenu(Desert.getDesertMerchantTradeStock(Game1.player), 0, "DesertTrade", boughtTraderItem)); case "Vanilla!KrobusShop": { var sewer = new Sewer(); return(new ShopMenu(sewer.getShadowShopStock(), 0, "Krobus", sewer.onShopPurchase)); } case "Vanilla!DwarfShop": return(new ShopMenu(StardewValley.Utility.getDwarfShopStock(), 0, "Dwarf")); case "Vanilla!AdventureRecovery": return(new ShopMenu(StardewValley.Utility.getAdventureRecoveryStock(), 0, "Marlon_Recovery")); case "Vanilla!GusShop": { return(new ShopMenu(StardewValley.Utility.getSaloonStock(), 0, "Gus", (item, farmer, amount) => { Game1.player.team.synchronizedShopStock.OnItemPurchased(SynchronizedShopStock.SynchedShop.Saloon, item, amount); return false; })); } case "Vanilla!WillyShop": return(new ShopMenu(StardewValley.Utility.getFishShopStock(Game1.player), 0, "Willy")); case "Vanilla!WizardBuildings": warpingShop = true; return(new CarpenterMenu(true)); case "Vanilla!QiShop": Game1.activeClickableMenu = new ShopMenu(StardewValley.Utility.getQiShopStock(), 2); break; case "Vanilla!IceCreamStand": return(new ShopMenu(new Dictionary <ISalable, int[]> { { new Object(233, 1), new[] { 250, int.MaxValue } } })); } return(null); }