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

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

            entities.Add(entity);
            foreach (var component in Components.Values)
            {
                component.Add(entity);
            }
        }
Beispiel #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);
        }
Beispiel #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);
            }
        }
Beispiel #5
0
 public int IndexOf(RawEntity entity)
 {
     //return entities.IndexOf(entity);
     return(entityToIndex[entity]);
 }
Beispiel #6
0
 public void Add(RawEntity entity)
 {
     wrapped.Add();
 }
Beispiel #7
0
 public RevolutionEntity(RevolutionWorld world, RawEntity raw)
 {
     World = world;
     Raw   = raw;
 }