diff --git a/1.5/Assemblies/Rimworld-Animations.dll b/1.5/Assemblies/Rimworld-Animations.dll index 494f83d..3c23703 100644 Binary files a/1.5/Assemblies/Rimworld-Animations.dll and b/1.5/Assemblies/Rimworld-Animations.dll differ diff --git a/1.5/Defs/AnimationDefs/TestAnimation2.xml b/1.5/Defs/AnimationDefs/TestAnimation2.xml index abda22f..8125f0c 100644 --- a/1.5/Defs/AnimationDefs/TestAnimation2.xml +++ b/1.5/Defs/AnimationDefs/TestAnimation2.xml @@ -2,7 +2,7 @@ TestAnimation2 - 400 + 120 False False @@ -13,35 +13,32 @@ Rimworld_Animations.AnimationWorker_KeyframesExtended
  • + (1, 0, 0) 0 0 - South + North
  • - 100 - 45 - South + (0, 0, 0) + 30 + 15 + North
  • - 0 - (-0.73, 0, -0.02) + (-1, 0, 0) + 60 0 - East + North
  • - 200 - 90 - South -
  • -
  • - 300 - 135 - South + (0, 0, 0) + 90 + -15 + North
  • -
    diff --git a/1.5/Defs/GroupAnimationDefs/TestGroupAnimation1.xml b/1.5/Defs/GroupAnimationDefs/TestGroupAnimation1.xml index 05c541b..ea2061e 100644 --- a/1.5/Defs/GroupAnimationDefs/TestGroupAnimation1.xml +++ b/1.5/Defs/GroupAnimationDefs/TestGroupAnimation1.xml @@ -10,16 +10,16 @@
  • 3 -
  • TestAnimation2
  • -
  • TestAnimation2
  • +
  • TestAnimation3
  • +
  • TestAnimation3
  • 1 -
  • TestAnimation2
  • -
  • TestAnimation2
  • +
  • TestAnimation3
  • +
  • TestAnimation3
  • diff --git a/1.5/Source/Comps/CompExtendedAnimator.cs b/1.5/Source/Comps/CompExtendedAnimator.cs index 2a6dfd2..46951c6 100644 --- a/1.5/Source/Comps/CompExtendedAnimator.cs +++ b/1.5/Source/Comps/CompExtendedAnimator.cs @@ -197,12 +197,6 @@ namespace Rimworld_Animations { PawnRenderNodeProperties props = animationProp.animPropProperties; - if (props.texPath.NullOrEmpty()) - { - props.texPath = "AnimationProps/MissingTexture/MissingTexture"; - } - - //create new render node PawnRenderNode animRenderNode = (PawnRenderNode)Activator.CreateInstance(props.nodeClass, new object[] { this.pawn, diff --git a/1.5/Source/Patches/RimworldPatches/HarmonyPatch_PawnRenderNode.cs b/1.5/Source/Patches/RimworldPatches/HarmonyPatch_PawnRenderNode.cs index 7e30364..a0741cd 100644 --- a/1.5/Source/Patches/RimworldPatches/HarmonyPatch_PawnRenderNode.cs +++ b/1.5/Source/Patches/RimworldPatches/HarmonyPatch_PawnRenderNode.cs @@ -41,9 +41,7 @@ namespace Rimworld_Animations } } - /* - * no longer needed; taken care of by graphic variants - * + // For changing texture path of thing to variant [HarmonyPatch(typeof(PawnRenderNode), "TexPathFor")] public static class HarmonyPatch_PawnRenderNode2 @@ -56,6 +54,4 @@ namespace Rimworld_Animations } } } - - */ } diff --git a/1.5/Source/PawnRenderNode/GraphicBodyTypeVariants/PawnRenderNode_GraphicBodyTypeVariants.cs b/1.5/Source/PawnRenderNode/GraphicBodyTypeVariants/PawnRenderNode_GraphicBodyTypeVariants.cs index ed26039..6164782 100644 --- a/1.5/Source/PawnRenderNode/GraphicBodyTypeVariants/PawnRenderNode_GraphicBodyTypeVariants.cs +++ b/1.5/Source/PawnRenderNode/GraphicBodyTypeVariants/PawnRenderNode_GraphicBodyTypeVariants.cs @@ -11,7 +11,6 @@ namespace Rimworld_Animations public class PawnRenderNode_BodyTypeVariants : PawnRenderNode_GraphicVariants { - private BodyTypeDef bodyType; protected new PawnRenderNodeProperties_BodyTypeVariants props; public PawnRenderNode_BodyTypeVariants(Pawn pawn, PawnRenderNodeProperties props, PawnRenderTree tree) : base(pawn, props, tree) @@ -21,39 +20,35 @@ namespace Rimworld_Animations } - protected Dictionary GraphicBodyTypeVariantsFor(Pawn pawn) + protected override Dictionary GraphicVariantsFor(Pawn pawn) { 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; } //for each different hediff-based texpathvariants, 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 - bodyType = texPathVariant_BodyType.bodyType; return GenerateVariants(pawn, texPathVariant_BodyType.texPathVariantsDef); } } - return null; + //otherwise just use default + return base.GraphicVariantsFor(pawn); } protected override void EnsureMaterialsInitialized() { - if (variants == null - || 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 + variants = GraphicVariantsFor(this.tree.pawn); base.EnsureMaterialsInitialized(); } diff --git a/1.5/Source/PawnRenderNode/GraphicHediffSeverityVariants/PawnRenderNodeProperties_GraphicHediffSeverityVariants.cs b/1.5/Source/PawnRenderNode/GraphicHediffSeverityVariants/PawnRenderNodeProperties_GraphicHediffSeverityVariants.cs deleted file mode 100644 index 96e9779..0000000 --- a/1.5/Source/PawnRenderNode/GraphicHediffSeverityVariants/PawnRenderNodeProperties_GraphicHediffSeverityVariants.cs +++ /dev/null @@ -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 hediffSeverityVariants; - - } - - public class HediffWithSeverity - { - public HediffDef hediff; - public List severityVariants; - } - - public class TexPathVariants_Severity - { - public int severity; - public TexPathVariantsDef texPathVariantsDef; - - - } - - -} diff --git a/1.5/Source/PawnRenderNode/GraphicHediffSeverityVariants/PawnRenderNodeWorker_GraphicHediffSeverityVariants.cs b/1.5/Source/PawnRenderNode/GraphicHediffSeverityVariants/PawnRenderNodeWorker_GraphicHediffSeverityVariants.cs deleted file mode 100644 index b8877a5..0000000 --- a/1.5/Source/PawnRenderNode/GraphicHediffSeverityVariants/PawnRenderNodeWorker_GraphicHediffSeverityVariants.cs +++ /dev/null @@ -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 - - } -} diff --git a/1.5/Source/PawnRenderNode/GraphicHediffSeverityVariants/PawnRenderNode_GraphicHediffSeverityVariants.cs b/1.5/Source/PawnRenderNode/GraphicHediffSeverityVariants/PawnRenderNode_GraphicHediffSeverityVariants.cs deleted file mode 100644 index 44ce6fd..0000000 --- a/1.5/Source/PawnRenderNode/GraphicHediffSeverityVariants/PawnRenderNode_GraphicHediffSeverityVariants.cs +++ /dev/null @@ -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 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 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(); - } - } -} diff --git a/1.5/Source/PawnRenderNode/GraphicHediffVariants/PawnRenderNode_GraphicHediffVariants.cs b/1.5/Source/PawnRenderNode/GraphicHediffVariants/PawnRenderNode_GraphicHediffVariants.cs index 5382373..e73b1cc 100644 --- a/1.5/Source/PawnRenderNode/GraphicHediffVariants/PawnRenderNode_GraphicHediffVariants.cs +++ b/1.5/Source/PawnRenderNode/GraphicHediffVariants/PawnRenderNode_GraphicHediffVariants.cs @@ -20,12 +20,12 @@ namespace Rimworld_Animations } - protected Dictionary GraphicHediffVariantsFor(Pawn pawn) + protected override Dictionary GraphicVariantsFor(Pawn pawn) { 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; } @@ -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 is List pawnHediffs && pawnHediffs.Any((Hediff hediff) => hediff.def == hediffDef)) + if (pawn.health.hediffSet.hediffs.Any((Hediff hediff) => hediff.def == hediffDef)) { //return that specific variant - curHediff = hediffDef; + curHediff = hediff.def; 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; - return null; + return base.GraphicVariantsFor(pawn); } protected override void EnsureMaterialsInitialized() { //if pawn no longer has the hediff, - if (variants == null || - !(this.tree.pawn.health?.hediffSet?.hediffs is List hediffs + if (curHediff == null || + (this.tree.pawn.health?.hediffSet?.hediffs is List hediffs && hediffs.Any((Hediff hediff) => hediff.def == curHediff))) { - //do graphicvariantsfor - variants = GraphicHediffVariantsFor(this.tree.pawn); + //redo graphicvariantsfor + 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(); } + + } + } diff --git a/1.5/Source/PawnRenderNode/GraphicVariants/PawnRenderNodeWorker_GraphicVariants.cs b/1.5/Source/PawnRenderNode/GraphicVariants/PawnRenderNodeWorker_GraphicVariants.cs index 184caff..9c3cf91 100644 --- a/1.5/Source/PawnRenderNode/GraphicVariants/PawnRenderNodeWorker_GraphicVariants.cs +++ b/1.5/Source/PawnRenderNode/GraphicVariants/PawnRenderNodeWorker_GraphicVariants.cs @@ -31,10 +31,12 @@ namespace Rimworld_Animations { //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) + + //and node is one with graphic variants && (node is PawnRenderNode_GraphicVariants nodeWithGraphicVariants) + + //and texpathvariant is set && extendedAnimWorker.TexPathVariantAtTick(node.tree.AnimationTick) != null) { Material materialVariant = GetMaterialVariant(nodeWithGraphicVariants, parms, (int)extendedAnimWorker.TexPathVariantAtTick(node.tree.AnimationTick)); diff --git a/1.5/Source/PawnRenderNode/GraphicVariants/PawnRenderNode_GraphicVariants.cs b/1.5/Source/PawnRenderNode/GraphicVariants/PawnRenderNode_GraphicVariants.cs index 0298c51..da09317 100644 --- a/1.5/Source/PawnRenderNode/GraphicVariants/PawnRenderNode_GraphicVariants.cs +++ b/1.5/Source/PawnRenderNode/GraphicVariants/PawnRenderNode_GraphicVariants.cs @@ -12,14 +12,13 @@ namespace Rimworld_Animations { protected new PawnRenderNodeProperties_GraphicVariants props; - protected Graphic missingTextureGraphic; protected Dictionary variants; public Graphic getGraphicVariant(int variant) { if (variants == null || !variants.ContainsKey(variant)) { - return missingTextureGraphic; + return null; } 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 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 protected Dictionary GenerateVariants(Pawn pawn, TexPathVariantsDef texPathVariants) { @@ -82,9 +75,6 @@ namespace Rimworld_Animations } - protected Graphic GenerateMissingTextureGraphic() - { - return GraphicDatabase.Get("AnimationProps/MissingTexture"); - } + } } diff --git a/1.5/Textures/AnimationProps/MissingTexture/MissingTexture_east.png b/1.5/Textures/AnimationProps/MissingTexture/MissingTexture_east.png deleted file mode 100644 index 59958a9..0000000 Binary files a/1.5/Textures/AnimationProps/MissingTexture/MissingTexture_east.png and /dev/null differ diff --git a/1.5/Textures/AnimationProps/MissingTexture/MissingTexture_north.png b/1.5/Textures/AnimationProps/MissingTexture/MissingTexture_north.png deleted file mode 100644 index 59958a9..0000000 Binary files a/1.5/Textures/AnimationProps/MissingTexture/MissingTexture_north.png and /dev/null differ diff --git a/1.5/Textures/AnimationProps/MissingTexture/MissingTexture_south.png b/1.5/Textures/AnimationProps/MissingTexture/MissingTexture_south.png deleted file mode 100644 index 59958a9..0000000 Binary files a/1.5/Textures/AnimationProps/MissingTexture/MissingTexture_south.png and /dev/null differ diff --git a/1.5/Textures/AnimationProps/MissingTexture/MissingTexture_west.png b/1.5/Textures/AnimationProps/MissingTexture/MissingTexture_west.png deleted file mode 100644 index 59958a9..0000000 Binary files a/1.5/Textures/AnimationProps/MissingTexture/MissingTexture_west.png and /dev/null differ diff --git a/Rimworld-Animations.csproj b/Rimworld-Animations.csproj index 1fad458..70e188e 100644 --- a/Rimworld-Animations.csproj +++ b/Rimworld-Animations.csproj @@ -121,9 +121,6 @@ - - - @@ -200,10 +197,6 @@ - - - -