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

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

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