示例#1
0
        public bool Recycle <T>(ref T obj) where T : class
        {
            if (obj == null)
            {
                return(false);
            }

            if (Pools.isActive == false)
            {
                PoolInternalBaseThread.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);
        }