private void checkForContractsAndEmptySpots()
        {
            GameEvents.onFlightReady.Remove(checkForContractsAndEmptySpots);
              if (!isVesselPrelaunch())
            return;
              var TourismContracts = ContractSystem.Instance.GetCurrentActiveContracts<FinePrint.Contracts.TourismContract>().Length;
              if (TourismContracts > 0)
              {
            int freeSpots = 0;
            int touristCount = 0;
            var currentVessel = FlightGlobals.ActiveVessel;
            foreach (var part in currentVessel.parts)
            {
              if (part.CrewCapacity > 0)
              {
            if (part.protoModuleCrew.Count < part.CrewCapacity)
            {
              freeSpots += part.CrewCapacity - part.protoModuleCrew.Count;
            }
              }
            }
            if (freeSpots == 0)
              return;
            touristList.Clear();
            var nextTourist = HighLogic.CurrentGame.CrewRoster.Kerbals(ProtoCrewMember.KerbalType.Tourist, ProtoCrewMember.RosterStatus.Available);
            foreach (var tourist in nextTourist)
            {
              touristCount++;
              touristList.Add(tourist);
            }
            if (touristCount == 0)
              return;
            var text = new StringBuilder();
            if (TourismContracts == 1)
            {
              text.Append("There is one tourism contract available");
            }
            else
            {
              text.Append("There are " + TourismContracts + " contracts available.");
            }
            if (touristCount == 1)
            {
              text.Append("You have one tourist waiting");
            }
            else
            {
              text.Append("You have " + touristCount + " tourists waiting");
            }
            if (freeSpots == 1)
            {
              text.Append(" and you have one spot free.");
            }
            else
            {
              text.Append(" and you have " + freeSpots + " spots free.");
            }

            text.Append(" Do you want to fill your empty spots with tourists ?");
            modalWindow = new ModalWindowClass(displayName, text.ToString(), "Yes", "No", addTourists, removeModal);
            ModalWindow.instance.add(modalWindow);
              }
        }
Exemplo n.º 2
0
        private void checkForContractsAndEmptySpots()
        {
            GameEvents.onFlightReady.Remove(checkForContractsAndEmptySpots);
            if (!isVesselPrelaunch())
            {
                return;
            }
            var TourismContracts = ContractSystem.Instance.GetCurrentActiveContracts <FinePrint.Contracts.TourismContract>().Length;

            if (TourismContracts > 0)
            {
                int freeSpots     = 0;
                int touristCount  = 0;
                var currentVessel = FlightGlobals.ActiveVessel;
                foreach (var part in currentVessel.parts)
                {
                    if (part.CrewCapacity > 0)
                    {
                        if (part.protoModuleCrew.Count < part.CrewCapacity)
                        {
                            freeSpots += part.CrewCapacity - part.protoModuleCrew.Count;
                        }
                    }
                }
                if (freeSpots == 0)
                {
                    return;
                }
                touristList.Clear();
                var nextTourist = HighLogic.CurrentGame.CrewRoster.Kerbals(ProtoCrewMember.KerbalType.Tourist, ProtoCrewMember.RosterStatus.Available);
                foreach (var tourist in nextTourist)
                {
                    touristCount++;
                    touristList.Add(tourist);
                }
                if (touristCount == 0)
                {
                    return;
                }
                var text = new StringBuilder();
                if (TourismContracts == 1)
                {
                    text.Append("There is one tourism contract available");
                }
                else
                {
                    text.Append("There are " + TourismContracts + " contracts available.");
                }
                if (touristCount == 1)
                {
                    text.Append("You have one tourist waiting");
                }
                else
                {
                    text.Append("You have " + touristCount + " tourists waiting");
                }
                if (freeSpots == 1)
                {
                    text.Append(" and you have one spot free.");
                }
                else
                {
                    text.Append(" and you have " + freeSpots + " spots free.");
                }

                text.Append(" Do you want to fill your empty spots with tourists ?");
                modalWindow = new ModalWindowClass(displayName, text.ToString(), "Yes", "No", addTourists, removeModal);
                ModalWindow.instance.add(modalWindow);
            }
        }