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,
|
||||
|
||||
Reference in New Issue
Block a user