mirror of
https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
synced 2024-08-15 00:43:45 +00:00
35 lines
1.4 KiB
C#
35 lines
1.4 KiB
C#
using HarmonyLib;
|
|
using RimWorld;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using Verse;
|
|
|
|
namespace Rimworld_Animations
|
|
{
|
|
[HarmonyPatch(typeof(PawnRenderTree), "TryGetMatrix")]
|
|
public class HarmonyPatch_PawnRenderTree
|
|
{
|
|
public static void Prefix(PawnRenderTree __instance, PawnRenderNode node, ref PawnDrawParms parms)
|
|
{
|
|
//Note: Maybe need to change this to check all ancestors if it's the head node
|
|
//in case of deeper nodes in the PawnRenderTree
|
|
//This code only checks for node and parent, if either are head
|
|
|
|
|
|
// Change facing for all head and apparelhead nodes
|
|
// So that the offset is based on body rotation, not head rotation
|
|
|
|
//fixes misaligned hairs and headaddons
|
|
if ((node.Props.tagDef == PawnRenderNodeTagDefOf.Head || node.Props.tagDef == PawnRenderNodeTagDefOf.ApparelHead
|
|
|| node?.parent?.Props?.tagDef == PawnRenderNodeTagDefOf.Head || node?.parent?.Props?.tagDef == PawnRenderNodeTagDefOf.ApparelHead)
|
|
&& node.tree.rootNode.AnimationWorker is AnimationWorker_KeyframesExtended rootNodeAnimationWorker)
|
|
{
|
|
|
|
parms.facing = rootNodeAnimationWorker.facingAtTick(node.tree.AnimationTick);
|
|
}
|
|
}
|
|
}
|
|
}
|