2024-04-17 23:57:18 +00:00
|
|
|
|
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)
|
|
|
|
|
{
|
|
|
|
|
|
2024-04-18 22:32:31 +00:00
|
|
|
|
// this is only for the Vector3 position to work right
|
2024-04-17 23:57:18 +00:00
|
|
|
|
parms.facing = rootNodeAnimationWorker.facingAtTick(node.tree.AnimationTick);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|