Remove Movement interface - make DefaultMovement a final Movement class and move it to :API
This commit is contained in:
@@ -87,7 +87,7 @@ public class DefaultEntity extends MovableSprite implements Entity {
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean move(Movement movement) {
|
||||
public boolean move(Movement movement) {
|
||||
if (super.move(movement)) {
|
||||
faceDirection = movement.getDirection();
|
||||
return true;
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
package com.bartlomiejpluta.base.engine.world.movement;
|
||||
|
||||
import com.bartlomiejpluta.base.api.move.Direction;
|
||||
import com.bartlomiejpluta.base.api.move.Movement;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.Getter;
|
||||
import org.joml.Vector2i;
|
||||
import org.joml.Vector2ic;
|
||||
|
||||
@Getter
|
||||
@EqualsAndHashCode
|
||||
public class DefaultMovement implements Movement {
|
||||
private final MovableSprite object;
|
||||
private final Direction direction;
|
||||
private final Vector2ic from;
|
||||
private final Vector2ic to;
|
||||
|
||||
DefaultMovement(MovableSprite object, Direction direction) {
|
||||
this.object = object;
|
||||
this.direction = direction;
|
||||
|
||||
this.from = object.getCoordinates();
|
||||
this.to = direction.vector.add(object.getCoordinates(), new Vector2i());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean perform() {
|
||||
return object.move(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Movement another() {
|
||||
return object.prepareMovement(direction);
|
||||
}
|
||||
}
|
||||
@@ -82,10 +82,11 @@ public abstract class MovableSprite extends AnimatedSprite implements Movable, U
|
||||
|
||||
@Override
|
||||
public Movement prepareMovement(Direction direction) {
|
||||
return new DefaultMovement(this, direction);
|
||||
return new Movement(this, direction);
|
||||
}
|
||||
|
||||
protected boolean move(Movement movement) {
|
||||
@Override
|
||||
public boolean move(Movement movement) {
|
||||
if (this.movement != null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user