A bunch of type-safety around HAR.

This commit is contained in:
lutepickle 2023-01-10 16:09:37 -08:00
parent 2cb26ea016
commit 3132992aa3
4 changed files with 3 additions and 2 deletions

Binary file not shown.

View File

@ -1,4 +1,5 @@
using AlienRace;
using System;
using System.Collections.Generic;
using UnityEngine;
using Verse;
@ -11,7 +12,7 @@ namespace RJW_Menstruation
public static bool IsHAR(this Pawn pawn)
{
if (!Configurations.HARActivated) return false;
return pawn?.def is ThingDef_AlienRace;
return GenTypes.GetTypeInAnyAssembly("AlienRace.ThingDef_AlienRace").IsInstanceOfType(pawn?.def);
}
public static void CopyHARProperties(Pawn baby, Pawn original)

View File

@ -19,7 +19,7 @@ namespace RJW_Menstruation
har.PatchAll(Assembly.GetExecutingAssembly());
if (ModsConfig.IsActive("erdelf.HumanoidAlienRaces")) // Don't use the cached in Configurations, it isn't initialized yet
{
har.Patch(typeof(AlienRace.HarmonyPatches).GetMethod(nameof(AlienRace.HarmonyPatches.BirthOutcomeMultiplier)),
har.Patch(GenTypes.GetTypeInAnyAssembly("AlienRace.HarmonyPatches").GetMethod(nameof(AlienRace.HarmonyPatches.BirthOutcomeMultiplier)),
postfix: new HarmonyMethod(typeof(HAR_LitterSize_Undo).GetMethod(nameof(HAR_LitterSize_Undo.Postfix))));
}