Skip to content

Commit

Permalink
rename class ActionAnimEventListener -> AnimationListener
Browse files Browse the repository at this point in the history
  • Loading branch information
capdevon committed Sep 11, 2023
1 parent d98cbb2 commit 568012d
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
*
* @author capdevon
*/
public interface ActionAnimEventListener {
public interface AnimationListener {

/**
* For non-looping animations, this event is invoked when the animation is
Expand Down
10 changes: 5 additions & 5 deletions game/src/main/java/com/capdevon/anim/Animator.java
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public class Animator extends AdapterControl {
private AnimComposer animComposer;
private SkinningControl skinningControl;
private String currentAnim;
private ArrayList<ActionAnimEventListener> listeners = new ArrayList<>();
private ArrayList<AnimationListener> listeners = new ArrayList<>();
private ArmatureDebugger debugger;

@Override
Expand Down Expand Up @@ -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");
}
Expand All @@ -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");
}
Expand All @@ -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);
}
}
Expand Down
12 changes: 9 additions & 3 deletions game/src/main/java/mygame/ai/AIControl.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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());

Expand All @@ -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
*/
Expand Down Expand Up @@ -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;
Expand All @@ -159,6 +164,7 @@ private void updateAnimations() {

case WAIT:
break;

default:
break;
}
Expand Down
4 changes: 2 additions & 2 deletions game/src/main/java/mygame/player/PlayerWeaponManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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());

Expand Down

0 comments on commit 568012d

Please sign in to comment.