public EntityManager(EntityManagerOptions options = null) { Options = options ?? new EntityManagerOptions(); _entityPool = InfiniteScaleObjectPool <Entity> .Create(Options.InitialPoolSize); _entities = new ConcurrentHashSet <Entity>(); _components = new ConcurrentDictionary <Type, ConcurrentDictionary <Entity, IComponent> >(); }
public EntityManager(EntityManagerOptions options = null) { Options = options ?? new EntityManagerOptions(); _entityPool = InfiniteScaleObjectPool <Entity> .Create(Options.InitialPoolSize); _entities = new ConcurrentHashSet <Entity>(Environment.ProcessorCount, (int)Options.InitialPoolSize, EntityEqualityComparer.Instance); _components = new ConcurrentDictionary <Type, ConcurrentDictionary <Entity, IComponent> >(TypeEqualityComparer.Instance); _componentSystems = LoadSystemComponents(); _indexedComponentSystems = _componentSystems.ToDictionary(x => x.GetType(), x => x, TypeEqualityComparer.Instance); _archTypes = new ConcurrentSet <ArcheType>(ArcheTypeEqualityComparer.Instance); _archeTypeMap = new ConcurrentDictionary <ArcheType, Dictionary <Entity, Dictionary <Type, IComponent> > >(ArcheTypeEqualityComparer.Instance); _entityArcheTypes = new ConcurrentDictionary <Entity, ArcheType>(Environment.ProcessorCount, (int)Options.InitialPoolSize, EntityEqualityComparer.Instance); //Assign empty archetype to collections _archTypes.Add(ArcheType.Empty); _archeTypeMap.TryAdd(ArcheType.Empty, CreateArcheTypeEntitySet()); }