public Table(EntityManager entityManager, EntityType type, EntityType storageType, IEnumerable <Type> columnTypes) { EntityManager = entityManager; Type = type; StorageType = storageType; Entities = new EcsId.Entity[0]; Columns = columnTypes.Select(type => Array.CreateInstance(type, 0)).ToArray(); }
public void Resize(int length) { if (length < 0) { throw new ArgumentOutOfRangeException(nameof(length), "length cannot be negative"); } if (length < Count) { throw new ArgumentOutOfRangeException(nameof(length), "length cannot be smaller than Count"); } var newEntities = new EcsId.Entity[length]; Array.Copy(Entities, newEntities, Math.Min(Entities.Length, length)); Entities = newEntities; for (var i = 0; i < Columns.Length; i++) { var elementType = Columns[i].GetType().GetElementType() !; var newColumn = Array.CreateInstance(elementType, length); Array.Copy(Columns[i], newColumn, Math.Min(Columns[i].Length, length)); Columns[i] = newColumn; } }
internal int Add(EcsId.Entity entity) { EnsureCapacity(Count + 1); Entities[Count] = entity; return(Count++); }