Cost not correct when switching fuel
Sna-aaa opened this issue · 1 comments
Hello,
It seems there is a problem with fuel resources switcher
Depending of the config resourceMultiplier for the module ModuleKerbetrotterResourceSwitch, there is a problem in computation of the fuel resource
for the FuelTank_Big, the resourceMultiplier is 1.0
In the editor, the price of the part is 1650$, and after playing to have only liquid fuel the price of the part becomes 2050$, leading to 400$ for the fuel part that is correct for 500 unit of fuel at 0.8$
Lets take the AttachableFuelTank with the resourceMultiplier of 0.1
There is only 50 units of fuel in it, but after configuring the part for liquid fuel only, the price change from 500$ to 504$. The fuel part is here about 4$, but must be around 40$ with 50 units of fuel at 0.8$
There is so an error taking the multiplier to a ² instead of just a multiplier
For me the error comes from KerbetrotterResourceSetup.cs around line 170
{
if (node.HasValue("name"))
{
name = node.GetValue("name");
}
//check of this resource exist
if (PartResourceLibrary.Instance.resourceDefinitions[name] != null)
{
if (node.HasValue("amount"))
{
amount = float.Parse(node.GetValue("amount"), CultureInfo.InvariantCulture.NumberFormat) * multiplier;
}
if (node.HasValue("maxAmount"))
{
maxAmount = float.Parse(node.GetValue("maxAmount"), CultureInfo.InvariantCulture.NumberFormat) * multiplier;
}
if (node.HasValue("isTweakable"))
{
isTweakable = bool.Parse(node.GetValue("isTweakable"));
}
cost = (float)(maxAmount * PartResourceLibrary.Instance.resourceDefinitions[name].unitCost) * (float)multiplier;
}
}
You use the multiplier to create the part amount and maxAmount that is correct
You use also the multiplier for the costs but also the maxAmount, there is no need for another * (float)multiplier, this lead to a ²