-
Notifications
You must be signed in to change notification settings - Fork 16
Expand file tree
/
Copy pathKSPAddon.cs
More file actions
30 lines (26 loc) · 1000 Bytes
/
Copy pathKSPAddon.cs
File metadata and controls
30 lines (26 loc) · 1000 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
using UnityEngine;
namespace KRPC.MechJeb {
[KSPAddon(KSPAddon.Startup.MainMenu, true)]
internal class InitTypes : MonoBehaviour {
public void Start() {
Logger.Info("Loading MechJeb types...");
Logger.Info(MechJeb.InitTypes() ? "MechJeb found!" : "MechJeb is not available.");
MechJeb.ShowErrors();
}
}
[KSPAddon(KSPAddon.Startup.Flight, false)]
internal class InitInstance : MonoBehaviour {
private Vessel activeVessel;
public void LateUpdate() {
if(!MechJeb.TypesLoaded)
return;
// Refresh MechJeb instance when focus changes or a flight is reverted to launch.
if(this.activeVessel != FlightGlobals.ActiveVessel) {
this.activeVessel = FlightGlobals.ActiveVessel;
Logger.Info("Initializing MechJeb instance...");
Logger.Info(MechJeb.InitInstance() ? "KRPC.MechJeb is ready!" : "MechJeb found but the instance initialization wasn't successful. Maybe you don't have any MechJeb part attached to the vessel?");
MechJeb.ShowErrors();
}
}
}
}