Exemple #1
0
        /// <summary>
        /// Creates new ecs-world instance.
        /// </summary>
        /// <param name="config">Optional config for default cache sizes. On zero or negative value - default value will be used.</param>
        public EcsWorld(EcsWorldConfig config = default)
        {
            var finalConfig = new EcsWorldConfig {
                EntityComponentsCacheSize = config.EntityComponentsCacheSize <= 0
                    ? EcsWorldConfig.DefaultEntityComponentsCacheSize
                    : config.EntityComponentsCacheSize,
                FilterEntitiesCacheSize = config.FilterEntitiesCacheSize <= 0
                    ? EcsWorldConfig.DefaultFilterEntitiesCacheSize
                    : config.FilterEntitiesCacheSize,
                WorldEntitiesCacheSize = config.WorldEntitiesCacheSize <= 0
                    ? EcsWorldConfig.DefaultWorldEntitiesCacheSize
                    : config.WorldEntitiesCacheSize,
                WorldFiltersCacheSize = config.WorldFiltersCacheSize <= 0
                    ? EcsWorldConfig.DefaultWorldFiltersCacheSize
                    : config.WorldFiltersCacheSize,
                WorldComponentPoolsCacheSize = config.WorldComponentPoolsCacheSize <= 0
                    ? EcsWorldConfig.DefaultWorldComponentPoolsCacheSize
                    : config.WorldComponentPoolsCacheSize
            };

            Config       = finalConfig;
            Entities     = new EcsEntityData[Config.WorldEntitiesCacheSize];
            FreeEntities = new EcsGrowList <int> (Config.WorldEntitiesCacheSize);
            Filters      = new EcsGrowList <EcsFilter> (Config.WorldFiltersCacheSize);
            FilterByIncludedComponents = new Dictionary <int, EcsGrowList <EcsFilter> > (Config.WorldFiltersCacheSize);
            FilterByExcludedComponents = new Dictionary <int, EcsGrowList <EcsFilter> > (Config.WorldFiltersCacheSize);
            ComponentPools             = new IEcsComponentPool[Config.WorldComponentPoolsCacheSize];
            _filterCtor = new object[] { this };
        }
Exemple #2
0
 public EcsWorld(int initialCapacity)
 {
     Entities     = new EcsEntityData[initialCapacity];
     FreeEntities = new EcsGrowList <int>(initialCapacity);
 }
Exemple #3
0
 public EcsWorld()
 {
     Entities     = new EcsEntityData[1024];
     FreeEntities = new EcsGrowList <int>(1024);
 }