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

45 lines
1.1 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using HarmonyLib;
using RimWorld;
using Verse;
using UnityEngine;
using System.Reflection;
using System.Reflection.Emit;
using Rimworld_Animations;
using rjw;
namespace Rimworld_Animations_Patch
{
[StaticConstructorOnStartup]
[HarmonyPatch(typeof(PawnGraphicSet), "ResolveAllGraphics")]
public static class HarmonyPatch_PawnGraphicSet_ResolveAllGraphics
{
// Update whether body parts are visible after resolving graphics
public static void Postfix(PawnGraphicSet __instance)
{
if (__instance?.pawn?.apparel == null)
{ return; }
if (__instance.pawn.GetAnimationData() != null)
{ return; }
if (__instance.pawn.apparel.WornApparel.NullOrEmpty() == false)
{
foreach (Apparel apparel in __instance.pawn.apparel.WornApparel)
{
CompApparelVisibility comp = apparel.TryGetComp<CompApparelVisibility>();
if (comp != null)
{
comp.isBeingWorn = null;
comp.rimNudeDataStatus = RimNudeDataStatus.NotLoaded;
}
}
}
__instance.pawn.TryGetComp<CompPawnSexData>()?.UpdateBodyAddonVisibility();
}
}
}