using System; using UnityEngine; namespace SpellBoundAR.Items.Inventories { [Serializable] public class BasicInventoryEntry : IInventoryEntry { public event Action OnQuantityChanged; public event Action OnViewsChanged; [Header("Cache")] private IItemTypeData _itemTypeData; private int _quantity; private int _views; private string _timestamp; public IItemTypeData ItemTypeData => _itemTypeData; public string ItemTypeID => _itemTypeData != null ? _itemTypeData.ID : string.Empty; public int Quantity { get => _quantity; set { if (_quantity == value) return; _quantity = Mathf.Max(value, 0); _timestamp = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString(); OnQuantityChanged?.Invoke(); } } public int Views { get => _views; set { if (_views == value) return; _views = value; OnViewsChanged?.Invoke(); } } public DateTime Timestamp => DateTime.Parse(_timestamp); public BasicInventoryEntry(IItemTypeData item, int quantity, int views) { _itemTypeData = item; _quantity = quantity; _views = views; _timestamp = DateTime.Now.ToShortDateString() + " " + DateTime.Now.ToLongTimeString(); } } }