Merge pull request #59 from itwtx/master
Merge pull request #59 from itwtx/master

Optimized time formatting

  1.0.18.1
  Changed: The 'Torque' value in the editor is now precise to two decimal places.
   
1.0.18.0 1.0.18.0
Added: Orbital readouts - "Speed at Periapsis" and "Speed at Apoapsis". (Padishar) Added: Orbital readouts - "Speed at Periapsis" and "Speed at Apoapsis". (Padishar)
Added: Manoeuvre readouts - "Post-burn Apoapsis" and "Post-burn Periapsis". (Padishar) Added: Manoeuvre readouts - "Post-burn Apoapsis" and "Post-burn Periapsis". (Padishar)
Added: Orbital readout - "Time to Atmosphere". Added: Orbital readout - "Time to Atmosphere".
Fixed: Synched the minimum simulation time sliders and stopped them from snapping back after 999ms. (saybur) 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: 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: Physically insignificant part mass was not being correctly cascaded down through multiple parent parts.
Fixed: Intake air demand calculation not working. Fixed: Intake air demand calculation not working.
Fixed: Some build engineer settings labels do not scale with UI size. Fixed: Some build engineer settings labels do not scale with UI size.
   
1.0.17.0 1.0.17.0
Added: 'Mach Number' readout under the 'Surface' category and included it on the default surface HUD. 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: Stock sections in the Flight Engineer can now become HUDs.
Added 'Thermal' readouts category including: Added 'Thermal' readouts category including:
Internal Flux Internal Flux
Convection Flux Convection Flux
Radiation Flux Radiation Flux
Critical Part Name Critical Part Name
Critical Part Temperature Critical Part Temperature
Critical Part Skin Temperature Critical Part Skin Temperature
Critical Part Thermal Percentage of Max Temperature Critical Part Thermal Percentage of Max Temperature
Hottest Part Name Hottest Part Name
Hottest Part Temperature Hottest Part Temperature
Hottest Part Skin Temperature Hottest Part Skin Temperature
Coldest Part Name Coldest Part Name
Coldest Part Temperature Coldest Part Temperature
Coldest Part Skin Temperature Coldest Part Skin Temperature
   
Changed: Mach on the Build Engineer now accurate to 2 decimal places. 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: 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: Increased eccentricity readout to 5 decimal places.
Changed: Implemented Sarbian's object pooling. Changed: Implemented Sarbian's object pooling.
Changed: The default selected body is now assigned via 'Planitarium.Home'. 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. 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: 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: Longitude and Latitude readouts now use a KER formatter instead of Squad's incorrect implementation.
Fixed: Possible null reference in the Rendezvous Processor. Fixed: Possible null reference in the Rendezvous Processor.
Fixed: Fairing mass issues introduced with regards to simulation changes. Fixed: Fairing mass issues introduced with regards to simulation changes.
Fixed: Use of per-propellant fuel flow mode override. Fixed: Use of per-propellant fuel flow mode override.
Fixed: Burn times calculated for jet engines. Fixed: Burn times calculated for jet engines.
Fixed: Thrust issues introduced with Sarbian's simulation alterations. 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. 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 1.0.16.6, 02-05-15
Fixed: Separately staged fairing mass jettisons are now calculated in the editor. Fixed: Separately staged fairing mass jettisons are now calculated in the editor.
   
1.0.16.5, 02-05-2015 1.0.16.5, 02-05-2015
Fixed: Delta-V not being correctly calculated. Fixed: Delta-V not being correctly calculated.
Changed: Editor locking now uses the InputLockManager. Changed: Editor locking now uses the InputLockManager.
   
1.0.16.4, 01-05-2015 1.0.16.4, 01-05-2015
Fixed: Physically insignificant part mass is now accounted for. Fixed: Physically insignificant part mass is now accounted for.
Changed: Module mass accounted for as it now makes its way onto the launch pad (e.g. fairings). Changed: Module mass accounted for as it now makes its way onto the launch pad (e.g. fairings).
   
Various optimisations: Various optimisations:
Object pooling. Object pooling.
Removed LINQ expressions. Removed LINQ expressions.
Converted foreach to for loops. Converted foreach to for loops.
   
1.0.16.3, 27-04-2015 1.0.16.3, 27-04-2015
Fixed issue with the toolbar icons not being created. Fixed issue with the toolbar icons not being created.
Removed superfluous 'm/s' on the mach slider in the build engineer. Removed superfluous 'm/s' on the mach slider in the build engineer.
   
1.0.16.2, 27-04-2015 1.0.16.2, 27-04-2015
Changed the atmospheric slider on the build engineer to default to 0km when changing bodies. Changed the atmospheric slider on the build engineer to default to 0km when changing bodies.
   
1.0.16.1, 26-04-2015, KSP Build #828 1.0.16.1, 26-04-2015, KSP Build #828
Merged Sarbian's mach adjustments. Merged Sarbian's mach adjustments.
Fixed bugs relating to thrust and atmosphere/velocity curves. Fixed bugs relating to thrust and atmosphere/velocity curves.
Changed the atmospheric slider on the Build Engineer to work based on altitude. Changed the atmospheric slider on the Build Engineer to work based on altitude.
Changed the atmospheric slider to clamp to the maximum altitude for the selected body. Changed the atmospheric slider to clamp to the maximum altitude for the selected body.
Changed the velocity slider to clamp to the maximum usable mach value for the current vessel. Changed the velocity slider to clamp to the maximum usable mach value for the current vessel.
   
1.0.16.0, 25-04-2015, KSP Build #821 1.0.16.0, 25-04-2015, KSP Build #821
Fixed errors relating to KSP 1.0 update. Fixed errors relating to KSP 1.0 update.
Fixed fuel simulation to account for new thrust system. Fixed fuel simulation to account for new thrust system.
Fixed atmospheric engines to use the new velocity curve. Fixed atmospheric engines to use the new velocity curve.
Fixed atmospheric readouts to work with the new atmospheric model. Fixed atmospheric readouts to work with the new atmospheric model.
   
1.0.15.2, 13-02-2015 1.0.15.2, 13-02-2015
Padishar's Fixes: Padishar's Fixes:
Fixed: Calculation of per-stage resource mass. Fixed: Calculation of per-stage resource mass.
   
1.0.15.1, 13-02-2015 1.0.15.1, 13-02-2015
Rebuild Rebuild
   
1.0.15.0, 08-02-2015 1.0.15.0, 08-02-2015
Padishar's Fixes: Padishar's Fixes:
Added: Support KIDS ISP thrust correction. Added: Support KIDS ISP thrust correction.
Fixed: Log spam for stage priority mode. Fixed: Log spam for stage priority mode.
Fixed: Locked tanks preventing simulation from staging. Fixed: Locked tanks preventing simulation from staging.
Fixed: No flow and all vessel modes to respect flow states. Fixed: No flow and all vessel modes to respect flow states.
   
1.0.14.1, 28-12-2014 1.0.14.1, 28-12-2014
Fixed: Missing texture on the ER-7500 model. Fixed: Missing texture on the ER-7500 model.
   
1.0.14.0, 28-12-2014 1.0.14.0, 28-12-2014
Added: Career mode that limits the Flight Engineer by: 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. - Requiring an Engineer Kerbal of any level, or placement of an Engineer Chip or ER-7500 part.
- Tracking station level 3 enables Flight Engineer everywhere. - Tracking station level 3 enables Flight Engineer everywhere.
   
Added: New readouts to the orbital category: Added: New readouts to the orbital category:
- Mean Anomaly at Epoc - Mean Anomaly at Epoc
   
Added: New readouts to the miscellaneous category: Added: New readouts to the miscellaneous category:
- System Time - System Time
   
Added: Editor Overlay Tab's X position is now changable in the BuildOverlay.xml settings file. Added: Editor Overlay Tab's X position is now changable in the BuildOverlay.xml settings file.
Changed: Editor Overlay Tabs start position moved over as to not overlap the parts menu. Changed: Editor Overlay Tabs start position moved over as to not overlap the parts menu.
Fixed: Bug where STAGE_PRIORITY_FLOW resources would not be corrently disabled/enabled. Fixed: Bug where STAGE_PRIORITY_FLOW resources would not be corrently disabled/enabled.
Fixed: Issue with the formatting large Mass and Cost values. Fixed: Issue with the formatting large Mass and Cost values.
Fixed: Error when loading the Engineer7500 part model. Fixed: Error when loading the Engineer7500 part model.
   
1.0.13.1, 16-12-2014 1.0.13.1, 16-12-2014
Fixed: Issue with manoeuvre node readouts and low tier tracking station. Fixed: Issue with manoeuvre node readouts and low tier tracking station.
   
1.0.13.0, 16-12-2014 1.0.13.0, 16-12-2014
Updated for KSP version 0.90 Updated for KSP version 0.90
   
Added: New readouts to the vessel category: Added: New readouts to the vessel category:
- Heading Rate - Heading Rate
- Pitch Rate - Pitch Rate
- Roll Rate - Roll Rate
   
Changed: Simulation to look for fuel lines that use CModuleFuelLine module. Changed: Simulation to look for fuel lines that use CModuleFuelLine module.
Fixed: Editor Overlay now loads the saved visibility value properly. Fixed: Editor Overlay now loads the saved visibility value properly.
Fixed: Altitude (Terrain) will no longer give a reading below sea level. Fixed: Altitude (Terrain) will no longer give a reading below sea level.
Fixed: Suicide burn now uses radar altitude that clamps to sea level. Fixed: Suicide burn now uses radar altitude that clamps to sea level.
   
1.0.12.0, 01-12-2014 1.0.12.0, 01-12-2014
Added: Setting in Build Engineer to enable/disable vectored thrust calculations. Added: Setting in Build Engineer to enable/disable vectored thrust calculations.
Added: Thrust torque field in Build Engineer (courtesy of mic_e). Added: Thrust torque field in Build Engineer (courtesy of mic_e).
Added: New readouts to the vessel category: Added: New readouts to the vessel category:
- Thrust Offset Angle (courtesy of mic_e) - Thrust Offset Angle (courtesy of mic_e)
- Thrust Torque (courtesy of mic_e) - Thrust Torque (courtesy of mic_e)
- Part Count: stage/total - Part Count: stage/total
- Heading - Heading
- Pitch - Pitch
- Roll - Roll
   
Added: New readouts to the surface category: Added: New readouts to the surface category:
- Situation - Situation
   
Added: New readouts to the miscellaneous category: Added: New readouts to the miscellaneous category:
- Vectored Thrust Toggle - Vectored Thrust Toggle
   
Fixed: The category selection within the section editors now do not always reset back to 'Orbital'. Fixed: The category selection within the section editors now do not always reset back to 'Orbital'.
Fixed: Issue where the vessel simulation can sometimes permanently freeze. Fixed: Issue where the vessel simulation can sometimes permanently freeze.
Fixed: Issue where the vessel simulation would not show updates when the delay was set lower than the frame rate. Fixed: Issue where the vessel simulation would not show updates when the delay was set lower than the frame rate.
   
1.0.11.3, 11-11-2014 1.0.11.3, 11-11-2014
Changed: Gravity measurements for Isp to 9.82. Changed: Gravity measurements for Isp to 9.82.
   
1.0.11.2, 10-11-2014 1.0.11.2, 10-11-2014
Changed: Gravity measurements for Isp calculations from 9.81 to 9.8066 for accuracy. Changed: Gravity measurements for Isp calculations from 9.81 to 9.8066 for accuracy.
Changed: Manoeuvre node burn times are now more accurate. Changed: Manoeuvre node burn times are now more accurate.
Fixed: Bug in the manoeuvre node burn time calculations where it was not averaging acceleration correctly. Fixed: Bug in the manoeuvre node burn time calculations where it was not averaging acceleration correctly.
   
1.0.11.1, 07-11-2014 1.0.11.1, 07-11-2014
Changed: Build Engineer now shows stage part count as well as total. Changed: Build Engineer now shows stage part count as well as total.
Changed: Build Overlay Vessel tab data: Changed: Build Overlay Vessel tab data:
DeltaV: stage / total DeltaV: stage / total
Mass: stage / total Mass: stage / total
TWR: start (max) <- shows for bottom stage only. TWR: start (max) <- shows for bottom stage only.
Parts: stage / total Parts: stage / total
   
Fixed: Issue with the vessel tab vanishing from the editor. Fixed: Issue with the vessel tab vanishing from the editor.
   
1.0.11.0, 06-11-2014 1.0.11.0, 06-11-2014
Added: New readouts to the orbital category: Added: New readouts to the orbital category:
- Current SOI - Current SOI
- Manoeuvre Node DeltaV (Prograde) - Manoeuvre Node DeltaV (Prograde)
- Manoeuvre Node DeltaV (Normal) - Manoeuvre Node DeltaV (Normal)
- Manoeuvre Node DeltaV (Radial) - Manoeuvre Node DeltaV (Radial)
- Manoeuvre Node DeltaV (Total) - Manoeuvre Node DeltaV (Total)
- Manoeuvre Node Burn Time - Manoeuvre Node Burn Time
- Manoeuvre Node Half Burn Time - Manoeuvre Node Half Burn Time
- Manoeuvre Node Angle to Prograde - Manoeuvre Node Angle to Prograde
- Manoeuvre Node Angle to Retrograde - Manoeuvre Node Angle to Retrograde
- Time to Manoeuvre Node - Time to Manoeuvre Node
- Time to Manoeuvre Burn - Time to Manoeuvre Burn
   
Added: Readout help strings by ClassyJakey. Added: Readout help strings by ClassyJakey.
   
Fixed: Issue with separators in HUDs. Fixed: Issue with separators in HUDs.
Fixed: Issue with HUDs with backgrounds that have no displayed lines. Fixed: Issue with HUDs with backgrounds that have no displayed lines.
   
Padishar's Fixes: Padishar's Fixes:
Fixed: Issue with multicouplers when attached to parent by bottom node. Fixed: Issue with multicouplers when attached to parent by bottom node.
Fixed: Issue with sepratrons on solid rocket boosters. Fixed: Issue with sepratrons on solid rocket boosters.
   
1.0.10.0, 19-10-2014 1.0.10.0, 19-10-2014
UPDATE NOTICE: If you are updating from a previous version of Kerbal Engineer 1.0, please UPDATE NOTICE: If you are updating from a previous version of Kerbal Engineer 1.0, please
delete the 'Settings/SectionLibrary.xml' file, or remove the old install first. This will delete the 'Settings/SectionLibrary.xml' file, or remove the old install first. This will
reset the Flight Engineer sections to their default values and enable the new HUD functionality. reset the Flight Engineer sections to their default values and enable the new HUD functionality.
   
Added: New reaouts to the vessel category: Added: New reaouts to the vessel category:
- Suicide Burn Altitude (height above terrain to start burn) - Suicide Burn Altitude (height above terrain to start burn)
- Suicide Burn Distance (distance to suicide burn altitude) - Suicide Burn Distance (distance to suicide burn altitude)
- Suicide Burn DeltaV (velocity change required to zero vertical speed) - Suicide Burn DeltaV (velocity change required to zero vertical speed)
*** F5 for safety and use at your own risk! *** *** F5 for safety and use at your own risk! ***
   
Added: HUD type sections to the Flight Engineer. Added: HUD type sections to the Flight Engineer.
Added: HUD sections can have a smoked background for easy visibility. Added: HUD sections can have a smoked background for easy visibility.
Added: 'Switch to Target' button on the Target Selector readout. Added: 'Switch to Target' button on the Target Selector readout.
Changed: The default installed readouts to reduce new user brain melt. Changed: The default installed readouts to reduce new user brain melt.
Fixed: Flight Engineer not saving its hidden state. Fixed: Flight Engineer not saving its hidden state.
Fixed: Bug in the phase angle calculations. Fixed: Bug in the phase angle calculations.
Fixed: Bug where the Build Engineer would stay locked after hiding with the shortcut key. Fixed: Bug where the Build Engineer would stay locked after hiding with the shortcut key.
   
1.0.9.3, 08-10-2014 1.0.9.3, 08-10-2014
Added: Title of the build engineer in compact mode now shows if you are using atmospheric data. Added: Title of the build engineer in compact mode now shows if you are using atmospheric data.
Added: New readout to the surface category: Added: New readout to the surface category:
- Vertical Acceleration - Vertical Acceleration
- Horizontal Acceleration - Horizontal Acceleration
   
Changed: Atmospheric efficiency readout now shows as a percentage. Changed: Atmospheric efficiency readout now shows as a percentage.
Changed: Atmospheric settings (pressure/velocity) in the editor condensed onto a single line. 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. Fixed: Bug where the overlays in the editor would stay open outside of parts screen.
   
1.0.9.2, 07-10-2014 1.0.9.2, 07-10-2014
Updated for KSP v0.25.0 Updated for KSP v0.25.0
Changed: Prettyfied Latitude and Longitude readouts. Changed: Prettyfied Latitude and Longitude readouts.
Changed: ModuleLandingGear now uses the physical significance flag. Changed: ModuleLandingGear now uses the physical significance flag.
Changed: Updated MiniAVC to 1.0.2.4. Changed: Updated MiniAVC to 1.0.2.4.
   
1.0.9.1, 17-09-2014 1.0.9.1, 17-09-2014
Fixed: Part size bug caused by TweakScale's cost calculator. Fixed: Part size bug caused by TweakScale's cost calculator.
   
1.0.9.0, 15-09-2014 1.0.9.0, 15-09-2014
Added: Build Engineer now also implements the '\' backslash show/hide shortcut. Added: Build Engineer now also implements the '\' backslash show/hide shortcut.
Added: New readouts to the vessel category: Added: New readouts to the vessel category:
- Current Stage DeltaV - Current Stage DeltaV
- Surface Thrust to Weight Ratio - Surface Thrust to Weight Ratio
   
Added: New editor overlay system. Added: New editor overlay system.
- Sleeker design. - Sleeker design.
- Hover over part information options: - Hover over part information options:
- Name only - Name only
- Middle click to show - Middle click to show
- Always show - Always show
- Slide out overlay displays: - Slide out overlay displays:
- Vessel information - Vessel information
- Resources list - Resources list
   
Fixed: Cost calculation now works with mods implementing IPartCostModifier. Fixed: Cost calculation now works with mods implementing IPartCostModifier.
   
1.0.8.1, 06-09-2014 1.0.8.1, 06-09-2014
Fixed: Bug which caused rendezvous readouts to freeze the game or show all zeros. Fixed: Bug which caused rendezvous readouts to freeze the game or show all zeros.
   
1.0.8.0, 06-09-2014 1.0.8.0, 06-09-2014
Added: New readouts to the vessel category: Added: New readouts to the vessel category:
- Intake Air (Usage) - Intake Air (Usage)
   
Added: New readouts to the rendezvous category: Added: New readouts to the rendezvous category:
- Relative Velocity - Relative Velocity
- Relative Speed - Relative Speed
   
