public Aspect(SparseComponentArray sparseComponents, TypeIndexer typeIndexer, int maxEntities, int maxComponentTypes, Type[] types) { Debug.Assert(maxEntities > 0); Debug.Assert(maxComponentTypes > 0); this.maxEntities = maxEntities; this.typeIndexer = typeIndexer; this.sparseComponents = sparseComponents; typeMap = new IntMap(maxComponentTypes); entities = new PackedArray <Entity>(maxEntities); components = new IArrayWrapper[types.Length]; addedEntities = new Entity[maxEntities]; removedEntities = new Entity[maxEntities]; foreach (Type type in types) { int typeIndex = typeIndexer.GetIndex(type); int packedIndex = typeMap.Add(typeIndex); Type genericArrayWrapper = typeof(ArrayWrapper <>).MakeGenericType(type); IArrayWrapper array = (IArrayWrapper)Activator.CreateInstance(genericArrayWrapper, maxEntities); components[packedIndex] = array; Bitmask = Bitmask.Set(typeIndex); } }
public TypeIndexerTests() { typeExplorer = Substitute.For <ITypeExplorer>(); typeExplorer.GetAllTypes().Returns(new[] { typeof(TestIndexed), typeof(TestIndexedMoreVersions), typeof(TestIndexedMoreVersionsV2), typeof(TestIndexedRenamed), typeof(TestNotIndexedAbstract), typeof(TestNotIndexedGeneric <>), typeof(TestNotIndexedGeneric <>).MakeGenericType(typeof(string)), typeof(ITestNotIndexedInterface), typeof(NotIndexedUnrelated) }); sut = new TypeIndexer(typeExplorer); }
public EntityWorld(int maxEntities, int maxEvents, int maxComponentTypes) { this.maxEntities = maxEntities; this.maxComponentTypes = maxComponentTypes; entities = new PackedArray <Entity>(maxEntities); entityMasks = new B[maxEntities]; typeIndexer = new TypeIndexer(maxComponentTypes); entityManager = new EntityManager(maxEntities); sparseComponents = new SparseComponentArray(maxComponentTypes, maxEntities); changeQueue = new ThreadLocal <ChangeQueue>(() => { var cq = new ChangeQueue(maxComponentTypes, maxEvents); changeQueues.Add(cq); return(cq); }); dirtyEntities = new PackedArray <Entity>(maxEntities); entitiesToDestroy = new PackedArray <Entity>(maxEntities); }
public TypeIndex GetIndexedTypes() { var content = GetContentAtPath(TypeIndexResourceName); return(TypeIndexer.DeserializeIndex(content)); }