示例#1
0
 private void LazyUpdate()
 {
     if (_window.gameObject.activeSelf)
     {
         // Get metadata from WOLF
         if (_wolf != null)
         {
             var flights  = _wolf.GetCrewRoutes(Planetarium.GetUniversalTime());
             var metadata = flights
                            .OrderBy(f => f.OriginBody)
                            .ThenBy(f => f.DestinationBody)
                            .ThenBy(f => f.OriginBiome)
                            .ThenBy(f => f.DestinationBiome)
                            .Select(f => new FlightMetadata
             {
                 ArrivalBiome   = f.DestinationBiome,
                 ArrivalBody    = f.DestinationBody,
                 DepartureBiome = f.OriginBiome,
                 DepartureBody  = f.OriginBody,
                 Duration       = GetDuration(f),
                 EconomySeats   = GetEconomySeats(f),
                 FlightNumber   = f.FlightNumber,
                 LuxurySeats    = GetLuxurySeats(f),
                 Status         = f.FlightStatus,
                 UniqueId       = f.UniqueId,
             })
                            .ToList();
             _window.ShowFlights(metadata);
         }
         if (_selectedFlight != null)
         {
             if (_selectedFlight.FlightStatus == FlightStatus.Boarding)
             {
                 if (HighLogic.LoadedSceneIsFlight)
                 {
                     var kerbals = GetNearbyKerbals();
                     if (kerbals == null || kerbals.Count < 1)
                     {
                         _activeWarnings.Clear();
                         _passengers.Clear();
                         _window.ShowPassengers(null);
                         ShowWarning(SelectedFlightPanelLabels.NoKerbalsToBoardMessage, true);
                     }
                     else
                     {
                         var passengers = kerbals
                                          .Select(k => new PassengerMetadata
                         {
                             Name        = k.name,
                             DisplayName = k.displayName,
                             Occupation  = k.experienceTrait.Title,
                             IsTourist   = k.type == ProtoCrewMember.KerbalType.Tourist,
                             Stars       = k.experienceLevel,
                         })
                                          .OrderBy(p => p.DisplayName)
                                          .ToList();
                         _window.ShowPassengers(passengers);
                     }
                 }
                 else
                 {
                     _window.ShowAlert(SelectedFlightPanelLabels.NoKerbalsToBoardMessage);
                 }
             }
             else
             {
                 var passengers = _selectedFlight.Passengers
                                  .Select(p => new PassengerMetadata
                 {
                     Name        = p.Name,
                     DisplayName = p.DisplayName,
                     Occupation  = p.Occupation,
                     IsTourist   = p.IsTourist,
                     Stars       = p.Stars,
                 })
                                  .OrderBy(p => p.DisplayName)
                                  .ToList();
                 _window.ShowPassengers(passengers);
                 if (_selectedFlight.FlightStatus == FlightStatus.Arrived)
                 {
                     if (!HighLogic.LoadedSceneIsFlight)
                     {
                         _window.ShowAlert(_arrivalWarnings.NoNearbyTerminalsMessage);
                         ShowWarning(_arrivalWarnings.NoNearbyTerminalsMessage, true);
                     }
                     else
                     {
                         var terminals = GetNearbyTerminals();
                         if (terminals == null || terminals.Count < 1)
                         {
                             _window.ShowAlert(_arrivalWarnings.NoNearbyTerminalsMessage);
                             ShowWarning(_arrivalWarnings.NoNearbyTerminalsMessage, true);
                         }
                         else
                         {
                             _window.HideAlert();
                             ClearWarning(_arrivalWarnings.NoNearbyTerminalsMessage);
                             if (_selectedTerminal == null)
                             {
                                 ShowWarning(_arrivalWarnings.NoTerminalSelectedMessage, true);
                             }
                             else
                             {
                                 ClearWarning(_arrivalWarnings.NoTerminalSelectedMessage);
                             }
                         }
                         _window.ShowArrivalTerminals(terminals);
                     }
                 }
             }
         }
     }
 }