2024-04-22 17:56:34 +00:00
|
|
|
|
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;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-25 19:02:11 +00:00
|
|
|
|
protected Dictionary<int, Graphic> GraphicHediffVariantsFor(Pawn pawn)
|
2024-04-22 17:56:34 +00:00
|
|
|
|
{
|
|
|
|
|
|
2024-04-24 06:10:35 +00:00
|
|
|
|
if (props.hediffVariants == null)
|
|
|
|
|
{
|
2024-04-25 18:58:34 +00:00
|
|
|
|
Log.Error("[Anims] Error: Tried to use GraphicHediffVariants node, but hediffVariants weren't given");
|
2024-04-24 06:10:35 +00:00
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-22 17:56:34 +00:00
|
|
|
|
//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,
|
2024-04-25 18:17:51 +00:00
|
|
|
|
if (pawn?.health?.hediffSet?.hediffs is List<Hediff> pawnHediffs && pawnHediffs.Any((Hediff hediff) => hediff.def == hediffDef))
|
2024-04-22 17:56:34 +00:00
|
|
|
|
{
|
|
|
|
|
//return that specific variant
|
2024-04-25 18:17:51 +00:00
|
|
|
|
curHediff = hediffDef;
|
2024-04-22 17:56:34 +00:00
|
|
|
|
return GenerateVariants(pawn, texPathVariant_Hediff.texPathVariantsDef);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-25 18:58:34 +00:00
|
|
|
|
//there is no graphic hediff variants appropriate
|
2024-04-22 17:56:34 +00:00
|
|
|
|
curHediff = null;
|
2024-04-25 18:58:34 +00:00
|
|
|
|
return null;
|
2024-04-22 17:56:34 +00:00
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override void EnsureMaterialsInitialized()
|
|
|
|
|
{
|
|
|
|
|
//if pawn no longer has the hediff,
|
2024-04-25 18:17:51 +00:00
|
|
|
|
if (variants == null ||
|
2024-04-22 17:56:34 +00:00
|
|
|
|
(this.tree.pawn.health?.hediffSet?.hediffs is List<Hediff> hediffs
|
|
|
|
|
&& hediffs.Any((Hediff hediff) => hediff.def == curHediff)))
|
|
|
|
|
{
|
2024-04-25 18:58:34 +00:00
|
|
|
|
//do graphicvariantsfor
|
2024-04-25 19:02:11 +00:00
|
|
|
|
variants = GraphicHediffVariantsFor(this.tree.pawn);
|
2024-04-22 17:56:34 +00:00
|
|
|
|
}
|
2024-04-25 18:58:34 +00:00
|
|
|
|
|
|
|
|
|
//call this in case variants wasn't set, and there is no graphic hediff variants appropriate; it'll set variants based on default
|
|
|
|
|
base.EnsureMaterialsInitialized();
|
2024-04-22 17:56:34 +00:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|