Skip to content

Commit

Permalink
NEW: No longer use FAR (when installed) to get atmospheric density, a…
Browse files Browse the repository at this point in the history
…s KSP 1.0 has proper values now
  • Loading branch information
jwvanderbeck committed May 11, 2015
1 parent d631b2f commit 8676648
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 55 deletions.
Binary file modified GameData/TestFlight/Plugins/TestFlight.dll
Binary file not shown.
Binary file modified GameData/TestFlight/Plugins/TestFlightAPI.dll
Binary file not shown.
Binary file modified GameData/TestFlight/Plugins/TestFlightContracts.dll
Binary file not shown.
Binary file modified GameData/TestFlight/Plugins/TestFlightCore.dll
Binary file not shown.
56 changes: 1 addition & 55 deletions TestFlightFailure_IgnitionFail.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,59 +23,14 @@ public class TestFlightFailure_IgnitionFail : TestFlightFailure_Engine
private ITestFlightCore core = null;


private bool _FARLoaded = false, check = true;
/// <summary>
/// Returns if FAR is currently loaded in the game
/// </summary>
public bool FARLoaded
{
get
{
if (check) { _FARLoaded = AssemblyLoader.loadedAssemblies.Any(a => a.dllName == "FerramAerospaceResearch"); check = false; }
return _FARLoaded;
}
}
private MethodInfo _densityMethod = null;
/// <summary>
/// A delegate to the FAR GetCurrentDensity method
/// </summary>
public MethodInfo densityMethod
{
get
{
if (_densityMethod == null)
{
_densityMethod = AssemblyLoader.loadedAssemblies.FirstOrDefault(a => a.dllName == "FerramAerospaceResearch").assembly
.GetTypes().Single(t => t.Name == "FARAeroUtil").GetMethods().Where(m => m.IsPublic && m.IsStatic)
.Where(m => m.ReturnType == typeof(double) && m.Name == "GetCurrentDensity").ToDictionary(m => m, m => m.GetParameters())
.Single(p => p.Value[0].ParameterType == typeof(CelestialBody) && p.Value[1].ParameterType == typeof(double)).Key;
}

return _densityMethod;
}
}
public double DynamicPressure
{
get
{
double density;
Vector3 velocity = this.part.Rigidbody.velocity + Krakensbane.GetFrameVelocityV3f();
float sqrSpeed = velocity.sqrMagnitude;
if (FARLoaded)
{
try
{
density = (double)densityMethod.Invoke(null, new object[] { this.vessel.mainBody, this.vessel.altitude, true });
}
catch
{
density = this.vessel.atmDensity;
}
}
else
{
density = this.vessel.atmDensity;
}
density = this.vessel.atmDensity;
double dynamicPressure = 0.5 * density * sqrSpeed;
return dynamicPressure;
}
Expand All @@ -86,21 +41,12 @@ public double DynamicPressure
{
// verify we have a valid core attached
if (core == null)
{
Log("IgnitionFail: No valid core attached");
return false;
}
if (baseIgnitionChance == null)
{
Log("IgnitionFail: No valid baseIgnitionChance FloatCurve");
return false;
}
// and a valid engine
if (engines == null)
{
Log("IgnitionFail: No valid engines found");
return false;
}
return TestFlightUtil.EvaluateQuery(Configuration, this.part);
}
}
Expand Down

0 comments on commit 8676648

Please sign in to comment.