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()); } }
public Pool GetPoolPart(PoolSettingsSO poolSettings) { Pool poolPart = GetPoolPart(poolSettings.key); if (poolPart == null) { poolPart = CreateNewPoolPart(poolSettings); } return(poolPart); }
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); } } }
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); }