public override void Entry(IModHelper helper) { mod = this; monitor = Monitor; SeedBagTool.loadTextures(); SaveEvents.AfterLoad += SaveEvents_AfterLoad; SaveEvents.AfterReturnToTitle += SaveEvents_AfterReturnToTitle; }
private void Player_InventoryChanged(object sender, InventoryChangedEventArgs e) { e.Added.Where(a => e.IsLocalPlayer && !(a is Tool) && (a?.netName?.Value?.Contains("SeedBag") ?? false) || (a?.netName?.Value?.Contains(i18n.Get("Name")) ?? false)).ToList().ForEach(s => { e.Player.removeItemFromInventory(s); e.Player.addItemToInventory(SeedBagTool.GetNew(Helper.GetPlatoHelper())); }); }
public override void Entry(IModHelper helper) { _monitor = Monitor; _helper = helper; SeedBagTool seedbag = new SeedBagTool(); addtoshop = new InventoryItem(seedbag, 30000, 1).addToNPCShop("Pierre"); CustomObjectData.newObject("Platonymous.SeedBag.Tool", SeedBagTool.texture, Color.White, "Seed Bag", "Empty", 0, customType: typeof(SeedBagTool)); }
private void OnGameLaunched(object sender, GameLaunchedEventArgs e) { SeedBagTool seedbag = new SeedBagTool(); CustomObjectData.newObject("Platonymous.SeedBag.Tool", SeedBagTool.texture, Color.White, i18n.Get("Name"), i18n.Get("Empty"), 0, customType: typeof(SeedBagTool)); InventoryItem bag = new InventoryItem(seedbag, config.Price, 1); bag.addToNPCShop(config.Shop); }
private void OnGameLaunched(object sender, GameLaunchedEventArgs e) { var platoHelper = Helper.GetPlatoHelper(); platoHelper.Harmony.LinkContruction <StardewValley.Tools.GenericTool, SeedBagTool>(); platoHelper.Harmony.LinkTypes(typeof(StardewValley.Tools.GenericTool), typeof(SeedBagTool)); SeedBagTool.LoadTextures(platoHelper); seedBagToolData = "SeedBag/" + config.Price + "/-300/Crafting/" + i18n.Get("Name") + "/" + i18n.Get("Empty"); SeedBagTool.SaveIndex = platoHelper.Content.GetSaveIndex("Plato.SeedBagTool", () => Game1.objectInformation, (s) => s.Value.StartsWith("SeedBag"), (s) => { platoHelper.Content.Injections.InjectDataInsert("Data/ObjectInformation", s.Index, seedBagToolData); Helper.Content.InvalidateCache("Data/ObjectInformation"); platoHelper.Harmony.PatchTileDraw("Plato.SeedBagObjectTile", Game1.objectSpriteSheet, (t) => t.Name == @"Maps\springobjects" || t.Equals(Game1.objectSpriteSheet), SeedBagTool.Texture, null, s.Index); platoHelper.Harmony.PatchTileDraw("Plato.SeedBagToolTile", Game1.toolSpriteSheet, (t) => t.Equals(Game1.toolSpriteSheet), SeedBagTool.Texture, null, s.Index); }); Helper.Events.Display.MenuChanged += (s, ev) => { if (ev.NewMenu is ShopMenu shop && shop.portraitPerson.Name == config.Shop) { var sale = SeedBagTool.GetNew(platoHelper); if (!shop.itemPriceAndStock.Keys.Any(k => k is Tool t && t.netName.Value.Contains("SeedBag") || k.DisplayName == sale.DisplayName || k.DisplayName == i18n.Get("Name"))) { shop.itemPriceAndStock.Add(sale, new int[2] { config.Price, 1 }); shop.forSale.Add(sale); } } }; if (Helper.ModRegistry.GetApi <PlatoTK.APIs.ISerializerAPI>("Platonymous.Toolkit") is PlatoTK.APIs.ISerializerAPI pytk) { pytk.AddPostDeserialization(ModManifest, (o) => { if (o is Chest c) { var data = pytk.ParseDataString(o); if (data.ContainsKey("@Type") && data["@Type"].Contains("SeedBagTool")) { StardewValley.Object seed = (StardewValley.Object)c.items.FirstOrDefault(i => i.Category == -74); StardewValley.Object fertilizer = (StardewValley.Object)c.items.FirstOrDefault(i => i.Category == -19); return(SeedBagTool.GetNew(platoHelper, seed, fertilizer)); } } return(o); }); } }
private void OnGameLaunched(object sender, GameLaunchedEventArgs e) { var platoHelper = Helper.GetPlatoHelper(); platoHelper.Harmony.LinkContruction <StardewValley.Tools.GenericTool, SeedBagTool>(); platoHelper.Harmony.LinkTypes(typeof(StardewValley.Tools.GenericTool), typeof(SeedBagTool)); SeedBagTool.LoadTextures(platoHelper); string seedBagTool = "Plato:IsSeedBag=true/" + config.Price + "/-300/Basic -20/" + i18n.Get("Name") + "/" + i18n.Get("Name"); SeedBagTool.TileIndex = ((Game1.toolSpriteSheet.Width / 16) * (Game1.toolSpriteSheet.Height / 16)) + 99; platoHelper.Harmony.PatchTileDraw("Plato.SeedBagToolTile", () => Game1.toolSpriteSheet, SeedBagTool.Texture, null, SeedBagTool.TileIndex); Helper.Events.Display.MenuChanged += (s, ev) => { if (ev.NewMenu is ShopMenu shop && shop.portraitPerson.Name == config.Shop) { var sale = SeedBagTool.GetNew(platoHelper); if (!shop.itemPriceAndStock.Keys.Any(k => k is Tool t && t.netName.Value.Contains("SeedBag") || k.DisplayName == sale.DisplayName || k.DisplayName == i18n.Get("Name"))) { shop.itemPriceAndStock.Add(sale, new int[2] { config.Price, 1 }); shop.forSale.Add(sale); } } }; if (Helper.ModRegistry.GetApi <PlatoTK.APIs.ISerializerAPI>("Platonymous.Toolkit") is PlatoTK.APIs.ISerializerAPI pytk) { pytk.AddPostDeserialization(ModManifest, (o) => { if (o is Chest c) { var data = pytk.ParseDataString(o); if (data.ContainsKey("@Type") && data["@Type"].Contains("SeedBagTool")) { StardewValley.Object seed = (StardewValley.Object)c.items.FirstOrDefault(i => i.Category == -74); StardewValley.Object fertilizer = (StardewValley.Object)c.items.FirstOrDefault(i => i.Category == -19); return(SeedBagTool.GetNew(platoHelper, seed, fertilizer)); } } return(o); }); } }
private void FixItems() { Game1.player.items.Where(i => i is StardewValley.Tools.GenericTool).ToList().ForEach(i => { if (i is Tool t && ((t?.netName?.Value?.Contains("Plato:IsSeedBag") ?? false) || (t?.netName?.Value?.Contains(i18n.Get("Name")) ?? false))) { int index = Game1.player.items.IndexOf(i); try { Game1.player.items[index] = SeedBagTool.GetNew(Helper.GetPlatoHelper(), t.attachments[0], t.attachments[1]); } catch { } } }); }
private void GameLoop_SaveLoaded(object sender, SaveLoadedEventArgs e) { Game1.player.items.Where(i => i is StardewValley.Tools.GenericTool).ToList().ForEach(i => { if (i is Tool t && t.netName.Value.Contains("Plato:IsSeedBag")) { Game1.player.removeItemFromInventory(t); try { Game1.player.addItemToInventory(SeedBagTool.GetNew(Helper.GetPlatoHelper(), t.attachments[0], t.attachments[1])); } catch { } } }); }