diff --git a/1.5/Assemblies/Rimworld-Animations.dll b/1.5/Assemblies/Rimworld-Animations.dll index bc82647..5d55c62 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/TestAnimation1.xml b/1.5/Defs/AnimationDefs/TestAnimation1.xml index 6ca49b0..d29a4fd 100644 --- a/1.5/Defs/AnimationDefs/TestAnimation1.xml +++ b/1.5/Defs/AnimationDefs/TestAnimation1.xml @@ -98,6 +98,35 @@ + +
  • + RenderNodeTag_Banana + + Rimworld_Animations.AnimationWorker_KeyframesExtended + +
  • + 30 + 0 + true +
  • +
  • + 100 + 0 + false +
  • +
  • + 200 + 0 + true +
  • +
  • + 300 + 0 + true +
  • + + + diff --git a/1.5/Defs/AnimationPropDefs/AnimationPropDef.xml b/1.5/Defs/AnimationPropDefs/AnimationPropDef.xml new file mode 100644 index 0000000..f635ce5 --- /dev/null +++ b/1.5/Defs/AnimationPropDefs/AnimationPropDef.xml @@ -0,0 +1,25 @@ + + + + + RenderNodeTag_Banana + + + + AnimationProp_Banana + + + + + AnimProp_Banana + Rimworld_Animations.PawnRenderNodeWorker_AnimationProp + RenderNodeTag_Banana + Body + AnimationProps/Banana/Banana + + Head + 95 + + + + diff --git a/1.5/Defs/XMLFile1.xml b/1.5/Defs/XMLFile1.xml deleted file mode 100644 index 2ddecfa..0000000 --- a/1.5/Defs/XMLFile1.xml +++ /dev/null @@ -1,11 +0,0 @@ - - - - Root - - Hand - PawnRenderNode - P - - - diff --git a/1.5/Source/AnimationProps/AnimationPropDef.cs b/1.5/Source/AnimationProps/AnimationPropDef.cs new file mode 100644 index 0000000..9acab99 --- /dev/null +++ b/1.5/Source/AnimationProps/AnimationPropDef.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Verse; + +namespace Rimworld_Animations +{ + public class AnimationPropDef : Def + { + + public PawnRenderNodeProperties animPropProperties; + + } +} diff --git a/1.5/Source/Comps/CompExtendedAnimator.cs b/1.5/Source/Comps/CompExtendedAnimator.cs index bd15457..212f81f 100644 --- a/1.5/Source/Comps/CompExtendedAnimator.cs +++ b/1.5/Source/Comps/CompExtendedAnimator.cs @@ -124,9 +124,57 @@ namespace Rimworld_Animations { } - public static void CheckRecacheNecessary(int anim) + public override List CompRenderNodes() { + //only if pawn is animating for performance + if (IsAnimating) + { + List animRenderNodes = new List(); + // for all animationpropdefs, + foreach (AnimationPropDef animationProp in DefDatabase.AllDefsListForReading) + { + //if animation makes use of prop, + if (AnimationMakesUseOfProp(animationProp)) + { + //create new render node + PawnRenderNode animRenderNode = new PawnRenderNode(pawn, animationProp.animPropProperties, pawn.Drawer.renderer.renderTree); + animRenderNodes.Add(animRenderNode); + } + + } + + //return list of rendernodes that should animate + return animRenderNodes; + + } + else + { + return null; + } + + } + + public bool AnimationMakesUseOfProp(AnimationPropDef animationProp) + { + // never true if not animating; anim props shouldn't be attached + if (!IsAnimating) return false; + + //for all queued animations, + foreach (AnimationDef animation in animationQueue) + { + // for each prop tag in the currently playing animation, + foreach (PawnRenderNodeTagDef propTag in animation.animationParts.Keys) + { + // if that proptag is the same as the one for animationProp, + if (propTag == animationProp.animPropProperties.tagDef) + { + //that prop is being used in the animation + return true; + } + } + } + return false; } private Pawn pawn => base.parent as Pawn; diff --git a/1.5/Source/Keyframes/ExtendedKeyframe.cs b/1.5/Source/Keyframes/ExtendedKeyframe.cs index 893c879..ef08e9b 100644 --- a/1.5/Source/Keyframes/ExtendedKeyframe.cs +++ b/1.5/Source/Keyframes/ExtendedKeyframe.cs @@ -10,8 +10,7 @@ namespace Rimworld_Animations { public class ExtendedKeyframe : Verse.Keyframe { - - public Rot4 rotation; + public Rot4 rotation = Rot4.North; public SoundDef sound = null; public bool visible = true; diff --git a/1.5/Source/Patches/RimworldPatches/HarmonyPatch_PawnRenderNode.cs b/1.5/Source/Patches/RimworldPatches/HarmonyPatch_PawnRenderNode.cs index 1e423a7..81c9fa4 100644 --- a/1.5/Source/Patches/RimworldPatches/HarmonyPatch_PawnRenderNode.cs +++ b/1.5/Source/Patches/RimworldPatches/HarmonyPatch_PawnRenderNode.cs @@ -9,7 +9,9 @@ using Verse; namespace Rimworld_Animations { - //Head Rotation Code - Textures + // Head Rotation Code - Textures + // it's fine to just edit each AppendRequests individually + // because they all the parms are passed down to each child node recursively [HarmonyPatch(typeof(PawnRenderNode), "AppendRequests")] public static class HarmonyPatch_PawnRenderNode { @@ -28,7 +30,9 @@ namespace Rimworld_Animations //replace maybe? //cheaper call now comparing prev tick to cur tick - return extendedAnimWorker.visibleAtTick(__instance.tree.AnimationTick); + + //not necessary because of new rendernodeworker hiding props now + //return extendedAnimWorker.visibleAtTick(__instance.tree.AnimationTick); } diff --git a/1.5/Source/PawnRenderNode/PawnRenderNodeWorker_AnimationProp.cs b/1.5/Source/PawnRenderNode/PawnRenderNodeWorker_AnimationProp.cs new file mode 100644 index 0000000..c2d7622 --- /dev/null +++ b/1.5/Source/PawnRenderNode/PawnRenderNodeWorker_AnimationProp.cs @@ -0,0 +1,23 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Verse; + +namespace Rimworld_Animations +{ + public class PawnRenderNodeWorker_AnimationProp : PawnRenderNodeWorker + { + public override bool CanDrawNow(PawnRenderNode node, PawnDrawParms parms) + { + if (node.AnimationWorker is AnimationWorker_KeyframesExtended propAnimator) + { + return propAnimator.visibleAtTick(node.tree.AnimationTick); + } + + return false; + } + + } +} diff --git a/1.5/Textures/AnimationProps/Banana/Banana_east.png b/1.5/Textures/AnimationProps/Banana/Banana_east.png new file mode 100644 index 0000000..d7df227 Binary files /dev/null and b/1.5/Textures/AnimationProps/Banana/Banana_east.png differ diff --git a/1.5/Textures/AnimationProps/Banana/Banana_north.png b/1.5/Textures/AnimationProps/Banana/Banana_north.png new file mode 100644 index 0000000..d4a4d28 Binary files /dev/null and b/1.5/Textures/AnimationProps/Banana/Banana_north.png differ diff --git a/1.5/Textures/AnimationProps/Banana/Banana_south.png b/1.5/Textures/AnimationProps/Banana/Banana_south.png new file mode 100644 index 0000000..d7df227 Binary files /dev/null and b/1.5/Textures/AnimationProps/Banana/Banana_south.png differ diff --git a/1.5/Textures/AnimationProps/Banana/Banana_west.png b/1.5/Textures/AnimationProps/Banana/Banana_west.png new file mode 100644 index 0000000..d7df227 Binary files /dev/null and b/1.5/Textures/AnimationProps/Banana/Banana_west.png differ diff --git a/Rimworld-Animations.csproj b/Rimworld-Animations.csproj index b6b9d15..405e2e6 100644 --- a/Rimworld-Animations.csproj +++ b/Rimworld-Animations.csproj @@ -72,6 +72,7 @@ + @@ -105,6 +106,7 @@ + @@ -115,11 +117,11 @@ + - @@ -156,6 +158,10 @@ + + + +