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:
CombatEntity
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
FieldsModifier and TypeFieldDescriptionprotected doubleThe entity's default speed valueFields inherited from class marauroa.common.game.RPObject
INVALID_ID -
Constructor Summary
ConstructorsConstructorDescriptionCreate a guided entity.GuidedEntity(RPObject object) Create a guided entity. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddSuspend(int duration, int... pos) Add a suspension to the entity's path.voidaddSuspend(int duration, Direction dir, int... pos) Add a suspension to the entity's path.voidApply movement and process it's reactions.final booleanChecks if the entity has reached a set radiusvoidClear the entity's path.booleanfinal doubleGet the normal movement speed.protected final Directionprotected final PointGet the distance that the entity has moved away from its starting pointgetGuide()getPath()function return current entity's path.intGet the path nodes position.protected voidbooleanhasPath()Determine if the entity has a path.booleanIs the path a loop.voidprotected voidonMoved(int oldX, int oldY, int newX, int newY) Notification of intra-zone position change.protected voidSuspends the entity's movement if the path position is marked for suspension.voidChanged path of entity when radius is reachedvoidremoveSuspend(int... pos) Removes suspension value from path position.voidreroute()Plan a new path to the old destination.voidDeprecated.final voidsetBaseSpeed(double bs) Set the normal movement speed.voidsetCollisionAction(CollisionAction action) Set the action type to take when entity collides.final voidSet a path for this entity to follow.final voidSet a path for this entity to follow.voidsetPathAndPosition(FixedPath path) Set path & starting position for entity.voidsetPathPosition(int pathPos) Set the path nodes position.voidsetRandomMovementRadius(int radius) Sets the maximum distance the entity will move from its originvoidsetRandomMovementRadius(int radius, boolean ret) Sets the maximum distance an entity will move away from its original positionvoidCauses entity to retrace its path backwards when it reaches the end.protected voidsetUsesRandomPath(boolean random) Sets or unsets entity's path as random.voidstop()Remove PATHSET attribute if available and stop entity movement.voidprotected booleanDetermines 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, updateMethods 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, squaredDistanceMethods 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, writeToJsonMethods inherited from class marauroa.common.game.SlotOwner
deserializeRPSlots, fill, serializeRPSlotsMethods 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, toAttributeStringMethods inherited from class java.lang.Object
finalize, getClass, notify, notifyAll, wait, wait, waitMethods 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:
stopin 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:
trueif 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:
applyMovementin classActiveEntity
-
followPath
public boolean followPath() -
getGuide
-
onMoved
protected void onMoved(int oldX, int oldY, int newX, int newY) Description copied from class:ActiveEntityNotification of intra-zone position change.- Overrides:
onMovedin 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, ornullif 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:
handleObjectCollisionin classActiveEntity
-
updateModifiedAttributes
public void updateModifiedAttributes() -
atMovementRadius
public final boolean atMovementRadius()Checks if the entity has reached a set radius- Returns:
trueif 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-trueif entity's path is random
-
usesRandomPath
protected boolean usesRandomPath()Determines whether the entity is using a random path.- Returns:
trueif the entity uses random paths, otherwisefalse
-
setRetracePath().