﻿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(PawnRenderNodeWorker), "CanDrawNow")]
    public class HarmonyPatch_PawnRenderTreeWorker
    {
        public static bool Prefix(PawnRenderNode node, ref bool __result)
        {
            //switching to this system so that head or body can be hidden separate from other nodes
            //(hide head but not addons, etc)
            //in case someone wanted to do that

            if (node.AnimationWorker is AnimationWorker_KeyframesExtended animWorker)
            {
                if (!animWorker.visibleAtTick(node.tree.AnimationTick))
                {
                    __result = false;
                    return false;
                }

                //visible when animating
                return true;
            }

            return true;
        }

    }

}

