|
ORTS
|
A base interface to terrain (path-finding) implementations. More...
#include <TerrainBase.H>
Classes | |
| struct | Goal |
| A movement goal. More... | |
| struct | Loc |
| A terrain location. More... | |
| struct | MoveCmd |
| A low-level move command to be executed. More... | |
| struct | Obj2LocTask |
| Shortcut construction of a "move a single obj to a location target" Task. More... | |
| struct | Obj2ObjTask |
| Shortcut construction of a "move a single obj to an object target" Task. More... | |
| struct | Path |
| A path is a sequence of locations (waypoints) More... | |
| struct | Segment |
| A pair of locations, representing boundaries etc. More... | |
| struct | StatusMsg |
| A task status notification to be sent. More... | |
| struct | Task |
| A pathfinding task to be executed. More... | |
Public Types | |
| typedef const void * | PathId |
| typedef const void * | TaskId |
Public Member Functions | |
| TerrainBase () | |
| TerrainBase (const TerrainBase &other) | |
| virtual | ~TerrainBase () |
| virtual void | init (sint4 tiles_x_, sint4 tiles_y_, sint4 tile_points_, sint4 client_pID_, sint4 neutral_pID_) |
| Set map dimensions. | |
Notifications on world changes | |
| virtual void | add_obj (const Object *obj)=0 |
| virtual void | remove_obj (const Object *obj)=0 |
| virtual void | update_obj (const Object *obj)=0 |
| virtual void | add_segments (const Vector< Segment > &segs)=0 |
Initiate/end pathfinding and execution | |
These methods are expected to return quickly. | |
| virtual TaskId | add_task (const Task &task)=0 |
| virtual void | remove_task (TaskId tid)=0 |
| virtual void | cancel_task (const Object *obj)=0 |
"Do some work" methods | |
| virtual void | execute_tasks (Vector< MoveCmd > &cmds, Vector< StatusMsg > &msgs)=0 |
| Monitor path execution. | |
| virtual bool | plan_tasks (uint4 max_time=0)=0 |
| Plan the paths you're handling. | |
Protected Attributes | |
| sint4 | tiles_x |
| playfield width | |
| sint4 | tiles_y |
| playfield height | |
| sint4 | tile_points |
| points on tile edge on fine grid | |
| sint4 | client_pID |
| ID of the client player. | |
| sint4 | neutral_pID |
| ID of neutral player (eg. sheep) | |
Requests for an immediate planning of a path | |
| enum | ConsiderObjects { CONSIDER_ALL = 0, IGNORE_MOBILE_FRIENDS = 0x001, IGNORE_MOBILE_FOES = 0x010, IGNORE_MOBILE_NEUTRALS = 0x100, IGNORE_ALL_MOBILE_OBJS = IGNORE_MOBILE_FRIENDS | IGNORE_MOBILE_FOES | IGNORE_MOBILE_NEUTRALS } |
Flags that specify what objects to consider as obstacles. More... | |
| virtual real8 | find_path (const Loc &l1, const Loc &l2, sint4 radius, Path *path, ConsiderObjects consider=CONSIDER_ALL)=0 |
| Compute path between l1 and l2 for a circular object. | |
| virtual real8 | find_path (const Object *obj, const Goal &goal, Path *path, ConsiderObjects consider=CONSIDER_ALL)=0 |
| Compute path for a given (circular only) Object with a given Goal,. | |
A base interface to terrain (path-finding) implementations.
This interface detaches path-finding (PF) code from ORTS. A derived implementation is: 1. notified of world changes, including object location/speed changes. 2. requested to handle PF tasks in 3 stages: a. calls to add/remove tasks. b. calls to plan tasks - here the implementation can spend thinking time c. calls to execute_tasks - the implementation should return low-level move commands and arrived/failed messages per path, where relevant.
Definition at line 25 of file TerrainBase.H.
| typedef const void* TerrainBase::PathId |
Definition at line 30 of file TerrainBase.H.
| typedef const void* TerrainBase::TaskId |
Definition at line 31 of file TerrainBase.H.
Flags that specify what objects to consider as obstacles.
Definition at line 265 of file TerrainBase.H.
| TerrainBase::TerrainBase | ( | ) | [inline] |
Definition at line 219 of file TerrainBase.H.
References client_pID, neutral_pID, tile_points, tiles_x, and tiles_y.
| TerrainBase::TerrainBase | ( | const TerrainBase & | other | ) | [inline] |
Definition at line 226 of file TerrainBase.H.
| TerrainBase::~TerrainBase | ( | ) | [virtual] |
Definition at line 6 of file TerrainBase.C.
| virtual void TerrainBase::add_obj | ( | const Object * | obj | ) | [pure virtual] |
Implemented in TRTerrain::TR_Terrain, PathfinderBasicImp, TerrainBasicImp< TaskWrapper >, FFLocPath, SimplePathfinder, SimpleTerrain::ST_Terrain, SimpleTerrain::ST_ForceField, TerrainBasicImp< FF_Task >, TerrainBasicImp< TR_Task >, TerrainBasicImp< PathfindTask >, and TerrainBasicImp< ST_Task >.
Referenced by TerrainModule::notify_timp_on_world_changes().
Implemented in TRTerrain::TR_Terrain, PathfinderBasicImp, TerrainBasicImp< TaskWrapper >, FFLocPath, SimplePathfinder, SimpleTerrain::ST_Terrain, SimpleTerrain::ST_ForceField, TerrainBasicImp< FF_Task >, TerrainBasicImp< TR_Task >, TerrainBasicImp< PathfindTask >, and TerrainBasicImp< ST_Task >.
Referenced by TerrainModule::notify_timp_on_world_changes().
Implemented in TerrainBasicImp< TaskWrapper >, TerrainBasicImp< FF_Task >, TerrainBasicImp< TR_Task >, TerrainBasicImp< PathfindTask >, and TerrainBasicImp< ST_Task >.
Referenced by TerrainModule::handle_event().
| virtual void TerrainBase::cancel_task | ( | const Object * | obj | ) | [pure virtual] |
Implemented in TRTerrain::TR_Terrain, TerrainBasicImp< TaskWrapper >, FFLocPath, SimplePathfinder, SimpleTerrain::ST_Terrain, SimpleTerrain::ST_ForceField, TerrainBasicImp< FF_Task >, TerrainBasicImp< TR_Task >, TerrainBasicImp< PathfindTask >, and TerrainBasicImp< ST_Task >.
Referenced by TerrainModule::handle_event().
| virtual void TerrainBase::execute_tasks | ( | Vector< MoveCmd > & | cmds, |
| Vector< StatusMsg > & | msgs | ||
| ) | [pure virtual] |
Monitor path execution.
Should return move commands and status messages, and is expected to return quickly.
Implemented in TRTerrain::TR_Terrain, PathfinderBasicImp, FFLocPath, SimplePathfinder, SimpleTerrain::ST_Terrain, and SimpleTerrain::ST_ForceField.
Referenced by TerrainModule::act().
| virtual real8 TerrainBase::find_path | ( | const Loc & | l1, |
| const Loc & | l2, | ||
| sint4 | radius, | ||
| Path * | path, | ||
| ConsiderObjects | consider = CONSIDER_ALL |
||
| ) | [pure virtual] |
Compute path between l1 and l2 for a circular object.
| l1 | Start of requested path. |
| l2 | End of requested path. |
| radius | Radius (half width) of the requested path. |
| path | If != NULL, and a path was found, this will contain the it (including l2 but not l1), with the first waypoint in locs[0]. |
| consider | What objects to consider as obstacles when searching for a path. |
Implemented in TRTerrain::TR_Terrain, FFLocPath, SimplePathfinder, SimpleTerrain::ST_Terrain, and SimpleTerrain::ST_ForceField.
| virtual real8 TerrainBase::find_path | ( | const Object * | obj, |
| const Goal & | goal, | ||
| Path * | path, | ||
| ConsiderObjects | consider = CONSIDER_ALL |
||
| ) | [pure virtual] |
Compute path for a given (circular only) Object with a given Goal,.
| obj | The object to move, including the start position and radius. |
| goal | Target of the requested path (location or object etc.). |
| path | If != NULL, and a path was found, this will contain it (including the final but not the start position), with the first waypoint in locs[0]. |
| consider | What objects to consider as obstacles when searching for a path. |
Implemented in TRTerrain::TR_Terrain, FFLocPath, SimplePathfinder, SimpleTerrain::ST_Terrain, and SimpleTerrain::ST_ForceField.
| virtual void TerrainBase::init | ( | sint4 | tiles_x_, |
| sint4 | tiles_y_, | ||
| sint4 | tile_points_, | ||
| sint4 | client_pID_, | ||
| sint4 | neutral_pID_ | ||
| ) | [inline, virtual] |
Set map dimensions.
set playfield dimensions and gives the pathfinder the IDs of the client and the neutral players tiles_x/y : dimensions in tiles tile_points : points on tile edge on fine grid
Reimplemented in TRTerrain::TR_Terrain, FFLocPath, SimplePathfinder, SimpleTerrain::ST_Terrain, and SimpleTerrain::ST_ForceField.
Definition at line 239 of file TerrainBase.H.
References client_pID, neutral_pID, tile_points, tiles_x, and tiles_y.
Referenced by TerrainModule::handle_event().
| virtual bool TerrainBase::plan_tasks | ( | uint4 | max_time = 0 | ) | [pure virtual] |
Plan the paths you're handling.
This is where long thinking should be done. Return true iff did some lengthy processing. Try to use only the specified amount of time (milliseconds) for planning before returning control to the caller. If max_time == 0 then there is no requested time limit.
Implemented in TRTerrain::TR_Terrain, FFLocPath, SimplePathfinder, SimpleTerrain::ST_Terrain, and SimpleTerrain::ST_ForceField.
Referenced by TerrainModule::handle_event().
| virtual void TerrainBase::remove_obj | ( | const Object * | obj | ) | [pure virtual] |
Implemented in TRTerrain::TR_Terrain, PathfinderBasicImp, TerrainBasicImp< TaskWrapper >, FFLocPath, SimplePathfinder, SimpleTerrain::ST_Terrain, SimpleTerrain::ST_ForceField, TerrainBasicImp< FF_Task >, TerrainBasicImp< TR_Task >, TerrainBasicImp< PathfindTask >, and TerrainBasicImp< ST_Task >.
Referenced by TerrainModule::notify_timp_on_world_changes().
| virtual void TerrainBase::remove_task | ( | TaskId | tid | ) | [pure virtual] |
| virtual void TerrainBase::update_obj | ( | const Object * | obj | ) | [pure virtual] |
Implemented in TRTerrain::TR_Terrain, PathfinderBasicImp, TerrainBasicImp< TaskWrapper >, FFLocPath, SimplePathfinder, SimpleTerrain::ST_Terrain, SimpleTerrain::ST_ForceField, TerrainBasicImp< FF_Task >, TerrainBasicImp< TR_Task >, TerrainBasicImp< PathfindTask >, and TerrainBasicImp< ST_Task >.
Referenced by TerrainModule::notify_timp_on_world_changes().
sint4 TerrainBase::client_pID [protected] |
ID of the client player.
Definition at line 335 of file TerrainBase.H.
Referenced by init(), and TerrainBase().
sint4 TerrainBase::neutral_pID [protected] |
ID of neutral player (eg. sheep)
Definition at line 335 of file TerrainBase.H.
Referenced by init(), and TerrainBase().
sint4 TerrainBase::tile_points [protected] |
points on tile edge on fine grid
Definition at line 334 of file TerrainBase.H.
Referenced by SimplePathfinderWidget::draw(), SimplePathfinderOverlay::draw(), init(), and TerrainBase().
sint4 TerrainBase::tiles_x [protected] |
playfield width
Definition at line 332 of file TerrainBase.H.
Referenced by SimplePathfinderWidget::draw(), SimplePathfinderOverlay::draw(), init(), and TerrainBase().
sint4 TerrainBase::tiles_y [protected] |
playfield height
Definition at line 332 of file TerrainBase.H.
Referenced by SimplePathfinderOverlay::draw(), init(), and TerrainBase().