cargo component refactoring
This commit is contained in:
@@ -1,12 +1,11 @@
|
||||
#include "BehaviorTargeting.h"
|
||||
|
||||
#include "CargoComponent.h"
|
||||
#include "EntityAdmin.h"
|
||||
#include "FactionComponent.h"
|
||||
#include "HealthComponent.h"
|
||||
#include "HqProxyComponent.h"
|
||||
#include "ModuleOwnerComponent.h"
|
||||
#include "PositionComponent.h"
|
||||
#include "SalvageCargoComponent.h"
|
||||
#include "ShipIdentityComponent.h"
|
||||
#include "StationBodyComponent.h"
|
||||
|
||||
@@ -72,13 +71,10 @@ std::vector<CombatantInfo> buildCombatants(EntityAdmin& admin)
|
||||
std::unordered_map<entt::entity, CargoState> buildCargoByShip(EntityAdmin& admin)
|
||||
{
|
||||
std::unordered_map<entt::entity, CargoState> cargoByShip;
|
||||
admin.forEach<SalvageCargoComponent, ModuleOwnerComponent>(
|
||||
[&cargoByShip](entt::entity /*ce*/, const SalvageCargoComponent& c,
|
||||
const ModuleOwnerComponent& o)
|
||||
admin.forEach<CargoComponent>(
|
||||
[&cargoByShip](entt::entity ship, const CargoComponent& c)
|
||||
{
|
||||
CargoState& agg = cargoByShip[o.owner];
|
||||
agg.current += c.current;
|
||||
agg.capacity += c.capacity;
|
||||
cargoByShip[ship] = CargoState{c.current, c.maxCapacity};
|
||||
});
|
||||
return cargoByShip;
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ std::vector<RepairableInfo> buildRepairables(EntityAdmin& admin);
|
||||
// All ships, stations, and the HQ proxy — candidates for attack targeting.
|
||||
std::vector<CombatantInfo> buildCombatants(EntityAdmin& admin);
|
||||
|
||||
// Aggregated salvage cargo per owning ship, summed across its salvage modules.
|
||||
// Salvage cargo pool per ship, read from each ship's shared CargoComponent.
|
||||
std::unordered_map<entt::entity, CargoState> buildCargoByShip(EntityAdmin& admin);
|
||||
|
||||
// True when the ship's aggregated cargo is at capacity (and it has any capacity).
|
||||
|
||||
Reference in New Issue
Block a user