diff --git a/1.5/Assemblies/Rimworld-Animations.dll b/1.5/Assemblies/Rimworld-Animations.dll
index 494f83d..2bed4c0 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 b4db1f0..c4d2e3b 100644
--- a/1.5/Defs/AnimationDefs/TestAnimation3.xml
+++ b/1.5/Defs/AnimationDefs/TestAnimation3.xml
@@ -107,6 +107,27 @@
+
+
+ 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 05c541b..2aa9ae3 100644
--- a/1.5/Defs/GroupAnimationDefs/TestGroupAnimation1.xml
+++ b/1.5/Defs/GroupAnimationDefs/TestGroupAnimation1.xml
@@ -38,18 +38,28 @@
+ 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 d62b348..747e154 100644
--- a/1.5/Source/Animations/GroupAnimations/GroupAnimationContexts/BaseGroupAnimationContext.cs
+++ b/1.5/Source/Animations/GroupAnimations/GroupAnimationContexts/BaseGroupAnimationContext.cs
@@ -10,7 +10,16 @@ namespace Rimworld_Animations
public abstract class BaseGroupAnimationContext
{
public int actorShift = 0;
- public abstract bool CanAnimationBeUsed(List actors, out int reorder);
+ public int priority = 0;
+ public abstract bool CanAnimationBeUsed(List actors);
+ public virtual int AnimationReorder()
+ {
+ return actorShift;
+ }
+ public virtual int AnimationPriority()
+ {
+ return priority;
+ }
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 a0bb3be..62e1928 100644
--- a/1.5/Source/Animations/GroupAnimations/GroupAnimationContexts/GroupAnimationContext_RJWSex.cs
+++ b/1.5/Source/Animations/GroupAnimations/GroupAnimationContexts/GroupAnimationContext_RJWSex.cs
@@ -15,12 +15,10 @@ namespace Rimworld_Animations
public List interactionDefs;
- public override bool CanAnimationBeUsed(List actors, out int reorder)
+ public override bool CanAnimationBeUsed(List actors)
{
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 da77e49..affee1b 100644
--- a/1.5/Source/Animations/GroupAnimations/GroupAnimationDef.cs
+++ b/1.5/Source/Animations/GroupAnimations/GroupAnimationDef.cs
@@ -16,26 +16,52 @@ namespace Rimworld_Animations
public List offsetDefs;
- public bool canAnimationBeUsed(List actors, out int reorder)
+ public bool canAnimationBeUsed(List actors)
{
+
if (RJWAnimationSettings.debugMode)
{
Log.Message("[anims] Checking if " + defName + " is valid animation");
}
-
-
+
+
foreach (BaseGroupAnimationContext context in contexts)
{
- if (context.CanAnimationBeUsed(actors, out reorder))
+ if (context.CanAnimationBeUsed(actors))
{
+ //find all where context matches actors
return true;
+
}
}
- reorder = 0;
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;
+
+ }
+
public List GetAllAnimationsForActor(int actor, int seed, int reorder = 0)
{
List animations = new List();
diff --git a/1.5/Source/Patches/RimworldPatches/HarmonyPatch_PawnRenderTree.cs b/1.5/Source/Patches/RimworldPatches/HarmonyPatch_PawnRenderTree.cs
index b79853f..c3cca54 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 fix
+ * Facing offsets 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 5382373..0742262 100644
--- a/1.5/Source/PawnRenderNode/GraphicHediffVariants/PawnRenderNode_GraphicHediffVariants.cs
+++ b/1.5/Source/PawnRenderNode/GraphicHediffVariants/PawnRenderNode_GraphicHediffVariants.cs
@@ -44,7 +44,6 @@ namespace Rimworld_Animations
}
}
-
}
//there is no graphic hediff variants appropriate
@@ -63,7 +62,6 @@ 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 117e459..b28a3b0 100644
--- a/1.5/Source/RenderSubWorkers/PawnRenderSubWorker_ChangeOffset.cs
+++ b/1.5/Source/RenderSubWorkers/PawnRenderSubWorker_ChangeOffset.cs
@@ -29,7 +29,6 @@ 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 04950f4..d691314 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;
- DefDatabase.AllDefsListForReading.TryRandomElement((GroupAnimationDef x) =>
- x.canAnimationBeUsed(participants, out reorder2), out GroupAnimationDef result);
+ //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));
+
reorder = reorder2;
- if (result != null) return result;
-
- return null;
-
-
+ return result;
}