Fixed: An issue where deltaV would not be calculated whilst flying. Fixed: An issue where deltaV would not be calculated whilst flying.
Fixed: NullRef whilst loading the in flight Action Menu. Fixed: NullRef whilst loading the in flight Action Menu.
   
1.0.7.1, 02-09-2014 1.0.7.1, 02-09-2014
Changed: Reversed Intake Air readout from 'S/D' to 'D/S' for easier reading. Changed: Reversed Intake Air readout from 'S/D' to 'D/S' for easier reading.
Changed: Increased Intake Air readout precision to 4 decimal places. Changed: Increased Intake Air readout precision to 4 decimal places.
Fixed: Issue where Intake Air supply was not representative of total supply. Fixed: Issue where Intake Air supply was not representative of total supply.
Fixed: Bug where actual thrust does not reset to zero on deactivated engines. Fixed: Bug where actual thrust does not reset to zero on deactivated engines.
Fixed: Thrust now scales with velocity for atmospheric engines. (Padishar's fix) Fixed: Thrust now scales with velocity for atmospheric engines. (Padishar's fix)
   
1.0.7.0, 01-09-2014 1.0.7.0, 01-09-2014
Added: Part count information to the Build Engineer. Added: Part count information to the Build Engineer.
Added: Reset button to the G-Force readout. Added: Reset button to the G-Force readout.
Added: Preset system to the Flight Engineer. Added: Preset system to the Flight Engineer.
Added: New stock presets: Added: New stock presets:
- Orbital - Orbital
- Surface - Surface
- Vessel - Vessel
- Rendezvous - Rendezvous
   
Added: New readouts to the orbital category: Added: New readouts to the orbital category:
- True Anomaly - True Anomaly
- Eccentric Anomaly - Eccentric Anomaly
- Mean Anomaly - Mean Anomaly
- Argument of Periapsis - Argument of Periapsis
- Angle to Prograde - Angle to Prograde
- Angle to Retrograde - Angle to Retrograde
   
Added: New readouts to the vessel category: Added: New readouts to the vessel category:
- Intake Air (Demand) - Intake Air (Demand)
- Intake Air (Supply) - Intake Air (Supply)
- Intake Air (Supply/Demand) - Intake Air (Supply/Demand)
   
Added: New readouts to the rendezvous category. Added: New readouts to the rendezvous category.
- Semi-major Axis - Semi-major Axis
- Semi-minor Axis - Semi-minor Axis
   
Added: Time formatter which can show time as referenced by any celestial body. Added: Time formatter which can show time as referenced by any celestial body.
Added: New readouts to the miscellaneous category: Added: New readouts to the miscellaneous category:
- Time Reference Adjuster - Time Reference Adjuster
   
Changed: Moved Sim Delay readout into the Miscellaneous category. Changed: Moved Sim Delay readout into the Miscellaneous category.
Changed: Updated MiniAVC to v1.0.2.3. Changed: Updated MiniAVC to v1.0.2.3.
Fixed: Issues with large value wrap around in the Flight Engineer. Fixed: Issues with large value wrap around in the Flight Engineer.
Fixed: Bug in the phase angle calculation. Fixed: Bug in the phase angle calculation.
   
1.0.6.0, 23-08-2014 1.0.6.0, 23-08-2014
Added: Time and Angle to equatorial ascending/descending nodes in the orbital display. Added: Time and Angle to equatorial ascending/descending nodes in the orbital display.
Added: Time and Angle to relative ascending/descending nodes in the rendezvous display. Added: Time and Angle to relative ascending/descending nodes in the rendezvous display.
Added: Overlay tooltip information delay adjustment slider to the Build Engineer settings. Added: Overlay tooltip information delay adjustment slider to the Build Engineer settings.
Added: Ability to rename the stock displays in the Flight Engineer. Added: Ability to rename the stock displays in the Flight Engineer.
Changed: Build Engineer is now hidden when not in parts view. Changed: Build Engineer is now hidden when not in parts view.
Changed: Custom display panels will only show in the control bar if an abbreviation is set. Changed: Custom display panels will only show in the control bar if an abbreviation is set.
Changed: Licensing and readme structures are now more verbose to satisfy the new add-on rules. Changed: Licensing and readme structures are now more verbose to satisfy the new add-on rules.
Fixed: Updated MiniAVC to v1.0.2.1 (fixes remote check bug as well as other minor bugs). Fixed: Updated MiniAVC to v1.0.2.1 (fixes remote check bug as well as other minor bugs).
   
1.0.5.0, 13-08-2014 1.0.5.0, 13-08-2014
Added: Acceleration readout to the Vessel category (current / maximum). Added: Acceleration readout to the Vessel category (current / maximum).
Added: Category library system for the Flight Engineer readouts. Added: Category library system for the Flight Engineer readouts.
Added: Drop-down category selection to better support the new system. Added: Drop-down category selection to better support the new system.
Changed: Misc category now called Miscellaneous (this will cause previously added readouts from this category to vanish). Changed: Misc category now called Miscellaneous (this will cause previously added readouts from this category to vanish).
Fixed: Bug with the Build Engineer toolbar button. Fixed: Bug with the Build Engineer toolbar button.
Fixed: Some buggyness when trying to close the bodies drop-down in the Build Engineer via the button. Fixed: Some buggyness when trying to close the bodies drop-down in the Build Engineer via the button.
Fixed: Flight Engineer toolbar menu now hides when hiding the GUI with F2. Fixed: Flight Engineer toolbar menu now hides when hiding the GUI with F2.
Fixed: Flight Engineer toolbar button now disables when in module mode and no engineer is running. Fixed: Flight Engineer toolbar button now disables when in module mode and no engineer is running.
   
1.0.4.0, 12-08-2014 1.0.4.0, 12-08-2014
Added: Better stock toolbar support in the flight engineer. Added: Better stock toolbar support in the flight engineer.
Added: Dynamically generated celestial body library for supporting add-ons that modify the star system. Added: Dynamically generated celestial body library for supporting add-ons that modify the star system.
Changed: Reference bodies are now listed with a nestable menu system. Changed: Reference bodies are now listed with a nestable menu system.
Changed: Extended logging system has been improved. Changed: Extended logging system has been improved.
Changed: Swapped out integrated MiniAVC in place of the official bundle version. Changed: Swapped out integrated MiniAVC in place of the official bundle version.
Changed: Increased general distance precision to 1 decimal place. Changed: Increased general distance precision to 1 decimal place.
Changed: Increased Semi-major/minor axis precision to 3 decimal places. Changed: Increased Semi-major/minor axis precision to 3 decimal places.
Fixed: Impact altitude was mistakenly formatted as an angle, it is now formatted correctly as a distance. Fixed: Impact altitude was mistakenly formatted as an angle, it is now formatted correctly as a distance.
   
1.0.3.0, 30-07-2014 1.0.3.0, 30-07-2014
Added: Integrated KSP-AVC support with MiniAVC. Added: Integrated KSP-AVC support with MiniAVC.
Added: Setting to change the simulation delay in the Build Engineer. Added: Setting to change the simulation delay in the Build Engineer.
Added: Setting to enable and disable the build overlay system. Added: Setting to enable and disable the build overlay system.
Added: Burn time to Delta-V readouts. Added: Burn time to Delta-V readouts.
Added: Atmospheric readouts fully support FAR. Added: Atmospheric readouts fully support FAR.
Added: Atmospheric readouts are disabled with NEAR. Added: Atmospheric readouts are disabled with NEAR.
Changed: Force formatting inversely scales decimal precision with value. Changed: Force formatting inversely scales decimal precision with value.
Fixed: Flickering in VAB and Vessel display. Fixed: Flickering in VAB and Vessel display.
Fixed: Bug saving the GUI display size. Fixed: Bug saving the GUI display size.
   
1.0.2.0, 27-07-2014 1.0.2.0, 27-07-2014
Added: Separator readout module under Misc in the Flight Engineer. Added: Separator readout module under Misc in the Flight Engineer.
Added: Adjustable GUI display size. Added: Adjustable GUI display size.
Added: Display size can be adjusted in the Build Engineer settings. Added: Display size can be adjusted in the Build Engineer settings.
Added: Misc readout for adjusting display size in the Flight Engineer. Added: Misc readout for adjusting display size in the Flight Engineer.
Changed: The rendezvous readout for the target's Orbital Period has higher precision. Changed: The rendezvous readout for the target's Orbital Period has higher precision.
Fixed: White toolbar icon by manually importing the texture if it cannot be found in the game database. Fixed: White toolbar icon by manually importing the texture if it cannot be found in the game database.
Fixed: Engines that have a minimum thrust are now calculated properly. (Thanks to nosscire.) Fixed: Engines that have a minimum thrust are now calculated properly. (Thanks to nosscire.)
Fixed: Compact collapse mode is now saved in the Build Engineer. Fixed: Compact collapse mode is now saved in the Build Engineer.
   
1.0.1.0, 26-07-2014 1.0.1.0, 26-07-2014
Added: Part-less Flight Engineer. Added: Part-less Flight Engineer.
Added: Ability to collapse the Build Engineer into compact mode from left or right. Added: Ability to collapse the Build Engineer into compact mode from left or right.
Added: Settings in Build Engineer for compact collapse mode and partless/module Flight Engineer. Added: Settings in Build Engineer for compact collapse mode and partless/module Flight Engineer.
Added: Biome, Impact Biome and Slope readouts. Added: Biome, Impact Biome and Slope readouts.
Added: Extra logging and exception handling. Added: Extra logging and exception handling.
Added: The original Engineer Chip part. Added: The original Engineer Chip part.
Added: "Show Engineer" toggle on the Flight Engineer toolbar. Added: "Show Engineer" toggle on the Flight Engineer toolbar.
Changed: Extended logging system now also writes to the standard KSP logs. Changed: Extended logging system now also writes to the standard KSP logs.
Changed: Extended logging saves next to the .dll file. Changed: Extended logging saves next to the .dll file.
Changed: ER7500 part has no physical significance. Changed: ER7500 part has no physical significance.
Fixed: ActionMenu and DisplayStack destruction bug. Fixed: ActionMenu and DisplayStack destruction bug.
   
1.0.0.1, 24-07-2014 1.0.0.1, 24-07-2014
Added: Stock toolbar support in the Flight Engineer. Added: Stock toolbar support in the Flight Engineer.
Changed: Orbital Period has higher precision. Changed: Orbital Period has higher precision.
Fixed: Various NullRefs in editor window and overlay. Fixed: Various NullRefs in editor window and overlay.
   
1.0.0.0, 24-07-2014 1.0.0.0, 24-07-2014
Initial release for public testing. Initial release for public testing.
   
// //
// Copyright (C) 2015 CYBUTEK // Copyright (C) 2015 CYBUTEK
// //
// This program is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// //
   
namespace KerbalEngineer namespace KerbalEngineer
{ {
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
   
public static class EngineerGlobals public static class EngineerGlobals
{ {
/// <summary> /// <summary>
/// Current version of the Kerbal Engineer assembly. /// Current version of the Kerbal Engineer assembly.
/// </summary> /// </summary>
public const string ASSEMBLY_VERSION = "1.0.18.0"; public const string ASSEMBLY_VERSION = "1.0.18.1";
   
private static string assemblyFile; private static string assemblyFile;
private static string assemblyName; private static string assemblyName;
private static string assemblyPath; private static string assemblyPath;
   
/// <summary> /// <summary>
/// Gets the Kerbal Engineer assembly's path including the file name. /// Gets the Kerbal Engineer assembly's path including the file name.
/// </summary> /// </summary>
public static string AssemblyFile public static string AssemblyFile
{ {
get get
{ {
return assemblyFile ?? (assemblyFile = Assembly.GetExecutingAssembly().Location); return assemblyFile ?? (assemblyFile = Assembly.GetExecutingAssembly().Location);
} }
} }
   
/// <summary> /// <summary>
/// Gets the Kerbal Engineer assembly's file name. /// Gets the Kerbal Engineer assembly's file name.
/// </summary> /// </summary>
public static string AssemblyName public static string AssemblyName
{ {
get get
{ {
return assemblyName ?? (assemblyName = new FileInfo(AssemblyFile).Name); return assemblyName ?? (assemblyName = new FileInfo(AssemblyFile).Name);
} }
} }
   
/// <summary> /// <summary>
/// Gets the Kerbal Engineer assembly's path excluding the file name. /// Gets the Kerbal Engineer assembly's path excluding the file name.
/// </summary> /// </summary>
public static string AssemblyPath public static string AssemblyPath
{ {
get get
{ {
return assemblyPath ?? (assemblyPath = AssemblyFile.Replace(new FileInfo(AssemblyFile).Name, "")); return assemblyPath ?? (assemblyPath = AssemblyFile.Replace(new FileInfo(AssemblyFile).Name, ""));
} }
} }
} }
} }
// //
// Kerbal Engineer Redux // Kerbal Engineer Redux
// //
// Copyright (C) 2014 CYBUTEK // Copyright (C) 2014 CYBUTEK
// //
// This program is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// //
   
#region Using Directives #region Using Directives
   
using System; using System;
using KerbalEngineer.Flight.Sections; using KerbalEngineer.Flight.Sections;
using KerbalEngineer.Helpers; using KerbalEngineer.Helpers;
   
#endregion #endregion
   
namespace KerbalEngineer.Flight.Readouts.Orbital namespace KerbalEngineer.Flight.Readouts.Orbital
{ {
public class TimeToAtmosphere : ReadoutModule public class TimeToAtmosphere : ReadoutModule
{ {
//private LogMsg log = new LogMsg(); //private LogMsg log = new LogMsg();
#region Constructors #region Constructors
   
public TimeToAtmosphere() public TimeToAtmosphere()
{ {
this.Name = "Time to Atmosphere"; this.Name = "Time to Atmosphere";
this.Category = ReadoutCategory.GetCategory("Orbital"); this.Category = ReadoutCategory.GetCategory("Orbital");
this.HelpString = "Shows the time until the vessel enters or leaves atmosphere."; this.HelpString = "Shows the time until the vessel enters or leaves atmosphere.";
this.IsDefault = false; this.IsDefault = false;
} }
   
#endregion #endregion
   
#region Methods: public #region Methods: public
   
public override void Draw(SectionModule section) public override void Draw(SectionModule section)
{ {
String str; String str;
Orbit orbit = FlightGlobals.ship_orbit; Orbit orbit = FlightGlobals.ship_orbit;
   
if (orbit.referenceBody.atmosphere && orbit.PeA < orbit.referenceBody.atmosphereDepth) if (orbit.referenceBody.atmosphere && orbit.PeA < orbit.referenceBody.atmosphereDepth && orbit.ApA > orbit.referenceBody.atmosphereDepth)
{ {
double tA = orbit.TrueAnomalyAtRadius(orbit.referenceBody.atmosphereDepth + orbit.referenceBody.Radius); double tA = orbit.TrueAnomalyAtRadius(orbit.referenceBody.atmosphereDepth + orbit.referenceBody.Radius);
//log.buf.AppendFormat("tA = {0}\n", tA); //log.buf.AppendFormat("tA = {0}\n", tA);
double utTime = Planetarium.GetUniversalTime(); double utTime = Planetarium.GetUniversalTime();
//log.buf.AppendFormat("utTime = {0}\n", utTime); //log.buf.AppendFormat("utTime = {0}\n", utTime);
double timeAtRad1 = orbit.GetUTforTrueAnomaly(tA, orbit.period * 0.5); double timeAtRad1 = orbit.GetUTforTrueAnomaly(tA, orbit.period * 0.5);
//log.buf.AppendFormat("timeAtRad1 = {0}\n", timeAtRad1); //log.buf.AppendFormat("timeAtRad1 = {0}\n", timeAtRad1);
if (timeAtRad1 < utTime) if (timeAtRad1 < utTime)
{ {
timeAtRad1 += orbit.period; timeAtRad1 += orbit.period;
//log.buf.AppendFormat("timeAtRad1 = {0}\n", timeAtRad1); //log.buf.AppendFormat("timeAtRad1 = {0}\n", timeAtRad1);
} }
double timeAtRad2 = orbit.GetUTforTrueAnomaly(-tA, orbit.period * 0.5); double timeAtRad2 = orbit.GetUTforTrueAnomaly(-tA, orbit.period * 0.5);
//log.buf.AppendFormat("timeAtRad2 = {0}\n", timeAtRad2); //log.buf.AppendFormat("timeAtRad2 = {0}\n", timeAtRad2);
if (timeAtRad2 < utTime) if (timeAtRad2 < utTime)
{ {
timeAtRad2 += orbit.period; timeAtRad2 += orbit.period;
//log.buf.AppendFormat("timeAtRad2 = {0}\n", timeAtRad2); //log.buf.AppendFormat("timeAtRad2 = {0}\n", timeAtRad2);
} }
double time = Math.Min(timeAtRad1, timeAtRad2) - utTime; double time = Math.Min(timeAtRad1, timeAtRad2) - utTime;
//log.buf.AppendFormat("time = {0}\n", time); //log.buf.AppendFormat("time = {0}\n", time);
   
if (Double.IsNaN(time)) if (Double.IsNaN(time))
{ {
str = "---s"; str = "---s";
//log.buf.AppendLine("time is NaN"); //log.buf.AppendLine("time is NaN");
} }
else else
{ {
str = TimeFormatter.ConvertToString(time); str = TimeFormatter.ConvertToString(time);
//log.buf.AppendFormat("str = {0}\n", str); //log.buf.AppendFormat("str = {0}\n", str);
} }
} }
else else
{ {
str = "---s"; str = "---s";
//log.buf.AppendLine("no atmosphere or pe > atmosphere"); //log.buf.AppendLine("no atmosphere, pe > atmosphere, or ap < atmosphere");
} }
   
//log.Flush(); //log.Flush();
this.DrawLine(str, section.IsHud); this.DrawLine(str, section.IsHud);
} }
   
#endregion #endregion
} }
} }
// //
// Copyright (C) 2015 CYBUTEK // Copyright (C) 2015 CYBUTEK
// //
// This program is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// //
   
