using System; using System.Collections.Generic; namespace AlicizaX.ObjectPool { public readonly struct ObjectPoolCreateOptions { public readonly string Name; public readonly bool AllowMultiSpawn; public readonly float? AutoReleaseInterval; public readonly int? Capacity; public readonly float? ExpireTime; public readonly int Priority; public ObjectPoolCreateOptions( string name = "", bool allowMultiSpawn = false, float? autoReleaseInterval = null, int? capacity = null, float? expireTime = null, int priority = 0) { Name = name ?? string.Empty; AllowMultiSpawn = allowMultiSpawn; AutoReleaseInterval = autoReleaseInterval; Capacity = capacity; ExpireTime = expireTime; Priority = priority; } public ObjectPoolCreateOptions WithName(string name) => new ObjectPoolCreateOptions(name, AllowMultiSpawn, AutoReleaseInterval, Capacity, ExpireTime, Priority); public static ObjectPoolCreateOptions Single(string name = "") => new ObjectPoolCreateOptions(name: name); public static ObjectPoolCreateOptions Multi(string name = "") => new ObjectPoolCreateOptions(name: name, allowMultiSpawn: true); } public interface IObjectPoolService : IService { int Count { get; } bool HasObjectPool() where T : ObjectBase; bool HasObjectPool(string name) where T : ObjectBase; bool HasObjectPool(Type objectType); bool HasObjectPool(Type objectType, string name); IObjectPool GetObjectPool() where T : ObjectBase; IObjectPool GetObjectPool(string name) where T : ObjectBase; ObjectPoolBase GetObjectPool(Type objectType); ObjectPoolBase GetObjectPool(Type objectType, string name); ObjectPoolBase[] GetAllObjectPools(); ObjectPoolBase[] GetAllObjectPools(bool sort); void GetAllObjectPools(List results); void GetAllObjectPools(bool sort, List results); IObjectPool CreatePool(ObjectPoolCreateOptions options = default) where T : ObjectBase; ObjectPoolBase CreatePool(Type objectType, ObjectPoolCreateOptions options = default); bool DestroyObjectPool() where T : ObjectBase; bool DestroyObjectPool(string name) where T : ObjectBase; bool DestroyObjectPool(Type objectType); bool DestroyObjectPool(Type objectType, string name); bool DestroyObjectPool(IObjectPool objectPool) where T : ObjectBase; bool DestroyObjectPool(ObjectPoolBase objectPool); void Release(); void ReleaseAllUnused(); } }