public static string DescribeKerbalsWithEffect(string experienceEffect, TechTier tier) { List <ExperienceTraitConfig> careers = GameDatabase.Instance.ExperienceConfigs .GetTraitsWithEffect(experienceEffect) .Select(name => GameDatabase.Instance.ExperienceConfigs.GetExperienceTraitConfig(name)) .ToList(); StringBuilder info = new StringBuilder(); for (int i = 0; i < careers.Count; ++i) { ExperienceEffectConfig effectConfig = careers[i].Effects.First(effect => effect.Name == experienceEffect); int numStars = 1 + (int)tier - int.Parse(effectConfig.Config.GetValue("level")); if (i == careers.Count - 1) { info.Append(" or a "); } else if (i > 0) { info.Append(", "); } info.Append(DescribeKerbalTrait(numStars, careers[i].Title)); } return(info.ToString()); }
public IEnumerable <DialogGUIBase> GetTraitDescription(bool showParts, List <ProtoCrewMember> crew) { List <ExperienceTraitConfig> careers = GameDatabase.Instance.ExperienceConfigs .GetTraitsWithEffect(this.Trait) .Select(name => GameDatabase.Instance.ExperienceConfigs.GetExperienceTraitConfig(name)) .ToList(); // #Needed Specialist #Crew Generalist #Crew // 1.5 Miner 2 3*Engineer 0 // Scrounger Drill- var requirementRow = new DialogGUIHorizontalLayout(); string quantity = UncrewedQuantity + DisabledQuantity > 0.001 ? $"{this.TotalQuantity - UncrewedQuantity - DisabledQuantity:N1}/{this.TotalQuantity:N1}" : this.TotalQuantity.ToString("N1"); if (UncrewedQuantity > 0.001) { quantity = TextEffects.Red(quantity); } else if (DisabledQuantity > 0.001) { quantity = TextEffects.Yellow(quantity); } requirementRow.AddChild(new DialogGUILabel(quantity, width: NumberColumnWidth)); for (int i = 0; i < careers.Count; ++i) { ExperienceEffectConfig effectConfig = careers[i].Effects.First(effect => effect.Name == this.Trait); var levelString = effectConfig.Config.GetValue("level"); int numStars = SkillLevel - int.Parse(levelString ?? "0"); requirementRow.AddChild(new DialogGUILabel( PksCrewRequirement.DescribeKerbalTrait(numStars, careers[i].Title), ProfessionColumnWidth)); requirementRow.AddChild(new DialogGUILabel( $"{crew.Count(c => c.trait == careers[i].Title && c.experienceLevel >= numStars)}", width: NumberColumnWidth)); } yield return(requirementRow); if (showParts) { var partsRow = new DialogGUIHorizontalLayout(); partsRow.AddChild(new DialogGUISpace(15)); partsRow.AddChild(new DialogGUILabel($"<I>{string.Join(", ", this.PartNames)}</I>")); yield return(partsRow); } }
/// <summary> /// Get all kerbal effect types. /// </summary> /// <param name="kerbalClasses"></param> /// <returns></returns> private static HashSet <string> FindKerbalEffects() { HashSet <string> kerbalEffects = new HashSet <string>(); ExperienceSystemConfig systemConfig = new ExperienceSystemConfig(); for (int traitIndex = 0; traitIndex < systemConfig.Categories.Count; ++traitIndex) { ExperienceTraitConfig traitConfig = systemConfig.Categories[traitIndex]; if (traitConfig.Effects == null) { continue; } for (int effectIndex = 0; effectIndex < traitConfig.Effects.Count; ++effectIndex) { ExperienceEffectConfig effectConfig = traitConfig.Effects[effectIndex]; if (!kerbalEffects.Contains(effectConfig.Name)) { Logging.Log("Adding kerbal effect: " + effectConfig.Name); kerbalEffects.Add(effectConfig.Name); } } } return(kerbalEffects); }