Compare commits

..

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

10 changed files with 20 additions and 81 deletions

View file

@ -107,27 +107,6 @@
</keyframes> </keyframes>
</value> </value>
</li> </li>
<li MayRequire="shauaputa.rimnudeworld">
<key>RimNude_Penis</key>
<value>
<workerClass>Rimworld_Animations.AnimationWorker_KeyframesExtended</workerClass>
<keyframes>
<li Class="Rimworld_Animations.ExtendedKeyframe">
<tick>0</tick>
<angle>-30</angle>
<visible>true</visible>
<rotation>East</rotation>
</li>
<li Class="Rimworld_Animations.ExtendedKeyframe">
<tick>400</tick>
<angle>-600</angle>
<visible>true</visible>
<rotation>East</rotation>
</li>
</keyframes>
</value>
</li>
</animationParts> </animationParts>
</AnimationDef> </AnimationDef>
</Defs> </Defs>

View file

@ -38,28 +38,18 @@
<contexts> <contexts>
<li Class="Rimworld_Animations.GroupAnimationContext_RJWSex"> <li Class="Rimworld_Animations.GroupAnimationContext_RJWSex">
<priority>1</priority>
<interactionDefs> <interactionDefs>
<li>Sex_Anal</li> <li>Sex_Anal</li>
<li>Sex_Vaginal</li> <li>Sex_Vaginal</li>
</interactionDefs> </interactionDefs>
</li> </li>
<li Class="Rimworld_Animations.GroupAnimationContext_RJWSex"> <li Class="Rimworld_Animations.GroupAnimationContext_RJWSex">
<priority>1</priority>
<actorShift>1</actorShift> <actorShift>1</actorShift>
<interactionDefs> <interactionDefs>
<li>Sex_Reverse_Anal</li> <li>Sex_Reverse_Anal</li>
<li>Sex_Reverse_Vaginal</li> <li>Sex_Reverse_Vaginal</li>
</interactionDefs> </interactionDefs>
</li> </li>
<li Class="Rimworld_Animations.GroupAnimationContext_RJWSex">
<priority>0</priority>
<interactionDefs>
<!-- all other contexts go here -->
<!-- the ones that don't make sense but play an animation anyway -->
</interactionDefs>
</li>
</contexts> </contexts>
<offsetDefs> <offsetDefs>

View file

@ -10,16 +10,7 @@ namespace Rimworld_Animations
public abstract class BaseGroupAnimationContext public abstract class BaseGroupAnimationContext
{ {
public int actorShift = 0; public int actorShift = 0;
public int priority = 0; public abstract bool CanAnimationBeUsed(List<Pawn> actors, out int reorder);
public abstract bool CanAnimationBeUsed(List<Pawn> actors);
public virtual int AnimationReorder()
{
return actorShift;
}
public virtual int AnimationPriority()
{
return priority;
}
public abstract string DebugMessage(); public abstract string DebugMessage();
//cool class for designating contexts for animations //cool class for designating contexts for animations

View file

@ -15,10 +15,12 @@ namespace Rimworld_Animations
public List<InteractionDef> interactionDefs; public List<InteractionDef> interactionDefs;
public override bool CanAnimationBeUsed(List<Pawn> actors) public override bool CanAnimationBeUsed(List<Pawn> actors, out int reorder)
{ {
JobDriver_SexBaseInitiator latestSexBaseInitiator = (actors.FindLast(x => x.jobs?.curDriver is JobDriver_SexBaseInitiator).jobs.curDriver as JobDriver_SexBaseInitiator); 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); return interactionDefs.Contains(latestSexBaseInitiator.Sexprops.dictionaryKey);
} }

View file

@ -16,50 +16,24 @@ namespace Rimworld_Animations
public List<AnimationOffsetDef> offsetDefs; public List<AnimationOffsetDef> offsetDefs;
public bool canAnimationBeUsed(List<Pawn> actors) public bool canAnimationBeUsed(List<Pawn> actors, out int reorder)
{ {
if (RJWAnimationSettings.debugMode) if (RJWAnimationSettings.debugMode)
{ {
Log.Message("[anims] Checking if " + defName + " is valid animation"); Log.Message("[anims] Checking if " + defName + " is valid animation");
} }
foreach (BaseGroupAnimationContext context in contexts) foreach (BaseGroupAnimationContext context in contexts)
{ {
if (context.CanAnimationBeUsed(actors)) if (context.CanAnimationBeUsed(actors, out reorder))
{ {
//find all where context matches actors
return true; return true;
} }
} }
return false;
}
public int Priority(List<Pawn> actors, out int reorder)
{
int priority = -999999999;
reorder = 0; reorder = 0;
return false;
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<AnimationDef> GetAllAnimationsForActor(int actor, int seed, int reorder = 0) public List<AnimationDef> GetAllAnimationsForActor(int actor, int seed, int reorder = 0)

View file

@ -17,7 +17,7 @@ namespace Rimworld_Animations
public static bool Prefix(PawnRenderTree __instance, Dictionary<PawnRenderNodeTagDef, PawnRenderNode> ___nodesByTag, PawnRenderNode node, ref PawnDrawParms parms, ref Matrix4x4 matrix, ref bool __result) public static bool Prefix(PawnRenderTree __instance, Dictionary<PawnRenderNodeTagDef, PawnRenderNode> ___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 //find lowest parent that is animating, or nothing if not animating
PawnRenderNode animatingNode = node; PawnRenderNode animatingNode = node;

View file

@ -44,6 +44,7 @@ namespace Rimworld_Animations
} }
} }
} }
//there is no graphic hediff variants appropriate //there is no graphic hediff variants appropriate
@ -62,6 +63,7 @@ namespace Rimworld_Animations
//do graphicvariantsfor //do graphicvariantsfor
variants = GraphicHediffVariantsFor(this.tree.pawn); 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 //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

@ -29,6 +29,7 @@ namespace Rimworld_Animations
public override void TransformRotation(PawnRenderNode node, PawnDrawParms parms, ref Quaternion rotation) public override void TransformRotation(PawnRenderNode node, PawnDrawParms parms, ref Quaternion rotation)
{ {
if (node.AnimationWorker is AnimationWorker_KeyframesExtended if (node.AnimationWorker is AnimationWorker_KeyframesExtended
&& node.tree.pawn.TryGetComp<CompExtendedAnimator>(out CompExtendedAnimator extendedAnimator) && node.tree.pawn.TryGetComp<CompExtendedAnimator>(out CompExtendedAnimator extendedAnimator)
&& extendedAnimator.IsAnimating) && extendedAnimator.IsAnimating)

View file

@ -84,15 +84,15 @@ namespace Rimworld_Animations {
int reorder2 = 0; int reorder2 = 0;
//find all, reorder randomly, then find max priority context DefDatabase<GroupAnimationDef>.AllDefsListForReading.TryRandomElement((GroupAnimationDef x) =>
GroupAnimationDef result = DefDatabase<GroupAnimationDef>.AllDefsListForReading x.canAnimationBeUsed(participants, out reorder2), out GroupAnimationDef result);
.FindAll((GroupAnimationDef x) => x.canAnimationBeUsed(participants))
.OrderBy(_ => Rand.Int)
.MaxBy((GroupAnimationDef x) => x.Priority(participants, out reorder2));
reorder = reorder2; reorder = reorder2;
return result; if (result != null) return result;
return null;
} }