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

54 lines
1.4 KiB
C#
Raw Normal View History

using System;
using System.Collections.Generic;
2025-10-11 15:18:09 +08:00
namespace AlicizaX.ObjectPool
{
2025-10-11 15:18:09 +08:00
public abstract class ObjectPoolBase
{
private readonly string m_Name;
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
public string FullName => new TypeNamePair(ObjectType, m_Name).ToString();
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();
public abstract ObjectInfo[] GetAllObjectInfos();
public abstract void GetAllObjectInfos(List<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
}
}