Class ActiveEntity

All Implemented Interfaces:
Killer, Cloneable, Iterable<String>, Serializable
Direct Known Subclasses:
Block, GuidedEntity

public abstract class ActiveEntity extends Entity
An entity that has speed and direction.
  • Constructor Details

    • ActiveEntity

      public ActiveEntity()
      Create an active entity.
    • ActiveEntity

      public ActiveEntity(RPObject object)
      Create an active entity.
      Parameters:
      object - The source object.
  • Method Details

    • move

      protected void move(int x, int y, int nx, int ny)
    • handlePortal

      protected boolean handlePortal(Portal portal)
    • handleLeaveZone

      protected void handleLeaveZone(int nx, int ny)
    • generateRPClass

      public static void generateRPClass()
      Generate the RPClass (compatible with manual init/order). NOTE: This MUST be called during environment initialization.
    • isZoneChangeAllowed

      protected boolean isZoneChangeAllowed()
      Determine if zone changes are currently allowed via normal means (non-portal teleportation doesn't count).
      Returns:
      true if the entity can change zones.
    • onAdded

      public void onAdded(StendhalRPZone zone)
      Called when this object is added to a zone.
      Overrides:
      onAdded in class Entity
      Parameters:
      zone - The zone this was added to.
    • onRemoved

      public void onRemoved(StendhalRPZone zone)
      Called when this object is removed from a zone.
      Overrides:
      onRemoved in class Entity
      Parameters:
      zone - The zone this was removed from.
    • update

      public void update()
      Overrides:
      update in class Entity
    • isGhost

      public boolean isGhost()
      Checks whether an entity is a ghost (non physically interactive).
      Returns:
      true if in ghost mode.
    • getResistance

      public int getResistance()
      Get the resistance this has on other entities (0-100).
      Overrides:
      getResistance in class Entity
      Returns:
      The amount of resistance, or 0 if in ghostmode.
    • faceto

      public final void faceto(int x, int y)
      Face toward a specified point on the map.
      Parameters:
      x - Horizontal coordinate of position
      y - Vertical coordinate of position
    • faceToward

      public final void faceToward(Entity entity)
      Face toward an entity.
      Parameters:
      entity - The entity to face toward
    • getDirection

      public Direction getDirection()
      Get the current facing direction.
      Returns:
      The facing direction
    • getDirectionToward

      public final Direction getDirectionToward(Entity entity)
      Get the direction toward an entity.
      Parameters:
      entity - The target entity
      Returns:
      A facing direction
    • getDirectionToward

      public final Direction getDirectionToward(Rectangle2D area)
    • isFacingToward

      public boolean isFacingToward(Entity entity)
      Determine if this entity is facing toward another entity.
      Parameters:
      entity - The target entity
      Returns:
      true if facing other entity
    • setDirection

      public void setDirection(Direction dir)
      Set the facing direction.
      Parameters:
      dir - Direction to face toward
    • applyMovement

      public void applyMovement()
      Apply movement and process it's reactions.
    • getSpeed

      public double getSpeed()
      Get the current speed.
      Returns:
      The current speed, or 0.0 if stopped.
    • getStepsTaken

      public int getStepsTaken()
      Retrieves the amount of steps the entity has taken during the current session.
      Returns:
      Steps taken
    • isMoveCompleted

      protected boolean isMoveCompleted()
      Determine if this entity has move at least a whole tile.
      Returns:
      true if moved a whole tile
    • onMoved

      protected void onMoved(int oldX, int oldY, int newX, int newY)
      Notification of intra-zone position change.
      Overrides:
      onMoved in class Entity
      Parameters:
      oldX - The old X coordinate.
      oldY - The old Y coordinate.
      newX - The new X coordinate.
      newY - The new Y coordinate.
    • setSpeed

      public void setSpeed(double speed)
      Set the movement speed.
      Parameters:
      speed - New speed.
    • stop

      public void stop()
      Stops entity's movement.
    • stopped

      public boolean stopped()
      Checks if the entity is not moving.
      Overrides:
      stopped in class Entity
      Returns:
      true if stopped, false if moving
    • handleObjectCollision

      protected void handleObjectCollision()
    • handleSimpleCollision

      protected void handleSimpleCollision(int nx, int ny)
      a simple collision is from tiled collision layer or the edge of the map.
      Parameters:
      ny -
      nx -
    • ignoresCollision

      public boolean ignoresCollision()
      Tells if entity can pass through collision tiles
      Returns:
      ignoreCollision
    • setIgnoresCollision

      public void setIgnoresCollision(boolean ignore)
      Set entity to ignore collision tiles
      Parameters:
      ignore -
    • canMoveTo

      public boolean canMoveTo(int x, int y)
      Predict if entity can move to a position.
      Parameters:
      x -
      y -
      Returns:
    • canMoveTo

      public boolean canMoveTo(Point pos)
      Predict if entity can move to a position.
      Parameters:
      pos -
      Returns: