改上限问题

This commit is contained in:
2025-09-24 13:28:23 +08:00
parent 509ecaf18f
commit bd7dc2cb65
2 changed files with 7 additions and 8 deletions

Binary file not shown.

View File

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