rjw-quirks/RJW-Quirks/HarmonyPatches/Patch_PartPreferenceDetecto...

27 lines
1007 B
C#

using HarmonyLib;
using rjw.Modules.Interactions.Contexts;
using rjw.Modules.Interactions.Internals.Implementation;
using rjw.Modules.Interactions.Rules.PartKindUsageRules;
using rjwquirks.Modules.Interactions;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace rjwquirks.HarmonyPatches
{
[HarmonyPatch(typeof(PartPreferenceDetectorService), nameof(PartPreferenceDetectorService.DetectPartPreferences))]
public class Patch_PartPreferenceDetectorService
{
public static void Prefix(InteractionContext context, IList<IPartPreferenceRule> ____partKindUsageRules)
{
if (____partKindUsageRules.Any(x => x.GetType() == typeof(QuirksPartKindUsageRule)) || (context.Internals.Submissive.Pawn.GetQuirks() == null || context.Internals.Dominant.Pawn.GetQuirks() == null))
return;
____partKindUsageRules.Add(new QuirksPartKindUsageRule());
}
}
}