mirror of
https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
synced 2024-08-15 00:43:45 +00:00
68 lines
2.1 KiB
C#
68 lines
2.1 KiB
C#
|
using System;
|
|||
|
using System.Collections.Generic;
|
|||
|
using System.Linq;
|
|||
|
using System.Text;
|
|||
|
using System.Threading.Tasks;
|
|||
|
using Verse;
|
|||
|
|
|||
|
namespace Rimworld_Animations
|
|||
|
{
|
|||
|
public class PawnRenderNode_GraphicHediffVariants : PawnRenderNode_GraphicVariants
|
|||
|
{
|
|||
|
|
|||
|
protected new PawnRenderNodeProperties_GraphicHediffVariants props;
|
|||
|
private HediffDef curHediff;
|
|||
|
|
|||
|
public PawnRenderNode_GraphicHediffVariants(Pawn pawn, PawnRenderNodeProperties props, PawnRenderTree tree) : base(pawn, props, tree)
|
|||
|
{
|
|||
|
|
|||
|
this.props = (PawnRenderNodeProperties_GraphicHediffVariants)props;
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
protected override Dictionary<int, Graphic> GraphicVariantsFor(Pawn pawn)
|
|||
|
{
|
|||
|
|
|||
|
//for each different hediff-based texpathvariants,
|
|||
|
foreach (TexPathVariants_Hediff texPathVariant_Hediff in props.hediffVariants)
|
|||
|
{
|
|||
|
//for all the hediffs corresponding to that texpathvariant,
|
|||
|
foreach (HediffDef hediffDef in texPathVariant_Hediff.hediffs)
|
|||
|
{
|
|||
|
//if the pawn has that hediff,
|
|||
|
if (pawn.health.hediffSet.hediffs.Any((Hediff hediff) => hediff.def == hediffDef))
|
|||
|
{
|
|||
|
//return that specific variant
|
|||
|
curHediff = hediff.def;
|
|||
|
return GenerateVariants(pawn, texPathVariant_Hediff.texPathVariantsDef);
|
|||
|
|
|||
|
}
|
|||
|
}
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
//otherwise just use default
|
|||
|
curHediff = null;
|
|||
|
return base.GraphicVariantsFor(pawn);
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
protected override void EnsureMaterialsInitialized()
|
|||
|
{
|
|||
|
//if pawn no longer has the hediff,
|
|||
|
if (curHediff == null ||
|
|||
|
(this.tree.pawn.health?.hediffSet?.hediffs is List<Hediff> hediffs
|
|||
|
&& hediffs.Any((Hediff hediff) => hediff.def == curHediff)))
|
|||
|
{
|
|||
|
//redo graphicvariantsfor
|
|||
|
variants = GraphicVariantsFor(this.tree.pawn);
|
|||
|
}
|
|||
|
|
|||
|
base.EnsureMaterialsInitialized();
|
|||
|
}
|
|||
|
|
|||
|
|
|||
|
}
|
|||
|
|
|||
|
}
|