rimworld-animations/1.5/Source/Patches/RimworldPatches/HarmonyPatch_PawnRenderNode.cs
c0ffee e8fd61fb4a Rewrote anim framework to use vanilla animation system
- added extended functionality for head rotations, invisible
 - tentative design for groupanimationdefs
2024-04-16 15:10:46 -07:00

45 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
if (!extendedAnimWorker.visibleAtTick(__instance.tree.AnimationTick))
{
__instance.requestRecache = true;
return false;
}
// HEAD ROTATION ADJUST FACING
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;
}
}
}