rimworld-animations-patch_m.../Source/Scripts/Patches/HarmonyPatch_RJWEvents.cs

45 lines
1.3 KiB
C#
Raw Normal View History

2022-10-02 02:14:35 +00:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
using HarmonyLib;
using RJW_Events;
namespace Rimworld_Animations_Patch
{
[StaticConstructorOnStartup]
public static class HarmonyPatch_RJWEvents
{
static HarmonyPatch_RJWEvents()
{
try
{
((Action)(() =>
{
if (LoadedModManager.RunningModsListForReading.Any(x => x.PackageIdPlayerFacing == "c0ffee.rjw.events"))
{
(new Harmony("Rimworld_Animations_Patch")).Patch(AccessTools.Method(typeof(ThinkNode_ConditionalNude), "Satisfied"),
prefix: new HarmonyMethod(AccessTools.Method(typeof(HarmonyPatch_RJWEvents), "Postfix_ThinkNode_ConditionalNude_Satisfied")));
}
}))();
}
2023-02-04 07:13:57 +00:00
catch (TypeLoadException) { }
2022-10-02 02:14:35 +00:00
}
public static bool Postfix_ThinkNode_ConditionalNude_Satisfied(ref bool __result, Pawn pawn)
{
if (__result == false && pawn?.apparel?.WornApparel != null)
{
// If 'isBeingWorn' has a value, the apparel has already been checked if it should be discarded
2023-02-04 07:13:57 +00:00
if (pawn.apparel.WornApparel.NullOrEmpty() || pawn.apparel.WornApparel.Any(x => x.TryGetComp<CompApparelVisibility>() != null && x.TryGetComp<CompApparelVisibility>().isBeingWorn.HasValue))
2022-10-02 02:14:35 +00:00
{ __result = true; }
}
return false;
}
}
}