mirror of
https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
synced 2024-08-15 00:43:45 +00:00
50 lines
1.7 KiB
C#
50 lines
1.7 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)
|
|
{
|
|
|
|
// ADJUST FACING get rotated textures
|
|
// compare the previous tick to the current tick; if the current tick rotation is different, recache
|
|
|
|
Rot4 animFacing = extendedAnimWorker.facingAtTick(__instance.tree.AnimationTick);
|
|
|
|
if (extendedAnimWorker.facingAtTick(__instance.tree.AnimationTick - 1) != extendedAnimWorker.facingAtTick(__instance.tree.AnimationTick))
|
|
{
|
|
__instance.requestRecache = true;
|
|
parms.facing = animFacing;
|
|
}
|
|
|
|
//INVIS IF ANIM CALLS FOR IT
|
|
//replace maybe?
|
|
|
|
//cheaper call now comparing prev tick to cur tick
|
|
if (extendedAnimWorker.visibleAtTick(__instance.tree.AnimationTick - 1) != extendedAnimWorker.visibleAtTick(__instance.tree.AnimationTick))
|
|
{
|
|
__instance.requestRecache = true;
|
|
return extendedAnimWorker.visibleAtTick(__instance.tree.AnimationTick);
|
|
}
|
|
|
|
}
|
|
|
|
return true;
|
|
|
|
}
|
|
}
|
|
}
|