mirror of
https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
synced 2024-08-15 00:43:45 +00:00
62 lines
2 KiB
C#
62 lines
2 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using UnityEngine;
|
|
using Verse;
|
|
|
|
namespace Rimworld_Animations
|
|
{
|
|
public class PawnRenderNodeWorker_GraphicVariants : PawnRenderNodeWorker
|
|
{
|
|
|
|
public override bool CanDrawNow(PawnRenderNode node, PawnDrawParms parms)
|
|
{
|
|
if (parms.Portrait) return false;
|
|
|
|
//don't draw if not visible at tick
|
|
if (node.AnimationWorker is AnimationWorker_KeyframesExtended extendedAnimator
|
|
&& !extendedAnimator.visibleAtTick(node.tree.AnimationTick))
|
|
{
|
|
return false;
|
|
}
|
|
|
|
|
|
return base.CanDrawNow(node, parms);
|
|
}
|
|
protected override Material GetMaterial(PawnRenderNode node, PawnDrawParms parms)
|
|
{
|
|
|
|
//if node is animating, and is a graphic variant type of node
|
|
if ((node.AnimationWorker is AnimationWorker_KeyframesExtended extendedAnimWorker)
|
|
&& (node is PawnRenderNode_GraphicVariants nodeWithGraphicVariants)
|
|
&& extendedAnimWorker.TexPathVariantAtTick(node.tree.AnimationTick) != null)
|
|
{
|
|
//if node has a graphic variant,
|
|
int variant = (int)extendedAnimWorker.TexPathVariantAtTick(node.tree.AnimationTick);
|
|
|
|
//return the variant
|
|
return GetMaterialVariant(nodeWithGraphicVariants, parms, variant);
|
|
}
|
|
|
|
//otherwise return original texture
|
|
return base.GetMaterial(node, parms);
|
|
}
|
|
|
|
public virtual Material GetMaterialVariant(PawnRenderNode_GraphicVariants node, PawnDrawParms parms, int variant)
|
|
{
|
|
Material material = node.getGraphicVariant(variant).NodeGetMat(parms);
|
|
if (material != null && !parms.Portrait && parms.flags.FlagSet(PawnRenderFlags.Invisible))
|
|
{
|
|
material = InvisibilityMatPool.GetInvisibleMat(material);
|
|
}
|
|
|
|
return material;
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|