rjw_menstruation/1.4/source/RJW_Menstruation/RJW_Menstruation/Patch/Harmony.cs

37 lines
1.5 KiB
C#

using HarmonyLib;
using rjw;
using rjw.Modules.Interactions.Internals.Implementation;
using rjw.Modules.Interactions.Rules.PartKindUsageRules;
using rjw.Modules.Shared.Logs;
using System.Collections.Generic;
using System.Reflection;
using Verse;
namespace RJW_Menstruation
{
[StaticConstructorOnStartup]
internal static class First
{
static First()
{
Harmony har = new Harmony("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(GenTypes.GetTypeInAnyAssembly("AlienRace.HarmonyPatches").GetMethod(nameof(AlienRace.HarmonyPatches.BirthOutcomeMultiplier)),
postfix: new HarmonyMethod(typeof(HAR_LitterSize_Undo).GetMethod(nameof(HAR_LitterSize_Undo.Postfix))));
}
InjectIntoRjwInteractionServices();
}
private static void InjectIntoRjwInteractionServices()
{
ILog log = LogManager.GetLogger("StaticConstructorOnStartup");
List<IPartPreferenceRule> partKindUsageRules = Unprivater.GetProtectedValue<List<IPartPreferenceRule>>("_partKindUsageRules", typeof(PartPreferenceDetectorService));
partKindUsageRules.Add(new Interactions.EstrusPartKindUsageRule());
log.Message("Added 1 rule to PartPreferenceDetectorService._partKindUsageRules");
}
}
}