public DataItem(int id, string name, string icon, ITEM_POCKET pocket, ITEM_FLAG_BINARY flags, string description) : base(id) { this.name = name; this.icon = (Texture2D)Resources.Load("Icons/items/" + icon); this.pocket = pocket; SetFlags(flags); this.description = description; }
public Items GetItems(ITEM_POCKET pocket) //Returns specified pocket items as a list. Keeps the result cached in-case it's called upon every frame when drawing the inventory (no-gui) { var existing = cachedPockets[pocket]; if (existing != null && !existing.invalidate) //Check if there is a previous list of this data and ensure it's not been changed { return(existing.items); } var items = new Items(); foreach (var item in GetItems()) { if (item.data.pocket == pocket) { this.items.Add(item); } } existing = cachedPockets[pocket] = new CachePocket(items); return(items); }
public Items GetItems(ITEM_POCKET pocket) { //All items in specified pocket of inventory var items = new Items(); foreach(var item in GetItems()) { if (item.data.pocket == pocket) this.items.Add(item); } return items; }