Ejemplo n.º 1
0
        public EntityIndex Alloc(EntityArchetype entityArchetype)
        {
            var types  = _archetypeManager.GetArchetypeTypeList(entityArchetype);
            int offset = -1;

            for (int i = 0; i < Archetypes.Count; ++i)
            {
                if (Archetypes[i].Equals(types) && !ChunkData[i].Full)
                {
                    offset = ChunkData[i].Alloc();
                    return(new EntityIndex {
                        ChunkIndex = i, ChunkOffset = offset
                    });
                }
            }

            Archetypes.Add(entityArchetype);
            ChunkData.Add(new ArchetypeChunk(types));

            offset = ChunkData.Last().Alloc();
            return(new EntityIndex {
                ChunkIndex = ChunkData.Count - 1, ChunkOffset = offset
            });
        }
Ejemplo n.º 2
0
        public List <Type> GetArchetypeTypeList(EntityArchetype i)
        {
            var componentTypeList = _entityArchetypes[i];

            return((from eachComponentType in componentTypeList select _componentTypes[eachComponentType]).ToList());
        }