move ecs related code to own folder

This commit is contained in:
2026-05-25 08:46:58 +02:00
parent 8ad7530740
commit 25ff3c56c5
54 changed files with 877 additions and 680 deletions

View File

@@ -0,0 +1,30 @@
SET(HDRS
${HDRS}
${CMAKE_CURRENT_SOURCE_DIR}/DespawnAtComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/DynamicBodyComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/FacingComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/FactionComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/HealthComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/HomeReturnBehaviorComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/HqProxyComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/MovementIntentComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/PositionComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/RallyBehaviorComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/RepairBehaviorComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/RepairToolComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/SalvageBehaviorComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/SalvageCargoComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/ScrapDataComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/SensorRangeComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/ShipIdentityComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/StationBodyComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/ThreatResponseBehaviorComponent.h
${CMAKE_CURRENT_SOURCE_DIR}/WeaponComponent.h
PARENT_SCOPE
)
set(LIB_INCLUDE_PATH
${LIB_INCLUDE_PATH}
${CMAKE_CURRENT_SOURCE_DIR}
PARENT_SCOPE
)

View File

@@ -0,0 +1,8 @@
#pragma once
#include "Tick.h"
struct DespawnAtComponent
{
Tick tick;
};

View File

@@ -0,0 +1,21 @@
#pragma once
#include <QVector2D>
struct DynamicBodyComponent
{
// --- dynamics parameters (formerly ShipDynamics) ---
float maxSpeedPerTick;
float mainAccelerationPerTick;
float maneuveringAccelerationPerTick;
float angularAccelerationPerTick;
float maxRotationSpeedPerTick;
// --- integrated state ---
QVector2D velocity;
float angularVelocity;
// --- written each tick by MovementIntentSystem, consumed by DynamicBodySystem ---
QVector2D linearAcceleration;
float angularAcceleration;
};

View File

@@ -0,0 +1,6 @@
#pragma once
struct FacingComponent
{
float radians;
};

View File

@@ -0,0 +1,6 @@
#pragma once
struct FactionComponent
{
bool isEnemy;
};

View File

@@ -0,0 +1,7 @@
#pragma once
struct HealthComponent
{
float hp;
float maxHp;
};

View File

@@ -0,0 +1,9 @@
#pragma once
#include <QVector2D>
struct HomeReturnBehaviorComponent
{
float retreatHpFraction;
QVector2D homePos;
};

View File

@@ -0,0 +1,6 @@
#pragma once
struct HqProxyComponent
{
char unused = 0;
};

View File

@@ -0,0 +1,12 @@
#pragma once
#include <QVector2D>
// A ship-behavior system writes this each tick before movement runs; the
// highest-priority write wins. Priority order is fixed globally — see
// architecture.md "Movement Arbitration".
struct MovementIntentComponent
{
int priority;
QVector2D target;
};

View File

@@ -0,0 +1,8 @@
#pragma once
#include <QVector2D>
struct PositionComponent
{
QVector2D value;
};

View File

@@ -0,0 +1,8 @@
#pragma once
#include <QVector2D>
struct RallyBehaviorComponent
{
QVector2D rallyPoint;
};

View File

@@ -0,0 +1,10 @@
#pragma once
#include <optional>
#include "entt/entity/entity.hpp"
struct RepairBehaviorComponent
{
std::optional<entt::entity> currentTarget;
};

View File

@@ -0,0 +1,12 @@
#pragma once
#include <optional>
#include "entt/entity/entity.hpp"
struct RepairToolComponent
{
float ratePerTick;
float range;
std::optional<entt::entity> currentTarget;
};

View File

@@ -0,0 +1,13 @@
#pragma once
#include <optional>
#include <QVector2D>
#include "BuildingId.h"
struct SalvageBehaviorComponent
{
std::optional<QVector2D> scrapTarget;
BuildingId deliveryBay; // kInvalidBuildingId until assigned at a salvage bay
};

View File

@@ -0,0 +1,8 @@
#pragma once
struct SalvageCargoComponent
{
int capacity;
int current;
float collectionRange;
};

View File

@@ -0,0 +1,6 @@
#pragma once
struct ScrapDataComponent
{
int amount;
};

View File

@@ -0,0 +1,6 @@
#pragma once
struct SensorRangeComponent
{
float value;
};

View File

@@ -0,0 +1,9 @@
#pragma once
#include <string>
struct ShipIdentityComponent
{
int level;
std::string schematicId;
};

View File

@@ -0,0 +1,13 @@
#pragma once
#include <vector>
#include <QPoint>
#include <QSize>
struct StationBodyComponent
{
QPoint anchor;
QSize footprint;
std::vector<QPoint> bodyCells;
};

View File

@@ -0,0 +1,10 @@
#pragma once
#include <optional>
#include "entt/entity/entity.hpp"
struct ThreatResponseBehaviorComponent
{
std::optional<entt::entity> currentTarget;
};

View File

@@ -0,0 +1,14 @@
#pragma once
#include <optional>
#include "entt/entity/entity.hpp"
struct WeaponComponent
{
float damage;
float range;
float fireRateHz;
float cooldownTicks;
std::optional<entt::entity> currentTarget;
};