Class EntityNavigator
java.lang.Object
de.gurkenlabs.litiengine.entities.behavior.EntityNavigator
- All Implemented Interfaces:
IRenderable,IUpdateable
The EntityNavigator class is responsible for navigating an entity along a path. It implements the IUpdateable and IRenderable interfaces.
-
Constructor Summary
ConstructorsConstructorDescriptionEntityNavigator(IMobileEntity entity) Instantiates a new entity navigator without a pre-initialized PathFinder.EntityNavigator(IMobileEntity entity, PathFinder pathFinder) Constructs an EntityNavigator with a specified entity and path finder. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddNavigationListener(NavigationListener listener) Adds a navigation listener to this EntityNavigator.voidcancelNavigation(Predicate<IMobileEntity> predicate) Adds a condition to cancel the navigation if the specified predicate evaluates to true.floatGets the acceptable error for navigation.Gets the entity being navigated.getPath()Gets the current path for navigation.Gets the path finder used for navigation.booleanChecks if the entity is currently navigating.booleanSets the current path for navigation.booleanFinds and sets a path to the specified target point.voidremoveNavigationListener(NavigationListener listener) Removes a navigation listener from this EntityNavigator.voidrender(Graphics2D g) Renders the visual contents of this instance onto the provided graphics context.voidrotateTowards(Point2D target) Rotates the entity towards the specified target point.voidsetAcceptableError(float acceptableError) Sets the acceptable error for navigation.voidstop()Stops the navigation and resets the current segment and path.voidupdate()This method is called by the game loop on all objects that are attached to the loop.
-
Constructor Details
-
EntityNavigator
Constructs an EntityNavigator with a specified entity and path finder.- Parameters:
entity- the entity that will be navigated by this instancepathFinder- the path finder used to find paths for navigation
-
EntityNavigator
Instantiates a new entity navigator without a pre-initialized PathFinder.- Parameters:
entity- The entity that will be navigated by this instance
-
-
Method Details
-
getEntity
Gets the entity being navigated.- Returns:
- the entity being navigated
-
getPath
Gets the current path for navigation.- Returns:
- the current path, or null if no path is set
-
getPathFinder
Gets the path finder used for navigation.- Returns:
- the path finder, or null if no path finder is set
-
getAcceptableError
public float getAcceptableError()Gets the acceptable error for navigation.- Returns:
- the acceptable error
-
render
Description copied from interface:IRenderableRenders the visual contents of this instance onto the provided graphics context.If an
Entityimplements this interface, this method will be called right after the entity was rendered from the environment. Allowing for a custom rendering mechanism.This interface can be implemented in general by anything that should be rendered to the game's screen.
- Specified by:
renderin interfaceIRenderable- Parameters:
g- The current graphics object onto which this instance will render its visual contents.- See Also:
-
rotateTowards
Rotates the entity towards the specified target point.- Parameters:
target- the target point to rotate towards
-
setAcceptableError
public void setAcceptableError(float acceptableError) Sets the acceptable error for navigation.- Parameters:
acceptableError- the acceptable error to set
-
stop
public void stop()Stops the navigation and resets the current segment and path. -
update
public void update()Description copied from interface:IUpdateableThis method is called by the game loop on all objects that are attached to the loop. It's called on every tick of the loop and the frequency can be configured using theClientConfiguration.- Specified by:
updatein interfaceIUpdateable- See Also: