summaryrefslogtreecommitdiff
path: root/battles/src
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2022-11-15 00:37:54 +0100
committerAki <please@ignore.pl>2022-11-15 00:37:54 +0100
commit5d0cba2b45aa30226ba72231b35424d404a5eec1 (patch)
tree4b157bbb550534eec38b1a0b45e2cbd10ce43fcb /battles/src
parent4f3de714cd04ee5d99167f415843573d6bbd9f62 (diff)
downloadkurator-5d0cba2b45aa30226ba72231b35424d404a5eec1.zip
kurator-5d0cba2b45aa30226ba72231b35424d404a5eec1.tar.gz
kurator-5d0cba2b45aa30226ba72231b35424d404a5eec1.tar.bz2
Implemented naive skeleton for types repository in universe
Diffstat (limited to 'battles/src')
-rw-r--r--battles/src/BaseBattle.cpp15
-rw-r--r--battles/src/scenarios.cpp37
2 files changed, 25 insertions, 27 deletions
diff --git a/battles/src/BaseBattle.cpp b/battles/src/BaseBattle.cpp
index 815c683..8a3dc37 100644
--- a/battles/src/BaseBattle.cpp
+++ b/battles/src/BaseBattle.cpp
@@ -1,13 +1,13 @@
#include "BaseBattle.h"
-#include <cmath>
#include <memory>
+#include <type_traits>
#include <entt/entity/registry.hpp>
#include <kurator/battles/components.h>
#include <kurator/battles/Scenario.h>
-#include <kurator/universe/ShipType.h>
+#include <kurator/universe.h>
namespace kurator
@@ -23,17 +23,20 @@ BaseBattle::BaseBattle(const Scenario& scenario) :
_registry {},
spawner {total_teams_in(scenario), 2.5, 0.1}
{
+ const auto repo = universe::load_sample();
for (const auto& ship : scenario.ships) {
const auto entity = _registry.create();
- _registry.emplace<universe::ShipType>(entity, ship.type);
+ const auto type = repo->ship_type(ship.type);
+ _registry.emplace<std::decay<decltype(type)>::type>(entity, type);
_registry.emplace<Team>(entity, ship.team);
_registry.emplace<Transform>(entity, spawner.get(ship.team));
_registry.emplace<FloatingMovement>(entity, 0.4);
_registry.emplace<AIState>(entity, Point{0.0, 0.0});
- _registry.emplace<HitPoints>(entity, ship.type.base_health_points);
- for (const auto& turret_def : ship.turrets) {
+ _registry.emplace<HitPoints>(entity, type.base_health_points);
+ for (const auto& turret_name : ship.turrets) {
const auto turret = _registry.create();
- _registry.emplace<universe::TurretType>(turret, turret_def);
+ const auto def = repo->turret_type(turret_name);
+ _registry.emplace<std::decay<decltype(def)>::type>(turret, def);
_registry.emplace<TurretControl>(turret, 0.0, entity);
_registry.emplace<Transform>(turret, Point{0.0, 0.0}, 0.0, entity);
}
diff --git a/battles/src/scenarios.cpp b/battles/src/scenarios.cpp
index 3b35f44..7a79942 100644
--- a/battles/src/scenarios.cpp
+++ b/battles/src/scenarios.cpp
@@ -1,7 +1,6 @@
#include <kurator/battles/scenarios.h>
#include <kurator/battles/Scenario.h>
-#include <kurator/universe/ShipType.h>
namespace kurator
@@ -15,29 +14,25 @@ namespace scenarios
Scenario
example()
{
- const universe::ShipType halo {"halo", 6.0};
- const universe::ShipType cube {"cube", 12.0};
- const universe::ShipType bell {"bell", 30.0};
- const universe::TurretType cannon {"cannon", 1.0, 1.0, 0.5};
return {
"example",
{
- {0, halo, {cannon}},
- {0, halo, {cannon}},
- {0, cube, {cannon, cannon}},
- {0, cube, {cannon, cannon}},
- {0, cube, {cannon, cannon}},
- {0, bell, {cannon}},
- {0, bell, {cannon}},
- {0, bell, {cannon}},
- {1, halo, {cannon}},
- {1, halo, {cannon}},
- {1, bell, {cannon}},
- {1, cube, {cannon, cannon}},
- {1, cube, {cannon, cannon}},
- {1, cube, {cannon, cannon}},
- {1, bell, {cannon}},
- {1, bell, {cannon}},
+ {0, "halo", {"cannon"}},
+ {0, "halo", {"cannon"}},
+ {0, "cube", {"cannon", "cannon"}},
+ {0, "cube", {"cannon", "cannon"}},
+ {0, "cube", {"cannon", "cannon"}},
+ {0, "bell", {"cannon"}},
+ {0, "bell", {"cannon"}},
+ {0, "bell", {"cannon"}},
+ {1, "halo", {"cannon"}},
+ {1, "halo", {"cannon"}},
+ {1, "bell", {"cannon"}},
+ {1, "cube", {"cannon", "cannon"}},
+ {1, "cube", {"cannon", "cannon"}},
+ {1, "cube", {"cannon", "cannon"}},
+ {1, "bell", {"cannon"}},
+ {1, "bell", {"cannon"}},
},
};
}