diff --git a/1.5/Assemblies/Rimworld-Animations.dll b/1.5/Assemblies/Rimworld-Animations.dll index 2bed4c0..494f83d 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/TestAnimation3.xml b/1.5/Defs/AnimationDefs/TestAnimation3.xml index c4d2e3b..b4db1f0 100644 --- a/1.5/Defs/AnimationDefs/TestAnimation3.xml +++ b/1.5/Defs/AnimationDefs/TestAnimation3.xml @@ -107,27 +107,6 @@ - -
  • - RimNude_Penis - - Rimworld_Animations.AnimationWorker_KeyframesExtended - -
  • - 0 - -30 - true - East -
  • -
  • - 400 - -600 - true - East -
  • - - - \ No newline at end of file diff --git a/1.5/Defs/GroupAnimationDefs/TestGroupAnimation1.xml b/1.5/Defs/GroupAnimationDefs/TestGroupAnimation1.xml index 2aa9ae3..05c541b 100644 --- a/1.5/Defs/GroupAnimationDefs/TestGroupAnimation1.xml +++ b/1.5/Defs/GroupAnimationDefs/TestGroupAnimation1.xml @@ -38,28 +38,18 @@
  • - 1
  • Sex_Anal
  • Sex_Vaginal
  • - 1 1
  • Sex_Reverse_Anal
  • Sex_Reverse_Vaginal
  • - -
  • - 0 - - - - -
  • diff --git a/1.5/Source/Animations/GroupAnimations/GroupAnimationContexts/BaseGroupAnimationContext.cs b/1.5/Source/Animations/GroupAnimations/GroupAnimationContexts/BaseGroupAnimationContext.cs index 747e154..d62b348 100644 --- a/1.5/Source/Animations/GroupAnimations/GroupAnimationContexts/BaseGroupAnimationContext.cs +++ b/1.5/Source/Animations/GroupAnimations/GroupAnimationContexts/BaseGroupAnimationContext.cs @@ -10,16 +10,7 @@ namespace Rimworld_Animations public abstract class BaseGroupAnimationContext { public int actorShift = 0; - public int priority = 0; - public abstract bool CanAnimationBeUsed(List actors); - public virtual int AnimationReorder() - { - return actorShift; - } - public virtual int AnimationPriority() - { - return priority; - } + public abstract bool CanAnimationBeUsed(List actors, out int reorder); public abstract string DebugMessage(); //cool class for designating contexts for animations diff --git a/1.5/Source/Animations/GroupAnimations/GroupAnimationContexts/GroupAnimationContext_RJWSex.cs b/1.5/Source/Animations/GroupAnimations/GroupAnimationContexts/GroupAnimationContext_RJWSex.cs index 62e1928..a0bb3be 100644 --- a/1.5/Source/Animations/GroupAnimations/GroupAnimationContexts/GroupAnimationContext_RJWSex.cs +++ b/1.5/Source/Animations/GroupAnimations/GroupAnimationContexts/GroupAnimationContext_RJWSex.cs @@ -15,10 +15,12 @@ namespace Rimworld_Animations public List interactionDefs; - public override bool CanAnimationBeUsed(List actors) + public override bool CanAnimationBeUsed(List actors, out int reorder) { JobDriver_SexBaseInitiator latestSexBaseInitiator = (actors.FindLast(x => x.jobs?.curDriver is JobDriver_SexBaseInitiator).jobs.curDriver as JobDriver_SexBaseInitiator); + reorder = base.actorShift; + return interactionDefs.Contains(latestSexBaseInitiator.Sexprops.dictionaryKey); } diff --git a/1.5/Source/Animations/GroupAnimations/GroupAnimationDef.cs b/1.5/Source/Animations/GroupAnimations/GroupAnimationDef.cs index affee1b..da77e49 100644 --- a/1.5/Source/Animations/GroupAnimations/GroupAnimationDef.cs +++ b/1.5/Source/Animations/GroupAnimations/GroupAnimationDef.cs @@ -16,50 +16,24 @@ namespace Rimworld_Animations public List offsetDefs; - public bool canAnimationBeUsed(List actors) + public bool canAnimationBeUsed(List actors, out int reorder) { - if (RJWAnimationSettings.debugMode) { Log.Message("[anims] Checking if " + defName + " is valid animation"); } - - + + foreach (BaseGroupAnimationContext context in contexts) { - if (context.CanAnimationBeUsed(actors)) + if (context.CanAnimationBeUsed(actors, out reorder)) { - //find all where context matches actors return true; - } } - return false; - } - - public int Priority(List actors, out int reorder) - { - int priority = -999999999; reorder = 0; - - foreach (BaseGroupAnimationContext context in contexts) - { - if (context.CanAnimationBeUsed(actors)) - { - if (context.AnimationPriority() > priority) - { - //get highest priority context for fitting animation - priority = context.AnimationPriority(); - reorder = context.AnimationReorder(); - - } - - } - } - - return priority; - + return false; } public List GetAllAnimationsForActor(int actor, int seed, int reorder = 0) diff --git a/1.5/Source/Patches/RimworldPatches/HarmonyPatch_PawnRenderTree.cs b/1.5/Source/Patches/RimworldPatches/HarmonyPatch_PawnRenderTree.cs index c3cca54..b79853f 100644 --- a/1.5/Source/Patches/RimworldPatches/HarmonyPatch_PawnRenderTree.cs +++ b/1.5/Source/Patches/RimworldPatches/HarmonyPatch_PawnRenderTree.cs @@ -17,7 +17,7 @@ namespace Rimworld_Animations public static bool Prefix(PawnRenderTree __instance, Dictionary ___nodesByTag, PawnRenderNode node, ref PawnDrawParms parms, ref Matrix4x4 matrix, ref bool __result) { /* - * Facing offsets fix + * Facing fix */ //find lowest parent that is animating, or nothing if not animating PawnRenderNode animatingNode = node; diff --git a/1.5/Source/PawnRenderNode/GraphicHediffVariants/PawnRenderNode_GraphicHediffVariants.cs b/1.5/Source/PawnRenderNode/GraphicHediffVariants/PawnRenderNode_GraphicHediffVariants.cs index 0742262..5382373 100644 --- a/1.5/Source/PawnRenderNode/GraphicHediffVariants/PawnRenderNode_GraphicHediffVariants.cs +++ b/1.5/Source/PawnRenderNode/GraphicHediffVariants/PawnRenderNode_GraphicHediffVariants.cs @@ -44,6 +44,7 @@ namespace Rimworld_Animations } } + } //there is no graphic hediff variants appropriate @@ -62,6 +63,7 @@ namespace Rimworld_Animations //do graphicvariantsfor variants = GraphicHediffVariantsFor(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/RenderSubWorkers/PawnRenderSubWorker_ChangeOffset.cs b/1.5/Source/RenderSubWorkers/PawnRenderSubWorker_ChangeOffset.cs index b28a3b0..117e459 100644 --- a/1.5/Source/RenderSubWorkers/PawnRenderSubWorker_ChangeOffset.cs +++ b/1.5/Source/RenderSubWorkers/PawnRenderSubWorker_ChangeOffset.cs @@ -29,6 +29,7 @@ namespace Rimworld_Animations public override void TransformRotation(PawnRenderNode node, PawnDrawParms parms, ref Quaternion rotation) { + if (node.AnimationWorker is AnimationWorker_KeyframesExtended && node.tree.pawn.TryGetComp(out CompExtendedAnimator extendedAnimator) && extendedAnimator.IsAnimating) diff --git a/1.5/Source/Utilities/AnimationUtility.cs b/1.5/Source/Utilities/AnimationUtility.cs index d691314..04950f4 100644 --- a/1.5/Source/Utilities/AnimationUtility.cs +++ b/1.5/Source/Utilities/AnimationUtility.cs @@ -84,15 +84,15 @@ namespace Rimworld_Animations { int reorder2 = 0; - //find all, reorder randomly, then find max priority context - GroupAnimationDef result = DefDatabase.AllDefsListForReading - .FindAll((GroupAnimationDef x) => x.canAnimationBeUsed(participants)) - .OrderBy(_ => Rand.Int) - .MaxBy((GroupAnimationDef x) => x.Priority(participants, out reorder2)); - + DefDatabase.AllDefsListForReading.TryRandomElement((GroupAnimationDef x) => + x.canAnimationBeUsed(participants, out reorder2), out GroupAnimationDef result); reorder = reorder2; - return result; + if (result != null) return result; + + return null; + + }