Tests are now clean so next step is to officially nuke the level manager.
This commit is contained in:
parent
564f9842a2
commit
5aca2fb56a
8 changed files with 47 additions and 72 deletions
|
@ -9,58 +9,72 @@ namespace Game {
|
|||
bool initialized = false;
|
||||
|
||||
void init() {
|
||||
LEVELS = make_shared<LevelManager>();
|
||||
initialized = true;
|
||||
if(!initialized) {
|
||||
LEVELS = make_shared<LevelManager>();
|
||||
initialized = true;
|
||||
}
|
||||
}
|
||||
|
||||
LevelManager& get_the_manager() {
|
||||
dbc::check(initialized, "Forgot to call Game::init()");
|
||||
return *LEVELS;
|
||||
}
|
||||
|
||||
shared_ptr<DinkyECS::World> current_world() {
|
||||
dbc::check(initialized, "Forgot to call Game::init()");
|
||||
return current().world;
|
||||
}
|
||||
|
||||
shared_ptr<gui::BossFightUI> create_bossfight() {
|
||||
dbc::check(initialized, "Forgot to call Game::init()");
|
||||
return LEVELS->create_bossfight(current_world());
|
||||
}
|
||||
|
||||
GameLevel& create_level() {
|
||||
dbc::check(initialized, "Forgot to call Game::init()");
|
||||
LEVELS->create_level(current_world());
|
||||
return next();
|
||||
}
|
||||
|
||||
GameLevel &next() {
|
||||
dbc::check(initialized, "Forgot to call Game::init()");
|
||||
return LEVELS->next();
|
||||
}
|
||||
|
||||
GameLevel &previous() {
|
||||
dbc::check(initialized, "Forgot to call Game::init()");
|
||||
return LEVELS->previous();
|
||||
}
|
||||
|
||||
GameLevel ¤t() {
|
||||
dbc::check(initialized, "Forgot to call Game::init()");
|
||||
return LEVELS->current();
|
||||
}
|
||||
|
||||
size_t current_index() {
|
||||
dbc::check(initialized, "Forgot to call Game::init()");
|
||||
return LEVELS->current_index();
|
||||
}
|
||||
|
||||
GameLevel &get(size_t index) {
|
||||
dbc::check(initialized, "Forgot to call Game::init()");
|
||||
return LEVELS->get(index);
|
||||
}
|
||||
|
||||
DinkyECS::Entity spawn_enemy(const std::string& named) {
|
||||
dbc::check(initialized, "Forgot to call Game::init()");
|
||||
return LEVELS->spawn_enemy(named);
|
||||
}
|
||||
|
||||
components::Position& player_position() {
|
||||
dbc::check(initialized, "Forgot to call Game::init()");
|
||||
auto world = current_world();
|
||||
auto& player = world->get_the<components::Player>();
|
||||
return world->get<components::Position>(player.entity);
|
||||
}
|
||||
|
||||
DinkyECS::Entity the_player() {
|
||||
dbc::check(initialized, "Forgot to call Game::init()");
|
||||
return current().player;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue