rimworld-animations/1.5/Source/Patches/RimworldPatches/HarmonyPatch_PawnRenderNode.cs

48 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
{
//Head Rotation Code
[HarmonyPatch(typeof(PawnRenderNode), "AppendRequests")]
public static class HarmonyPatch_PawnRenderNode
{
//if rendernodetag is head, update PawnDrawParms so that head, and all children, are rotated for anim
public static bool Prefix(ref PawnRenderNode __instance, ref PawnDrawParms parms)
{
if (__instance.AnimationWorker is AnimationWorker_KeyframesExtended extendedAnimWorker)
{
//INVIS IF ANIM CALLS FOR IT
//replace maybe?
if (!extendedAnimWorker.visibleAtTick(__instance.tree.AnimationTick))
{
__instance.requestRecache = true;
return false;
}
// HEAD ROTATION ADJUST FACING get rotated textures
Rot4 animFacing = extendedAnimWorker.facingAtTick(__instance.tree.AnimationTick);
if (parms.facing != animFacing)
{
//requestRecache or else it won't update properly
__instance.requestRecache = true;
parms.facing = animFacing;
}
}
return true;
}
}
}