Compare commits

..

No commits in common. "319979b0f3c7fd4479761cb2c7f790754999aa80" and "df3a670d6fce13c7117a76e2c82374ada715b965" have entirely different histories.

17 changed files with 55 additions and 256 deletions

View file

@ -2,7 +2,7 @@
<Defs> <Defs>
<AnimationDef> <AnimationDef>
<defName>TestAnimation2</defName> <defName>TestAnimation2</defName>
<durationTicks>400</durationTicks> <durationTicks>120</durationTicks>
<startOnRandomTick>False</startOnRandomTick> <startOnRandomTick>False</startOnRandomTick>
<playWhenDowned>False</playWhenDowned> <playWhenDowned>False</playWhenDowned>
@ -13,35 +13,32 @@
<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>South</rotation> <rotation>North</rotation>
</li> </li>
<li Class="Rimworld_Animations.ExtendedKeyframe"> <li Class="Rimworld_Animations.ExtendedKeyframe">
<tick>100</tick> <offset>(0, 0, 0)</offset>
<angle>45</angle> <tick>30</tick>
<rotation>South</rotation> <angle>15</angle>
<rotation>North</rotation>
</li> </li>
<li Class="Rimworld_Animations.ExtendedKeyframe"> <li Class="Rimworld_Animations.ExtendedKeyframe">
<tick>0</tick> <offset>(-1, 0, 0)</offset>
<offset>(-0.73, 0, -0.02)</offset> <tick>60</tick>
<angle>0</angle> <angle>0</angle>
<rotation>East</rotation> <rotation>North</rotation>
</li> </li>
<li Class="Rimworld_Animations.ExtendedKeyframe"> <li Class="Rimworld_Animations.ExtendedKeyframe">
<tick>200</tick> <offset>(0, 0, 0)</offset>
<angle>90</angle> <tick>90</tick>
<rotation>South</rotation> <angle>-15</angle>
</li> <rotation>North</rotation>
<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>
@ -70,7 +67,6 @@
</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>TestAnimation2</li> <li>TestAnimation3</li>
<li>TestAnimation2</li> <li>TestAnimation3</li>
</animationDefs> </animationDefs>
</li> </li>
<li> <li>
<probability>1</probability> <probability>1</probability>
<animationDefs> <animationDefs>
<li>TestAnimation2</li> <li>TestAnimation3</li>
<li>TestAnimation2</li> <li>TestAnimation3</li>
</animationDefs> </animationDefs>
</li> </li>
</loopOptions> </loopOptions>

View file

@ -197,12 +197,6 @@ namespace Rimworld_Animations {
PawnRenderNodeProperties props = animationProp.animPropProperties; PawnRenderNodeProperties props = animationProp.animPropProperties;
if (props.texPath.NullOrEmpty())
{
props.texPath = "AnimationProps/MissingTexture/MissingTexture";
}
//create new render node //create new render node
PawnRenderNode animRenderNode = (PawnRenderNode)Activator.CreateInstance(props.nodeClass, new object[] { PawnRenderNode animRenderNode = (PawnRenderNode)Activator.CreateInstance(props.nodeClass, new object[] {
this.pawn, this.pawn,

View file

@ -41,9 +41,7 @@ namespace Rimworld_Animations
} }
} }
/*
* no longer needed; taken care of by graphic variants
*
// For changing texture path of thing to variant // For changing texture path of thing to variant
[HarmonyPatch(typeof(PawnRenderNode), "TexPathFor")] [HarmonyPatch(typeof(PawnRenderNode), "TexPathFor")]
public static class HarmonyPatch_PawnRenderNode2 public static class HarmonyPatch_PawnRenderNode2
@ -56,6 +54,4 @@ namespace Rimworld_Animations
} }
} }
} }
*/
} }

View file

@ -11,7 +11,6 @@ namespace Rimworld_Animations
public class PawnRenderNode_BodyTypeVariants : PawnRenderNode_GraphicVariants public class PawnRenderNode_BodyTypeVariants : PawnRenderNode_GraphicVariants
{ {
private BodyTypeDef bodyType;
protected new PawnRenderNodeProperties_BodyTypeVariants props; protected new PawnRenderNodeProperties_BodyTypeVariants props;
public PawnRenderNode_BodyTypeVariants(Pawn pawn, PawnRenderNodeProperties props, PawnRenderTree tree) : base(pawn, props, tree) public PawnRenderNode_BodyTypeVariants(Pawn pawn, PawnRenderNodeProperties props, PawnRenderTree tree) : base(pawn, props, tree)
@ -21,39 +20,35 @@ namespace Rimworld_Animations
} }
protected Dictionary<int, Graphic> GraphicBodyTypeVariantsFor(Pawn pawn) protected override Dictionary<int, Graphic> GraphicVariantsFor(Pawn pawn)
{ {
if (props.bodyTypeVariantsDef == null) if (props.bodyTypeVariantsDef == null)
{ {
Log.Error("[Anims] Error: Tried to use BodyTypeVariants node, but bodyTypeVariants weren't given"); Log.ErrorOnce("[Anims] Error: Tried to use BodyTypeVariants node, but bodyTypeVariants weren't given", 211341349);
return null; return null;
} }
//for each different hediff-based texpathvariants, //for each different hediff-based texpathvariants,
foreach (TexPathVariants_BodyType texPathVariant_BodyType in props.bodyTypeVariantsDef) foreach (TexPathVariants_BodyType texPathVariant_BodyType in props.bodyTypeVariantsDef)
{ {
if (pawn.story?.bodyType == texPathVariant_BodyType.bodyType) if (pawn.story.bodyType == texPathVariant_BodyType.bodyType)
{ {
//return that specific variant //return that specific variant
bodyType = texPathVariant_BodyType.bodyType;
return GenerateVariants(pawn, texPathVariant_BodyType.texPathVariantsDef); return GenerateVariants(pawn, texPathVariant_BodyType.texPathVariantsDef);
} }
} }
return null; //otherwise just use default
return base.GraphicVariantsFor(pawn);
} }
protected override void EnsureMaterialsInitialized() protected override void EnsureMaterialsInitialized()
{ {
if (variants == null variants = GraphicVariantsFor(this.tree.pawn);
|| this.tree.pawn.story?.bodyType != bodyType)
variants = GraphicBodyTypeVariantsFor(this.tree.pawn);
//call this in case variants wasn't set, and there is no graphic bodytype variants appropriate; it'll set variants based on default
base.EnsureMaterialsInitialized(); base.EnsureMaterialsInitialized();
} }

View file

@ -1,33 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace Rimworld_Animations
{
public class PawnRenderNodeProperties_GraphicHediffSeverityVariants : PawnRenderNodeProperties_GraphicVariants
{
public BodyPartDef bodyPart = null;
public List<HediffWithSeverity> hediffSeverityVariants;
}
public class HediffWithSeverity
{
public HediffDef hediff;
public List<TexPathVariants_Severity> severityVariants;
}
public class TexPathVariants_Severity
{
public int severity;
public TexPathVariantsDef texPathVariantsDef;
}
}

View file

@ -1,15 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Rimworld_Animations
{
public class PawnRenderNodeWorker_GraphicHediffSeverityVariants : PawnRenderNodeWorker_GraphicVariants
{
//same functionality as graphicvariants worker
//just here for readability
}
}

View file

