From b019dd4f69c9fefeba9f14c2049fb352127e448f Mon Sep 17 00:00:00 2001 From: Jesse Plamondon-Willard Date: Wed, 7 Dec 2016 20:36:28 -0500 Subject: replace out_items, out_melee, and out_rings commands with a searchable list_items command --- src/TrainerMod/ItemData/SearchableObject.cs | 48 +++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 src/TrainerMod/ItemData/SearchableObject.cs (limited to 'src/TrainerMod/ItemData/SearchableObject.cs') diff --git a/src/TrainerMod/ItemData/SearchableObject.cs b/src/TrainerMod/ItemData/SearchableObject.cs new file mode 100644 index 00000000..30362f54 --- /dev/null +++ b/src/TrainerMod/ItemData/SearchableObject.cs @@ -0,0 +1,48 @@ +using StardewValley; + +namespace TrainerMod.ItemData +{ + /// An object that can be searched and added to the player's inventory through the console. + internal class SearchableObject : ISearchItem + { + /********* + ** Properties + *********/ + /// The underlying item. + private readonly Item Item; + + + /********* + ** Accessors + *********/ + /// Whether the item is valid. + public bool IsValid => this.Item != null && this.Item.Name != "Broken Item"; + + /// The item ID. + public int ID => this.Item.parentSheetIndex; + + /// The item name. + public string Name => this.Item.Name; + + /// The item type. + public ItemType Type => ItemType.Object; + + + /********* + ** Accessors + *********/ + /// Construct an instance. + /// The item ID. + public SearchableObject(int id) + { + try + { + this.Item = new Object(id, 1); + } + catch + { + // invalid + } + } + } +} \ No newline at end of file -- cgit