Example #1
0
    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);
    }
Example #2
0
 public CachePocket(Items items)
 {
     this.items = items;
     invalidate = false;
 }
Example #3
0
 public Inventory(Trainer trainer)
 {
     this.trainer = trainer;
     items        = new Items();
     selected     = null;
 }
Example #4
0
    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;
    }
Example #5
0
    public Inventory(Trainer trainer)
    {
        this.trainer = trainer;

        items = new Items();
    }