public void RightClickInteractWithAnItem(InteractableItemBase mInteractItem) //Exact same method as InteractWithItemAnimEvent() which is Being called in the animation events, this is for rightclickmenu { if (mInteractItem != null) { mInteractItem.OnInteract(); if (mInteractItem is InventoryItemBase) //If the interactable item is an InventoryItemBase (like axe) { InventoryItemBase inventoryItem = mInteractItem as InventoryItemBase; // inventoryItem becomes the interacted with item if it is an Instance of InventoryItemBase? (as is like is keyword + cast) Inventory.AddItem(inventoryItem); inventoryItem.OnPickup(); if (inventoryItem.UseItemAfterPickup) { Inventory.UseItem(inventoryItem); } } } else { Debug.Log("mInteractItem is null"); } Hud.CloseMessagePanel(); mInteractItem = null; }
public void InteractWithItem() { if (mInteractItem != null) { mInteractItem.OnInteract(); if (mInteractItem is InventoryItemBase) { InventoryItemBase inventoryItem = mInteractItem as InventoryItemBase; inventory.AddItem(inventoryItem); inventoryItem.OnPickup(); if (inventoryItem.UseItemAfterPickup) { inventory.UseItem(inventoryItem); } } } hud.CloseMessagePanel(); mInteractItem = null; }