Esempio n. 1
0
        public static bool CheckCrewForPart(ProtoCrewMember pcm, string partName)
        {
            // lolwut. But just in case.
            if (pcm == null)
            {
                return(false);
            }

            if (EntryCostStorage.GetCost(partName) == 1)
            {
                return(true);
            }

            partName = Crew.TrainingDatabase.SynonymReplace(partName);

            FlightLog.Entry ent = pcm.careerLog.Last();
            if (ent == null)
            {
                return(false);
            }

            int  lastFlight   = ent.flight;
            bool lacksMission = true;

            for (int i = pcm.careerLog.Entries.Count; i-- > 0;)
            {
                FlightLog.Entry e = pcm.careerLog.Entries[i];
                if (lacksMission)
                {
                    if (e.flight < lastFlight)
                    {
                        return(false);
                    }

                    if (string.IsNullOrEmpty(e.type) || string.IsNullOrEmpty(e.target))
                    {
                        continue;
                    }

                    if (e.type == "TRAINING_mission" && e.target == partName)
                    {
                        lacksMission = false;
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(e.type) || string.IsNullOrEmpty(e.target))
                    {
                        continue;
                    }

                    if (e.type == "TRAINING_proficiency" && e.target == partName)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Esempio n. 2
0
        public static bool CheckCrewForPart(ProtoCrewMember pcm, string partName)
        {
            // lolwut. But just in case.
            if (pcm == null)
            {
                return(false);
            }

            bool requireTraining = HighLogic.CurrentGame.Parameters.CustomParams <RP0Settings>().IsTrainingEnabled;

            if (!requireTraining || EntryCostStorage.GetCost(partName) == 1)
            {
                return(true);
            }

            partName = TrainingDatabase.SynonymReplace(partName);

            FlightLog.Entry ent = pcm.careerLog.Last();
            if (ent == null)
            {
                return(false);
            }

            bool lacksMission = true;

            for (int i = pcm.careerLog.Entries.Count; i-- > 0;)
            {
                FlightLog.Entry e = pcm.careerLog.Entries[i];
                if (lacksMission)
                {
                    if (string.IsNullOrEmpty(e.type) || string.IsNullOrEmpty(e.target))
                    {
                        continue;
                    }

                    if (e.type == "TRAINING_mission" && e.target == partName)
                    {
                        double exp = CrewHandler.Instance.GetExpiration(pcm.name, e);
                        lacksMission = exp == 0d || exp < Planetarium.GetUniversalTime();
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(e.type) || string.IsNullOrEmpty(e.target))
                    {
                        continue;
                    }

                    if (e.type == "TRAINING_proficiency" && e.target == partName)
                    {
                        return(true);
                    }
                }
            }
            return(false);
        }
Esempio n. 3
0
        public static bool CheckCrewForPart(ProtoCrewMember pcm, string partName)
        {
            // lolwut. But just in case.
            if (pcm == null)
            {
                return(false);
            }

            bool requireTraining = HighLogic.CurrentGame.Parameters.CustomParams <RP0Settings>().IsTrainingEnabled;

            if (!requireTraining || EntryCostStorage.GetCost(partName) == 1)
            {
                return(true);
            }

            return(CrewHandler.Instance.NautHasTrainingForPart(pcm, partName));
        }