Class GuidedEntity

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

public abstract class GuidedEntity extends ActiveEntity
An entity that has speed/direction and is guided via a Path.
  • Field Details

    • baseSpeed

      protected double baseSpeed
      The entity's default speed value
    • pathnotifier

      public Registrator pathnotifier
  • Constructor Details

    • GuidedEntity

      public GuidedEntity()
      Create a guided entity.
    • GuidedEntity

      public GuidedEntity(RPObject object)
      Create a guided entity.
      Parameters:
      object - The source object.
  • Method Details

    • getBaseSpeed

      public final double getBaseSpeed()
      Get the normal movement speed.
      Returns:
      The normal speed when moving.
    • setBaseSpeed

      public final void setBaseSpeed(double bs)
      Set the normal movement speed.
      Parameters:
      bs - - New normal speed for moving.
    • setPath

      public final void setPath(FixedPath path)
      Set a path for this entity to follow. Any previous path is cleared and the entity starts at the first node (so the first node should be its position, of course). The speed will be set to the default for the entity.
      Parameters:
      path - The path.
    • setPathAndPosition

      public void setPathAndPosition(FixedPath path)
      Set path & starting position for entity. The starting position is the first node in the path.
      Parameters:
      path - Path to set.
    • setRetracePath

      public void setRetracePath()
      Causes entity to retrace its path backwards when it reaches the end.
    • retracePath

      @Deprecated public void retracePath()
      Deprecated.
      backward compatibility
    • setPath

      public final void setPath(FixedPath path, int position)
      Set a path for this entity to follow. Any previous path is cleared and the entity starts at the first node (so the first node should be its position, of course). The speed will be set to the default for the entity.
      Parameters:
      path - The path.
      position - The position of the path where the entity should start
    • stop

      public void stop()
      Remove PATHSET attribute if available and stop entity movement.
      Overrides:
      stop in class ActiveEntity
    • setCollisionAction

      public void setCollisionAction(CollisionAction action)
      Set the action type to take when entity collides.
      Parameters:
      action - Type of action to execute
    • getPath

      public FixedPath getPath()
      function return current entity's path.
      Returns:
      path
    • clearPath

      public void clearPath()
      Clear the entity's path.
    • hasPath

      public boolean hasPath()
      Determine if the entity has a path.
      Returns:
      true if there is a path.
    • isPathLoop

      public boolean isPathLoop()
      Is the path a loop.
      Returns:
      true if running in circles
    • getPathPosition

      public int getPathPosition()
      Get the path nodes position.
      Returns:
      position in path
    • setPathPosition

      public void setPathPosition(int pathPos)
      Set the path nodes position.
      Parameters:
      pathPos -
    • reroute

      public void reroute()
      Plan a new path to the old destination.
    • applyMovement

      public void applyMovement()
      Apply movement and process it's reactions.
      Overrides:
      applyMovement in class ActiveEntity
    • followPath

      public boolean followPath()
    • getGuide

      public EntityGuide getGuide()
    • onMoved

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

      protected void onNodeReached()
      Suspends the entity's movement if the path position is marked for suspension.
    • addSuspend

      public void addSuspend(int duration, Direction dir, int... pos)
      Add a suspension to the entity's path.
      Parameters:
      duration - Amount of time (in turns) the entity will be suspended.
      dir - Direction to face while suspended, or null if direction should not be changed.
      pos - The position(s) in the path where to add the suspension.
    • addSuspend

      public void addSuspend(int duration, int... pos)
      Add a suspension to the entity's path.
      Parameters:
      duration - Amount of time (in turns) the entity will be suspended. if direction should not be changed.
      pos - The position(s) in the path where to add the suspension.
    • removeSuspend

      public void removeSuspend(int... pos)
      Removes suspension value from path position.
      Parameters:
      pos - The position(s) in the path from where to remove the suspension.
    • onFinishedPath

      public void onFinishedPath()
    • handleObjectCollision

      protected void handleObjectCollision()
      Overrides:
      handleObjectCollision in class ActiveEntity
    • updateModifiedAttributes

      public void updateModifiedAttributes()
    • atMovementRadius

      public final boolean atMovementRadius()
      Checks if the entity has reached a set radius
      Returns:
      true if the entity has moved outside its movement area, othwewise false
    • getDirectionFromOrigin

      protected final Direction getDirectionFromOrigin()
    • getDistanceFromOrigin

      protected final Point getDistanceFromOrigin()
      Get the distance that the entity has moved away from its starting point
      Returns:
      The distance from entity's starting point
    • getCollisionAction

      public CollisionAction getCollisionAction()
      Returns:
      Action to take on collision
    • onOutsideMovementRadius

      public void onOutsideMovementRadius()
      Changed path of entity when radius is reached
    • setRandomMovementRadius

      public void setRandomMovementRadius(int radius)
      Sets the maximum distance the entity will move from its origin
      Parameters:
      radius - max movable distance
    • setRandomMovementRadius

      public void setRandomMovementRadius(int radius, boolean ret)
      Sets the maximum distance an entity will move away from its original position
      Parameters:
      radius - distance entity will move away from its origin
      ret - if "true" entity will return to origin when radius border reached
    • setUsesRandomPath

      protected void setUsesRandomPath(boolean random)
      Sets or unsets entity's path as random.
      Parameters:
      random - true if entity's path is random
    • usesRandomPath

      protected boolean usesRandomPath()
      Determines whether the entity is using a random path.
      Returns:
      true if the entity uses random paths, otherwise false