namespace KerbalEngineer.Flight.Readouts namespace KerbalEngineer.Flight.Readouts
{ {
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using Miscellaneous; using Miscellaneous;
using Orbital; using Orbital;
using Orbital.ManoeuvreNode; using Orbital.ManoeuvreNode;
using Rendezvous; using Rendezvous;
using Settings; using Settings;
using Surface; using Surface;
using Thermal; using Thermal;
using Vessel; using Vessel;
using AltitudeSeaLevel = Surface.AltitudeSeaLevel; using AltitudeSeaLevel = Surface.AltitudeSeaLevel;
using ApoapsisHeight = Orbital.ApoapsisHeight; using ApoapsisHeight = Orbital.ApoapsisHeight;
using OrbitalPeriod = Orbital.OrbitalPeriod; using OrbitalPeriod = Orbital.OrbitalPeriod;
using PeriapsisHeight = Orbital.PeriapsisHeight; using PeriapsisHeight = Orbital.PeriapsisHeight;
using SemiMajorAxis = Orbital.SemiMajorAxis; using SemiMajorAxis = Orbital.SemiMajorAxis;
using SemiMinorAxis = Orbital.SemiMinorAxis; using SemiMinorAxis = Orbital.SemiMinorAxis;
using TimeToApoapsis = Orbital.TimeToApoapsis; using TimeToApoapsis = Orbital.TimeToApoapsis;
using TimeToPeriapsis = Orbital.TimeToPeriapsis; using TimeToPeriapsis = Orbital.TimeToPeriapsis;
   
public static class ReadoutLibrary public static class ReadoutLibrary
{ {
private static List<ReadoutModule> readouts = new List<ReadoutModule>(); private static List<ReadoutModule> readouts = new List<ReadoutModule>();
   
/// <summary> /// <summary>
/// Sets up and populates the readout library with the stock readouts. /// Sets up and populates the readout library with the stock readouts.
/// </summary> /// </summary>
static ReadoutLibrary() static ReadoutLibrary()
{ {
try try
{ {
ReadoutCategory.SetCategory("Orbital", "Readout for orbital manovoeures."); ReadoutCategory.SetCategory("Orbital", "Readout for orbital manovoeures.");
ReadoutCategory.SetCategory("Surface", "Surface and atmospheric readouts."); ReadoutCategory.SetCategory("Surface", "Surface and atmospheric readouts.");
ReadoutCategory.SetCategory("Vessel", "Vessel performance statistics."); ReadoutCategory.SetCategory("Vessel", "Vessel performance statistics.");
ReadoutCategory.SetCategory("Rendezvous", "Readouts for rendezvous manovoeures."); ReadoutCategory.SetCategory("Rendezvous", "Readouts for rendezvous manovoeures.");
ReadoutCategory.SetCategory("Thermal", "Thermal characteristics readouts."); ReadoutCategory.SetCategory("Thermal", "Thermal characteristics readouts.");
ReadoutCategory.SetCategory("Miscellaneous", "Miscellaneous readouts."); ReadoutCategory.SetCategory("Miscellaneous", "Miscellaneous readouts.");
ReadoutCategory.Selected = ReadoutCategory.GetCategory("Orbital"); ReadoutCategory.Selected = ReadoutCategory.GetCategory("Orbital");
   
// Orbital // Orbital
readouts.Add(new ApoapsisHeight()); readouts.Add(new ApoapsisHeight());
readouts.Add(new PeriapsisHeight()); readouts.Add(new PeriapsisHeight());
readouts.Add(new TimeToApoapsis()); readouts.Add(new TimeToApoapsis());
readouts.Add(new TimeToPeriapsis()); readouts.Add(new TimeToPeriapsis());
readouts.Add(new Inclination()); readouts.Add(new Inclination());
readouts.Add(new TimeToEquatorialAscendingNode()); readouts.Add(new TimeToEquatorialAscendingNode());
readouts.Add(new TimeToEquatorialDescendingNode()); readouts.Add(new TimeToEquatorialDescendingNode());
readouts.Add(new AngleToEquatorialAscendingNode()); readouts.Add(new AngleToEquatorialAscendingNode());
readouts.Add(new AngleToEquatorialDescendingNode()); readouts.Add(new AngleToEquatorialDescendingNode());
readouts.Add(new Eccentricity()); readouts.Add(new Eccentricity());
readouts.Add(new OrbitalSpeed()); readouts.Add(new OrbitalSpeed());
readouts.Add(new OrbitalPeriod()); readouts.Add(new OrbitalPeriod());
readouts.Add(new CurrentSoi()); readouts.Add(new CurrentSoi());
readouts.Add(new LongitudeOfAscendingNode()); readouts.Add(new LongitudeOfAscendingNode());
readouts.Add(new LongitudeOfPeriapsis()); readouts.Add(new LongitudeOfPeriapsis());
readouts.Add(new ArgumentOfPeriapsis()); readouts.Add(new ArgumentOfPeriapsis());
readouts.Add(new TrueAnomaly()); readouts.Add(new TrueAnomaly());
readouts.Add(new MeanAnomaly()); readouts.Add(new MeanAnomaly());
readouts.Add(new MeanAnomalyAtEpoc()); readouts.Add(new MeanAnomalyAtEpoc());
readouts.Add(new EccentricAnomaly()); readouts.Add(new EccentricAnomaly());
readouts.Add(new SemiMajorAxis()); readouts.Add(new SemiMajorAxis());
readouts.Add(new SemiMinorAxis()); readouts.Add(new SemiMinorAxis());
readouts.Add(new AngleToPrograde()); readouts.Add(new AngleToPrograde());
readouts.Add(new AngleToRetrograde()); readouts.Add(new AngleToRetrograde());
readouts.Add(new NodeProgradeDeltaV()); readouts.Add(new NodeProgradeDeltaV());
readouts.Add(new NodeNormalDeltaV()); readouts.Add(new NodeNormalDeltaV());
readouts.Add(new NodeRadialDeltaV()); readouts.Add(new NodeRadialDeltaV());
readouts.Add(new NodeTotalDeltaV()); readouts.Add(new NodeTotalDeltaV());
readouts.Add(new NodeBurnTime()); readouts.Add(new NodeBurnTime());
readouts.Add(new NodeHalfBurnTime()); readouts.Add(new NodeHalfBurnTime());
readouts.Add(new NodeTimeToManoeuvre()); readouts.Add(new NodeTimeToManoeuvre());
readouts.Add(new NodeTimeToHalfBurn()); readouts.Add(new NodeTimeToHalfBurn());
readouts.Add(new NodeAngleToPrograde()); readouts.Add(new NodeAngleToPrograde());
readouts.Add(new NodeAngleToRetrograde()); readouts.Add(new NodeAngleToRetrograde());
readouts.Add(new PostBurnApoapsis()); readouts.Add(new PostBurnApoapsis());
readouts.Add(new PostBurnPeriapsis()); readouts.Add(new PostBurnPeriapsis());
readouts.Add(new SpeedAtApoapsis()); readouts.Add(new SpeedAtApoapsis());
readouts.Add(new SpeedAtPeriapsis()); readouts.Add(new SpeedAtPeriapsis());
readouts.Add(new TimeToAtmosphere()); readouts.Add(new TimeToAtmosphere());
   
// Surface // Surface
readouts.Add(new AltitudeSeaLevel()); readouts.Add(new AltitudeSeaLevel());
readouts.Add(new AltitudeTerrain()); readouts.Add(new AltitudeTerrain());
readouts.Add(new VerticalSpeed()); readouts.Add(new VerticalSpeed());
readouts.Add(new VerticalAcceleration()); readouts.Add(new VerticalAcceleration());
readouts.Add(new HorizontalSpeed()); readouts.Add(new HorizontalSpeed());
readouts.Add(new HorizontalAcceleration()); readouts.Add(new HorizontalAcceleration());
readouts.Add(new MachNumber()); readouts.Add(new MachNumber());
readouts.Add(new Latitude()); readouts.Add(new Latitude());
readouts.Add(new Longitude()); readouts.Add(new Longitude());
readouts.Add(new GeeForce()); readouts.Add(new GeeForce());
readouts.Add(new TerminalVelocity()); readouts.Add(new TerminalVelocity());
readouts.Add(new AtmosphericEfficiency()); readouts.Add(new AtmosphericEfficiency());
readouts.Add(new Biome()); readouts.Add(new Biome());
readouts.Add(new Situation()); readouts.Add(new Situation());
readouts.Add(new Slope()); readouts.Add(new Slope());
readouts.Add(new ImpactTime()); readouts.Add(new ImpactTime());
readouts.Add(new ImpactLongitude()); readouts.Add(new ImpactLongitude());
readouts.Add(new ImpactLatitude()); readouts.Add(new ImpactLatitude());
readouts.Add(new ImpactAltitude()); readouts.Add(new ImpactAltitude());
readouts.Add(new ImpactBiome()); readouts.Add(new ImpactBiome());
   
// Vessel // Vessel
  readouts.Add(new Name());
readouts.Add(new DeltaVStaged()); readouts.Add(new DeltaVStaged());
readouts.Add(new DeltaVCurrent()); readouts.Add(new DeltaVCurrent());
readouts.Add(new DeltaVTotal()); readouts.Add(new DeltaVTotal());
readouts.Add(new DeltaVCurrentTotal()); readouts.Add(new DeltaVCurrentTotal());
readouts.Add(new SpecificImpulse()); readouts.Add(new SpecificImpulse());
readouts.Add(new Mass()); readouts.Add(new Mass());
readouts.Add(new Thrust()); readouts.Add(new Thrust());
readouts.Add(new ThrustToWeight()); readouts.Add(new ThrustToWeight());
readouts.Add(new ThrustOffsetAngle()); readouts.Add(new ThrustOffsetAngle());
readouts.Add(new ThrustTorque()); readouts.Add(new ThrustTorque());
readouts.Add(new SurfaceThrustToWeight()); readouts.Add(new SurfaceThrustToWeight());
readouts.Add(new Acceleration()); readouts.Add(new Acceleration());
readouts.Add(new SuicideBurnAltitude()); readouts.Add(new SuicideBurnAltitude());
readouts.Add(new SuicideBurnDistance()); readouts.Add(new SuicideBurnDistance());
readouts.Add(new SuicideBurnDeltaV()); readouts.Add(new SuicideBurnDeltaV());
readouts.Add(new IntakeAirUsage()); readouts.Add(new IntakeAirUsage());
readouts.Add(new IntakeAirDemand()); readouts.Add(new IntakeAirDemand());
readouts.Add(new IntakeAirSupply()); readouts.Add(new IntakeAirSupply());
readouts.Add(new IntakeAirDemandSupply()); readouts.Add(new IntakeAirDemandSupply());
readouts.Add(new PartCount()); readouts.Add(new PartCount());
readouts.Add(new Heading()); readouts.Add(new Heading());
readouts.Add(new Pitch()); readouts.Add(new Pitch());
readouts.Add(new Roll()); readouts.Add(new Roll());
readouts.Add(new HeadingRate()); readouts.Add(new HeadingRate());
readouts.Add(new PitchRate()); readouts.Add(new PitchRate());
readouts.Add(new RollRate()); readouts.Add(new RollRate());
   
// Rendezvous // Rendezvous
readouts.Add(new TargetSelector()); readouts.Add(new TargetSelector());
readouts.Add(new PhaseAngle()); readouts.Add(new PhaseAngle());
readouts.Add(new InterceptAngle()); readouts.Add(new InterceptAngle());
readouts.Add(new RelativeVelocity()); readouts.Add(new RelativeVelocity());
readouts.Add(new RelativeSpeed()); readouts.Add(new RelativeSpeed());
readouts.Add(new RelativeInclination()); readouts.Add(new RelativeInclination());
readouts.Add(new TimeToRelativeAscendingNode()); readouts.Add(new TimeToRelativeAscendingNode());
readouts.Add(new TimeToRelativeDescendingNode()); readouts.Add(new TimeToRelativeDescendingNode());
readouts.Add(new AngleToRelativeAscendingNode()); readouts.Add(new AngleToRelativeAscendingNode());
readouts.Add(new AngleToRelativeDescendingNode()); readouts.Add(new AngleToRelativeDescendingNode());
readouts.Add(new Rendezvous.AltitudeSeaLevel()); readouts.Add(new Rendezvous.AltitudeSeaLevel());
readouts.Add(new Rendezvous.ApoapsisHeight()); readouts.Add(new Rendezvous.ApoapsisHeight());
readouts.Add(new Rendezvous.PeriapsisHeight()); readouts.Add(new Rendezvous.PeriapsisHeight());
readouts.Add(new Rendezvous.TimeToApoapsis()); readouts.Add(new Rendezvous.TimeToApoapsis());
readouts.Add(new Rendezvous.TimeToPeriapsis()); readouts.Add(new Rendezvous.TimeToPeriapsis());
readouts.Add(new Distance()); readouts.Add(new Distance());
readouts.Add(new Rendezvous.OrbitalPeriod()); readouts.Add(new Rendezvous.OrbitalPeriod());
readouts.Add(new Rendezvous.SemiMajorAxis()); readouts.Add(new Rendezvous.SemiMajorAxis());
readouts.Add(new Rendezvous.SemiMinorAxis()); readouts.Add(new Rendezvous.SemiMinorAxis());
  readouts.Add(new Rendezvous.RelativeRadialVelocity());
  readouts.Add(new Rendezvous.TimeToRendezvous());
   
// Thermal // Thermal
readouts.Add(new InternalFlux()); readouts.Add(new InternalFlux());
readouts.Add(new ConvectionFlux()); readouts.Add(new ConvectionFlux());
readouts.Add(new RadiationFlux()); readouts.Add(new RadiationFlux());
readouts.Add(new CriticalPart()); readouts.Add(new CriticalPart());
readouts.Add(new CriticalTemperature()); readouts.Add(new CriticalTemperature());
readouts.Add(new CriticalSkinTemperature()); readouts.Add(new CriticalSkinTemperature());
readouts.Add(new CriticalThermalPercentage()); readouts.Add(new CriticalThermalPercentage());
readouts.Add(new HottestPart()); readouts.Add(new HottestPart());
readouts.Add(new HottestTemperature()); readouts.Add(new HottestTemperature());
readouts.Add(new HottestSkinTemperature()); readouts.Add(new HottestSkinTemperature());
readouts.Add(new CoolestPart()); readouts.Add(new CoolestPart());
readouts.Add(new CoolestTemperature()); readouts.Add(new CoolestTemperature());
readouts.Add(new CoolestSkinTemperature()); readouts.Add(new CoolestSkinTemperature());
   
// Misc // Misc
readouts.Add(new Separator()); readouts.Add(new Separator());
readouts.Add(new GuiSizeAdjustor()); readouts.Add(new GuiSizeAdjustor());
readouts.Add(new SimulationDelay()); readouts.Add(new SimulationDelay());
readouts.Add(new TimeReference()); readouts.Add(new TimeReference());
readouts.Add(new VectoredThrustToggle()); readouts.Add(new VectoredThrustToggle());
readouts.Add(new SystemTime()); readouts.Add(new SystemTime());
   
LoadHelpStrings(); LoadHelpStrings();
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Exception(ex); Logger.Exception(ex);
} }
} }
   
/// <summary> /// <summary>
/// Gets and sets the available readout modules. /// Gets and sets the available readout modules.
/// </summary> /// </summary>
public static List<ReadoutModule> Readouts public static List<ReadoutModule> Readouts
{ {
get get
{ {
return readouts; return readouts;
} }
set set
{ {
readouts = value; readouts = value;
} }
} }
   
/// <summary> /// <summary>
/// Gets a list of readout modules which are associated with the specified category. /// Gets a list of readout modules which are associated with the specified category.
/// </summary> /// </summary>
public static List<ReadoutModule> GetCategory(ReadoutCategory category) public static List<ReadoutModule> GetCategory(ReadoutCategory category)
{ {
return readouts.Where(r => r.Category == category).ToList(); return readouts.Where(r => r.Category == category).ToList();
} }
   
/// <summary> /// <summary>
/// Gets a readout module with the specified name or class name. (Returns null if not found.) /// Gets a readout module with the specified name or class name. (Returns null if not found.)
/// </summary> /// </summary>
public static ReadoutModule GetReadout(string name) public static ReadoutModule GetReadout(string name)
{ {
return readouts.FirstOrDefault(r => r.Name == name || r.GetType().Name == name || r.Category + "." + r.GetType().Name == name); return readouts.FirstOrDefault(r => r.Name == name || r.GetType().Name == name || r.Category + "." + r.GetType().Name == name);
} }
   
/// <summary> /// <summary>
/// Resets all the readout modules. /// Resets all the readout modules.
/// </summary> /// </summary>
public static void Reset() public static void Reset()
{ {
foreach (ReadoutModule readout in readouts) foreach (ReadoutModule readout in readouts)
{ {
readout.Reset(); readout.Reset();
} }
} }
   
/// <summary> /// <summary>
/// Loads the help strings from file. /// Loads the help strings from file.
/// </summary> /// </summary>
private static void LoadHelpStrings() private static void LoadHelpStrings()
{ {
try try
{ {
SettingHandler handler = SettingHandler.Load("HelpStrings.xml"); SettingHandler handler = SettingHandler.Load("HelpStrings.xml");
foreach (ReadoutModule readout in readouts) foreach (ReadoutModule readout in readouts)
{ {
readout.HelpString = handler.GetSet(readout.Category + "." + readout.GetType().Name, readout.HelpString); readout.HelpString = handler.GetSet(readout.Category + "." + readout.GetType().Name, readout.HelpString);
} }
handler.Save("HelpStrings.xml"); handler.Save("HelpStrings.xml");
} }
catch (Exception ex) catch (Exception ex)
{ {
Logger.Exception(ex); Logger.Exception(ex);
} }
} }
} }
} }
  //
  // Kerbal Engineer Redux
  //
  // Copyright (C) 2014 CYBUTEK
  //
  // This program is free software: you can redistribute it and/or modify
  // it under the terms of the GNU General Public License as published by
  // the Free Software Foundation, either version 3 of the License, or
  // (at your option) any later version.
  //
  // This program is distributed in the hope that it will be useful,
  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  // GNU General Public License for more details.
  //
  // You should have received a copy of the GNU General Public License
  // along with this program. If not, see <http://www.gnu.org/licenses/>.
  //
 
  #region Using Directives
 
  using 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
  }
  }
 
// //
// Kerbal Engineer Redux // Kerbal Engineer Redux
// //
// Copyright (C) 2015 CYBUTEK // Copyright (C) 2015 CYBUTEK
// //
// This program is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// //
   
