Refactor Movable model and add position offset property to them
This commit is contained in:
@@ -6,18 +6,9 @@ import com.bartlomiejpluta.base.api.internal.logic.Updatable;
|
||||
import com.bartlomiejpluta.base.api.internal.object.Placeable;
|
||||
import com.bartlomiejpluta.base.api.internal.render.Renderable;
|
||||
import com.bartlomiejpluta.base.api.util.path.Path;
|
||||
import org.joml.Vector2ic;
|
||||
|
||||
public interface Animation extends Placeable, Movable, Renderable, Updatable {
|
||||
|
||||
void setStepSize(float x, float y);
|
||||
|
||||
Vector2ic getCoordinates();
|
||||
|
||||
void setCoordinates(Vector2ic coordinates);
|
||||
|
||||
void setCoordinates(int x, int y);
|
||||
|
||||
void setAnimationSpeed(float speed);
|
||||
|
||||
Integer getRepeat();
|
||||
@@ -26,8 +17,6 @@ public interface Animation extends Placeable, Movable, Renderable, Updatable {
|
||||
|
||||
void followPath(Path<Animation> path, Integer repeat, boolean finishOnEnd, boolean finishOnFail);
|
||||
|
||||
void setSpeed(float speed);
|
||||
|
||||
void onAdd(Layer layer);
|
||||
|
||||
void onFinish(Layer layer);
|
||||
|
||||
@@ -159,6 +159,16 @@ public abstract class AnimationDelegate implements Animation {
|
||||
return animation.isMoving();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPositionOffset(Vector2fc offset) {
|
||||
animation.setPositionOffset(offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPositionOffset(float offsetX, float offsetY) {
|
||||
animation.setPositionOffset(offsetX, offsetY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void followPath(Path<Animation> path, Integer repeat, boolean finishOnEnd, boolean finishOnFail) {
|
||||
animation.followPath(path, repeat, finishOnEnd, finishOnFail);
|
||||
|
||||
@@ -4,16 +4,8 @@ import com.bartlomiejpluta.base.api.game.map.layer.object.ObjectLayer;
|
||||
import com.bartlomiejpluta.base.api.internal.logic.Updatable;
|
||||
import com.bartlomiejpluta.base.api.internal.object.Placeable;
|
||||
import com.bartlomiejpluta.base.api.internal.render.Renderable;
|
||||
import org.joml.Vector2ic;
|
||||
|
||||
public interface Entity extends Placeable, Movable, Renderable, Updatable {
|
||||
void setStepSize(float x, float y);
|
||||
|
||||
Vector2ic getCoordinates();
|
||||
|
||||
void setCoordinates(Vector2ic coordinates);
|
||||
|
||||
void setCoordinates(int x, int y);
|
||||
|
||||
Direction getFaceDirection();
|
||||
|
||||
|
||||
@@ -71,6 +71,16 @@ public abstract class EntityDelegate implements Entity {
|
||||
return entity.isMoving();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPositionOffset(Vector2fc offset) {
|
||||
entity.setPositionOffset(offset);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setPositionOffset(float offsetX, float offsetY) {
|
||||
entity.setPositionOffset(offsetX, offsetY);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int chebyshevDistance(Entity other) {
|
||||
return entity.chebyshevDistance(other);
|
||||
|
||||
@@ -1,6 +1,23 @@
|
||||
package com.bartlomiejpluta.base.api.game.entity;
|
||||
|
||||
import org.joml.Vector2fc;
|
||||
import org.joml.Vector2ic;
|
||||
|
||||
public interface Movable {
|
||||
void setStepSize(float x, float y);
|
||||
|
||||
Vector2ic getCoordinates();
|
||||
|
||||
void setCoordinates(Vector2ic coordinates);
|
||||
|
||||
void setCoordinates(int x, int y);
|
||||
|
||||
void setPositionOffset(Vector2fc offset);
|
||||
|
||||
void setPositionOffset(float offsetX, float offsetY);
|
||||
|
||||
void setSpeed(float speed);
|
||||
|
||||
Movement prepareMovement(Direction direction);
|
||||
|
||||
Movement getMovement();
|
||||
|
||||
Reference in New Issue
Block a user