com.alicizax.unity.framework/Runtime/ABase/ObjectPool/ObjectBase.cs
陈思海 e42be670fe 彻底重构ObjectPoolService模块
重构ObjectPoolService模块
去掉过度设计移除旧的容器列表
使用自定义Hash提高整体性能速度
单线程高吞吐
2026-04-22 13:04:31 +08:00

58 lines
1.4 KiB
C#

namespace AlicizaX.ObjectPool
{
public abstract class ObjectBase : IMemory
{
private string m_Name;
private object m_Target;
private bool m_Locked;
private float m_LastUseTime;
public string Name => m_Name;
public object Target => m_Target;
public bool Locked
{
get => m_Locked;
set => m_Locked = value;
}
public float LastUseTime
{
get => m_LastUseTime;
internal set => m_LastUseTime = value;
}
public virtual bool CustomCanReleaseFlag => true;
protected void Initialize(object target)
{
Initialize(string.Empty, target, false);
}
protected void Initialize(string name, object target)
{
Initialize(name, target, false);
}
protected void Initialize(string name, object target, bool locked)
{
m_Name = name ?? string.Empty;
m_Target = target;
m_Locked = locked;
m_LastUseTime = 0f;
}
protected internal virtual void OnSpawn() { }
protected internal virtual void OnUnspawn() { }
protected internal abstract void Release(bool isShutdown);
public virtual void Clear()
{
m_Name = null;
m_Target = null;
m_Locked = false;
m_LastUseTime = 0f;
}
}
}