public T Spawn() { foreach (var Cache in ObjectCacheList_) { if (!Cache.Value.Used) { UsedCount++; IdleCount--; var TCache = Cache.Value as ObjectPoolCache <T>; TriggerSpawn(TCache); return(TCache.Entity); } } var Obj = CreateFunc_.Invoke(); var NewCache = new ObjectPoolCache <T>(Obj); ObjectCacheList_.Add(Obj.GetInstanceID(), NewCache); TriggerSpawn(NewCache); UsedCount++; return(Obj); }
private void TriggerRecycle(ObjectPoolCache <T> Cache) { Cache.OnRecycle(); RecycleFunc_?.Invoke(Cache.Entity); }
private void TriggerDispose(ObjectPoolCache <T> Cache) { DisposeFunc_?.Invoke(Cache.Entity); }
private void TriggerSpawn(ObjectPoolCache <T> Cache) { Cache.OnSpawn(); SpawnFunc_?.Invoke(Cache.Entity); }