summaryrefslogtreecommitdiff
path: root/src/TrainerMod/ItemData/SearchableObject.cs
blob: 30362f54dee168a5538cd8048399a7b625756a0e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using StardewValley;

namespace TrainerMod.ItemData
{
    /// <summary>An object that can be searched and added to the player's inventory through the console.</summary>
    internal class SearchableObject : ISearchItem
    {
        /*********
        ** Properties
        *********/
        /// <summary>The underlying item.</summary>
        private readonly Item Item;


        /*********
        ** Accessors
        *********/
        /// <summary>Whether the item is valid.</summary>
        public bool IsValid => this.Item != null && this.Item.Name != "Broken Item";

        /// <summary>The item ID.</summary>
        public int ID => this.Item.parentSheetIndex;

        /// <summary>The item name.</summary>
        public string Name => this.Item.Name;

        /// <summary>The item type.</summary>
        public ItemType Type => ItemType.Object;


        /*********
        ** Accessors
        *********/
        /// <summary>Construct an instance.</summary>
        /// <param name="id">The item ID.</param>
        public SearchableObject(int id)
        {
            try
            {
                this.Item = new Object(id, 1);
            }
            catch
            {
                // invalid
            }
        }
    }
}