@ -1,121 +0,0 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Verse;
namespace Rimworld_Animations
{
public class PawnRenderNode_GraphicHediffSeverityVariants : PawnRenderNode_GraphicVariants
{
protected HediffDef hediffWithSeverity;
protected float curSeverity;
protected new PawnRenderNodeProperties_GraphicHediffSeverityVariants props;
private HediffDef curHediff;
public PawnRenderNode_GraphicHediffSeverityVariants(Pawn pawn, PawnRenderNodeProperties props, PawnRenderTree tree) : base(pawn, props, tree)
{
this.props = (PawnRenderNodeProperties_GraphicHediffSeverityVariants)props;
}
protected Dictionary<int, Graphic> GraphicHediffSeverityVariantsFor(Pawn pawn)
{
if (props.hediffSeverityVariants == null)
{
Log.Error("[Anims] Error: Tried to use GraphicBodyPartHediffSeverityVariants node, but hediffSeverityVariants weren't given");
}
Hediff idealHediff = null;
HediffWithSeverity idealHediffSeverity = null;
if (props.bodyPart == null)
{
//search the entire body for the hediff because no bodypart was set
for (int i = 0; i < props.hediffSeverityVariants.Count; i++)
{
idealHediff = pawn.health.hediffSet.hediffs.Find((Hediff hediffWithSeverity) =>
hediffWithSeverity.def == props.hediffSeverityVariants[i].hediff);
if (idealHediff != null)
{
//get the ideal hediff severity variants, to iterate through and find the right one for the severity
idealHediffSeverity = props.hediffSeverityVariants[i];
break;
}
}
}
else
{
//search for a hediff with a specific body part
for (int i = 0; i < props.hediffSeverityVariants.Count; i++)
{
//right hediff with the right hediff and right body part
idealHediff = pawn.health.hediffSet.hediffs.Find((Hediff hediffWithSeverity) =>
hediffWithSeverity.def == props.hediffSeverityVariants[i].hediff
&& hediffWithSeverity.Part.def == props.bodyPart);
if (idealHediff != null) {
//get the ideal hediff severity variants, to iterate through and find the right one for the severity
idealHediffSeverity = props.hediffSeverityVariants[i];
break;
}
}
}
if (idealHediff != null)
{
//set severity so that recache when this is different
curSeverity = idealHediff.Severity;
//look for the right severity-based texpathvariants
TexPathVariants_Severity texPathVariants_Severity = idealHediffSeverity.severityVariants.Find((TexPathVariants_Severity texPathVariants) =>
texPathVariants.severity < idealHediff.Severity);
//if null, assume value is really too small
if (texPathVariants_Severity == null)
{
//return largest value
return GenerateVariants(pawn, idealHediffSeverity.severityVariants.First().texPathVariantsDef);
}
//return right severity variants
return GenerateVariants(pawn, texPathVariants_Severity.texPathVariantsDef);
}
//there is no graphic hediff variants appropriate
curHediff = null;
return null;
}
protected override void EnsureMaterialsInitialized()
{
//if pawn no longer has the hediff,
if (variants == null ||
!(this.tree.pawn.health?.hediffSet?.hediffs is List<Hediff> hediffs
&& hediffs.Any((Hediff hediff) => hediff.def == curHediff && hediff.Severity == curSeverity)))
{
//do graphicvariantsfor
variants = GraphicHediffSeverityVariantsFor(this.tree.pawn);
}
//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();
}
}
}

View file

@ -20,12 +20,12 @@ namespace Rimworld_Animations
} }
protected Dictionary<int, Graphic> GraphicHediffVariantsFor(Pawn pawn) protected override Dictionary<int, Graphic> GraphicVariantsFor(Pawn pawn)
{ {
if (props.hediffVariants == null) if (props.hediffVariants == null)
{ {
Log.Error("[Anims] Error: Tried to use GraphicHediffVariants node, but hediffVariants weren't given"); Log.ErrorOnce("[Anims] Error: Tried to use GraphicHediffVariants node, but hediffVariants weren't given", 231321349);
return null; return null;
} }
@ -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 is List<Hediff> pawnHediffs && pawnHediffs.Any((Hediff hediff) => hediff.def == hediffDef)) if (pawn.health.hediffSet.hediffs.Any((Hediff hediff) => hediff.def == hediffDef))
{ {
//return that specific variant //return that specific variant
curHediff = hediffDef; curHediff = hediff.def;
return GenerateVariants(pawn, texPathVariant_Hediff.texPathVariantsDef); return GenerateVariants(pawn, texPathVariant_Hediff.texPathVariantsDef);
} }
@ -47,25 +47,27 @@ namespace Rimworld_Animations
} }
//there is no graphic hediff variants appropriate //otherwise just use default
curHediff = null; curHediff = null;
return null; return base.GraphicVariantsFor(pawn);
} }
protected override void EnsureMaterialsInitialized() protected override void EnsureMaterialsInitialized()
{ {
//if pawn no longer has the hediff, //if pawn no longer has the hediff,
if (variants == null || if (curHediff == 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)))
{ {
//do graphicvariantsfor //redo graphicvariantsfor
variants = GraphicHediffVariantsFor(this.tree.pawn); variants = GraphicVariantsFor(this.tree.pawn);
} }
//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(); base.EnsureMaterialsInitialized();
} }
} }
} }

