Enforce Entities exist on only one object layer at the same time
This commit is contained in:
@@ -22,6 +22,8 @@ public interface Entity extends Movable, Renderable, Updatable {
|
||||
|
||||
Direction getDirectionTowards(Entity target);
|
||||
|
||||
ObjectLayer getLayer();
|
||||
|
||||
void onAdd(ObjectLayer layer);
|
||||
|
||||
void onRemove(ObjectLayer layer);
|
||||
|
||||
@@ -32,4 +32,6 @@ public interface Movable extends Placeable {
|
||||
int manhattanDistance(Vector2ic coordinates);
|
||||
|
||||
boolean move(Movement movement);
|
||||
|
||||
void abortMove();
|
||||
}
|
||||
|
||||
@@ -26,6 +26,10 @@ public final class Movement {
|
||||
return object.move(this);
|
||||
}
|
||||
|
||||
public void abort() {
|
||||
object.abortMove();
|
||||
}
|
||||
|
||||
public Movement another() {
|
||||
return object.prepareMovement(direction);
|
||||
}
|
||||
|
||||
@@ -200,6 +200,11 @@ public abstract class AnimationDelegate implements Animation {
|
||||
return animation.move(movement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void abortMove() {
|
||||
animation.abortMove();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdd(Layer layer) {
|
||||
animation.onAdd(layer);
|
||||
|
||||
@@ -194,6 +194,11 @@ public abstract class EntityDelegate implements Entity {
|
||||
return entity.getModelMatrix();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ObjectLayer getLayer() {
|
||||
return entity.getLayer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onAdd(ObjectLayer layer) {
|
||||
entity.onAdd(layer);
|
||||
@@ -234,6 +239,11 @@ public abstract class EntityDelegate implements Entity {
|
||||
return entity.move(movement);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void abortMove() {
|
||||
entity.abortMove();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(float dt) {
|
||||
entity.update(dt);
|
||||
|
||||
Reference in New Issue
Block a user