Closed sumghai closed 2 years ago
I believe I know where is the problem. In GenerateRandomAgePrefix
, there is an if statement to stop the method early if pawn has fixed gender.
if (request.FixedGender.HasValue || !pawn.RaceProps.hasGenders) return;
But this condition ignores the KindDef value in the request. The whole condition should probably look like this:
if (request.FixedGender.HasValue || request.KindDef.fixedGender.HasValue || !pawn.RaceProps.hasGenders) return;
I see that the bug has been fixed. So this issue can be closed.
I've confirmed that 8897ea6 works in my own race mod. Thanks @erdelf and @Euphoric!
Issue Description
When spawning pawns with the HAR framework, their
PawnKindDef
'sfixedGender
tag is ignored.This means that if, for example, a custom human or alien pawnkind is set to be female-only via
<fixedGender>Female</fixedGender>
, both males and females are still spawned at the default gender ratio for that race.Expected Behaviour
HAR should account for the
PawnKindDef
'sfixedGender
value, and ensure than human/alien pawns strict gender requirements are spawned correctly.Steps to Reproduce
Baseline behaviour a. Start a new savegame with only Core active b. Using the dev mode debug actions menu > Spawn Pawn button, spawn 20
Grenadier_Destructive
pawns onto the map c. Observe that there is a mix of both male and female grenadier pawnsModified Core files a. Open
RimWorld\Data\Core\Defs\PawnKindDefs_Humanlikes\PawnKinds_Mercenary.xml
in a text editor b. Add<fixedGender>Female</fixedGender>
to the definition forGrenadier_Destructive
c. Save all changes d. Start a new savegame with only (the modified) Core active e. Using the dev mode debug actions menu > Spawn Pawn button, spawn 20Grenadier_Destructive
pawns onto the map f. Observe that all grenadiers are female, as expected and desiredModified Core files + HAR a. Start a new savegame with the modified Core (from section 2) and HAR b. Using the dev mode debug actions menu > Spawn Pawn button, spawn 20
Grenadier_Destructive
pawns onto the map c. Observe that there is a mix of both male and female grenadier pawns, despitefixedGender
being set to FemaleAdditional Information
Verse.PawnGenerator.TryGenerateNewPawnInternal()
is whererequest.KindDef.fixedGender.Value
is used, so this might be a good place to start investigating.System and Game Configuration
Operating System: Microsoft Windows 10 (64-bit), Version 21H1 (OS Build 19043.1237) Physical RAM: 16.0 GB RimWorld base game version: 1.3.3117 RimWorld DLCs loaded: none Mod list: