private void InitSession()
        {
            CurrentGroundSpeed     = 0;
            _numberOfSpeedReadings = 0;
            _totalOfSpeedReadings  = 0;
            AverageGroundSpeed     = 0;
            MaximumGroundSpeed     = 0;
            MaximumAltitude        = 0;
            SpeedAltitudeAdjusted  = 0;
            TotalDistanceTravelled = 0;
            TotalShipRepairs       = 0;
            TotalSynthRepairs      = 0;
            SessionStartTime       = DateTime.Now;
            SessionStartLocation   = null;
            TotalSRVsDestroyed     = 0;

            _telemetry.Clear();
            _telemetry.Add("CurrentGroundSpeed", CurrentGroundSpeed.ToString());
            _telemetry.Add("CurrentHeading", "Unknown");
            _telemetry.Add("HullStrength", $"{(HullHealth * 100).ToString("F1")}%");
            _telemetry.Add("AverageGroundSpeed", AverageGroundSpeed.ToString());
            _telemetry.Add("MaximumGroundSpeed", MaximumGroundSpeed.ToString());
            _telemetry.Add("DistanceFromStart", "0m");
            _telemetry.Add("TotalDistanceTravelled", TotalDistanceTravelled.ToString("F1"));
            _telemetry.Add("TotalShipRepairs", TotalShipRepairs.ToString());
            _telemetry.Add("TotalSynthRepairs", TotalSynthRepairs.ToString());
            _telemetry.Add("TotalSRVsDestroyed", "0");
            _telemetry.Add("SessionStartTime", "");
            _telemetry.Add("SessionDate", "");
            _telemetry.Add("SessionTime", "00:00:00");
            _telemetry.Add("CurrentAltitude", "0");
            _telemetry.Add("MaximumAltitude", "0");
            _telemetry.Add("SpeedAltitudeAdjusted", SpeedAltitudeAdjusted.ToString());
            _telemetry.Add("MaximumSpeedAltitudeAdjusted", MaximumSpeedAltitudeAdjusted.ToString());

            SessionHistory.Clear();
            _srvTelemetryDisplay?.UpdateTargetData(Telemetry());
        }
        public void ProcessEvent(EDEvent edEvent)
        {
            if (SessionStartTime == DateTime.MinValue)
            {
                SessionStartTime = new DateTime(edEvent.TimeStamp.Year, edEvent.TimeStamp.Month, edEvent.TimeStamp.Day, edEvent.TimeStamp.Hour, edEvent.TimeStamp.Minute, edEvent.TimeStamp.Second);
                _telemetry["SessionStartTime"] = SessionStartTime.ToString("HH:mm:ss");
                _telemetry["SessionDate"]      = SessionStartTime.ToShortDateString();
            }

            bool statsUpdated = ProcessFlags(edEvent);

            switch (edEvent.EventName)
            {
            case "DockSRV":
                TotalShipRepairs++;
                HullHealth = 1;
                _telemetry["HullStrength"]        = "100%";
                _telemetry["TotalSRVShipRepairs"] = TotalShipRepairs.ToString();
                statsUpdated   = true;
                _playerIsInSRV = false;
                break;

            case "LaunchSRV":
                _playerIsInSRV = true;
                break;

            case "Shutdown":
                SaveSession();
                break;

            case "SRVDestroyed":
                _playerIsInSRV = false;
                TotalSRVsDestroyed++;
                _telemetry["TotalSRVsDestroyed"] = TotalSRVsDestroyed.ToString();
                statsUpdated = true;
                break;

            case "HullDamage":
                HullHealth = edEvent.Health;
                _telemetry["HullStrength"] = $"{(HullHealth * 100).ToString("F1")}%";
                statsUpdated = true;
                break;

            case "Synthesis":
                TotalSynthRepairs++;
                _telemetry["TotalSRVSynthRepairs"] = TotalSynthRepairs.ToString();
                statsUpdated = true;
                break;

            case "Status":
                if (_playerIsInSRV && ProcessLocationUpdate(edEvent))
                {
                    statsUpdated = true;
                }
                break;
            }

            _lastEventTime = edEvent.TimeStamp;
            if (statsUpdated)
            {
                SessionHistory.Add(edEvent);
                _srvTelemetryDisplay?.UpdateTargetData(Telemetry());
            }
        }
Example #3
0
        public void ProcessEvent(EDEvent edEvent, bool noHistory = false)
        {
            bool statsUpdated = ProcessFlags(edEvent);

            switch (edEvent.EventName)
            {
            case "DockSRV":
                TotalShipRepairs++;
                HullHealth = 1;
                _telemetry["HullStrength"]        = "100%";
                _telemetry["TotalSRVShipRepairs"] = TotalShipRepairs.ToString();
                statsUpdated   = true;
                _playerIsInSRV = false;
                ResetSpeedCalc();
                break;

            case "LaunchSRV":
                _playerIsInSRV = true;
                ResetSpeedCalc();
                break;

            case "Shutdown":
                SaveSession();
                break;

            case "SRVDestroyed":
                _playerIsInSRV = false;
                TotalSRVsDestroyed++;
                _telemetry["TotalSRVsDestroyed"] = TotalSRVsDestroyed.ToString();
                ResetSpeedCalc();
                statsUpdated = true;
                break;

            case "HullDamage":
                HullHealth = edEvent.Health;
                _telemetry["HullStrength"] = $"{(HullHealth * 100).ToString("F1")}%";
                statsUpdated = true;
                break;

            case "Synthesis":
                if (edEvent.AdditionalData.StartsWith("Repair"))
                {
                    TotalSynthRepairs++;
                    _telemetry["TotalSRVSynthRepairs"] = TotalSynthRepairs.ToString();
                    HullHealth = 1;
                    _telemetry["HullStrength"] = "100%";
                    statsUpdated = true;
                }
                break;

            case "Status":
                // We only process location updates if the event is for the correct vehicle (ship or SRV)
                if ((_playerIsInSRV == TrackSRV) && ProcessLocationUpdate(edEvent))
                {
                    statsUpdated = true;
                }
                break;
            }

            _lastEventTime = edEvent.TimeStamp;
            if (statsUpdated)
            {
                if (!noHistory)
                {
                    SessionHistory.Add(edEvent);
                }
                _srvTelemetryDisplay?.UpdateTargetData(Telemetry());
            }
        }