This commit is contained in:
Tourswen
2025-09-24 13:39:16 +08:00

View File

@@ -87,21 +87,20 @@ namespace ArachnaeSwarm
if (workProgress >= Props.workAmount)
{
int unitsToCraft = (int)(workProgress / Props.workAmount);
float totalFuel = unitsToCraft * Props.fuelAmount;
float fuelToProduce = unitsToCraft * Props.fuelAmount;
float spaceInTank = fuelComp.Props.fuelCapacity - fuelComp.Fuel;
if (totalFuel > spaceInTank)
if (spaceInTank > 0)
{
totalFuel = spaceInTank;
unitsToCraft = (int)(totalFuel / Props.fuelAmount);
}
// Add as much fuel as possible, up to what was produced.
float fuelToAdd = System.Math.Min(fuelToProduce, spaceInTank);
fuelComp.Refuel(fuelToAdd);
if (unitsToCraft > 0)
{
fuelComp.Refuel(unitsToCraft * Props.fuelAmount);
// Consume the full cost, regardless of how much was actually added.
nutritionProgress -= unitsToCraft * Props.nutritionCost;
workProgress -= unitsToCraft * Props.workAmount;
}
// If spaceInTank is 0, do nothing and let progress build up.
}
}