Skip to content

Commit

Permalink
1.1.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
jrbudda committed Jul 1, 2020
1 parent d62e753 commit 83f8282
Show file tree
Hide file tree
Showing 14 changed files with 157 additions and 17 deletions.
Binary file modified Assets/Plugins/KerbalEngineer.Unity.dll
Binary file not shown.
7 changes: 7 additions & 0 deletions Documents/CHANGES.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
1.1.7.2, 2020-7-1, KSP 1.10.0 #2917
- Update to 1.10
- Fix incorrect caluclations if default pressure of Kerbin is changed. Thanks Sigma88
- Use localized names of vessels and celetial bodies when possible. Thanks Sigma88.
- Added 'Crosshair' readout to misc category. This is just a 16x16 crosshair you could put in a transparent hud somewhere.
- Fix some jet engine thrusts not calculating correctly with Mach due to not honoring flow multiplier cap.

1.1.7.1, 2019-10-18, KSP 1.8.0 #2686
- Fix impact marker rendering.
- Further improvements to handling old xml settings.
Expand Down
2 changes: 1 addition & 1 deletion KerbalEngineer/EngineerGlobals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public static class EngineerGlobals
/// <summary>
/// Current version of the Kerbal Engineer assembly.
/// </summary>
public const string ASSEMBLY_VERSION = "1.1.7.1";
public const string ASSEMBLY_VERSION = "1.1.7.2";

