Exemple #1
0
        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();
        }
Exemple #2
0
        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;
            }
        }
Exemple #3
0
 internal int Add(EcsId.Entity entity)
 {
     EnsureCapacity(Count + 1);
     Entities[Count] = entity;
     return(Count++);
 }