From 568012d47da5d7c27e39d9fe917acc4f64ad92e1 Mon Sep 17 00:00:00 2001 From: capdevon Date: Mon, 11 Sep 2023 18:15:48 +0200 Subject: [PATCH] rename class ActionAnimEventListener -> AnimationListener --- ...AnimEventListener.java => AnimationListener.java} | 2 +- game/src/main/java/com/capdevon/anim/Animator.java | 10 +++++----- game/src/main/java/mygame/ai/AIControl.java | 12 +++++++++--- .../main/java/mygame/player/PlayerWeaponManager.java | 4 ++-- 4 files changed, 17 insertions(+), 11 deletions(-) rename game/src/main/java/com/capdevon/anim/{ActionAnimEventListener.java => AnimationListener.java} (89%) diff --git a/game/src/main/java/com/capdevon/anim/ActionAnimEventListener.java b/game/src/main/java/com/capdevon/anim/AnimationListener.java similarity index 89% rename from game/src/main/java/com/capdevon/anim/ActionAnimEventListener.java rename to game/src/main/java/com/capdevon/anim/AnimationListener.java index 1a4464f..3de7adf 100644 --- a/game/src/main/java/com/capdevon/anim/ActionAnimEventListener.java +++ b/game/src/main/java/com/capdevon/anim/AnimationListener.java @@ -6,7 +6,7 @@ * * @author capdevon */ -public interface ActionAnimEventListener { +public interface AnimationListener { /** * For non-looping animations, this event is invoked when the animation is diff --git a/game/src/main/java/com/capdevon/anim/Animator.java b/game/src/main/java/com/capdevon/anim/Animator.java index f98a2ff..a320f36 100644 --- a/game/src/main/java/com/capdevon/anim/Animator.java +++ b/game/src/main/java/com/capdevon/anim/Animator.java @@ -31,7 +31,7 @@ public class Animator extends AdapterControl { private AnimComposer animComposer; private SkinningControl skinningControl; private String currentAnim; - private ArrayList listeners = new ArrayList<>(); + private ArrayList listeners = new ArrayList<>(); private ArmatureDebugger debugger; @Override @@ -156,7 +156,7 @@ private Material createWireMaterial(AssetManager asm) { /** * Adds a new listener to receive animation related events. */ - public void addListener(ActionAnimEventListener listener) { + public void addListener(AnimationListener listener) { if (listeners.contains(listener)) { throw new IllegalArgumentException("The given listener is already registered at this Animator"); } @@ -167,7 +167,7 @@ public void addListener(ActionAnimEventListener listener) { /** * Removes the given listener from listening to events. */ - public void removeListener(ActionAnimEventListener listener) { + public void removeListener(AnimationListener listener) { if (!listeners.remove(listener)) { throw new IllegalArgumentException("The given listener is not registered at this Animator"); } @@ -181,13 +181,13 @@ public void clearListeners() { } void notifyAnimChange(String name) { - for (ActionAnimEventListener listener : listeners) { + for (AnimationListener listener : listeners) { listener.onAnimChange(animComposer, name); } } void notifyAnimCycleDone(String name, boolean loop) { - for (ActionAnimEventListener listener : listeners) { + for (AnimationListener listener : listeners) { listener.onAnimCycleDone(animComposer, name, loop); } } diff --git a/game/src/main/java/mygame/ai/AIControl.java b/game/src/main/java/mygame/ai/AIControl.java index 4d8eb7c..b84bc42 100644 --- a/game/src/main/java/mygame/ai/AIControl.java +++ b/game/src/main/java/mygame/ai/AIControl.java @@ -3,7 +3,7 @@ import java.util.logging.Level; import java.util.logging.Logger; -import com.capdevon.anim.ActionAnimEventListener; +import com.capdevon.anim.AnimationListener; import com.capdevon.anim.Animator; import com.capdevon.control.AdapterControl; import com.jme3.anim.AnimComposer; @@ -25,7 +25,7 @@ * * @author capdevon */ -public class AIControl extends AdapterControl implements ActionAnimEventListener { +public class AIControl extends AdapterControl implements AnimationListener { private static final Logger logger = Logger.getLogger(AIControl.class.getName()); @@ -39,7 +39,7 @@ private enum AIState { /** * display the monster's status in the viewport */ - final private BitmapText hud; + private final BitmapText hud; /** * physics controls */ @@ -129,20 +129,25 @@ private void updateAnimations() { case ATTACK: animator.setAnimation(Monster.Attack2); break; + case AWARE: animator.setAnimation(Monster.Scream); break; + case CHASE: animator.setAnimation(Monster.Running); break; + case DYING: animator.setAnimation(Monster.Dying); bcc.setEnabled(false); bcc.getSpatial().removeControl(bcc); break; + case HIT: animator.setAnimation(Monster.ReactionHit); break; + case IDLE: animator.setAnimation(Monster.OrcIdle); break; @@ -159,6 +164,7 @@ private void updateAnimations() { case WAIT: break; + default: break; } diff --git a/game/src/main/java/mygame/player/PlayerWeaponManager.java b/game/src/main/java/mygame/player/PlayerWeaponManager.java index 7a1b719..974c5d2 100644 --- a/game/src/main/java/mygame/player/PlayerWeaponManager.java +++ b/game/src/main/java/mygame/player/PlayerWeaponManager.java @@ -6,7 +6,7 @@ import java.util.logging.Level; import java.util.logging.Logger; -import com.capdevon.anim.ActionAnimEventListener; +import com.capdevon.anim.AnimationListener; import com.capdevon.anim.Animator; import com.capdevon.anim.HumanBodyBones; import com.capdevon.anim.IKRig; @@ -39,7 +39,7 @@ /** * @author capdevon */ -public class PlayerWeaponManager extends AdapterControl implements ActionAnimEventListener { +public class PlayerWeaponManager extends AdapterControl implements AnimationListener { private static final Logger logger = Logger.getLogger(PlayerWeaponManager.class.getName());