コード例 #1
0
        private bool ProcessLocationUpdate(EDEvent edEvent)
        {
            EDLocation currentLocation = edEvent.Location();

            if (currentLocation == null)
            {
                return(false);
            }

            if (SessionStartLocation == null)
            {
                SessionStartLocation = currentLocation;
            }

            _telemetry["CurrentAltitude"] = EDLocation.DistanceToString(edEvent.Altitude);
            if ((int)edEvent.Altitude > MaximumAltitude)
            {
                MaximumAltitude = (int)edEvent.Altitude;
                _telemetry["MaximumAltitude"] = EDLocation.DistanceToString(MaximumAltitude);
            }
            else if (!_playerIsInSRV && (int)edEvent.Altitude < MinimumAltitude)
            {
                MinimumAltitude = (int)edEvent.Altitude;
                _telemetry["MinimumAltitude"] = EDLocation.DistanceToString(MinimumAltitude);
            }



            if (_lastLocation == null)
            {
                _lastLocation = currentLocation;
                return(false);
            }
            if (_lastLocation.Latitude.Equals(currentLocation.Latitude) && _lastLocation.Longitude.Equals(currentLocation.Longitude))
            {
                return(false);
            }

            _telemetry["CurrentLatitude"]  = currentLocation.Latitude.ToString();
            _telemetry["CurrentLongitude"] = currentLocation.Longitude.ToString();

            // Update distance/speed statistics
            if (CalculateDistances(currentLocation))
            {
                CalculateSpeed(currentLocation, edEvent.TimeStamp);
                if (SessionStartTime == DateTime.MinValue)
                {
                    // We set session start time on first detected movement
                    SessionStartTime = DateTime.UtcNow;
                    _telemetry["SessionStartTime"] = SessionStartTime.ToString("HH:mm:ss");
                    _telemetry["SessionDate"]      = SessionStartTime.ToShortDateString();
                }
                return(true);
            }
            return(false);
        }
コード例 #2
0
 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();
     }
 }
コード例 #3
0
        private bool ProcessLocationUpdate(EDEvent edEvent)
        {
            EDLocation currentLocation = edEvent.Location();

            if (currentLocation == null)
            {
                return(false);
            }

            if (SessionStartLocation == null)
            {
                SessionStartLocation = currentLocation;
            }

            _telemetry["CurrentAltitude"] = EDLocation.DistanceToString(edEvent.Altitude);
            if ((int)edEvent.Altitude > MaximumAltitude)
            {
                MaximumAltitude = (int)edEvent.Altitude;
                _telemetry["MaximumAltitude"] = EDLocation.DistanceToString(MaximumAltitude);
            }

            if (_lastLocation == null)
            {
                _lastLocation    = currentLocation;
                SessionStartTime = edEvent.TimeStamp;
                return(false);
            }
            if (_lastLocation.Latitude.Equals(currentLocation.Latitude) && _lastLocation.Longitude.Equals(currentLocation.Longitude))
            {
                return(false);
            }

            // Update distance/speed statistics
            if (CalculateDistances(currentLocation))
            {
                CalculateSpeed(currentLocation, edEvent.TimeStamp);
                return(true);
            }
            return(false);
        }
コード例 #4
0
        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);
        }