switch to ECS architecture
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
#include "BuildingSystem.h"
|
||||
#include "BuildingType.h"
|
||||
#include "ConfigLoader.h"
|
||||
#include "EcsComponents.h"
|
||||
#include "EntityAdmin.h"
|
||||
#include "GameConfig.h"
|
||||
#include "ItemType.h"
|
||||
#include "ModulesConfig.h"
|
||||
@@ -96,13 +98,12 @@ TEST_CASE("Ship spawn: no modules leaves base stats unchanged", "[modules]")
|
||||
const double x = static_cast<double>(def->schematic.playerProductionLevel);
|
||||
const float expectedHp = static_cast<float>(def->health.hpFormula.evaluate(x));
|
||||
|
||||
const EntityId id = sim.ships().spawn("interceptor",
|
||||
const entt::entity e = sim.ships().spawn("interceptor",
|
||||
def->schematic.playerProductionLevel,
|
||||
QVector2D(5.0f, 5.0f), false, std::nullopt);
|
||||
|
||||
const Ship* ship = sim.ships().findShip(id);
|
||||
REQUIRE(ship != nullptr);
|
||||
CHECK(ship->maxHp == Approx(expectedHp));
|
||||
REQUIRE(sim.admin().isValid(e));
|
||||
CHECK(sim.admin().get<Health>(e).maxHp == Approx(expectedHp));
|
||||
}
|
||||
|
||||
TEST_CASE("Ship spawn: multiplicative HP module applies correctly", "[modules]")
|
||||
@@ -121,16 +122,15 @@ TEST_CASE("Ship spawn: multiplicative HP module applies correctly", "[modules]")
|
||||
pm.rotation = Rotation::East;
|
||||
layout.placedModules.push_back(pm);
|
||||
|
||||
const EntityId id = sim.ships().spawn("interceptor",
|
||||
const entt::entity e = sim.ships().spawn("interceptor",
|
||||
def->schematic.playerProductionLevel,
|
||||
QVector2D(5.0f, 5.0f), false, layout);
|
||||
|
||||
const Ship* ship = sim.ships().findShip(id);
|
||||
REQUIRE(ship != nullptr);
|
||||
REQUIRE(sim.admin().isValid(e));
|
||||
// armor_plate has multiplied_hp_formula = "1.5"
|
||||
// final = base * (1 + (1.5 - 1)) + 0 = base * 1.5
|
||||
CHECK(ship->maxHp == Approx(baseHp * 1.5f));
|
||||
CHECK(ship->hp == ship->maxHp);
|
||||
CHECK(sim.admin().get<Health>(e).maxHp == Approx(baseHp * 1.5f));
|
||||
CHECK(sim.admin().get<Health>(e).hp == sim.admin().get<Health>(e).maxHp);
|
||||
}
|
||||
|
||||
TEST_CASE("Ship spawn: additive sensor module applies correctly", "[modules]")
|
||||
@@ -149,15 +149,14 @@ TEST_CASE("Ship spawn: additive sensor module applies correctly", "[modules]")
|
||||
pm.rotation = Rotation::East;
|
||||
layout.placedModules.push_back(pm);
|
||||
|
||||
const EntityId id = sim.ships().spawn("interceptor",
|
||||
const entt::entity e = sim.ships().spawn("interceptor",
|
||||
def->schematic.playerProductionLevel,
|
||||
QVector2D(5.0f, 5.0f), false, layout);
|
||||
|
||||
const Ship* ship = sim.ships().findShip(id);
|
||||
REQUIRE(ship != nullptr);
|
||||
REQUIRE(sim.admin().isValid(e));
|
||||
// sensor_booster has added_sensor_range_formula = "10"
|
||||
// final = base * 1.0 + 10 = base + 10
|
||||
CHECK(ship->sensorRange == Approx(baseRange + 10.0f));
|
||||
CHECK(sim.admin().get<SensorRange>(e).value == Approx(baseRange + 10.0f));
|
||||
}
|
||||
|
||||
TEST_CASE("Ship spawn: multiple modules stack correctly", "[modules]")
|
||||
@@ -179,16 +178,15 @@ TEST_CASE("Ship spawn: multiple modules stack correctly", "[modules]")
|
||||
layout.placedModules.push_back(pm);
|
||||
}
|
||||
|
||||
const EntityId id = sim.ships().spawn("interceptor",
|
||||
const entt::entity e = sim.ships().spawn("interceptor",
|
||||
def->schematic.playerProductionLevel,
|
||||
QVector2D(5.0f, 5.0f), false, layout);
|
||||
|
||||
const Ship* ship = sim.ships().findShip(id);
|
||||
REQUIRE(ship != nullptr);
|
||||
REQUIRE(sim.admin().isValid(e));
|
||||
// Two armor_plates: each 1.5 multiplier
|
||||
// total_mult = 1 + (1.5 - 1) + (1.5 - 1) = 2.0
|
||||
// final = base * 2.0
|
||||
CHECK(ship->maxHp == Approx(baseHp * 2.0f));
|
||||
CHECK(sim.admin().get<Health>(e).maxHp == Approx(baseHp * 2.0f));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user