public override void Entry(IModHelper helper) { helper.Events.GameLoop.DayStarted += this.DayStarted; helper.Events.GameLoop.GameLaunched += this.Launched; helper.Events.Input.ButtonPressed += this.Action; helper.ConsoleCommands.Add("shoplifter_resetsave", "Removes and readds save data added by the mod to fix broken save data, only use if you're getting errors", this.ResetSave); try { this.config = helper.ReadConfig <ModConfig>(); } catch { this.config = new ModConfig(); this.Monitor.Log("Failed to parse config file, default options will be used. Ensure only positive whole numbers are entered in config", LogLevel.Warn); } ShopMenuUtilities.gethelpers(this.Monitor, this.ModManifest, this.config); i18n.gethelpers(this.Helper.Translation, this.config); }
private void Action(object sender, ButtonPressedEventArgs e) { GameLocation location = Game1.player.currentLocation; if ((e.Button.IsActionButton() == true || e.Button == SButton.ControllerA) && Game1.dialogueUp == false && Context.CanPlayerMove == true && Context.IsWorldReady == true) { var TileX = e.Cursor.GrabTile.X; var TileY = e.Cursor.GrabTile.Y; // If using a controller, don't use cursor position if not facing wrong direction, check player is one tile under (Y - 1) tile with property if (e.Button == SButton.ControllerA && Game1.player.FacingDirection != 2) { TileX = Game1.player.getTileX(); TileY = Game1.player.getTileY() - 1; } Location tilelocation = new Location((int)TileX, (int)TileY); // Get whether tile has action property and its' parameters string[] split = location.doesTileHavePropertyNoNull((int)TileX, (int)TileY, "Action", "Buildings").Split(' '); // Tile has desired property if (split != null) { switch (split[0]) { // If the door is a locked warp, check player can enter case "LockedDoorWarp": // Player is banned from location they would warp to otherwise if (PerScreenShopsBannedFrom.Value.Contains($"{split[3]}")) { // Supress button so game doesn't warp player (they're banned) Helper.Input.Suppress(e.Button); Game1.drawObjectDialogue(i18n.string_Banned()); } break; // For each action that would open a shop that can be shoplifted, check if it can be shoplifted and take appropriate action case "HospitalShop": ShopMenuUtilities.HospitalShopliftingMenu(location, Game1.player); break; case "Carpenter": ShopMenuUtilities.CarpenterShopliftingMenu(location, Game1.player, tilelocation); break; case "AnimalShop": ShopMenuUtilities.AnimalShopShopliftingMenu(location, Game1.player, tilelocation); break; case "Blacksmith": ShopMenuUtilities.BlacksmithShopliftingMenu(location, tilelocation); break; case "Saloon": ShopMenuUtilities.SaloonShopliftingMenu(location, tilelocation); break; case "IceCreamStand": ShopMenuUtilities.IceCreamShopliftingMenu(location, tilelocation); break; case "Buy": if (split[1] == "Fish") { ShopMenuUtilities.FishShopShopliftingMenu(location); } else if (location is SeedShop && PerScreenShopliftCounter.Value < config.MaxShopliftsPerDay) { ShopMenuUtilities.SeedShopShopliftingMenu(location); } else if (location.name.Equals("SandyHouse")) { ShopMenuUtilities.SandyShopShopliftingMenu(location); } break; } } } }