WaveFunctionP/KSPInterstellar — pull request #52 by chwthewke (2014-09-09 18:43:40+00:00)
Title: Proposal: Optional, config-driven upgrade modes for reactors, radiators and generators.

What’s this?

My goal was to modestly increase the configurability of KSPIL, and more precisely the electrical subsystem. Thus, apart from slight cosmetic changes (improvements I hope) and miscellaneous bugs I came across, this pull request does not change the behaviour of KSPIL until you modify some part configs.

What this does is re-introduce the “upgrade part with later tech” mechanism for all nuclear reactors, heat radiators and the electric generator, but in an optional way that relies on part configs only, works with TweakScale, and is not activated by configs in this PR (my “upgrade-configs” branch has some configs I made that activate upgrades if you would like to have a look; right now they are part configs and I plan to make them MM patches). The "Retrofit" action stays gone as well, and ship parts will stay as upgraded as they were at the time they launched.

Basically, I’ve introduced a new module `FNUpgradeModule` that, when added to a part is in charge of calling into its sibling `FNUpgradeableModule`s to do the upgrade stuff. It is not added to the part configs by default, and when added (after the TweakScale module), it gets scaled values and everything works nicely with e.g. rescaled reactors.

Details:
- The `FNUpgradeableModule` interface was modified, and `hasTechRequiredForUpgrade` was deduplicated between modules into an extension method.
- The new (and not used by default) `FNUpgradeModule` takes care of discovering, enabling and persisting upgrades for upgradeable modules.
- Refactored (deduplicated) `GetInfo()` for reactors, also, `GetInfo()` displays upgraded values, only if upgrades are enabled.
- Likewise, `GetInfo()` for radiators no longer displays values for temperatures above the unupgraded max temperature (by default 2000°K), unless upgrades are enabled.
- Fixed a likely bug in `FNFusionReactor` where the reactor would attempt to produce Charged Particles, resulting in reduced output.
- Added a display of the part variant in the Part UI for generators and radiators (where it was missing), only when upgrades are added.
- Added the Core Temperature and Power Output to reactors in the Editor scene, whether upgrades were added or not. It reacts correctly to scale changes and I figured it could be useful to know those numbers in the editor even when not using upgrades.
- Misc: The Thermal Rocket Nozzle/Turbojet computes its ISP correctly as soon as it is activated (thus avoiding erroneous delta-v values in MechJeb between loading the ship and actually thrusting with the TRN).
- Micro-bug in `FNRadiator`: Convected power was not correctly updated when rapidly leaving the atmosphere (such as when using HyperEdit to jump into orbit during testing).
- Known issue (or is it?): Ships that were built unupgraded, when launched directly from the launchpad without hitting the VAB after acquiring the upgrade are not upgraded; going through the VAB upgrades them. (I'm not sure how it worked in 0.11)

Please let me know if you would consider merging this PR, or if there is anything more (or less) I can change to make it mergeable. In particular, I’ve been much less aggressive at cleaning up unused code and de-duplicating stuff than I usually am, in the interest of limiting the quantity of modified lines here. If you’d like me to do more of that, I will, gladly. Also, I’ve left a few debugging “print”s inside “#if DEBUG/#endif” pragmas, if that bothers you, say the word and they’re gone.

Thanks for reading all this, and thanks again for your work on KSPI which is an outstanding mod!