改上限问题
This commit is contained in:
Binary file not shown.
@@ -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.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user