30 lines
938 B
C#
30 lines
938 B
C#
using UnityEngine;
|
|
|
|
public class PickupBagAction : MonoBehaviour, IInteractable
|
|
{
|
|
[Header("Settings")]
|
|
public ItemData bagItemData; // Reference to the bag's ScriptableObject
|
|
|
|
public void Interact()
|
|
{
|
|
// 1. Try to add the item to the inventory
|
|
bool added = InventorySystem.Instance.AddItem(bagItemData);
|
|
|
|
if (added)
|
|
{
|
|
// 2. Notify the quest system that we interacted with this object
|
|
// The quest itself will decide what to do next (e.g., show the bag in hand)
|
|
if (InteractionHandler.Instance != null)
|
|
{
|
|
InteractionHandler.Instance.NotifyInteraction(gameObject);
|
|
}
|
|
}
|
|
// If the item was not added (already exists or no space), do nothing.
|
|
// A message about this is logged from the InventorySystem.
|
|
}
|
|
|
|
public string GetDescription()
|
|
{
|
|
return "Pick up trash bags";
|
|
}
|
|
} |