Full IUpdatable & IUpdateRequest integration with padishar's simulation.
[VesselSimulator.git] / KerbalEngineer / Flight / Readouts / Vessel / ThrustToWeight.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
// Project:  KerbalEngineer
// Author:      CYBUTEK
// License:     Attribution-NonCommercial-ShareAlike 3.0 Unported
 
#region Using Directives
 
using KerbalEngineer.Simulation;
 
#endregion
 
namespace KerbalEngineer.Flight.Readouts.Vessel
{
    public class ThrustToWeight : ReadoutModule
    {
        private string actual = string.Empty;
        private string total = string.Empty;
 
        public ThrustToWeight()
        {
            this.Name = "Thrust to Weight Ratio";
            this.Category = ReadoutCategory.Vessel;
            this.HelpString = "Shows the vessel's actual and total thrust to weight ratio.";
        }
 
        public override void Update()
        {
            SimManager.RequestUpdate();
        }
 
        public override void Draw()
        {
            this.actual = (SimManager.LastStage.actualThrust / (SimManager.LastStage.totalMass * FlightGlobals.getGeeForceAtPosition(FlightGlobals.ship_position).magnitude)).ToString("F2");
            this.total = (SimManager.LastStage.thrust / (SimManager.LastStage.totalMass * FlightGlobals.getGeeForceAtPosition(FlightGlobals.ship_position).magnitude)).ToString("F2");
            this.DrawLine("TWR", this.actual + " / " + this.total);
        }
 
        public override void Reset()
        {
            FlightEngineerCore.Instance.AddUpdatable(SimManager.Instance);
        }
    }
}