Skip to content

Commit

Permalink
1.2.4 - Fix some bugs reported by @eggrobin
Browse files Browse the repository at this point in the history
  • Loading branch information
sarbian committed Mar 22, 2017
1 parent 89c79c0 commit e32cffb
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 11 deletions.
20 changes: 17 additions & 3 deletions MFIManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,14 @@

namespace ModularFI
{
[KSPAddon(KSPAddon.Startup.EveryScene, false)]
[KSPAddon(KSPAddon.Startup.Instantly, true)]
public class MFIManager: MonoBehaviour
{
private void Awake()
{
DontDestroyOnLoad(this);
}

private void Start()
{
var fiw = VesselModuleManager.GetWrapper(typeof (FlightIntegrator));
Expand All @@ -18,7 +23,7 @@ private void Start()
string msg = "[MFIManager] Current active VesselModule : \n";
foreach (var vesselModuleWrapper in VesselModuleManager.GetModules(false, false))
{
msg += " " + vesselModuleWrapper.type.ToString() + " active=" + vesselModuleWrapper.active +
msg += "[MFIManager] " + vesselModuleWrapper.type.ToString() + " active=" + vesselModuleWrapper.active +
" order=" + vesselModuleWrapper.order + "\n";
}
print(msg);
Expand All @@ -33,7 +38,16 @@ private void OnDestroy()

private void AddModularPrecalc(Vessel vessel)
{
vessel.gameObject.AddComponent<ModularVesselPrecalculate>();
if (!vessel.gameObject.GetComponent<ModularVesselPrecalculate>())
{
print("[MFIManager] Adding ModularVesselPrecalculate");
vessel.gameObject.AddComponent<ModularVesselPrecalculate>();
}
print("[MFIManager] listing vessel " + vessel.vesselName + " Components");
foreach (Component component in vessel.gameObject.GetComponents<Component>())
{
print("[MFIManager] " + component.GetType().Name);
}
}
}
}
13 changes: 6 additions & 7 deletions ModularVesselPrecalculate.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ class ModularVesselPrecalculate : VesselPrecalculate
{
public override void Awake()
{
TimingManager.UpdateAdd(TimingManager.TimingStage.FlightIntegrator, TimedUpdate);
TimingManager.FixedUpdateAdd(TimingManager.TimingStage.FlightIntegrator, TimedFixedUpdate);
TimingManager.UpdateAdd(TimingManager.TimingStage.Precalc, TimedUpdate);
TimingManager.FixedUpdateAdd(TimingManager.TimingStage.Precalc, TimedFixedUpdate);

base.Awake();
}

public override void OnDestroy()
{
TimingManager.UpdateRemove(TimingManager.TimingStage.FlightIntegrator, TimedUpdate);
TimingManager.FixedUpdateRemove(TimingManager.TimingStage.FlightIntegrator, TimedFixedUpdate);
TimingManager.UpdateRemove(TimingManager.TimingStage.Precalc, TimedUpdate);
TimingManager.FixedUpdateRemove(TimingManager.TimingStage.Precalc, TimedFixedUpdate);
base.OnDestroy();
}

Expand All @@ -26,7 +26,7 @@ public override void OnDestroy()

public void TimedFixedUpdate()
{
if (gameObject.activeInHierarchy)
if (gameObject.activeInHierarchy && this.enabled)
base.FixedUpdate();
}

Expand All @@ -42,11 +42,10 @@ public override void Update()
/// </summary>
public void TimedUpdate()
{
if (gameObject.activeInHierarchy)
if (gameObject.activeInHierarchy && this.enabled)
base.Update();
}


private static Action runFirstOverride;

public static bool RegisterMainPhysicsOverride(Action act)
Expand Down
2 changes: 1 addition & 1 deletion Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.0")]
[assembly: AssemblyFileVersion("1.2.3.0")]
[assembly: AssemblyFileVersion("1.2.4.0")]


[assembly: KSPAssembly("ModularFlightIntegrator", 1, 0)]

0 comments on commit e32cffb

Please sign in to comment.