forked from sarbian/ModularFlightIntegrator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Potential fix for the Gimbal/CoM problem
- Loading branch information
Showing
3 changed files
with
145 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using UnityEngine; | ||
|
||
namespace ModularFlightIntegrator | ||
{ | ||
|
||
[KSPAddon(KSPAddon.Startup.EveryScene, false)] | ||
public class MFIManager: MonoBehaviour | ||
{ | ||
private void Start() | ||
{ | ||
string msg = "MFIManager Start " + HighLogic.LoadedScene + ". Current modules coVesselModule : \n"; | ||
|
||
foreach (var vesselModuleWrapper in VesselModuleManager.GetModules(false, false)) | ||
{ | ||
msg += " " + vesselModuleWrapper.type.ToString() + " active=" + vesselModuleWrapper.active + " order=" + vesselModuleWrapper.order + "\n"; | ||
} | ||
print(msg); | ||
|
||
VesselModuleManager.RemoveModuleOfType(typeof(FlightIntegrator)); | ||
//VesselModuleManager.SetWrapperActive(typeof(ModularFI.ModularFlightIntegrator), false); | ||
//VesselModuleManager.SetWrapperActive(typeof(FlightIntegrator), false); | ||
|
||
msg = "MFIManager Start Post RemoveModuleOfType. Current modules coVesselModule : \n"; | ||
foreach (var vesselModuleWrapper in VesselModuleManager.GetModules(false, false)) | ||
{ | ||
msg += " " + vesselModuleWrapper.type.ToString() + " active=" + vesselModuleWrapper.active + " order=" + vesselModuleWrapper.order + "\n"; | ||
} | ||
print(msg); | ||
|
||
|
||
// TODO : clear the event ? | ||
GameEvents.onVesselLoaded.Add(OnVesselLoad); | ||
} | ||
|
||
private void OnVesselLoad(Vessel v) | ||
{ | ||
print("OnVesselLoad"); | ||
VesselModuleManager.RemoveModulesFromVessel(v); | ||
VesselModuleManager.AddModulesToVessel(v); | ||
|
||
string msg = "OnVesselLoad. Vessel Component : \n"; | ||
foreach (var c in v.gameObject.GetComponents(typeof(Component))) | ||
{ | ||
msg += " " + c.GetType() + "\n"; | ||
} | ||
print(msg); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters