This commit is contained in:
2025-09-16 19:43:52 +08:00
parent bfc20d53a1
commit a9ecd1e0fa
4 changed files with 18 additions and 15 deletions

Binary file not shown.

View File

@@ -322,7 +322,7 @@
</categories>
</fuelFilter>
<fuelCapacity>50</fuelCapacity>
<fuelConsumptionRate>25</fuelConsumptionRate>
<fuelConsumptionRate>12.5</fuelConsumptionRate>
<consumeFuelOnlyWhenUsed>true</consumeFuelOnlyWhenUsed>
</li>
@@ -337,7 +337,7 @@
</categories>
</fuelFilter>
<fuelCapacity>50</fuelCapacity>
<fuelConsumptionRate>25</fuelConsumptionRate>
<fuelConsumptionRate>12.5</fuelConsumptionRate>
<consumeFuelOnlyWhenUsed>true</consumeFuelOnlyWhenUsed>
</li>
</comps>

View File

@@ -28,7 +28,7 @@ namespace ArachnaeSwarm
public class CompMultiFuelSpawner : ThingComp
{
private int ticksUntilSpawn;
private List<IFuelSource> fuelComps; // Changed to use the interface
private List<IFuelSource> fuelComps;
public CompProperties_MultiFuelSpawner Props => (CompProperties_MultiFuelSpawner)props;
@@ -39,7 +39,6 @@ namespace ArachnaeSwarm
{
ResetCountdown();
}
// Find all components that implement our interface
fuelComps = parent.GetComps<ThingComp>().OfType<IFuelSource>().ToList();
}
@@ -54,21 +53,20 @@ namespace ArachnaeSwarm
base.CompTick();
if (fuelComps.NullOrEmpty()) return;
// Check if all fuel sources have fuel
bool allFuelsOk = fuelComps.All(c => c.HasFuel);
if (allFuelsOk && (parent.GetComp<CompPowerTrader>()?.PowerOn ?? true))
{
// CORRECTED LOGIC: Consume fuel every tick
foreach (var comp in fuelComps)
{
comp.Notify_UsedThisTick();
}
ticksUntilSpawn--;
if (ticksUntilSpawn <= 0)
{
// Consume fuel from all sources
foreach (var comp in fuelComps)
{
comp.Notify_UsedThisTick();
}
TryDoSpawn();
ResetCountdown();
}

View File

@@ -59,7 +59,12 @@ namespace ArachnaeSwarm
// ... and so on
}
// We already have Notify_UsedThisTick from the previous step.
// If not, we would add it here.
public new void Notify_UsedThisTick()
{
if (Props.consumeFuelOnlyWhenUsed)
{
ConsumeFuel(Props.fuelConsumptionRate / 60000f);
}
}
}
}