public static void clearSelect() { m_SelectedInventory = null; for (int i = 0; i < m_SelectedItemList.Count; i++) { m_SelectedItemList[i].picked = false; } m_SelectedItemList.Clear(); eventState?.Invoke(State.EndAdd); }
public void setInventory(TezInventory inventory) { if (m_Inventory != null && m_Inventory.tryGet(out var old_inventory)) { old_inventory.onItemAdded -= this.onItemAdded; old_inventory.onItemRemoved -= this.onItemRemoved; m_Inventory.close(); } this.resetSlots(); m_Inventory = inventory; inventory.onItemAdded += onItemAdded; inventory.onItemRemoved += onItemRemoved; }
public override void close() { base.close(); this.item = null; m_Inventory = null; }
public TezInventoryItemSlot(TezInventory inventory) { m_Inventory = inventory; this.picked = false; }
public static void selectSlot(TezInventory inventory, TezInventoryItemSlot itemSlot) { if (itemSlot.picked) { return; } ///没有被选择的Inventory 或者是一样的 就是Pick功能 if (m_SelectedInventory == null) { itemSlot.picked = true; m_SelectedInventory = inventory; m_SelectedItemList.Add(itemSlot); eventState?.Invoke(State.BeginAdd); } else { if (m_SelectedInventory == inventory) { itemSlot.picked = true; m_SelectedItemList.Add(itemSlot); eventState?.Invoke(State.ContinueAdd); } else { ///只选择了一个 if (m_SelectedItemList.Count == 1) { ///如果选择的槽位有item了 ///就是交换功能 if (itemSlot.item != null) { var count = m_SelectedItemList[0].count; var temp = m_SelectedItemList[0].take(); m_SelectedItemList[0].item = itemSlot.item; m_SelectedItemList[0].count = itemSlot.count; itemSlot.item = temp; itemSlot.count = count; eventState?.Invoke(State.ItemSwitch); } ///否则就是存储功能 else { var count = m_SelectedItemList[0].count; var item = m_SelectedItemList[0].take(); itemSlot.store(item, count); eventState?.Invoke(State.ContinueAdd); } } ///大量释放就是存储功能 else { for (int i = 0; i < m_SelectedItemList.Count; i++) { var count = m_SelectedItemList[i].count; var item = m_SelectedItemList[i].take(); inventory.store(item, count); } eventState?.Invoke(State.ContinueAdd); } } } }
public virtual void setInventory(TezInventory inventory) { m_InventoryRef = inventory; m_FilterManager.setInventory(inventory); }