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

45 lines
1.1 KiB
C#
Raw Normal View History

2022-09-10 01:22:08 +00:00
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
{
2023-02-04 07:13:57 +00:00
// Update whether body parts are visible after resolving graphics
2022-09-10 01:22:08 +00:00
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)
{
2022-09-11 06:05:16 +00:00
foreach (Apparel apparel in __instance.pawn.apparel.WornApparel)
2022-09-10 01:22:08 +00:00
{
CompApparelVisibility comp = apparel.TryGetComp<CompApparelVisibility>();
if (comp != null)
2022-09-11 06:05:16 +00:00
{
2022-09-30 23:34:08 +00:00
comp.isBeingWorn = null;
2022-09-11 06:05:16 +00:00
comp.rimNudeDataStatus = RimNudeDataStatus.NotLoaded;
}
2022-09-10 01:22:08 +00:00
}
}
2022-10-01 03:51:09 +00:00
__instance.pawn.TryGetComp<CompPawnSexData>()?.UpdateBodyAddonVisibility();
2022-09-10 01:22:08 +00:00
}
}
}