Skip to content

Commit

Permalink
Merge pull request #239 from edbmods/develop
Browse files Browse the repository at this point in the history
Merge to master for 0.19.9
  • Loading branch information
edbmods authored Sep 1, 2018
2 parents 661cbf2 + 7a604ec commit 43ff5be
Show file tree
Hide file tree
Showing 11 changed files with 60 additions and 31 deletions.
1 change: 1 addition & 0 deletions EdBPrepareCarefully.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
<Compile Include="Source\ControllerRelationships.cs" />
<Compile Include="Source\CostCalculator.cs" />
<Compile Include="Source\CustomFaction.cs" />
<Compile Include="Source\FilterBackstoryMatchesFaction.cs" />
<Compile Include="Source\ParentChildGroup.cs" />
<Compile Include="Source\CustomPawnType.cs" />
<Compile Include="Source\DialogFactions.cs" />
Expand Down
2 changes: 1 addition & 1 deletion Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion Resources/About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
</description>
</ModMetaData>
11 changes: 11 additions & 0 deletions Resources/CHANGELOG.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,14 @@
_____________________________________________________________________________

Version 0.19.9
_____________________________________________________________________________

- 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.

_____________________________________________________________________________

Version 0.19.8
Expand Down
4 changes: 4 additions & 0 deletions Resources/Languages/English/Keyed/EdBPrepareCarefully.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8" ?>
<!-- CHANGE NOTES -->
<!-- v0.19.9 -->
<!-- NEW: EdB.PC.Dialog.Backstory.Filter.MatchesFaction -->

<!-- v0.19.8 -->
<!-- UPDATED: EdB.PC.Panel.Incapable.Warning -->

Expand Down Expand Up @@ -105,6 +108,7 @@
<EdB.PC.Dialog.Backstory.Filter.NoSkillPenalties>No Skill Penalties</EdB.PC.Dialog.Backstory.Filter.NoSkillPenalties>
<EdB.PC.Dialog.Backstory.Filter.SkillBonus>Bonus: {0} +{1}</EdB.PC.Dialog.Backstory.Filter.SkillBonus>
<EdB.PC.Dialog.Backstory.Filter.SkillBonusFull>Skill Bonus: {0}, +{1} or better</EdB.PC.Dialog.Backstory.Filter.SkillBonusFull>
<EdB.PC.Dialog.Backstory.Filter.MatchesFaction>Faction backstories only</EdB.PC.Dialog.Backstory.Filter.MatchesFaction>

<EdB.PC.Dialog.BodyPart.Header>Select a location</EdB.PC.Dialog.BodyPart.Header>
<EdB.PC.Dialog.BodyPart.Error.Required>You must select a location</EdB.PC.Dialog.BodyPart.Error.Required>
Expand Down
2 changes: 1 addition & 1 deletion ResourcesUnstable/About/About.xml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
</description>
</ModMetaData>
4 changes: 2 additions & 2 deletions Source/ControllerPawns.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
28 changes: 28 additions & 0 deletions Source/FilterBackstoryMatchesFaction.cs
Original file line number Diff line number Diff line change
@@ -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<Backstory> {
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<string> pawnKindBackstoryCategories = new HashSet<string>(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;
};
}
}
}
2 changes: 1 addition & 1 deletion Source/PanelBackstory.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ public class PanelBackstory : PanelBase {
private List<Filter<Backstory>> availableFilters = new List<Filter<Backstory>>();
private List<Filter<Backstory>> activeFilters = new List<Filter<Backstory>>();
public PanelBackstory() {
availableFilters.Add(new FilterBackstoryMatchesFaction());
availableFilters.Add(new FilterBackstoryNoDisabledWorkTypes());
availableFilters.Add(new FilterBackstoryNoPenalties());
foreach (var s in DefDatabase<SkillDef>.AllDefs) {
Expand Down Expand Up @@ -148,7 +149,6 @@ protected void ShowBackstoryDialog(CustomPawn customPawn, BackstorySlot slot) {
Backstory originalBackstory = (slot == BackstorySlot.Childhood) ? customPawn.Childhood : customPawn.Adulthood;
Backstory selectedBackstory = originalBackstory;
Filter<Backstory> filterToRemove = null;
Filter<Backstory> filterToAdd = null;
bool filterListDirtyFlag = true;
List<Backstory> fullOptionsList = slot == BackstorySlot.Childhood ?
this.providerBackstories.GetChildhoodBackstoriesForPawn(customPawn) : this.providerBackstories.GetAdulthoodBackstoriesForPawn(customPawn);
Expand Down
27 changes: 2 additions & 25 deletions Source/ProviderBackstories.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,38 +45,15 @@ public ProviderBackstories() {
}

private void InitializeBackstoriesForPawnKind(PawnKindDef def) {

HashSet<string> pawnKindBackstoryCategories = new HashSet<string>(def.backstoryCategories);
List<Backstory> 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<Backstory> 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;
Expand Down
8 changes: 8 additions & 0 deletions Source/ProviderHair.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,13 @@ protected OptionsHair HumanlikeHairs {
}
protected OptionsHair InitializeHumanlikeHairs() {
HashSet<string> nonHumanHairTags = new HashSet<string>();
// 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<ThingDef> alienRaces = DefDatabase<ThingDef>.AllDefs.Where((ThingDef def) => {
return def.race != null && ProviderAlienRaces.IsAlienRace(def);
});
Expand All @@ -112,6 +119,7 @@ protected OptionsHair InitializeHumanlikeHairs() {
}
}
}
*/
OptionsHair result = new OptionsHair();
foreach (HairDef hairDef in DefDatabase<HairDef>.AllDefs.Where((HairDef def) => {
foreach (var tag in def.hairTags) {
Expand Down

0 comments on commit 43ff5be

Please sign in to comment.