rimworld-animations-patch_m.../Source/Scripts/Patches/HarmonyPatch_Pawn_ApparelTracker.cs
AbstractConcept f089b94044 v 1.2.2
2022-09-30 18:34:08 -05:00

43 lines
1.2 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RimWorld;
using Verse;
using HarmonyLib;
namespace Rimworld_Animations_Patch
{
[HarmonyPatch(typeof(Pawn_ApparelTracker), "HasBasicApparel")]
public static class HarmonyPatch_Pawn_ApparelTracker_HasBasicApparel
{
public static void Postfix(Pawn_ApparelTracker __instance, ref bool hasPants, ref bool hasShirt)
{
if (__instance?.pawn?.apparel?.WornApparel == null || __instance.pawn.apparel.WornApparel.NullOrEmpty()) return;
if (hasPants == false)
{
if (__instance.pawn.apparel.WornApparel.Any(x => x.def.apparel.bodyPartGroups.Contains(PatchBodyPartGroupDefOf.GenitalsBPG)))
{ hasPants = true; }
}
if (hasShirt == false)
{
if (__instance.pawn.apparel.WornApparel.Any(x => x.def.apparel.bodyPartGroups.Contains(PatchBodyPartGroupDefOf.ChestBPG)))
{ hasShirt = true; }
}
}
}
[HarmonyPatch(typeof(Pawn_ApparelTracker), "Notify_ApparelChanged")]
public static class HarmonyPatch_Pawn_ApparelTracker_Notify_ApparelChanged
{
public static void Postfix(Pawn_ApparelTracker __instance)
{
__instance?.pawn?.TryGetComp<CompPawnSexData>()?.UpdateBodyAddonVisibility();
}
}
}