예제 #1
0
 public Pool(MegaPool _megaPool, PoolSettingsSO _poolSet, Transform _holder)
 {
     megaPool = _megaPool;
     holder   = _holder;
     poolSet  = _poolSet;
     for (int i = 0; i < poolSet.initialSize; i++)
     {
         poolables.Enqueue(CreateNewPoolable());
     }
 }
예제 #2
0
        public Pool GetPoolPart(PoolSettingsSO poolSettings)
        {
            Pool poolPart = GetPoolPart(poolSettings.key);

            if (poolPart == null)
            {
                poolPart = CreateNewPoolPart(poolSettings);
            }
            return(poolPart);
        }
예제 #3
0
 private void OnDestroy()
 {
     if (PoolSettingsSO.generalMegaPool == this)
     {
         PoolSettingsSO.SetGeneralMegaPool(null);
     }
     foreach (var item in dictionary)
     {
         if (item.Value == item.Value.poolSet.GetPool())
         {
             item.Value.poolSet.SetPool(null);
         }
     }
 }
예제 #4
0
        Pool CreateNewPoolPart(PoolSettingsSO poolSet)
        {
            Transform newHolder = new GameObject("Holder_" + poolSet.key).transform;

            newHolder.SetParent(transform);
            Pool newPoolPart = new Pool(this, poolSet, newHolder);

            dictionary.Add(poolSet.key, newPoolPart);
            if (poolSet.GetPool() == null)
            {
                poolSet.SetPool(newPoolPart);
            }
            return(newPoolPart);
        }
 /// <summary>
 /// Called when new iPoolable was created
 /// </summary>
 public virtual void InitializePoolable(PoolSettingsSO _poolSet)
 {
     IsInPool = true;
     poolSet  = _poolSet;
     gameObject.SetActive(false);
 }