split MovementSystem to MovementIntentSystem and DynamicBodySystem
This commit is contained in:
@@ -12,7 +12,8 @@
|
||||
#include "CombatSystem.h"
|
||||
#include "EcsComponents.h"
|
||||
#include "EntityAdmin.h"
|
||||
#include "MovementSystem.h"
|
||||
#include "DynamicBodySystem.h"
|
||||
#include "MovementIntentSystem.h"
|
||||
#include "ScrapSystem.h"
|
||||
#include "Ship.h"
|
||||
#include "ShipSystem.h"
|
||||
@@ -45,7 +46,8 @@ ArenaSimulation::ArenaSimulation(const GameConfig& gameConfig,
|
||||
|
||||
m_shipSystem = std::make_unique<ShipSystem>(m_gameConfig, m_admin);
|
||||
m_aiSystem = std::make_unique<AiSystem>();
|
||||
m_movementSystem = std::make_unique<MovementSystem>();
|
||||
m_movementIntentSystem = std::make_unique<MovementIntentSystem>();
|
||||
m_dynamicBodySystem = std::make_unique<DynamicBodySystem>();
|
||||
m_combatSystem = std::make_unique<CombatSystem>(m_gameConfig);
|
||||
m_scrapSystem = std::make_unique<ScrapSystem>(m_admin);
|
||||
|
||||
@@ -255,7 +257,8 @@ void ArenaSimulation::tick()
|
||||
tickDeaths();
|
||||
|
||||
// Movement (tick step 10).
|
||||
m_movementSystem->tick(m_admin);
|
||||
m_movementIntentSystem->tick(m_admin);
|
||||
m_dynamicBodySystem->tick(m_admin);
|
||||
|
||||
// Scrap despawn (tick step 11).
|
||||
m_scrapSystem->tickDespawn(m_currentTick);
|
||||
|
||||
@@ -21,7 +21,8 @@
|
||||
class AiSystem;
|
||||
class BuildingSystem;
|
||||
class CombatSystem;
|
||||
class MovementSystem;
|
||||
class DynamicBodySystem;
|
||||
class MovementIntentSystem;
|
||||
class ShipSystem;
|
||||
class ScrapSystem;
|
||||
|
||||
@@ -92,7 +93,8 @@ private:
|
||||
std::unique_ptr<BuildingSystem> m_buildingSystem;
|
||||
std::unique_ptr<ShipSystem> m_shipSystem;
|
||||
std::unique_ptr<AiSystem> m_aiSystem;
|
||||
std::unique_ptr<MovementSystem> m_movementSystem;
|
||||
std::unique_ptr<MovementIntentSystem> m_movementIntentSystem;
|
||||
std::unique_ptr<DynamicBodySystem> m_dynamicBodySystem;
|
||||
std::unique_ptr<CombatSystem> m_combatSystem;
|
||||
std::unique_ptr<ScrapSystem> m_scrapSystem;
|
||||
|
||||
|
||||
@@ -10,6 +10,7 @@
|
||||
#include "ArenaSimulation.h"
|
||||
#include "Building.h"
|
||||
#include "BuildingSystem.h"
|
||||
#include "DynamicBodyComponent.h"
|
||||
#include "EcsComponents.h"
|
||||
#include "ScrapSystem.h"
|
||||
#include "Ship.h"
|
||||
@@ -314,9 +315,9 @@ void ArenaView::drawStations(QPainter& painter)
|
||||
|
||||
void ArenaView::drawShips(QPainter& painter)
|
||||
{
|
||||
m_sim->admin().forEach<ShipIdentity, Position, Velocity, Faction>(
|
||||
m_sim->admin().forEach<ShipIdentity, Position, DynamicBodyComponent, Faction>(
|
||||
[&](entt::entity e, const ShipIdentity& /*si*/, const Position& pos,
|
||||
const Velocity& vel, const Faction& fac)
|
||||
const DynamicBodyComponent& body, const Faction& fac)
|
||||
{
|
||||
const bool hasCargo = m_sim->admin().hasAll<SalvageCargo>(e);
|
||||
const bool hasRepair = m_sim->admin().hasAll<RepairTool>(e);
|
||||
@@ -326,8 +327,8 @@ void ArenaView::drawShips(QPainter& painter)
|
||||
if (it == m_visuals->ships.end()) { return; }
|
||||
|
||||
const QPointF center = worldToWidget(pos.value);
|
||||
const QVector2D dir = (vel.value.length() > 0.0001f)
|
||||
? vel.value.normalized()
|
||||
const QVector2D dir = (body.velocity.length() > 0.0001f)
|
||||
? body.velocity.normalized()
|
||||
: QVector2D(1.0f, 0.0f);
|
||||
const QVector2D perp(-dir.y(), dir.x());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user