using UnityEngine; namespace MedievalShopkeeper { public class StorageRack : Interactable { [Header("Storage Settings")] [Tooltip("The item this rack provides.")] [SerializeField] private ItemData storedItem; [Tooltip("How many items are withdrawn at once into a crate.")] [SerializeField] private int withdrawalBatchSize = 10; public override string InteractionPrompt { get { if (storedItem != null) { return $"Withdraw {withdrawalBatchSize}x {storedItem.itemName} Crate"; } return "Empty Storage Rack"; } } public override void Interact(PlayerController player) { base.Interact(player); if (storedItem == null) { Debug.Log("[StorageRack] Rack is empty."); return; } if (player.IsCarryingItem) { Debug.LogWarning("[StorageRack] Player is already carrying a box! Drop it or stock a shelf first."); return; } // Ensure ShopInventory has enough stock before withdrawing if (ShopInventory.Instance.GetStockCount(storedItem) < withdrawalBatchSize) { Debug.LogWarning($"[StorageRack] Not enough stock in ShopInventory! Need {withdrawalBatchSize}, have {ShopInventory.Instance.GetStockCount(storedItem)}."); // Optional: For testing purposes, auto-buy the stock if empty Debug.Log("[StorageRack] Auto-buying stock for testing purposes..."); ShopInventory.Instance.BuyStock(storedItem, withdrawalBatchSize * 5); } // Withdraw from central inventory to player hands ShopInventory.Instance.WithdrawToPlayer(storedItem, withdrawalBatchSize, player); } } }