Ejemplo n.º 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);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
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);
        }
Ejemplo n.º 4
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();
        }
Ejemplo n.º 5
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)
        }
Ejemplo n.º 6
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);
                }
            }
        }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
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);
                }
            }
        }
Ejemplo n.º 9
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);
        }