namespace KerbalEngineer.Flight.Readouts.Rendezvous namespace KerbalEngineer.Flight.Readouts.Rendezvous
{ {
using System; using System;
using Extensions; using Extensions;
using Helpers; using Helpers;
   
public class RendezvousProcessor : IUpdatable, IUpdateRequest public class RendezvousProcessor : IUpdatable, IUpdateRequest
{ {
private static readonly RendezvousProcessor instance = new RendezvousProcessor(); private static readonly RendezvousProcessor instance = new RendezvousProcessor();
   
private Orbit originOrbit; private Orbit originOrbit;
private Orbit targetOrbit; private Orbit targetOrbit;
   
/// <summary> /// <summary>
/// Gets the target's altitude above its reference body. /// Gets the target's altitude above its reference body.
/// </summary> /// </summary>
public static double AltitudeSeaLevel { get; private set; } public static double AltitudeSeaLevel { get; private set; }
   
/// <summary> /// <summary>
/// Gets the angle from the origin position to the ascending node. /// Gets the angle from the origin position to the ascending node.
/// </summary> /// </summary>
public static double AngleToAscendingNode { get; private set; } public static double AngleToAscendingNode { get; private set; }
   
/// <summary> /// <summary>
/// Gets the angle from the origin position to the descending node. /// Gets the angle from the origin position to the descending node.
/// </summary> /// </summary>
public static double AngleToDescendingNode { get; private set; } public static double AngleToDescendingNode { get; private set; }
   
/// <summary> /// <summary>
/// Gets the target's apoapsis above its reference body. /// Gets the target's apoapsis above its reference body.
/// </summary> /// </summary>
public static double ApoapsisHeight { get; private set; } public static double ApoapsisHeight { get; private set; }
   
/// <summary> /// <summary>
/// Gets the distance from the origin position to the target position. /// Gets the distance from the origin position to the target position.
/// </summary> /// </summary>
public static double Distance { get; private set; } public static double Distance { get; private set; }
   
/// <summary> /// <summary>
/// Gets the current instance of the rendezvous processor. /// Gets the current instance of the rendezvous processor.
/// </summary> /// </summary>
public static RendezvousProcessor Instance public static RendezvousProcessor Instance
{ {
get get
{ {
return instance; return instance;
} }
} }
   
/// <summary> /// <summary>
/// Gets the difference in angle from the origin position to where it is most efficient to burn for an encounter. /// Gets the difference in angle from the origin position to where it is most efficient to burn for an encounter.
/// </summary> /// </summary>
public static double InterceptAngle { get; private set; } public static double InterceptAngle { get; private set; }
   
/// <summary> /// <summary>
/// Gets the orbital period of the target orbit. /// Gets the orbital period of the target orbit.
/// </summary> /// </summary>
public static double OrbitalPeriod { get; private set; } public static double OrbitalPeriod { get; private set; }
   
/// <summary> /// <summary>
/// Gets the target's periapsis above its reference body. /// Gets the target's periapsis above its reference body.
/// </summary> /// </summary>
public static double PeriapsisHeight { get; private set; } public static double PeriapsisHeight { get; private set; }
   
/// <summary> /// <summary>
/// Gets the difference in angle from the origin position to the target position based on a common reference. /// Gets the difference in angle from the origin position to the target position based on a common reference.
/// </summary> /// </summary>
public static double PhaseAngle { get; private set; } public static double PhaseAngle { get; private set; }
   
/// <summary> /// <summary>
/// Gets the angular difference between the origin and target orbits. /// Gets the angular difference between the origin and target orbits.
/// </summary> /// </summary>
public static double RelativeInclination { get; private set; } public static double RelativeInclination { get; private set; }
   
/// <summary> /// <summary>
/// Gets the relative orbital speed between the vessel and target. /// Gets the relative orbital speed between the vessel and target.
/// </summary> /// </summary>
public static double RelativeSpeed { get; private set; } public static double RelativeSpeed { get; private set; }
   
/// <summary> /// <summary>
/// Gets the relative orbital velocity between the vessel and target. /// Gets the relative orbital velocity between the vessel and target.
/// </summary> /// </summary>
public static double RelativeVelocity { get; private set; } public static double RelativeVelocity { get; private set; }
   
/// <summary> /// <summary>
/// Gets the semi-major axis of the target orbit. /// Gets the semi-major axis of the target orbit.
/// </summary> /// </summary>
public static double SemiMajorAxis { get; private set; } public static double SemiMajorAxis { get; private set; }
   
/// <summary> /// <summary>
/// Gets the semi-minor axis of the target orbit. /// Gets the semi-minor axis of the target orbit.
/// </summary> /// </summary>
public static double SemiMinorAxis { get; private set; } public static double SemiMinorAxis { get; private set; }
   
/// <summary> /// <summary>
/// Gets whether the details are ready to be shown. /// Gets whether the details are ready to be shown.
/// </summary> /// </summary>
public static bool ShowDetails { get; private set; } public static bool ShowDetails { get; private set; }
   
/// <summary> /// <summary>
/// Gets the target's time to apoapsis. /// Gets the target's time to apoapsis.
/// </summary> /// </summary>
public static double TimeToApoapsis { get; private set; } public static double TimeToApoapsis { get; private set; }
   
/// <summary> /// <summary>
/// Gets the time it will take to reach the ascending node. /// Gets the time it will take to reach the ascending node.
/// </summary> /// </summary>
public static double TimeToAscendingNode { get; private set; } public static double TimeToAscendingNode { get; private set; }
   
/// <summary> /// <summary>
/// Gets the time it will take to reach the descending node. /// Gets the time it will take to reach the descending node.
/// </summary> /// </summary>
public static double TimeToDescendingNode { get; private set; } public static double TimeToDescendingNode { get; private set; }
   
/// <summary> /// <summary>
/// Gets the target's time to periapsis. /// Gets the target's time to periapsis.
/// </summary> /// </summary>
public static double TimeToPeriapsis { get; private set; } public static double TimeToPeriapsis { get; private set; }
   
  /// <summary>
  /// Gets the relative radial velocity.
  /// </summary>
  public static double RelativeRadialVelocity { get; private set; }
   
  /// <summary>
  /// Gets approximate (linearly) time to the minimum distance between objects.
  /// </summary>
  public static double TimeToRendezvous { get; private set; }
   
/// <summary> /// <summary>
/// Gets and sets whether the updatable object should be updated. /// Gets and sets whether the updatable object should be updated.
/// </summary> /// </summary>
public bool UpdateRequested { get; set; } public bool UpdateRequested { get; set; }
   
/// <summary> /// <summary>
/// Request and update to calculate the details. /// Request and update to calculate the details.
/// </summary> /// </summary>
public static void RequestUpdate() public static void RequestUpdate()
{ {
instance.UpdateRequested = true; instance.UpdateRequested = true;
} }
   
/// <summary> /// <summary>
/// Updates the details by recalculating if requested. /// Updates the details by recalculating if requested.
/// </summary> /// </summary>
public void Update() public void Update()
{ {
if (FlightGlobals.fetch == null || if (FlightGlobals.fetch == null ||
FlightGlobals.fetch.VesselTarget == null || FlightGlobals.fetch.VesselTarget == null ||
FlightGlobals.ActiveVessel == null || FlightGlobals.ActiveVessel == null ||
FlightGlobals.ActiveVessel.targetObject == null || FlightGlobals.ActiveVessel.targetObject == null ||
FlightGlobals.ActiveVessel.targetObject.GetOrbit() == null || FlightGlobals.ActiveVessel.targetObject.GetOrbit() == null ||
FlightGlobals.ship_orbit == null || FlightGlobals.ship_orbit == null ||
FlightGlobals.ship_orbit.referenceBody == null) FlightGlobals.ship_orbit.referenceBody == null)
{ {
ShowDetails = false; ShowDetails = false;
return; return;
} }
   
ShowDetails = true; ShowDetails = true;
   
targetOrbit = FlightGlobals.fetch.VesselTarget.GetOrbit(); targetOrbit = FlightGlobals.fetch.VesselTarget.GetOrbit();
originOrbit = (FlightGlobals.ship_orbit.referenceBody == Planetarium.fetch.Sun || originOrbit = (FlightGlobals.ship_orbit.referenceBody == Planetarium.fetch.Sun ||
FlightGlobals.ship_orbit.referenceBody == FlightGlobals.ActiveVessel.targetObject.GetOrbit().referenceBody) FlightGlobals.ship_orbit.referenceBody == FlightGlobals.ActiveVessel.targetObject.GetOrbit().referenceBody)
? FlightGlobals.ship_orbit ? FlightGlobals.ship_orbit
: FlightGlobals.ship_orbit.referenceBody.orbit; : FlightGlobals.ship_orbit.referenceBody.orbit;
   
RelativeInclination = originOrbit.GetRelativeInclination(targetOrbit); RelativeInclination = originOrbit.GetRelativeInclination(targetOrbit);
RelativeVelocity = FlightGlobals.ship_tgtSpeed; RelativeVelocity = FlightGlobals.ship_tgtSpeed;
RelativeSpeed = FlightGlobals.ship_obtSpeed - targetOrbit.orbitalSpeed; RelativeSpeed = FlightGlobals.ship_obtSpeed - targetOrbit.orbitalSpeed;
PhaseAngle = originOrbit.GetPhaseAngle(targetOrbit); PhaseAngle = originOrbit.GetPhaseAngle(targetOrbit);
InterceptAngle = CalcInterceptAngle(); InterceptAngle = CalcInterceptAngle();
TimeToAscendingNode = originOrbit.GetTimeToVector(GetAscendingNode()); TimeToAscendingNode = originOrbit.GetTimeToVector(GetAscendingNode());
TimeToDescendingNode = originOrbit.GetTimeToVector(GetDescendingNode()); TimeToDescendingNode = originOrbit.GetTimeToVector(GetDescendingNode());
AngleToAscendingNode = originOrbit.GetAngleToVector(GetAscendingNode()); AngleToAscendingNode = originOrbit.GetAngleToVector(GetAscendingNode());
AngleToDescendingNode = originOrbit.GetAngleToVector(GetDescendingNode()); AngleToDescendingNode = originOrbit.GetAngleToVector(GetDescendingNode());
AltitudeSeaLevel = targetOrbit.altitude; AltitudeSeaLevel = targetOrbit.altitude;
ApoapsisHeight = targetOrbit.ApA; ApoapsisHeight = targetOrbit.ApA;
PeriapsisHeight = targetOrbit.PeA; PeriapsisHeight = targetOrbit.PeA;
TimeToApoapsis = targetOrbit.timeToAp; TimeToApoapsis = targetOrbit.timeToAp;
TimeToPeriapsis = targetOrbit.timeToPe; TimeToPeriapsis = targetOrbit.timeToPe;
SemiMajorAxis = targetOrbit.semiMajorAxis; SemiMajorAxis = targetOrbit.semiMajorAxis;
SemiMinorAxis = targetOrbit.semiMinorAxis; SemiMinorAxis = targetOrbit.semiMinorAxis;
   
Distance = Vector3d.Distance(targetOrbit.pos, originOrbit.pos); Distance = Vector3d.Distance(targetOrbit.pos, originOrbit.pos);
OrbitalPeriod = targetOrbit.period; 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() private double CalcInterceptAngle()
{ {
double originRadius = (originOrbit.semiMinorAxis + originOrbit.semiMajorAxis) * 0.5; double originRadius = (originOrbit.semiMinorAxis + originOrbit.semiMajorAxis) * 0.5;
double targetRadius = (targetOrbit.semiMinorAxis + targetOrbit.semiMajorAxis) * 0.5; double targetRadius = (targetOrbit.semiMinorAxis + targetOrbit.semiMajorAxis) * 0.5;
double angle = 180.0 * (1.0 - Math.Pow((originRadius + targetRadius) / (2.0 * targetRadius), 1.5)); double angle = 180.0 * (1.0 - Math.Pow((originRadius + targetRadius) / (2.0 * targetRadius), 1.5));
angle = PhaseAngle - angle; angle = PhaseAngle - angle;
return RelativeInclination < 90.0 ? AngleHelper.Clamp360(angle) : AngleHelper.Clamp360(360.0 - (180.0 - angle)); return RelativeInclination < 90.0 ? AngleHelper.Clamp360(angle) : AngleHelper.Clamp360(360.0 - (180.0 - angle));
} }
   
private Vector3d GetAscendingNode() private Vector3d GetAscendingNode()
{ {
return Vector3d.Cross(targetOrbit.GetOrbitNormal(), originOrbit.GetOrbitNormal()); return Vector3d.Cross(targetOrbit.GetOrbitNormal(), originOrbit.GetOrbitNormal());
} }
   
private Vector3d GetDescendingNode() private Vector3d GetDescendingNode()
{ {
return Vector3d.Cross(originOrbit.GetOrbitNormal(), targetOrbit.GetOrbitNormal()); return Vector3d.Cross(originOrbit.GetOrbitNormal(), targetOrbit.GetOrbitNormal());
} }
} }
} }
  //
  // Kerbal Engineer Redux
  //
  // Copyright (C) 2014 CYBUTEK
  //
  // This program is free software: you can redistribute it and/or modify
  // it under the terms of the GNU General Public License as published by
  // the Free Software Foundation, either version 3 of the License, or
  // (at your option) any later version.
  //
  // This program is distributed in the hope that it will be useful,
  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  // GNU General Public License for more details.
  //
  // You should have received a copy of the GNU General Public License
  // along with this program. If not, see <http://www.gnu.org/licenses/>.
  //
 
  #region Using Directives
 
  using 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
  }
  }
  //
  // Kerbal Engineer Redux
  //
  // Copyright (C) 2014 CYBUTEK
  //
  // This program is free software: you can redistribute it and/or modify
  // it under the terms of the GNU General Public License as published by
  // the Free Software Foundation, either version 3 of the License, or
  // (at your option) any later version.
  //
  // This program is distributed in the hope that it will be useful,
  // but WITHOUT ANY WARRANTY; without even the implied warranty of
  // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  // GNU General Public License for more details.
  //
  // You should have received a copy of the GNU General Public License
  // along with this program. If not, see <http://www.gnu.org/licenses/>.
  //
 
  #region Using Directives
 
  using 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
  }
  }
// //
// Kerbal Engineer Redux // Kerbal Engineer Redux
// //
// Copyright (C) 2014 CYBUTEK // Copyright (C) 2014 CYBUTEK
// //
// This program is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// //
   
#region Using Directives #region Using Directives
   
using System; using System;
   
using KerbalEngineer.Settings; using KerbalEngineer.Settings;
   
#endregion #endregion
   
namespace KerbalEngineer.Helpers namespace KerbalEngineer.Helpers
{ {
public static class TimeFormatter public static class TimeFormatter
{ {
#region Constructors #region Constructors
   
static TimeFormatter() static TimeFormatter()
{ {
SetReference(false); SetReference(false);
Load(); Load();
} }
   
#endregion #endregion
   
#region Properties #region Properties
   
public static string Reference { get; set; } public static string Reference { get; set; }
   
public static double SecondsPerDay { get; set; } public static double SecondsPerDay { get; set; }
   
public static double SecondsPerHour { get; set; } public static double SecondsPerHour { get; set; }
   
public static double SecondsPerMinute { get; set; } public static double SecondsPerMinute { get; set; }
   
public static double SecondsPerYear { get; set; } public static double SecondsPerYear { get; set; }
   
#endregion #endregion
   
#region Methods: public #region Methods: public
   
public static string ConvertToString(double seconds, string format = "F1") public static string ConvertToString(double seconds, string format = "F1")
{ {
var years = 0; var years = 0;
while (seconds >= SecondsPerYear) var days = 0;
  var hours = 0;
  var minutes = 0;
   
  if (seconds > 0)
{ {
years++; years = (int)(seconds / SecondsPerYear);
seconds -= SecondsPerYear; seconds -= years * SecondsPerYear;
}  
   
var days = 0; days = (int)(seconds / SecondsPerDay);
while (seconds >= SecondsPerDay) seconds -= days * SecondsPerDay;
{  
days++;  
seconds -= SecondsPerDay;  
}  
   
var hours = 0; hours = (int)(seconds / SecondsPerHour);
while (seconds >= SecondsPerHour) seconds -= hours * SecondsPerHour;
{  
hours++;  
seconds -= SecondsPerHour;  
}  
   
var minutes = 0; minutes = (int)(seconds / SecondsPerMinute);
while (seconds >= SecondsPerMinute) seconds -= minutes * SecondsPerMinute;
{  
minutes++;  
seconds -= SecondsPerMinute;  
} }
   
if (years > 0) if (years > 0)
{ {
return String.Format("{0}y {1}d {2}h {3}m {4}s", years, days, hours, minutes, seconds.ToString(format)); return String.Format("{0}y {1}d {2}h {3}m {4}s", years, days, hours, minutes, seconds.ToString(format));
} }
if (days > 0) if (days > 0)
{ {
return String.Format("{0}d {1}h {2}m {3}s", days, hours, minutes, seconds.ToString(format)); return String.Format("{0}d {1}h {2}m {3}s", days, hours, minutes, seconds.ToString(format));
} }
if (hours > 0) if (hours > 0)
{ {
return String.Format("{0}h {1}m {2}s", hours, minutes, seconds.ToString(format)); return String.Format("{0}h {1}m {2}s", hours, minutes, seconds.ToString(format));
} }
   
return minutes > 0 ? String.Format("{0}m {1}s", minutes, seconds.ToString(format)) : String.Format("{0}s", seconds.ToString(format)); return minutes > 0 ? String.Format("{0}m {1}s", minutes, seconds.ToString(format)) : String.Format("{0}s", seconds.ToString(format));
} }
   
public static void Load() public static void Load()
{ {
var handler = SettingHandler.Load("TimeFormatter.xml"); var handler = SettingHandler.Load("TimeFormatter.xml");
SecondsPerMinute = handler.Get("SecondsPerMinute", SecondsPerMinute); SecondsPerMinute = handler.Get("SecondsPerMinute", SecondsPerMinute);
SecondsPerHour = handler.Get("SecondsPerHour", SecondsPerHour); SecondsPerHour = handler.Get("SecondsPerHour", SecondsPerHour);
SecondsPerDay = handler.Get("SecondsPerDay", SecondsPerDay); SecondsPerDay = handler.Get("SecondsPerDay", SecondsPerDay);
SecondsPerYear = handler.Get("SecondsPerYear", SecondsPerYear); SecondsPerYear = handler.Get("SecondsPerYear", SecondsPerYear);
Reference = handler.Get("Reference", Reference); Reference = handler.Get("Reference", Reference);
} }
   
public static void Save() public static void Save()
{ {
var handler = SettingHandler.Load("TimeFormatter.xml"); var handler = SettingHandler.Load("TimeFormatter.xml");
handler.Set("SecondsPerMinute", SecondsPerMinute); handler.Set("SecondsPerMinute", SecondsPerMinute);
handler.Set("SecondsPerHour", SecondsPerHour); handler.Set("SecondsPerHour", SecondsPerHour);
handler.Set("SecondsPerDay", SecondsPerDay); handler.Set("SecondsPerDay", SecondsPerDay);
handler.Set("SecondsPerYear", SecondsPerYear); handler.Set("SecondsPerYear", SecondsPerYear);
handler.Set("Reference", Reference); handler.Set("Reference", Reference);
handler.Save("TimeFormatter.xml"); handler.Save("TimeFormatter.xml");
} }
   
public static void SetReference(bool save = true) public static void SetReference(bool save = true)
{ {
const double minute = 60.0; const double minute = 60.0;
const double hour = minute * 60.0; const double hour = minute * 60.0;
const double day = hour * 24.0; const double day = hour * 24.0;
const double year = day * 365.0; const double year = day * 365.0;
SetReference(minute, hour, day, year, "Earth", save); SetReference(minute, hour, day, year, "Earth", save);
} }
   
public static void SetReference(CelestialBody body, bool save = true) public static void SetReference(CelestialBody body, bool save = true)
{ {
SetReference(SecondsPerMinute, SecondsPerHour, body.rotationPeriod, body.orbit.period, body.bodyName, save); SetReference(SecondsPerMinute, SecondsPerHour, body.rotationPeriod, body.orbit.period, body.bodyName, save);
} }
   
public static void SetReference(double minute, double hour, double day, double year, string reference, bool save = true) public static void SetReference(double minute, double hour, double day, double year, string reference, bool save = true)
{ {
SecondsPerMinute = minute; SecondsPerMinute = minute;
SecondsPerHour = hour; SecondsPerHour = hour;
SecondsPerDay = day; SecondsPerDay = day;
SecondsPerYear = year; SecondsPerYear = year;
Reference = reference; Reference = reference;
   
if (save) if (save)
{ {
Save(); Save();
} }
} }
   
public new static string ToString() public new static string ToString()
{ {
return String.Format("SecondsPerMinute: {0}", SecondsPerMinute) + Environment.NewLine + return String.Format("SecondsPerMinute: {0}", SecondsPerMinute) + Environment.NewLine +
String.Format("SecondsPerHour: {0}", SecondsPerHour) + Environment.NewLine + String.Format("SecondsPerHour: {0}", SecondsPerHour) + Environment.NewLine +
String.Format("SecondsPerDay: {0}", SecondsPerDay) + Environment.NewLine + String.Format("SecondsPerDay: {0}", SecondsPerDay) + Environment.NewLine +
String.Format("SecondsPerYear: {0}", SecondsPerYear) + Environment.NewLine; String.Format("SecondsPerYear: {0}", SecondsPerYear) + Environment.NewLine;
} }
   
#endregion #endregion
} }
} }
// //
// Kerbal Engineer Redux // Kerbal Engineer Redux
// //
// Copyright (C) 2015 CYBUTEK // Copyright (C) 2015 CYBUTEK
// //
// This program is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// //
   
namespace KerbalEngineer.Helpers namespace KerbalEngineer.Helpers
{ {
using System; using System;
   
public static class Units public static class Units
{ {
public const double GRAVITY = 9.80665; public const double GRAVITY = 9.80665;
   
public static string Concat(int value1, int value2) public static string Concat(int value1, int value2)
{ {
return value1 + " / " + value2; return value1 + " / " + value2;
} }
   
public static string ConcatF(double value1, double value2, int decimals = 1) public static string ConcatF(double value1, double value2, int decimals = 1)
{ {
return value1.ToString("F" + decimals) + " / " + value2.ToString("F" + decimals); return value1.ToString("F" + decimals) + " / " + value2.ToString("F" + decimals);
} }
   
public static string ConcatF(double value1, double value2, double value3, int decimals = 1) public static string ConcatF(double value1, double value2, double value3, int decimals = 1)
{ {
return value1.ToString("F" + decimals) + " / " + value2.ToString("F" + decimals) + " / " + value3.ToString("F" + decimals); return value1.ToString("F" + decimals) + " / " + value2.ToString("F" + decimals) + " / " + value3.ToString("F" + decimals);
} }
   
public static string ConcatN(double value1, double value2, int decimals = 1) public static string ConcatN(double value1, double value2, int decimals = 1)
{ {
return value1.ToString("N" + decimals) + " / " + value2.ToString("N" + decimals); return value1.ToString("N" + decimals) + " / " + value2.ToString("N" + decimals);
} }
   
public static string ConcatN(double value1, double value2, double value3, int decimals = 1) public static string ConcatN(double value1, double value2, double value3, int decimals = 1)
{ {
return value1.ToString("N" + decimals) + " / " + value2.ToString("N" + decimals) + " / " + value3.ToString("N" + decimals); return value1.ToString("N" + decimals) + " / " + value2.ToString("N" + decimals) + " / " + value3.ToString("N" + decimals);
} }
   
public static string Cost(double value, int decimals = 1) public static string Cost(double value, int decimals = 1)
{ {
if (value >= 1000000.0) if (value >= 1000000.0)
{ {
return (value / 1000.0).ToString("N" + decimals) + "K"; return (value / 1000.0).ToString("N" + decimals) + "K";
} }
return value.ToString("N" + decimals); return value.ToString("N" + decimals);
} }
   
public static string Cost(double value1, double value2, int decimals = 1) public static string Cost(double value1, double value2, int decimals = 1)
{ {
if (value1 >= 1000000.0 || value2 >= 1000000.0) if (value1 >= 1000000.0 || value2 >= 1000000.0)
{ {
return (value1 / 1000.0).ToString("N" + decimals) + " / " + (value2 / 1000.0).ToString("N" + decimals) + "K"; return (value1 / 1000.0).ToString("N" + decimals) + " / " + (value2 / 1000.0).ToString("N" + decimals) + "K";
} }
return value1.ToString("N" + decimals) + " / " + value2.ToString("N" + decimals); return value1.ToString("N" + decimals) + " / " + value2.ToString("N" + decimals);
} }
   
public static string ToAcceleration(double value, int decimals = 2) public static string ToAcceleration(double value, int decimals = 2)
{ {
return value.ToString("N" + decimals) + "m/s²"; return value.ToString("N" + decimals) + "m/s²";
} }
   
public static string ToAcceleration(double value1, double value2, int decimals = 2) public static string ToAcceleration(double value1, double value2, int decimals = 2)
{ {
return value1.ToString("N" + decimals) + " / " + value2.ToString("N" + decimals) + "m/s²"; return value1.ToString("N" + decimals) + " / " + value2.ToString("N" + decimals) + "m/s²";
} }
   
public static string ToAngle(double value, int decimals = 5) public static string ToAngle(double value, int decimals = 5)
{ {
return value.ToString("F" + decimals) + "°"; return value.ToString("F" + decimals) + "°";
} }
   
public static string ToAngleDMS(double value) public static string ToAngleDMS(double value)
{ {
double absAngle = Math.Abs(value); double absAngle = Math.Abs(value);
int deg = (int)Math.Floor(absAngle); int deg = (int)Math.Floor(absAngle);
double rem = absAngle - deg; double rem = absAngle - deg;
int min = (int)Math.Floor(rem * 60); int min = (int)Math.Floor(rem * 60);
rem -= ((double)min / 60); rem -= ((double)min / 60);
int sec = (int)Math.Floor(rem * 3600); int sec = (int)Math.Floor(rem * 3600);
return String.Format("{0:0}° {1:00}' {2:00}\"", deg, min, sec); return String.Format("{0:0}° {1:00}' {2:00}\"", deg, min, sec);
} }
   
public static string ToDistance(double value, int decimals = 1) public static string ToDistance(double value, int decimals = 1)
{ {
if (Math.Abs(value) < 1000000.0) if (Math.Abs(value) < 1000000.0)
{ {
if (Math.Abs(value) >= 10.0) if (Math.Abs(value) >= 10.0)
{ {
return value.ToString("N" + decimals) + "m"; return value.ToString("N" + decimals) + "m";
} }
   
value *= 100.0; value *= 100.0;
if (Math.Abs(value) >= 100.0) if (Math.Abs(value) >= 100.0)
{ {
return value.ToString("N" + decimals) + "cm"; return value.ToString("N" + decimals) + "cm";
} }
   
value *= 10.0; value *= 10.0;
return value.ToString("N" + decimals) + "mm"; return value.ToString("N" + decimals) + "mm";
} }
   
value /= 1000.0; value /= 1000.0;
if (Math.Abs(value) < 1000000.0) if (Math.Abs(value) < 1000000.0)
{ {
return value.ToString("N" + decimals) + "km"; return value.ToString("N" + decimals) + "km";
} }
   
value /= 1000.0; value /= 1000.0;
return value.ToString("N" + decimals) + "Mm"; return value.ToString("N" + decimals) + "Mm";
} }
   
public static string ToFlux(double value) public static string ToFlux(double value)
{ {
return value.ToString("#,0.00") + "W"; return value.ToString("#,0.00") + "W";
} }
   
public static string ToForce(double value) public static string ToForce(double value)
{ {
return value.ToString((value < 100000.0) ? (value < 10000.0) ? (value < 100.0) ? (Math.Abs(value) < Double.Epsilon) ? "N0" : "N3" : "N2" : "N1" : "N0") + "kN"; return value.ToString((value < 100000.0) ? (value < 10000.0) ? (value < 100.0) ? (Math.Abs(value) < Double.Epsilon) ? "N0" : "N3" : "N2" : "N1" : "N0") + "kN";
} }
   
public static string ToForce(double value1, double value2) public static string ToForce(double value1, double value2)
{ {
string format1 = (value1 < 100000.0) ? (value1 < 10000.0) ? (value1 < 100.0) ? (Math.Abs(value1) < Double.Epsilon) ? "N0" : "N3" : "N2" : "N1" : "N0"; string format1 = (value1 < 100000.0) ? (value1 < 10000.0) ? (value1 < 100.0) ? (Math.Abs(value1) < Double.Epsilon) ? "N0" : "N3" : "N2" : "N1" : "N0";
string format2 = (value2 < 100000.0) ? (value2 < 10000.0) ? (value2 < 100.0) ? (Math.Abs(value2) < Double.Epsilon) ? "N0" : "N3" : "N2" : "N1" : "N0"; string format2 = (value2 < 100000.0) ? (value2 < 10000.0) ? (value2 < 100.0) ? (Math.Abs(value2) < Double.Epsilon) ? "N0" : "N3" : "N2" : "N1" : "N0";
return value1.ToString(format1) + " / " + value2.ToString(format2) + "kN"; return value1.ToString(format1) + " / " + value2.ToString(format2) + "kN";
} }
   
public static string ToMach(double value) public static string ToMach(double value)
{ {
return value.ToString("0.00") + "Ma"; return value.ToString("0.00") + "Ma";
} }
   
public static string ToMass(double value, int decimals = 0) public static string ToMass(double value, int decimals = 0)
{ {
if (value >= 1000.0) if (value >= 1000.0)
{ {
return value.ToString("N" + decimals + 2) + "t"; return value.ToString("N" + decimals + 2) + "t";
} }
   
value *= 1000.0; value *= 1000.0;
return value.ToString("N" + decimals) + "kg"; return value.ToString("N" + decimals) + "kg";
} }
   
public static string ToMass(double value1, double value2, int decimals = 0) public static string ToMass(double value1, double value2, int decimals = 0)
{ {
if (value1 >= 1000.0f || value2 >= 1000.0f) if (value1 >= 1000.0f || value2 >= 1000.0f)
{ {
return value1.ToString("N" + decimals + 2) + " / " + value2.ToString("N" + decimals + 2) + "t"; return value1.ToString("N" + decimals + 2) + " / " + value2.ToString("N" + decimals + 2) + "t";
} }
   
value1 *= 1000.0; value1 *= 1000.0;
value2 *= 1000.0; value2 *= 1000.0;
return value1.ToString("N" + decimals) + " / " + value2.ToString("N" + decimals) + "kg"; return value1.ToString("N" + decimals) + " / " + value2.ToString("N" + decimals) + "kg";
} }
   
public static string ToPercent(double value, int decimals = 2) public static string ToPercent(double value, int decimals = 2)
{ {
value *= 100.0; value *= 100.0;
return value.ToString("F" + decimals) + "%"; return value.ToString("F" + decimals) + "%";
} }
   
public static string ToRate(double value, int decimals = 1) public static string ToRate(double value, int decimals = 1)
{ {
return value < 1.0 ? (value * 60.0).ToString("F" + decimals) + "/min" : value.ToString("F" + decimals) + "/sec"; return value < 1.0 ? (value * 60.0).ToString("F" + decimals) + "/min" : value.ToString("F" + decimals) + "/sec";
} }
   
public static string ToSpeed(double value, int decimals = 2) public static string ToSpeed(double value, int decimals = 2)
{ {
if (Math.Abs(value) < 1.0) if (Math.Abs(value) < 1.0)
{ {
return (value * 1000.0).ToString("N" + decimals) + "mm/s"; return (value * 1000.0).ToString("N" + decimals) + "mm/s";
} }
return value.ToString("N" + decimals) + "m/s"; return value.ToString("N" + decimals) + "m/s";
} }
   
public static string ToTemperature(double value) public static string ToTemperature(double value)
{ {
return value.ToString("#,0") + "K"; return value.ToString("#,0") + "K";
} }
   
public static string ToTemperature(double value1, double value2) public static string ToTemperature(double value1, double value2)
{ {
return value1.ToString("#,0") + " / " + value2.ToString("#,0") + "K"; return value1.ToString("#,0") + " / " + value2.ToString("#,0") + "K";
} }
   
public static string ToTime(double value) public static string ToTime(double value)
{ {
return TimeFormatter.ConvertToString(value); return TimeFormatter.ConvertToString(value);
} }
   
public static string ToTorque(double value) 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";
} }
} }
} }
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> <Project ToolsVersion="4.0" DefaultTargets="Build" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> <Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup> <PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> <Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> <Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
<ProjectGuid>{39806613-E0B7-46E0-89A6-A569EC538CBB}</ProjectGuid> <ProjectGuid>{39806613-E0B7-46E0-89A6-A569EC538CBB}</ProjectGuid>
<OutputType>Library</OutputType> <OutputType>Library</OutputType>
<AppDesignerFolder>Properties</AppDesignerFolder> <AppDesignerFolder>Properties</AppDesignerFolder>
<RootNamespace>KerbalEngineer</RootNamespace> <RootNamespace>KerbalEngineer</RootNamespace>
<AssemblyName>KerbalEngineer</AssemblyName> <AssemblyName>KerbalEngineer</AssemblyName>
<TargetFrameworkVersion>v3.5</TargetFrameworkVersion> <TargetFrameworkVersion>v3.5</TargetFrameworkVersion>
<FileAlignment>512</FileAlignment> <FileAlignment>512</FileAlignment>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
<DebugSymbols>false</DebugSymbols> <DebugSymbols>false</DebugSymbols>
<DebugType>none</DebugType> <DebugType>none</DebugType>
<Optimize>false</Optimize> <Optimize>false</Optimize>
<OutputPath>..\Output\KerbalEngineer\</OutputPath> <OutputPath>..\Output\KerbalEngineer\</OutputPath>
<DefineConstants>DEBUG;TRACE</DefineConstants> <DefineConstants>DEBUG;TRACE</DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess> <UseVSHostingProcess>false</UseVSHostingProcess>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> <PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
<DebugType>none</DebugType> <DebugType>none</DebugType>
<Optimize>true</Optimize> <Optimize>true</Optimize>
<OutputPath>..\Output\KerbalEngineer\</OutputPath> <OutputPath>..\Output\KerbalEngineer\</OutputPath>
<DefineConstants> <DefineConstants>
</DefineConstants> </DefineConstants>
<ErrorReport>prompt</ErrorReport> <ErrorReport>prompt</ErrorReport>
<WarningLevel>4</WarningLevel> <WarningLevel>4</WarningLevel>
<UseVSHostingProcess>false</UseVSHostingProcess> <UseVSHostingProcess>false</UseVSHostingProcess>
<AllowUnsafeBlocks>false</AllowUnsafeBlocks> <AllowUnsafeBlocks>false</AllowUnsafeBlocks>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<Compile Include="Control\IControlPanel.cs" /> <Compile Include="Control\IControlPanel.cs" />
<Compile Include="Control\Panels\BuildOverlayPanel.cs" /> <Compile Include="Control\Panels\BuildOverlayPanel.cs" />
<Compile Include="Control\Panels\BuildEngineerPanel.cs" /> <Compile Include="Control\Panels\BuildEngineerPanel.cs" />
<Compile Include="Editor\BuildAdvanced.cs" /> <Compile Include="Editor\BuildAdvanced.cs" />
<Compile Include="Editor\BuildOverlay.cs" /> <Compile Include="Editor\BuildOverlay.cs" />
<Compile Include="CelestialBodies.cs" /> <Compile Include="CelestialBodies.cs" />
<Compile Include="Editor\BuildOverlayPartInfo.cs" /> <Compile Include="Editor\BuildOverlayPartInfo.cs" />
<Compile Include="Editor\BuildOverlayResources.cs" /> <Compile Include="Editor\BuildOverlayResources.cs" />
<Compile Include="Editor\BuildOverlayVessel.cs" /> <Compile Include="Editor\BuildOverlayVessel.cs" />
<Compile Include="Editor\BuildToolbar.cs" /> <Compile Include="Editor\BuildToolbar.cs" />
<Compile Include="Editor\PartInfoItem.cs" /> <Compile Include="Editor\PartInfoItem.cs" />
<Compile Include="Editor\ResourceInfoItem.cs" /> <Compile Include="Editor\ResourceInfoItem.cs" />
<Compile Include="Extensions\FloatExtensions.cs" /> <Compile Include="Extensions\FloatExtensions.cs" />
<Compile Include="Extensions\OrbitExtensions.cs" /> <Compile Include="Extensions\OrbitExtensions.cs" />
<Compile Include="Extensions\StringExtensions.cs" /> <Compile Include="Extensions\StringExtensions.cs" />
<Compile Include="Flight\ActionMenuGui.cs" /> <Compile Include="Flight\ActionMenuGui.cs" />
<Compile Include="Flight\Presets\Preset.cs" /> <Compile Include="Flight\Presets\Preset.cs" />
<Compile Include="Flight\Readouts\Miscellaneous\SystemTime.cs" /> <Compile Include="Flight\Readouts\Miscellaneous\SystemTime.cs" />
<Compile Include="Flight\Readouts\Miscellaneous\VectoredThrustToggle.cs" /> <Compile Include="Flight\Readouts\Miscellaneous\VectoredThrustToggle.cs" />
<Compile Include="Flight\Readouts\Miscellaneous\TimeReference.cs" /> <Compile Include="Flight\Readouts\Miscellaneous\TimeReference.cs" />
<Compile Include="Flight\Readouts\Miscellaneous\Separator.cs" /> <Compile Include="Flight\Readouts\Miscellaneous\Separator.cs" />
<Compile Include="Flight\Readouts\Miscellaneous\GuiSizeAdjustor.cs" /> <Compile Include="Flight\Readouts\Miscellaneous\GuiSizeAdjustor.cs" />
<Compile Include="Flight\Readouts\Orbital\AngleToEquatorialDescendingNode.cs" /> <Compile Include="Flight\Readouts\Orbital\AngleToEquatorialDescendingNode.cs" />
<Compile Include="Flight\Readouts\Orbital\AngleToEquatorialAscendingNode.cs" /> <Compile Include="Flight\Readouts\Orbital\AngleToEquatorialAscendingNode.cs" />
<Compile Include="Flight\Readouts\Orbital\AngleToRetrograde.cs" /> <Compile Include="Flight\Readouts\Orbital\AngleToRetrograde.cs" />
<Compile Include="Flight\Readouts\Orbital\AngleToPrograde.cs" /> <Compile Include="Flight\Readouts\Orbital\AngleToPrograde.cs" />
<Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\NodeRadialDeltaV.cs" /> <Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\NodeRadialDeltaV.cs" />
<Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\ManoeuvreProcessor.cs" /> <Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\ManoeuvreProcessor.cs" />
<Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\NodeTimeToHalfBurn.cs" /> <Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\NodeTimeToHalfBurn.cs" />
<Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\NodeTimeToManoeuvre.cs" /> <Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\NodeTimeToManoeuvre.cs" />
<Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\NodeHalfBurnTime.cs" /> <Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\NodeHalfBurnTime.cs" />
<Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\NodeBurnTime.cs" /> <Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\NodeBurnTime.cs" />
<Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\NodeAngleToRetrograde.cs" /> <Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\NodeAngleToRetrograde.cs" />
<Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\NodeNormalDeltaV.cs" /> <Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\NodeNormalDeltaV.cs" />
<Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\NodeAngleToPrograde.cs" /> <Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\NodeAngleToPrograde.cs" />
<Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\NodeTotalDeltaV.cs" /> <Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\NodeTotalDeltaV.cs" />
<Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\NodeProgradeDeltaV.cs" /> <Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\NodeProgradeDeltaV.cs" />
<Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\PostBurnApoapsis.cs" /> <Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\PostBurnApoapsis.cs" />
<Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\PostBurnPeriapsis.cs" /> <Compile Include="Flight\Readouts\Orbital\ManoeuvreNode\PostBurnPeriapsis.cs" />
<Compile Include="Flight\Readouts\Orbital\MeanAnomalyAtEpoc.cs" /> <Compile Include="Flight\Readouts\Orbital\MeanAnomalyAtEpoc.cs" />
<Compile Include="Flight\Readouts\Orbital\MeanAnomaly.cs" /> <Compile Include="Flight\Readouts\Orbital\MeanAnomaly.cs" />
<Compile Include="Flight\Readouts\Orbital\EccentricAnomaly.cs" /> <Compile Include="Flight\Readouts\Orbital\EccentricAnomaly.cs" />
<Compile Include="Flight\Readouts\Orbital\ArgumentOfPeriapsis.cs" /> <Compile Include="Flight\Readouts\Orbital\ArgumentOfPeriapsis.cs" />
<Compile Include="Flight\Readouts\Orbital\CurrentSoi.cs" /> <Compile Include="Flight\Readouts\Orbital\CurrentSoi.cs" />
<Compile Include="Flight\Readouts\Orbital\SemiMajorAxis.cs"> <Compile Include="Flight\Readouts\Orbital\SemiMajorAxis.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="Flight\Readouts\Orbital\SpeedAtApoapsis.cs" /> <Compile Include="Flight\Readouts\Orbital\SpeedAtApoapsis.cs" />
<Compile Include="Flight\Readouts\Orbital\SpeedAtPeriapsis.cs"> <Compile Include="Flight\Readouts\Orbital\SpeedAtPeriapsis.cs">
<SubType>Code</SubType> <SubType>Code</SubType>
</Compile> </Compile>
<Compile Include="Flight\Readouts\Orbital\TimeToAtmosphere.cs" /> <Compile Include="Flight\Readouts\Orbital\TimeToAtmosphere.cs" />
<Compile Include="Flight\Readouts\Orbital\TrueAnomaly.cs" /> <Compile Include="Flight\Readouts\Orbital\TrueAnomaly.cs" />
<Compile Include="Flight\Readouts\Orbital\TimeToEquatorialAscendingNode.cs" /> <Compile Include="Flight\Readouts\Orbital\TimeToEquatorialAscendingNode.cs" />
<Compile Include="Flight\Readouts\Orbital\TimeToEquatorialDescendingNode.cs" /> <Compile Include="Flight\Readouts\Orbital\TimeToEquatorialDescendingNode.cs" />
<Compile Include="Flight\Readouts\Rendezvous\RelativeSpeed.cs" /> <Compile Include="Flight\Readouts\Rendezvous\RelativeSpeed.cs" />
<Compile Include="Flight\Readouts\Rendezvous\RelativeVelocity.cs" /> <Compile Include="Flight\Readouts\Rendezvous\RelativeVelocity.cs" />
<Compile Include="Flight\Readouts\Rendezvous\SemiMinorAxis.cs" /> <Compile Include="Flight\Readouts\Rendezvous\SemiMinorAxis.cs" />
<Compile Include="Flight\Readouts\Rendezvous\SemiMajorAxis.cs" /> <Compile Include="Flight\Readouts\Rendezvous\SemiMajorAxis.cs" />
<Compile Include="Flight\Readouts\Rendezvous\TimeToRelativeDescendingNode.cs" /> <Compile Include="Flight\Readouts\Rendezvous\TimeToRelativeDescendingNode.cs" />
<Compile Include="Flight\Readouts\Rendezvous\TimeToRelativeAscendingNode.cs" /> <Compile Include="Flight\Readouts\Rendezvous\TimeToRelativeAscendingNode.cs" />
<Compile Include="Flight\Readouts\Surface\ImpactBiome.cs" /> <Compile Include="Flight\Readouts\Surface\ImpactBiome.cs" />
<Compile Include="Flight\Readouts\Surface\Slope.cs" /> <Compile Include="Flight\Readouts\Surface\Slope.cs" />
<Compile Include="Flight\Readouts\Surface\Biome.cs" /> <Compile Include="Flight\Readouts\Surface\Biome.cs" />
<Compile Include="Flight\Readouts\Surface\HorizontalAcceleration.cs" /> <Compile Include="Flight\Readouts\Surface\HorizontalAcceleration.cs" />
<Compile Include="Flight\Readouts\Surface\VerticalAcceleration.cs" /> <Compile Include="Flight\Readouts\Surface\VerticalAcceleration.cs" />
<Compile Include="Flight\Readouts\Surface\MachNumber.cs" /> <Compile Include="Flight\Readouts\Surface\MachNumber.cs" />
<Compile Include="Flight\Readouts\Thermal\CoolestSkinTemperature.cs" /> <Compile Include="Flight\Readouts\Thermal\CoolestSkinTemperature.cs" />
<Compile Include="Flight\Readouts\Thermal\CriticalPart.cs" /> <Compile Include="Flight\Readouts\Thermal\CriticalPart.cs" />
<Compile Include="Flight\Readouts\Thermal\CoolestPart.cs" /> <Compile Include="Flight\Readouts\Thermal\CoolestPart.cs" />
<Compile Include="Flight\Readouts\Thermal\CoolestTemperature.cs" /> <Compile Include="Flight\Readouts\Thermal\CoolestTemperature.cs" />
<Compile Include="Flight\Readouts\Thermal\CriticalThermalPercentage.cs" /> <Compile Include="Flight\Readouts\Thermal\CriticalThermalPercentage.cs" />
<Compile Include="Flight\Readouts\Thermal\CriticalSkinTemperature.cs" /> <Compile Include="Flight\Readouts\Thermal\CriticalSkinTemperature.cs" />
<Compile Include="Flight\Readouts\Thermal\CriticalTemperature.cs" /> <Compile Include="Flight\Readouts\Thermal\CriticalTemperature.cs" />
<Compile Include="Flight\Readouts\Thermal\HottestSkinTemperature.cs" /> <Compile Include="Flight\Readouts\Thermal\HottestSkinTemperature.cs" />
<Compile Include="Flight\Readouts\Thermal\InternalFlux.cs" /> <Compile Include="Flight\Readouts\Thermal\InternalFlux.cs" />
<Compile Include="Flight\Readouts\Thermal\RadiationFlux.cs" /> <Compile Include="Flight\Readouts\Thermal\RadiationFlux.cs" />
<Compile Include="Flight\Readouts\Thermal\ConvectionFlux.cs" /> <Compile Include="Flight\Readouts\Thermal\ConvectionFlux.cs" />
<Compile Include="Flight\Readouts\Thermal\HottestTemperature.cs" /> <Compile Include="Flight\Readouts\Thermal\HottestTemperature.cs" />
<Compile Include="Flight\Readouts\Thermal\HottestPart.cs" /> <Compile Include="Flight\Readouts\Thermal\HottestPart.cs" />
<Compile Include="Flight\Readouts\Thermal\ThermalProcessor.cs" /> <Compile Include="Flight\Readouts\Thermal\ThermalProcessor.cs" />
  <Compile Include="Flight\Readouts\Vessel\Name.cs" />
