rimworld-animations/1.4/Source/Patches/RimworldPatches/HarmonyPatch_SetPawnAnimata...

33 lines
759 B
C#
Raw Normal View History

2022-10-05 20:50:02 +00:00
using HarmonyLib;
using RimWorld;
using System.Collections.Generic;
using Verse;
namespace Rimworld_Animations
{
[HarmonyPatch(typeof(PawnRenderer), "RenderPawnAt")]
public static class PawnRenderer_RenderPawnAt_Patch
{
static bool ClearCache(Pawn pawn)
{
2023-12-03 06:48:42 +00:00
return pawn.IsInvisible() || CompBodyAnimator.IsAnimating(pawn);
2022-10-05 20:50:02 +00:00
}
public static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
{
foreach (CodeInstruction i in instructions)
{
2023-12-03 06:48:42 +00:00
if (i.Calls(AccessTools.Method(typeof(PawnUtility), nameof(PawnUtility.IsInvisible))))
2022-10-05 20:50:02 +00:00
{
2023-12-03 06:48:42 +00:00
yield return CodeInstruction.Call(typeof(PawnRenderer_RenderPawnAt_Patch), nameof(ClearCache));
2022-10-05 20:50:02 +00:00
}
else
{
yield return i;
}
}
}
}
}