@@ -30,36 +30,29 @@ protected void Awake()
30
30
{
31
31
enabled = Settings . Enabled ;
32
32
Instance = this ;
33
- }
34
- protected void Start ( )
35
- {
36
33
SetupEditorCallbacks ( ) ;
37
34
}
38
-
39
35
#region Editor
40
36
protected void SetupEditorCallbacks ( )
41
37
{
42
- /// Add events for editor modifications
43
- if ( HighLogic . LoadedSceneIsEditor )
44
- {
45
- GameEvents . onEditorShipModified . Add ( new EventData < ShipConstruct > . OnEvent ( onEditorVesselModified ) ) ;
46
- GameEvents . onEditorRestart . Add ( new EventVoid . OnEvent ( onEditorVesselReset ) ) ;
47
- GameEvents . onEditorStarted . Add ( new EventVoid . OnEvent ( onEditorVesselStart ) ) ;
48
- GameEvents . onEditorPartDeleted . Add ( new EventData < Part > . OnEvent ( onEditorPartDeleted ) ) ;
49
- GameEvents . onEditorPodDeleted . Add ( new EventVoid . OnEvent ( onEditorVesselReset ) ) ;
50
- GameEvents . onEditorLoad . Add ( new EventData < ShipConstruct , KSP . UI . Screens . CraftBrowserDialog . LoadType > . OnEvent ( onEditorVesselLoad ) ) ;
51
- GameEvents . onPartRemove . Add ( new EventData < GameEvents . HostTargetAction < Part , Part > > . OnEvent ( onEditorVesselPartRemoved ) ) ;
52
- }
53
- else
54
- {
55
- GameEvents . onEditorShipModified . Remove ( new EventData < ShipConstruct > . OnEvent ( onEditorVesselModified ) ) ;
56
- GameEvents . onEditorRestart . Remove ( new EventVoid . OnEvent ( onEditorVesselReset ) ) ;
57
- GameEvents . onEditorStarted . Remove ( new EventVoid . OnEvent ( onEditorVesselStart ) ) ;
58
- GameEvents . onEditorPodDeleted . Remove ( new EventVoid . OnEvent ( onEditorVesselReset ) ) ;
59
- GameEvents . onEditorPartDeleted . Remove ( new EventData < Part > . OnEvent ( onEditorPartDeleted ) ) ;
60
- GameEvents . onEditorLoad . Remove ( new EventData < ShipConstruct , KSP . UI . Screens . CraftBrowserDialog . LoadType > . OnEvent ( onEditorVesselLoad ) ) ;
61
- GameEvents . onPartRemove . Remove ( new EventData < GameEvents . HostTargetAction < Part , Part > > . OnEvent ( onEditorVesselPartRemoved ) ) ;
62
- }
38
+ GameEvents . onEditorShipModified . Add ( new EventData < ShipConstruct > . OnEvent ( onEditorVesselModified ) ) ;
39
+ GameEvents . onEditorRestart . Add ( new EventVoid . OnEvent ( onEditorVesselReset ) ) ;
40
+ GameEvents . onEditorStarted . Add ( new EventVoid . OnEvent ( onEditorVesselStart ) ) ;
41
+ GameEvents . onEditorPartDeleted . Add ( new EventData < Part > . OnEvent ( onEditorPartDeleted ) ) ;
42
+ GameEvents . onEditorPodDeleted . Add ( new EventVoid . OnEvent ( onEditorVesselReset ) ) ;
43
+ GameEvents . onEditorLoad . Add ( new EventData < ShipConstruct , KSP . UI . Screens . CraftBrowserDialog . LoadType > . OnEvent ( onEditorVesselLoad ) ) ;
44
+ GameEvents . onPartRemove . Add ( new EventData < GameEvents . HostTargetAction < Part , Part > > . OnEvent ( onEditorVesselPartRemoved ) ) ;
45
+ }
46
+
47
+ void OnDestroy ( )
48
+ {
49
+ GameEvents . onEditorShipModified . Remove ( new EventData < ShipConstruct > . OnEvent ( onEditorVesselModified ) ) ;
50
+ GameEvents . onEditorRestart . Remove ( new EventVoid . OnEvent ( onEditorVesselReset ) ) ;
51
+ GameEvents . onEditorStarted . Remove ( new EventVoid . OnEvent ( onEditorVesselStart ) ) ;
52
+ GameEvents . onEditorPodDeleted . Remove ( new EventVoid . OnEvent ( onEditorVesselReset ) ) ;
53
+ GameEvents . onEditorPartDeleted . Remove ( new EventData < Part > . OnEvent ( onEditorPartDeleted ) ) ;
54
+ GameEvents . onEditorLoad . Remove ( new EventData < ShipConstruct , KSP . UI . Screens . CraftBrowserDialog . LoadType > . OnEvent ( onEditorVesselLoad ) ) ;
55
+ GameEvents . onPartRemove . Remove ( new EventData < GameEvents . HostTargetAction < Part , Part > > . OnEvent ( onEditorVesselPartRemoved ) ) ;
63
56
}
64
57
65
58
protected void InitializeEditorConstruct ( ShipConstruct ship , bool forceReset )
@@ -92,7 +85,7 @@ protected void RemovePart(Part p)
92
85
#region Game Events
93
86
public void onEditorPartDeleted ( Part part )
94
87
{
95
- Utils . Log ( "[VAB VesselDataManager][Editor]: Part Delete " , Utils . LogType . VesselData ) ;
88
+ Utils . Log ( "[VAB VesselDataManager][Editor]: Part DELETED " , Utils . LogType . VesselData ) ;
96
89
if ( ! HighLogic . LoadedSceneIsEditor ) { return ; }
97
90
98
91
InitializeEditorConstruct ( EditorLogic . fetch . ship , false ) ;
@@ -105,19 +98,25 @@ public void onEditorVesselReset()
105
98
}
106
99
public void onEditorVesselStart ( )
107
100
{
108
- Utils . Log ( "[VAB VesselDataManager]: Vessel START" , Utils . LogType . VesselData ) ;
101
+ Utils . Log ( "[VAB VesselDataManager][Editor]: Vessel START" , Utils . LogType . VesselData ) ;
102
+ if ( ! HighLogic . LoadedSceneIsEditor ) { return ; }
103
+ InitializeEditorConstruct ( EditorLogic . fetch . ship , true ) ;
104
+ }
105
+ public void onEditorVesselRestore ( )
106
+ {
107
+ Utils . Log ( "[VAB VesselDataManager]: Vessel RESTORE" , Utils . LogType . VesselData ) ;
109
108
if ( ! HighLogic . LoadedSceneIsEditor ) { return ; }
110
109
InitializeEditorConstruct ( EditorLogic . fetch . ship , true ) ;
111
110
}
112
111
public void onEditorVesselLoad ( ShipConstruct ship , KSP . UI . Screens . CraftBrowserDialog . LoadType type )
113
112
{
114
- Utils . Log ( "[RadioactivitySimulator ][Editor]: Vessel LOAD" , Utils . LogType . VesselData ) ;
113
+ Utils . Log ( "[VAB VesselDataManager ][Editor]: Vessel LOAD" , Utils . LogType . VesselData ) ;
115
114
if ( ! HighLogic . LoadedSceneIsEditor ) { return ; }
116
115
InitializeEditorConstruct ( ship , true ) ;
117
116
}
118
117
public void onEditorVesselPartRemoved ( GameEvents . HostTargetAction < Part , Part > p )
119
118
{
120
- Utils . Log ( "[VAB VesselDataManager][Editor]: Vessel PART REMOVE " , Utils . LogType . VesselData ) ;
119
+ Utils . Log ( "[VAB VesselDataManager][Editor]: Vessel PART REMOVED " , Utils . LogType . VesselData ) ;
121
120
if ( ! HighLogic . LoadedSceneIsEditor ) { return ; }
122
121
123
122
if ( electricalData == null )
0 commit comments