Add CompletableFuture for animations
This commit is contained in:
@@ -17,6 +17,8 @@ import lombok.Setter;
|
||||
import org.joml.Vector2f;
|
||||
import org.joml.Vector2fc;
|
||||
|
||||
import java.util.concurrent.CompletableFuture;
|
||||
|
||||
import static com.bartlomiejpluta.base.util.path.PathProgress.DONE;
|
||||
import static com.bartlomiejpluta.base.util.path.PathProgress.SEGMENT_FAILED;
|
||||
|
||||
@@ -44,6 +46,9 @@ public class DefaultAnimation extends MovableSprite implements Animation {
|
||||
private Layer layer;
|
||||
private boolean isObjectLayer = false;
|
||||
|
||||
@Getter
|
||||
private final CompletableFuture<Animation> future = new CompletableFuture<>();
|
||||
|
||||
public DefaultAnimation(Mesh mesh, Material material, @NonNull Vector2fc[] frames) {
|
||||
super(mesh, material);
|
||||
this.frames = frames;
|
||||
|
||||
@@ -54,6 +54,7 @@ public abstract class BaseLayer implements Layer, Updatable {
|
||||
|
||||
if (animation.finished()) {
|
||||
animations.remove(animation);
|
||||
animation.getFuture().complete(animation);
|
||||
animation.onFinish(this);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user