internal static void UpdateTo(this ProtoCrewMember kerbal, string name, ProtoCrewMember.Gender gender, string trait, bool veteran, bool isBadass, float courage, float stupidity) { kerbal.NewName(name); kerbal.gender = gender; kerbal.type = veteran ? ProtoCrewMember.KerbalType.Crew : ProtoCrewMember.KerbalType.Applicant; KerbalRoster.SetExperienceTrait(kerbal, trait); kerbal.veteran = veteran; kerbal.isBadass = isBadass; kerbal.courage = courage; kerbal.stupidity = stupidity; if (HighLogic.CurrentGame != null && HighLogic.CurrentGame.Mode != Game.Modes.CAREER) { kerbal.experienceLevel = 5; kerbal.experience = 99999; } }
internal static void Rename(ProtoCrewMember kerbal) { // First 4 Veterans if (CustomKerbals.Veteran(kerbal)) { return; } int index = HighLogic.CurrentGame.CrewRoster.Count; if (Settings.preserveOriginals) { // Originals First if (CustomKerbals.Original(kerbal, index)) { return; } } else { // Developers First if (CustomKerbals.Custom(kerbal, index)) { return; } } // GENERATE RANDOM KERBAL if (Settings.generateStats || Settings.generateFirstNames || Settings.generateLastNames) { // Get the hash for this Kerbal hash = new Random(seed); // GENERATE STATS if (Settings.generateStats && kerbal?.type == ProtoCrewMember.KerbalType.Applicant) { Debug.Log("KerbalRenamer.Rename", "Generating Stats"); // generate some new stats kerbal.stupidity = 1 - hash.Get(useBellCurveMethod: Settings.useBellCurveMethod); kerbal.courage = hash.Get(useBellCurveMethod: Settings.useBellCurveMethod); kerbal.isBadass = (hash.Get() < Settings.badassPercent); float rand = hash.Get(to: 3); if (rand < 1) { KerbalRoster.SetExperienceTrait(kerbal, "Pilot"); } else if (rand < 2) { KerbalRoster.SetExperienceTrait(kerbal, "Engineer"); } else { KerbalRoster.SetExperienceTrait(kerbal, "Scientist"); } if (hash.Get() < Settings.femalePercent) { kerbal.gender = ProtoCrewMember.Gender.Female; } else { kerbal.gender = ProtoCrewMember.Gender.Male; } } // GENERATE NAME if (Settings.generateFirstNames || Settings.generateLastNames) { Debug.Log("KerbalRenamer.Rename", "Generating Full Name"); string fullName = ""; int count = 0; while (fullName.Length == 0 || HighLogic.CurrentGame.CrewRoster[fullName] != null) { fullName = getFullName(kerbal); if (count++ > 50) { return; } } Debug.Log("KerbalRenamer.Rename", "Generated Full Name = " + fullName); kerbal.NewName(fullName); } } }