Package horizons :: Package util :: Package pathfinding :: Module pather :: Class AbstractPather
[hide private]
[frames] | no frames]

Class AbstractPather

source code

Abstract Interface for pathfinding for use by Unit. Use only subclasses!

Instance Methods [hide private]
 
__init__(self, unit, move_diagonal, session, make_target_walkable=True) source code
 
unit(self) source code
 
_get_path_nodes(self)
Returns nodes, where unit can walk on.
source code
 
_get_blocked_coords(self)
Returns blocked coordinates Return value type must be supported by FindPath
source code
 
_check_for_obstacles(self, point)
Check if the path is unexpectedly blocked by e.g.
source code
 
_get_position(self)
Returns current position considering movement status and being in a building
source code
 
calc_path(self, destination, destination_in_building=False, check_only=False, source=None)
Calculates a path to destination
source code
 
move_on_path(self, path, source=None, destination_in_building=False)
Start moving on a precalculated path.
source code
 
get_next_step(self)
Returns the next step in the current movement
source code
 
get_move_source(self)
Returns the source Point of the current movement.
source code
 
get_move_target(self)
Returns the point where the path leads
source code
 
end_move(self)
Pretends that the path is finished in order to make the unit stop
source code
 
save(self, db, unitid) source code
 
load(self, db, worldid)
Returns: Bool, whether a path was loaded
source code
Class Variables [hide private]
  log = logging.getLogger("world.pathfinding")
Method Details [hide private]

__init__(self, unit, move_diagonal, session, make_target_walkable=True)
(Constructor)

source code 
Parameters:
  • unit - instance of unit, to which the pather belongs
  • move_diagonal - whether the unit may walk diagonally
  • make_target_walkable - whether we should assume, that we can walk on the tiles that make up the target

unit(self)

source code 
Decorators:
  • @property

_get_path_nodes(self)

source code 

Returns nodes, where unit can walk on. Return value type must be supported by FindPath

_check_for_obstacles(self, point)

source code 

Check if the path is unexpectedly blocked by e.g. a unit

Parameters:
  • point - tuple: (x, y)
Returns:
bool, True if path is blocked

calc_path(self, destination, destination_in_building=False, check_only=False, source=None)

source code 

Calculates a path to destination

Parameters:
  • destination - a destination supported by pathfinding
  • destination_in_building - bool, whether destination is in a building. this makes the unit "enter the building"
  • check_only - if True the path isn't saved
  • source - use this as source of movement instead of self.unit.position
Returns:
True iff movement is possible or the path if check_only==True

move_on_path(self, path, source=None, destination_in_building=False)

source code 

Start moving on a precalculated path.

Parameters:
  • path - return value of FindPath()()

get_next_step(self)

source code 

Returns the next step in the current movement

Returns:
Point

get_move_source(self)

source code 

Returns the source Point of the current movement.

Returns:
Point or None if no path has been calculated

get_move_target(self)

source code 

Returns the point where the path leads

Returns:
Point or None if no path has been calculated

load(self, db, worldid)

source code 
Returns:
Bool, whether a path was loaded