Beispiel #1
0
        public static T Spawn <T>() where T : class, IFilterBase, new()
        {
            var key = WorldUtilities.GetKey <T>();
            PoolInternalBase pool;

            if (PoolFilters.pool.TryGetValue(key, out pool) == true)
            {
                var obj = pool.Spawn();
                if (obj != null)
                {
                    return((T)obj);
                }
            }
            else
            {
                pool = new PoolInternalBase(null, null);
                var obj = (T)pool.Spawn();
                PoolFilters.pool.Add(key, pool);
                if (obj != null)
                {
                    return(obj);
                }
            }

            return(PoolInternalBase.Create <T>());
        }
Beispiel #2
0
        public static T Spawn <T>() where T : class, IComponentBase, new()
        {
            var key = WorldUtilities.GetKey <T>();
            var obj = (T)PoolComponents.Spawn_INTERNAL(key);

            if (obj != null)
            {
                return(obj);
            }

            return(PoolInternalBase.Create <T>());
        }
Beispiel #3
0
        public static StructRegistryBase Spawn <T>() where T : struct, IStructComponent
        {
            var key = WorldUtilities.GetAllComponentTypeId <T>();
            var obj = (StructComponents <T>)PoolRegistries.Spawn_INTERNAL(key, out var pool);

            if (obj != null)
            {
                return(obj);
            }

            return(PoolInternalBase.Create <StructComponents <T> >(pool));
        }