public EDRaceStatus(EDEvent baseEvent) { // This constructor should only ever be called by the server Flags = baseEvent.Flags; Heading = baseEvent.Heading; TimeStamp = baseEvent.TimeStamp; Commander = baseEvent.Commander; if (baseEvent.HasCoordinates()) { Location = baseEvent.Location(); } }
public void UpdateStatus(EDEvent updateEvent) { // Update our status based on the passed event if (updateEvent.TimeStamp > DateTime.MinValue) { TimeStamp = updateEvent.TimeStamp; } if (Finished) // We keep tracking when eliminated in case of mistake (racers can be restored) { return; } if ((updateEvent.Flags > 0) && (Flags != updateEvent.Flags)) { _lastFlags = Flags; Flags = updateEvent.Flags; } Flags2 = updateEvent.Flags2; Pips = (byte[])updateEvent.Pips.Clone(); Heading = updateEvent.Heading; if (updateEvent.Health >= 0) { Hull = updateEvent.Health; AddRaceHistory($"Hull percentage: {Hull*100:F1}"); } if (updateEvent.HasCoordinates()) { _previousLocation = Location; Location = updateEvent.Location(); ProcessLocationChange(); CalculateSpeed(); } if (!Started) { return; } ProcessFlags(); switch (updateEvent.EventName) { case "SRVDestroyed": ProcessSRVDestroyedEvent(); break; case "FighterDestroyed": ProcessFighterDestroyedEvent(); break; case "ShipTargeted": ProcessShipTargetedEvent(updateEvent); break; case "Touchdown": ProcessTouchdownEvent(updateEvent); break; case "Liftoff": _lastTouchDown = DateTime.MinValue; break; case "DockSRV": ProcessDockSRVEvent(updateEvent); break; case "LaunchSRV": ProcessLaunchSRVEvent(); break; case "Synthesis": ProcessSynthesisEvent(updateEvent); break; } GenerateStatus(); if (_status.Equals(_lastStatus)) { return; } AddRaceHistory(_status); _lastStatus = _status; StatusChanged?.Invoke(null, Commander, _status); }