/// <summary> /// Called on inventoru update /// </summary> /// <param name="pos">Index of new item</param> /// <param name="newItem">New item data</param> public void OnInventoryUpdate(Vector2Byte pos, ItemData newItem) { Debug.Log(pos.x + " " + pos.y + " " + newItem.ID); Item item = ObjectDatabase.GetItem(newItem.ID); if (item) { inventoryUICells[pos.x, pos.y].InsertItem(item, newItem.Count); Inventory[pos.x, pos.y] = item; } else { inventoryUICells[pos.x, pos.y].RemoveItem(); Inventory[pos.x, pos.y] = null; } }
/// <summary> /// Remove item at index /// </summary> /// <param name="index">Vector2Byte item index</param> /// <returns></returns> public static bool DropItem(Vector2Byte index) { Instance.inventoryUICells[index.x, index.y].RemoveItem(); Instance.Inventory[index.x, index.y] = null; return(true); }