diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs | 253 |
1 files changed, 123 insertions, 130 deletions
diff --git a/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs b/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs index 1371d3a5..08dd8eed 100644 --- a/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs +++ b/src/SMAPI.Mods.ConsoleCommands/Framework/ItemRepository.cs @@ -46,6 +46,10 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework yield return this.TryCreate(ItemType.Tool, this.CustomIDOffset + 2, () => new Pan()); yield return this.TryCreate(ItemType.Tool, this.CustomIDOffset + 3, () => new Wand()); + // clothing + foreach (int id in Game1.clothingInformation.Keys) + yield return this.TryCreate(ItemType.Clothing, id, () => new Clothing(id)); + // wallpapers for (int id = 0; id < 112; id++) yield return this.TryCreate(ItemType.Wallpaper, id, () => new Wallpaper(id) { Category = SObject.furnitureCategory }); @@ -59,11 +63,6 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework yield return this.TryCreate(ItemType.Boots, id, () => new Boots(id)); foreach (int id in Game1.content.Load<Dictionary<int, string>>("Data\\hats").Keys) yield return this.TryCreate(ItemType.Hat, id, () => new Hat(id)); - foreach (int id in Game1.objectInformation.Keys) - { - if ((id >= Ring.ringLowerIndexRange && id <= Ring.ringUpperIndexRange) || (id >= 810 && id <= 811)) - yield return this.TryCreate(ItemType.Ring, id, () => new Ring(id)); - } // weapons foreach (int id in Game1.content.Load<Dictionary<int, string>>("Data\\weapons").Keys) @@ -87,147 +86,141 @@ namespace StardewModdingAPI.Mods.ConsoleCommands.Framework foreach (int id in Game1.bigCraftablesInformation.Keys) yield return this.TryCreate(ItemType.BigCraftable, id, () => new SObject(Vector2.Zero, id)); - // secret notes - foreach (int id in Game1.content.Load<Dictionary<int, string>>("Data\\SecretNotes").Keys) - { - yield return this.TryCreate(ItemType.Object, this.CustomIDOffset + id, () => - { - SObject note = new SObject(79, 1); - note.name = $"{note.name} #{id}"; - return note; - }); - } - // objects foreach (int id in Game1.objectInformation.Keys) { - if (id == 79) - continue; // secret note handled above - if ((id >= Ring.ringLowerIndexRange && id <= Ring.ringUpperIndexRange) || (id >= 810 && id <= 811)) - continue; // handled separated - - // spawn main item - SObject item; - { - SearchableItem main = this.TryCreate(ItemType.Object, id, () => id == 812 - ? new ColoredObject(id, 1, Color.White) - : new SObject(id, 1) - ); - yield return main; - item = main?.Item as SObject; - } - if (item == null) - continue; + string[] fields = Game1.objectInformation[id]?.Split('/'); - // fruit products - if (item.Category == SObject.FruitsCategory) + // secret notes + if (id == 79) { - // wine - yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 2 + id, () => + foreach (int secretNoteId in Game1.content.Load<Dictionary<int, string>>("Data\\SecretNotes").Keys) { - SObject wine = new SObject(348, 1) + yield return this.TryCreate(ItemType.Object, this.CustomIDOffset + secretNoteId, () => { - Name = $"{item.Name} Wine", - Price = item.Price * 3 - }; - wine.preserve.Value = SObject.PreserveType.Wine; - wine.preservedParentSheetIndex.Value = item.ParentSheetIndex; - return wine; - }); - - // jelly - yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 3 + id, () => - { - SObject jelly = new SObject(344, 1) - { - Name = $"{item.Name} Jelly", - Price = 50 + item.Price * 2 - }; - jelly.preserve.Value = SObject.PreserveType.Jelly; - jelly.preservedParentSheetIndex.Value = item.ParentSheetIndex; - return jelly; - }); + SObject note = new SObject(79, 1); + note.name = $"{note.name} #{secretNoteId}"; + return note; + }); + } } - // vegetable products - else if (item.Category == SObject.VegetableCategory) - { - // juice - yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 4 + id, () => - { - SObject juice = new SObject(350, 1) - { - Name = $"{item.Name} Juice", - Price = (int)(item.Price * 2.25d) - }; - juice.preserve.Value = SObject.PreserveType.Juice; - juice.preservedParentSheetIndex.Value = item.ParentSheetIndex; - return juice; - }); - - // pickled - yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 5 + id, () => - { - SObject pickled = new SObject(342, 1) - { - Name = $"Pickled {item.Name}", - Price = 50 + item.Price * 2 - }; - pickled.preserve.Value = SObject.PreserveType.Pickle; - pickled.preservedParentSheetIndex.Value = item.ParentSheetIndex; - return pickled; - }); - } + // ring + else if (id != 801 && fields?.Length >= 4 && fields[3] == "Ring") // 801 = wedding ring, which isn't an equippable ring + yield return this.TryCreate(ItemType.Ring, id, () => new Ring(id)); - // flower honey - else if (item.Category == SObject.flowersCategory) + // item + else { - yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 5 + id, () => + // spawn main item + SObject item = null; + yield return this.TryCreate(ItemType.Object, id, () => { - SObject honey = new SObject(Vector2.Zero, 340, $"{item.Name} Honey", false, true, false, false) - { - Name = $"{item.Name} Honey", - preservedParentSheetIndex = { item.ParentSheetIndex } - }; - honey.Price += item.Price * 2; - return honey; + return item = (id == 812 // roe + ? new ColoredObject(id, 1, Color.White) + : new SObject(id, 1) + ); }); - } + if (item == null) + continue; - // roe and aged roe (derived from FishPond.GetFishProduce) - else if (id == 812) - { - foreach (var pair in Game1.objectInformation) + // flavored items + switch (item.Category) { - // get input - SObject input = new SObject(pair.Key, 1); - if (input.Category != SObject.FishCategory) - continue; - Color color = TailoringMenu.GetDyeColor(input) ?? Color.Orange; - - // yield roe - SObject roe = new ColoredObject(812, 1, color) - { - name = $"{input.Name} Roe", - preserve = { Value = SObject.PreserveType.Roe }, - preservedParentSheetIndex = { Value = input.ParentSheetIndex } - }; - roe.Price += input.Price / 2; - yield return new SearchableItem(ItemType.Object, this.CustomIDOffset * 6 + 1, roe); - - // aged roe - if (pair.Key != 698) // aged sturgeon roe is caviar, which is a separate item - { - ColoredObject agedRoe = new ColoredObject(447, 1, color) + // fruit products + case SObject.FruitsCategory: + // wine + yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 2 + id, () => new SObject(348, 1) + { + Name = $"{item.Name} Wine", + Price = item.Price * 3, + preserve = { SObject.PreserveType.Wine }, + preservedParentSheetIndex = { item.ParentSheetIndex } + }); + + // jelly + yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 3 + id, () => new SObject(344, 1) + { + Name = $"{item.Name} Jelly", + Price = 50 + item.Price * 2, + preserve = { SObject.PreserveType.Jelly }, + preservedParentSheetIndex = { item.ParentSheetIndex } + }); + break; + + // vegetable products + case SObject.VegetableCategory: + // juice + yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 4 + id, () => new SObject(350, 1) + { + Name = $"{item.Name} Juice", + Price = (int)(item.Price * 2.25d), + preserve = { SObject.PreserveType.Juice }, + preservedParentSheetIndex = { item.ParentSheetIndex } + }); + + // pickled + yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 5 + id, () => new SObject(342, 1) + { + Name = $"Pickled {item.Name}", + Price = 50 + item.Price * 2, + preserve = { SObject.PreserveType.Pickle }, + preservedParentSheetIndex = { item.ParentSheetIndex } + }); + break; + + // flower honey + case SObject.flowersCategory: + yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 5 + id, () => + { + SObject honey = new SObject(Vector2.Zero, 340, $"{item.Name} Honey", false, true, false, false) + { + Name = $"{item.Name} Honey", + preservedParentSheetIndex = { item.ParentSheetIndex } + }; + honey.Price += item.Price * 2; + return honey; + }); + break; + + // roe and aged roe (derived from FishPond.GetFishProduce) + case SObject.sellAtFishShopCategory when id == 812: + foreach (var pair in Game1.objectInformation) { - name = $"Aged {input.Name} Roe", - Category = -27, - preserve = { Value = SObject.PreserveType.AgedRoe }, - preservedParentSheetIndex = { Value = input.ParentSheetIndex }, - Price = roe.Price * 2 - }; - yield return new SearchableItem(ItemType.Object, this.CustomIDOffset * 6 + 1, agedRoe); - } + // get input + SObject input = this.TryCreate(ItemType.Object, -1, () => new SObject(pair.Key, 1))?.Item as SObject; + if (input == null || input.Category != SObject.FishCategory) + continue; + Color color = TailoringMenu.GetDyeColor(input) ?? Color.Orange; + + // yield roe + SObject roe = null; + yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 7 + id, () => + { + roe = new ColoredObject(812, 1, color) + { + name = $"{input.Name} Roe", + preserve = { Value = SObject.PreserveType.Roe }, + preservedParentSheetIndex = { Value = input.ParentSheetIndex } + }; + roe.Price += input.Price / 2; + return roe; + }); + + // aged roe + if (roe != null && pair.Key != 698) // aged sturgeon roe is caviar, which is a separate item + { + yield return this.TryCreate(ItemType.Object, this.CustomIDOffset * 7 + id, () => new ColoredObject(447, 1, color) + { + name = $"Aged {input.Name} Roe", + Category = -27, + preserve = { Value = SObject.PreserveType.AgedRoe }, + preservedParentSheetIndex = { Value = input.ParentSheetIndex }, + Price = roe.Price * 2 + }); + } + } + break; } } } |