Skip to content

Commit

Permalink
Generate random pawn name for trader subcores
Browse files Browse the repository at this point in the history
  • Loading branch information
eth0net committed Jan 25, 2023
1 parent cb8e6ff commit c59b7df
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 4 deletions.
Binary file modified Assemblies/SubcoreInfo.dll
Binary file not shown.
21 changes: 20 additions & 1 deletion Source/SubcoreInfo/Comps/SubcoreInfoComp.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Verse;
using RimWorld;
using Verse;

namespace SubcoreInfo
{
Expand All @@ -21,5 +22,23 @@ public override bool AllowStackWith(Thing other)

return PatternName == otherComp.PatternName;
}

/// <summary>
/// PostPostGeneratedForTrader is called after the subcore is generated for a trader.
/// </summary>
/// <param name="trader"></param>
/// <param name="forTile"></param>
/// <param name="forFaction"></param>
public override void PostPostGeneratedForTrader(TraderKindDef trader, int forTile, Faction forFaction)
{
base.PostPostGeneratedForTrader(trader, forTile, forFaction);

Gender gender = Rand.Bool ? Gender.Male : Gender.Female;
PawnKindDef pawnKind = forFaction.RandomPawnKind();
RulePackDef pawnKindNameMaker = pawnKind.GetNameMaker(gender);
RulePackDef raceNameGenerator = pawnKind.RaceProps.GetNameGenerator(gender);

PatternName = PawnBioAndNameGenerator.GenerateFullPawnName(parent.def, pawnKindNameMaker, null, null, raceNameGenerator, null, gender);
}
}
}
4 changes: 1 addition & 3 deletions Source/SubcoreInfo/SubcoreInfo.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props"
Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
Expand Down Expand Up @@ -69,6 +68,5 @@
<ItemGroup>
<None Include="packages.config" />
</ItemGroup>
<ItemGroup />
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
</Project>

0 comments on commit c59b7df

Please sign in to comment.