private static string assemblyFile;
private static string assemblyName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public ClearSeparator()
{
this.Name = "Clear Separator";
this.Category = ReadoutCategory.GetCategory("Miscellaneous");
this.HelpString = "Creats a space to help seperate subsections in a module.";
this.HelpString = "Creates a space to help seperate subsections in a module.";
this.IsDefault = false;
this.Cloneable = true;

Expand Down
102 changes: 102 additions & 0 deletions KerbalEngineer/Flight/Readouts/Miscellaneous/Crosshair.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
//
// Kerbal Engineer Redux
//
// Copyright (C) 2014 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/>.
//

#region Using Directives

using System;

using KerbalEngineer.Flight.Sections;
using KerbalEngineer.Helpers;

using UnityEngine;

#endregion

namespace KerbalEngineer.Flight.Readouts.Miscellaneous
{
public class Crosshair : ReadoutModule
{
#region Fields

private GUIStyle boxStyle;
private GUIStyle boxStyleHud;
#endregion

#region Constructors

public Crosshair()
{
this.Name = "Crosshair";
this.Category = ReadoutCategory.GetCategory("Miscellaneous");
this.HelpString = "Creates a cross that can be used as a placeable crosshair.";
this.IsDefault = false;
this.Cloneable = true;

this.InitialiseStyles();

GuiDisplaySize.OnSizeChanged += this.InitialiseStyles;
}

#endregion

#region Methods: public

public override void Draw(Unity.Flight.ISectionModule section)
{
GUILayout.BeginHorizontal();
GUILayout.FlexibleSpace();
GUILayout.Box(tex, section.IsHud ? this.boxStyleHud : this.boxStyle);
GUILayout.FlexibleSpace();
GUILayout.EndHorizontal();
}

#endregion

#region Methods: private

private static readonly Texture2D tex = TextureHelper.createCrosshair(new Color(1.0f, 1.0f, 1.0f, 0.75f));
private static readonly Texture2D bg = TextureHelper.CreateTextureFromColour(new Color(0.0f, 0.0f, 0.0f, 0.0f));

private void InitialiseStyles()
{
this.boxStyle = new GUIStyle
{
normal =
{
background = bg,
textColor = new Color(1,1,1,0f)
},
active =
{
background = bg
},
border = new RectOffset(0, 0, 0, 0),
fixedHeight = 0.0f,
imagePosition = ImagePosition.ImageOnly
};

this.boxStyleHud = new GUIStyle(this.boxStyle)
{
margin = new RectOffset(0, 0, (int)(8 * GuiDisplaySize.Offset), 0)
};
}

#endregion
}
}
2 changes: 1 addition & 1 deletion KerbalEngineer/Flight/Readouts/Miscellaneous/Separator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ public Separator()
{
this.Name = "Separator";
this.Category = ReadoutCategory.GetCategory("Miscellaneous");
this.HelpString = "Creats a line to help seperate subsections in a module.";
this.HelpString = "Creates a line to help seperate subsections in a module.";
this.IsDefault = false;
this.Cloneable = true;

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 @@ -219,6 +219,7 @@ static ReadoutLibrary() {
// Misc
readouts.Add(new Separator());
readouts.Add(new ClearSeparator());
readouts.Add(new Crosshair());
readouts.Add(new GuiSizeAdjustor());
readouts.Add(new SimulationDelay());
readouts.Add(new VectoredThrustToggle());
Expand Down
22 changes: 22 additions & 0 deletions KerbalEngineer/Helpers/TextureHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,29 @@ public static Texture2D CreateTextureFromColour(Color colour)
texture.Apply();
return texture;
}
public static Texture2D createCrosshair(Color colour)
{
var texture = new Texture2D(17, 17, TextureFormat.ARGB32, false);

for (int i = 0; i < 17; i++)
{
for (int j = 0; j < 17; j++)
{
texture.SetPixel(i, j, new Color(0,0,0,0));
}
}

for (int i = 0; i < 17; i++)
{
texture.SetPixel(8, i, colour);
}
for (int i = 0; i < 17; i++)
{
texture.SetPixel(i, 8, colour);
}
texture.Apply();
return texture;
}
#endregion
}
}
1 change: 1 addition & 0 deletions KerbalEngineer/KerbalEngineer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
<Compile Include="Flight\Readouts\Body\LowSpaceHeight.cs" />
<Compile Include="Flight\Readouts\Miscellaneous\LogSimToggle.cs" />
<Compile Include="Flight\Readouts\Miscellaneous\ClearSeparator.cs" />
<Compile Include="Flight\Readouts\Miscellaneous\Crosshair.cs" />
<Compile Include="Flight\Readouts\Miscellaneous\SystemDateTime.cs" />
<Compile Include="Flight\Readouts\Miscellaneous\SystemTime24.cs" />
<Compile Include="Flight\Readouts\Miscellaneous\SystemTime.cs" />
Expand Down
31 changes: 19 additions & 12 deletions KerbalEngineer/VesselSimulator/EngineSim.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,15 @@ public static EngineSim New(PartSim theEngine,
bool throttleLocked = engineMod.throttleLocked || fullThrust;
List<Propellant> propellants = engineMod.propellants;
float thrustCurveRatio = engineMod.thrustCurveRatio;

foreach (Propellant p in propellants)
{
if (p.ignoreForThrustCurve) continue;
double ratio = p.totalResourceAvailable / p.totalResourceCapacity;
if (ratio < thrustCurveRatio)
thrustCurveRatio = (float)ratio;
}

bool active = engineMod.isOperational;

//I do not know if this matters. RF and stock always have finalThrust. But stock uses resultingThrust in the mass flow calculations, so keep it.
Expand All @@ -121,19 +130,13 @@ public static EngineSim New(PartSim theEngine,
engineSim.resourceFlowModes.Reset();
engineSim.appliedForces.Clear();



double flowRate = 0.0;
if (engineSim.partSim.hasVessel)
{
if (log != null) log.AppendLine("hasVessel is true");

foreach(Propellant p in propellants) {
if (p.ignoreForThrustCurve) continue;
double ratio = p.totalResourceAvailable / p.totalResourceCapacity;
if (ratio < thrustCurveRatio)
thrustCurveRatio = (float) ratio;
}

float flowModifier = GetFlowModifier(atmChangeFlow, atmCurve, engineSim.partSim.part.atmDensity, velCurve, machNumber, thrustCurve, thrustCurveRatio, ref engineSim.maxMach);
float flowModifier = GetFlowModifier(atmChangeFlow, atmCurve, engineSim.partSim.part.atmDensity, velCurve, machNumber, thrustCurve, thrustCurveRatio, ref engineSim.maxMach, engineMod.flowMultCap, engineMod.flowMultCapSharpness);
engineSim.isp = atmosphereCurve.Evaluate((float)atmosphere);
engineSim.thrust = GetThrust(Mathf.Lerp(minFuelFlow, maxFuelFlow, GetThrustPercent(thrustPercentage)) * flowModifier, engineSim.isp);
engineSim.actualThrust = engineSim.isActive ? resultingThrust : 0.0;
Expand Down Expand Up @@ -169,7 +172,7 @@ public static EngineSim New(PartSim theEngine,
else
{
if (log != null) log.buf.AppendLine("hasVessel is false");
float flowModifier = GetFlowModifier(atmChangeFlow, atmCurve, CelestialBodies.SelectedBody.GetDensity(BuildAdvanced.Altitude), velCurve, machNumber, thrustCurve, thrustCurveRatio, ref engineSim.maxMach);
float flowModifier = GetFlowModifier(atmChangeFlow, atmCurve, CelestialBodies.SelectedBody.GetDensity(BuildAdvanced.Altitude), velCurve, machNumber, thrustCurve, thrustCurveRatio, ref engineSim.maxMach, engineMod.flowMultCap, engineMod.flowMultCapSharpness);
engineSim.isp = atmosphereCurve.Evaluate((float)atmosphere);
engineSim.thrust = GetThrust(Mathf.Lerp(minFuelFlow, maxFuelFlow, GetThrustPercent(thrustPercentage)) * flowModifier, engineSim.isp);
engineSim.actualThrust = 0d;
Expand Down Expand Up @@ -269,7 +272,7 @@ public static double GetExhaustVelocity(double isp)
return isp * Units.GRAVITY;
}

public static float GetFlowModifier(bool atmChangeFlow, FloatCurve atmCurve, double atmDensity, FloatCurve velCurve, float machNumber, FloatCurve thrustCurve, float thrustCurveRatio, ref float maxMach)
public static float GetFlowModifier(bool atmChangeFlow, FloatCurve atmCurve, double atmDensity, FloatCurve velCurve, float machNumber, FloatCurve thrustCurve, float thrustCurveRatio, ref float maxMach, float flowMultCap, float flowMultCapSharp)
{
float flowModifier = 1.0f;
if (atmChangeFlow)
Expand All @@ -289,7 +292,11 @@ public static float GetFlowModifier(bool atmChangeFlow, FloatCurve atmCurve, dou
{
flowModifier = flowModifier * thrustCurve.Evaluate(thrustCurveRatio);
}
if (flowModifier < float.Epsilon)
if (flowModifier > flowMultCap)
{
flowModifier = flowMultCapSharp / ((flowMultCapSharp - 1) / flowMultCap + 1 / flowModifier);
}
if (flowModifier < 1E-05f)
{
flowModifier = float.Epsilon;
}
Expand Down
Binary file modified Output/KerbalEngineer/KerbalEngineer.Unity.dll
Binary file not shown.
Binary file modified Output/KerbalEngineer/KerbalEngineer.dll
Binary file not shown.
4 changes: 2 additions & 2 deletions Output/KerbalEngineer/KerbalEngineer.version
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"MAJOR":1,
"MINOR":1,
"PATCH":7,
"BUILD":1
"BUILD":2
},
"KSP_VERSION":
{
Expand All @@ -24,7 +24,7 @@
"KSP_VERSION_MAX":
{
"MAJOR":1,
"MINOR":9,
"MINOR":10,
"PATCH":9
}
}
Binary file added UpgradeLog.htm
Binary file not shown.

0 comments on commit 83f8282

Please sign in to comment.