fix tests
This commit is contained in:
@@ -2,8 +2,10 @@
|
||||
|
||||
#include "EntityAdmin.h"
|
||||
#include "FactionComponent.h"
|
||||
#include "StationBodyComponent.h"
|
||||
#include "HealthComponent.h"
|
||||
#include "PositionComponent.h"
|
||||
#include "SensorRangeComponent.h"
|
||||
#include "ShipIdentityComponent.h"
|
||||
#include "ThreatResponseBehaviorComponent.h"
|
||||
#include "WeaponComponent.h"
|
||||
@@ -31,10 +33,11 @@ void CombatSystem::tick(Tick currentTick,
|
||||
resolveWeapon(e, weapon, pos, faction, currentTick, admin, outFireEvents);
|
||||
});
|
||||
|
||||
// Station weapons.
|
||||
admin.forEach<WeaponComponent, PositionComponent, FactionComponent>(
|
||||
// Station weapons (entities with StationBodyComponent; ships are excluded because
|
||||
// they lack that component and are already handled by the ship loop above).
|
||||
admin.forEach<WeaponComponent, PositionComponent, FactionComponent, StationBodyComponent>(
|
||||
[&](entt::entity e, WeaponComponent& weapon, PositionComponent& pos,
|
||||
FactionComponent& faction)
|
||||
FactionComponent& faction, const StationBodyComponent& /*sb*/)
|
||||
{
|
||||
resolveWeapon(e, weapon, pos, faction, currentTick, admin, outFireEvents);
|
||||
});
|
||||
@@ -77,10 +80,14 @@ void CombatSystem::resolveWeapon(
|
||||
}
|
||||
}
|
||||
|
||||
// Acquire a new target if needed (nearest opposing-faction ship).
|
||||
// Acquire a new target if needed.
|
||||
// Ships use their sensor range; stations fall back to weapon range.
|
||||
if (!weapon.currentTarget)
|
||||
{
|
||||
float bestDistanceSquared = weapon.range * weapon.range;
|
||||
const float acquisitionRange = admin.hasAll<SensorRangeComponent>(shipEntity)
|
||||
? admin.get<SensorRangeComponent>(shipEntity).value
|
||||
: weapon.range;
|
||||
float bestDistanceSquared = acquisitionRange * acquisitionRange;
|
||||
admin.forEach<ShipIdentityComponent, PositionComponent, FactionComponent>(
|
||||
[&](entt::entity candidate, const ShipIdentityComponent& /*si*/,
|
||||
const PositionComponent& candidatePos,
|
||||
|
||||
@@ -91,9 +91,11 @@ void MovementIntentSystem::tick(EntityAdmin& admin)
|
||||
const float manAccel = body.maneuveringAccelerationPerTick;
|
||||
const float stoppingDist = (body.maxSpeedPerTick * body.maxSpeedPerTick)
|
||||
/ (2.0f * manAccel);
|
||||
const float desiredSpeed = (dist <= stoppingDist)
|
||||
// Cap to dist so the ship never overshoots the target in a single tick.
|
||||
const float baseDesiredSpeed = (dist <= stoppingDist)
|
||||
? std::sqrt(2.0f * manAccel * dist)
|
||||
: body.maxSpeedPerTick;
|
||||
const float desiredSpeed = std::min(dist, baseDesiredSpeed);
|
||||
|
||||
const QVector2D desiredVel = delta.normalized() * desiredSpeed;
|
||||
const QVector2D velError = desiredVel - body.velocity;
|
||||
|
||||
Reference in New Issue
Block a user