public void Interact() { ToolbarSlotUI currentSlot = Toolbar.Instance.SelectedSlot; if (currentSlot.ReferencedItemStack == null && CraftingStation != null) { CraftingStation.Interact(); return; } ItemBase heldItem = currentSlot.ReferencedItemStack.ContainedItem; if (IsOn == false && heldItem.Tags.Contains(ItemSystem.ItemTags.FireStarter)) { UseFireStarter(heldItem); return; } else if (heldItem.Type == ItemSystem.ItemTypes.Material) { if ((heldItem as ItemMaterial).BurnTime > 0) { AddFuel(currentSlot.ReferencedItemStack); return; } } else { if (CraftingStation != null) { CraftingStation.Interact(); } } }
public void ChangeSelectedSlot(ToolbarSlotUI pSlot = null) { if (GameManager.Instance.Player.IsActing) { return; } // If there is a currently selected slot, unsubscribe it from listening to its item change event if (SelectedSlot != null) { SelectedSlot.OnSlotItemChanged -= ItemChanged; } // If no slot is specified, set the selected slot to the current index if (pSlot == null) { SelectedSlot = Slots[SelectedSlotIndex]; // print (SelectedSlot.gameObject.name + " " + SelectedSlot.ReferencedItemStack); } // If a slot is specified, set the selected slot to that slot and set the slot index to its index else { SelectedSlot = pSlot; for (int i = 0; i < Slots.Length; i++) { if (SelectedSlot == Slots[i]) { SelectedSlotIndex = i; break; } } } // Set the active frame graphic on the selected slot and set it off for the others SetActiveFrame(); // Subscribe the selected slot to its item change event SelectedSlot.OnSlotItemChanged += ItemChanged; //Call the item changed event ItemChanged(); if (Inventory.IsOpen && Inventory.SelectedItem.Name != "") { SelectedSlot.ChangeItem(PlayerInventory.FindItemStack(Inventory.SelectedItem.ID)); } //Call the slot change event if (OnSelectedSlotChanged != null) { OnSelectedSlotChanged(); } }