blowfishpro / B9PartSwitch

A Kerbal Space Program plugin designed to implement switching of part meshes, resources, and nodes
GNU Lesser General Public License v3.0
50 stars 33 forks source link

ModuleResourceConverter should reset its recipe after being activated #242

Open JonnyOThan opened 1 year ago

JonnyOThan commented 1 year ago

The stock ModuleResourceConverter has this annoying property:

public virtual ConversionRecipe Recipe => _recipe ?? (_recipe = LoadRecipe());

Which means that once this property has been accessed, the recipe will never change. This is why you must save/load after changing converter recipes with B9PS. If B9PS reset the _recipe field after configuring this module, it should fix that problem.

Note this originally came up because RasterPropMonitor was accessing the Recipe property before B9PS had a chance to change the module, so it would get stuck with the wrong recipe permanently even across save/load. I've changed RPM to no longer do that, but other mods might have similar behavior.

I think adding some code in here could handle this: https://github.com/blowfishpro/B9PartSwitch/blob/dd7482a87deb750690ac0d77860b3d02460b698a/B9PartSwitch/PartSwitch/ModuleModifierInfo.cs#L86