Threading for renderer, textures, entities, game state

This commit is contained in:
2026-03-11 09:01:10 +01:00
parent 755e14ad62
commit d748ca63a0
12 changed files with 218 additions and 30 deletions

View File

@@ -0,0 +1,24 @@
#pragma once
#include <shared_mutex>
#include <vector>
#include <utils.hpp>
#include <object/entity.hpp>
namespace Game::State {
class GameState {
public:
static GameState& getInstance() { static GameState instance; return instance; }
// Retrieve a COPY of the entities - Only used by renderer, use getAtIndex() for generic access
const std::vector<Object::Entity>& getEntities();
// Retrieve a REFERENCE of the entities; DANGEROUS!
std::vector<Object::Entity>* getEntitiesRef();
// Update entity at index, by REFERENCE
Object::Entity* getAtIndex(size_t at);
private:
mutable std::shared_mutex mMutex;
std::vector<Object::Entity> mEntities;
};
}