예제 #1
0
        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);
        }
예제 #2
0
 private void TriggerRecycle(ObjectPoolCache <T> Cache)
 {
     Cache.OnRecycle();
     RecycleFunc_?.Invoke(Cache.Entity);
 }
예제 #3
0
 private void TriggerDispose(ObjectPoolCache <T> Cache)
 {
     DisposeFunc_?.Invoke(Cache.Entity);
 }
예제 #4
0
 private void TriggerSpawn(ObjectPoolCache <T> Cache)
 {
     Cache.OnSpawn();
     SpawnFunc_?.Invoke(Cache.Entity);
 }