mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-13 04:17:36 +00:00
Merge branch 'dev' into syntax-highlighter-unified
This commit is contained in:
commit
33442f9398
3 files changed
+29
-9
No files matched your search
@@ -39,9 +39,9 @@ public class Animation implements IAnimation {
|
||||
|
||||
protected final Map<String, Object> dataStore = new HashMap<>();
|
||||
|
||||
public Consumer<Animation> onAnimationStart;
|
||||
public BiConsumer<Integer, Animation> onAnimationFrame;
|
||||
public Consumer<Animation> onAnimationEnd;
|
||||
public Consumer<IAnimation> onAnimationStart;
|
||||
public BiConsumer<Integer, IAnimation> onAnimationFrame;
|
||||
public Consumer<IAnimation> onAnimationEnd;
|
||||
|
||||
public Animation() {
|
||||
}
|
||||
@@ -318,17 +318,20 @@ public class Animation implements IAnimation {
|
||||
}
|
||||
}
|
||||
|
||||
public IAnimation onStart(Consumer<Animation> task) {
|
||||
@Override
|
||||
public IAnimation onStart(Consumer<IAnimation> task) {
|
||||
this.onAnimationStart = task;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IAnimation onFrame(BiConsumer<Integer, Animation> task) {
|
||||
|
||||
@Override
|
||||
public IAnimation onFrame(BiConsumer<Integer, IAnimation> task) {
|
||||
this.onAnimationFrame = task;
|
||||
return this;
|
||||
}
|
||||
|
||||
public IAnimation onEnd(Consumer<Animation> task) {
|
||||
|
||||
@Override
|
||||
public IAnimation onEnd(Consumer<IAnimation> task) {
|
||||
this.onAnimationEnd = task;
|
||||
return this;
|
||||
}
|
||||
@@ -350,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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user