Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cost not correct when switching fuel #75

Open
Sna-aaa opened this issue Feb 13, 2023 · 1 comment
Open

Cost not correct when switching fuel #75

Sna-aaa opened this issue Feb 13, 2023 · 1 comment

Comments

@Sna-aaa
Copy link

Sna-aaa commented Feb 13, 2023

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

@Sna-aaa
Copy link
Author

Sna-aaa commented Feb 13, 2023

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 ²

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant