From 5d5f7192dc49546610df13147f4e076eb199efc1 Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Sun, 2 Jul 2017 17:21:28 -0400 Subject: add item repository which returns all spawnable items in the game (#302) Based on code I wrote for CJB Item Spawner. --- src/TrainerMod/Framework/ItemData/ItemType.cs | 28 +++++++++++++-- .../Framework/ItemData/SearchableItem.cs | 41 ++++++++++++++++++++++ 2 files changed, 67 insertions(+), 2 deletions(-) create mode 100644 src/TrainerMod/Framework/ItemData/SearchableItem.cs (limited to 'src/TrainerMod/Framework/ItemData') diff --git a/src/TrainerMod/Framework/ItemData/ItemType.cs b/src/TrainerMod/Framework/ItemData/ItemType.cs index f93160a2..423455e9 100644 --- a/src/TrainerMod/Framework/ItemData/ItemType.cs +++ b/src/TrainerMod/Framework/ItemData/ItemType.cs @@ -3,13 +3,37 @@ /// An item type that can be searched and added to the player through the console. internal enum ItemType { + /// A big craftable object in + BigCraftable, + + /// A item. + Boots, + + /// A fish item. + Fish, + + /// A flooring item. + Flooring, + + /// A item. + Furniture, + + /// A item. + Hat, + /// Any object in (except rings). Object, - /// A ring in . + /// A item. Ring, - /// A weapon from Data\weapons. + /// A tool. + Tool, + + /// A wall item. + Wallpaper, + + /// A or item. Weapon } } diff --git a/src/TrainerMod/Framework/ItemData/SearchableItem.cs b/src/TrainerMod/Framework/ItemData/SearchableItem.cs new file mode 100644 index 00000000..146da1a8 --- /dev/null +++ b/src/TrainerMod/Framework/ItemData/SearchableItem.cs @@ -0,0 +1,41 @@ +using StardewValley; + +namespace TrainerMod.Framework.ItemData +{ + /// A game item with metadata. + internal class SearchableItem + { + /********* + ** Accessors + *********/ + /// The item type. + public ItemType Type { get; } + + /// The item instance. + public Item Item { get; } + + /// The item's unique ID for its type. + public int ID { get; } + + /// The item's default name. + public string Name => this.Item.Name; + + /// The item's display name for the current language. + public string DisplayName => this.Item.DisplayName; + + + /********* + ** Public methods + *********/ + /// Construct an instance. + /// The item type. + /// The unique ID (if different from the item's parent sheet index). + /// The item instance. + public SearchableItem(ItemType type, int id, Item item) + { + this.Type = type; + this.ID = id; + this.Item = item; + } + } +} -- cgit