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

35 lines
1000 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)
{
if (animator.IsAnchored)
{
Vector3 anchor = animator.getAnchor();
__result.x = anchor.x;
__result.y = anchor.y;
__result.z = anchor.z;
}
else
{
__result.y = AltitudeLayer.Pawn.AltitudeFor();
}
}
}
}
}