entity destruction, etc.

This commit is contained in:
2026-03-15 19:22:20 +01:00
parent 2983b919cd
commit d522881358
6 changed files with 101 additions and 47 deletions

View File

@@ -20,6 +20,7 @@ namespace Game::State {
}
void sort(); // Sort entities by zIndex for correct rendering order
void wipe();
Object::Entity* getEntityByName(const std::string& name); // Get an entity by name, returns nullptr if no entity with the name exists
std::vector<Object::Entity*> getEntitiesSnapshot(bool sortByZIndex = false); // Get a stable snapshot of entity pointers for iteration outside the lock
@@ -27,6 +28,7 @@ namespace Game::State {
Object::Entity* getAtIndex(size_t at);
// Add an entity to the gamestate.
void addEntity(std::unique_ptr<Object::Entity> entity);
bool removeEntity(const std::string& name);
private:
mutable std::mutex mMutex; // Shared mutex for thread safety