public class PathfindableModel extends TraitModel implements Pathfindable
The ObjectGame
owner must have the following Trait
:
The ObjectGame
owner must provide a valid Configurer
compatible
with PathfindableConfig
.
The Services
must provide the following services:
If the ObjectGame
is a PathfindableListener
, it will automatically
addListener(PathfindableListener)
on it.
Constructor and Description |
---|
PathfindableModel()
Create a pathfindable model.
|
Modifier and Type | Method and Description |
---|---|
void |
addListener(PathfindableListener listener)
Add a pathfindable listener.
|
void |
clearIgnoredId()
Clear all ignored objects ID.
|
void |
clearSharedPathIds()
Clear the list of objects ID that share the same path.
|
double |
getCost(String category)
Get the cost movement depending of the category.
|
int |
getInTileHeight()
Get the height in tile.
|
int |
getInTileWidth()
Get the width in tile.
|
int |
getInTileX()
Get horizontal tile location.
|
int |
getInTileY()
Get vertical tile location.
|
double |
getMoveX()
Get horizontal current speed.
|
double |
getMoveY()
Get vertical current speed.
|
Orientation |
getOrientation()
Get the current orientation.
|
double |
getSpeedX()
Get horizontal movement speed.
|
double |
getSpeedY()
Get vertical movement speed.
|
boolean |
isBlocking(String category)
Check if the category is considered as blocking.
|
boolean |
isDestinationReached()
Check if has reached destination.
|
boolean |
isIgnoredId(Integer id)
Check if object ID is ignored.
|
boolean |
isMovementAllowed(String category,
MovementTile movement)
Check if movement is allowed for the specified tile.
|
boolean |
isMoving()
Check if currently moving.
|
boolean |
isPathAvailable(int tx,
int ty)
Check if a path exists between object and destination.
|
void |
moveTo(double extrp,
double x,
double y)
Move to specified destination only when calling this function.
|
void |
pointTo(int tx,
int ty)
Adjust orientation to face to specified tile.
|
void |
pointTo(Tiled tiled)
Adjust orientation to face to specified entity.
|
void |
prepare(ObjectGame owner,
Services services)
Prepare the trait.
|
void |
render(Graphic g) |
boolean |
setDestination(int tx,
int ty)
Assign a specified location.
|
boolean |
setDestination(Localizable localizable)
Assign a specified location.
|
boolean |
setDestination(Tiled tiled)
Assign a specified location.
|
void |
setIgnoreId(Integer id,
boolean state)
Ignore an object ID while searching pathfinding.
|
void |
setLocation(int tx,
int ty)
Set specified location in tile.
|
void |
setOrientation(Orientation orientation)
Set the orientation to use.
|
void |
setRenderDebug(boolean debug)
Render additional information on path rendering with
Renderable.render(com.b3dgs.lionengine.graphic.Graphic) . |
void |
setSharedPathIds(Collection<Integer> ids)
Set the object ID list that shares the same path (this can be used in grouped movement).
|
void |
setSpeed(double speedX,
double speedY)
Set movement speed.
|
void |
stopMoves()
Stop any pathfinding movements.
|
void |
update(double extrp) |
getOwner
public void prepare(ObjectGame owner, Services services)
Trait
prepare
in interface Trait
prepare
in class TraitModel
owner
- The owner reference.services
- The services reference.public void addListener(PathfindableListener listener)
Pathfindable
addListener
in interface Pathfindable
listener
- The pathfindable listener to add.public void clearSharedPathIds()
Pathfindable
clearSharedPathIds
in interface Pathfindable
public void clearIgnoredId()
Pathfindable
clearIgnoredId
in interface Pathfindable
public void stopMoves()
Pathfindable
stopMoves
in interface Pathfindable
public void moveTo(double extrp, double x, double y)
Pathfindable
moveTo
in interface Pathfindable
extrp
- The extrapolation value.x
- The destination horizontal location.y
- The destination vertical location.public void pointTo(int tx, int ty)
Orientable
pointTo
in interface Orientable
tx
- The horizontal tile to face.ty
- The vertical tile to face.public void pointTo(Tiled tiled)
Orientable
pointTo
in interface Orientable
tiled
- The tiled to face to.public void render(Graphic g)
render
in interface Renderable
public void setSpeed(double speedX, double speedY)
Pathfindable
setSpeed
in interface Pathfindable
speedX
- The horizontal speed.speedY
- The vertical speed.public void setIgnoreId(Integer id, boolean state)
Pathfindable
setIgnoreId
in interface Pathfindable
id
- The object ID to ignore.state
- true
to ignore, false
else.public void setSharedPathIds(Collection<Integer> ids)
Pathfindable
setSharedPathIds
in interface Pathfindable
ids
- The object ID list to add.public boolean setDestination(Localizable localizable)
Pathfindable
setDestination
in interface Pathfindable
localizable
- The destination location.true
if destination reachable, false
else.public boolean setDestination(Tiled tiled)
Pathfindable
setDestination
in interface Pathfindable
tiled
- The destination location in tile.true
if destination reachable, false
else.public boolean setDestination(int tx, int ty)
Pathfindable
setDestination
in interface Pathfindable
tx
- The horizontal location in tile.ty
- The vertical location in tile.true
if destination reachable, false
else.public void setLocation(int tx, int ty)
Pathfindable
setLocation
in interface Pathfindable
tx
- The horizontal location in tile.ty
- The vertical location in tile.public void setOrientation(Orientation orientation)
Orientable
setOrientation
in interface Orientable
orientation
- The orientation to use.public void setRenderDebug(boolean debug)
Pathfindable
Renderable.render(com.b3dgs.lionengine.graphic.Graphic)
.
(Movement cost for each tile is displayed).setRenderDebug
in interface Pathfindable
debug
- true
to show debug information relative to path, false
else.public double getSpeedX()
Pathfindable
getSpeedX
in interface Pathfindable
public double getSpeedY()
Pathfindable
getSpeedY
in interface Pathfindable
public double getMoveX()
Pathfindable
getMoveX
in interface Pathfindable
public double getMoveY()
Pathfindable
getMoveY
in interface Pathfindable
public Orientation getOrientation()
Orientable
getOrientation
in interface Orientable
public int getInTileX()
Tiled
getInTileX
in interface Tiled
public int getInTileY()
Tiled
getInTileY
in interface Tiled
public int getInTileWidth()
Tiled
getInTileWidth
in interface Tiled
public int getInTileHeight()
Tiled
getInTileHeight
in interface Tiled
public double getCost(String category)
Pathfindable
getCost
in interface Pathfindable
category
- The category the check.public boolean isMovementAllowed(String category, MovementTile movement)
Pathfindable
isMovementAllowed
in interface Pathfindable
category
- The category the check.movement
- The movement to check.true
if movement allowed, false
else.public boolean isPathAvailable(int tx, int ty)
Pathfindable
isPathAvailable
in interface Pathfindable
tx
- The horizontal location in tile.ty
- The vertical location in tile.true
if path exists, false
else.public boolean isBlocking(String category)
Pathfindable
isBlocking
in interface Pathfindable
category
- The category the check.true
if blocking, false
else or category not found.public boolean isDestinationReached()
Pathfindable
isDestinationReached
in interface Pathfindable
true
if destination has been reached, false
else.public boolean isIgnoredId(Integer id)
Pathfindable
isIgnoredId
in interface Pathfindable
id
- The object ID to check.true
if ignored, false
else.public boolean isMoving()
Pathfindable
isMoving
in interface Pathfindable
true
if moving, false
else.Copyright © 2016 Byron 3D Games Studio. All rights reserved.