Hi everybody,
first of all, a big thank you to @RoverDude for his awesome constellation of mods. I am currently experiencing the issue, that efficiency parts in MKS do not seem to be taken into account during catchup (also refererenced here: https://github.com/UmbraSpaceIndustries/MKS/issues/1441).
I did some investigation in the code base and have a quick fix which currently works for me, but would love some pointers to get this into a more permanent solution which I could provide as a Pull Request. Sorry if this thread is not the right place for such a discussion, if so, let me know and I will move it somewhere else.
Anyway, here it goes (sorry for the long explanation, but I did not want to leave out any facts):
Simple test setup is a Tundra Industrial Refinery combined with a 250 MPU. Industrial Refinery is set to Metals. MPU's bays to [Smelter]. When running this setup for 10 Minutes in the Refinery Scene, I get the correct amount of metals produced. When running it from the Tracking Station and returning to the ship (thus triggering catchup), I get an amount of metals as if the efficiency impact from the MPU was missing. I can provide a simple save file on request.
Debugging the code, I narrowed it down to a line in MKSModule.GetActiveBoosters:
totalEfficiencyBoost += (float)(booster.EfficiencyMultiplier * booster.Multiplier);
The EfficiencyMultiplier is calculated in USI_EfficiencyBoosterAddon during PostProcess. Unfortunatly, this has not been called when the catchup-mechanic (and thus GetActiveBoosters) runs, so it returns "0".
My current quick fix is to simply set the EfficiencyMultiplier to "1" if we are in catchup.
if (InCatchupMode())
totalEfficiencyBoost += (float)booster.Multiplier;
else
totalEfficiencyBoost += (float)(booster.EfficiencyMultiplier * booster.Multiplier);
This of course results in the expected booster effect when testing it in the game, but is a cludge.
The actual efficiency multiplier (when not in catchup) is calculated as follows (in USI_EfficiencyBoosterAddon from USITools):
public override void PostProcess(ConverterResults result, double deltaTime)
{
base.PostProcess(result, deltaTime);
EfficiencyMultiplier = result.TimeFactor / deltaTime;
}
During my test case TimeFactor and deltaTime where always pretty close, so the EfficiencyMultiplier resulted in a number close to one, but I currently do not understand the involved variables (TimeFactor) and deltaTime (which seem to come from Stock KSP where I can not investigate the code).
Can someone give some insight here?
I currently see two solutions, for which I would like to get some input:
1. Make sure PostProcess is called in catchup before the booster calculations. I am currently not sure, where to go for this and how large of a change this would be.
2. Understand the efficiencyMultiplier-Logic and handle it during the booster-calculation (I tested changing the governor setting but could not see any change).