|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcz.cuni.amis.pogamut.ut2004.agent.navigation.UT2004Navigation
public class UT2004Navigation
Facade for navigation in UT2004. Method navigate() can be called both synchronously and asynchronously.
Uses IUT2004PathExecutor
, FloydWarshallMap
, IUT2004RunStraight
and IUT2004GetBackToNavGraph
to handle all possible navigation cases.
Field Summary | |
---|---|
protected static int |
ARRIVED_AT_LOCATION_XY_THRESHOLD
Location threshold for checking whether we have arrived on target. |
protected static int |
ARRIVED_AT_LOCATION_Z_THRESHOLD
Location threshold for checking whether we have arrived on target. |
static double |
AT_PLAYER
We're managed to get to player |
protected UT2004Bot |
bot
UT2004Bot reference. |
protected IWorldEventListener<BotKilled> |
botKilledMessageListener
|
protected ILocated |
continueTo
Where the bot will continue to. |
protected IPathFuture<NavPoint> |
continueToPath
Path to prolong. |
protected IPathFuture |
currentPathFuture
Current path stored in IPathFuture object. |
protected ILocated |
currentTarget
Current location target. |
protected Player |
currentTargetPlayer
Current target is player (if not null) |
protected IWorldEventListener<EndMessage> |
endMessageListener
|
static double |
EXTEND_PATH_THRESHOLD
|
protected double |
extendPathThreshold
From which distance we should use IUT2004PathExecutor.extendPath(List) . |
protected NavPoint |
fromNavPoint
Navpoint we're running from (initial position when path executor has been triggered) |
protected IUT2004GetBackToNavGraph |
getBackToNavGraph
UT2004GetBackToNavGraph for returning bot back to the navigation graph. |
protected ILocated |
lastTarget
Last location target. |
protected Player |
lastTargetPlayer
Last location target. |
protected LogCategory |
log
Log used by this class. |
protected boolean |
navigating
Whether navigation is running. |
protected static int |
NEW_PATH_DISTANCE_THRESHOLD
Location threshold for requesting of a new path or switching a path. |
protected IUT2004PathExecutor<ILocated> |
pathExecutor
UT2004PathExecutor that is used for the navigation. |
protected IPathPlanner<NavPoint> |
pathPlanner
FloydWarshallMap that is used for path planning. |
protected static double |
PLAYER_DISTANCE_TRASHOLD
When PLAYER is further from currentTarget than this location, recompute the path |
protected boolean |
runningStraightToPlayer
We're running straight to the player. |
protected Location |
runningStraightToPlayerFailedAt
Where run-straight failed. |
protected IUT2004RunStraight |
runStraight
UT2004RunStraight is used to run directly to player at some moment. |
protected cz.cuni.amis.utils.flag.Flag<NavigationState> |
state
State of UT2004Navigation |
protected NavPoint |
toNavPoint
Navpoint we're running to, nearest navpoint to currentTarget |
protected boolean |
usingGetBackToNavGraph
Whether we're using getBackToNavGraph . |
Constructor Summary | |
---|---|
UT2004Navigation(UT2004Bot bot,
AgentInfo info,
AdvancedLocomotion move)
Will auto-create all needed UT2004Navigation subparts. |
|
UT2004Navigation(UT2004Bot bot,
IUT2004PathExecutor ut2004PathExecutor,
IPathPlanner<NavPoint> pathPlanner,
IUT2004GetBackToNavGraph getBackOnPath,
IUT2004RunStraight runStraight)
Here you may specify any custom UT2004Navigation parts. |
|
UT2004Navigation(UT2004Bot bot,
IUT2004PathExecutor ut2004PathExecutor,
IPathPlanner<NavPoint> pathPlanner,
IUT2004GetBackToNavGraph getBackOnPath,
IUT2004RunStraight runStraight,
double extendPathThreshold)
Here you may specify any custom UT2004Navigation parts. |
Method Summary | |
---|---|
void |
addStrongNavigationListener(cz.cuni.amis.utils.flag.FlagListener<NavigationState> listener)
Use this to register listeners to various states the navigation - stuck, target reached, etc. |
IUT2004GetBackToNavGraph |
getBackToNavGraph()
Returns underlying IUT2004GetBackToNavGraph object that is being used by this IUT2004Navigation . |
ILocated |
getContinueTo()
Returns where the bot will continue to, for more info see IUT2004Navigation.setContinueTo(ILocated) . |
List<ILocated> |
getCurrentPathCopy()
Returns COPY of current path in list. |
List<ILocated> |
getCurrentPathDirect()
Returns current path as in IPathFuture object that is used by ut2004pathExecutor to navigate. |
ILocated |
getCurrentTarget()
Current POINT where the navigation is trying to get to. |
Item |
getCurrentTargetItem()
If navigation is trying to get to some item, otherwise returns null. |
NavPoint |
getCurrentTargetNavPoint()
If navigation is trying to get to some navpoint, otherwise returns null. |
Player |
getCurrentTargetPlayer()
If navigation is trying to get to some player, otherwise returns null. |
ILocated |
getLastTarget()
Returns previous location we tried to get to (i.e., what was getCurrentTarget() before
another navigate(ILocated) or navigate(Player) was called. |
Item |
getLastTargetItem()
If previous target was an item, returns non-null Item we previously tried to get to. |
Player |
getLastTargetPlayer()
If previous target was a player, returns non-null player we previously tried to get to (i.e., what was getCurrentTargetPlayer() before
another navigate(ILocated) or navigate(Player) was called. |
Logger |
getLog()
Returns logger used by the object. |
NavPoint |
getNearestNavPoint(ILocated location)
Returns nearest navigation point to input location. |
IUT2004PathExecutor<ILocated> |
getPathExecutor()
Returns underlying IUT2004PathExecutor object that is being used by this IUT2004Navigation . |
double |
getRemainingDistance()
Returns how far is our target (path-distance == real-distance). |
IUT2004RunStraight |
getRunStraight()
Returns underlying IUT2004RunStraight object that is being used by this IUT2004Navigation . |
cz.cuni.amis.utils.flag.Flag<NavigationState> |
getState()
Returns an immutable flag with the current state of the navigation. |
boolean |
isNavigating()
True if navigating, e.g., trying to get somewhere using either IUT2004PathExecutor , IUT2004GetBackToNavGraph or IUT2004RunStraight . |
boolean |
isNavigatingToItem()
Whether we're currently navigating to item (final target). |
boolean |
isNavigatingToNavPoint()
Whether we're currently navigating to navpoint (final target). |
boolean |
isNavigatingToPlayer()
Whether we're currently navigating to player (final target). |
boolean |
isPathExecuting()
Whether UT2004Navigation is currently using IUT2004PathExecutor to follow the path. |
boolean |
isRunningStraight()
Whether UT2004Navigation is currently using runStraight to get to player by running straight to it/him/her. |
boolean |
isTryingToGetBackToNav()
Whether UT2004Navigation is currently trying to get back to nav using IUT2004GetBackToNavGraph . |
protected void |
navigate()
|
void |
navigate(ILocated target)
This method can be called periodically or asynchronously. |
void |
navigate(IPathFuture<ILocated> pathHandle)
Let the bot to follow this path. |
void |
navigate(Player player)
This method can be called periodically or asynchronously. |
protected void |
noPath()
|
protected boolean |
processPathFuture(IPathFuture futurePath,
ILocated currentTarget)
Checks if last path element is in close distance from our desired target and if not, we will add our desired target as the last path element. |
void |
removeStrongNavigationListener(cz.cuni.amis.utils.flag.FlagListener<NavigationState> listener)
Removes path state listener. |
protected void |
reset(boolean stopGetBackToNavGraph,
NavigationState resultState)
|
void |
setContinueTo(ILocated continueTo)
When the bot is about to reach its target, it will prolong his path to continue to 'target'. |
void |
setFocus(ILocated located)
Sets focus of the bot when navigating (when using this object to run to some location target)! To reset focus call this method with null parameter. |
void |
stopNavigation()
Stops navigation and resets the class. |
protected void |
stuck()
|
protected void |
switchState(NavigationState newState)
|
protected void |
targetReached()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static double EXTEND_PATH_THRESHOLD
protected LogCategory log
protected IUT2004PathExecutor<ILocated> pathExecutor
protected IPathPlanner<NavPoint> pathPlanner
protected UT2004Bot bot
protected IUT2004GetBackToNavGraph getBackToNavGraph
protected IUT2004RunStraight runStraight
protected double extendPathThreshold
IUT2004PathExecutor.extendPath(List)
.
protected static final int NEW_PATH_DISTANCE_THRESHOLD
protected static final int ARRIVED_AT_LOCATION_XY_THRESHOLD
protected static final int ARRIVED_AT_LOCATION_Z_THRESHOLD
protected static final double PLAYER_DISTANCE_TRASHOLD
public static final double AT_PLAYER
protected cz.cuni.amis.utils.flag.Flag<NavigationState> state
protected IWorldEventListener<EndMessage> endMessageListener
protected IWorldEventListener<BotKilled> botKilledMessageListener
protected ILocated lastTarget
protected Player lastTargetPlayer
protected ILocated currentTarget
protected Player currentTargetPlayer
protected NavPoint fromNavPoint
protected NavPoint toNavPoint
protected IPathFuture currentPathFuture
protected boolean navigating
protected boolean runningStraightToPlayer
protected Location runningStraightToPlayerFailedAt
protected boolean usingGetBackToNavGraph
getBackToNavGraph
.
protected ILocated continueTo
protected IPathFuture<NavPoint> continueToPath
Constructor Detail |
---|
public UT2004Navigation(UT2004Bot bot, IUT2004PathExecutor ut2004PathExecutor, IPathPlanner<NavPoint> pathPlanner, IUT2004GetBackToNavGraph getBackOnPath, IUT2004RunStraight runStraight)
bot
- ut2004PathExecutor
- pathPlanner
- getBackOnPath
- runStraight
- public UT2004Navigation(UT2004Bot bot, IUT2004PathExecutor ut2004PathExecutor, IPathPlanner<NavPoint> pathPlanner, IUT2004GetBackToNavGraph getBackOnPath, IUT2004RunStraight runStraight, double extendPathThreshold)
bot
- ut2004PathExecutor
- pathPlanner
- getBackOnPath
- runStraight
- public UT2004Navigation(UT2004Bot bot, AgentInfo info, AdvancedLocomotion move)
bot
- info
- move
- Method Detail |
---|
public Logger getLog()
IUT2004Navigation
getLog
in interface IUT2004Navigation
public void addStrongNavigationListener(cz.cuni.amis.utils.flag.FlagListener<NavigationState> listener)
IUT2004Navigation
NavigationState
.
addStrongNavigationListener
in interface IUT2004Navigation
public void removeStrongNavigationListener(cz.cuni.amis.utils.flag.FlagListener<NavigationState> listener)
IUT2004Navigation
removeStrongNavigationListener
in interface IUT2004Navigation
public IUT2004PathExecutor<ILocated> getPathExecutor()
IUT2004Navigation
IUT2004PathExecutor
object that is being used by this IUT2004Navigation
.
getPathExecutor
in interface IUT2004Navigation
public IUT2004GetBackToNavGraph getBackToNavGraph()
IUT2004Navigation
IUT2004GetBackToNavGraph
object that is being used by this IUT2004Navigation
.
getBackToNavGraph
in interface IUT2004Navigation
public IUT2004RunStraight getRunStraight()
IUT2004Navigation
IUT2004RunStraight
object that is being used by this IUT2004Navigation
.
getRunStraight
in interface IUT2004Navigation
public boolean isNavigating()
IUT2004Navigation
IUT2004PathExecutor
, IUT2004GetBackToNavGraph
or IUT2004RunStraight
.
isNavigating
in interface IUT2004Navigation
public boolean isNavigatingToNavPoint()
IUT2004Navigation
isNavigatingToNavPoint
in interface IUT2004Navigation
public boolean isNavigatingToItem()
IUT2004Navigation
isNavigatingToItem
in interface IUT2004Navigation
public boolean isNavigatingToPlayer()
IUT2004Navigation
isNavigatingToPlayer
in interface IUT2004Navigation
public boolean isTryingToGetBackToNav()
IUT2004Navigation
UT2004Navigation
is currently trying to get back to nav using IUT2004GetBackToNavGraph
.
isTryingToGetBackToNav
in interface IUT2004Navigation
public boolean isPathExecuting()
IUT2004Navigation
UT2004Navigation
is currently using IUT2004PathExecutor
to follow the path.
isPathExecuting
in interface IUT2004Navigation
public boolean isRunningStraight()
IUT2004Navigation
UT2004Navigation
is currently using runStraight
to get to player by running straight to it/him/her.
isRunningStraight
in interface IUT2004Navigation
public void setFocus(ILocated located)
IUT2004Navigation
setFocus
in interface IUT2004Navigation
public void stopNavigation()
IUT2004Navigation
stopNavigation
in interface IUT2004Navigation
public void navigate(ILocated target)
IUT2004Navigation
navigate
in interface IUT2004Navigation
target
- target locationpublic void navigate(Player player)
IUT2004Navigation
navigate
in interface IUT2004Navigation
public void navigate(IPathFuture<ILocated> pathHandle)
IUT2004Navigation
navigate
in interface IUT2004Navigation
public NavPoint getNearestNavPoint(ILocated location)
IUT2004Navigation
getNearestNavPoint
in interface IUT2004Navigation
public ILocated getContinueTo()
IUT2004Navigation
IUT2004Navigation.setContinueTo(ILocated)
.
WARNING: continueTo is reset when bot stop navigating / stuck, etc.
WARNING: continueTo is also "nullified" when the bot actually prolongs its path to reach the 'target'.
getContinueTo
in interface IUT2004Navigation
public void setContinueTo(ILocated continueTo)
IUT2004Navigation
IUT2004Navigation.navigate(Player)
.
WARNING: continueTo is reset when bot stop navigating / stuck, etc.
WARNING: continueTo is also "nullified" when the bot actually prolongs its path to reach the 'target'.
setContinueTo
in interface IUT2004Navigation
continueTo
- cannot be Player
public List<ILocated> getCurrentPathCopy()
IUT2004Navigation
getCurrentPathCopy
in interface IUT2004Navigation
public List<ILocated> getCurrentPathDirect()
IUT2004Navigation
getCurrentPathDirect
in interface IUT2004Navigation
public ILocated getCurrentTarget()
IUT2004Navigation
getCurrentTarget
in interface IUT2004Navigation
public Player getCurrentTargetPlayer()
IUT2004Navigation
getCurrentTargetPlayer
in interface IUT2004Navigation
public Item getCurrentTargetItem()
IUT2004Navigation
getCurrentTargetItem
in interface IUT2004Navigation
public NavPoint getCurrentTargetNavPoint()
IUT2004Navigation
getCurrentTargetNavPoint
in interface IUT2004Navigation
public ILocated getLastTarget()
IUT2004Navigation
getCurrentTarget()
before
another navigate(ILocated)
or navigate(Player)
was called.
getLastTarget
in interface IUT2004Navigation
public Player getLastTargetPlayer()
IUT2004Navigation
getCurrentTargetPlayer()
before
another navigate(ILocated)
or navigate(Player)
was called.
getLastTargetPlayer
in interface IUT2004Navigation
public Item getLastTargetItem()
IUT2004Navigation
Item
we previously tried to get to.
(i.e., what was getCurrentTargetItem()
before
another navigate(ILocated)
or navigate(Player)
was called.
getLastTargetItem
in interface IUT2004Navigation
public double getRemainingDistance()
IUT2004Navigation
getRemainingDistance
in interface IUT2004Navigation
protected void navigate()
protected boolean processPathFuture(IPathFuture futurePath, ILocated currentTarget)
futurePath
- protected void switchState(NavigationState newState)
protected void noPath()
protected void stuck()
protected void targetReached()
protected void reset(boolean stopGetBackToNavGraph, NavigationState resultState)
public cz.cuni.amis.utils.flag.Flag<NavigationState> getState()
IUT2004Navigation
getState
in interface IUT2004Navigation
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |