Class FixedPath
java.lang.Object
games.stendhal.server.core.pathfinder.FixedPath
A path using a fixed route.
-
Field Summary
Modifier and TypeFieldDescriptionprotected Node
The current goal node.protected boolean
Whether to loop the path.The path nodes.protected int
The current position.Positions in the entity's path where it will suspend for a determined amount of turns. -
Constructor Summary
-
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.boolean
follow(ActiveEntity entity)
Follow this path.Get the current goal.Get the final destination point.Get the list of nodes that make up the path.Node[]
getNodes()
Get the array of nodes that make up the path.getSuspendDirection(int pos)
Retrieves the direction the entity should face while suspended.getSuspendValue(int pos)
Retrieves the duration of the suspension of the given path position.boolean
Determine if the path has finished.boolean
isLoop()
Determine if the path is an infinite loop.void
removeSuspend(int... pos)
Removes suspension value from path position.boolean
suspendAt(int pos)
Checks if the entity should be suspended at the given path position.toString()
Get the string representation.
-
Field Details
-
currentGoal
The current goal node. -
loop
protected boolean loopWhether to loop the path. -
nodes
The path nodes. -
pos
protected int posThe current position. -
suspensions
Positions in the entity's path where it will suspend for a determined amount of turns.
-
-
Constructor Details
-
FixedPath
Create a fixed path from a list. NOTE: The list is not copied, and should not be modified afterward.- Parameters:
nodes
- A list of nodes to follow.loop
- Whether the path should loop.
-
-
Method Details
-
getCurrentGoal
Get the current goal.- Returns:
- The current goal to reach, or
null
.
-
getNodeList
Get the list of nodes that make up the path. NOTE: The list is not copied, and should not be modified.- Returns:
- The node list.
-
getNodes
Get the array of nodes that make up the path.- Returns:
- The nodes.
-
isLoop
public boolean isLoop()Determine if the path is an infinite loop.- Returns:
true
if the path loops when the last point is reached.
-
follow
Follow this path. This will face the entity into the proper direction to reach it's next path goal.- Parameters:
entity
- The entity to direct along the path.- Returns:
true
if something to follow,false
if complete.
-
getDestination
Get the final destination point.- Returns:
- The destination node, or
null
if there is none (i.e. no path, or unbound/infinite movement).
-
isFinished
public boolean isFinished()Determine if the path has finished.- Returns:
true
if there is no more path to follow.
-
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.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.
-
suspendAt
public boolean suspendAt(int pos)Checks if the entity should be suspended at the given path position.- Parameters:
pos
- Path position to check.- Returns:
true
if the entity should suspend.
-
getSuspendValue
Retrieves the duration of the suspension of the given path position.- Parameters:
pos
- Path position to check.- Returns:
- Duration (in turns) the entity should suspend or
null
.
-
getSuspendDirection
Retrieves the direction the entity should face while suspended.- Parameters:
pos
- Path position to check.- Returns:
- Direction to face or
null
.
-
toString
Get the string representation.
-