Agent code and restructuring

This commit is contained in:
2026-06-04 11:05:21 -04:00
parent 0feac0f0a0
commit 7310e4ed71
134 changed files with 3074 additions and 895 deletions
+9 -9
View File
@@ -282,7 +282,8 @@ public class BuildOrderService : IBuildOrderService
{
return (from ordersAtTime in _buildOrder.StartedOrders
from orders in ordersAtTime.Value
where ordersAtTime.Key + (orders.Production() == null ? 0 : orders.Production().BuildTime) <= interval
let production = orders.Production()
where ordersAtTime.Key + (production?.BuildTime ?? 0) <= interval
select orders).ToList();
}
@@ -290,15 +291,14 @@ public class BuildOrderService : IBuildOrderService
{
return (from ordersAtTime in _buildOrder.StartedOrders
from orders in ordersAtTime.Value
where orders.Harvest() != null
where ordersAtTime.Key + (orders.Production() == null
? 0
: orders.Production().BuildTime) <= interval
&& !orders.Harvest().IsDepleted(
let production = orders.Production()
let harvest = orders.Harvest()
where harvest != null
let buildTime = production?.BuildTime ?? 0
where ordersAtTime.Key + buildTime <= interval
&& !harvest.IsDepleted(
interval,
ordersAtTime.Key + (orders.Production() == null
? 0
: orders.Production().BuildTime))
ordersAtTime.Key + buildTime)
select orders).ToList();
}
+3 -2
View File
@@ -11,7 +11,7 @@ public class EconomyService : IEconomyService
public List<EconomyModel> GetOverTime()
{
return buildEconomyOverTime;
return buildEconomyOverTime ?? [];
}
public void Subscribe(Action action)
@@ -67,6 +67,7 @@ public class EconomyService : IEconomyService
public EconomyModel GetEconomy(int atInterval)
{
if (buildEconomyOverTime == null) return new EconomyModel();
return atInterval >= buildEconomyOverTime.Count
? buildEconomyOverTime.Last()
: buildEconomyOverTime[atInterval];
@@ -218,7 +219,7 @@ public class EconomyService : IEconomyService
private void CarryOverEconomyFromPreviousInterval(int interval, EconomyModel economyAtSecond)
{
if (interval <= 0) return;
if (interval <= 0 || buildEconomyOverTime == null) return;
economyAtSecond.Alloy = buildEconomyOverTime[interval - 1].Alloy;
economyAtSecond.Ether = buildEconomyOverTime[interval - 1].Ether;