split MovementSystem to MovementIntentSystem and DynamicBodySystem
This commit is contained in:
@@ -10,9 +10,11 @@
|
||||
#include "BuildingSystem.h"
|
||||
#include "BuildingType.h"
|
||||
#include "ConfigLoader.h"
|
||||
#include "DynamicBodyComponent.h"
|
||||
#include "DynamicBodySystem.h"
|
||||
#include "EcsComponents.h"
|
||||
#include "EntityAdmin.h"
|
||||
#include "MovementSystem.h"
|
||||
#include "MovementIntentSystem.h"
|
||||
#include "Rotation.h"
|
||||
#include "ScrapSystem.h"
|
||||
#include "Ship.h"
|
||||
@@ -38,9 +40,10 @@ struct Fixture
|
||||
EntityAdmin admin;
|
||||
BuildingSystem buildings;
|
||||
ShipSystem ships;
|
||||
AiSystem ai;
|
||||
MovementSystem movement;
|
||||
ScrapSystem scraps;
|
||||
AiSystem ai;
|
||||
MovementIntentSystem movementIntent;
|
||||
DynamicBodySystem dynamicBody;
|
||||
ScrapSystem scraps;
|
||||
Tick tick;
|
||||
|
||||
explicit Fixture()
|
||||
@@ -68,7 +71,8 @@ struct Fixture
|
||||
ai.tickThreatResponseBehavior(admin, buildings);
|
||||
ai.tickRepairBehavior(admin, buildings);
|
||||
ai.tickSalvageBehavior(admin, scraps, buildings);
|
||||
movement.tick(admin);
|
||||
movementIntent.tick(admin);
|
||||
dynamicBody.tick(admin);
|
||||
++tick;
|
||||
}
|
||||
};
|
||||
@@ -115,9 +119,10 @@ TEST_CASE("BehaviorSystem: tickMovement advances ship by maxSpeedPerTick toward
|
||||
Fixture f;
|
||||
const entt::entity e = f.ships.spawn("interceptor", 1, QVector2D(0.0f, 0.0f));
|
||||
|
||||
const float speed = f.admin.get<ShipDynamics>(e).maxSpeedPerTick;
|
||||
const float speed = f.admin.get<DynamicBodyComponent>(e).maxSpeedPerTick;
|
||||
f.admin.get<MovementIntent>(e) = MovementIntent{1, QVector2D(100.0f, 0.0f)};
|
||||
f.movement.tick(f.admin);
|
||||
f.movementIntent.tick(f.admin);
|
||||
f.dynamicBody.tick(f.admin);
|
||||
|
||||
REQUIRE(pos(f.admin, e).value.x() == Approx(speed));
|
||||
REQUIRE(pos(f.admin, e).value.y() == Approx(0.0f));
|
||||
@@ -129,10 +134,11 @@ TEST_CASE("BehaviorSystem: tickMovement stops exactly at target without overshoo
|
||||
Fixture f;
|
||||
const entt::entity e = f.ships.spawn("interceptor", 1, QVector2D(0.0f, 0.0f));
|
||||
|
||||
const float speed = f.admin.get<ShipDynamics>(e).maxSpeedPerTick;
|
||||
const float speed = f.admin.get<DynamicBodyComponent>(e).maxSpeedPerTick;
|
||||
const QVector2D target(speed * 0.5f, 0.0f);
|
||||
f.admin.get<MovementIntent>(e) = MovementIntent{1, target};
|
||||
f.movement.tick(f.admin);
|
||||
f.movementIntent.tick(f.admin);
|
||||
f.dynamicBody.tick(f.admin);
|
||||
|
||||
REQUIRE(pos(f.admin, e).value.x() == Approx(target.x()));
|
||||
REQUIRE(pos(f.admin, e).value.y() == Approx(target.y()));
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <QVector2D>
|
||||
|
||||
#include "ConfigLoader.h"
|
||||
#include "DynamicBodyComponent.h"
|
||||
#include "EcsComponents.h"
|
||||
#include "EntityAdmin.h"
|
||||
#include "BuildingId.h"
|
||||
@@ -83,7 +84,7 @@ TEST_CASE("ShipSystem: interceptor level 0 maxSpeedPerTick matches formula / kTi
|
||||
|
||||
// speed_formula = "200 + 5*x" at x=0 → 200; maxSpeedPerTick = 200/30
|
||||
const float expected = 200.0f / static_cast<float>(kTickRateHz);
|
||||
REQUIRE(admin.get<ShipDynamics>(e).maxSpeedPerTick == Approx(expected));
|
||||
REQUIRE(admin.get<DynamicBodyComponent>(e).maxSpeedPerTick == Approx(expected));
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
Reference in New Issue
Block a user