rimworld-animations/1.5/Source/Patches/RimworldPatches/HarmonyPatch_Pawn_DrawTrack...

27 lines
831 B
C#

using HarmonyLib;
using rjw;
using UnityEngine;
using Verse;
namespace Rimworld_Animations {
[HarmonyPatch(typeof(Pawn_DrawTracker), "DrawPos", MethodType.Getter)]
public static class HarmonyPatch_Pawn_DrawTracker {
//switch to postfix to get pawn original height first
public static void Postfix(ref Pawn ___pawn, ref Vector3 __result) {
//align pos on top of partner, position, etc., based on animatoranchor
if (___pawn.TryGetComp<CompExtendedAnimator>() is CompExtendedAnimator animator
&& animator.IsAnchored)
{
Vector3 anchor = animator.getAnchor();
//ignore y so that pawns don't clip through stuff
__result.x = anchor.x;
__result.z = anchor.z;
}
}
}
}