using Assets.Source.Misc;
using Assets.Source.Patterns.ObjectPool;

namespace Assets.Source.UI
{
    public class UISubItem<T> : MonoDestroyTracker, IPoolObject
    {
        public T Origin;

        void Awake()
        {
            VAwake();
            if (Origin != null)
                HandleNewOrigin();
        }

        public void SetOrigin(T origin)
        {
            Origin = origin;
            HandleNewOrigin();
        }

        public void OnSpawnFromPool()
        {
            VOnSpawnFromPool();
        }

        public void OnReturnToPool()
        {
            VOnReturnToPool();
        }

        protected virtual void HandleNewOrigin() { }
        protected virtual void VOnSpawnFromPool() { }
        protected virtual void VOnReturnToPool() { }
        protected virtual void VAwake() { }
    }
}
