Beispiel #1
0
        internal void AddComponent <T>(Entity entity, T component, int typeIndex)
        {
            Debug.Assert(entityManager.Contains(entity), "Entity not managed: " + entity);

            int entityIndex = entity.Index;

            sparseComponents.Add(entity.Index, component, typeIndex);
            entityMasks[entityIndex] = entityMasks[entityIndex].Set(typeIndex);

            dirtyEntities.Add(entity, entityIndex);
        }
Beispiel #2
0
 public Entity CreateEntity()
 {
     lock (entityManager)
     {
         Entity entity = entityManager.Create();
         entities.Add(entity, entity.Index);
         entityMasks[entity.Index] = default(B);
         return(entity);
     }
 }
Beispiel #3
0
        public void Add(Entity entity)
        {
            int sparseIndex = entity.Index;
            int packedIndex = entities.Add(entity, sparseIndex);

            for (int i = 0; i < components.Length; ++i)
            {
                int           typeIndex   = typeMap.GetSparse(i);
                IArrayWrapper array       = components[i];
                IArrayWrapper sparseArray = sparseComponents.GetArrayWrapper(typeIndex);
                array.AddFrom(packedIndex, sparseArray, entity.Index);
            }

            addedEntities[addedEntitiesCount++] = entity;
        }
Beispiel #4
0
        public void DestroyEntity(Entity entity)
        {
            Debug.Assert(entityManager.Contains(entity), "Entity not managed: " + entity);

            lock (entitiesToDestroy) entitiesToDestroy.Add(entity, entity.Index);
        }