Extract Animated trait interface
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
package com.bartlomiejpluta.base.api.animation;
|
||||
|
||||
import com.bartlomiejpluta.base.internal.logic.Updatable;
|
||||
|
||||
public interface Animated extends Updatable {
|
||||
boolean isAnimationEnabled();
|
||||
|
||||
void setAnimationEnabled(boolean enabled);
|
||||
|
||||
void enableAnimation();
|
||||
|
||||
void disableAnimation();
|
||||
|
||||
void toggleAnimationEnabled();
|
||||
|
||||
float getAnimationSpeed();
|
||||
|
||||
void setAnimationSpeed(float speed);
|
||||
}
|
||||
@@ -6,9 +6,7 @@ import com.bartlomiejpluta.base.internal.logic.Updatable;
|
||||
import com.bartlomiejpluta.base.internal.render.Renderable;
|
||||
import com.bartlomiejpluta.base.util.path.Path;
|
||||
|
||||
public interface Animation extends Movable, Renderable, Updatable {
|
||||
|
||||
void setAnimationSpeed(float speed);
|
||||
public interface Animation extends Movable, Animated, Renderable, Updatable {
|
||||
|
||||
Integer getRepeat();
|
||||
|
||||
|
||||
@@ -1,21 +1,18 @@
|
||||
package com.bartlomiejpluta.base.api.entity;
|
||||
|
||||
import com.bartlomiejpluta.base.api.animation.Animated;
|
||||
import com.bartlomiejpluta.base.api.map.layer.object.ObjectLayer;
|
||||
import com.bartlomiejpluta.base.api.move.Direction;
|
||||
import com.bartlomiejpluta.base.api.move.Movable;
|
||||
import com.bartlomiejpluta.base.internal.logic.Updatable;
|
||||
import com.bartlomiejpluta.base.internal.render.Renderable;
|
||||
|
||||
public interface Entity extends Movable, Renderable, Updatable {
|
||||
public interface Entity extends Movable, Animated, Renderable, Updatable {
|
||||
|
||||
Direction getFaceDirection();
|
||||
|
||||
void setFaceDirection(Direction direction);
|
||||
|
||||
void setSpeed(float speed);
|
||||
|
||||
void setAnimationSpeed(float speed);
|
||||
|
||||
int chebyshevDistance(Entity other);
|
||||
|
||||
int manhattanDistance(Entity other);
|
||||
|
||||
@@ -41,6 +41,36 @@ public abstract class AnimationDelegate implements Animation {
|
||||
animation.setCoordinates(x, y);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAnimationEnabled() {
|
||||
return animation.isAnimationEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAnimationEnabled(boolean enabled) {
|
||||
animation.setAnimationEnabled(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableAnimation() {
|
||||
animation.enableAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableAnimation() {
|
||||
animation.disableAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toggleAnimationEnabled() {
|
||||
animation.toggleAnimationEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAnimationSpeed() {
|
||||
return animation.getAnimationSpeed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAnimationSpeed(float speed) {
|
||||
animation.setAnimationSpeed(speed);
|
||||
|
||||
@@ -65,6 +65,36 @@ public abstract class EntityDelegate implements Entity {
|
||||
entity.setSpeed(speed);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAnimationEnabled() {
|
||||
return entity.isAnimationEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAnimationEnabled(boolean enabled) {
|
||||
entity.setAnimationEnabled(enabled);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enableAnimation() {
|
||||
entity.enableAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void disableAnimation() {
|
||||
entity.disableAnimation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void toggleAnimationEnabled() {
|
||||
entity.toggleAnimationEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getAnimationSpeed() {
|
||||
return entity.getAnimationSpeed();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAnimationSpeed(float speed) {
|
||||
entity.setAnimationSpeed(speed);
|
||||
|
||||
Reference in New Issue
Block a user