Skip to content

Commit

Permalink
Merge pull request #118 from Gerry1135/stagedecouplers
Browse files Browse the repository at this point in the history
Fix for staged docking ports
  • Loading branch information
CYBUTEK committed Dec 23, 2016
2 parents f7385cb + e5ef6c8 commit 4fcd7ba
Show file tree
Hide file tree
Showing 10 changed files with 89 additions and 4 deletions.
5 changes: 5 additions & 0 deletions KerbalEngineer/Extensions/DoubleExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public static string ToPercent(this double value)
return Units.ToPercent(value);
}

public static string ToPressure(this double value)
{
return Units.ToPressure(value);
}

public static string ToRate(this double value)
{
return Units.ToRate(value);
Expand Down
1 change: 1 addition & 0 deletions KerbalEngineer/Flight/Readouts/ReadoutLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ static ReadoutLibrary()
readouts.Add(new GeeForce());
readouts.Add(new TerminalVelocity());
readouts.Add(new AtmosphericEfficiency());
readouts.Add(new AtmosphericPressure());
readouts.Add(new Biome());
readouts.Add(new Situation());
readouts.Add(new Slope());
Expand Down
53 changes: 53 additions & 0 deletions KerbalEngineer/Flight/Readouts/Surface/AtmosphericPressure.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
//
// Kerbal Engineer Redux
//
// Copyright (C) 2015 CYBUTEK
//
// This program is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>.
//

namespace KerbalEngineer.Flight.Readouts.Surface
{
using Extensions;
using Sections;

public class AtmosphericPressure : ReadoutModule
{
public AtmosphericPressure()
{
Name = "Atmos. Pressure";
Category = ReadoutCategory.GetCategory("Surface");
HelpString = "Displays the current atmospheric pressure.";
IsDefault = false;
}

public override void Draw(SectionModule section)
{
if (AtmosphericProcessor.ShowDetails)
{
DrawLine(AtmosphericProcessor.StaticPressure.ToPressure(), section.IsHud);
}
}

public override void Reset()
{
FlightEngineerCore.Instance.AddUpdatable(AtmosphericProcessor.Instance);
}

public override void Update()
{
AtmosphericProcessor.RequestUpdate();
}
}
}
13 changes: 13 additions & 0 deletions KerbalEngineer/Flight/Readouts/Surface/AtmosphericProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,16 @@ public static AtmosphericProcessor Instance
/// </summary>
public static double TerminalVelocity { get; private set; }

/// <summary>
/// Gets the static pressure of the active vessel.
/// </summary>
public static double StaticPressure { get; private set; }

/// <summary>
/// Gets the dynamic pressure of the active vessel.
/// </summary>
public static double DynamicPressure { get; private set; }

#endregion

#region IUpdatable Members
Expand Down Expand Up @@ -134,6 +144,9 @@ public void Update()
var c = PhysicsGlobals.DragMultiplier;

TerminalVelocity = Math.Sqrt((2.0 * m * g) / (p * a * c));

StaticPressure = FlightGlobals.ActiveVessel.staticPressurekPa;
DynamicPressure = FlightGlobals.ActiveVessel.dynamicPressurekPa;
}

Efficiency = FlightGlobals.ship_srfSpeed / TerminalVelocity;
Expand Down
2 changes: 1 addition & 1 deletion KerbalEngineer/Flight/Readouts/Surface/ImpactLongitude.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public override void Draw(SectionModule section)
{
if (ImpactProcessor.ShowDetails)
{
this.DrawLine(Units.ToAngleDMS(ImpactProcessor.Longitude) + (ImpactProcessor.Longitude < 0.0 ? "W" : " E"), section.IsHud);
this.DrawLine(Units.ToAngleDMS(ImpactProcessor.Longitude) + (ImpactProcessor.Longitude < 0.0 ? " W" : " E"), section.IsHud);
}
}

Expand Down
2 changes: 1 addition & 1 deletion KerbalEngineer/Flight/Readouts/Surface/Longitude.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public Longitude()
public override void Draw(SectionModule section)
{
double angle = AngleHelper.Clamp180(FlightGlobals.ship_longitude);
DrawLine(Units.ToAngleDMS(angle) + (angle < 0.0 ? "W" : " E"), section.IsHud);
DrawLine(Units.ToAngleDMS(angle) + (angle < 0.0 ? " W" : " E"), section.IsHud);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public IntakeAirDemandSupply()
{
this.Name = "Intake Air (D/S)";
this.Category = ReadoutCategory.GetCategory("Vessel");
this.HelpString = "Displays the Ration between required and available Intake Air.";
this.HelpString = "Displays the Ratio between required and available Intake Air.";
this.IsDefault = false;
}

Expand Down
5 changes: 5 additions & 0 deletions KerbalEngineer/Helpers/Units.cs
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,11 @@ public static string ToPercent(double value, int decimals = 2)
return value.ToString("F" + decimals) + "%";
}

public static string ToPressure(double value)
{
return value.ToString((value < 100000.0) ? (value < 10000.0) ? (value < 100.0) ? (Math.Abs(value) < double.Epsilon) ? "N0" : "N3" : "N2" : "N1" : "N0") + "kN/m²";
}

public static string ToRate(double value, int decimals = 1)
{
return value < 1.0 ? (value * 60.0).ToString("F" + decimals) + "/min" : value.ToString("F" + decimals) + "/sec";
Expand Down
1 change: 1 addition & 0 deletions KerbalEngineer/KerbalEngineer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@
<Compile Include="Flight\Readouts\Rendezvous\TargetLongitude.cs" />
<Compile Include="Flight\Readouts\Rendezvous\TimeToRelativeDescendingNode.cs" />
<Compile Include="Flight\Readouts\Rendezvous\TimeToRelativeAscendingNode.cs" />
<Compile Include="Flight\Readouts\Surface\AtmosphericPressure.cs" />
<Compile Include="Flight\Readouts\Surface\ImpactBiome.cs" />
<Compile Include="Flight\Readouts\Surface\Slope.cs" />
<Compile Include="Flight\Readouts\Surface\Biome.cs" />
Expand Down
9 changes: 8 additions & 1 deletion KerbalEngineer/VesselSimulator/PartSim.cs
Original file line number Diff line number Diff line change
Expand Up @@ -940,7 +940,14 @@ private bool IsActiveDecoupler(Part thePart)
private bool IsDecoupler(Part thePart)
{
PartExtensions.ProtoModuleDecoupler protoDecoupler = thePart.GetProtoModuleDecoupler();
return protoDecoupler != null && protoDecoupler.IsStageEnabled;
if (protoDecoupler != null && protoDecoupler.IsStageEnabled)
return true;

ModuleDockingNode modDock = thePart.GetModule<ModuleDockingNode>();
if (modDock != null && modDock.IsStageable())
return true;

return false;
}

private bool IsSepratron()
Expand Down

0 comments on commit 4fcd7ba

Please sign in to comment.