Next phase of the refactor is done. Now to replace everything in Systems.
This commit is contained in:
parent
644ff6edc0
commit
81e25f73bb
10 changed files with 163 additions and 82 deletions
66
game_level.cpp
Normal file
66
game_level.cpp
Normal file
|
@ -0,0 +1,66 @@
|
|||
#include "game_level.hpp"
|
||||
#include "levelmanager.hpp"
|
||||
#include "components.hpp"
|
||||
|
||||
namespace Game {
|
||||
using std::shared_ptr, std::string, std::make_shared;
|
||||
|
||||
shared_ptr<LevelManager> LEVELS;
|
||||
bool initialized = false;
|
||||
|
||||
void init() {
|
||||
LEVELS = make_shared<LevelManager>();
|
||||
initialized = true;
|
||||
}
|
||||
|
||||
LevelManager& get_the_manager() {
|
||||
return *LEVELS;
|
||||
}
|
||||
|
||||
shared_ptr<DinkyECS::World> current_world() {
|
||||
return current().world;
|
||||
}
|
||||
|
||||
shared_ptr<gui::BossFightUI> create_bossfight() {
|
||||
return LEVELS->create_bossfight(current_world());
|
||||
}
|
||||
|
||||
GameLevel& create_level() {
|
||||
LEVELS->create_level(current_world());
|
||||
return next();
|
||||
}
|
||||
|
||||
GameLevel &next() {
|
||||
return LEVELS->next();
|
||||
}
|
||||
|
||||
GameLevel &previous() {
|
||||
return LEVELS->previous();
|
||||
}
|
||||
|
||||
GameLevel ¤t() {
|
||||
return LEVELS->current();
|
||||
}
|
||||
|
||||
size_t current_index() {
|
||||
return LEVELS->current_index();
|
||||
}
|
||||
|
||||
GameLevel &get(size_t index) {
|
||||
return LEVELS->get(index);
|
||||
}
|
||||
|
||||
DinkyECS::Entity spawn_enemy(const std::string& named) {
|
||||
return LEVELS->spawn_enemy(named);
|
||||
}
|
||||
|
||||
components::Position& player_position() {
|
||||
auto world = current_world();
|
||||
auto& player = world->get_the<components::Player>();
|
||||
return world->get<components::Position>(player.entity);
|
||||
}
|
||||
|
||||
DinkyECS::Entity the_player() {
|
||||
return current().player;
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue