Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- public class Item : Interactable
- {
- [SerializeField] private ItemData m_itemData;
- protected override void OnInteracted(GameObject interactor)
- {
- base.OnInteracted(interactor);
- Inventory inv = interactor.GetComponent<Inventory>();
- if (inv != null)
- OnPicked(inv);
- else
- Debug.LogWarning("Failed to pick item because the picker doesn't have a Inventory component.");
- }
- protected virtual void OnPicked(Inventory pickerInv)
- {
- if (pickerInv.AddItem(m_itemData))
- {
- Destroy(gameObject);
- }
- else
- {
- Debug.LogWarning("Cannot pick item, AddItem returned false. (Inventory full?)");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement