queue object destruction

This commit is contained in:
2026-04-22 08:13:20 +02:00
parent b211fbf2cd
commit a7a7f9f4e9
6 changed files with 45 additions and 1 deletions

View File

@@ -56,6 +56,7 @@ namespace Game {
static T* getEntityByName(const std::string& name);
template<typename T>
static void destroyEntity(T* entity);
static void processPendingEntityRemovals();
private:
int mTargetUpdatesPerSecond = TARGET_UPDATE_RATE;
@@ -140,7 +141,8 @@ namespace Game {
void GameManager::destroyEntity(T* entity) {
static_assert(std::is_base_of_v<Object::Entity, T>, "T must derive from Object::Entity");
if (entity) {
State::GameState::getInstance().removeEntity(entity->getName());
entity->setActive(false);
State::GameState::getInstance().queueEntityRemoval(entity->getName());
}
}
}