View file

@ -31,10 +31,12 @@ namespace Rimworld_Animations
{ {
//if node is animating, and is a graphic variant type of node //if node is animating, and is a graphic variant type of node
//and node is one with graphic variants
//and texpathvariant is set
if ((node.AnimationWorker is AnimationWorker_KeyframesExtended extendedAnimWorker) if ((node.AnimationWorker is AnimationWorker_KeyframesExtended extendedAnimWorker)
//and node is one with graphic variants
&& (node is PawnRenderNode_GraphicVariants nodeWithGraphicVariants) && (node is PawnRenderNode_GraphicVariants nodeWithGraphicVariants)
//and texpathvariant is set
&& extendedAnimWorker.TexPathVariantAtTick(node.tree.AnimationTick) != null) && extendedAnimWorker.TexPathVariantAtTick(node.tree.AnimationTick) != null)
{ {
Material materialVariant = GetMaterialVariant(nodeWithGraphicVariants, parms, (int)extendedAnimWorker.TexPathVariantAtTick(node.tree.AnimationTick)); Material materialVariant = GetMaterialVariant(nodeWithGraphicVariants, parms, (int)extendedAnimWorker.TexPathVariantAtTick(node.tree.AnimationTick));

View file

@ -12,14 +12,13 @@ namespace Rimworld_Animations
{ {
protected new PawnRenderNodeProperties_GraphicVariants props; protected new PawnRenderNodeProperties_GraphicVariants props;
protected Graphic missingTextureGraphic;
protected Dictionary<int, Graphic> variants; protected Dictionary<int, Graphic> variants;
public Graphic getGraphicVariant(int variant) public Graphic getGraphicVariant(int variant)
{ {
if (variants == null || !variants.ContainsKey(variant)) if (variants == null || !variants.ContainsKey(variant))
{ {
return missingTextureGraphic; return null;
} }
return variants[variant]; return variants[variant];
@ -31,6 +30,17 @@ namespace Rimworld_Animations
} }
protected override void EnsureMaterialsInitialized()
{
if (variants == null)
{
variants = GraphicVariantsFor(this.tree.pawn);
}
base.EnsureMaterialsInitialized();
}
protected virtual Dictionary<int, Graphic> GraphicVariantsFor(Pawn pawn) protected virtual Dictionary<int, Graphic> GraphicVariantsFor(Pawn pawn)
{ {
@ -43,23 +53,6 @@ namespace Rimworld_Animations
} }
protected override void EnsureMaterialsInitialized()
{
if (variants == null)
{
variants = GraphicVariantsFor(this.tree.pawn);
}
if (missingTextureGraphic == null)
{
missingTextureGraphic = GenerateMissingTextureGraphic();
}
base.EnsureMaterialsInitialized();
}
//used by all, including base classes, to create texPathVariants for pawn //used by all, including base classes, to create texPathVariants for pawn
protected Dictionary<int, Graphic> GenerateVariants(Pawn pawn, TexPathVariantsDef texPathVariants) protected Dictionary<int, Graphic> GenerateVariants(Pawn pawn, TexPathVariantsDef texPathVariants)
{ {
@ -82,9 +75,6 @@ namespace Rimworld_Animations
} }
protected Graphic GenerateMissingTextureGraphic()
{
return GraphicDatabase.Get<Graphic_Multi>("AnimationProps/MissingTexture");
}
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 758 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 758 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 758 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 758 KiB

View file

@ -121,9 +121,6 @@
<Compile Include="1.5\Source\PawnRenderNode\GraphicBodyTypeVariants\PawnRenderNodeProperties_GraphicBodyTypeVariants.cs" /> <Compile Include="1.5\Source\PawnRenderNode\GraphicBodyTypeVariants\PawnRenderNodeProperties_GraphicBodyTypeVariants.cs" />
<Compile Include="1.5\Source\PawnRenderNode\GraphicBodyTypeVariants\PawnRenderNodeWorker_GraphicBodyTypeVariants.cs" /> <Compile Include="1.5\Source\PawnRenderNode\GraphicBodyTypeVariants\PawnRenderNodeWorker_GraphicBodyTypeVariants.cs" />
<Compile Include="1.5\Source\PawnRenderNode\GraphicBodyTypeVariants\PawnRenderNode_GraphicBodyTypeVariants.cs" /> <Compile Include="1.5\Source\PawnRenderNode\GraphicBodyTypeVariants\PawnRenderNode_GraphicBodyTypeVariants.cs" />
<Compile Include="1.5\Source\PawnRenderNode\GraphicHediffSeverityVariants\PawnRenderNodeProperties_GraphicHediffSeverityVariants.cs" />
<Compile Include="1.5\Source\PawnRenderNode\GraphicHediffSeverityVariants\PawnRenderNodeWorker_GraphicHediffSeverityVariants.cs" />
<Compile Include="1.5\Source\PawnRenderNode\GraphicHediffSeverityVariants\PawnRenderNode_GraphicHediffSeverityVariants.cs" />
<Compile Include="1.5\Source\PawnRenderNode\GraphicHediffVariants\PawnRenderNodeProperties_GraphicHediffVariants.cs" /> <Compile Include="1.5\Source\PawnRenderNode\GraphicHediffVariants\PawnRenderNodeProperties_GraphicHediffVariants.cs" />
<Compile Include="1.5\Source\PawnRenderNode\GraphicHediffVariants\PawnRenderNodeWorker_GraphicHediffVariants.cs" /> <Compile Include="1.5\Source\PawnRenderNode\GraphicHediffVariants\PawnRenderNodeWorker_GraphicHediffVariants.cs" />
<Compile Include="1.5\Source\PawnRenderNode\GraphicHediffVariants\PawnRenderNode_GraphicHediffVariants.cs" /> <Compile Include="1.5\Source\PawnRenderNode\GraphicHediffVariants\PawnRenderNode_GraphicHediffVariants.cs" />
@ -200,10 +197,6 @@
<Content Include="1.5\Textures\AnimationProps\Banana\Banana_west.png" /> <Content Include="1.5\Textures\AnimationProps\Banana\Banana_west.png" />
<Content Include="1.5\Textures\AnimationProps\Doggystyle\Doggy_Arms_north.png" /> <Content Include="1.5\Textures\AnimationProps\Doggystyle\Doggy_Arms_north.png" />
<Content Include="1.5\Textures\AnimationProps\Doggystyle\Doggy_Legs_north.png" /> <Content Include="1.5\Textures\AnimationProps\Doggystyle\Doggy_Legs_north.png" />
<Content Include="1.5\Textures\AnimationProps\MissingTexture\MissingTexture_east.png" />
<Content Include="1.5\Textures\AnimationProps\MissingTexture\MissingTexture_north.png" />
<Content Include="1.5\Textures\AnimationProps\MissingTexture\MissingTexture_south.png" />
<Content Include="1.5\Textures\AnimationProps\MissingTexture\MissingTexture_west.png" />
<Content Include="1.5\Textures\UI\MainTab.png" /> <Content Include="1.5\Textures\UI\MainTab.png" />
<Content Include="About\About.xml" /> <Content Include="About\About.xml" />
<Content Include="About\Manifest.xml" /> <Content Include="About\Manifest.xml" />