protected bool IsNearTerminal()
        {
            var partModules = LogisticsTools.GetNearbyPartModules <WOLF_TerminalModule>(
                TERMINAL_RANGE,
                vessel,
                false,
                false);

            return(partModules != null && partModules.Any(m => m.IsConnectedToDepot));
        }
Exemple #2
0
        private List <ProtoCrewMember> GetNearbyKerbals()
        {
            var activeVessel = FlightGlobals.ActiveVessel;

            if (activeVessel == null)
            {
                return(null);
            }
            // Make sure we have an eligible terminal nearby
            var landedSituations = Vessel.Situations.LANDED |
                                   Vessel.Situations.PRELAUNCH |
                                   Vessel.Situations.SPLASHED;
            var landedOnly = (activeVessel.situation & landedSituations) == landedSituations;
            var terminals  = LogisticsTools.GetNearbyPartModules <WOLF_TerminalModule>(
                TERMINAL_RANGE,
                activeVessel,
                true,
                landedOnly);

            if (terminals == null || terminals.Count < 1)
            {
                return(null);
            }
            var terminalIds = terminals
                              .Where(t => !string.IsNullOrEmpty(t.TerminalId))
                              .Select(t => t.TerminalId);
            var wolfTerminals = _wolf.GetTerminals()
                                .Where(t => terminalIds.Contains(t.Id) &&
                                       t.Body == _selectedFlight.OriginBody &&
                                       t.Biome == _selectedFlight.OriginBiome);

            if (wolfTerminals == null || wolfTerminals.Count() < 1)
            {
                return(null);
            }
            // Get all nearby vessels
            var vessels = LogisticsTools
                          .GetNearbyVessels(TERMINAL_RANGE, true, activeVessel, landedOnly);
            var kerbals = new List <ProtoCrewMember>();

            foreach (var vessel in vessels)
            {
                var crew = vessel
                           .GetVesselCrew()
                           .Where(c => c.type == ProtoCrewMember.KerbalType.Crew ||
                                  c.type == ProtoCrewMember.KerbalType.Tourist);
                kerbals.AddRange(crew);
            }
            return(kerbals);
        }
Exemple #3
0
        private List <ArrivalMetadata> GetNearbyTerminals()
        {
            var activeVessel = FlightGlobals.ActiveVessel;

            if (activeVessel == null)
            {
                return(null);
            }
            // Make sure we have an eligible terminal nearby
            var landedSituations = Vessel.Situations.LANDED |
                                   Vessel.Situations.PRELAUNCH |
                                   Vessel.Situations.SPLASHED;
            var landedOnly      = (activeVessel.situation & landedSituations) == landedSituations;
            var terminalModules = LogisticsTools.GetNearbyPartModules <WOLF_TerminalModule>(
                TERMINAL_RANGE,
                activeVessel,
                true,
                landedOnly);

            if (terminalModules == null || terminalModules.Count < 1)
            {
                return(null);
            }
            var terminalIds = terminalModules
                              .Where(t => !string.IsNullOrEmpty(t.TerminalId))
                              .Select(t => t.TerminalId);
            var wolfTerminals = _wolf.GetTerminals()
                                .Where(t => terminalIds.Contains(t.Id) &&
                                       t.Body == _selectedFlight.DestinationBody &&
                                       t.Biome == _selectedFlight.DestinationBiome)
                                .ToList();
            var terminals = new List <ArrivalMetadata>();

            foreach (var wolfTerminal in wolfTerminals)
            {
                var terminalModule = terminalModules
                                     .FirstOrDefault(t => t.TerminalId == wolfTerminal.Id);
                var terminal = new ArrivalMetadata
                {
                    OccupiedSeats = terminalModule.part.protoModuleCrew.Count,
                    TotalSeats    = terminalModule.part.CrewCapacity,
                    TerminalId    = terminalModule.TerminalId,
                    VesselName    = terminalModule.vessel.GetDisplayName(),
                    VesselId      = terminalModule.vessel.id,
                };
                terminals.Add(terminal);
            }
            if (_passengers != null && _passengers.Count > 0 && _selectedTerminal != null)
            {
                foreach (var terminal in terminals)
                {
                    if (terminal.TerminalId == _selectedTerminal.TerminalId)
                    {
                        terminal.OccupiedSeats += _passengers.Count;
                    }
                }
            }
            return(terminals
                   .OrderBy(t => t.VesselName)
                   .ThenBy(t => t.TerminalId)
                   .ToList());
        }