@@ -15,20 +15,22 @@ public class ModuleCenterFollowTransform : PartModule
15
15
16
16
[ KSPField ]
17
17
public bool enableCoP = false ;
18
+ private bool wasEnabledCoP ;
18
19
19
20
[ KSPField ]
20
21
public bool enableCoM = false ;
22
+ private bool wasEnabledCoM ;
21
23
22
24
[ KSPField ]
23
25
public bool enableCoL = false ;
26
+ private bool wasEnabledCoL ;
24
27
25
28
[ KSPField ]
26
29
public string transformName ;
27
30
28
31
[ SerializeField ]
29
32
private Transform followTransform ;
30
33
31
- // TODO: Reset offset to prefab value if B9PS disables one of the fields.
32
34
public override void OnLoad ( ConfigNode node )
33
35
{
34
36
bool anyModeActive = enableCoP || enableCoM || enableCoL ;
@@ -51,7 +53,14 @@ public override void OnLoad(ConfigNode node)
51
53
if ( enableCoM ) part . CoMOffset = part . partInfo . partPrefab . CoMOffset ;
52
54
if ( enableCoL ) part . CoLOffset = part . partInfo . partPrefab . CoLOffset ;
53
55
}
54
-
56
+ // Set offets back to the values in the prefab if the mode is disabled after initial initialisation; e.g. B9PS
57
+ if ( ! enableCoP && wasEnabledCoP ) part . CoPOffset = part . partInfo . partPrefab . CoPOffset ;
58
+ if ( ! enableCoM && wasEnabledCoM ) part . CoMOffset = part . partInfo . partPrefab . CoMOffset ;
59
+ if ( ! enableCoL && wasEnabledCoL ) part . CoLOffset = part . partInfo . partPrefab . CoLOffset ;
60
+ wasEnabledCoP = enableCoP ;
61
+ wasEnabledCoM = enableCoM ;
62
+ wasEnabledCoL = enableCoL ;
63
+
55
64
// NOTE: isEnabled will be persisted to the save file, but we want to treat it purely as runtime state
56
65
isEnabled = followTransform != null && anyModeActive ;
57
66
enabled = followTransform != null && anyModeActive && HighLogic . LoadedSceneIsFlight ;
0 commit comments