From: cybutek Date: Mon, 02 Nov 2015 19:46:05 +0000 Subject: Updated change log to reflect pulled changes. X-Git-Url: http://git.toad.homelinux.net/projects/VesselSimulator.git/commitdiff/343993f --- Updated change log to reflect pulled changes. --- --- a/Documents/CHANGES.txt +++ b/Documents/CHANGES.txt @@ -1,24 +1,54 @@ +1.0.19.0 + Added: Added current vessel name readout. (antplant) + Added: 'Relative Radial Velocity' and 'Time To Rendezvous' readouts. (itwtx) + Added: Readout help strings. (harryyoung) + Changed: The 'Torque' value in the editor is now precise to two decimal places. + Fixed: Optimised time formatting. (itwtx) + Fixed: TimeToAtmosphere checks that the Apoapsis is outside atmosphere. (Kerbas-ad-astra) + Fixed: Issue with stage priority flow. Caused Rapier calculations to fail if LF and O are drawn from different tanks. (Padishar) + +1.0.18.0 + Added: Orbital readouts - "Speed at Periapsis" and "Speed at Apoapsis". (Padishar) + Added: Manoeuvre readouts - "Post-burn Apoapsis" and "Post-burn Periapsis". (Padishar) + Added: Orbital readout - "Time to Atmosphere". + Fixed: Synched the minimum simulation time sliders and stopped them from snapping back after 999ms. (saybur) + Fixed: Added workaround for the bug in Vessel.horizontalSrfSpeed (Padishar) + Fixed: Physically insignificant part mass was not being correctly cascaded down through multiple parent parts. + Fixed: Intake air demand calculation not working. + Fixed: Some build engineer settings labels do not scale with UI size. + 1.0.17.0 Added: 'Mach Number' readout under the 'Surface' category and included it on the default surface HUD. + Added: Stock sections in the Flight Engineer can now become HUDs. Added 'Thermal' readouts category including: Internal Flux Convection Flux Radiation Flux Critical Part Name Critical Part Temperature - Critical Part Percentage of Max Temperature + Critical Part Skin Temperature + Critical Part Thermal Percentage of Max Temperature Hottest Part Name Hottest Part Temperature + Hottest Part Skin Temperature Coldest Part Name Coldest Part Temperature + Coldest Part Skin Temperature Changed: Mach on the Build Engineer now accurate to 2 decimal places. Changed: Max mach in the Build Engineer defaults to 1.00 even when no jet engines are present. - Changed: Increased eccentricity readout to 5 decimal places. - Changed: Implemented Sarbian's object pooling. + Changed: Increased eccentricity readout to 5 decimal places. + Changed: Implemented Sarbian's object pooling. + Changed: The default selected body is now assigned via 'Planitarium.Home'. + Changed: HUDs to clamp fully inside the screen instead of allowing them to run off the edge by a certain amount. Fixed: Physically insignificant part mass is now associated with the parent part. Fixed: Longitude and Latitude readouts now use a KER formatter instead of Squad's incorrect implementation. Fixed: Possible null reference in the Rendezvous Processor. + Fixed: Fairing mass issues introduced with regards to simulation changes. + Fixed: Use of per-propellant fuel flow mode override. + Fixed: Burn times calculated for jet engines. + Fixed: Thrust issues introduced with Sarbian's simulation alterations. + Fixed: Issue where HUDs positioned close to the top/bottom of the screen could be pushed out of position. 1.0.16.6, 02-05-15 Fixed: Separately staged fairing mass jettisons are now calculated in the editor. @@ -62,7 +92,7 @@ 1.0.15.1, 13-02-2015 Rebuild - + 1.0.15.0, 08-02-2015 Padishar's Fixes: Added: Support KIDS ISP thrust correction. @@ -72,7 +102,7 @@ 1.0.14.1, 28-12-2014 Fixed: Missing texture on the ER-7500 model. - + 1.0.14.0, 28-12-2014 Added: Career mode that limits the Flight Engineer by: - Requiring an Engineer Kerbal of any level, or placement of an Engineer Chip or ER-7500 part. @@ -192,7 +222,7 @@ Added: New readout to the surface category: - Vertical Acceleration - Horizontal Acceleration - + Changed: Atmospheric efficiency readout now shows as a percentage. Changed: Atmospheric settings (pressure/velocity) in the editor condensed onto a single line. Fixed: Bug where the overlays in the editor would stay open outside of parts screen. @@ -349,6 +379,7 @@ Added: Stock toolbar support in the Flight Engineer. Changed: Orbital Period has higher precision. Fixed: Various NullRefs in editor window and overlay. - + 1.0.0.0, 24-07-2014 Initial release for public testing. + --- a/KerbalEngineer/CelestialBodies.cs +++ b/KerbalEngineer/CelestialBodies.cs @@ -37,7 +37,8 @@ try { SystemBody = new BodyInfo(PSystemManager.Instance.localBodies.Find(b => b.referenceBody == null || b.referenceBody == b)); - if (!SetSelectedBody("Kerbin")) + String homeCBName = Planetarium.fetch.Home.bodyName; + if (!SetSelectedBody(homeCBName)) { SelectedBody = SystemBody; SelectedBody.SetSelected(true); --- a/KerbalEngineer/Control/ControlCentre.cs +++ b/KerbalEngineer/Control/ControlCentre.cs @@ -142,7 +142,7 @@ try { GUI.skin = null; - this.position = GUILayout.Window(this.GetInstanceID(), this.position, this.Window, "KERBAL ENGINEER REDUX " + EngineerGlobals.AssemblyVersion + " - CONTROL CENTRE", HighLogic.Skin.window); + this.position = GUILayout.Window(this.GetInstanceID(), this.position, this.Window, "KERBAL ENGINEER REDUX " + EngineerGlobals.ASSEMBLY_VERSION + " - CONTROL CENTRE", HighLogic.Skin.window); this.CentreWindow(); } catch (Exception ex) --- a/KerbalEngineer/Editor/BuildAdvanced.cs +++ b/KerbalEngineer/Editor/BuildAdvanced.cs @@ -215,7 +215,7 @@ } // Change the window title based on whether in compact mode or not. - title = !compactMode ? "KERBAL ENGINEER REDUX " + EngineerGlobals.AssemblyVersion : "K.E.R. " + EngineerGlobals.AssemblyVersion; + title = !compactMode ? "KERBAL ENGINEER REDUX " + EngineerGlobals.ASSEMBLY_VERSION : "K.E.R. " + EngineerGlobals.ASSEMBLY_VERSION; // Reset the window size when the staging or something else has changed. stagesLength = stages.Length; @@ -523,12 +523,12 @@ GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); - GUILayout.Label("Simulate using vectored thrust values:"); + GUILayout.Label("Simulate using vectored thrust values:", settingStyle); SimManager.vectoredThrust = GUILayout.Toggle(SimManager.vectoredThrust, "ENABLED", buttonStyle, GUILayout.Width(100.0f * GuiDisplaySize.Offset)); GUILayout.EndHorizontal(); GUILayout.BeginHorizontal(); - GUILayout.Label("Verbose Simulation Log:"); + GUILayout.Label("Verbose Simulation Log:", settingStyle); SimManager.logOutput = GUILayout.Toggle(SimManager.logOutput, "ENABLED", buttonStyle, GUILayout.Width(100.0f * GuiDisplaySize.Offset)); GUILayout.EndHorizontal(); @@ -563,9 +563,9 @@ } GUILayout.EndHorizontal(); - GUILayout.Label("Minimum delay between simulations: " + SimManager.minSimTime.Milliseconds + "ms", settingStyle); + GUILayout.Label("Minimum delay between simulations: " + SimManager.minSimTime.TotalMilliseconds + "ms", settingStyle); GUI.skin = HighLogic.Skin; - SimManager.minSimTime = new TimeSpan(0, 0, 0, 0, (int)GUILayout.HorizontalSlider(SimManager.minSimTime.Milliseconds, 0, 2000.0f)); + SimManager.minSimTime = TimeSpan.FromMilliseconds(GUILayout.HorizontalSlider((float)SimManager.minSimTime.TotalMilliseconds, 0, 2000.0f)); GUI.skin = null; } --- a/KerbalEngineer/EngineerGlobals.cs +++ b/KerbalEngineer/EngineerGlobals.cs @@ -1,7 +1,5 @@ // -// Kerbal Engineer Redux -// -// Copyright (C) 2014 CYBUTEK +// 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 @@ -17,42 +15,31 @@ // along with this program. If not, see . // -#region Using Directives - -using System.IO; -using System.Reflection; - -#endregion - namespace KerbalEngineer { - public class EngineerGlobals + using System.IO; + using System.Reflection; + + public static class EngineerGlobals { - #region Constants - /// /// Current version of the Kerbal Engineer assembly. /// - public const string AssemblyVersion = "1.0.16.6"; - - #endregion - - #region Fields + public const string ASSEMBLY_VERSION = "1.0.18.1"; private static string assemblyFile; private static string assemblyName; private static string assemblyPath; - - #endregion - - #region Properties /// /// Gets the Kerbal Engineer assembly's path including the file name. /// public static string AssemblyFile { - get { return assemblyFile ?? (assemblyFile = Assembly.GetExecutingAssembly().Location); } + get + { + return assemblyFile ?? (assemblyFile = Assembly.GetExecutingAssembly().Location); + } } /// @@ -60,7 +47,10 @@ /// public static string AssemblyName { - get { return assemblyName ?? (assemblyName = new FileInfo(AssemblyFile).Name); } + get + { + return assemblyName ?? (assemblyName = new FileInfo(AssemblyFile).Name); + } } /// @@ -68,9 +58,10 @@ /// public static string AssemblyPath { - get { return assemblyPath ?? (assemblyPath = AssemblyFile.Replace(new FileInfo(AssemblyFile).Name, "")); } + get + { + return assemblyPath ?? (assemblyPath = AssemblyFile.Replace(new FileInfo(AssemblyFile).Name, "")); + } } - - #endregion } } --- a/KerbalEngineer/Extensions/PartExtensions.cs +++ b/KerbalEngineer/Extensions/PartExtensions.cs @@ -55,6 +55,7 @@ /// /// Gets whether the part has fuel. /// + /* not used public static bool EngineHasFuel(this Part part) { PartModule cachePartModule = GetModule(part); @@ -71,7 +72,7 @@ return false; } - + */ /// /// Gets the cost of the part excluding resources. /// @@ -123,6 +124,7 @@ /// /// Gets the maximum thrust of the part if it's an engine. /// + /* not used public static double GetMaxThrust(this Part part) { PartModule cachePartModule = GetModule(part); @@ -139,6 +141,7 @@ return 0.0; } + */ /// /// Gets the first typed PartModule in the part's module list. @@ -194,10 +197,10 @@ return GetModule(part); } - public static ModuleEnginesFX GetModuleEnginesFx(this Part part) +/* public static ModuleEnginesFX GetModuleEnginesFx(this Part part) { return GetModule(part); - } + }*/ /// /// Gets a ModuleGenerator typed PartModule. @@ -218,16 +221,20 @@ /// /// Gets the current selected ModuleEnginesFX. /// - public static ModuleEnginesFX GetModuleMultiModeEngine(this Part part) - { - ModuleEnginesFX moduleEngineFx; - string mode = GetModule(part).mode; - for (int i = 0; i < part.Modules.Count; ++i) - { - moduleEngineFx = part.Modules[i] as ModuleEnginesFX; - if (moduleEngineFx != null && moduleEngineFx.engineID == mode) - { - return moduleEngineFx; + public static ModuleEngines GetModuleMultiModeEngine(this Part part) + { + ModuleEngines moduleEngines; + MultiModeEngine multiMod = GetModule(part); + if (multiMod != null) + { + string mode = multiMod.mode; + for (int i = 0; i < part.Modules.Count; ++i) + { + moduleEngines = part.Modules[i] as ModuleEngines; + if (moduleEngines != null && moduleEngines.engineID == mode) + { + return moduleEngines; + } } } return null; @@ -343,6 +350,7 @@ /// /// Gets the current specific impulse for the engine. /// + /* not used public static double GetSpecificImpulse(this Part part, float atmosphere) { PartModule cachePartModule = GetModule(part); @@ -359,6 +367,7 @@ return 0.0; } + */ /// /// Gets the total mass of the part including resources. @@ -457,7 +466,7 @@ /// public static bool IsEngine(this Part part) { - return HasModule(part) || HasModule(part); + return HasModule(part); } /// @@ -540,7 +549,7 @@ /// public static bool IsSolidRocket(this Part part) { - return (part.HasModule() && part.GetModuleEngines().throttleLocked) || (part.HasModule() && part.GetModuleEnginesFx().throttleLocked); + return (part.HasModule() && part.GetModuleEngines().throttleLocked); } public class ProtoModuleDecoupler @@ -588,6 +597,12 @@ } } + // This needs updating to handle multi-mode engines and engines with multiple ModuleEngines correctly. + // It currently just shows the stats of the currently active module for multi-mode engines and just + // the first ModuleEngines for engines with multiple modules. + // It should really show all the modes for multi-mode engines as separate sections. + // For other engines with multiple ModuleEngines it should combine the separate modules into a single set of data + // The constructor should be changed to take the Part itself. It can be called if HasModule() is true. public class ProtoModuleEngine { private readonly PartModule module; @@ -627,19 +642,6 @@ MinimumThrust = engine.minThrust; Propellants = engine.propellants; } - - private void SetModuleEnginesFx() - { - ModuleEnginesFX engine = module as ModuleEnginesFX; - if (engine == null) - { - return; - } - - MaximumThrust = engine.maxThrust * (engine.thrustPercentage * 0.01); - MinimumThrust = engine.minThrust; - Propellants = engine.propellants; - } } } } --- a/KerbalEngineer/Flight/DisplayStack.cs +++ b/KerbalEngineer/Flight/DisplayStack.cs @@ -214,7 +214,7 @@ /// private void DrawControlBar() { - GUILayout.Label("FLIGHT ENGINEER " + EngineerGlobals.AssemblyVersion, this.titleStyle); + GUILayout.Label("FLIGHT ENGINEER " + EngineerGlobals.ASSEMBLY_VERSION, this.titleStyle); this.DrawControlBarButtons(SectionLibrary.StockSections); this.DrawControlBarButtons(SectionLibrary.CustomSections); --- a/KerbalEngineer/Flight/Readouts/Miscellaneous/Separator.cs +++ b/KerbalEngineer/Flight/Readouts/Miscellaneous/Separator.cs @@ -45,7 +45,7 @@ { this.Name = "Separator"; this.Category = ReadoutCategory.GetCategory("Miscellaneous"); - this.HelpString = String.Empty; + this.HelpString = "Creats a line to help seperate subsections in a module."; this.IsDefault = false; this.Cloneable = true; --- a/KerbalEngineer/Flight/Readouts/Miscellaneous/SimulationDelay.cs +++ b/KerbalEngineer/Flight/Readouts/Miscellaneous/SimulationDelay.cs @@ -51,7 +51,7 @@ GUILayout.BeginHorizontal(); GUILayout.Label("Sim Delay", this.NameStyle); GUI.skin = HighLogic.Skin; - SimManager.minSimTime = new TimeSpan(0, 0, 0, 0, (int)GUILayout.HorizontalSlider(SimManager.minSimTime.Milliseconds, 0, 1000.0f)); + SimManager.minSimTime = TimeSpan.FromMilliseconds(GUILayout.HorizontalSlider((float)SimManager.minSimTime.TotalMilliseconds, 0, 2000.0f)); GUI.skin = null; GUILayout.EndHorizontal(); } --- a/KerbalEngineer/Flight/Readouts/Miscellaneous/SystemTime.cs +++ b/KerbalEngineer/Flight/Readouts/Miscellaneous/SystemTime.cs @@ -40,7 +40,7 @@ { this.Name = "System Time"; this.Category = ReadoutCategory.GetCategory("Miscellaneous"); - this.HelpString = String.Empty; + this.HelpString = "Shows the System Time in 12 hour format (AM/PM)"; this.IsDefault = false; } --- a/KerbalEngineer/Flight/Readouts/Miscellaneous/TimeReference.cs +++ b/KerbalEngineer/Flight/Readouts/Miscellaneous/TimeReference.cs @@ -38,7 +38,7 @@ { this.Name = "Time Reference Adjuster"; this.Category = ReadoutCategory.GetCategory("Miscellaneous"); - this.HelpString = String.Empty; + this.HelpString = "Shows a control that will allow you to select if days and years are calculated in Kerbin Time (6 hours/day) or Earth Time (24 hours/day)"; this.IsDefault = false; } --- a/KerbalEngineer/Flight/Readouts/Orbital/AngleToEquatorialAscendingNode.cs +++ b/KerbalEngineer/Flight/Readouts/Orbital/AngleToEquatorialAscendingNode.cs @@ -34,7 +34,7 @@ { this.Name = "Angle to Equ. AN"; this.Category = ReadoutCategory.GetCategory("Orbital"); - this.HelpString = string.Empty; + this.HelpString = "Angular Distance from the vessel to crossing the Equator of the central body, going north of it."; this.IsDefault = false; } --- a/KerbalEngineer/Flight/Readouts/Orbital/AngleToEquatorialDescendingNode.cs +++ b/KerbalEngineer/Flight/Readouts/Orbital/AngleToEquatorialDescendingNode.cs @@ -34,7 +34,7 @@ { this.Name = "Angle to Equ. DN"; this.Category = ReadoutCategory.GetCategory("Orbital"); - this.HelpString = string.Empty; + this.HelpString = "Angular Distance from the vessel to crossing the Equator of the central body, going south of it."; this.IsDefault = false; } --- a/KerbalEngineer/Flight/Readouts/Orbital/AngleToPrograde.cs +++ b/KerbalEngineer/Flight/Readouts/Orbital/AngleToPrograde.cs @@ -36,7 +36,7 @@ { this.Name = "Angle to Prograde"; this.Category = ReadoutCategory.GetCategory("Orbital"); - this.HelpString = String.Empty; + this.HelpString = "Angular Distance from the vessel to crossing the Orbit of the central body on it's retrograde side."; this.IsDefault = true; } --- a/KerbalEngineer/Flight/Readouts/Orbital/AngleToRetrograde.cs +++ b/KerbalEngineer/Flight/Readouts/Orbital/AngleToRetrograde.cs @@ -36,7 +36,7 @@ { this.Name = "Angle to Retrograde"; this.Category = ReadoutCategory.GetCategory("Orbital"); - this.HelpString = String.Empty; + this.HelpString = "Angular Distance from the vessel to crossing the Orbit of the central body on it's retrograde side."; this.IsDefault = true; } --- a/KerbalEngineer/Flight/Readouts/Orbital/ApoapsisHeight.cs +++ b/KerbalEngineer/Flight/Readouts/Orbital/ApoapsisHeight.cs @@ -34,7 +34,7 @@ { this.Name = "Apoapsis Height"; this.Category = ReadoutCategory.GetCategory("Orbital"); - this.HelpString = "Shows the vessel's apoapsis height relative to sea level. (Apoapsis is the highest point of an orbit.)"; + this.HelpString = "Shows the vessel's apoapsis height relative to sea level. (Apoapsis is the highest point of an orbit.)"; this.IsDefault = true; } --- a/KerbalEngineer/Flight/Readouts/Orbital/Inclination.cs +++ b/KerbalEngineer/Flight/Readouts/Orbital/Inclination.cs @@ -34,7 +34,7 @@ { this.Name = "Inclination"; this.Category = ReadoutCategory.GetCategory("Orbital"); - this.HelpString = "Shows the vessel's orbital inclination."; + this.HelpString = "Shows the vessel's orbital inclination relative to the Equator."; this.IsDefault = true; } --- a/KerbalEngineer/Flight/Readouts/Orbital/ManoeuvreNode/ManoeuvreProcessor.cs +++ b/KerbalEngineer/Flight/Readouts/Orbital/ManoeuvreNode/ManoeuvreProcessor.cs @@ -63,6 +63,10 @@ public static double NormalDeltaV { get; private set; } + public static double PostBurnAp { get; private set; } + + public static double PostBurnPe { get; private set; } + public static double ProgradeDeltaV { get; private set; } public static double RadialDeltaV { get; private set; } @@ -110,6 +114,8 @@ NormalDeltaV = deltaV.y; RadialDeltaV = deltaV.x; TotalDeltaV = node.GetBurnVector(FlightGlobals.ship_orbit).magnitude; + PostBurnAp = node.nextPatch != null ? node.nextPatch.ApA : 0; + PostBurnPe = node.nextPatch != null ? node.nextPatch.PeA : 0; UniversalTime = FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes[0].UT; AngleToPrograde = FlightGlobals.ActiveVessel.patchedConicSolver.maneuverNodes[0].patch.GetAngleToPrograde(UniversalTime); --- a/KerbalEngineer/Flight/Readouts/Orbital/ManoeuvreNode/NodeAngleToPrograde.cs +++ b/KerbalEngineer/Flight/Readouts/Orbital/ManoeuvreNode/NodeAngleToPrograde.cs @@ -36,7 +36,7 @@ { this.Name = "Manoeuvre Node Angle to Prograde"; this.Category = ReadoutCategory.GetCategory("Orbital"); - this.HelpString = String.Empty; + this.HelpString = "Angular Distance from the Node to crossing the Orbit of the central body on it's prograde side."; this.IsDefault = true; } --- a/KerbalEngineer/Flight/Readouts/Orbital/ManoeuvreNode/NodeAngleToRetrograde.cs +++ b/KerbalEngineer/Flight/Readouts/Orbital/ManoeuvreNode/NodeAngleToRetrograde.cs @@ -36,7 +36,7 @@ { this.Name = "Manoeuvre Node Angle to Retrograde"; this.Category = ReadoutCategory.GetCategory("Orbital"); - this.HelpString = String.Empty; + this.HelpString = "Angular Distance from the Node to crossing the Orbit of the central body on it's retrograde side."; this.IsDefault = true; } --- a/KerbalEngineer/Flight/Readouts/Orbital/ManoeuvreNode/NodeBurnTime.cs +++ b/KerbalEngineer/Flight/Readouts/Orbital/ManoeuvreNode/NodeBurnTime.cs @@ -36,7 +36,7 @@ { this.Name = "Manoeuvre Node Burn Time"; this.Category = ReadoutCategory.GetCategory("Orbital"); - this.HelpString = String.Empty; + this.HelpString = "The burn's total duration."; this.IsDefault = true; } --- a/KerbalEngineer/Flight/Readouts/Orbital/ManoeuvreNode/NodeHalfBurnTime.cs +++ b/KerbalEngineer/Flight/Readouts/Orbital/ManoeuvreNode/NodeHalfBurnTime.cs @@ -36,7 +36,7 @@ { this.Name = "Manoeuvre Node Half Burn Time"; this.Category = ReadoutCategory.GetCategory("Orbital"); - this.HelpString = String.Empty; + this.HelpString = "Half of the burn's total duration."; this.IsDefault = true; } --- a/KerbalEngineer/Flight/Readouts/Orbital/ManoeuvreNode/NodeNormalDeltaV.cs +++ b/KerbalEngineer/Flight/Readouts/Orbital/ManoeuvreNode/NodeNormalDeltaV.cs @@ -36,7 +36,7 @@ { this.Name = "Manoeuvre Node DeltaV (Normal)"; this.Category = ReadoutCategory.GetCategory("Orbital"); - this.HelpString = String.Empty; + this.HelpString = "Normal component of the total change in velocity."; this.IsDefault = true; } --- a/KerbalEngineer/Flight/Readouts/Orbital/ManoeuvreNode/NodeProgradeDeltaV.cs +++ b/KerbalEngineer/Flight/Readouts/Orbital/ManoeuvreNode/NodeProgradeDeltaV.cs @@ -36,7 +36,7 @@ { this.Name = "Manoeuvre Node DeltaV (Prograde)"; this.Category = ReadoutCategory.GetCategory("Orbital"); - this.HelpString = String.Empty; + this.HelpString = "Prograde/Retrograde component of the total change in velocity."; this.IsDefault = true; } --- a/KerbalEngineer/Flight/Readouts/Orbital/ManoeuvreNode/NodeRadialDeltaV.cs +++ b/KerbalEngineer/Flight/Readouts/Orbital/ManoeuvreNode/NodeRadialDeltaV.cs @@ -36,7 +36,7 @@ { this.Name = "Manoeuvre Node DeltaV (Radial)"; this.Category = ReadoutCategory.GetCategory("Orbital"); - this.HelpString = String.Empty; + this.HelpString = "Radial component of the total change in velocity."; this.IsDefault = true; } --- a/KerbalEngineer/Flight/Readouts/Orbital/ManoeuvreNode/NodeTimeToHalfBurn.cs +++ b/KerbalEngineer/Flight/Readouts/Orbital/ManoeuvreNode/NodeTimeToHalfBurn.cs @@ -36,7 +36,7 @@ { this.Name = "Time to Manoeuvre Burn"; this.Category = ReadoutCategory.GetCategory("Orbital"); - this.HelpString = String.Empty; + this.HelpString = "Time until the Manoeuvre should be started."; this.IsDefault = true; } --- a/KerbalEngineer/Flight/Readouts/Orbital/ManoeuvreNode/NodeTimeToManoeuvre.cs +++ b/KerbalEngineer/Flight/Readouts/Orbital/ManoeuvreNode/NodeTimeToManoeuvre.cs @@ -36,7 +36,7 @@ { this.Name = "Time to Manoeuvre Node"; this.Category = ReadoutCategory.GetCategory("Orbital"); - this.HelpString = String.Empty; + this.HelpString = "Time until the vessel reaches the position of the Manoeuvre Node."; this.IsDefault = true; } --- a/KerbalEngineer/Flight/Readouts/Orbital/ManoeuvreNode/NodeTotalDeltaV.cs +++ b/KerbalEngineer/Flight/Readouts/Orbital/ManoeuvreNode/NodeTotalDeltaV.cs @@ -36,7 +36,7 @@ { this.Name = "Manoeuvre Node DeltaV (Total)"; this.Category = ReadoutCategory.GetCategory("Orbital"); - this.HelpString = String.Empty; + this.HelpString = "Total change in velocity during the burn."; this.IsDefault = true; } --- /dev/null +++ b/KerbalEngineer/Flight/Readouts/Orbital/ManoeuvreNode/PostBurnApoapsis.cs @@ -1,1 +1,69 @@ +// +// 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 . +// +#region Using Directives + +using System; + +using KerbalEngineer.Extensions; +using KerbalEngineer.Flight.Sections; + +#endregion + +namespace KerbalEngineer.Flight.Readouts.Orbital.ManoeuvreNode +{ + public class PostBurnApoapsis : ReadoutModule + { + #region Constructors + + public PostBurnApoapsis() + { + this.Name = "Post-burn Apoapsis"; + this.Category = ReadoutCategory.GetCategory("Orbital"); + this.HelpString = "Farthest point of the vessel's ofbit after the burn."; + this.IsDefault = false; + } + + #endregion + + #region Methods: public + + public override void Draw(SectionModule section) + { + if (!ManoeuvreProcessor.ShowDetails) + { + return; + } + + this.DrawLine("Post-burn Apoapsis", ManoeuvreProcessor.PostBurnAp.ToDistance(), section.IsHud); + } + + public override void Reset() + { + ManoeuvreProcessor.Reset(); + } + + public override void Update() + { + ManoeuvreProcessor.RequestUpdate(); + } + + #endregion + } +} --- /dev/null +++ b/KerbalEngineer/Flight/Readouts/Orbital/ManoeuvreNode/PostBurnPeriapsis.cs @@ -1,1 +1,69 @@ +// +// 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 . +// +#region Using Directives + +using System; + +using KerbalEngineer.Extensions; +using KerbalEngineer.Flight.Sections; + +#endregion + +namespace KerbalEngineer.Flight.Readouts.Orbital.ManoeuvreNode +{ + public class PostBurnPeriapsis : ReadoutModule + { + #region Constructors + + public PostBurnPeriapsis() + { + this.Name = "Post-burn Periapsis"; + this.Category = ReadoutCategory.GetCategory("Orbital"); + this.HelpString = "Closest point of the vessel's ofbit after the burn."; + this.IsDefault = false; + } + + #endregion + + #region Methods: public + + public override void Draw(SectionModule section) + { + if (!ManoeuvreProcessor.ShowDetails) + { + return; + } + + this.DrawLine("Post-burn Periapsis", ManoeuvreProcessor.PostBurnPe.ToDistance(), section.IsHud); + } + + public override void Reset() + { + ManoeuvreProcessor.Reset(); + } + + public override void Update() + { + ManoeuvreProcessor.RequestUpdate(); + } + + #endregion + } +} --- a/KerbalEngineer/Flight/Readouts/Orbital/PeriapsisHeight.cs +++ b/KerbalEngineer/Flight/Readouts/Orbital/PeriapsisHeight.cs @@ -34,7 +34,7 @@ { this.Name = "Periapsis Height"; this.Category = ReadoutCategory.GetCategory("Orbital"); - this.HelpString = "Shows the vessel's periapsis height relative to sea level. (Periapsis is the lowest point of an orbit."; + this.HelpString = "Shows the vessel's periapsis height relative to sea level. (Periapsis is the lowest point of an orbit.)"; this.IsDefault = true; } --- /dev/null +++ b/KerbalEngineer/Flight/Readouts/Orbital/SpeedAtApoapsis.cs @@ -1,1 +1,68 @@ +// +// 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 . +// +#region Using Directives + +using System; +using KerbalEngineer.Flight.Sections; +using KerbalEngineer.Helpers; +using KerbalEngineer.Extensions; + +#endregion + +namespace KerbalEngineer.Flight.Readouts.Orbital +{ + public class SpeedAtApoapsis : ReadoutModule + { + #region Constructors + + public SpeedAtApoapsis() + { + this.Name = "Speed at Apoapsis"; + this.Category = ReadoutCategory.GetCategory("Orbital"); + this.HelpString = "Shows the orbital speed of the vessel when at apoapsis, the highest point of the orbit."; + this.IsDefault = false; + } + + #endregion + + #region Methods: public + + public override void Draw(SectionModule section) + { + // Vis-viva: v^2 = GM(2/r - 1/a) + // All this is easily got from the ships orbit (and reference body) + String str; + Orbit orbit = FlightGlobals.ship_orbit; + if (orbit.eccentricity > 1.0) + str = "---m/s"; + else + { + double speedsqr = orbit.referenceBody.gravParameter * ((2 / orbit.ApR) - (1 / orbit.semiMajorAxis)); + if (Double.IsNaN(speedsqr) || speedsqr < 0) + str = "---m/s"; // Don't think this is possible barring bugs in the Orbit class + else + str = Math.Sqrt(speedsqr).ToSpeed(); + } + this.DrawLine(str, section.IsHud); + } + + #endregion + } +} --- /dev/null +++ b/KerbalEngineer/Flight/Readouts/Orbital/SpeedAtPeriapsis.cs @@ -1,1 +1,64 @@ +// +// 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 . +// +#region Using Directives + +using System; +using KerbalEngineer.Flight.Sections; +using KerbalEngineer.Helpers; +using KerbalEngineer.Extensions; + +#endregion + +namespace KerbalEngineer.Flight.Readouts.Orbital +{ + public class SpeedAtPeriapsis : ReadoutModule + { + #region Constructors + + public SpeedAtPeriapsis() + { + this.Name = "Speed at Periapsis"; + this.Category = ReadoutCategory.GetCategory("Orbital"); + this.HelpString = "Shows the orbital speed of the vessel when at periapsis, the lowest point of the orbit."; + this.IsDefault = false; + } + + #endregion + + #region Methods: public + + public override void Draw(SectionModule section) + { + // Vis-viva: v^2 = GM(2/r - 1/a) + // All this is easily got from the ships orbit (and reference body) + String str; + Orbit orbit = FlightGlobals.ship_orbit; + double oneovera = (orbit.eccentricity == 1) ? 0 : (1 / orbit.semiMajorAxis); + double speedsqr = orbit.referenceBody.gravParameter * ((2 / orbit.PeR) - oneovera); + if (Double.IsNaN(speedsqr) || speedsqr < 0) + str = "---m/s"; + else + str = Math.Sqrt(speedsqr).ToSpeed(); + this.DrawLine(str, section.IsHud); + } + + #endregion + } +} --- /dev/null +++ b/KerbalEngineer/Flight/Readouts/Orbital/TimeToAtmosphere.cs @@ -1,1 +1,99 @@ +// +// 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 . +// +#region Using Directives + +using System; +using KerbalEngineer.Flight.Sections; +using KerbalEngineer.Helpers; + +#endregion + +namespace KerbalEngineer.Flight.Readouts.Orbital +{ + public class TimeToAtmosphere : ReadoutModule + { + //private LogMsg log = new LogMsg(); + + #region Constructors + + public TimeToAtmosphere() + { + this.Name = "Time to Atmosphere"; + this.Category = ReadoutCategory.GetCategory("Orbital"); + this.HelpString = "Shows the time until the vessel enters or leaves the atmosphere."; + this.IsDefault = false; + } + + #endregion + + #region Methods: public + + public override void Draw(SectionModule section) + { + String str; + Orbit orbit = FlightGlobals.ship_orbit; + + if (orbit.referenceBody.atmosphere && orbit.PeA < orbit.referenceBody.atmosphereDepth && orbit.ApA > orbit.referenceBody.atmosphereDepth) + { + double tA = orbit.TrueAnomalyAtRadius(orbit.referenceBody.atmosphereDepth + orbit.referenceBody.Radius); + //log.buf.AppendFormat("tA = {0}\n", tA); + double utTime = Planetarium.GetUniversalTime(); + //log.buf.AppendFormat("utTime = {0}\n", utTime); + double timeAtRad1 = orbit.GetUTforTrueAnomaly(tA, orbit.period * 0.5); + //log.buf.AppendFormat("timeAtRad1 = {0}\n", timeAtRad1); + if (timeAtRad1 < utTime) + { + timeAtRad1 += orbit.period; + //log.buf.AppendFormat("timeAtRad1 = {0}\n", timeAtRad1); + } + double timeAtRad2 = orbit.GetUTforTrueAnomaly(-tA, orbit.period * 0.5); + //log.buf.AppendFormat("timeAtRad2 = {0}\n", timeAtRad2); + if (timeAtRad2 < utTime) + { + timeAtRad2 += orbit.period; + //log.buf.AppendFormat("timeAtRad2 = {0}\n", timeAtRad2); + } + double time = Math.Min(timeAtRad1, timeAtRad2) - utTime; + //log.buf.AppendFormat("time = {0}\n", time); + + if (Double.IsNaN(time)) + { + str = "---s"; + //log.buf.AppendLine("time is NaN"); + } + else + { + str = TimeFormatter.ConvertToString(time); + //log.buf.AppendFormat("str = {0}\n", str); + } + } + else + { + str = "---s"; + //log.buf.AppendLine("no atmosphere, pe > atmosphere, or ap < atmosphere"); + } + + //log.Flush(); + this.DrawLine(str, section.IsHud); + } + + #endregion + } +} --- a/KerbalEngineer/Flight/Readouts/Orbital/TimeToEquatorialAscendingNode.cs +++ b/KerbalEngineer/Flight/Readouts/Orbital/TimeToEquatorialAscendingNode.cs @@ -35,7 +35,7 @@ { this.Name = "Time to Equ. AN"; this.Category = ReadoutCategory.GetCategory("Orbital"); - this.HelpString = string.Empty; + this.HelpString = "Shows the time until the vessel corsses the Equator, going north of it."; this.IsDefault = false; } --- a/KerbalEngineer/Flight/Readouts/Orbital/TimeToEquatorialDescendingNode.cs +++ b/KerbalEngineer/Flight/Readouts/Orbital/TimeToEquatorialDescendingNode.cs @@ -35,7 +35,7 @@ { this.Name = "Time to Equ. DN"; this.Category = ReadoutCategory.GetCategory("Orbital"); - this.HelpString = string.Empty; + this.HelpString = "Shows the time until the vessel corsses the Equator, going south of it."; this.IsDefault = false; } --- a/KerbalEngineer/Flight/Readouts/ReadoutLibrary.cs +++ b/KerbalEngineer/Flight/Readouts/ReadoutLibrary.cs @@ -1,6 +1,4 @@ // -// Kerbal Engineer Redux -// // Copyright (C) 2015 CYBUTEK // // This program is free software: you can redistribute it and/or modify @@ -93,6 +91,11 @@ readouts.Add(new NodeTimeToHalfBurn()); readouts.Add(new NodeAngleToPrograde()); readouts.Add(new NodeAngleToRetrograde()); + readouts.Add(new PostBurnApoapsis()); + readouts.Add(new PostBurnPeriapsis()); + readouts.Add(new SpeedAtApoapsis()); + readouts.Add(new SpeedAtPeriapsis()); + readouts.Add(new TimeToAtmosphere()); // Surface readouts.Add(new AltitudeSeaLevel()); @@ -117,6 +120,7 @@ readouts.Add(new ImpactBiome()); // Vessel + readouts.Add(new Name()); readouts.Add(new DeltaVStaged()); readouts.Add(new DeltaVCurrent()); readouts.Add(new DeltaVTotal()); @@ -164,6 +168,8 @@ readouts.Add(new Rendezvous.OrbitalPeriod()); readouts.Add(new Rendezvous.SemiMajorAxis()); readouts.Add(new Rendezvous.SemiMinorAxis()); + readouts.Add(new Rendezvous.RelativeRadialVelocity()); + readouts.Add(new Rendezvous.TimeToRendezvous()); // Thermal readouts.Add(new InternalFlux()); @@ -171,11 +177,14 @@ readouts.Add(new RadiationFlux()); readouts.Add(new CriticalPart()); readouts.Add(new CriticalTemperature()); - readouts.Add(new CriticalPercentage()); + readouts.Add(new CriticalSkinTemperature()); + readouts.Add(new CriticalThermalPercentage()); readouts.Add(new HottestPart()); readouts.Add(new HottestTemperature()); + readouts.Add(new HottestSkinTemperature()); readouts.Add(new CoolestPart()); readouts.Add(new CoolestTemperature()); + readouts.Add(new CoolestSkinTemperature()); // Misc readouts.Add(new Separator()); --- a/KerbalEngineer/Flight/Readouts/Rendezvous/AltitudeSeaLevel.cs +++ b/KerbalEngineer/Flight/Readouts/Rendezvous/AltitudeSeaLevel.cs @@ -34,7 +34,7 @@ { this.Name = "Altitude (Sea Level)"; this.Category = ReadoutCategory.GetCategory("Rendezvous"); - this.HelpString = string.Empty; + this.HelpString = "Shows the target's altitude above sea level."; this.IsDefault = true; } --- a/KerbalEngineer/Flight/Readouts/Rendezvous/AngleToRelativeAscendingNode.cs +++ b/KerbalEngineer/Flight/Readouts/Rendezvous/AngleToRelativeAscendingNode.cs @@ -34,7 +34,7 @@ { this.Name = "Angle to Rel. AN"; this.Category = ReadoutCategory.GetCategory("Rendezvous"); - this.HelpString = string.Empty; + this.HelpString = "Angular Distance from the vessel to crossing the orbit of the target object, going north of it."; this.IsDefault = false; } --- a/KerbalEngineer/Flight/Readouts/Rendezvous/AngleToRelativeDescendingNode.cs +++ b/KerbalEngineer/Flight/Readouts/Rendezvous/AngleToRelativeDescendingNode.cs @@ -34,7 +34,7 @@ { this.Name = "Angle to Rel. DN"; this.Category = ReadoutCategory.GetCategory("Rendezvous"); - this.HelpString = string.Empty; + this.HelpString = "Angular Distance from the vessel to crossing the orbit of the target object, going south of it."; this.IsDefault = false; } --- a/KerbalEngineer/Flight/Readouts/Rendezvous/ApoapsisHeight.cs +++ b/KerbalEngineer/Flight/Readouts/Rendezvous/ApoapsisHeight.cs @@ -34,7 +34,7 @@ { this.Name = "Apoapsis Height"; this.Category = ReadoutCategory.GetCategory("Rendezvous"); - this.HelpString = string.Empty; + this.HelpString = "Shows the targets's apoapsis height relative to sea level. (Apoapsis is the highest point of an orbit.)"; this.IsDefault = true; } --- a/KerbalEngineer/Flight/Readouts/Rendezvous/Distance.cs +++ b/KerbalEngineer/Flight/Readouts/Rendezvous/Distance.cs @@ -34,7 +34,7 @@ { this.Name = "Distance"; this.Category = ReadoutCategory.GetCategory("Rendezvous"); - this.HelpString = string.Empty; + this.HelpString = "Current distance between the vessel and the target object."; this.IsDefault = true; } --- a/KerbalEngineer/Flight/Readouts/Rendezvous/OrbitalPeriod.cs +++ b/KerbalEngineer/Flight/Readouts/Rendezvous/OrbitalPeriod.cs @@ -34,7 +34,7 @@ { this.Name = "Orbital Period"; this.Category = ReadoutCategory.GetCategory("Rendezvous"); - this.HelpString = string.Empty; + this.HelpString = "Shows the amount of time it will take the target object to complete a full orbit."; this.IsDefault = false; } --- a/KerbalEngineer/Flight/Readouts/Rendezvous/PeriapsisHeight.cs +++ b/KerbalEngineer/Flight/Readouts/Rendezvous/PeriapsisHeight.cs @@ -34,7 +34,7 @@ { this.Name = "Periapsis Height"; this.Category = ReadoutCategory.GetCategory("Rendezvous"); - this.HelpString = string.Empty; + this.HelpString = "Shows the targets's periapsis height relative to sea level. (Periapsis is the lowest point of an orbit.)"; this.IsDefault = true; } --- a/KerbalEngineer/Flight/Readouts/Rendezvous/PhaseAngle.cs +++ b/KerbalEngineer/Flight/Readouts/Rendezvous/PhaseAngle.cs @@ -34,7 +34,7 @@ { this.Name = "Phase Angle"; this.Category = ReadoutCategory.GetCategory("Rendezvous"); - this.HelpString = string.Empty; + this.HelpString = "Angular distance of the vessel relative to the target object."; this.IsDefault = true; } --- /dev/null +++ b/KerbalEngineer/Flight/Readouts/Rendezvous/RelativeRadialVelocity.cs @@ -1,1 +1,66 @@ +// +// 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 . +// +#region Using Directives + +using KerbalEngineer.Extensions; +using KerbalEngineer.Flight.Sections; + +#endregion + +namespace KerbalEngineer.Flight.Readouts.Rendezvous +{ + public class RelativeRadialVelocity : ReadoutModule + { + #region Constructors + + public RelativeRadialVelocity() + { + this.Name = "Relative Radial Velocity"; + this.Category = ReadoutCategory.GetCategory("Rendezvous"); + this.HelpString = "Relative radial velocity between your vessel and the target object"; + this.IsDefault = false; + } + + #endregion + + #region Methods: public + + public override void Draw(SectionModule section) + { + if (RendezvousProcessor.ShowDetails) + { + this.DrawLine(RendezvousProcessor.RelativeRadialVelocity.ToSpeed(), section.IsHud); + } + } + + public override void Reset() + { + FlightEngineerCore.Instance.AddUpdatable(RendezvousProcessor.Instance); + } + + public override void Update() + { + RendezvousProcessor.RequestUpdate(); + } + + #endregion + } +} + --- a/KerbalEngineer/Flight/Readouts/Rendezvous/RendezvousProcessor.cs +++ b/KerbalEngineer/Flight/Readouts/Rendezvous/RendezvousProcessor.cs @@ -135,6 +135,16 @@ /// Gets the target's time to periapsis. /// public static double TimeToPeriapsis { get; private set; } + + /// + /// Gets the relative radial velocity. + /// + public static double RelativeRadialVelocity { get; private set; } + + /// + /// Gets approximate (linearly) time to the minimum distance between objects. + /// + public static double TimeToRendezvous { get; private set; } /// /// Gets and sets whether the updatable object should be updated. @@ -193,6 +203,14 @@ Distance = Vector3d.Distance(targetOrbit.pos, originOrbit.pos); OrbitalPeriod = targetOrbit.period; + + // beware that the order/sign of coordinates is inconsistent across different exposed variables + // in particular, v below does not equal to FlightGlobals.ship_tgtVelocity + Vector3d x = targetOrbit.pos - originOrbit.pos; + Vector3d v = targetOrbit.vel - originOrbit.vel; + double xv = Vector3d.Dot(x, v); + TimeToRendezvous = - xv / Vector3d.SqrMagnitude(v); + RelativeRadialVelocity = xv / Vector3d.Magnitude(x); } private double CalcInterceptAngle() --- a/KerbalEngineer/Flight/Readouts/Rendezvous/SemiMajorAxis.cs +++ b/KerbalEngineer/Flight/Readouts/Rendezvous/SemiMajorAxis.cs @@ -36,7 +36,7 @@ { this.Name = "Semi-major Axis"; this.Category = ReadoutCategory.GetCategory("Rendezvous"); - this.HelpString = String.Empty; + this.HelpString = "Shows the distance from the centre of the target's orbit to the farthest edge."; this.IsDefault = true; } --- a/KerbalEngineer/Flight/Readouts/Rendezvous/SemiMinorAxis.cs +++ b/KerbalEngineer/Flight/Readouts/Rendezvous/SemiMinorAxis.cs @@ -36,7 +36,7 @@ { this.Name = "Semi-minor Axis"; this.Category = ReadoutCategory.GetCategory("Rendezvous"); - this.HelpString = String.Empty; + this.HelpString = "Shows the distance from the centre of the target's orbit to the nearest edge."; this.IsDefault = false; } --- a/KerbalEngineer/Flight/Readouts/Rendezvous/TimeToApoapsis.cs +++ b/KerbalEngineer/Flight/Readouts/Rendezvous/TimeToApoapsis.cs @@ -34,7 +34,7 @@ { this.Name = "Time to Apoapsis"; this.Category = ReadoutCategory.GetCategory("Rendezvous"); - this.HelpString = string.Empty; + this.HelpString = "Shows the time until the target reaches apoapsis, the highest point of the orbit."; this.IsDefault = false; } --- a/KerbalEngineer/Flight/Readouts/Rendezvous/TimeToPeriapsis.cs +++ b/KerbalEngineer/Flight/Readouts/Rendezvous/TimeToPeriapsis.cs @@ -34,7 +34,7 @@ { this.Name = "Time to Periapsis"; this.Category = ReadoutCategory.GetCategory("Rendezvous"); - this.HelpString = string.Empty; + this.HelpString = "Shows the time until the target reaches periapsis, the lowest point of the orbit."; this.IsDefault = false; } --- a/KerbalEngineer/Flight/Readouts/Rendezvous/TimeToRelativeAscendingNode.cs +++ b/KerbalEngineer/Flight/Readouts/Rendezvous/TimeToRelativeAscendingNode.cs @@ -34,7 +34,7 @@ { this.Name = "Time to Rel. AN"; this.Category = ReadoutCategory.GetCategory("Rendezvous"); - this.HelpString = string.Empty; + this.HelpString = "Time until the vessel crosses the target's orbit, going north."; this.IsDefault = true; } --- a/KerbalEngineer/Flight/Readouts/Rendezvous/TimeToRelativeDescendingNode.cs +++ b/KerbalEngineer/Flight/Readouts/Rendezvous/TimeToRelativeDescendingNode.cs @@ -34,7 +34,7 @@ { this.Name = "Time to Rel. DN"; this.Category = ReadoutCategory.GetCategory("Rendezvous"); - this.HelpString = string.Empty; + this.HelpString = "Time until the vessel crosses the target's orbit, going south."; this.IsDefault = true; } --- /dev/null +++ b/KerbalEngineer/Flight/Readouts/Rendezvous/TimeToRendezvous.cs @@ -1,1 +1,65 @@ +// +// 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 . +// +#region Using Directives + +using KerbalEngineer.Flight.Sections; +using KerbalEngineer.Helpers; + +#endregion + +namespace KerbalEngineer.Flight.Readouts.Rendezvous +{ + public class TimeToRendezvous : ReadoutModule + { + #region Constructors + + public TimeToRendezvous() + { + this.Name = "Time to Rendezvous"; + this.Category = ReadoutCategory.GetCategory("Rendezvous"); + this.HelpString = "Approximate (linearly) time to the minimum distance between objects."; + this.IsDefault = false; + } + + #endregion + + #region Methods: public + + public override void Draw(SectionModule section) + { + if (RendezvousProcessor.ShowDetails) + { + this.DrawLine(TimeFormatter.ConvertToString(RendezvousProcessor.TimeToRendezvous), section.IsHud); + } + } + + public override void Reset() + { + FlightEngineerCore.Instance.AddUpdatable(RendezvousProcessor.Instance); + } + + public override void Update() + { + RendezvousProcessor.RequestUpdate(); + } + + #endregion + } +} --- a/KerbalEngineer/Flight/Readouts/Surface/HorizontalSpeed.cs +++ b/KerbalEngineer/Flight/Readouts/Surface/HorizontalSpeed.cs @@ -21,6 +21,7 @@ using KerbalEngineer.Extensions; using KerbalEngineer.Flight.Sections; +using System; #endregion @@ -44,7 +45,11 @@ public override void Draw(SectionModule section) { - this.DrawLine(FlightGlobals.ActiveVessel.horizontalSrfSpeed.ToSpeed(), section.IsHud); + // Used to do this but the bug-fix to horizontalSrfSpeed in KSP 1.0.3 actually made it worse so workaround + //this.DrawLine(FlightGlobals.ActiveVessel.horizontalSrfSpeed.ToSpeed(), section.IsHud); + var ves = FlightGlobals.ActiveVessel; + double horizSpeed = Math.Sqrt(ves.srfSpeed * ves.srfSpeed - ves.verticalSpeed * ves.verticalSpeed); + this.DrawLine(horizSpeed.ToSpeed(), section.IsHud); } #endregion --- a/KerbalEngineer/Flight/Readouts/Surface/ImpactAltitude.cs +++ b/KerbalEngineer/Flight/Readouts/Surface/ImpactAltitude.cs @@ -34,7 +34,7 @@ { this.Name = "Impact Altitude"; this.Category = ReadoutCategory.GetCategory("Surface"); - this.HelpString = string.Empty; + this.HelpString = "Altitude at which the Vessel will impact."; this.IsDefault = false; } --- a/KerbalEngineer/Flight/Readouts/Surface/ImpactBiome.cs +++ b/KerbalEngineer/Flight/Readouts/Surface/ImpactBiome.cs @@ -33,7 +33,7 @@ { this.Name = "Impact Biome"; this.Category = ReadoutCategory.GetCategory("Surface"); - this.HelpString = string.Empty; + this.HelpString = "Biome the Vessel will impact in."; this.IsDefault = true; } --- a/KerbalEngineer/Flight/Readouts/Surface/ImpactLatitude.cs +++ b/KerbalEngineer/Flight/Readouts/Surface/ImpactLatitude.cs @@ -34,7 +34,7 @@ { this.Name = "Impact Latitude"; this.Category = ReadoutCategory.GetCategory("Surface"); - this.HelpString = string.Empty; + this.HelpString = "Latitude of the impact position."; this.IsDefault = false; } --- a/KerbalEngineer/Flight/Readouts/Surface/ImpactLongitude.cs +++ b/KerbalEngineer/Flight/Readouts/Surface/ImpactLongitude.cs @@ -34,7 +34,7 @@ { this.Name = "Impact Longitude"; this.Category = ReadoutCategory.GetCategory("Surface"); - this.HelpString = string.Empty; + this.HelpString = "Longditude of the impact position."; this.IsDefault = false; } --- a/KerbalEngineer/Flight/Readouts/Surface/ImpactTime.cs +++ b/KerbalEngineer/Flight/Readouts/Surface/ImpactTime.cs @@ -34,7 +34,7 @@ { this.Name = "Impact Time"; this.Category = ReadoutCategory.GetCategory("Surface"); - this.HelpString = string.Empty; + this.HelpString = "Shows time until the vessel impacts the central object."; this.IsDefault = true; } --- a/KerbalEngineer/Flight/Readouts/Surface/Latitude.cs +++ b/KerbalEngineer/Flight/Readouts/Surface/Latitude.cs @@ -34,7 +34,7 @@ { this.Name = "Latitude"; this.Category = ReadoutCategory.GetCategory("Surface"); - this.HelpString = "Shows the vessel's latitude position around the celestial body. Latitude is the angle from the equator to poles."; + this.HelpString = "Shows the vessel's latitude position around the celestial body. Latitude is the angle from the equator to poles."; this.IsDefault = true; } --- a/KerbalEngineer/Flight/Readouts/Surface/Longitude.cs +++ b/KerbalEngineer/Flight/Readouts/Surface/Longitude.cs @@ -28,7 +28,7 @@ { Name = "Longitude"; Category = ReadoutCategory.GetCategory("Surface"); - HelpString = "Shows the vessel's longitude around a celestial body. Longitude is the angle from the bodies prime meridian."; + HelpString = "Shows the vessel's longitude around a celestial body. Longitude is the angle from the bodies prime meridian."; IsDefault = true; } --- a/KerbalEngineer/Flight/Readouts/Surface/Situation.cs +++ b/KerbalEngineer/Flight/Readouts/Surface/Situation.cs @@ -33,7 +33,7 @@ { this.Name = "Situation"; this.Category = ReadoutCategory.GetCategory("Surface"); - this.HelpString = string.Empty; + this.HelpString = "Shows the vessel's current scientific situation. (Landed, Splashed, Flying Low/High, In Space Low/High)"; this.IsDefault = true; } --- a/KerbalEngineer/Flight/Readouts/Thermal/CoolestPart.cs +++ b/KerbalEngineer/Flight/Readouts/Thermal/CoolestPart.cs @@ -27,7 +27,7 @@ { Name = "Coolest Part"; Category = ReadoutCategory.GetCategory("Thermal"); - HelpString = string.Empty; + HelpString = "The part of the vessel that is enduring the lowest temperature."; IsDefault = true; } --- /dev/null +++ b/KerbalEngineer/Flight/Readouts/Thermal/CoolestSkinTemperature.cs @@ -1,1 +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 . +// +namespace KerbalEngineer.Flight.Readouts.Thermal +{ + using Helpers; + using Sections; + + public class CoolestSkinTemperature : ReadoutModule + { + public CoolestSkinTemperature() + { + Name = "Coolest Skin Temperature"; + Category = ReadoutCategory.GetCategory("Thermal"); + HelpString = "Lowest external Temperature on the Vessel."; + IsDefault = true; + } + + public override void Draw(SectionModule section) + { + if (ThermalProcessor.ShowDetails) + { + DrawLine(Units.ToTemperature(ThermalProcessor.CoolestSkinTemperature, ThermalProcessor.CoolestSkinTemperatureMax), section.IsHud); + } + } + + public override void Reset() + { + FlightEngineerCore.Instance.AddUpdatable(ThermalProcessor.Instance); + } + + public override void Update() + { + ThermalProcessor.RequestUpdate(); + } + } +} --- a/KerbalEngineer/Flight/Readouts/Thermal/CoolestTemperature.cs +++ b/KerbalEngineer/Flight/Readouts/Thermal/CoolestTemperature.cs @@ -28,7 +28,7 @@ { Name = "Coolest Temperature"; Category = ReadoutCategory.GetCategory("Thermal"); - HelpString = string.Empty; + HelpString = "Lowest internal Temperature on the Vessel."; IsDefault = true; } --- a/KerbalEngineer/Flight/Readouts/Thermal/CriticalPart.cs +++ b/KerbalEngineer/Flight/Readouts/Thermal/CriticalPart.cs @@ -27,7 +27,7 @@ { Name = "Critical Part"; Category = ReadoutCategory.GetCategory("Thermal"); - HelpString = string.Empty; + HelpString = "This part is structually most critical. If it endures too high temperature there is a high chance for major structual failure!"; IsDefault = true; } --- a/KerbalEngineer/Flight/Readouts/Thermal/CriticalPercentage.cs +++ /dev/null @@ -1,53 +1,1 @@ -// -// 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 . -// -namespace KerbalEngineer.Flight.Readouts.Thermal -{ - using Extensions; - using Sections; - - public class CriticalPercentage : ReadoutModule - { - public CriticalPercentage() - { - Name = "Critical Percentage"; - Category = ReadoutCategory.GetCategory("Thermal"); - HelpString = string.Empty; - IsDefault = true; - } - - public override void Draw(SectionModule section) - { - if (ThermalProcessor.ShowDetails) - { - DrawLine(ThermalProcessor.CriticalTemperaturePercentage.ToPercent(), section.IsHud); - } - } - - public override void Reset() - { - FlightEngineerCore.Instance.AddUpdatable(ThermalProcessor.Instance); - } - - public override void Update() - { - ThermalProcessor.RequestUpdate(); - } - } -} --- /dev/null +++ b/KerbalEngineer/Flight/Readouts/Thermal/CriticalSkinTemperature.cs @@ -1,1 +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 . +// +namespace KerbalEngineer.Flight.Readouts.Thermal +{ + using Helpers; + using Sections; + + public class CriticalSkinTemperature : ReadoutModule + { + public CriticalSkinTemperature() + { + Name = "Critical Skin Temperature"; + Category = ReadoutCategory.GetCategory("Thermal"); + HelpString = "Highest external Temperature on the part of the Vessel that is structually most critical."; + IsDefault = true; + } + + public override void Draw(SectionModule section) + { + if (ThermalProcessor.ShowDetails) + { + DrawLine(Units.ToTemperature(ThermalProcessor.CriticalSkinTemperature, ThermalProcessor.CriticalSkinTemperatureMax), section.IsHud); + } + } + + public override void Reset() + { + FlightEngineerCore.Instance.AddUpdatable(ThermalProcessor.Instance); + } + + public override void Update() + { + ThermalProcessor.RequestUpdate(); + } + } +} --- a/KerbalEngineer/Flight/Readouts/Thermal/CriticalTemperature.cs +++ b/KerbalEngineer/Flight/Readouts/Thermal/CriticalTemperature.cs @@ -28,7 +28,7 @@ { Name = "Critical Temperature"; Category = ReadoutCategory.GetCategory("Thermal"); - HelpString = string.Empty; + HelpString = "Internal Temperature on the part of the Vessel that is structually most critical."; IsDefault = true; } --- /dev/null +++ b/KerbalEngineer/Flight/Readouts/Thermal/CriticalThermalPercentage.cs @@ -1,1 +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 . +// +namespace KerbalEngineer.Flight.Readouts.Thermal +{ + using Extensions; + using Sections; + + public class CriticalThermalPercentage : ReadoutModule + { + public CriticalThermalPercentage() + { + Name = "Critical Thermal Percentage"; + Category = ReadoutCategory.GetCategory("Thermal"); + HelpString = "Shows how high a temperature the critical Part is enduring relative to it's maximal temperature."; + IsDefault = true; + } + + public override void Draw(SectionModule section) + { + if (ThermalProcessor.ShowDetails) + { + DrawLine(ThermalProcessor.CriticalTemperaturePercentage.ToPercent(), section.IsHud); + } + } + + public override void Reset() + { + FlightEngineerCore.Instance.AddUpdatable(ThermalProcessor.Instance); + } + + public override void Update() + { + ThermalProcessor.RequestUpdate(); + } + } +} --- a/KerbalEngineer/Flight/Readouts/Thermal/HottestPart.cs +++ b/KerbalEngineer/Flight/Readouts/Thermal/HottestPart.cs @@ -27,7 +27,7 @@ { Name = "Hottest Part"; Category = ReadoutCategory.GetCategory("Thermal"); - HelpString = string.Empty; + HelpString = "The part of the vessel that is enduring the highest temperature."; IsDefault = true; } --- /dev/null +++ b/KerbalEngineer/Flight/Readouts/Thermal/HottestSkinTemperature.cs @@ -1,1 +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 . +// +namespace KerbalEngineer.Flight.Readouts.Thermal +{ + using Helpers; + using Sections; + + public class HottestSkinTemperature : ReadoutModule + { + public HottestSkinTemperature() + { + Name = "Hottest Skin Temperature"; + Category = ReadoutCategory.GetCategory("Thermal"); + HelpString = "Highest external Temperature on the Vessel."; + IsDefault = true; + } + + public override void Draw(SectionModule section) + { + if (ThermalProcessor.ShowDetails) + { + DrawLine(Units.ToTemperature(ThermalProcessor.HottestSkinTemperature, ThermalProcessor.HottestSkinTemperatureMax), section.IsHud); + } + } + + public override void Reset() + { + FlightEngineerCore.Instance.AddUpdatable(ThermalProcessor.Instance); + } + + public override void Update() + { + ThermalProcessor.RequestUpdate(); + } + } +} --- a/KerbalEngineer/Flight/Readouts/Thermal/HottestTemperature.cs +++ b/KerbalEngineer/Flight/Readouts/Thermal/HottestTemperature.cs @@ -28,7 +28,7 @@ { Name = "Hottest Temperature"; Category = ReadoutCategory.GetCategory("Thermal"); - HelpString = string.Empty; + HelpString = "Highest internal Temperature on the Vessel."; IsDefault = true; } --- a/KerbalEngineer/Flight/Readouts/Thermal/ThermalProcessor.cs +++ b/KerbalEngineer/Flight/Readouts/Thermal/ThermalProcessor.cs @@ -1,6 +1,4 @@ // -// Kerbal Engineer Redux -// // Copyright (C) 2015 CYBUTEK // // This program is free software: you can redistribute it and/or modify @@ -19,6 +17,8 @@ namespace KerbalEngineer.Flight.Readouts.Thermal { + using System; + public class ThermalProcessor : IUpdatable, IUpdateRequest { private static readonly ThermalProcessor instance = new ThermalProcessor(); @@ -27,10 +27,16 @@ { HottestTemperature = 0.0; HottestTemperatureMax = 0.0; + HottestSkinTemperature = 0.0; + HottestSkinTemperatureMax = 0.0; CoolestTemperature = 0.0; CoolestTemperatureMax = 0.0; + CoolestSkinTemperature = 0.0; + CoolestSkinTemperatureMax = 0.0; CriticalTemperature = 0.0; CriticalTemperatureMax = 0.0; + CriticalSkinTemperature = 0.0; + CriticalSkinTemperatureMax = 0.0; HottestPartName = string.Empty; CoolestPartName = string.Empty; CriticalPartName = string.Empty; @@ -40,11 +46,19 @@ public static string CoolestPartName { get; private set; } + public static double CoolestSkinTemperature { get; private set; } + + public static double CoolestSkinTemperatureMax { get; private set; } + public static double CoolestTemperature { get; private set; } public static double CoolestTemperatureMax { get; private set; } public static string CriticalPartName { get; private set; } + + public static double CriticalSkinTemperature { get; private set; } + + public static double CriticalSkinTemperatureMax { get; private set; } public static double CriticalTemperature { get; private set; } @@ -53,6 +67,10 @@ public static double CriticalTemperaturePercentage { get; private set; } public static string HottestPartName { get; private set; } + + public static double HottestSkinTemperature { get; private set; } + + public static double HottestSkinTemperatureMax { get; private set; } public static double HottestTemperature { get; private set; } @@ -69,14 +87,8 @@ public static double InternalFlux { get; private set; } public static double RadiationFlux { get; private set; } + public static bool ShowDetails { get; private set; } - - public bool UpdateRequested { get; set; } - - public static void RequestUpdate() - { - instance.UpdateRequested = true; - } public void Update() { @@ -92,8 +104,11 @@ RadiationFlux = 0.0; InternalFlux = 0.0; HottestTemperature = 0.0; + HottestSkinTemperature = 0.0; CoolestTemperature = double.MaxValue; + CoolestSkinTemperature = double.MaxValue; CriticalTemperature = double.MaxValue; + CriticalSkinTemperature = double.MaxValue; CriticalTemperaturePercentage = 0.0; HottestPartName = string.Empty; CoolestPartName = string.Empty; @@ -107,26 +122,40 @@ RadiationFlux = RadiationFlux + part.thermalRadiationFlux; InternalFlux = InternalFlux + part.thermalInternalFluxPrevious; - if (part.temperature > HottestTemperature) + if (part.temperature > HottestTemperature || part.skinTemperature > HottestSkinTemperature) { HottestTemperature = part.temperature; HottestTemperatureMax = part.maxTemp; + HottestSkinTemperature = part.skinTemperature; + HottestSkinTemperatureMax = part.skinMaxTemp; HottestPartName = part.partInfo.title; } - if (part.temperature < CoolestTemperature) + if (part.temperature < CoolestTemperature || part.skinTemperature < CoolestSkinTemperature) { CoolestTemperature = part.temperature; CoolestTemperatureMax = part.maxTemp; + CoolestSkinTemperature = part.skinTemperature; + CoolestSkinTemperatureMax = part.skinMaxTemp; CoolestPartName = part.partInfo.title; } - if (part.temperature / part.maxTemp > CriticalTemperaturePercentage) + + if (part.temperature / part.maxTemp > CriticalTemperaturePercentage || part.skinTemperature / part.skinMaxTemp > CriticalTemperaturePercentage) { CriticalTemperature = part.temperature; CriticalTemperatureMax = part.maxTemp; - CriticalTemperaturePercentage = part.temperature / part.maxTemp; + CriticalSkinTemperature = part.skinTemperature; + CriticalSkinTemperatureMax = part.skinMaxTemp; + CriticalTemperaturePercentage = Math.Max(part.temperature / part.maxTemp, part.skinTemperature / part.skinMaxTemp); CriticalPartName = part.partInfo.title; } } } + + public bool UpdateRequested { get; set; } + + public static void RequestUpdate() + { + instance.UpdateRequested = true; + } } } --- a/KerbalEngineer/Flight/Readouts/Vessel/Acceleration.cs +++ b/KerbalEngineer/Flight/Readouts/Vessel/Acceleration.cs @@ -34,7 +34,7 @@ { this.Name = "Acceleration"; this.Category = ReadoutCategory.GetCategory("Vessel"); - this.HelpString = string.Empty; + this.HelpString = "Shows the current and maximum acceleration of the craft."; this.IsDefault = true; } --- a/KerbalEngineer/Flight/Readouts/Vessel/DeltaVStaged.cs +++ b/KerbalEngineer/Flight/Readouts/Vessel/DeltaVStaged.cs @@ -30,13 +30,6 @@ { public class DeltaVStaged : ReadoutModule { - #region Fields - - private int numberOfStages; - private bool showing; - - #endregion - #region Constructors public DeltaVStaged() --- a/KerbalEngineer/Flight/Readouts/Vessel/Heading.cs +++ b/KerbalEngineer/Flight/Readouts/Vessel/Heading.cs @@ -34,7 +34,7 @@ { this.Name = "Heading"; this.Category = ReadoutCategory.GetCategory("Vessel"); - this.HelpString = string.Empty; + this.HelpString = "Shows the current Heading."; this.IsDefault = false; } --- a/KerbalEngineer/Flight/Readouts/Vessel/HeadingRate.cs +++ b/KerbalEngineer/Flight/Readouts/Vessel/HeadingRate.cs @@ -34,7 +34,7 @@ { this.Name = "Heading Rate"; this.Category = ReadoutCategory.GetCategory("Vessel"); - this.HelpString = string.Empty; + this.HelpString = "Shows the current change in Heading."; this.IsDefault = false; } --- a/KerbalEngineer/Flight/Readouts/Vessel/IntakeAirDemand.cs +++ b/KerbalEngineer/Flight/Readouts/Vessel/IntakeAirDemand.cs @@ -39,7 +39,7 @@ { this.Name = "Intake Air (Demand)"; this.Category = ReadoutCategory.GetCategory("Vessel"); - this.HelpString = string.Empty; + this.HelpString = "Displays the Amount of Intake Air required."; this.IsDefault = false; } --- a/KerbalEngineer/Flight/Readouts/Vessel/IntakeAirDemandSupply.cs +++ b/KerbalEngineer/Flight/Readouts/Vessel/IntakeAirDemandSupply.cs @@ -42,7 +42,7 @@ { this.Name = "Intake Air (D/S)"; this.Category = ReadoutCategory.GetCategory("Vessel"); - this.HelpString = string.Empty; + this.HelpString = "Displays the Ration between required and available Intake Air."; this.IsDefault = false; } @@ -55,20 +55,11 @@ var demand = 0.0; foreach (var part in FlightGlobals.ActiveVessel.Parts) { - if (part.Modules.Contains("ModuleEngines")) + for (int i = 0; i < part.Modules.Count; i++) { - var engine = part.Modules["ModuleEngines"] as ModuleEngines; - if (engine.isOperational) - { - demand += engine.propellants - .Where(p => p.name == "IntakeAir") - .Sum(p => p.currentRequirement); - } - } - if (part.Modules.Contains("ModuleEnginesFX")) - { - var engine = part.Modules["ModuleEnginesFX"] as ModuleEnginesFX; - if (engine.isOperational) + PartModule partmod = part.Modules[i]; + var engine = partmod as ModuleEngines; + if (engine != null && engine.isOperational) { demand += engine.propellants .Where(p => p.name == "IntakeAir") --- a/KerbalEngineer/Flight/Readouts/Vessel/IntakeAirSupply.cs +++ b/KerbalEngineer/Flight/Readouts/Vessel/IntakeAirSupply.cs @@ -39,7 +39,7 @@ { this.Name = "Intake Air (Supply)"; this.Category = ReadoutCategory.GetCategory("Vessel"); - this.HelpString = string.Empty; + this.HelpString = "Displays the available Intake Air."; this.IsDefault = false; } --- a/KerbalEngineer/Flight/Readouts/Vessel/IntakeAirUsage.cs +++ b/KerbalEngineer/Flight/Readouts/Vessel/IntakeAirUsage.cs @@ -42,7 +42,7 @@ { this.Name = "Intake Air (Usage)"; this.Category = ReadoutCategory.GetCategory("Vessel"); - this.HelpString = string.Empty; + this.HelpString = "Displays the consumption of Intake Air."; this.IsDefault = true; } --- a/KerbalEngineer/Flight/Readouts/Vessel/Mass.cs +++ b/KerbalEngineer/Flight/Readouts/Vessel/Mass.cs @@ -28,19 +28,13 @@ { public class Mass : ReadoutModule { - #region Fields - - private bool showing; - - #endregion - #region Constructors public Mass() { this.Name = "Mass"; this.Category = ReadoutCategory.GetCategory("Vessel"); - this.HelpString = string.Empty; + this.HelpString = "Displays the total Mass of the Vessel."; this.IsDefault = true; } --- /dev/null +++ b/KerbalEngineer/Flight/Readouts/Vessel/Name.cs @@ -1,1 +1,55 @@ +// +// 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 . +// +#region Using Directives + +using KerbalEngineer.Flight.Sections; +using KerbalEngineer.Helpers; + +#endregion + +namespace KerbalEngineer.Flight.Readouts.Vessel +{ + public class Name : ReadoutModule + { + #region Constructors + + public Name() + { + Name = "Name"; + Category = ReadoutCategory.GetCategory("Vessel"); + HelpString = "Displays the name of the current vessel."; + IsDefault = true; + } + + #endregion + + #region Methods: public + + public override void Draw(SectionModule section) + { + if (SimulationProcessor.ShowDetails) + { + DrawLine(FlightGlobals.ActiveVessel.vesselName); + } + } + + #endregion + } +} --- a/KerbalEngineer/Flight/Readouts/Vessel/PartCount.cs +++ b/KerbalEngineer/Flight/Readouts/Vessel/PartCount.cs @@ -34,7 +34,7 @@ { this.Name = "Part Count"; this.Category = ReadoutCategory.GetCategory("Vessel"); - this.HelpString = string.Empty; + this.HelpString = "Shows the total number of Parts the current and next stage."; this.IsDefault = true; } --- a/KerbalEngineer/Flight/Readouts/Vessel/Pitch.cs +++ b/KerbalEngineer/Flight/Readouts/Vessel/Pitch.cs @@ -34,7 +34,7 @@ { this.Name = "Pitch"; this.Category = ReadoutCategory.GetCategory("Vessel"); - this.HelpString = string.Empty; + this.HelpString = "Shows the current Pitch angle."; this.IsDefault = false; } --- a/KerbalEngineer/Flight/Readouts/Vessel/PitchRate.cs +++ b/KerbalEngineer/Flight/Readouts/Vessel/PitchRate.cs @@ -34,7 +34,7 @@ { this.Name = "Pitch Rate"; this.Category = ReadoutCategory.GetCategory("Vessel"); - this.HelpString = string.Empty; + this.HelpString = "Shows the current Pitch speed."; this.IsDefault = false; } --- a/KerbalEngineer/Flight/Readouts/Vessel/Roll.cs +++ b/KerbalEngineer/Flight/Readouts/Vessel/Roll.cs @@ -34,7 +34,7 @@ { this.Name = "Roll"; this.Category = ReadoutCategory.GetCategory("Vessel"); - this.HelpString = string.Empty; + this.HelpString = "Shows the current Roll angle."; this.IsDefault = false; } --- a/KerbalEngineer/Flight/Readouts/Vessel/RollRate.cs +++ b/KerbalEngineer/Flight/Readouts/Vessel/RollRate.cs @@ -34,7 +34,7 @@ { this.Name = "Roll Rate"; this.Category = ReadoutCategory.GetCategory("Vessel"); - this.HelpString = string.Empty; + this.HelpString = "Shows the current Roll speed."; this.IsDefault = false; } --- a/KerbalEngineer/Flight/Readouts/Vessel/SpecificImpulse.cs +++ b/KerbalEngineer/Flight/Readouts/Vessel/SpecificImpulse.cs @@ -33,7 +33,7 @@ { this.Name = "Specific Impulse"; this.Category = ReadoutCategory.GetCategory("Vessel"); - this.HelpString = string.Empty; + this.HelpString = "Shows the average Specific Impulse of all engines in the current stage."; this.IsDefault = false; } --- a/KerbalEngineer/Flight/Readouts/Vessel/Thrust.cs +++ b/KerbalEngineer/Flight/Readouts/Vessel/Thrust.cs @@ -34,7 +34,7 @@ { this.Name = "Thrust"; this.Category = ReadoutCategory.GetCategory("Vessel"); - this.HelpString = string.Empty; + this.HelpString = "Shows the current and maximum thrust the vessel can put out."; this.IsDefault = true; } --- a/KerbalEngineer/Flight/Sections/SectionEditor.cs +++ b/KerbalEngineer/Flight/Sections/SectionEditor.cs @@ -215,15 +215,18 @@ this.ParentSection.Name = GUILayout.TextField(this.ParentSection.Name, this.textStyle); var isShowingInControlBar = !string.IsNullOrEmpty(this.ParentSection.Abbreviation); this.ParentSection.Abbreviation = GUILayout.TextField(this.ParentSection.Abbreviation, this.textStyle, GUILayout.Width(75.0f)); + + ParentSection.IsHud = GUILayout.Toggle(this.ParentSection.IsHud, "HUD", this.readoutButtonStyle, GUILayout.Width(50.0f)); + if (ParentSection.IsHud) + { + this.ParentSection.IsHudBackground = GUILayout.Toggle(this.ParentSection.IsHudBackground, "BG", this.readoutButtonStyle, GUILayout.Width(50.0f)); + } + if (this.ParentSection.IsCustom) { if (isShowingInControlBar && string.IsNullOrEmpty(this.ParentSection.Abbreviation)) { DisplayStack.Instance.RequestResize(); - } - if (this.ParentSection.IsHud = GUILayout.Toggle(this.ParentSection.IsHud, "HUD", this.readoutButtonStyle, GUILayout.Width(50.0f))) - { - this.ParentSection.IsHudBackground = GUILayout.Toggle(this.ParentSection.IsHudBackground, "BG", this.readoutButtonStyle, GUILayout.Width(50.0f)); } if (GUILayout.Button("DELETE SECTION", this.readoutButtonStyle, GUILayout.Width(150.0f))) --- a/KerbalEngineer/Flight/Sections/SectionLibrary.cs +++ b/KerbalEngineer/Flight/Sections/SectionLibrary.cs @@ -72,9 +72,10 @@ { Name = "THERMAL", Abbreviation = "HEAT", - ReadoutModules = ReadoutLibrary.GetCategory(ReadoutCategory.GetCategory("Thermal")).Where(r => r.IsDefault).ToList() - }); - + ReadoutModules = ReadoutLibrary.GetCategory(ReadoutCategory.GetCategory("Thermal")).Where(r => r.IsDefault).ToList(), + IsCustom = true + }); + SectionModule hud1 = new SectionModule { Name = "HUD 1", --- a/KerbalEngineer/Flight/Sections/SectionWindow.cs +++ b/KerbalEngineer/Flight/Sections/SectionWindow.cs @@ -134,7 +134,11 @@ (!this.ParentSection.IsHud || this.ParentSection.IsEditorVisible) ? this.windowStyle : this.ParentSection.IsHudBackground && this.ParentSection.LineCount > 0 ? this.hudWindowBgStyle - : this.hudWindowStyle).ClampToScreen(); + : this.hudWindowStyle); + + windowPosition = (ParentSection.IsHud) ? windowPosition.ClampInsideScreen() : windowPosition.ClampToScreen(); + + this.ParentSection.FloatingPositionX = this.windowPosition.x; this.ParentSection.FloatingPositionY = this.windowPosition.y; } --- a/KerbalEngineer/Helpers/TimeFormatter.cs +++ b/KerbalEngineer/Helpers/TimeFormatter.cs @@ -58,31 +58,23 @@ public static string ConvertToString(double seconds, string format = "F1") { var years = 0; - while (seconds >= SecondsPerYear) + var days = 0; + var hours = 0; + var minutes = 0; + + if (seconds > 0) { - years++; - seconds -= SecondsPerYear; - } + years = (int)(seconds / SecondsPerYear); + seconds -= years * SecondsPerYear; - var days = 0; - while (seconds >= SecondsPerDay) - { - days++; - seconds -= SecondsPerDay; - } + days = (int)(seconds / SecondsPerDay); + seconds -= days * SecondsPerDay; - var hours = 0; - while (seconds >= SecondsPerHour) - { - hours++; - seconds -= SecondsPerHour; - } + hours = (int)(seconds / SecondsPerHour); + seconds -= hours * SecondsPerHour; - var minutes = 0; - while (seconds >= SecondsPerMinute) - { - minutes++; - seconds -= SecondsPerMinute; + minutes = (int)(seconds / SecondsPerMinute); + seconds -= minutes * SecondsPerMinute; } if (years > 0) --- a/KerbalEngineer/Helpers/Units.cs +++ b/KerbalEngineer/Helpers/Units.cs @@ -205,7 +205,7 @@ public static string ToTorque(double value) { - return value.ToString((value < 100.0) ? (Math.Abs(value) < Double.Epsilon) ? "N0" : "N1" : "N0") + "kNm"; + return value.ToString((value < 100.0) ? (Math.Abs(value) < Double.Epsilon) ? "N0" : "N2" : "N0") + "kNm"; } } } --- a/KerbalEngineer/KerbalEngineer.csproj +++ b/KerbalEngineer/KerbalEngineer.csproj @@ -71,11 +71,21 @@ + + + + Code + + + + Code + + @@ -91,17 +101,21 @@ + - + + + + @@ -158,7 +172,6 @@ - @@ -218,6 +231,8 @@ + + --- a/KerbalEngineer/LogMsg.cs +++ b/KerbalEngineer/LogMsg.cs @@ -15,7 +15,8 @@ public void Flush() { - MonoBehaviour.print(this.buf); + if (this.buf.Length > 0) + MonoBehaviour.print(this.buf); this.buf.Length = 0; } } --- a/KerbalEngineer/Properties/AssemblyInfo.cs +++ b/KerbalEngineer/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // You can specify all the values or you can default the Build and Revision Numbers // by using the '*' as shown below: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion(KerbalEngineer.EngineerGlobals.AssemblyVersion)] +[assembly: AssemblyVersion(KerbalEngineer.EngineerGlobals.ASSEMBLY_VERSION)] --- a/KerbalEngineer/VesselSimulator/EngineSim.cs +++ b/KerbalEngineer/VesselSimulator/EngineSim.cs @@ -31,6 +31,7 @@ private static readonly Pool pool = new Pool(Create, Reset); private readonly ResourceContainer resourceConsumptions = new ResourceContainer(); + private readonly ResourceContainer resourceFlowModes = new ResourceContainer(); public double actualThrust = 0; public bool isActive = false; @@ -52,6 +53,7 @@ private static void Reset(EngineSim engineSim) { engineSim.resourceConsumptions.Reset(); + engineSim.resourceFlowModes.Reset(); engineSim.actualThrust = 0; engineSim.isActive = false; engineSim.isp = 0; @@ -98,51 +100,72 @@ engineSim.isActive = active; engineSim.thrustVec = vecThrust; engineSim.resourceConsumptions.Reset(); + engineSim.resourceFlowModes.Reset(); engineSim.appliedForces.Clear(); double flowRate = 0.0; if (engineSim.partSim.hasVessel) { + if (log != null) log.buf.AppendLine("hasVessel is true"); + float flowModifier = GetFlowModifier(atmChangeFlow, atmCurve, engineSim.partSim.part.atmDensity, velCurve, machNumber, ref engineSim.maxMach); 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; + if (log != null) + { + log.buf.AppendFormat("flowMod = {0:g6}\n", flowModifier); + log.buf.AppendFormat("isp = {0:g6}\n", engineSim.isp); + log.buf.AppendFormat("thrust = {0:g6}\n", engineSim.thrust); + log.buf.AppendFormat("actual = {0:g6}\n", engineSim.actualThrust); + } if (throttleLocked) { + if (log != null) log.buf.AppendLine("throttleLocked is true, using thrust for flowRate"); flowRate = GetFlowRate(engineSim.thrust, engineSim.isp); } else { if (currentThrottle > 0.0f && engineSim.partSim.isLanded == false) { + if (log != null) log.buf.AppendLine("throttled up and not landed, using actualThrust for flowRate"); flowRate = GetFlowRate(engineSim.actualThrust, engineSim.isp); } else { + if (log != null) log.buf.AppendLine("throttled down or landed, using thrust for flowRate"); flowRate = GetFlowRate(engineSim.thrust, engineSim.isp); } } } else { + if (log != null) log.buf.AppendLine("hasVessel is false"); float flowModifier = GetFlowModifier(atmChangeFlow, atmCurve, CelestialBodies.SelectedBody.GetDensity(BuildAdvanced.Altitude), velCurve, machNumber, ref engineSim.maxMach); engineSim.isp = atmosphereCurve.Evaluate((float)atmosphere); engineSim.thrust = GetThrust(Mathf.Lerp(minFuelFlow, maxFuelFlow, GetThrustPercent(thrustPercentage)) * flowModifier, engineSim.isp); + engineSim.actualThrust = 0d; + if (log != null) + { + log.buf.AppendFormat("flowMod = {0:g6}\n", flowModifier); + log.buf.AppendFormat("isp = {0:g6}\n", engineSim.isp); + log.buf.AppendFormat("thrust = {0:g6}\n", engineSim.thrust); + log.buf.AppendFormat("actual = {0:g6}\n", engineSim.actualThrust); + } + + if (log != null) log.buf.AppendLine("no vessel, using thrust for flowRate"); flowRate = GetFlowRate(engineSim.thrust, engineSim.isp); } if (log != null) log.buf.AppendFormat("flowRate = {0:g6}\n", flowRate); - - engineSim.thrust = flowRate * (engineSim.isp * IspG); - // I did not look into the diff between those 2 so I made them equal... - engineSim.actualThrust = engineSim.thrust; float flowMass = 0f; for (int i = 0; i < propellants.Count; ++i) { Propellant propellant = propellants[i]; - flowMass += propellant.ratio * ResourceContainer.GetResourceDensity(propellant.id); + if (!propellant.ignoreForIsp) + flowMass += propellant.ratio * ResourceContainer.GetResourceDensity(propellant.id); } if (log != null) log.buf.AppendFormat("flowMass = {0:g6}\n", flowMass); @@ -164,6 +187,7 @@ theEngine.partId, consumptionRate); engineSim.resourceConsumptions.Add(propellant.id, consumptionRate); + engineSim.resourceFlowModes.Add(propellant.id, (double)propellant.GetFlowMode()); } double thrustPerThrustTransform = engineSim.thrust / thrustTransforms.Count; @@ -249,14 +273,36 @@ HashSet visited = new HashSet(); + public void DumpSourcePartSets(String msg) + { + MonoBehaviour.print("DumpSourcePartSets " + msg); + foreach (int type in sourcePartSets.Keys) + { + MonoBehaviour.print("SourcePartSet for " + ResourceContainer.GetResourceName(type)); + HashSet sourcePartSet = sourcePartSets[type]; + if (sourcePartSet.Count > 0) + { + foreach (PartSim partSim in sourcePartSet) + { + MonoBehaviour.print("Part " + partSim.name + ":" + partSim.partId); + } + } + else + { + MonoBehaviour.print("No parts"); + } + } + } + public bool SetResourceDrains(List allParts, List allFuelLines, HashSet drainingParts) { LogMsg log = null; - + //DumpSourcePartSets("before clear"); foreach (HashSet sourcePartSet in sourcePartSets.Values) { sourcePartSet.Clear(); } + //DumpSourcePartSets("after clear"); for (int index = 0; index < this.resourceConsumptions.Types.Count; index++) { @@ -269,7 +315,7 @@ sourcePartSets.Add(type, sourcePartSet); } - switch (ResourceContainer.GetResourceFlowMode(type)) + switch ((ResourceFlowMode)this.resourceFlowModes[type]) { case ResourceFlowMode.NO_FLOW: if (partSim.resources[type] > SimManager.RESOURCE_MIN && partSim.resourceFlowStates[type] != 0) @@ -314,20 +360,27 @@ maxStage = stage; } - if (!stagePartSets.TryGetValue(stage, out sourcePartSet)) + HashSet tempPartSet; + if (!stagePartSets.TryGetValue(stage, out tempPartSet)) { - sourcePartSet = new HashSet(); - stagePartSets.Add(stage, sourcePartSet); + tempPartSet = new HashSet(); + stagePartSets.Add(stage, tempPartSet); } - sourcePartSet.Add(aPartSim); - } - - for (int j = 0; j <= maxStage; j++) + tempPartSet.Add(aPartSim); + } + + for (int j = maxStage; j >= 0; j--) { HashSet stagePartSet; if (stagePartSets.TryGetValue(j, out stagePartSet) && stagePartSet.Count > 0) { - sourcePartSet = stagePartSet; + // We have to copy the contents of the set here rather than copying the set reference or + // bad things (tm) happen + foreach (PartSim aPartSim in stagePartSet) + { + sourcePartSet.Add(aPartSim); + } + break; } } break; @@ -352,11 +405,9 @@ break; } - - if (sourcePartSet.Count > 0) - { - sourcePartSets[type] = sourcePartSet; - if (SimManager.logOutput) + if (SimManager.logOutput) + { + if (sourcePartSet.Count > 0) { log = new LogMsg(); log.buf.AppendLine("Source parts for " + ResourceContainer.GetResourceName(type) + ":"); @@ -367,6 +418,8 @@ MonoBehaviour.print(log.buf); } } + + //DumpSourcePartSets("after " + ResourceContainer.GetResourceName(type)); } // If we don't have sources for all the needed resources then return false without setting up any drains @@ -385,6 +438,7 @@ return false; } } + // Now we set the drains on the members of the sets and update the draining parts set for (int i = 0; i < this.resourceConsumptions.Types.Count; i++) { --- a/KerbalEngineer/VesselSimulator/PartSim.cs +++ b/KerbalEngineer/VesselSimulator/PartSim.cs @@ -38,12 +38,11 @@ public double baseMass; public double baseMassForCoM; public Vector3d centerOfMass; - public double cost; + public double baseCost; public int decoupledInStage; public bool fuelCrossFeed; public List fuelTargets = new List(); public bool hasModuleEngines; - public bool hasModuleEnginesFX; public bool hasMultiModeEngine; public bool hasVessel; @@ -57,8 +56,7 @@ public bool isNoPhysics; public bool isSepratron; public bool isFairing; - public bool localCorrectThrust; - public float moduleMass; + public float fairingMass; public int stageIndex; public String name; public String noCrossFeedNodeKey; @@ -90,6 +88,7 @@ partSim.resourceDrains.Reset(); partSim.resourceFlowStates.Reset(); partSim.resources.Reset(); + partSim.baseCost = 0d; partSim.baseMass = 0d; partSim.baseMassForCoM = 0d; partSim.startMass = 0d; @@ -119,10 +118,11 @@ partSim.isFuelLine = partSim.part.HasModule(); partSim.isFuelTank = partSim.part is FuelTank; partSim.isSepratron = partSim.IsSepratron(); + partSim.isFairing = partSim.IsFairing(partSim.part); partSim.inverseStage = partSim.part.inverseStage; //MonoBehaviour.print("inverseStage = " + inverseStage); - partSim.cost = partSim.part.GetCostWet(); + partSim.baseCost = partSim.part.GetCostDry(); if (log != null) { @@ -147,6 +147,11 @@ if (log != null) log.buf.AppendLine("Using part.mass of " + partSim.part.mass); } + if (partSim.isFairing) + { + partSim.fairingMass = partSim.part.GetModuleMass((float)partSim.realMass); + } + for (int i = 0; i < partSim.part.Resources.Count; i++) { PartResource resource = partSim.part.Resources[i]; @@ -177,10 +182,9 @@ partSim.initialVesselName = partSim.part.initialVesselName; partSim.hasMultiModeEngine = partSim.part.HasModule(); - partSim.hasModuleEnginesFX = partSim.part.HasModule(); partSim.hasModuleEngines = partSim.part.HasModule(); - partSim.isEngine = partSim.hasMultiModeEngine || partSim.hasModuleEnginesFX || partSim.hasModuleEngines; + partSim.isEngine = partSim.hasMultiModeEngine || partSim.hasModuleEngines; if (log != null) log.buf.AppendLine("Created " + partSim.name + ". Decoupled in stage " + partSim.decoupledInStage); @@ -205,7 +209,6 @@ public void CreateEngineSims(List allEngines, double atmosphere, double mach, bool vectoredThrust, bool fullThrust, LogMsg log) { - bool correctThrust = SimManager.DoesEngineUseCorrectedThrust(part); if (log != null) { log.buf.AppendLine("CreateEngineSims for " + this.name); @@ -214,20 +217,18 @@ PartModule partMod = this.part.Modules[i]; log.buf.AppendLine("Module: " + partMod.moduleName); } - - log.buf.AppendLine("correctThrust = " + correctThrust); } if (hasMultiModeEngine) { - // A multi-mode engine has multiple ModuleEnginesFX but only one is active at any point - // The mode of the engine is the engineID of the ModuleEnginesFX that is active + // A multi-mode engine has multiple ModuleEngines but only one is active at any point + // The mode of the engine is the engineID of the ModuleEngines that is active string mode = part.GetModule().mode; - List engines = part.GetModules(); + List engines = part.GetModules(); for (int i = 0; i < engines.Count; ++i) { - ModuleEnginesFX engine = engines[i]; + ModuleEngines engine = engines[i]; if (engine.engineID == mode) { if (log != null) log.buf.AppendLine("Module: " + engine.moduleName); @@ -258,40 +259,37 @@ } } } - else - { - if (hasModuleEngines) - { - List engines = part.GetModules(); - for (int i = 0; i < engines.Count; ++i) - { - ModuleEngines engine = engines[i]; - if (log != null) log.buf.AppendLine("Module: " + engine.moduleName); - - Vector3 thrustvec = this.CalculateThrustVector(vectoredThrust ? engine.thrustTransforms : null, log); - - EngineSim engineSim = EngineSim.New( - this, - atmosphere, - (float)mach, - engine.maxFuelFlow, - engine.minFuelFlow, - engine.thrustPercentage, - thrustvec, - engine.atmosphereCurve, - engine.atmChangeFlow, - engine.useAtmCurve ? engine.atmCurve : null, - engine.useVelCurve ? engine.velCurve : null, - engine.currentThrottle, - engine.g, - engine.throttleLocked || fullThrust, - engine.propellants, - engine.isOperational, - engine.resultingThrust, - engine.thrustTransforms, - log); - allEngines.Add(engineSim); - } + else if (hasModuleEngines) + { + List engines = part.GetModules(); + for (int i = 0; i < engines.Count; ++i) + { + ModuleEngines engine = engines[i]; + if (log != null) log.buf.AppendLine("Module: " + engine.moduleName); + + Vector3 thrustvec = this.CalculateThrustVector(vectoredThrust ? engine.thrustTransforms : null, log); + + EngineSim engineSim = EngineSim.New( + this, + atmosphere, + (float)mach, + engine.maxFuelFlow, + engine.minFuelFlow, + engine.thrustPercentage, + thrustvec, + engine.atmosphereCurve, + engine.atmChangeFlow, + engine.useAtmCurve ? engine.atmCurve : null, + engine.useVelCurve ? engine.velCurve : null, + engine.currentThrottle, + engine.g, + engine.throttleLocked || fullThrust, + engine.propellants, + engine.isOperational, + engine.resultingThrust, + engine.thrustTransforms, + log); + allEngines.Add(engineSim); } } @@ -408,6 +406,9 @@ public double GetMass(int currentStage, bool forCoM = false) { + if (decoupledInStage >= currentStage) + return 0d; + double mass = forCoM ? baseMassForCoM : baseMass; for (int i = 0; i < resources.Types.Count; ++i) @@ -415,14 +416,33 @@ mass += resources.GetResourceMass(resources.Types[i]); } - if (hasVessel == false && isFairing && inverseStage < currentStage) - { - mass = mass + moduleMass; + if (hasVessel == false && isFairing && currentStage > inverseStage) + { + mass += fairingMass; + } + else if (hasVessel && isFairing && currentStage <= inverseStage) + { + mass -= fairingMass; } return mass; } - + + public double GetCost(int currentStage) + { + if (decoupledInStage >= currentStage) + return 0d; + + double cost = baseCost; + + for (int i = 0; i < resources.Types.Count; ++i) + { + cost += resources.GetResourceCost(resources.Types[i]); + } + + return cost; + } + public void ReleasePart() { this.part = null; --- a/KerbalEngineer/VesselSimulator/ResourceContainer.cs +++ b/KerbalEngineer/VesselSimulator/ResourceContainer.cs @@ -150,6 +150,12 @@ return density == 0d ? 0d : this.resources[type] * density; } + public double GetResourceCost(int type) + { + double unitCost = GetResourceUnitCost(type); + return unitCost == 0d ? 0d : this.resources[type] * unitCost; + } + public static ResourceFlowMode GetResourceFlowMode(int type) { return PartResourceLibrary.Instance.GetDefinition(type).resourceFlowMode; @@ -157,7 +163,7 @@ public static ResourceTransferMode GetResourceTransferMode(int type) { - return PartResourceLibrary.Instance.GetDefinition(type).resourceTransferMode;; + return PartResourceLibrary.Instance.GetDefinition(type).resourceTransferMode; } public static float GetResourceDensity(int type) @@ -169,5 +175,10 @@ { return PartResourceLibrary.Instance.GetDefinition(type).name; } + + public static double GetResourceUnitCost(int type) + { + return PartResourceLibrary.Instance.GetDefinition(type).unitCost; + } } } --- a/KerbalEngineer/VesselSimulator/Simulation.cs +++ b/KerbalEngineer/VesselSimulator/Simulation.cs @@ -30,6 +30,7 @@ namespace KerbalEngineer.VesselSimulator { + using System.ComponentModel; using CompoundParts; using Extensions; using Helpers; @@ -75,7 +76,6 @@ public String vesselName; public VesselType vesselType; private WeightedVectorAverager vectorAverager = new WeightedVectorAverager(); - private static ModuleProceduralFairing moduleProceduralFairing; public Simulation() { @@ -139,6 +139,7 @@ log.buf.AppendLine("PrepareSimulation started"); dumpTree = true; } + this._timer.Reset(); this._timer.Start(); // Store the parameters in members for ease of access in other functions @@ -299,6 +300,7 @@ MonoBehaviour.print("RunSimulation started"); } + this._timer.Reset(); this._timer.Start(); LogMsg log = null; @@ -382,34 +384,34 @@ // Create the array of stages that will be returned Stage[] stages = new Stage[this.currentStage + 1]; + int startStage = currentStage; + // Loop through the stages while (this.currentStage >= 0) { if (log != null) { log.buf.AppendLine("Simulating stage " + this.currentStage); - log.buf.AppendLine("ShipMass = " + this.ShipMass); log.Flush(); this._timer.Reset(); this._timer.Start(); } + // Update active engines and resource drains + this.UpdateResourceDrains(); + // Update the masses of the parts to correctly handle "no physics" parts - this.UpdatePartMasses(); + this.stageStartMass = this.UpdatePartMasses(); if (log != null) this.allParts[0].DumpPartToBuffer(log.buf, "", this.allParts); - // Update active engines and resource drains - this.UpdateResourceDrains(); - // Create the Stage object for this stage Stage stage = new Stage(); this.stageTime = 0d; this.vecStageDeltaV = Vector3.zero; - this.stageStartMass = this.ShipMass; this.stageStartCom = this.ShipCom; this.stepStartMass = this.stageStartMass; @@ -448,22 +450,31 @@ stage.thrustOffsetAngle = Math.Asin(sinThrustOffsetAngle) * 180 / Math.PI; - // Calculate the cost and mass of this stage and add all engines and tanks that are decoupled - // in the next stage to the dontStageParts list + // Calculate the total cost of the vessel at this point + stage.totalCost = 0d; for (int i = 0; i < allParts.Count; ++i) { - PartSim partSim = allParts[i]; - - if (partSim.decoupledInStage == this.currentStage - 1) - { - stage.cost += partSim.cost; - stage.mass += partSim.GetStartMass(); - } - - if (partSim.hasVessel == false && partSim.isFairing && partSim.inverseStage == currentStage) - { - stage.mass += partSim.moduleMass; - } + if (this.currentStage > allParts[i].decoupledInStage) + stage.totalCost += allParts[i].GetCost(currentStage); + } + + // The total mass is simply the mass at the start of the stage + stage.totalMass = this.stageStartMass; + + // If we have done a previous stage + if (currentStage < startStage) + { + // Calculate what the previous stage's mass and cost were by subtraction + Stage prev = stages[currentStage + 1]; + prev.cost = prev.totalCost - stage.totalCost; + prev.mass = prev.totalMass - stage.totalMass; + } + + // The above code will never run for the last stage so set those directly + if (currentStage == 0) + { + stage.cost = stage.totalCost; + stage.mass = stage.totalMass; } this.dontStageParts = dontStagePartsLists[this.currentStage]; @@ -626,8 +637,6 @@ // For each stage we total up the cost, mass, deltaV and time for this stage and all the stages above for (int j = i; j >= 0; j--) { - stages[i].totalCost += stages[j].cost; - stages[i].totalMass += stages[j].mass; stages[i].totalDeltaV += stages[j].deltaV; stages[i].totalTime += stages[j].time; stages[i].partCount = i > 0 ? stages[i].totalPartCount - stages[i - 1].totalPartCount : stages[i].totalPartCount; @@ -656,7 +665,7 @@ return stages; } - public void UpdatePartMasses() + public double UpdatePartMasses() { for (int i = 0; i < this.allParts.Count; i++) { @@ -667,27 +676,39 @@ for (int i = 0; i < this.allParts.Count; i++) { PartSim part = this.allParts[i]; - // If the part has a parent - if (part.parent != null) - { - if (part.isNoPhysics) - { - if (part.parent.isNoPhysics && part.parent.parent != null) - { - part.baseMass = 0d; - part.baseMassForCoM = 0d; - } - else - { - part.parent.baseMassForCoM += part.baseMassForCoM; - part.baseMassForCoM = 0d; - } - } - } - } - + + // Check if part should pass it's mass onto its parent. + if (part.isNoPhysics && part.parent != null) + { + PartSim partParent = part.parent; + + // Loop through all parents until a physically significant parent is found. + while (partParent != null) + { + // Check if parent is physically significant. + if (partParent.isNoPhysics == false) + { + // Apply the mass to the parent and remove it from the originating part. + partParent.baseMassForCoM += part.baseMassForCoM; + part.baseMassForCoM = 0.0; + + // Break out of the recursive loop. + break; + } + + // Recursively loop through the parent parts. + partParent = partParent.parent; + } + } + } + + double totalMass = 0d; for (int i = 0; i < this.allParts.Count; i++) - this.allParts[i].startMass = this.allParts[i].GetMass(currentStage); + { + totalMass += this.allParts[i].startMass = this.allParts[i].GetMass(currentStage); + } + + return totalMass; } // Make sure we free them all, even if they should all be free already at this point --- a/Output/KerbalEngineer/KerbalEngineer.version +++ b/Output/KerbalEngineer/KerbalEngineer.version @@ -1,17 +1,18 @@ { - "NAME":"Kerbal Engineer Redux 1.0", + "NAME":"Kerbal Engineer Redux", "URL":"http://ksp-avc.cybutek.net/version.php?id=6", "VERSION": { "MAJOR":1, "MINOR":0, - "PATCH":16, - "BUILD":6 + "PATCH":18, + "BUILD":0 }, "KSP_VERSION": { "MAJOR":1, "MINOR":0, - "PATCH":2 + "PATCH":4 } } +