daily pastebin goal
36%
SHARE
TWEET

Item.cs

a guest Jan 31st, 2018 2 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using UnityEngine;
  2.  
  3. public class Item : Interactable
  4. {
  5.     [SerializeField] private ItemData m_itemData;
  6.  
  7.     protected override void OnInteracted(GameObject interactor)
  8.     {
  9.         base.OnInteracted(interactor);
  10.  
  11.         Inventory inv = interactor.GetComponent<Inventory>();
  12.         if (inv != null)
  13.             OnPicked(inv);
  14.         else
  15.             Debug.LogWarning("Failed to pick item because the picker doesn't have a Inventory component.");
  16.     }
  17.  
  18.     protected virtual void OnPicked(Inventory pickerInv)
  19.     {
  20.         if (pickerInv.AddItem(m_itemData))
  21.         {
  22.             Destroy(gameObject);
  23.         }
  24.         else
  25.         {
  26.             Debug.LogWarning("Cannot pick item, AddItem returned false. (Inventory full?)");
  27.         }
  28.     }
  29. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top