Example #1
0
        public RevolutionEntity CreateEntityInChunk(RevolutionChunk chunk)
        {
            lastEntity = new RawEntity(lastEntity.Id + 1);
            chunk.AddEntity(lastEntity);
            entityToChunk[lastEntity] = chunk;

            return(new RevolutionEntity(this, lastEntity));
        }
Example #2
0
        internal void AddEntity(RawEntity entity)
        {
            entityToIndex[entity] = entities.Count;

            entities.Add(entity);
            foreach (var component in Components.Values)
            {
                component.Add(entity);
            }
        }
Example #3
0
        public RevolutionWorld(int entityInitialCapacity = 0)
        {
            lastEntity = default;

            Chunks = new RevolutionChunk[1];
            // the first chunk has no component
            Chunks[0] = new RevolutionChunk(new Type[0]);

            entityToChunk      = new Dictionary <RawEntity, RevolutionChunk>(entityInitialCapacity);
            identifierToEntity = new TwoWayDictionary <EntityIdentifier, RawEntity>(entityInitialCapacity);
        }
Example #4
0
        internal void RemoveEntity(RawEntity entity)
        {
            var idx = IndexOf(entity);

            foreach (var component in Components.Values)
            {
                component.RemoveAt(idx);
            }

            entities.RemoveAt(idx);
            // swapping back the index of the next entity to the previous index
            if (idx < entities.Count)
            {
                entityToIndex.Remove(entity);
                entityToIndex[entities[idx]] = idx;
                Parallel.For(idx, entities.Count, updateEntityIndex);
            }
        }
Example #5
0
 public int IndexOf(RawEntity entity)
 {
     //return entities.IndexOf(entity);
     return(entityToIndex[entity]);
 }
Example #6
0
 public void Add(RawEntity entity)
 {
     wrapped.Add();
 }
Example #7
0
 public RevolutionEntity(RevolutionWorld world, RawEntity raw)
 {
     World = world;
     Raw   = raw;
 }