using UnityEngine;
namespace Ashwild.Inventory
{
public enum ItemType
{
Material,
Tool,
Weapon,
Consumable
}
public enum HarvestType
{
None,
Tree,
Rock
}
[CreateAssetMenu(fileName = "NewItem", menuName = "Items/Item Data")]
public class ItemData : ScriptableObject
{
[Header("Identity")]
[SerializeField] private string itemName;
[SerializeField] private Sprite icon;
[SerializeField] [TextArea] private string description;
[Header("Stacking")]
[SerializeField] private bool isStackable = true;
[SerializeField] private int maxStackSize = 64;
[Header("Type")]
[SerializeField] private ItemType itemType;
[Header("Uses / Durability")]
[Tooltip("How many times this item can be used before it is depleted (a tool's hits, a food's bites). 0 = no usage tracking — a normal item without a uses bar.")]
[SerializeField] private int maxUses = 0;
[Tooltip("When the uses reach 0: checked = the item stays in the inventory, shown red and unusable (repairable tool, refillable container); unchecked = it is destroyed.")]
[SerializeField] private bool keepWhenDepleted = false;
[Header("Tool")]
[SerializeField] private HarvestType harvestType = HarvestType.None;
[SerializeField] private float toolPower = 1f;
[Header("Consumable")]
[SerializeField] private float healthRestore;
[SerializeField] private float hungerRestore;
[SerializeField] private float thirstRestore;
[Header("Cooking")]
[SerializeField] private ItemData cookedResult;
[SerializeField] private float cookTime = 10f;
[Header("Fuel")]
[SerializeField] private bool isFuel;
[SerializeField] private float fuelSeconds = 30f;
[Header("Prefabs")]
[SerializeField] private GameObject worldPrefab;
[SerializeField] private GameObject handPrefab;
public string ItemName => itemName;
public Sprite Icon => icon;
public string Description => description;
public bool IsStackable => isStackable;
public int MaxStackSize => maxStackSize;
public ItemType ItemType => itemType;
public int MaxUses => maxUses;
///
/// When uses run out: true keeps the item (shown red, unusable until repaired/refilled),
/// false destroys it. Repairable tools and refillable containers set this true.
///
public bool KeepWhenDepleted => keepWhenDepleted;
///
/// Whether this item tracks per-instance uses (a tool's durability, a food's bites). Items
/// with uses get a slot bar and are treated as non-stackable so each instance keeps its own value.
///
public bool HasUses => maxUses > 0;
public HarvestType HarvestType => harvestType;
public float ToolPower => toolPower;
public float HealthRestore => healthRestore;
public float HungerRestore => hungerRestore;
public float ThirstRestore => thirstRestore;
public ItemData CookedResult => cookedResult;
public float CookTime => cookTime;
public bool IsCookable => cookedResult != null;
public bool IsFuel => isFuel;
public float FuelSeconds => fuelSeconds;
public GameObject WorldPrefab => worldPrefab;
public GameObject HandPrefab => handPrefab;
}
}