using OTGIntegrated.Core; using OTGIntegrated.Inventory; using OTGIntegrated.Player; using UnityEngine; namespace OTGIntegrated.Items { [RequireComponent(typeof(Collider))] public sealed class ItemPickup : MonoBehaviour, IInteractable { public ItemData itemData; [Min(1)] public int amount = 1; public Transform InteractTransform => transform; private void Awake() { Collider ownCollider = GetComponent(); ownCollider.isTrigger = true; } public string GetPrompt() { string label = itemData != null ? itemData.displayName : "Предмет"; return $"E — подобрать: {label}"; } public bool CanInteract(GameObject interactor) { return itemData != null && amount > 0; } public void Interact(GameObject interactor) { OTGIntegrated.Inventory.Inventory inventory = GameManager.Instance != null ? GameManager.Instance.inventory : interactor.GetComponentInChildren(); if (inventory != null && inventory.AddItem(itemData, amount)) { Destroy(gameObject); } } } }