Important IAnimation takeTasksFrom global instance in AnimationController to local instance in entity AnimationData

This commit is contained in:
bigguy345 committed 2026-01-05 20:25:34 +02:00
1 parent db0aa94a3a
commit e8ef60deb4
2 files changed
+17

No files matched your search

@@ -353,6 +353,22 @@ public class Animation implements IAnimation {
this.onAnimationEnd.accept(this);
}
}
/**
* Only called on setAnimation, to transfer tasks from
* this global instance stored in AnimationController
* to the new local instance on entity's AnimationData,
* and clear them from the global instance.
*/
public void takeTasksFrom(Animation animation) {
this.onAnimationStart = animation.onAnimationStart;
this.onAnimationFrame = animation.onAnimationFrame;
this.onAnimationEnd = animation.onAnimationEnd;
animation.onAnimationEnd = null;
animation.onAnimationFrame = null;
animation.onAnimationStart = null;
}
}
@@ -272,6 +272,7 @@ public class AnimationData implements IAnimationData {
newAnim.currentFrame = 0;
newAnim.currentFrameTime = 0;
newAnim.parent = this;
newAnim.takeTasksFrom((Animation) animation);
}