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); } } }
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") * Config.hoursPerDay * 3600); n.AddValue("isTemporary", false); n.AddValue("timeUseStupid", true); n.AddValue("seatMax", ap.partPrefab.CrewCapacity * 2); n.AddValue("expiration", Settings.trainingMissionExpirationDays * Config.hoursPerDay * 3600); 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); }
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) * Config.hoursPerDay * 3600)); 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); }
public double GetTime() { double c = days; foreach (string s in children) { c += TrainingDatabase._GetTime(s); } return(c); }
public void AddPartCourses(AvailablePart ap) { string name = TrainingDatabase.SynonymReplace(ap.name); if (!_partSynsHandled.Contains(name)) { _partSynsHandled.Add(name); bool isPartUnlocked = ResearchAndDevelopment.PartModelPurchased(ap); GenerateCourseProf(ap, !isPartUnlocked); if (isPartUnlocked) { GenerateCourseMission(ap); } } }
public bool NautHasTrainingForPart(ProtoCrewMember pcm, string partName) { 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 = 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); }
public bool NautHasTrainingForPart(ProtoCrewMember pcm, string partName) { TrainingDatabase.SynonymReplace(partName, out partName); FlightLog.Entry ent = pcm.careerLog.Last(); if (ent == null) { return(false); } bool lacksMission = IsMissionTrainingEnabled; 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 == TrainingType_Mission && e.target == partName) { double exp = GetExpiration(pcm.name, e); lacksMission = exp == 0d || exp < KSPUtils.GetUT(); } } else { if (string.IsNullOrEmpty(e.type) || string.IsNullOrEmpty(e.target)) { continue; } if (e.type == TrainingType_Proficiency && e.target == partName) { return(true); } } } return(false); }
private void GenerateCourseProf(AvailablePart ap, bool isTemporary) { var 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) * 86400)); n.AddValue("isTemporary", isTemporary); 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); var c = new CourseTemplate(n); c.PopulateFromSourceNode(); OfferedCourses.Add(c); }
private void GenerateCourseMission(AvailablePart ap) { var n = new ConfigNode("FS_COURSE"); string name = TrainingDatabase.SynonymReplace(ap.name); n.AddValue("id", "msn_" + name); n.AddValue("name", "Mission: " + name); 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", "TRAINING_proficiency:" + name); ConfigNode r = n.AddNode("REWARD"); ConfigNode l = r.AddNode("FLIGHTLOG"); l.AddValue("0", "TRAINING_mission," + name); var c = new CourseTemplate(n); c.PopulateFromSourceNode(); OfferedCourses.Add(c); }
public override void OnLoad(ConfigNode node) { base.OnLoad(node); if (Settings == null) { Settings = new CrewHandlerSettings(); foreach (ConfigNode stg in GameDatabase.Instance.GetConfigNodes("CREWHANDLERSETTINGS")) { Settings.Load(stg); } } KerbalRetireTimes.Clear(); ConfigNode n = node.GetNode("RETIRETIMES"); if (n != null) { foreach (ConfigNode.Value v in n.values) { KerbalRetireTimes[v.name] = double.Parse(v.value); } } KerbalRetireIncreases.Clear(); n = node.GetNode("RETIREINCREASES"); if (n != null) { foreach (ConfigNode.Value v in n.values) { KerbalRetireIncreases[v.name] = double.Parse(v.value); } } _retirees.Clear(); n = node.GetNode("RETIREES"); if (n != null) { foreach (ConfigNode.Value v in n.values) { _retirees.Add(v.value); } } _expireTimes.Clear(); n = node.GetNode("EXPIRATIONS"); if (n != null) { foreach (ConfigNode eN in n.nodes) { _expireTimes.Add(new TrainingExpiration(eN)); } } ConfigNode FSData = node.GetNode("FlightSchoolData"); if (FSData != null) { //load all the active courses ActiveCourses.Clear(); foreach (ConfigNode courseNode in FSData.GetNodes("ACTIVE_COURSE")) { try { ActiveCourses.Add(new ActiveCourse(courseNode)); } catch (Exception ex) { Debug.LogException(ex); } } } TrainingDatabase.EnsureInitialized(); GenerateOfferedCourses(); KACWrapper.InitKACWrapper(); }
public override void OnLoad(ConfigNode node) { base.OnLoad(node); if (Config == null) { Config = new LRTRHomeWorldParameters(); foreach (ConfigNode stg in GameDatabase.Instance.GetConfigNodes("HOMEWORLDPARAMETERS")) { Config.Load(stg); } } if (Settings == null) { Settings = new CrewHandlerSettings(); foreach (ConfigNode stg in GameDatabase.Instance.GetConfigNodes("CREWHANDLERSETTINGS")) { Settings.Load(stg); } Settings.retireIncreaseCap = Settings.retireIncreaseCap * Config.hoursPerDay * Config.daysPerYear * 3600; } KerbalRetireTimes.Clear(); ConfigNode n = node.GetNode("RETIRETIMES"); if (n != null) { _isFirstLoad = false; foreach (ConfigNode.Value v in n.values) { KerbalRetireTimes[v.name] = double.Parse(v.value); } } KerbalRetireIncreases.Clear(); n = node.GetNode("RETIREINCREASES"); if (n != null) { foreach (ConfigNode.Value v in n.values) { KerbalRetireIncreases[v.name] = double.Parse(v.value); } } _retirees.Clear(); n = node.GetNode("RETIREES"); if (n != null) { foreach (ConfigNode.Value v in n.values) { _retirees.Add(v.value); } } _expireTimes.Clear(); n = node.GetNode("EXPIRATIONS"); if (n != null) { foreach (ConfigNode eN in n.nodes) { _expireTimes.Add(new TrainingExpiration(eN)); } } ConfigNode FSData = node.GetNode("FlightSchoolData"); if (FSData != null) { //load all the active courses ActiveCourses.Clear(); foreach (ConfigNode courseNode in FSData.GetNodes("ACTIVE_COURSE")) { try { ActiveCourses.Add(new ActiveCourse(courseNode)); } catch (Exception ex) { Debug.LogException(ex); } } } TrainingDatabase.EnsureInitialized(); KACWrapper.InitKACWrapper(); }