Exemple #1
0
 void IPoolImplementation.PoolRecycle <T>(ref T obj)
 {
     if (this.isNull == true || this.pools.Recycle(ref obj) == false)
     {
         PoolInternalBase.CallOnDespawn(obj, null);
         obj = null;
     }
 }
Exemple #2
0
        public bool Recycle <T>(ref T obj) where T : class
        {
            if (obj == null)
            {
                return(false);
            }

            if (Pools.isActive == false)
            {
                PoolInternalBase.CallOnDespawn(obj, null);
                obj = default;
                return(false);
            }

            {
                var type = typeof(T);
                if (this.pool.TryGetValue(type, out var pool) == true)
                {
                    pool.Recycle(obj);
                    obj = default;
                    return(true);
                }
            }

            {
                var type = obj.GetType();
                if (this.pool.TryGetValue(type, out var pool) == true)
                {
                    pool.Recycle(obj);
                    obj = default;
                    return(true);
                }
            }

            return(false);
        }