Package games.stendhal.server.entity
Class GuidedEntity
java.lang.Object
marauroa.common.game.Attributes
marauroa.common.game.SlotOwner
marauroa.common.game.RPObject
games.stendhal.server.entity.Entity
games.stendhal.server.entity.ActiveEntity
games.stendhal.server.entity.GuidedEntity
- All Implemented Interfaces:
Killer
,Cloneable
,Iterable<String>
,Serializable
- Direct Known Subclasses:
RPEntity
An entity that has speed/direction and is guided via a Path.
-
Nested Class Summary
Nested classes/interfaces inherited from class marauroa.common.game.RPObject
RPObject.ID
-
Field Summary
Modifier and TypeFieldDescriptionprotected double
The entity's default speed valueFields inherited from class marauroa.common.game.RPObject
INVALID_ID
-
Constructor Summary
ConstructorDescriptionCreate a guided entity.GuidedEntity(RPObject object)
Create a guided entity. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addSuspend(int duration, int... pos)
Add a suspension to the entity's path.void
addSuspend(int duration, Direction dir, int... pos)
Add a suspension to the entity's path.void
Apply movement and process it's reactions.boolean
Checks if the entity has reached a set radiusvoid
Clear the entity's path.boolean
double
Get the normal movement speed.protected Direction
protected Point
Get the distance that the entity has moved away from its starting pointgetGuide()
getPath()
function return current entity's path.int
Get the path nodes position.protected void
boolean
hasPath()
Determine if the entity has a path.boolean
Is the path a loop.void
protected void
onMoved(int oldX, int oldY, int newX, int newY)
Notification of intra-zone position change.protected void
Suspends the entity's movement if the path position is marked for suspension.void
Changed path of entity when radius is reachedvoid
removeSuspend(int... pos)
Removes suspension value from path position.void
reroute()
Plan a new path to the old destination.void
Deprecated.void
setBaseSpeed(double bs)
Set the normal movement speed.void
setCollisionAction(CollisionAction action)
Set the action type to take when entity collides.void
Set a path for this entity to follow.void
Set a path for this entity to follow.void
setPathAndPosition(FixedPath path)
Set path & starting position for entity.void
setPathPosition(int pathPos)
Set the path nodes position.void
setRandomMovementRadius(int radius)
Sets the maximum distance the entity will move from its originvoid
setRandomMovementRadius(int radius, boolean ret)
Sets the maximum distance an entity will move away from its original positionvoid
Causes entity to retrace its path backwards when it reaches the end.protected void
setUsesRandomPath(boolean random)
Sets or unsets entity's path as random.void
stop()
Remove PATHSET attribute if available and stop entity movement.void
protected boolean
Determines whether the entity is using a random path.Methods inherited from class games.stendhal.server.entity.ActiveEntity
canMoveTo, canMoveTo, faceto, faceToward, generateRPClass, getDirection, getDirectionToward, getDirectionToward, getResistance, getSpeed, getStepsTaken, handleLeaveZone, handlePortal, handleSimpleCollision, ignoresCollision, isFacingToward, isGhost, isMoveCompleted, isZoneChangeAllowed, move, onAdded, onRemoved, setDirection, setIgnoresCollision, setSpeed, stopped, update
Methods inherited from class games.stendhal.server.entity.Entity
describe, getAdjacentNodes, getArea, getArea, getCursor, getDescription, getDescriptionName, getEntitySlot, getHeight, getName, getOrigin, getResistance, getTitle, getWidth, getX, getY, getZone, hasDescription, isInSight, isObstacle, nextTo, nextTo, notifyWorldAboutChanges, setCursor, setDescription, setEntityClass, setEntitySubclass, setMenu, setPosition, setResistance, setSize, setVisibility, slotIterator, slots, squaredDistance, squaredDistance
Methods inherited from class marauroa.common.game.RPObject
addEvent, addLink, addLink, addMap, addSlot, addSlot, applyDifferences, clearEvents, clearVisible, clone, containsKey, equals, events, eventsIterator, fill, get, getBaseContainer, getBoolean, getContainer, getContainerBaseOwner, getContainerOwner, getContainerSlot, getDifferences, getDouble, getFromSlots, getID, getInt, getLink, getLinkedObject, getMap, getSlot, has, hashCode, hasLink, hasMap, hasSlot, hide, isContained, isEmpty, isHidden, isStorable, maps, put, put, put, put, readObject, remove, removeLink, removeMap, removeSlot, resetAddedAndDeleted, resetAddedAndDeletedMaps, resetAddedAndDeletedRPLink, resetAddedAndDeletedRPSlot, setAddedMaps, setAddedRPSlot, setContainer, setDeletedMaps, setDeletedRPSlot, setID, size, slots, slotsIterator, store, toString, unhide, unstore, writeObject, writeObject, writeToJson
Methods inherited from class marauroa.common.game.SlotOwner
deserializeRPSlots, fill, serializeRPSlots
Methods inherited from class marauroa.common.game.Attributes
add, applyDifferences, get, getBool, getDouble, getInt, getList, getLong, getRPClass, has, instanceOf, iterator, put, put, put, put, put, readFromMap, remove, resetAddedAndDeletedAttributes, setAddedAttributes, setDeletedAttributes, setRPClass, setRPClass, toAttributeString
Methods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
baseSpeed
protected double baseSpeedThe entity's default speed value -
pathnotifier
-
-
Constructor Details
-
GuidedEntity
public GuidedEntity()Create a guided entity. -
GuidedEntity
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
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
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.UsesetRetracePath()
.backward compatibility -
setPath
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 classActiveEntity
-
setCollisionAction
Set the action type to take when entity collides.- Parameters:
action
- Type of action to execute
-
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 classActiveEntity
-
followPath
public boolean followPath() -
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 classActiveEntity
- 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
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, ornull
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 classActiveEntity
-
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, othwewisefalse
-
getDirectionFromOrigin
-
getDistanceFromOrigin
Get the distance that the entity has moved away from its starting point- Returns:
- The distance from entity's starting point
-
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 originret
- 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, otherwisefalse
-
setRetracePath()
.