From 78f5153c80c44b0bf84a0c44eb028d0451fe1940 Mon Sep 17 00:00:00 2001 From: edbmods Date: Wed, 29 Aug 2018 17:46:04 -0700 Subject: [PATCH 1/6] Added missing backstories. Added faction-only backstory filter. --- .../English/Keyed/EdBPrepareCarefully.xml | 4 +++ Source/PanelBackstory.cs | 2 +- Source/ProviderBackstories.cs | 27 ++----------------- 3 files changed, 7 insertions(+), 26 deletions(-) diff --git a/Resources/Languages/English/Keyed/EdBPrepareCarefully.xml b/Resources/Languages/English/Keyed/EdBPrepareCarefully.xml index 487a7fb..88a14a7 100644 --- a/Resources/Languages/English/Keyed/EdBPrepareCarefully.xml +++ b/Resources/Languages/English/Keyed/EdBPrepareCarefully.xml @@ -1,5 +1,8 @@  + + + @@ -105,6 +108,7 @@ No Skill Penalties Bonus: {0} +{1} Skill Bonus: {0}, +{1} or better + Faction backstories only Select a location You must select a location diff --git a/Source/PanelBackstory.cs b/Source/PanelBackstory.cs index 873436f..653c1ce 100644 --- a/Source/PanelBackstory.cs +++ b/Source/PanelBackstory.cs @@ -23,6 +23,7 @@ public class PanelBackstory : PanelBase { private List> availableFilters = new List>(); private List> activeFilters = new List>(); public PanelBackstory() { + availableFilters.Add(new FilterBackstoryMatchesFaction()); availableFilters.Add(new FilterBackstoryNoDisabledWorkTypes()); availableFilters.Add(new FilterBackstoryNoPenalties()); foreach (var s in DefDatabase.AllDefs) { @@ -148,7 +149,6 @@ protected void ShowBackstoryDialog(CustomPawn customPawn, BackstorySlot slot) { Backstory originalBackstory = (slot == BackstorySlot.Childhood) ? customPawn.Childhood : customPawn.Adulthood; Backstory selectedBackstory = originalBackstory; Filter filterToRemove = null; - Filter filterToAdd = null; bool filterListDirtyFlag = true; List fullOptionsList = slot == BackstorySlot.Childhood ? this.providerBackstories.GetChildhoodBackstoriesForPawn(customPawn) : this.providerBackstories.GetAdulthoodBackstoriesForPawn(customPawn); diff --git a/Source/ProviderBackstories.cs b/Source/ProviderBackstories.cs index de6ae48..9a86345 100644 --- a/Source/ProviderBackstories.cs +++ b/Source/ProviderBackstories.cs @@ -45,38 +45,15 @@ public ProviderBackstories() { } private void InitializeBackstoriesForPawnKind(PawnKindDef def) { - HashSet pawnKindBackstoryCategories = new HashSet(def.backstoryCategories); List childhood = BackstoryDatabase.allBackstories.Values.Where((b) => { - if (b.slot != BackstorySlot.Childhood) { - return false; - } - if (def.backstoryCategories == null || def.backstoryCategories.Count == 0) { - return true; - } - foreach (var c in b.spawnCategories) { - if (pawnKindBackstoryCategories.Contains(c)) { - return true; - } - } - return false; + return (b.slot == BackstorySlot.Childhood); }).ToList(); childhood.Sort((b1, b2) => b1.TitleCapFor(Gender.Male).CompareTo(b2.TitleCapFor(Gender.Male))); childhoodBackstoryLookup[def.defName] = childhood; List adulthood = BackstoryDatabase.allBackstories.Values.Where((b) => { - if (b.slot != BackstorySlot.Adulthood) { - return false; - } - if (def.backstoryCategories == null || def.backstoryCategories.Count == 0) { - return true; - } - foreach (var c in b.spawnCategories) { - if (pawnKindBackstoryCategories.Contains(c)) { - return true; - } - } - return false; + return (b.slot == BackstorySlot.Adulthood); }).ToList(); adulthood.Sort((b1, b2) => b1.TitleCapFor(Gender.Male).CompareTo(b2.TitleCapFor(Gender.Male))); adulthoodBackstoryLookup[def.defName] = adulthood; From b0f1656515adb9d97d1990c5679a328d2cb0963f Mon Sep 17 00:00:00 2001 From: edbmods Date: Wed, 29 Aug 2018 17:46:33 -0700 Subject: [PATCH 2/6] Fixed backstory randomizer reflection calls. --- Source/ControllerPawns.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/ControllerPawns.cs b/Source/ControllerPawns.cs index 02c6d60..b5312a8 100644 --- a/Source/ControllerPawns.cs +++ b/Source/ControllerPawns.cs @@ -104,10 +104,10 @@ public void RandomizeBackstories() { factionDef = Faction.OfPlayer.def; } MethodInfo method = typeof(PawnBioAndNameGenerator).GetMethod("FillBackstorySlotShuffled", BindingFlags.Static | BindingFlags.NonPublic); - object[] arguments = new object[] { currentPawn.Pawn, BackstorySlot.Childhood, null, factionDef }; + object[] arguments = new object[] { currentPawn.Pawn, BackstorySlot.Childhood, null, kindDef.backstoryCategories, factionDef }; method.Invoke(null, arguments); currentPawn.Childhood = arguments[2] as Backstory; - arguments = new object[] { currentPawn.Pawn, BackstorySlot.Adulthood, null, factionDef }; + arguments = new object[] { currentPawn.Pawn, BackstorySlot.Adulthood, null, kindDef.backstoryCategories, factionDef }; method.Invoke(null, arguments); currentPawn.Adulthood = arguments[2] as Backstory; } From d4f2dbd33aabc9f64d59d75e57726ed913ec531d Mon Sep 17 00:00:00 2001 From: edbmods Date: Wed, 29 Aug 2018 17:47:03 -0700 Subject: [PATCH 3/6] Added missing faction filter class. --- EdBPrepareCarefully.csproj | 1 + Source/FilterBackstoryMatchesFaction.cs | 28 +++++++++++++++++++++++++ 2 files changed, 29 insertions(+) create mode 100644 Source/FilterBackstoryMatchesFaction.cs diff --git a/EdBPrepareCarefully.csproj b/EdBPrepareCarefully.csproj index 2da9393..acfaf3e 100644 --- a/EdBPrepareCarefully.csproj +++ b/EdBPrepareCarefully.csproj @@ -59,6 +59,7 @@ + diff --git a/Source/FilterBackstoryMatchesFaction.cs b/Source/FilterBackstoryMatchesFaction.cs new file mode 100644 index 0000000..2792394 --- /dev/null +++ b/Source/FilterBackstoryMatchesFaction.cs @@ -0,0 +1,28 @@ +using RimWorld; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Verse; + +namespace EdB.PrepareCarefully { + class FilterBackstoryMatchesFaction : Filter { + public FilterBackstoryMatchesFaction() { + this.LabelShort = this.LabelFull = "EdB.PC.Dialog.Backstory.Filter.MatchesFaction".Translate(); + this.FilterFunction = (Backstory backstory) => { + CustomPawn pawn = PrepareCarefully.Instance.State.CurrentPawn; + PawnKindDef kindDef = pawn.Pawn.kindDef; + HashSet pawnKindBackstoryCategories = new HashSet(kindDef.backstoryCategories); + if (kindDef.backstoryCategories == null || kindDef.backstoryCategories.Count == 0) { + return true; + } + foreach (var c in backstory.spawnCategories) { + if (pawnKindBackstoryCategories.Contains(c)) { + return true; + } + } + return false; + }; + } + } +} From 0dc33c246be9ff4a5d3368b22ccfaecb14ce134c Mon Sep 17 00:00:00 2001 From: edbmods Date: Wed, 29 Aug 2018 17:48:56 -0700 Subject: [PATCH 4/6] Incremented version number to 0.19.9 --- Resources/About/About.xml | 2 +- Resources/CHANGELOG.txt | 9 +++++++++ ResourcesUnstable/About/About.xml | 2 +- 3 files changed, 11 insertions(+), 2 deletions(-) diff --git a/Resources/About/About.xml b/Resources/About/About.xml index 84a21af..cd2f1b0 100644 --- a/Resources/About/About.xml +++ b/Resources/About/About.xml @@ -8,6 +8,6 @@ If you get a set of starting colonists that you like, save them as a preset so that you can start your game the same way next time. -[Version 0.19.8] +[Version 0.19.9] \ No newline at end of file diff --git a/Resources/CHANGELOG.txt b/Resources/CHANGELOG.txt index 6a82090..e78dba1 100644 --- a/Resources/CHANGELOG.txt +++ b/Resources/CHANGELOG.txt @@ -1,3 +1,12 @@ + _____________________________________________________________________________ + + Version 0.19.9 + _____________________________________________________________________________ + + - Fixed problem when randomizing backstories. + - Added missing backstories back to the backstory dialogs. + - Added a "matching faction only" backstory filter. + _____________________________________________________________________________ Version 0.19.8 diff --git a/ResourcesUnstable/About/About.xml b/ResourcesUnstable/About/About.xml index 5b12bd3..516a418 100644 --- a/ResourcesUnstable/About/About.xml +++ b/ResourcesUnstable/About/About.xml @@ -10,6 +10,6 @@ If you get a set of starting colonists that you like, save them as a preset so t THIS IS A TEST VERSION OF THE MOD FOR THE UNSTABLE PUBLIC TESTING VERSION OF RIMWORLD. -[Version 0.19.8] +[Version 0.19.9] \ No newline at end of file From 485490e110eeaf54cc0f2a69db2da1e275053756 Mon Sep 17 00:00:00 2001 From: edbmods Date: Sat, 1 Sep 2018 14:40:20 -0700 Subject: [PATCH 5/6] Fixed the initialization for humanlike hairs to avoid incorrectly filtering out those are the allowed for alien races. --- Source/ProviderHair.cs | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Source/ProviderHair.cs b/Source/ProviderHair.cs index bb7527c..a5783f7 100644 --- a/Source/ProviderHair.cs +++ b/Source/ProviderHair.cs @@ -98,6 +98,13 @@ protected OptionsHair HumanlikeHairs { } protected OptionsHair InitializeHumanlikeHairs() { HashSet nonHumanHairTags = new HashSet(); + // This was meant to remove alien race-specific hair defs from those available when customizing non-aliens. + // However, there's no way to distinguish between hair tags that are ONLY for aliens vs. the non-alien + // hair defs that are also allow for aliens. This makes the logic below fail. Instead, we'll include + // all hair def (both alien and non-alien) in the list of available hairs for non-aliens. + // TODO: Implement filtering in the hair selection to make it easier to find appropriate hairs when there + // are a lot of mods that add hairs. + /* IEnumerable alienRaces = DefDatabase.AllDefs.Where((ThingDef def) => { return def.race != null && ProviderAlienRaces.IsAlienRace(def); }); @@ -112,6 +119,7 @@ protected OptionsHair InitializeHumanlikeHairs() { } } } + */ OptionsHair result = new OptionsHair(); foreach (HairDef hairDef in DefDatabase.AllDefs.Where((HairDef def) => { foreach (var tag in def.hairTags) { From 7a604ec01301778df549f1c81b862739f7633ed8 Mon Sep 17 00:00:00 2001 From: edbmods Date: Sat, 1 Sep 2018 14:43:26 -0700 Subject: [PATCH 6/6] Updated assembly version number and update changelog. --- Properties/AssemblyInfo.cs | 2 +- Resources/CHANGELOG.txt | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index 9757820..4cc7356 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -17,7 +17,7 @@ // The form "{Major}.{Minor}.*" will automatically update the build and revision, // and "{Major}.{Minor}.{Build}.*" will update just the revision. -[assembly: AssemblyVersion("0.19.8")] +[assembly: AssemblyVersion("0.19.9")] // The following attributes are used to specify the signing key for the assembly, // if desired. See the Mono documentation for more information about signing. diff --git a/Resources/CHANGELOG.txt b/Resources/CHANGELOG.txt index e78dba1..e796e91 100644 --- a/Resources/CHANGELOG.txt +++ b/Resources/CHANGELOG.txt @@ -3,9 +3,11 @@ Version 0.19.9 _____________________________________________________________________________ - - Fixed problem when randomizing backstories. + - Fixed a problem when randomizing backstories. - Added missing backstories back to the backstory dialogs. - Added a "matching faction only" backstory filter. + - Fixed a problem where hair selections were being removed due to specific + alien races. Now all hairs are available for "humanlike" pawns. _____________________________________________________________________________