forked from sarbian/ModularFlightIntegrator
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMFIManager.cs
48 lines (42 loc) · 1.59 KB
/
MFIManager.cs
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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
using UnityEngine;
namespace ModularFI
{
[KSPAddon(KSPAddon.Startup.Instantly, true)]
public class MFIManager: MonoBehaviour
{
private void Awake()
{
DontDestroyOnLoad(this);
}
private void Start()
{
var fiw = VesselModuleManager.GetWrapper(typeof (FlightIntegrator));
if (fiw != null && fiw.active)
{
print("[MFIManager] FlightIntegrator is active. Deactivating it");
VesselModuleManager.SetWrapperActive(typeof (FlightIntegrator), false);
}
// Should we display this only if we deactivated the stock FI ?
string msg = "[MFIManager] Current active VesselModule : \n";
foreach (var vesselModuleWrapper in VesselModuleManager.GetModules(false, false))
{
msg += "[MFIManager] " + vesselModuleWrapper.type.ToString() + " active=" + vesselModuleWrapper.active +
" order=" + vesselModuleWrapper.order + "\n";
}
print(msg);
GameEvents.onVesselPrecalcAssign.Add(AddModularPrecalc);
}
private void OnDestroy()
{
GameEvents.onVesselPrecalcAssign.Remove(AddModularPrecalc);
}
private void AddModularPrecalc(Vessel vessel)
{
if (!vessel.gameObject.GetComponent<ModularVesselPrecalculate>())
{
//print("[MFIManager] Adding ModularVesselPrecalculate");
vessel.gameObject.AddComponent<ModularVesselPrecalculate>();
}
}
}
}