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
29
boss/system.cpp
Normal file
29
boss/system.cpp
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
#include "boss/system.hpp"
|
||||
#include <fmt/core.h>
|
||||
#include "components.hpp"
|
||||
#include "game_level.hpp"
|
||||
|
||||
namespace boss {
|
||||
using namespace components;
|
||||
|
||||
void System::load_config() {
|
||||
fmt::println("load it");
|
||||
}
|
||||
|
||||
shared_ptr<boss::UI> System::create_bossfight() {
|
||||
auto& level = GameDB::current_level();
|
||||
auto prev_world = GameDB::current_world();
|
||||
dbc::check(prev_world != nullptr, "Starter world for boss fights can't be null.");
|
||||
auto world = GameDB::clone_load_world(prev_world);
|
||||
auto& config = prev_world->get_the<GameConfig>();
|
||||
|
||||
auto boss_names = config.bosses.keys();
|
||||
auto& level_name = boss_names[level.index % 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);
|
||||
}
|
||||
}
|
||||
11
boss/system.hpp
Normal file
11
boss/system.hpp
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
#pragma once
|
||||
#include "dinkyecs.hpp"
|
||||
#include <memory>
|
||||
#include "boss/ui.hpp"
|
||||
|
||||
namespace boss {
|
||||
namespace System {
|
||||
void load_config();
|
||||
std::shared_ptr<boss::UI> create_bossfight();
|
||||
}
|
||||
}
|
||||
14
boss/ui.cpp
14
boss/ui.cpp
|
|
@ -1,5 +1,6 @@
|
|||
#include "boss/ui.hpp"
|
||||
#include "constants.hpp"
|
||||
#include "components.hpp"
|
||||
|
||||
namespace boss {
|
||||
using namespace guecs;
|
||||
|
|
@ -7,11 +8,16 @@ namespace boss {
|
|||
UI::UI(shared_ptr<World> world, Entity boss_id) :
|
||||
$world(world),
|
||||
$boss_id(boss_id),
|
||||
$combat_ui(true),
|
||||
$boss_sprite(textures::get_sprite("test_boss")),
|
||||
$player_sprite(textures::get_sprite("test_player")),
|
||||
$floor_sprite(textures::get_sprite("test_floor"))
|
||||
$combat_ui(true)
|
||||
{
|
||||
auto& sprite = world->get<components::Sprite>($boss_id);
|
||||
$boss_sprite = textures::get_sprite(sprite.name);
|
||||
|
||||
auto& boss_conf = world->get<components::BossFight>($boss_id);
|
||||
// floor is std::optional
|
||||
$floor_sprite = textures::get_sprite(*boss_conf.floor);
|
||||
|
||||
$player_sprite = textures::get_sprite("test_player");
|
||||
}
|
||||
|
||||
void UI::init() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue