Move GetRacesPawnKind to Utility

This commit is contained in:
lutepickle 2022-07-18 07:00:15 -07:00
parent 76c2a67390
commit 697b837a4d
2 changed files with 11 additions and 14 deletions

View file

@ -451,16 +451,6 @@ namespace RJW_Menstruation
return baby;
}
public PawnKindDef GetRacesPawnKind(Pawn pawn)
{
if (pawn == null) return null;
if (pawn.kindDef?.race == pawn.def) return pawn.kindDef;
return VariousDefOf.AllKinds.Find(kind => kind.race == pawn.def && kind.defName.Contains("Colonist")) ??
VariousDefOf.AllKinds.Find(kind => kind.race == pawn.def) ??
pawn.def.race?.AnyPawnKind ??
pawn.kindDef;
}
/// <summary>
/// Decide pawnkind from mother and father <para/>
/// Come from RJW
@ -470,8 +460,8 @@ namespace RJW_Menstruation
/// <returns></returns>
public PawnKindDef BabyPawnKindDecider(Pawn mother, Pawn father)
{
PawnKindDef motherKindDef = GetRacesPawnKind(mother);
PawnKindDef fatherKindDef = GetRacesPawnKind(father);
PawnKindDef motherKindDef = Utility.GetRacesPawnKind(mother);
PawnKindDef fatherKindDef = Utility.GetRacesPawnKind(father);
PawnKindDef spawn_kind_def = motherKindDef;

View file

@ -49,8 +49,15 @@ namespace RJW_Menstruation
{
public static System.Random random = new System.Random(Environment.TickCount);
public static PawnKindDef GetRacesPawnKind(Pawn pawn)
{
if (pawn == null) return null;
if (pawn.kindDef?.race == pawn.def) return pawn.kindDef;
return VariousDefOf.AllKinds.Find(kind => kind.race == pawn.def && kind.defName.Contains("Colonist")) ??
VariousDefOf.AllKinds.Find(kind => kind.race == pawn.def) ??
pawn.def.race?.AnyPawnKind ??
pawn.kindDef;
}
public static float GetCumVolume(this Pawn pawn)
{