SSTU - Shadow Space Technologies Unlimited

SSTU - Shadow Space Technologies Unlimited

98.5k Downloads

SSTUModularEngineCluster - Symmetry parts result in null-ref and unusable parts

blowfishpro opened this issue ยท 6 comments

commented
commented

Apparently there is a stock bug where the partInfo.partConfig does not get set properly for symmetry counterparts.

Attempting to find a workaround now...

commented

Have implemented a workaround to make part configs accessible through GameDatabase. Previously they had their 'name' node deleted as the part was loaded., making it impossible to tell what config belonged to what part).

I have added a MM patch to add a 'persistentPartName' field identical to the part name during the FINAL pass. This then makes all part configs accessible through GameDatabase by finding the config with the proper persistentPartName field.

This should potentially clean up a few other issues in the long run, as getting reliable access to part configs has always been a pain.

Edit: That solution turned out to cause a ton of log-spam regarding Part not containing a field for that value. Investigating other solutions for reliable retrieval of part configs at runtime.

commented

Out of curiosity, what requires accessing the part config?

commented

Reloading the engine - transforms, effects, thrust;.
The only reliable way I found to do it is to feed the engine a modified config node during a manual call to Load() -- this causes the engine to re-initialize its cached transforms, recalculate propellant use, and setup new effects for the updated # of engines.

commented

Implemented a generic KSPAddon with a module-manager DB-load callback; allowing me to grab the part configs before the PartLoader mangles them.

This solution also allows for grabbing the part config during prefab loading, which was previously not possible. Will continue to test while I'm sorting out the fairing issues.

commented

Yeah, it looks like the effects setup and thrust transforms might be accessible via other methods, but calculating propellant use is only done in OnLoad(). Might be possible to re-create that code, or just call OnLoad() with just the adjusted thrust (nothing else in the PartModule should be touched if it only contains that value).