depend on factory data instead of BuildingSystem in the AI path

This commit is contained in:
2026-08-05 06:44:49 +02:00
parent 46932e4abf
commit 0408336cf9
17 changed files with 238 additions and 126 deletions

View File

@@ -1,4 +1,5 @@
#include "SalvagerSystem.h"
#include "FactoryQueries.h"
#include <vector>
@@ -23,7 +24,7 @@ SalvagerSystem::SalvagerSystem(EntityAdmin& admin)
{
}
void SalvagerSystem::tick(Tick currentTick, DebrisSystem& debris, BuildingSystem& buildings,
void SalvagerSystem::tick(Tick currentTick, DebrisSystem& debris, FactoryState& state,
std::vector<BeamFiredEvent>& outBeamFiredEvents)
{
TRACE();
@@ -89,7 +90,7 @@ void SalvagerSystem::tick(Tick currentTick, DebrisSystem& debris, BuildingSystem
[&](entt::entity ship, const DeliverScrapBehavior& deliver, const PositionComponent& pos)
{
if (!deliver.deliveryBay.has_value()) { return; }
const Building* bay = buildings.findBuilding(*deliver.deliveryBay);
const Building* bay = findBuilding(state, *deliver.deliveryBay);
if (!bay) { return; }
const QVector2D bayCenter(bay->anchor.x() + bay->footprint.width() / 2.0f,
@@ -100,7 +101,7 @@ void SalvagerSystem::tick(Tick currentTick, DebrisSystem& debris, BuildingSystem
if (!m_admin.hasAll<CargoComponent>(ship)) { return; }
CargoComponent& cargo = m_admin.get<CargoComponent>(ship);
if (cargo.current <= 0) { return; }
if (buildings.deliverScrapToSalvageBay(*deliver.deliveryBay))
if (deliverScrapToSalvageBay(state, *deliver.deliveryBay))
{
--cargo.current;
}