Class MovableAreaEntity

All Implemented Interfaces:
Interactable, Acoustics, Actor, Graphics, Updatable, Positionable

public abstract class MovableAreaEntity extends AreaEntity
MovableAreaEntity represent AreaEntity which can move on the grid
  • Constructor Details

    • MovableAreaEntity

      public MovableAreaEntity(Area area, Orientation orientation, DiscreteCoordinates position)
      Default MovableAreaEntity constructor
      Parameters:
      area - (Area): Owner area. Not null
      orientation - (Orientation): Initial orientation of the entity. Not null
      position - (Coordinate): Initial position of the entity. Not null
  • Method Details

    • resetMotion

      protected void resetMotion()
      Initialize or reset (if some) the current motion information
    • move

      protected final boolean move(int frameForMove)
      Final move method If no displacement occurs or if the displacement just ends now, start movement of one Cell in the current Orientation direction Note the movement is possible only if this MovableAreaEntity can: - leave the cells this motion implies to leave - enter the cells this motion implies to enter
      Parameters:
      frameForMove - (int): the frame. This value will be cropped to 1 if smaller
      Returns:
      (boolean): indicate if the move is initiated
    • move

      protected final boolean move(int frameForMove, int startingFrame)
      Final move method If no displacement occurs or if the displacement just ends now, start movement of one Cell in the current Orientation direction Note the movement is possible only if this MovableAreaEntity can: - leave the cells this motion implies to leave - enter the cells this motion implies to enter
      Parameters:
      frameForMove - (int): the frame. This value will be cropped to 1 if smaller
      startingFrame - (int): start the movement directly from this frame
      Returns:
      (boolean): indicate if the move is initiated
    • changePosition

      public boolean changePosition(DiscreteCoordinates newPosition)
      Change the unit position to the one specified
      Parameters:
      newPosition - new unit's position
      Returns:
      true if the move was successful, false otherwise
    • abortCurrentMove

      protected final boolean abortCurrentMove()
      Final abortCurrentMove method If a displacement occurs and if the displacement is not end, abort the current move, returning to the previous cell Note the abort is possible only if this MovableAreaEntity can: - return to the cells it left - leave the cells it entered
      Returns:
      (boolean): indicate if the abort is initiated
    • isDisplacementOccurs

      protected boolean isDisplacementOccurs()
      Indicate if a displacement is occurring
      Returns:
      (boolean)
    • isTargetReached

      protected boolean isTargetReached()
      Returns:
      (boolean): true when the target cell is just reaching now
    • orientate

      protected boolean orientate(Orientation orientation)
      Description copied from class: AreaEntity
      Orientate the AreaEntity to a new orientation
      Overrides:
      orientate in class AreaEntity
      Parameters:
      orientation - (Orientation): The new orientation. Not null
      Returns:
      (boolean): if the orientation change happens, by default always true
    • update

      public void update(float deltaTime)
      Description copied from interface: Updatable
      Simulates a single time step. Note: Need to be Override
      Parameters:
      deltaTime - elapsed time since last update, in seconds, non-negative
    • getVelocity

      public Vector getVelocity()
      Specified by:
      getVelocity in interface Positionable
      Overrides:
      getVelocity in class Entity
      Returns:
      (Vector): linear velocity, not null