Files
letnik3koncni-prap/include/state/gamestate.hpp

24 lines
781 B
C++

#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;
};
}