mirror of
https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
synced 2024-08-15 00:43:45 +00:00
Compare commits
3 commits
319979b0f3
...
c3ee13de83
Author | SHA1 | Date | |
---|---|---|---|
|
c3ee13de83 | ||
|
e914cab80a | ||
|
990d27d4b1 |
10 changed files with 81 additions and 20 deletions
Binary file not shown.
|
@ -107,6 +107,27 @@
|
||||||
</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>
|
|
@ -38,18 +38,28 @@
|
||||||
|
|
||||||
<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>
|
||||||
|
|
|
@ -10,7 +10,16 @@ namespace Rimworld_Animations
|
||||||
public abstract class BaseGroupAnimationContext
|
public abstract class BaseGroupAnimationContext
|
||||||
{
|
{
|
||||||
public int actorShift = 0;
|
public int actorShift = 0;
|
||||||
public abstract bool CanAnimationBeUsed(List<Pawn> actors, out int reorder);
|
public int priority = 0;
|
||||||
|
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
|
||||||
|
|
|
@ -15,12 +15,10 @@ namespace Rimworld_Animations
|
||||||
|
|
||||||
public List<InteractionDef> interactionDefs;
|
public List<InteractionDef> interactionDefs;
|
||||||
|
|
||||||
public override bool CanAnimationBeUsed(List<Pawn> actors, out int reorder)
|
public override bool CanAnimationBeUsed(List<Pawn> actors)
|
||||||
{
|
{
|
||||||
|
|
||||||
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);
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,26 +16,52 @@ namespace Rimworld_Animations
|
||||||
public List<AnimationOffsetDef> offsetDefs;
|
public List<AnimationOffsetDef> offsetDefs;
|
||||||
|
|
||||||
|
|
||||||
public bool canAnimationBeUsed(List<Pawn> actors, out int reorder)
|
public bool canAnimationBeUsed(List<Pawn> actors)
|
||||||
{
|
{
|
||||||
|
|
||||||
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, out reorder))
|
if (context.CanAnimationBeUsed(actors))
|
||||||
{
|
{
|
||||||
|
//find all where context matches actors
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
reorder = 0;
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int Priority(List<Pawn> 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<AnimationDef> GetAllAnimationsForActor(int actor, int seed, int reorder = 0)
|
public List<AnimationDef> GetAllAnimationsForActor(int actor, int seed, int reorder = 0)
|
||||||
{
|
{
|
||||||
List<AnimationDef> animations = new List<AnimationDef>();
|
List<AnimationDef> animations = new List<AnimationDef>();
|
||||||
|
|
|
@ -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 fix
|
* Facing offsets 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;
|
||||||
|
|
|
@ -44,7 +44,6 @@ namespace Rimworld_Animations
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//there is no graphic hediff variants appropriate
|
//there is no graphic hediff variants appropriate
|
||||||
|
@ -63,7 +62,6 @@ 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();
|
||||||
}
|
}
|
||||||
|
|
|
@ -29,7 +29,6 @@ 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)
|
||||||
|
|
|
@ -84,15 +84,15 @@ namespace Rimworld_Animations {
|
||||||
|
|
||||||
int reorder2 = 0;
|
int reorder2 = 0;
|
||||||
|
|
||||||
DefDatabase<GroupAnimationDef>.AllDefsListForReading.TryRandomElement((GroupAnimationDef x) =>
|
//find all, reorder randomly, then find max priority context
|
||||||
x.canAnimationBeUsed(participants, out reorder2), out GroupAnimationDef result);
|
GroupAnimationDef result = DefDatabase<GroupAnimationDef>.AllDefsListForReading
|
||||||
|
.FindAll((GroupAnimationDef x) => x.canAnimationBeUsed(participants))
|
||||||
|
.OrderBy(_ => Rand.Int)
|
||||||
|
.MaxBy((GroupAnimationDef x) => x.Priority(participants, out reorder2));
|
||||||
|
|
||||||
|
|
||||||
reorder = reorder2;
|
reorder = reorder2;
|
||||||
if (result != null) return result;
|
return result;
|
||||||
|
|
||||||
return null;
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue