Exemple #1
0
        private CourseTemplate GenerateCourseProf(AvailablePart ap, bool isTemporary)
        {
            var  n     = new ConfigNode("FS_COURSE");
            bool found = TrainingDatabase.SynonymReplace(ap.name, out string name);

            n.AddValue("id", "prof_" + name);
            n.AddValue("name", "Proficiency: " + (found ? name : ap.title));
            n.AddValue("time", 1d + (TrainingDatabase.GetTime(name) * 86400));
            n.AddValue("isTemporary", isTemporary);
            n.AddValue("conflicts", $"{TrainingType_Proficiency}:{name}");

            ConfigNode r = n.AddNode("REWARD");

            r.AddValue("XPAmt", Settings.trainingProficiencyXP);
            ConfigNode l = r.AddNode("FLIGHTLOG");

            l.AddValue("0", $"{TrainingType_Proficiency},{name}");

            var c = new CourseTemplate(n);

            c.PopulateFromSourceNode();
            OfferedCourses.Add(c);

            return(c);
        }
Exemple #2
0
        public void AddPartCourses(AvailablePart ap, bool isKCTExperimentalNode = false)
        {
            if (ap.partPrefab.isVesselEVA || ap.name.StartsWith("kerbalEVA", StringComparison.OrdinalIgnoreCase) ||
                ap.partPrefab.Modules.Contains <KerbalSeat>() ||
                ap.partPrefab.Modules.Contains <LaunchClamp>() || ap.partPrefab.HasTag("PadInfrastructure"))
            {
                return;
            }

            TrainingDatabase.SynonymReplace(ap.name, out string name);
            if (!_partSynsHandled.TryGetValue(name, out var coursePair))
            {
                bool isPartUnlocked = !isKCTExperimentalNode && ResearchAndDevelopment.GetTechnologyState(ap.TechRequired) == RDTech.State.Available;

                CourseTemplate profCourse = GenerateCourseProf(ap, !isPartUnlocked);
                AppendToPartTooltip(ap, profCourse);
                CourseTemplate missionCourse = null;
                if (isPartUnlocked && IsMissionTrainingEnabled)
                {
                    missionCourse = GenerateCourseMission(ap);
                    AppendToPartTooltip(ap, missionCourse);
                }
                _partSynsHandled.Add(name, new Tuple <CourseTemplate, CourseTemplate>(profCourse, missionCourse));
            }
            else
            {
                CourseTemplate pc = coursePair.Item1;
                CourseTemplate mc = coursePair.Item2;
                AppendToPartTooltip(ap, pc);
                if (mc != null)
                {
                    AppendToPartTooltip(ap, mc);
                }
            }
        }
Exemple #3
0
        private CourseTemplate GenerateCourseMission(AvailablePart ap)
        {
            var  n     = new ConfigNode("FS_COURSE");
            bool found = TrainingDatabase.SynonymReplace(ap.name, out string name);

            n.AddValue("id", "msn_" + name);
            n.AddValue("name", "Mission: " + (found ? name : ap.title));
            n.AddValue("time", 1 + TrainingDatabase.GetTime(name + "-Mission") * 86400);
            n.AddValue("isTemporary", false);
            n.AddValue("timeUseStupid", true);
            n.AddValue("seatMax", ap.partPrefab.CrewCapacity * 2);
            n.AddValue("expiration", Settings.trainingMissionExpirationDays * 86400);
            n.AddValue("preReqs", $"{TrainingType_Proficiency}:{name}");

            ConfigNode r = n.AddNode("REWARD");
            ConfigNode l = r.AddNode("FLIGHTLOG");

            l.AddValue("0", $"{TrainingType_Mission},{name}");

            var c = new CourseTemplate(n);

            c.PopulateFromSourceNode();
            OfferedCourses.Add(c);

            return(c);
        }
Exemple #4
0
        protected void GenerateCourseMission(AvailablePart ap)
        {
            ConfigNode n    = new ConfigNode("FS_COURSE");
            string     name = TrainingDatabase.SynonymReplace(ap.name);

            n.AddValue("id", "msn_" + name);
            n.AddValue("name", "Mission: " + name);
            n.AddValue("time", 1d + TrainingDatabase.GetTime(name + "-Mission") * 86400d);
            n.AddValue("isTemporary", false);
            n.AddValue("timeUseStupid", true);
            n.AddValue("seatMax", ap.partPrefab.CrewCapacity * 2);
            n.AddValue("expiration", settings.trainingMissionExpirationDays * 86400d);

            n.AddValue("preReqs", "TRAINING_proficiency:" + name);
            n.AddValue("conflicts", "TRAINING_mission:" + name);

            ConfigNode r = n.AddNode("REWARD");
            ConfigNode l = r.AddNode("FLIGHTLOG");

            l.AddValue("0", "TRAINING_mission," + name);

            CourseTemplate c = new CourseTemplate(n);

            c.PopulateFromSourceNode();
            OfferedCourses.Add(c);
        }
Exemple #5
0
        private void GenerateOfferedCourses()
        {
            Profiler.BeginSample("RP0 GenerateOfferedCourses");
            OfferedCourses.Clear();
            _partSynsHandled.Clear();

            if (!CurrentSceneAllowsCrewManagement)
            {
                Profiler.EndSample();
                return;    // Course UI is only available in those 2 scenes so no need to generate them for any other
            }

            //convert the saved configs to course offerings
            foreach (CourseTemplate template in CourseTemplates)
            {
                var duplicate = new CourseTemplate(template.sourceNode, true); //creates a duplicate so the initial template is preserved
                duplicate.PopulateFromSourceNode();
                if (duplicate.Available)
                {
                    OfferedCourses.Add(duplicate);
                }
            }

            foreach (AvailablePart ap in PartLoader.LoadedPartsList)
            {
                if (!ap.TechHidden && ap.partPrefab.CrewCapacity > 0 &&
                    ResearchAndDevelopment.GetTechnologyState(ap.TechRequired) == RDTech.State.Available)
                {
                    AddPartCourses(ap);
                }
            }
            Profiler.EndSample();
        }
Exemple #6
0
        protected void GenerateOfferedCourses() //somehow provide some variable options here?
        {
            //convert the saved configs to course offerings
            foreach (CourseTemplate template in CourseTemplates)
            {
                CourseTemplate duplicate = new CourseTemplate(template.sourceNode, true); //creates a duplicate so the initial template is preserved
                duplicate.PopulateFromSourceNode();
                if (duplicate.Available)
                {
                    OfferedCourses.Add(duplicate);
                }
            }

            foreach (AvailablePart ap in PartLoader.LoadedPartsList)
            {
                if (ap.partPrefab.CrewCapacity > 0 && /*&& ap.TechRequired != "start"*/
                    ResearchAndDevelopment.PartModelPurchased(ap))
                {
                    AddPartCourses(ap);
                }
            }

            Debug.Log("[FS] Offering " + OfferedCourses.Count + " courses.");
            //fire an event to let other mods add available courses (where they can pass variables through then)
        }
Exemple #7
0
        private void GenerateOfferedCourses()
        {
            OfferedCourses.Clear();
            _partSynsHandled.Clear();

            if (!CurrentSceneAllowsCrewManagement)
            {
                return;                                       // Course UI is only available in those 2 scenes so no need to generate them for any other
            }
            //convert the saved configs to course offerings
            foreach (CourseTemplate template in CourseTemplates)
            {
                var duplicate = new CourseTemplate(template.sourceNode, true); //creates a duplicate so the initial template is preserved
                duplicate.PopulateFromSourceNode();
                if (duplicate.Available)
                {
                    OfferedCourses.Add(duplicate);
                }
            }

            foreach (AvailablePart ap in PartLoader.LoadedPartsList)
            {
                if (ap.partPrefab.CrewCapacity > 0 &&
                    ResearchAndDevelopment.PartModelPurchased(ap) &&
                    !ResearchAndDevelopment.IsExperimentalPart(ap))
                {
                    AddPartCourses(ap);
                }
            }
        }
