/// <summary> /// Scan and register all inventory slots /// </summary> private void RegisterSlots() { Node rowContainer = GetNode(rowContainerPath); for (int row = 0; row < 4; row++) { for (int col = 0; col < 2; col++) { LootChestSlot slot = rowContainer.GetNode <LootChestSlot>($"{row}/{col}"); chestInventorySlots[row, col] = slot; } } }
/// <summary> /// Unload the ItemInventoryTiles in the LootChestMenu, this should NOT remove the item from the original chest /// </summary> public void UnloadChest() { // Dispose of chest tiles for (int row = 0; row < 4; row++) { for (int col = 0; col < 2; col++) { LootChestSlot slot = chestInventorySlots[row, col]; if (slot.IsOccupied()) { ItemInventoryTile tile = slot.GetItemTile(); slot.RemoveItemTileNoPropagate(); // Do not remove the Item from the Chest!! tile.QueueFree(); } } } currentChest.Close(); currentChest = null; }
private void HandleOnLootAllPressed() { for (int row = 0; row < 4; row++) { for (int col = 0; col < 2; col++) { LootChestSlot slot = chestInventorySlots[row, col]; if (slot.IsOccupied() && backPackSlotManager.HasEmptySlots()) { // Take ItemTile from Chest ItemInventoryTile tile = slot.GetItemTile(); slot.RemoveItemTile(); // Add to the Backpack and to the inventory backPackSlotManager.AddItemTileToBackpack(tile); inventoryController.AddItem(tile.GetParentItem(), false); } } } }
private void AddTileToSlot(ItemInventoryTile tile) { LootChestSlot slot = GetEmptySlot(); slot.AddItemTile(tile); }