From 27216f78d7a08ffd14ad7040f76c8078ecdfd993 Mon Sep 17 00:00:00 2001 From: Aki Date: Mon, 2 Jan 2023 00:47:48 +0100 Subject: Moved UniqueIdentifier to universe module --- campaign/include/kurator/campaign/ShipConfig.h | 4 ++-- campaign/include/kurator/campaign/UniqueIdentifier.h | 17 ----------------- kurator/src/Battle.cpp | 4 ++-- sim/src/BaseBattle.cpp | 8 ++++---- stats/CMakeLists.txt | 2 +- stats/include/kurator/stats/events.h | 4 ++-- universe/include/kurator/universe/UniqueIdentifier.h | 17 +++++++++++++++++ 7 files changed, 28 insertions(+), 28 deletions(-) delete mode 100644 campaign/include/kurator/campaign/UniqueIdentifier.h create mode 100644 universe/include/kurator/universe/UniqueIdentifier.h diff --git a/campaign/include/kurator/campaign/ShipConfig.h b/campaign/include/kurator/campaign/ShipConfig.h index 9aec2fa..e10251b 100644 --- a/campaign/include/kurator/campaign/ShipConfig.h +++ b/campaign/include/kurator/campaign/ShipConfig.h @@ -3,7 +3,7 @@ #include #include -#include "UniqueIdentifier.h" +#include namespace kurator @@ -14,7 +14,7 @@ namespace campaign struct ShipConfig { - UniqueIdentifier identifier; + universe::UniqueIdentifier identifier; int team; std::string type; std::vector turrets; diff --git a/campaign/include/kurator/campaign/UniqueIdentifier.h b/campaign/include/kurator/campaign/UniqueIdentifier.h deleted file mode 100644 index 6e3c4f5..0000000 --- a/campaign/include/kurator/campaign/UniqueIdentifier.h +++ /dev/null @@ -1,17 +0,0 @@ -#pragma once - - -namespace kurator -{ -namespace campaign -{ - - -struct UniqueIdentifier -{ - int id; -}; - - -} // namespace campaign -} // namespace kurator diff --git a/kurator/src/Battle.cpp b/kurator/src/Battle.cpp index 52270b3..3d0ac72 100644 --- a/kurator/src/Battle.cpp +++ b/kurator/src/Battle.cpp @@ -11,13 +11,13 @@ #include #include -#include #include #include #include #include #include #include +#include #include "colors.h" #include "components.h" @@ -46,7 +46,7 @@ Battle::Battle(std::shared_ptr _session, campaign::Scenario scenario, B battle->dispatcher().sink().connect<&Battle::on_hit>(*this); battle->dispatcher().sink().connect<&Battle::on_ship_left>(*this); auto& registry = battle->registry(); - auto ships = registry.view(); + auto ships = registry.view(); for (const auto& [entity, team, type, identifier] : ships.each()) { std::string label = TextFormat("%s (%d)", type.name.c_str(), identifier.id); registry.emplace(entity, 5.0, team_color(team.id), std::move(label)); diff --git a/sim/src/BaseBattle.cpp b/sim/src/BaseBattle.cpp index 14a9ccd..17df990 100644 --- a/sim/src/BaseBattle.cpp +++ b/sim/src/BaseBattle.cpp @@ -6,7 +6,6 @@ #include #include -#include #include #include #include @@ -14,6 +13,7 @@ #include #include #include +#include #include "Builder.h" @@ -33,7 +33,7 @@ BaseBattle::BaseBattle(const campaign::Scenario& scenario) : Builder build {_registry, spawner}; for (const auto& ship : scenario.ships) { const auto entity = build(repo->ship_type(ship.type), ship.team); - _registry.emplace(entity, ship.identifier); + _registry.emplace(entity, ship.identifier); auto& state = _registry.get(entity); for (const auto& turret_type : ship.turrets) { auto def = repo->turret_type(turret_type); @@ -105,8 +105,8 @@ BaseBattle::kill_off_dead() for (auto&& [entity, points] : view.each()) { if (points.health > 0.0) continue; - if (_registry.all_of(entity)) { - const auto& [identifier, team] = _registry.get(entity); + if (_registry.all_of(entity)) { + const auto& [identifier, team] = _registry.get(entity); _dispatcher.trigger(stats::ShipLeft{time, identifier, team.id, true}); } _registry.destroy(entity); diff --git a/stats/CMakeLists.txt b/stats/CMakeLists.txt index 02b68a8..0af30a8 100644 --- a/stats/CMakeLists.txt +++ b/stats/CMakeLists.txt @@ -8,5 +8,5 @@ target_include_directories( ) target_link_libraries( ${PROJECT_NAME} - INTERFACE campaign + INTERFACE universe ) diff --git a/stats/include/kurator/stats/events.h b/stats/include/kurator/stats/events.h index a9a9612..ea25826 100644 --- a/stats/include/kurator/stats/events.h +++ b/stats/include/kurator/stats/events.h @@ -1,6 +1,6 @@ #pragma once -#include +#include namespace kurator @@ -12,7 +12,7 @@ namespace stats struct ShipLeft { double time; - campaign::UniqueIdentifier ship; + universe::UniqueIdentifier ship; int team; bool destroyed; }; diff --git a/universe/include/kurator/universe/UniqueIdentifier.h b/universe/include/kurator/universe/UniqueIdentifier.h new file mode 100644 index 0000000..d02bbb8 --- /dev/null +++ b/universe/include/kurator/universe/UniqueIdentifier.h @@ -0,0 +1,17 @@ +#pragma once + + +namespace kurator +{ +namespace universe +{ + + +struct UniqueIdentifier +{ + int id; +}; + + +} // namespace universe +} // namespace kurator -- cgit v1.1