<Compile Include="Flight\Readouts\Vessel\AttitudeProcessor.cs" /> <Compile Include="Flight\Readouts\Vessel\AttitudeProcessor.cs" />
<Compile Include="Flight\Readouts\Vessel\DeltaVCurrentTotal.cs" /> <Compile Include="Flight\Readouts\Vessel\DeltaVCurrentTotal.cs" />
<Compile Include="Flight\Readouts\Vessel\PitchRate.cs" /> <Compile Include="Flight\Readouts\Vessel\PitchRate.cs" />
<Compile Include="Flight\Readouts\Vessel\HeadingRate.cs" /> <Compile Include="Flight\Readouts\Vessel\HeadingRate.cs" />
<Compile Include="Flight\Readouts\Vessel\RollRate.cs" /> <Compile Include="Flight\Readouts\Vessel\RollRate.cs" />
<Compile Include="Flight\Readouts\Vessel\Roll.cs" /> <Compile Include="Flight\Readouts\Vessel\Roll.cs" />
<Compile Include="Flight\Readouts\Vessel\Pitch.cs" /> <Compile Include="Flight\Readouts\Vessel\Pitch.cs" />
<Compile Include="Flight\Readouts\Vessel\Heading.cs" /> <Compile Include="Flight\Readouts\Vessel\Heading.cs" />
<Compile Include="Flight\Readouts\Vessel\PartCount.cs" /> <Compile Include="Flight\Readouts\Vessel\PartCount.cs" />
<Compile Include="Flight\Readouts\Vessel\SuicideBurnDeltaV.cs" /> <Compile Include="Flight\Readouts\Vessel\SuicideBurnDeltaV.cs" />
<Compile Include="Flight\Readouts\Vessel\SuicideBurnAltitude.cs" /> <Compile Include="Flight\Readouts\Vessel\SuicideBurnAltitude.cs" />
<Compile Include="Flight\Readouts\Vessel\SuicideBurnDistance.cs" /> <Compile Include="Flight\Readouts\Vessel\SuicideBurnDistance.cs" />
<Compile Include="Flight\Readouts\Vessel\DeltaVCurrent.cs" /> <Compile Include="Flight\Readouts\Vessel\DeltaVCurrent.cs" />
<Compile Include="Flight\Readouts\Vessel\IntakeAirUsage.cs" /> <Compile Include="Flight\Readouts\Vessel\IntakeAirUsage.cs" />
<Compile Include="Flight\Readouts\Vessel\IntakeAirDemandSupply.cs" /> <Compile Include="Flight\Readouts\Vessel\IntakeAirDemandSupply.cs" />
<Compile Include="Flight\Readouts\Vessel\IntakeAirSupply.cs" /> <Compile Include="Flight\Readouts\Vessel\IntakeAirSupply.cs" />
<Compile Include="Flight\Readouts\Vessel\IntakeAirDemand.cs" /> <Compile Include="Flight\Readouts\Vessel\IntakeAirDemand.cs" />
<Compile Include="Flight\Readouts\Miscellaneous\SimulationDelay.cs" /> <Compile Include="Flight\Readouts\Miscellaneous\SimulationDelay.cs" />
<Compile Include="Flight\Readouts\Vessel\SimulationProcessor.cs" /> <Compile Include="Flight\Readouts\Vessel\SimulationProcessor.cs" />
<Compile Include="Flight\Readouts\Vessel\Acceleration.cs" /> <Compile Include="Flight\Readouts\Vessel\Acceleration.cs" />
<Compile Include="Flight\Presets\PresetLibrary.cs" /> <Compile Include="Flight\Presets\PresetLibrary.cs" />
<Compile Include="Flight\Readouts\Vessel\SuicideBurnProcessor.cs" /> <Compile Include="Flight\Readouts\Vessel\SuicideBurnProcessor.cs" />
<Compile Include="Flight\Readouts\Vessel\SurfaceThrustToWeight.cs" /> <Compile Include="Flight\Readouts\Vessel\SurfaceThrustToWeight.cs" />
<Compile Include="Flight\Readouts\Surface\Situation.cs" /> <Compile Include="Flight\Readouts\Surface\Situation.cs" />
<Compile Include="Flight\Readouts\Vessel\ThrustOffsetAngle.cs" /> <Compile Include="Flight\Readouts\Vessel\ThrustOffsetAngle.cs" />
<Compile Include="Flight\Readouts\Vessel\ThrustTorque.cs" /> <Compile Include="Flight\Readouts\Vessel\ThrustTorque.cs" />
<Compile Include="GuiDisplaySize.cs" /> <Compile Include="GuiDisplaySize.cs" />
<Compile Include="Helpers\AngleHelper.cs" /> <Compile Include="Helpers\AngleHelper.cs" />
<Compile Include="Helpers\Averager.cs" /> <Compile Include="Helpers\Averager.cs" />
<Compile Include="Helpers\ForceAccumulator.cs" /> <Compile Include="Helpers\ForceAccumulator.cs" />
<Compile Include="Helpers\TextureHelper.cs" /> <Compile Include="Helpers\TextureHelper.cs" />
<Compile Include="Helpers\Units.cs" /> <Compile Include="Helpers\Units.cs" />
<Compile Include="Helpers\TimeFormatter.cs" /> <Compile Include="Helpers\TimeFormatter.cs" />
<Compile Include="KeyBinder.cs" /> <Compile Include="KeyBinder.cs" />
<Compile Include="Control\ControlCentre.cs" /> <Compile Include="Control\ControlCentre.cs" />
<Compile Include="UIControls\DropDown.cs" /> <Compile Include="UIControls\DropDown.cs" />
<Compile Include="Logger.cs" /> <Compile Include="Logger.cs" />
<Compile Include="EngineerGlobals.cs" /> <Compile Include="EngineerGlobals.cs" />
<Compile Include="Extensions\DoubleExtensions.cs" /> <Compile Include="Extensions\DoubleExtensions.cs" />
<Compile Include="Extensions\PartExtensions.cs" /> <Compile Include="Extensions\PartExtensions.cs" />
<Compile Include="Extensions\PartResourceExtensions.cs" /> <Compile Include="Extensions\PartResourceExtensions.cs" />
<Compile Include="Extensions\RectExtensions.cs" /> <Compile Include="Extensions\RectExtensions.cs" />
<Compile Include="Flight\ActionMenu.cs" /> <Compile Include="Flight\ActionMenu.cs" />
<Compile Include="Flight\DisplayStack.cs" /> <Compile Include="Flight\DisplayStack.cs" />
<Compile Include="Flight\FlightEngineerCore.cs" /> <Compile Include="Flight\FlightEngineerCore.cs" />
<Compile Include="Flight\FlightEngineerModule.cs" /> <Compile Include="Flight\FlightEngineerModule.cs" />
<Compile Include="Flight\IUpdatable.cs" /> <Compile Include="Flight\IUpdatable.cs" />
<Compile Include="Flight\IUpdateRequest.cs" /> <Compile Include="Flight\IUpdateRequest.cs" />
<Compile Include="Flight\Readouts\Orbital\ApoapsisHeight.cs" /> <Compile Include="Flight\Readouts\Orbital\ApoapsisHeight.cs" />
<Compile Include="Flight\Readouts\Orbital\Eccentricity.cs" /> <Compile Include="Flight\Readouts\Orbital\Eccentricity.cs" />
<Compile Include="Flight\Readouts\Orbital\Inclination.cs" /> <Compile Include="Flight\Readouts\Orbital\Inclination.cs" />
<Compile Include="Flight\Readouts\Orbital\LongitudeOfAscendingNode.cs" /> <Compile Include="Flight\Readouts\Orbital\LongitudeOfAscendingNode.cs" />
<Compile Include="Flight\Readouts\Orbital\LongitudeOfPeriapsis.cs" /> <Compile Include="Flight\Readouts\Orbital\LongitudeOfPeriapsis.cs" />
<Compile Include="Flight\Readouts\Orbital\OrbitalPeriod.cs" /> <Compile Include="Flight\Readouts\Orbital\OrbitalPeriod.cs" />
<Compile Include="Flight\Readouts\Orbital\OrbitalSpeed.cs" /> <Compile Include="Flight\Readouts\Orbital\OrbitalSpeed.cs" />
<Compile Include="Flight\Readouts\Orbital\PeriapsisHeight.cs" /> <Compile Include="Flight\Readouts\Orbital\PeriapsisHeight.cs" />
<Compile Include="Flight\Readouts\Orbital\SemiMinorAxis.cs" /> <Compile Include="Flight\Readouts\Orbital\SemiMinorAxis.cs" />
<Compile Include="Flight\Readouts\Orbital\TimeToApoapsis.cs" /> <Compile Include="Flight\Readouts\Orbital\TimeToApoapsis.cs" />
<Compile Include="Flight\Readouts\Orbital\TimeToPeriapsis.cs" /> <Compile Include="Flight\Readouts\Orbital\TimeToPeriapsis.cs" />
<Compile Include="Flight\Readouts\ReadoutCategory.cs" /> <Compile Include="Flight\Readouts\ReadoutCategory.cs" />
<Compile Include="Flight\Readouts\ReadoutLibrary.cs" /> <Compile Include="Flight\Readouts\ReadoutLibrary.cs" />
<Compile Include="Flight\Readouts\ReadoutModule.cs" /> <Compile Include="Flight\Readouts\ReadoutModule.cs" />
<Compile Include="Flight\Readouts\Rendezvous\TimeToPeriapsis.cs" /> <Compile Include="Flight\Readouts\Rendezvous\TimeToPeriapsis.cs" />
<Compile Include="Flight\Readouts\Rendezvous\TimeToApoapsis.cs" /> <Compile Include="Flight\Readouts\Rendezvous\TimeToApoapsis.cs" />
<Compile Include="Flight\Readouts\Rendezvous\PeriapsisHeight.cs" /> <Compile Include="Flight\Readouts\Rendezvous\PeriapsisHeight.cs" />
<Compile Include="Flight\Readouts\Rendezvous\ApoapsisHeight.cs" /> <Compile Include="Flight\Readouts\Rendezvous\ApoapsisHeight.cs" />
<Compile Include="Flight\Readouts\Rendezvous\InterceptAngle.cs" /> <Compile Include="Flight\Readouts\Rendezvous\InterceptAngle.cs" />
<Compile Include="Flight\Readouts\Rendezvous\OrbitalPeriod.cs" /> <Compile Include="Flight\Readouts\Rendezvous\OrbitalPeriod.cs" />
<Compile Include="Flight\Readouts\Rendezvous\Distance.cs" /> <Compile Include="Flight\Readouts\Rendezvous\Distance.cs" />
<Compile Include="Flight\Readouts\Rendezvous\AltitudeSeaLevel.cs" /> <Compile Include="Flight\Readouts\Rendezvous\AltitudeSeaLevel.cs" />
<Compile Include="Flight\Readouts\Rendezvous\AngleToRelativeDescendingNode.cs" /> <Compile Include="Flight\Readouts\Rendezvous\AngleToRelativeDescendingNode.cs" />
<Compile Include="Flight\Readouts\Rendezvous\AngleToRelativeAscendingNode.cs" /> <Compile Include="Flight\Readouts\Rendezvous\AngleToRelativeAscendingNode.cs" />
<Compile Include="Flight\Readouts\Rendezvous\PhaseAngle.cs" /> <Compile Include="Flight\Readouts\Rendezvous\PhaseAngle.cs" />
<Compile Include="Flight\Readouts\Rendezvous\RelativeInclination.cs" /> <Compile Include="Flight\Readouts\Rendezvous\RelativeInclination.cs" />
<Compile Include="Flight\Readouts\Rendezvous\RendezvousProcessor.cs" /> <Compile Include="Flight\Readouts\Rendezvous\RendezvousProcessor.cs" />
<Compile Include="Flight\Readouts\Rendezvous\TargetSelector.cs" /> <Compile Include="Flight\Readouts\Rendezvous\TargetSelector.cs" />
<Compile Include="Flight\Readouts\Surface\AltitudeSeaLevel.cs" /> <Compile Include="Flight\Readouts\Surface\AltitudeSeaLevel.cs" />
<Compile Include="Flight\Readouts\Surface\AltitudeTerrain.cs" /> <Compile Include="Flight\Readouts\Surface\AltitudeTerrain.cs" />
<Compile Include="Flight\Readouts\Surface\ImpactLatitude.cs" /> <Compile Include="Flight\Readouts\Surface\ImpactLatitude.cs" />
<Compile Include="Flight\Readouts\Surface\ImpactAltitude.cs" /> <Compile Include="Flight\Readouts\Surface\ImpactAltitude.cs" />
<Compile Include="Flight\Readouts\Surface\ImpactLongitude.cs" /> <Compile Include="Flight\Readouts\Surface\ImpactLongitude.cs" />
<Compile Include="Flight\Readouts\Surface\ImpactTime.cs" /> <Compile Include="Flight\Readouts\Surface\ImpactTime.cs" />
<Compile Include="Flight\Readouts\Surface\AtmosphericProcessor.cs" /> <Compile Include="Flight\Readouts\Surface\AtmosphericProcessor.cs" />
<Compile Include="Flight\Readouts\Surface\AtmosphericEfficiency.cs" /> <Compile Include="Flight\Readouts\Surface\AtmosphericEfficiency.cs" />
<Compile Include="Flight\Readouts\Surface\GeeForce.cs" /> <Compile Include="Flight\Readouts\Surface\GeeForce.cs" />
<Compile Include="Flight\Readouts\Surface\HorizontalSpeed.cs" /> <Compile Include="Flight\Readouts\Surface\HorizontalSpeed.cs" />
<Compile Include="Flight\Readouts\Surface\ImpactProcessor.cs" /> <Compile Include="Flight\Readouts\Surface\ImpactProcessor.cs" />
<Compile Include="Flight\Readouts\Surface\Latitude.cs" /> <Compile Include="Flight\Readouts\Surface\Latitude.cs" />
<Compile Include="Flight\Readouts\Surface\Longitude.cs" /> <Compile Include="Flight\Readouts\Surface\Longitude.cs" />
<Compile Include="Flight\Readouts\Surface\TerminalVelocity.cs" /> <Compile Include="Flight\Readouts\Surface\TerminalVelocity.cs" />
<Compile Include="Flight\Readouts\Surface\VerticalSpeed.cs" /> <Compile Include="Flight\Readouts\Surface\VerticalSpeed.cs" />
<Compile Include="Flight\Readouts\Vessel\DeltaVStaged.cs" /> <Compile Include="Flight\Readouts\Vessel\DeltaVStaged.cs" />
<Compile Include="Flight\Readouts\Vessel\DeltaVTotal.cs" /> <Compile Include="Flight\Readouts\Vessel\DeltaVTotal.cs" />
<Compile Include="Flight\Readouts\Vessel\Mass.cs" /> <Compile Include="Flight\Readouts\Vessel\Mass.cs" />
<Compile Include="Flight\Readouts\Vessel\Thrust.cs" /> <Compile Include="Flight\Readouts\Vessel\Thrust.cs" />
<Compile Include="Flight\Readouts\Vessel\SpecificImpulse.cs" /> <Compile Include="Flight\Readouts\Vessel\SpecificImpulse.cs" />
<Compile Include="Flight\Readouts\Vessel\ThrustToWeight.cs" /> <Compile Include="Flight\Readouts\Vessel\ThrustToWeight.cs" />
<Compile Include="Flight\Sections\SectionEditor.cs" /> <Compile Include="Flight\Sections\SectionEditor.cs" />
<Compile Include="Flight\Sections\SectionLibrary.cs" /> <Compile Include="Flight\Sections\SectionLibrary.cs" />
<Compile Include="Flight\Sections\SectionModule.cs" /> <Compile Include="Flight\Sections\SectionModule.cs" />
<Compile Include="Flight\Sections\SectionWindow.cs" /> <Compile Include="Flight\Sections\SectionWindow.cs" />
<Compile Include="LogMsg.cs" /> <Compile Include="LogMsg.cs" />
<Compile Include="Properties\AssemblyInfo.cs" /> <Compile Include="Properties\AssemblyInfo.cs" />
<Compile Include="Settings\SettingHandler.cs" /> <Compile Include="Settings\SettingHandler.cs" />
<Compile Include="Settings\SettingItem.cs" /> <Compile Include="Settings\SettingItem.cs" />
<Compile Include="TapeDriveAnimator.cs" /> <Compile Include="TapeDriveAnimator.cs" />
<Compile Include="UIControls\WindowObject.cs" /> <Compile Include="UIControls\WindowObject.cs" />
<Compile Include="VesselSimulator\AttachNodeSim.cs" /> <Compile Include="VesselSimulator\AttachNodeSim.cs" />
<Compile Include="VesselSimulator\EngineSim.cs" /> <Compile Include="VesselSimulator\EngineSim.cs" />
<Compile Include="Helpers\Pool.cs" /> <Compile Include="Helpers\Pool.cs" />
<Compile Include="VesselSimulator\PartSim.cs" /> <Compile Include="VesselSimulator\PartSim.cs" />
<Compile Include="VesselSimulator\ResourceContainer.cs" /> <Compile Include="VesselSimulator\ResourceContainer.cs" />
<Compile Include="VesselSimulator\SimManager.cs" /> <Compile Include="VesselSimulator\SimManager.cs" />
<Compile Include="VesselSimulator\Simulation.cs" /> <Compile Include="VesselSimulator\Simulation.cs" />
<Compile Include="VesselSimulator\Stage.cs" /> <Compile Include="VesselSimulator\Stage.cs" />
  <Compile Include="Flight\Readouts\Rendezvous\RelativeRadialVelocity.cs" />
  <Compile Include="Flight\Readouts\Rendezvous\TimeToRendezvous.cs" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<Reference Include="Assembly-CSharp"> <Reference Include="Assembly-CSharp">
