Protect EntityManager constructor, since it is a base class only.
This commit is contained in:
parent
2f0d961a92
commit
2950f23b4d
@ -40,11 +40,11 @@ class EntityManager : INonCopyable
|
||||
using TypeList = std::list<TypeInfo>;
|
||||
|
||||
public:
|
||||
static EntityManager& GetInstance()
|
||||
/*static EntityManager& GetInstance()
|
||||
{
|
||||
static EntityManager instance;
|
||||
return instance;
|
||||
}
|
||||
static EntityManager instance;
|
||||
return instance;
|
||||
} */
|
||||
virtual ~EntityManager() {}
|
||||
|
||||
template<typename TComponent>
|
||||
@ -76,11 +76,12 @@ class EntityManager : INonCopyable
|
||||
DictionaryMap& getPools() { return this->pool_table; }
|
||||
#endif // #endregion
|
||||
protected:
|
||||
EntityManager(); /// Protected constructor
|
||||
/// This class should not be used directly
|
||||
|
||||
void* get_pool(const TypeInfo& poolType);
|
||||
bool pool_exists(const TypeInfo& poolType);
|
||||
|
||||
EntityManager();
|
||||
|
||||
DictionaryMap pool_table;
|
||||
};
|
||||
}
|
||||
|
@ -15,11 +15,8 @@
|
||||
#include <thread>
|
||||
#include <type_traits>
|
||||
|
||||
#include "framework/core/components/Entity.hpp"
|
||||
#include "framework/core/exceptions.hpp"
|
||||
|
||||
#include "game/ComponentStore.hpp"
|
||||
//#include "game/GameConfiguration.hpp"
|
||||
// #include "game/GameConfiguration.hpp"
|
||||
#include "game/QuartzWarriors.hpp"
|
||||
|
||||
#ifdef QW_DEBUG
|
||||
@ -40,9 +37,9 @@ QuartzWarriors::QuartzWarriors() : IGame(), is_running(false), ticks(0)
|
||||
this->renderer = System::Video::new_renderer();
|
||||
|
||||
// Initialize player 1's data structs (Entity id = 0)
|
||||
component_pools.players.emplace(0, 0);
|
||||
component_pools.views.emplace(0, 0);
|
||||
component_pools.positions.emplace(0, 0);
|
||||
component_pools.players.emplace(0, 0);
|
||||
}
|
||||
|
||||
QuartzWarriors::~QuartzWarriors()
|
||||
@ -121,7 +118,8 @@ QuartzWarriors::ProcessSystemEvents()
|
||||
input_state inputStatus;
|
||||
|
||||
while (input_state::NO_EVENTS !=
|
||||
(inputStatus = System::Input::get_input(&e))) {
|
||||
(inputStatus = System::Input::get_input(&e)))
|
||||
{
|
||||
|
||||
if (input_state::ABORT == inputStatus) {
|
||||
this->Stop();
|
||||
@ -152,31 +150,37 @@ QuartzWarriors::Render()
|
||||
{
|
||||
Sint32 timeTaken;
|
||||
|
||||
mutex_lock dataLock(data_mutex);
|
||||
|
||||
System::Video::clear_screen(this->renderer);
|
||||
|
||||
/// @todo: find a way to filter only the elements in camera view
|
||||
// Render All the entities
|
||||
auto positionList = component_pools.AsSequential<PositionAttribute>();
|
||||
for (auto& position : positionList) {
|
||||
auto& viewMetadata = position.GetMetadata();
|
||||
InstanceId id = viewMetadata.instance.id;
|
||||
{
|
||||
mutex_lock dataLock(data_mutex);
|
||||
|
||||
RenderedCircle& view =
|
||||
component_pools.GetComponent<RenderedCircle>(id);
|
||||
auto positionList =
|
||||
component_pools.AsSequential<PositionAttribute>();
|
||||
|
||||
view.Draw(this->renderer, position);
|
||||
for (auto& position : positionList) {
|
||||
auto& viewMetadata = position.GetMetadata();
|
||||
InstanceId id = viewMetadata.instance.id;
|
||||
|
||||
RenderedCircle& view =
|
||||
component_pools.GetComponent<RenderedCircle>(id);
|
||||
|
||||
view.Draw(this->renderer, position);
|
||||
}
|
||||
}
|
||||
dataLock.unlock();
|
||||
// dataLock.unlock();
|
||||
|
||||
System::Video::render(this->renderer);
|
||||
if ((timeTaken = SDL_GetTicks() - ticks) < 16) {
|
||||
|
||||
#ifdef QW_DEBUG //#region print framerate
|
||||
std::cout << std::trunc(1000 / (16 - timeTaken)) << std::endl;
|
||||
auto frameDelay = (16 - timeTaken);
|
||||
#ifdef QW_DEBUG // #region print framerate
|
||||
std::cout << (1000 / (frameDelay)) << std::flush << "\b\b\b\b\b"
|
||||
<< " "
|
||||
<< "\b\b\b\b\b";
|
||||
#endif // #endregion
|
||||
SDL_Delay(16 - timeTaken);
|
||||
SDL_Delay(frameDelay);
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user