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

View File

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

View File

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

View File

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