Create the systems.cpp for the boss fight mini game.
This commit is contained in:
parent
27b71d4ba3
commit
06f6098281
7 changed files with 67 additions and 38 deletions
|
|
@ -16,19 +16,6 @@ struct LevelScaling {
|
|||
int map_height=20;
|
||||
};
|
||||
|
||||
inline shared_ptr<DinkyECS::World> clone_load_world(shared_ptr<DinkyECS::World> prev_world)
|
||||
{
|
||||
auto world = make_shared<DinkyECS::World>();
|
||||
|
||||
if(prev_world == nullptr) {
|
||||
GameDB::load_configs(*world);
|
||||
} else {
|
||||
prev_world->clone_into(*world);
|
||||
}
|
||||
|
||||
return world;
|
||||
}
|
||||
|
||||
namespace GameDB {
|
||||
using std::shared_ptr, std::string, std::make_shared;
|
||||
|
||||
|
|
@ -48,6 +35,19 @@ namespace GameDB {
|
|||
};
|
||||
}
|
||||
|
||||
shared_ptr<DinkyECS::World> clone_load_world(shared_ptr<DinkyECS::World> prev_world) {
|
||||
auto world = make_shared<DinkyECS::World>();
|
||||
|
||||
if(prev_world == nullptr) {
|
||||
GameDB::load_configs(*world);
|
||||
} else {
|
||||
prev_world->clone_into(*world);
|
||||
}
|
||||
|
||||
return world;
|
||||
}
|
||||
|
||||
|
||||
size_t new_level(std::shared_ptr<DinkyECS::World> prev_world) {
|
||||
dbc::check(initialized, "Forgot to call GameDB::init()");
|
||||
auto world = clone_load_world(prev_world);
|
||||
|
|
@ -88,24 +88,6 @@ namespace GameDB {
|
|||
return current_level().world;
|
||||
}
|
||||
|
||||
shared_ptr<boss::UI> create_bossfight() {
|
||||
dbc::check(initialized, "Forgot to call GameDB::init()");
|
||||
auto prev_world = current_world();
|
||||
dbc::check(prev_world != nullptr, "Starter world for boss fights can't be null.");
|
||||
auto world = clone_load_world(prev_world);
|
||||
auto& config = prev_world->get_the<GameConfig>();
|
||||
|
||||
// BUG: the jank is too strong here
|
||||
auto boss_names = config.bosses.keys();
|
||||
auto& level_name = boss_names[LDB->current_level % boss_names.size()];
|
||||
auto& boss_data = config.bosses[level_name];
|
||||
|
||||
auto boss_id = world->entity();
|
||||
components::configure_entity(*world, boss_id, boss_data["components"]);
|
||||
|
||||
return make_shared<boss::UI>(world, boss_id);
|
||||
}
|
||||
|
||||
Level& create_level() {
|
||||
dbc::check(initialized, "Forgot to call GameDB::init()");
|
||||
dbc::check(LDB->current_level < LDB->levels.size(), "attempt to get next level when at end");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue