Added simulation processor to fix flickering.
[VesselSimulator.git] / KerbalEngineer / Flight / Readouts / Vessel / SimulationProcessor.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
using KerbalEngineer.VesselSimulator;
 
namespace KerbalEngineer.Flight.Readouts.Vessel
{
    public class SimulationProcessor : IUpdatable, IUpdateRequest
    {
        #region Instance
        private static readonly SimulationProcessor instance = new SimulationProcessor();
 
        /// <summary>
        ///     Gets the current instance of the simulation processor.
        /// </summary>
        public static SimulationProcessor Instance
        {
            get { return instance; }
        }
        #endregion
 
        #region Properies
 
        /// <summary>
        ///     Gets whether the details are ready to be shown.
        /// </summary>
        public static bool ShowDetails { get; private set; }
 
        /// <summary>
        ///     Gets an array of the vessel stages.
        /// </summary>
        public static Stage[] Stages { get; private set; }
 
        /// <summary>
        ///     Gets the currently active vessel stage.
        /// </summary>
        public static Stage LastStage { get; private set; }
 
        #endregion
 
        public void Update()
        {
            SimManager.RequestSimulation();
            if (!SimManager.ResultsReady())
            {
                return;
            }
 
            Stages = SimManager.Stages;
            LastStage = SimManager.LastStage;
 
            if (Stages != null && LastStage != null)
            {
                ShowDetails = true;
            }
        }
 
        public bool UpdateRequested { get; set; }
 
        public static void RequestUpdate()
        {
            instance.UpdateRequested = true;
        }
    }
}