com.alicizax.unity.framework/Runtime/ObjectPool/ObjectPoolBase.cs

60 lines
1.5 KiB
C#
Raw Normal View History

using System;
2025-10-11 15:18:09 +08:00
namespace AlicizaX.ObjectPool
{
2026-04-23 19:09:56 +08:00
public abstract class ObjectPoolBase : IObjectPoolDebugView
2025-10-11 15:18:09 +08:00
{
private readonly string m_Name;
2026-04-23 19:09:56 +08:00
private string m_FullName;
2025-10-11 15:18:09 +08:00
public ObjectPoolBase() : this(null) { }
2025-10-11 15:18:09 +08:00
public ObjectPoolBase(string name)
{
m_Name = name ?? string.Empty;
}
public string Name => m_Name;
2025-10-11 15:18:09 +08:00
2026-04-23 19:09:56 +08:00
public string FullName
{
get
{
if (m_FullName == null)
m_FullName = new TypeNamePair(ObjectType, m_Name).ToString();
return m_FullName;
}
}
2025-10-11 15:18:09 +08:00
public abstract Type ObjectType { get; }
public abstract int Count { get; }
public abstract bool AllowMultiSpawn { get; }
2025-10-11 15:18:09 +08:00
public abstract float AutoReleaseInterval { get; set; }
public abstract int Capacity { get; set; }
public abstract float ExpireTime { get; set; }
public abstract int Priority { get; set; }
2025-10-11 15:18:09 +08:00
public virtual int ReleasePerFrameBudget
2025-10-11 15:18:09 +08:00
{
get => 8;
set { }
2025-10-11 15:18:09 +08:00
}
public abstract void Release();
public abstract void Release(int toReleaseCount);
public abstract void ReleaseAllUnused();
2026-04-23 19:09:56 +08:00
public abstract int GetAllObjectInfos(ObjectInfo[] results);
2025-10-11 15:18:09 +08:00
internal abstract void Update(float elapseSeconds, float realElapseSeconds);
internal abstract void Shutdown();
internal virtual void OnLowMemory()
{
ReleaseAllUnused();
}
2025-10-11 15:18:09 +08:00
}
}