public class MovementController<T extends IMobileEntity> extends java.lang.Object implements IMovementController
| Constructor and Description |
|---|
MovementController(T mobileEntity) |
| Modifier and Type | Method and Description |
|---|---|
void |
apply(Force force)
Apply the force to the entity.
|
void |
attach() |
void |
decelerateVelocityX(double dec) |
void |
decelerateVelocityY(double dec) |
void |
detach() |
java.util.List<Force> |
getActiveForces()
Gets the active forces.
|
float |
getDx()
Gets the delta x for each horizontal movement.
|
float |
getDy()
Sets the delta y for each vertical movement.
|
T |
getEntity() |
Force |
getForce(java.lang.String identifier) |
protected double |
getStopThreshold() |
double |
getVelocityX() |
double |
getVelocityY() |
void |
handleMovement() |
boolean |
isMovedX() |
boolean |
isMovedY() |
protected boolean |
isMovementAllowed() |
protected void |
moveEntity(double deltaX,
double deltaY) |
void |
onMovementCheck(java.util.function.Predicate<IMobileEntity> predicate)
Checks given conditions before moving.
|
void |
setDx(float dx)
Gets the delta x for each horizontal movement.
|
void |
setDy(float dy)
Sets the delta y for each vertical movement.
|
void |
setMovedX(boolean movedX) |
void |
setMovedY(boolean movedY) |
protected void |
setVelocityX(double velocityX) |
protected void |
setVelocityY(double velocityY) |
void |
update()
This method is called by the game loop on all objects that are attached to the loop.
|
public MovementController(T mobileEntity)
public void attach()
attach in interface IEntityControllerpublic void detach()
detach in interface IEntityControllerpublic void apply(Force force)
IMovementControllerapply in interface IMovementControllerforce - the force being applied to the entitypublic java.util.List<Force> getActiveForces()
IMovementControllergetActiveForces in interface IMovementControllerpublic T getEntity()
getEntity in interface IEntityControllerpublic float getDx()
IMovementControllergetDx in interface IMovementControllerpublic void setDx(float dx)
IMovementControllersetDx in interface IMovementControllerdx - the new dxpublic float getDy()
IMovementControllergetDy in interface IMovementControllerpublic void setDy(float dy)
IMovementControllersetDy in interface IMovementControllerdy - the new dypublic void onMovementCheck(java.util.function.Predicate<IMobileEntity> predicate)
IMovementControlleronMovementCheck in interface IMovementControllerpredicate - the conditions that need to apply before moving. If they don't apply, the entity won't be moved.public void update()
IUpdateableClientConfiguration.update in interface IUpdateableClientConfiguration.setMaxFps(int)public void handleMovement()
public boolean isMovedX()
public void setMovedX(boolean movedX)
public boolean isMovedY()
public void setMovedY(boolean movedY)
public double getVelocityX()
public Force getForce(java.lang.String identifier)
getForce in interface IMovementControllerprotected void setVelocityX(double velocityX)
protected void setVelocityY(double velocityY)
public void decelerateVelocityX(double dec)
public void decelerateVelocityY(double dec)
public double getVelocityY()
protected double getStopThreshold()
protected void moveEntity(double deltaX,
double deltaY)
protected boolean isMovementAllowed()