@@ -79,9 +79,12 @@ public override void OnStart(StartState state)
7979 GameEvents . onPartUndock . Add ( OnPartUndock ) ;
8080 GameEvents . onPartActionUICreate . Add ( onPartActionUICreate ) ;
8181 mRegisteredId = vessel . id ;
82- RTCore . Instance . Satellites . Register ( vessel , this ) ;
83- if ( FlightComputer == null )
84- FlightComputer = new FlightComputer . FlightComputer ( this ) ;
82+ if ( RTCore . Instance != null )
83+ {
84+ RTCore . Instance . Satellites . Register ( vessel , this ) ;
85+ if ( FlightComputer == null )
86+ FlightComputer = new FlightComputer . FlightComputer ( this ) ;
87+ }
8588 }
8689 Fields [ "GUI_Status" ] . guiActive = ShowGUI_Status ;
8790 }
@@ -101,14 +104,14 @@ public void OnDestroy()
101104 {
102105 RTCore . Instance . Satellites . Unregister ( mRegisteredId , this ) ;
103106 mRegisteredId = Guid . Empty ;
107+ if ( FlightComputer != null ) FlightComputer . Dispose ( ) ;
104108 }
105- if ( FlightComputer != null ) FlightComputer . Dispose ( ) ;
106109 }
107110
108111 private State UpdateControlState ( )
109112 {
110113 IsRTPowered = part . isControlSource ;
111- if ( ! RTCore . Instance )
114+ if ( RTCore . Instance == null )
112115 {
113116 return State . Operational ;
114117 }
@@ -153,7 +156,7 @@ public void OnPartUndock(Part p)
153156
154157 public void OnVesselModified ( Vessel v )
155158 {
156- if ( ( mRegisteredId != vessel . id ) )
159+ if ( RTCore . Instance != null && mRegisteredId != vessel . id )
157160 {
158161 RTCore . Instance . Satellites . Unregister ( mRegisteredId , this ) ;
159162 mRegisteredId = vessel . id ;
@@ -171,8 +174,13 @@ public void HookPartMenus()
171174 e . Invoke ( ) ;
172175 return ;
173176 }
177+
178+ VesselSatellite vs = null ;
179+ if ( RTCore . Instance != null )
180+ {
181+ vs = RTCore . Instance . Satellites [ v ] ;
182+ }
174183
175- var vs = RTCore . Instance . Satellites [ v ] ;
176184 if ( vs == null || vs . HasLocalControl )
177185 {
178186 e . Invoke ( ) ;
0 commit comments