make stations not attack other stations
This commit is contained in:
@@ -121,8 +121,7 @@ void CombatSystem::resolveStationWeapon(Building& station, Tick currentTick,
|
||||
// Acquire a new target if needed.
|
||||
if (!w.currentTarget)
|
||||
{
|
||||
w.currentTarget = acquireStationTarget(station, stationIsEnemy,
|
||||
ships, buildings);
|
||||
w.currentTarget = acquireStationTarget(station, stationIsEnemy, ships);
|
||||
}
|
||||
|
||||
if (!w.currentTarget)
|
||||
@@ -174,8 +173,7 @@ void CombatSystem::resolveStationWeapon(Building& station, Tick currentTick,
|
||||
|
||||
std::optional<EntityId> CombatSystem::acquireStationTarget(
|
||||
const Building& station, bool stationIsEnemy,
|
||||
const ShipSystem& ships,
|
||||
const BuildingSystem& buildings) const
|
||||
const ShipSystem& ships) const
|
||||
{
|
||||
const QVector2D stationCenter(
|
||||
station.anchor.x() + station.footprint.width() / 2.0f,
|
||||
@@ -202,27 +200,6 @@ std::optional<EntityId> CombatSystem::acquireStationTarget(
|
||||
}
|
||||
}
|
||||
|
||||
// Enemy stations also target player buildings (HQ, PlayerDefenceStation).
|
||||
if (stationIsEnemy)
|
||||
{
|
||||
for (const Building& b : buildings.allBuildings())
|
||||
{
|
||||
if (b.type != BuildingType::Hq &&
|
||||
b.type != BuildingType::PlayerDefenceStation)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
const QVector2D bCenter(b.anchor.x() + b.footprint.width() / 2.0f,
|
||||
b.anchor.y() + b.footprint.height() / 2.0f);
|
||||
const float dist = (bCenter - stationCenter).length();
|
||||
if (dist < bestDist)
|
||||
{
|
||||
bestDist = dist;
|
||||
best = b.id;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return best;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user