mirror of
https://gitgud.io/c0ffeeeeeeee/rimworld-animations.git
synced 2024-08-15 00:43:45 +00:00
texture recaching issue fix
This commit is contained in:
parent
43843a398f
commit
fbf8b3444d
7 changed files with 79 additions and 35 deletions
Binary file not shown.
|
@ -24,46 +24,51 @@
|
||||||
</li>
|
</li>
|
||||||
</loopOptions>
|
</loopOptions>
|
||||||
</li>
|
</li>
|
||||||
<!--
|
|
||||||
<li Class="Rimworld_Animations.AnimationStage_Branch">
|
<li Class="Rimworld_Animations.AnimationStage_Branch">
|
||||||
<paths>
|
<paths>
|
||||||
<li Class="Rimworld_Animations.AnimationStage_LoopRandomSelectChance">
|
<li Class="Rimworld_Animations.AnimationStage_LoopRandomSelectChance">
|
||||||
<loops>10</loops>
|
<loops>10</loops>
|
||||||
<animationOptions>
|
<loopOptions>
|
||||||
<li>
|
<li>
|
||||||
<probability>3</probability>
|
<probability>3</probability>
|
||||||
<li>Pawn1_Stage2_Variant1</li>
|
<animationDefs>
|
||||||
<li>Pawn2_Stage2_Variant1</li>
|
<li>TestAnimation1</li>
|
||||||
|
<li>TestAnimation1</li>
|
||||||
|
</animationDefs>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<probability>1</probability>
|
<probability>1</probability>
|
||||||
<li>Pawn1_Stage2_Variant2</li>
|
<animationDefs>
|
||||||
<li>Pawn2_Stage2_Variant2</li>
|
<li>TestAnimation1</li>
|
||||||
|
<li>TestAnimation1</li>
|
||||||
|
</animationDefs>
|
||||||
</li>
|
</li>
|
||||||
</animationOptions>
|
</loopOptions>
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
<li Class="Rimworld_Animations.AnimationStage_LoopRandomSelectChance">
|
<li Class="Rimworld_Animations.AnimationStage_LoopRandomSelectChance">
|
||||||
<loops>10</loops>
|
<loops>10</loops>
|
||||||
<animationOptions>
|
<loopOptions>
|
||||||
<li>
|
<li>
|
||||||
<probability>3</probability>
|
<probability>3</probability>
|
||||||
<li>Pawn1_Stage2_Variant1</li>
|
<animationDefs>
|
||||||
<li>Pawn2_Stage2_Variant1</li>
|
<li>TestAnimation2</li>
|
||||||
|
<li>TestAnimation2</li>
|
||||||
|
</animationDefs>
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
<li>
|
<li>
|
||||||
<probability>1</probability>
|
<probability>1</probability>
|
||||||
<li>Pawn1_Stage2_Variant2</li>
|
<animationDefs>
|
||||||
<li>Pawn2_Stage2_Variant2</li>
|
<li>TestAnimation2</li>
|
||||||
|
<li>TestAnimation2</li>
|
||||||
|
</animationDefs>
|
||||||
</li>
|
</li>
|
||||||
</animationOptions>
|
</loopOptions>
|
||||||
|
|
||||||
</li>
|
</li>
|
||||||
</paths>
|
</paths>
|
||||||
</li>
|
</li>
|
||||||
-->
|
|
||||||
</animationStages>
|
</animationStages>
|
||||||
|
|
||||||
<contexts>
|
<contexts>
|
||||||
|
|
|
@ -35,3 +35,4 @@
|
||||||
</raceOffsets>
|
</raceOffsets>
|
||||||
</Rimworld_Animations.OffsetDef>
|
</Rimworld_Animations.OffsetDef>
|
||||||
</Defs>
|
</Defs>
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace Rimworld_Animations
|
||||||
//use extendedkeyframes to determine addon facing
|
//use extendedkeyframes to determine addon facing
|
||||||
public Rot4 facingAtTick(int tick)
|
public Rot4 facingAtTick(int tick)
|
||||||
{
|
{
|
||||||
|
|
||||||
//if ticks are < first keyframe tick, just be stuck to first keyframe rot
|
//if ticks are < first keyframe tick, just be stuck to first keyframe rot
|
||||||
if (tick <= this.part.keyframes[0].tick) {
|
if (tick <= this.part.keyframes[0].tick) {
|
||||||
|
|
||||||
|
@ -64,8 +65,6 @@ namespace Rimworld_Animations
|
||||||
return (keyframe as ExtendedKeyframe).rotation;
|
return (keyframe as ExtendedKeyframe).rotation;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public bool visibleAtTick(int tick)
|
public bool visibleAtTick(int tick)
|
||||||
{
|
{
|
||||||
//if ticks are < first keyframe tick, just be stuck to first keyframe rot
|
//if ticks are < first keyframe tick, just be stuck to first keyframe rot
|
||||||
|
@ -110,5 +109,15 @@ namespace Rimworld_Animations
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public bool shouldRecache(int tick)
|
||||||
|
{
|
||||||
|
if (facingAtTick(tick) != facingAtTick(tick - 1) || visibleAtTick(tick) != visibleAtTick(tick - 1))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,8 @@ namespace Rimworld_Animations {
|
||||||
|
|
||||||
// CompExtendedAnimator
|
// CompExtendedAnimator
|
||||||
// Helps manage AnimationQueue, AbsolutePosition
|
// Helps manage AnimationQueue, AbsolutePosition
|
||||||
|
//ticks of current animation
|
||||||
|
private int animationTicks;
|
||||||
|
|
||||||
private List<AnimationDef> animationQueue;
|
private List<AnimationDef> animationQueue;
|
||||||
private BaseExtendedAnimatorAnchor anchor;
|
private BaseExtendedAnimatorAnchor anchor;
|
||||||
|
@ -41,8 +43,6 @@ namespace Rimworld_Animations {
|
||||||
return anchor.getDrawPos();
|
return anchor.getDrawPos();
|
||||||
}
|
}
|
||||||
|
|
||||||
//ticks of current animation
|
|
||||||
private int animationTicks;
|
|
||||||
|
|
||||||
public override void CompTick()
|
public override void CompTick()
|
||||||
{
|
{
|
||||||
|
@ -111,20 +111,24 @@ namespace Rimworld_Animations {
|
||||||
public void PlayGroupAnimation(List<AnimationDef> groupAnimation, BaseExtendedAnimatorAnchor anchor)
|
public void PlayGroupAnimation(List<AnimationDef> groupAnimation, BaseExtendedAnimatorAnchor anchor)
|
||||||
{
|
{
|
||||||
this.anchor = anchor;
|
this.anchor = anchor;
|
||||||
animationQueue = groupAnimation;
|
PlayGroupAnimation(groupAnimation);
|
||||||
PlayNextAnimation();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void PostExposeData()
|
public override void PostExposeData()
|
||||||
{
|
{
|
||||||
base.PostExposeData();
|
base.PostExposeData();
|
||||||
Scribe_Values.Look<bool>(ref this.isAnimating, "animations_isAnimating", false);
|
Scribe_Values.Look<bool>(ref this.isAnimating, "animations_isAnimating", false);
|
||||||
|
Scribe_Values.Look<int>(ref this.animationTicks, "animations_ticks", 0);
|
||||||
Scribe_Collections.Look<AnimationDef>(ref animationQueue, "animations_queue");
|
Scribe_Collections.Look<AnimationDef>(ref animationQueue, "animations_queue");
|
||||||
Scribe_Deep.Look<BaseExtendedAnimatorAnchor>(ref this.anchor, "animations_anchor");
|
Scribe_Deep.Look<BaseExtendedAnimatorAnchor>(ref this.anchor, "animations_anchor");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void CheckRecacheNecessary(int anim)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private Pawn pawn => base.parent as Pawn;
|
private Pawn pawn => base.parent as Pawn;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,24 +21,14 @@ namespace Rimworld_Animations
|
||||||
|
|
||||||
// ADJUST FACING get rotated textures
|
// ADJUST FACING get rotated textures
|
||||||
// compare the previous tick to the current tick; if the current tick rotation is different, recache
|
// compare the previous tick to the current tick; if the current tick rotation is different, recache
|
||||||
|
parms.facing = extendedAnimWorker.facingAtTick(__instance.tree.AnimationTick);
|
||||||
|
|
||||||
Rot4 animFacing = extendedAnimWorker.facingAtTick(__instance.tree.AnimationTick);
|
|
||||||
|
|
||||||
if (extendedAnimWorker.facingAtTick(__instance.tree.AnimationTick - 1) != extendedAnimWorker.facingAtTick(__instance.tree.AnimationTick))
|
|
||||||
{
|
|
||||||
__instance.requestRecache = true;
|
|
||||||
parms.facing = animFacing;
|
|
||||||
}
|
|
||||||
|
|
||||||
//INVIS IF ANIM CALLS FOR IT
|
//INVIS IF ANIM CALLS FOR IT
|
||||||
//replace maybe?
|
//replace maybe?
|
||||||
|
|
||||||
//cheaper call now comparing prev tick to cur tick
|
//cheaper call now comparing prev tick to cur tick
|
||||||
if (extendedAnimWorker.visibleAtTick(__instance.tree.AnimationTick - 1) != extendedAnimWorker.visibleAtTick(__instance.tree.AnimationTick))
|
|
||||||
{
|
|
||||||
__instance.requestRecache = true;
|
|
||||||
return extendedAnimWorker.visibleAtTick(__instance.tree.AnimationTick);
|
return extendedAnimWorker.visibleAtTick(__instance.tree.AnimationTick);
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -33,4 +33,39 @@ namespace Rimworld_Animations
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[HarmonyPatch(typeof(PawnRenderTree), "AdjustParms")]
|
||||||
|
public class HarmonyPatch_PawnRenderTree2
|
||||||
|
{
|
||||||
|
public static void Prefix(PawnRenderTree __instance, ref PawnDrawParms parms)
|
||||||
|
{
|
||||||
|
|
||||||
|
int animationTick = __instance.AnimationTick;
|
||||||
|
|
||||||
|
if (__instance.rootNode.AnimationWorker is AnimationWorker_KeyframesExtended rootAnimWorkerExtended)
|
||||||
|
{
|
||||||
|
//recache during facing turn
|
||||||
|
if (rootAnimWorkerExtended.shouldRecache(animationTick))
|
||||||
|
{
|
||||||
|
__instance.rootNode.requestRecache = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
foreach (PawnRenderNode node in __instance.rootNode.children)
|
||||||
|
{
|
||||||
|
if (node.AnimationWorker is AnimationWorker_KeyframesExtended animWorkerExtended)
|
||||||
|
{
|
||||||
|
//recache during facing turn
|
||||||
|
if (animWorkerExtended.shouldRecache(animationTick))
|
||||||
|
{
|
||||||
|
|
||||||
|
node.requestRecache = true;
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue