|
@@ -45,18 +45,23 @@ const Signature& System::getComponentSignature() const
|
|
|
}
|
|
|
|
|
|
|
|
|
-Entity Registry::CreateEntity()
|
|
|
+Entity Registry::createEntity()
|
|
|
{
|
|
|
uint32_t entityId = this->numEntities++;
|
|
|
Entity entity(entityId);
|
|
|
this->entitiesToBeAdded.insert(entity);
|
|
|
|
|
|
- Logger::Info("Entity created with id = %s", entityId);
|
|
|
+ if (entityId >= this->entityComponentSignatures.size())
|
|
|
+ {
|
|
|
+ this->entityComponentSignatures.resize(entityId + 1);
|
|
|
+ }
|
|
|
+
|
|
|
+ Logger::Info("Entity created with id = %d", entityId);
|
|
|
|
|
|
return entity;
|
|
|
}
|
|
|
|
|
|
-void Registry::addEntityToSystem(Entity entity)
|
|
|
+void Registry::addEntityToSystems(Entity entity)
|
|
|
{
|
|
|
const auto entityId = entity.getId();
|
|
|
const auto entityComponentSignature = this->entityComponentSignatures[entityId];
|
|
@@ -76,5 +81,12 @@ void Registry::addEntityToSystem(Entity entity)
|
|
|
|
|
|
void Registry::Update()
|
|
|
{
|
|
|
+ /* Add pending entities */
|
|
|
+ for(auto entity: entitiesToBeAdded)
|
|
|
+ {
|
|
|
+ this->addEntityToSystems(entity);
|
|
|
+ }
|
|
|
+ entitiesToBeAdded.clear();
|
|
|
+
|
|
|
|
|
|
}
|