<HintPath>..\Game\KSP_Data\Managed\Assembly-CSharp.dll</HintPath> <HintPath>..\Game\KSP_Data\Managed\Assembly-CSharp.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="System"> <Reference Include="System">
<HintPath>..\Game\KSP_Data\Managed\System.dll</HintPath> <HintPath>..\Game\KSP_Data\Managed\System.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="System.Xml"> <Reference Include="System.Xml">
<HintPath>..\Game\KSP_Data\Managed\System.Xml.dll</HintPath> <HintPath>..\Game\KSP_Data\Managed\System.Xml.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
<Reference Include="UnityEngine"> <Reference Include="UnityEngine">
<HintPath>..\Game\KSP_Data\Managed\UnityEngine.dll</HintPath> <HintPath>..\Game\KSP_Data\Managed\UnityEngine.dll</HintPath>
<Private>False</Private> <Private>False</Private>
</Reference> </Reference>
</ItemGroup> </ItemGroup>
<ItemGroup /> <ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> <Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
<Target Name="PostBuildMacros"> <Target Name="PostBuildMacros">
<GetAssemblyIdentity AssemblyFiles="$(TargetPath)"> <GetAssemblyIdentity AssemblyFiles="$(TargetPath)">
<Output TaskParameter="Assemblies" ItemName="Targets" /> <Output TaskParameter="Assemblies" ItemName="Targets" />
</GetAssemblyIdentity> </GetAssemblyIdentity>
<ItemGroup> <ItemGroup>
<VersionNumber Include="@(Targets->'%(Version)')" /> <VersionNumber Include="@(Targets->'%(Version)')" />
</ItemGroup> </ItemGroup>
</Target> </Target>
<PropertyGroup> <PropertyGroup>
<PostBuildEventDependsOn> <PostBuildEventDependsOn>
$(PostBuildEventDependsOn); $(PostBuildEventDependsOn);
PostBuildMacros; PostBuildMacros;
</PostBuildEventDependsOn> </PostBuildEventDependsOn>
<PostBuildEvent>xcopy "$(SolutionDir)Output\*" "$(SolutionDir)Game\GameData\*" /E /Y <PostBuildEvent>xcopy "$(SolutionDir)Output\*" "$(SolutionDir)Game\GameData\*" /E /Y
del "$(SolutionDir)Release\*" /Q del "$(SolutionDir)Release\*" /Q
xcopy "$(SolutionDir)Documents\*" "$(SolutionDir)Release\Documents\*" /E /Y xcopy "$(SolutionDir)Documents\*" "$(SolutionDir)Release\Documents\*" /E /Y
7z.exe a -tzip -mx3 "$(SolutionDir)Release\$(ProjectName)-@(VersionNumber).zip" "$(SolutionDir)Output\*" 7z.exe a -tzip -mx3 "$(SolutionDir)Release\$(ProjectName)-@(VersionNumber).zip" "$(SolutionDir)Output\*"
7z.exe a -tzip -mx3 "$(SolutionDir)Release\$(ProjectName)-@(VersionNumber).zip" "$(SolutionDir)Documents\*"</PostBuildEvent> 7z.exe a -tzip -mx3 "$(SolutionDir)Release\$(ProjectName)-@(VersionNumber).zip" "$(SolutionDir)Documents\*"</PostBuildEvent>
</PropertyGroup> </PropertyGroup>
<!-- To modify your build process, add your task inside one of the targets below and uncomment it. <!-- To modify your build process, add your task inside one of the targets below and uncomment it.
Other similar extension points exist, see Microsoft.Common.targets. Other similar extension points exist, see Microsoft.Common.targets.
<Target Name="BeforeBuild"> <Target Name="BeforeBuild">
</Target> </Target>
<Target Name="AfterBuild"> <Target Name="AfterBuild">
</Target> </Target>
--> -->
</Project> </Project>
// //
// Kerbal Engineer Redux // Kerbal Engineer Redux
// //
// Copyright (C) 2014 CYBUTEK // Copyright (C) 2014 CYBUTEK
// //
// This program is free software: you can redistribute it and/or modify // 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 // it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or // the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version. // (at your option) any later version.
// //
// This program is distributed in the hope that it will be useful, // This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of // but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details. // GNU General Public License for more details.
// //
// You should have received a copy of the GNU General Public License // You should have received a copy of the GNU General Public License
// along with this program. If not, see <http://www.gnu.org/licenses/>. // along with this program. If not, see <http://www.gnu.org/licenses/>.
// //
   
