From 87e95ad1aaaacf89391241f04015bf35dee11ade Mon Sep 17 00:00:00 2001 From: Collin Smith Date: Tue, 5 Mar 2019 14:57:25 -0800 Subject: [PATCH] Added support for entity animation chaining --- core/src/gdx/diablo/codec/Animation.java | 4 ++++ core/src/gdx/diablo/entity/Entity.java | 10 ++++++++++ core/src/gdx/diablo/entity/StaticEntity.java | 12 +++++++++--- 3 files changed, 23 insertions(+), 3 deletions(-) diff --git a/core/src/gdx/diablo/codec/Animation.java b/core/src/gdx/diablo/codec/Animation.java index d9a43780..cd8470f5 100644 --- a/core/src/gdx/diablo/codec/Animation.java +++ b/core/src/gdx/diablo/codec/Animation.java @@ -189,6 +189,10 @@ public class Animation extends BaseDrawable { } } + public boolean isFinished() { + return frame == numFrames - 1; + } + public boolean isLooping() { return looping; } diff --git a/core/src/gdx/diablo/entity/Entity.java b/core/src/gdx/diablo/entity/Entity.java index c7809d22..a4f22ac0 100644 --- a/core/src/gdx/diablo/entity/Entity.java +++ b/core/src/gdx/diablo/entity/Entity.java @@ -126,6 +126,7 @@ public class Entity { int dirty; String mode; String code; + String mode2; String layers[]; String weaponClass; Vector3 position = new Vector3(); @@ -228,6 +229,11 @@ public class Entity { return (byte) 0xFF; } + public void animate(String mode1, String mode2) { + setMode(mode1); + this.mode2 = mode2; + } + public Vector3 position() { return position; } @@ -532,6 +538,10 @@ public class Entity { animation.draw(batch, x, y); updateLabel(label, x, y); //if (over) drawLabel(batch); + if (mode2 != null && animation.isFinished()) { + setMode(mode2); + mode2 = null; + } } protected void updateLabel(Label label, float x, float y) { diff --git a/core/src/gdx/diablo/entity/StaticEntity.java b/core/src/gdx/diablo/entity/StaticEntity.java index 4d127532..a730ca5d 100644 --- a/core/src/gdx/diablo/entity/StaticEntity.java +++ b/core/src/gdx/diablo/entity/StaticEntity.java @@ -90,7 +90,7 @@ public class StaticEntity extends Entity { case 9 : case 10: case 11: case 12: case 13: case 14: case 15: case 16: break; case 17: // waypoint - // TODO: Automatically sets on + // TODO: Set ON based on save file setMode("ON"); break; case 18: @@ -107,6 +107,12 @@ public class StaticEntity extends Entity { } } + @Override + public void animate(String mode1, String mode2) { + assert !base.CycleAnim[Diablo.files.ObjMode.index(mode1)]; + super.animate(mode1, mode2); + } + private void operate(GameScreen gameScreen) { switch (base.OperateFn) { case 0: @@ -117,8 +123,8 @@ public class StaticEntity extends Entity { break; case 23: // waypoint if (mode.equalsIgnoreCase("NU")) { - setMode("OP"); - //setMode("OP".."ON"); + animate("OP", "ON"); + Diablo.audio.play("object_waypoint_open", true); } break; case 24: case 25: case 26: case 27: case 28: case 29: