bugfixing hediff variants and body type variants

This commit is contained in:
c0ffee 2024-04-25 11:17:51 -07:00
parent df3a670d6f
commit 3cc7985515
5 changed files with 25 additions and 27 deletions

View file

@ -2,7 +2,7 @@
<Defs>
<AnimationDef>
<defName>TestAnimation2</defName>
<durationTicks>120</durationTicks>
<durationTicks>400</durationTicks>
<startOnRandomTick>False</startOnRandomTick>
<playWhenDowned>False</playWhenDowned>
@ -13,32 +13,35 @@
<workerClass>Rimworld_Animations.AnimationWorker_KeyframesExtended</workerClass>
<keyframes>
<li Class="Rimworld_Animations.ExtendedKeyframe">
<offset>(1, 0, 0)</offset>
<tick>0</tick>
<angle>0</angle>
<rotation>North</rotation>
<rotation>South</rotation>
</li>
<li Class="Rimworld_Animations.ExtendedKeyframe">
<offset>(0, 0, 0)</offset>
<tick>30</tick>
<angle>15</angle>
<rotation>North</rotation>
<tick>100</tick>
<angle>45</angle>
<rotation>South</rotation>
</li>
<li Class="Rimworld_Animations.ExtendedKeyframe">
<offset>(-1, 0, 0)</offset>
<tick>60</tick>
<tick>0</tick>
<offset>(-0.73, 0, -0.02)</offset>
<angle>0</angle>
<rotation>North</rotation>
<rotation>East</rotation>
</li>
<li Class="Rimworld_Animations.ExtendedKeyframe">
<offset>(0, 0, 0)</offset>
<tick>90</tick>
<angle>-15</angle>
<rotation>North</rotation>
<tick>200</tick>
<angle>90</angle>
<rotation>South</rotation>
</li>
<li Class="Rimworld_Animations.ExtendedKeyframe">
<tick>300</tick>
<angle>135</angle>
<rotation>South</rotation>
</li>
</keyframes>
</value>
</li>
<!--
<li>
<key>Head</key>
<value>
@ -67,6 +70,7 @@
</keyframes>
</value>
</li>
-->
</animationParts>
</AnimationDef>
</Defs>

View file

@ -10,16 +10,16 @@
<li>
<probability>3</probability>
<animationDefs>
<li>TestAnimation3</li>
<li>TestAnimation3</li>
<li>TestAnimation2</li>
<li>TestAnimation2</li>
</animationDefs>
</li>
<li>
<probability>1</probability>
<animationDefs>
<li>TestAnimation3</li>
<li>TestAnimation3</li>
<li>TestAnimation2</li>
<li>TestAnimation2</li>
</animationDefs>
</li>
</loopOptions>

View file

@ -49,7 +49,6 @@ namespace Rimworld_Animations
protected override void EnsureMaterialsInitialized()
{
variants = GraphicVariantsFor(this.tree.pawn);
base.EnsureMaterialsInitialized();
}

View file

@ -36,10 +36,10 @@ namespace Rimworld_Animations
foreach (HediffDef hediffDef in texPathVariant_Hediff.hediffs)
{
//if the pawn has that hediff,
if (pawn.health.hediffSet.hediffs.Any((Hediff hediff) => hediff.def == hediffDef))
if (pawn?.health?.hediffSet?.hediffs is List<Hediff> pawnHediffs && pawnHediffs.Any((Hediff hediff) => hediff.def == hediffDef))
{
//return that specific variant
curHediff = hediff.def;
curHediff = hediffDef;
return GenerateVariants(pawn, texPathVariant_Hediff.texPathVariantsDef);
}
@ -56,18 +56,13 @@ namespace Rimworld_Animations
protected override void EnsureMaterialsInitialized()
{
//if pawn no longer has the hediff,
if (curHediff == null ||
if (variants == 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();
}
}
}