Skip to content

Commit

Permalink
Compatibility-checker tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
NathanKell committed Oct 4, 2014
1 parent 66a9491 commit 995d96b
Showing 1 changed file with 26 additions and 2 deletions.
28 changes: 26 additions & 2 deletions Source/DeadlyReentry.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public class ModuleAeroReentry: PartModule
{
public const float CTOK = 273.15f;

protected bool isCompatible = true;


UIPartActionWindow _myWindow = null;
UIPartActionWindow myWindow {
Expand Down Expand Up @@ -190,6 +192,11 @@ public void SetDamageLabel()
public override void OnAwake()
{
base.OnAwake();
if (!CompatibilityChecker.IsCompatible())
{
isCompatible = false;
return;
}
if (part && part.Modules != null) // thanks, FlowerChild!
{
is_engine = (part.Modules.Contains("ModuleEngines") || part.Modules.Contains("ModuleEnginesFX"));
Expand Down Expand Up @@ -232,6 +239,8 @@ private bool GetShieldedStateFromFAR()

public override void OnStart (StartState state)
{
if (!isCompatible)
return;
counter = 0;
if (state == StartState.Editor)
return;
Expand Down Expand Up @@ -328,7 +337,7 @@ public float ReentryHeat()

public void FixedUpdate ()
{
if (!HighLogic.LoadedSceneIsFlight)
if (!HighLogic.LoadedSceneIsFlight || !isCompatible)
return;
Rigidbody rb = part.Rigidbody;
deltaTime = TimeWarp.fixedDeltaTime;
Expand Down Expand Up @@ -681,6 +690,9 @@ public class FixMaxTemps : MonoBehaviour
{
public void Start()
{
if (!CompatibilityChecker.IsCompatible())
return;

foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes ("REENTRY_EFFECTS")) {
if(node.HasValue("ridiculousMaxTemp")) {
float maxTemp;
Expand Down Expand Up @@ -737,6 +749,7 @@ public void Start()
[KSPAddon(KSPAddon.Startup.Flight, false)]
public class ReentryPhysics : MonoBehaviour
{
protected bool isCompatible = true;
private static AerodynamicsFX _afx;

public static AerodynamicsFX afx {
Expand Down Expand Up @@ -781,6 +794,11 @@ public static float TemperatureDelta(double density, float shockwaveK, float par

public void Start()
{
if (!CompatibilityChecker.IsCompatible())
{
isCompatible = false;
return;
}
enabled = true; // 0.24 compatibility
foreach (ConfigNode node in GameDatabase.Instance.GetConfigNodes ("REENTRY_EFFECTS")) {
if(node.HasValue("shockwaveExponent"))
Expand Down Expand Up @@ -829,7 +847,7 @@ public void Start()

public void OnGUI()
{
if (debugging)
if (isCompatible && debugging)
{
windowPos = GUILayout.Window("DeadlyReentry".GetHashCode(), windowPos, DrawWindow, "Deadly Reentry 2.0 Setup");
}
Expand All @@ -848,6 +866,8 @@ private void FixAeroFX(AerodynamicsFX aeroFX)

public void FixedUpdate()
{
if (!isCompatible)
return;
FixAeroFX (afx);
frameVelocity = Krakensbane.GetFrameVelocityV3f() - Krakensbane.GetLastCorrection() * TimeWarp.fixedDeltaTime;
if((object)FlightGlobals.ActiveVessel != null) // FIXME only valid for Earthlike atmospheres
Expand All @@ -857,11 +877,15 @@ public void FixedUpdate()

public void LateUpdate()
{
if (!isCompatible)
return;
FixAeroFX (afx);
}

public void Update()
{
if (!isCompatible)
return;
if (Input.GetKeyDown(KeyCode.R) && Input.GetKey(KeyCode.LeftAlt) && Input.GetKey(KeyCode.D))
{
debugging = !debugging;
Expand Down

0 comments on commit 995d96b

Please sign in to comment.