namespace KerbalEngineer.VesselSimulator namespace KerbalEngineer.VesselSimulator
{ {
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Text; using System.Text;
using Editor; using Editor;
using Helpers; using Helpers;
using UnityEngine; using UnityEngine;
   
public class EngineSim public class EngineSim
{ {
private static readonly Pool<EngineSim> pool = new Pool<EngineSim>(Create, Reset); private static readonly Pool<EngineSim> pool = new Pool<EngineSim>(Create, Reset);
   
private readonly ResourceContainer resourceConsumptions = new ResourceContainer(); private readonly ResourceContainer resourceConsumptions = new ResourceContainer();
private readonly ResourceContainer resourceFlowModes = new ResourceContainer(); private readonly ResourceContainer resourceFlowModes = new ResourceContainer();
   
public double actualThrust = 0; public double actualThrust = 0;
public bool isActive = false; public bool isActive = false;
public double isp = 0; public double isp = 0;
public PartSim partSim; public PartSim partSim;
public List<AppliedForce> appliedForces = new List<AppliedForce>(); public List<AppliedForce> appliedForces = new List<AppliedForce>();
public float maxMach; public float maxMach;
   
public double thrust = 0; public double thrust = 0;
   
// Add thrust vector to account for directional losses // Add thrust vector to account for directional losses
public Vector3 thrustVec; public Vector3 thrustVec;
   
private static EngineSim Create() private static EngineSim Create()
{ {
return new EngineSim(); return new EngineSim();
} }
   
private static void Reset(EngineSim engineSim) private static void Reset(EngineSim engineSim)
{ {
engineSim.resourceConsumptions.Reset(); engineSim.resourceConsumptions.Reset();
engineSim.resourceFlowModes.Reset(); engineSim.resourceFlowModes.Reset();
engineSim.actualThrust = 0; engineSim.actualThrust = 0;
engineSim.isActive = false; engineSim.isActive = false;
engineSim.isp = 0; engineSim.isp = 0;
for (int i = 0; i < engineSim.appliedForces.Count; i++) for (int i = 0; i < engineSim.appliedForces.Count; i++)
{ {
engineSim.appliedForces[i].Release(); engineSim.appliedForces[i].Release();
} }
engineSim.appliedForces.Clear(); engineSim.appliedForces.Clear();
engineSim.thrust = 0; engineSim.thrust = 0;
engineSim.maxMach = 0f; engineSim.maxMach = 0f;
} }
   
public void Release() public void Release()
{ {
pool.Release(this); pool.Release(this);
} }
   
public static EngineSim New(PartSim theEngine, public static EngineSim New(PartSim theEngine,
double atmosphere, double atmosphere,
float machNumber, float machNumber,
float maxFuelFlow, float maxFuelFlow,
float minFuelFlow, float minFuelFlow,
float thrustPercentage, float thrustPercentage,
Vector3 vecThrust, Vector3 vecThrust,
FloatCurve atmosphereCurve, FloatCurve atmosphereCurve,
bool atmChangeFlow, bool atmChangeFlow,
FloatCurve atmCurve, FloatCurve atmCurve,
FloatCurve velCurve, FloatCurve velCurve,
float currentThrottle, float currentThrottle,
float IspG, float IspG,
bool throttleLocked, bool throttleLocked,
List<Propellant> propellants, List<Propellant> propellants,
bool active, bool active,
float resultingThrust, float resultingThrust,
List<Transform> thrustTransforms, List<Transform> thrustTransforms,
LogMsg log) LogMsg log)
{ {
EngineSim engineSim = pool.Borrow(); EngineSim engineSim = pool.Borrow();
   
engineSim.isp = 0.0; engineSim.isp = 0.0;
engineSim.maxMach = 0.0f; engineSim.maxMach = 0.0f;
engineSim.actualThrust = 0.0; engineSim.actualThrust = 0.0;
engineSim.partSim = theEngine; engineSim.partSim = theEngine;
engineSim.isActive = active; engineSim.isActive = active;
engineSim.thrustVec = vecThrust; engineSim.thrustVec = vecThrust;
engineSim.resourceConsumptions.Reset(); engineSim.resourceConsumptions.Reset();
engineSim.resourceFlowModes.Reset(); engineSim.resourceFlowModes.Reset();
engineSim.appliedForces.Clear(); engineSim.appliedForces.Clear();
   
double flowRate = 0.0; double flowRate = 0.0;
if (engineSim.partSim.hasVessel) if (engineSim.partSim.hasVessel)
{ {
if (log != null) log.buf.AppendLine("hasVessel is true"); if (log != null) log.buf.AppendLine("hasVessel is true");
   
float flowModifier = GetFlowModifier(atmChangeFlow, atmCurve, engineSim.partSim.part.atmDensity, velCurve, machNumber, ref engineSim.maxMach); float flowModifier = GetFlowModifier(atmChangeFlow, atmCurve, engineSim.partSim.part.atmDensity, velCurve, machNumber, ref engineSim.maxMach);
engineSim.isp = atmosphereCurve.Evaluate((float)atmosphere); engineSim.isp = atmosphereCurve.Evaluate((float)atmosphere);
engineSim.thrust = GetThrust(Mathf.Lerp(minFuelFlow, maxFuelFlow, GetThrustPercent(thrustPercentage)) * flowModifier, engineSim.isp); engineSim.thrust = GetThrust(Mathf.Lerp(minFuelFlow, maxFuelFlow, GetThrustPercent(thrustPercentage)) * flowModifier, engineSim.isp);
engineSim.actualThrust = engineSim.isActive ? resultingThrust : 0.0; engineSim.actualThrust = engineSim.isActive ? resultingThrust : 0.0;
if (log != null) if (log != null)
{ {
log.buf.AppendFormat("flowMod = {0:g6}\n", flowModifier); log.buf.AppendFormat("flowMod = {0:g6}\n", flowModifier);
log.buf.AppendFormat("isp = {0:g6}\n", engineSim.isp); log.buf.AppendFormat("isp = {0:g6}\n", engineSim.isp);
log.buf.AppendFormat("thrust = {0:g6}\n", engineSim.thrust); log.buf.AppendFormat("thrust = {0:g6}\n", engineSim.thrust);
log.buf.AppendFormat("actual = {0:g6}\n", engineSim.actualThrust); log.buf.AppendFormat("actual = {0:g6}\n", engineSim.actualThrust);
} }
   
if (throttleLocked) if (throttleLocked)
{ {
if (log != null) log.buf.AppendLine("throttleLocked is true, using thrust for flowRate"); if (log != null) log.buf.AppendLine("throttleLocked is true, using thrust for flowRate");
flowRate = GetFlowRate(engineSim.thrust, engineSim.isp); flowRate = GetFlowRate(engineSim.thrust, engineSim.isp);
} }
else else
{ {
if (currentThrottle > 0.0f && engineSim.partSim.isLanded == false) if (currentThrottle > 0.0f && engineSim.partSim.isLanded == false)
{ {
if (log != null) log.buf.AppendLine("throttled up and not landed, using actualThrust for flowRate"); if (log != null) log.buf.AppendLine("throttled up and not landed, using actualThrust for flowRate");
flowRate = GetFlowRate(engineSim.actualThrust, engineSim.isp); flowRate = GetFlowRate(engineSim.actualThrust, engineSim.isp);
} }
else else
{ {
if (log != null) log.buf.AppendLine("throttled down or landed, using thrust for flowRate"); if (log != null) log.buf.AppendLine("throttled down or landed, using thrust for flowRate");
flowRate = GetFlowRate(engineSim.thrust, engineSim.isp); flowRate = GetFlowRate(engineSim.thrust, engineSim.isp);
} }
} }
} }
else else
{ {
if (log != null) log.buf.AppendLine("hasVessel is false"); if (log != null) log.buf.AppendLine("hasVessel is false");
float flowModifier = GetFlowModifier(atmChangeFlow, atmCurve, CelestialBodies.SelectedBody.GetDensity(BuildAdvanced.Altitude), velCurve, machNumber, ref engineSim.maxMach); float flowModifier = GetFlowModifier(atmChangeFlow, atmCurve, CelestialBodies.SelectedBody.GetDensity(BuildAdvanced.Altitude), velCurve, machNumber, ref engineSim.maxMach);
engineSim.isp = atmosphereCurve.Evaluate((float)atmosphere); engineSim.isp = atmosphereCurve.Evaluate((float)atmosphere);
engineSim.thrust = GetThrust(Mathf.Lerp(minFuelFlow, maxFuelFlow, GetThrustPercent(thrustPercentage)) * flowModifier, engineSim.isp); engineSim.thrust = GetThrust(Mathf.Lerp(minFuelFlow, maxFuelFlow, GetThrustPercent(thrustPercentage)) * flowModifier, engineSim.isp);
engineSim.actualThrust = 0d; engineSim.actualThrust = 0d;
if (log != null) if (log != null)
{ {
log.buf.AppendFormat("flowMod = {0:g6}\n", flowModifier); log.buf.AppendFormat("flowMod = {0:g6}\n", flowModifier);
log.buf.AppendFormat("isp = {0:g6}\n", engineSim.isp); log.buf.AppendFormat("isp = {0:g6}\n", engineSim.isp);
log.buf.AppendFormat("thrust = {0:g6}\n", engineSim.thrust); log.buf.AppendFormat("thrust = {0:g6}\n", engineSim.thrust);
log.buf.AppendFormat("actual = {0:g6}\n", engineSim.actualThrust); log.buf.AppendFormat("actual = {0:g6}\n", engineSim.actualThrust);
} }
   
if (log != null) log.buf.AppendLine("no vessel, using thrust for flowRate"); if (log != null) log.buf.AppendLine("no vessel, using thrust for flowRate");
flowRate = GetFlowRate(engineSim.thrust, engineSim.isp); flowRate = GetFlowRate(engineSim.thrust, engineSim.isp);
} }
   
if (log != null) log.buf.AppendFormat("flowRate = {0:g6}\n", flowRate); if (log != null) log.buf.AppendFormat("flowRate = {0:g6}\n", flowRate);
   
float flowMass = 0f; float flowMass = 0f;
for (int i = 0; i < propellants.Count; ++i) for (int i = 0; i < propellants.Count; ++i)
{ {
Propellant propellant = propellants[i]; Propellant propellant = propellants[i];
if (!propellant.ignoreForIsp) if (!propellant.ignoreForIsp)
flowMass += propellant.ratio * ResourceContainer.GetResourceDensity(propellant.id); flowMass += propellant.ratio * ResourceContainer.GetResourceDensity(propellant.id);
} }
   
if (log != null) log.buf.AppendFormat("flowMass = {0:g6}\n", flowMass); if (log != null) log.buf.AppendFormat("flowMass = {0:g6}\n", flowMass);
   
for (int i = 0; i < propellants.Count; ++i) for (int i = 0; i < propellants.Count; ++i)
{ {
Propellant propellant = propellants[i]; Propellant propellant = propellants[i];
   
if (propellant.name == "ElectricCharge" || propellant.name == "IntakeAir") if (propellant.name == "ElectricCharge" || propellant.name == "IntakeAir")
{ {
continue; continue;
} }
   
double consumptionRate = propellant.ratio * flowRate / flowMass; double consumptionRate = propellant.ratio * flowRate / flowMass;
if (log != null) log.buf.AppendFormat( if (log != null) log.buf.AppendFormat(
"Add consumption({0}, {1}:{2:d}) = {3:g6}\n", "Add consumption({0}, {1}:{2:d}) = {3:g6}\n",
ResourceContainer.GetResourceName(propellant.id), ResourceContainer.GetResourceName(propellant.id),
theEngine.name, theEngine.name,
theEngine.partId, theEngine.partId,
consumptionRate); consumptionRate);
engineSim.resourceConsumptions.Add(propellant.id, consumptionRate); engineSim.resourceConsumptions.Add(propellant.id, consumptionRate);
engineSim.resourceFlowModes.Add(propellant.id, (double)propellant.GetFlowMode()); engineSim.resourceFlowModes.Add(propellant.id, (double)propellant.GetFlowMode());
} }
   
double thrustPerThrustTransform = engineSim.thrust / thrustTransforms.Count; double thrustPerThrustTransform = engineSim.thrust / thrustTransforms.Count;
for (int i = 0; i < thrustTransforms.Count; i++) for (int i = 0; i < thrustTransforms.Count; i++)
{ {
Transform thrustTransform = thrustTransforms[i]; Transform thrustTransform = thrustTransforms[i];
Vector3d direction = thrustTransform.forward.normalized; Vector3d direction = thrustTransform.forward.normalized;
Vector3d position = thrustTransform.position; Vector3d position = thrustTransform.position;
   
AppliedForce appliedForce = AppliedForce.New(direction * thrustPerThrustTransform, position); AppliedForce appliedForce = AppliedForce.New(direction * thrustPerThrustTransform, position);
engineSim.appliedForces.Add(appliedForce); engineSim.appliedForces.Add(appliedForce);
} }
   
return engineSim; return engineSim;
} }
   
public ResourceContainer ResourceConsumptions public ResourceContainer ResourceConsumptions
{ {
get get
{ {
return resourceConsumptions; return resourceConsumptions;
} }
} }
   
public static double GetExhaustVelocity(double isp) public static double GetExhaustVelocity(double isp)
{ {
return isp * Units.GRAVITY; return isp * Units.GRAVITY;
} }
   
public static float GetFlowModifier(bool atmChangeFlow, FloatCurve atmCurve, double atmDensity, FloatCurve velCurve, float machNumber, ref float maxMach) public static float GetFlowModifier(bool atmChangeFlow, FloatCurve atmCurve, double atmDensity, FloatCurve velCurve, float machNumber, ref float maxMach)
{ {
float flowModifier = 1.0f; float flowModifier = 1.0f;
if (atmChangeFlow) if (atmChangeFlow)
{ {
flowModifier = (float)(atmDensity / 1.225); flowModifier = (float)(atmDensity / 1.225);
if (atmCurve != null) if (atmCurve != null)
{ {
flowModifier = atmCurve.Evaluate(flowModifier); flowModifier = atmCurve.Evaluate(flowModifier);
} }
} }
if (velCurve != null) if (velCurve != null)
{ {
flowModifier = flowModifier * velCurve.Evaluate(machNumber); flowModifier = flowModifier * velCurve.Evaluate(machNumber);
maxMach = velCurve.maxTime; maxMach = velCurve.maxTime;
} }
if (flowModifier < float.Epsilon) if (flowModifier < float.Epsilon)
{ {
flowModifier = float.Epsilon; flowModifier = float.Epsilon;
} }
return flowModifier; return flowModifier;
} }
   
public static double GetFlowRate(double thrust, double isp) public static double GetFlowRate(double thrust, double isp)
{ {
return thrust / GetExhaustVelocity(isp); return thrust / GetExhaustVelocity(isp);
} }
   
public static float GetThrottlePercent(float currentThrottle, float thrustPercentage) public static float GetThrottlePercent(float currentThrottle, float thrustPercentage)
{ {
return currentThrottle * GetThrustPercent(thrustPercentage); return currentThrottle * GetThrustPercent(thrustPercentage);
} }
   
public static double GetThrust(double flowRate, double isp) public static double GetThrust(double flowRate, double isp)
{ {
return flowRate * GetExhaustVelocity(isp); return flowRate * GetExhaustVelocity(isp);
} }
   
public static float GetThrustPercent(float thrustPercentage) public static float GetThrustPercent(float thrustPercentage)
{ {
return thrustPercentage * 0.01f; return thrustPercentage * 0.01f;
} }
   
public void DumpEngineToBuffer(StringBuilder buffer, String prefix) public void DumpEngineToBuffer(StringBuilder buffer, String prefix)
{ {
buffer.Append(prefix); buffer.Append(prefix);
buffer.AppendFormat("[thrust = {0:g6}, actual = {1:g6}, isp = {2:g6}\n", thrust, actualThrust, isp); buffer.AppendFormat("[thrust = {0:g6}, actual = {1:g6}, isp = {2:g6}\n", thrust, actualThrust, isp);
} }
   
// A dictionary to hold a set of parts for each resource // A dictionary to hold a set of parts for each resource
Dictionary<int, HashSet<PartSim>> sourcePartSets = new Dictionary<int, HashSet<PartSim>>(); Dictionary<int, HashSet<PartSim>> sourcePartSets = new Dictionary<int, HashSet<PartSim>>();
   
Dictionary<int, HashSet<PartSim>> stagePartSets = new Dictionary<int, HashSet<PartSim>>(); Dictionary<int, HashSet<PartSim>> stagePartSets = new Dictionary<int, HashSet<PartSim>>();
   
HashSet<PartSim> visited = new HashSet<PartSim>(); HashSet<PartSim> visited = new HashSet<PartSim>();
   
  public void DumpSourcePartSets(String msg)
  {
  MonoBehaviour.print("DumpSourcePartSets " + msg);
  foreach (int type in sourcePartSets.Keys)
  {
  MonoBehaviour.print("SourcePartSet for " + ResourceContainer.GetResourceName(type));
  HashSet<PartSim> 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<PartSim> allParts, List<PartSim> allFuelLines, HashSet<PartSim> drainingParts) public bool SetResourceDrains(List<PartSim> allParts, List<PartSim> allFuelLines, HashSet<PartSim> drainingParts)
{ {
LogMsg log = null; LogMsg log = null;
  //DumpSourcePartSets("before clear");
foreach (HashSet<PartSim> sourcePartSet in sourcePartSets.Values) foreach (HashSet<PartSim> sourcePartSet in sourcePartSets.Values)
{ {
sourcePartSet.Clear(); sourcePartSet.Clear();
} }
  //DumpSourcePartSets("after clear");
   
for (int index = 0; index < this.resourceConsumptions.Types.Count; index++) for (int index = 0; index < this.resourceConsumptions.Types.Count; index++)
{ {
int type = this.resourceConsumptions.Types[index]; int type = this.resourceConsumptions.Types[index];
   
HashSet<PartSim> sourcePartSet; HashSet<PartSim> sourcePartSet;
if (!sourcePartSets.TryGetValue(type, out sourcePartSet)) if (!sourcePartSets.TryGetValue(type, out sourcePartSet))
{ {
sourcePartSet = new HashSet<PartSim>(); sourcePartSet = new HashSet<PartSim>();
sourcePartSets.Add(type, sourcePartSet); sourcePartSets.Add(type, sourcePartSet);
} }
   
switch ((ResourceFlowMode)this.resourceFlowModes[type]) switch ((ResourceFlowMode)this.resourceFlowModes[type])
{ {
case ResourceFlowMode.NO_FLOW: case ResourceFlowMode.NO_FLOW:
if (partSim.resources[type] > SimManager.RESOURCE_MIN && partSim.resourceFlowStates[type] != 0) if (partSim.resources[type] > SimManager.RESOURCE_MIN && partSim.resourceFlowStates[type] != 0)
{ {
//sourcePartSet = new HashSet<PartSim>(); //sourcePartSet = new HashSet<PartSim>();
//MonoBehaviour.print("SetResourceDrains(" + name + ":" + partId + ") setting sources to just this"); //MonoBehaviour.print("SetResourceDrains(" + name + ":" + partId + ") setting sources to just this");
sourcePartSet.Add(partSim); sourcePartSet.Add(partSim);
} }
break; break;
   
case ResourceFlowMode.ALL_VESSEL: case ResourceFlowMode.ALL_VESSEL:
for (int i = 0; i < allParts.Count; i++) for (int i = 0; i < allParts.Count; i++)
{ {
PartSim aPartSim = allParts[i]; PartSim aPartSim = allParts[i];
if (aPartSim.resources[type] > SimManager.RESOURCE_MIN && aPartSim.resourceFlowStates[type] != 0) if (aPartSim.resources[type] > SimManager.RESOURCE_MIN && aPartSim.resourceFlowStates[type] != 0)
{ {
sourcePartSet.Add(aPartSim); sourcePartSet.Add(aPartSim);
} }
} }
break; break;
   
case ResourceFlowMode.STAGE_PRIORITY_FLOW: case ResourceFlowMode.STAGE_PRIORITY_FLOW:
   
foreach (HashSet<PartSim> stagePartSet in stagePartSets.Values) foreach (HashSet<PartSim> stagePartSet in stagePartSets.Values)
{ {
stagePartSet.Clear(); stagePartSet.Clear();
} }
var maxStage = -1; var maxStage = -1;
   
//Logger.Log(type); //Logger.Log(type);
for (int i = 0; i < allParts.Count; i++) for (int i = 0; i < allParts.Count; i++)
{ {
var aPartSim = allParts[i]; var aPartSim = allParts[i];
if (aPartSim.resources[type] <= SimManager.RESOURCE_MIN || aPartSim.resourceFlowStates[type] == 0) if (aPartSim.resources[type] <= SimManager.RESOURCE_MIN || aPartSim.resourceFlowStates[type] == 0)
{ {
continue; continue;
} }
   
int stage = aPartSim.DecouplerCount(); int stage = aPartSim.DecouplerCount();
if (stage > maxStage) if (stage > maxStage)
{ {
maxStage = stage; maxStage = stage;
} }
   
if (!stagePartSets.TryGetValue(stage, out sourcePartSet)) HashSet<PartSim> tempPartSet;
  if (!stagePartSets.TryGetValue(stage, out tempPartSet))
{ {
sourcePartSet = new HashSet<PartSim>(); tempPartSet = new HashSet<PartSim>();
stagePartSets.Add(stage, sourcePartSet); stagePartSets.Add(stage, tempPartSet);
} }
sourcePartSet.Add(aPartSim); tempPartSet.Add(aPartSim);
} }
   
for (int j = 0; j <= maxStage; j++) for (int j = maxStage; j >= 0; j--)
{ {
HashSet<PartSim> stagePartSet; HashSet<PartSim> stagePartSet;
if (stagePartSets.TryGetValue(j, out stagePartSet) && stagePartSet.Count > 0) 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; break;
   
case ResourceFlowMode.STACK_PRIORITY_SEARCH: case ResourceFlowMode.STACK_PRIORITY_SEARCH:
visited.Clear(); visited.Clear();
   
if (SimManager.logOutput) if (SimManager.logOutput)
{ {
log = new LogMsg(); log = new LogMsg();
log.buf.AppendLine("Find " + ResourceContainer.GetResourceName(type) + " sources for " + partSim.name + ":" + partSim.partId); log.buf.AppendLine("Find " + ResourceContainer.GetResourceName(type) + " sources for " + partSim.name + ":" + partSim.partId);
} }
partSim.GetSourceSet(type, allParts, visited, sourcePartSet, log, ""); partSim.GetSourceSet(type, allParts, visited, sourcePartSet, log, "");
if (SimManager.logOutput) if (SimManager.logOutput)
{ {
MonoBehaviour.print(log.buf); MonoBehaviour.print(log.buf);
} }
break; break;
   
default: default:
MonoBehaviour.print("SetResourceDrains(" + partSim.name + ":" + partSim.partId + ") Unexpected flow type for " + ResourceContainer.GetResourceName(type) + ")"); MonoBehaviour.print("SetResourceDrains(" + partSim.name + ":" + partSim.partId + ") Unexpected flow type for " + ResourceContainer.GetResourceName(type) + ")");
break; break;
} }
   
  if (SimManager.logOutput)
if (sourcePartSet.Count > 0) {
{ if (sourcePartSet.Count > 0)
sourcePartSets[type] = sourcePartSet;  
if (SimManager.logOutput)  
{ {
log = new LogMsg(); log = new LogMsg();
log.buf.AppendLine("Source parts for " + ResourceContainer.GetResourceName(type) + ":"); log.buf.AppendLine("Source parts for " + ResourceContainer.GetResourceName(type) + ":");
foreach (PartSim partSim in sourcePartSet) foreach (PartSim partSim in sourcePartSet)
{ {
log.buf.AppendLine(partSim.name + ":" + partSim.partId); log.buf.AppendLine(partSim.name + ":" + partSim.partId);
} }
MonoBehaviour.print(log.buf); 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 // If we don't have sources for all the needed resources then return false without setting up any drains
for (int i = 0; i < this.resourceConsumptions.Types.Count; i++) for (int i = 0; i < this.resourceConsumptions.Types.Count; i++)
{ {
int type = this.resourceConsumptions.Types[i]; int type = this.resourceConsumptions.Types[i];
HashSet<PartSim> sourcePartSet; HashSet<PartSim> sourcePartSet;
if (!sourcePartSets.TryGetValue(type, out sourcePartSet) || sourcePartSet.Count == 0) if (!sourcePartSets.TryGetValue(type, out sourcePartSet) || sourcePartSet.Count == 0)
{ {
if (SimManager.logOutput) if (SimManager.logOutput)
{ {
MonoBehaviour.print("No source of " + ResourceContainer.GetResourceName(type)); MonoBehaviour.print("No source of " + ResourceContainer.GetResourceName(type));
} }
   
isActive = false; isActive = false;
return false; return false;
} }
} }
   
// Now we set the drains on the members of the sets and update the draining parts set // 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++) for (int i = 0; i < this.resourceConsumptions.Types.Count; i++)
{ {
int type = this.resourceConsumptions.Types[i]; int type = this.resourceConsumptions.Types[i];
HashSet<PartSim> sourcePartSet = sourcePartSets[type]; HashSet<PartSim> sourcePartSet = sourcePartSets[type];
// Loop through the members of the set // Loop through the members of the set
double amount = resourceConsumptions[type] / sourcePartSet.Count; double amount = resourceConsumptions[type] / sourcePartSet.Count;
foreach (PartSim partSim in sourcePartSet) foreach (PartSim partSim in sourcePartSet)
{ {
if (SimManager.logOutput) if (SimManager.logOutput)
{ {
MonoBehaviour.print( MonoBehaviour.print(
"Adding drain of " + amount + " " + ResourceContainer.GetResourceName(type) + " to " + partSim.name + ":" + "Adding drain of " + amount + " " + ResourceContainer.GetResourceName(type) + " to " + partSim.name + ":" +
partSim.partId); partSim.partId);
} }
   
partSim.resourceDrains.Add(type, amount); partSim.resourceDrains.Add(type, amount);
drainingParts.Add(partSim); drainingParts.Add(partSim);
} }
} }
return true; return true;
} }
} }
} }
 Binary files a/Output/KerbalEngineer/KerbalEngineer.dll and b/Output/KerbalEngineer/KerbalEngineer.dll differ