Exemple #8
0
        protected void GenerateCourseProf(AvailablePart ap)
        {
            ConfigNode n    = new ConfigNode("FS_COURSE");
            string     name = TrainingDatabase.SynonymReplace(ap.name);

            n.AddValue("id", "prof_" + name);
            n.AddValue("name", "Proficiency: " + name);
            n.AddValue("time", 1d + (TrainingDatabase.GetTime(name) * 86400d));
            n.AddValue("expiration", settings.trainingProficiencyExpirationYears * 86400d * 365d);
            n.AddValue("expirationUseStupid", true);

            n.AddValue("conflicts", "TRAINING_proficiency:" + name);

            ConfigNode r = n.AddNode("REWARD");

            r.AddValue("XPAmt", settings.trainingProficiencyXP);
            ConfigNode l = r.AddNode("FLIGHTLOG");

            l.AddValue("0", "TRAINING_proficiency," + name);

            CourseTemplate c = new CourseTemplate(n);

            c.PopulateFromSourceNode();
            OfferedCourses.Add(c);

            ConfigNode n2 = n.CreateCopy();

            n2.SetValue("id", "profR_" + name);
            n2.SetValue("name", "Refresher: " + name);
            n2.SetValue("time", 1d + TrainingDatabase.GetTime(name) * 86400d * settings.trainingProficiencyRefresherTimeMult);
            n2.AddValue("preReqsAny", "expired_TRAINING_proficiency:" + name + ",TRAINING_proficiency:" + name);
            n2.RemoveValue("conflicts");

            r = n2.GetNode("REWARD");
            r.SetValue("XPAmt", "0");
            ConfigNode exp = r.AddNode("EXPIRELOG");

            exp.AddValue("0", "TRAINING_proficiency," + name);

            c = new CourseTemplate(n2);
            c.PopulateFromSourceNode();
            OfferedCourses.Add(c);
        }
Exemple #9
0
        private void GenerateOfferedCourses()
        {
            //convert the saved configs to course offerings
            foreach (CourseTemplate template in CourseTemplates)
            {
                var duplicate = new CourseTemplate(template.sourceNode, true); //creates a duplicate so the initial template is preserved
                duplicate.PopulateFromSourceNode();
                if (duplicate.Available)
                {
                    OfferedCourses.Add(duplicate);
                }
            }

            foreach (AvailablePart ap in PartLoader.LoadedPartsList)
            {
                if (ap.partPrefab.CrewCapacity > 0 &&
                    ResearchAndDevelopment.PartModelPurchased(ap))
                {
                    AddPartCourses(ap);
                }
            }
        }
Exemple #10
0
        protected void GenerateCourseProf(AvailablePart ap)
        {
            ConfigNode n    = new ConfigNode("FS_COURSE");
            string     name = TrainingDatabase.SynonymReplace(ap.name);

            n.AddValue("id", "prof_" + name);
            n.AddValue("name", "Proficiency: " + name);
            n.AddValue("time", 1d + (TrainingDatabase.GetTime(name) * 86400d));

            n.AddValue("conflicts", "TRAINING_proficiency:" + name);

            ConfigNode r = n.AddNode("REWARD");

            r.AddValue("XPAmt", settings.trainingProficiencyXP);
            ConfigNode l = r.AddNode("FLIGHTLOG");

            l.AddValue("0", "TRAINING_proficiency," + name);

            CourseTemplate c = new CourseTemplate(n);

            c.PopulateFromSourceNode();
            OfferedCourses.Add(c);
        }
Exemple #11
0
 public ActiveCourse(CourseTemplate template)
 {
     sourceNode = template.sourceNode;
     PopulateFromSourceNode(template.sourceNode);
 }
Exemple #12
0
 private static void AppendToPartTooltip(AvailablePart ap, CourseTemplate ct)
 {
     ct.PartsTooltip = ct.PartsTooltip == null ? $"Applies to parts: {ap.title}" :
                       $"{ct.PartsTooltip}, {ap.title}";
 }