Mercurial > fife-parpg
comparison engine/core/model/metamodel/abstractpather.h @ 0:4a0efb7baf70
* Datasets becomes the new trunk and retires after that :-)
author | mvbarracuda@33b003aa-7bff-0310-803a-e67f0ece8222 |
---|---|
date | Sun, 29 Jun 2008 18:44:17 +0000 |
parents | |
children | 90005975cdbb |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:4a0efb7baf70 |
---|---|
1 /*************************************************************************** | |
2 * Copyright (C) 2005-2008 by the FIFE team * | |
3 * http://www.fifengine.de * | |
4 * This file is part of FIFE. * | |
5 * * | |
6 * FIFE is free software; you can redistribute it and/or modify * | |
7 * it under the terms of the GNU General Public License as published by * | |
8 * the Free Software Foundation; either version 2 of the License, or * | |
9 * (at your option) any later version. * | |
10 * * | |
11 * This program is distributed in the hope that it will be useful, * | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of * | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * | |
14 * GNU General Public License for more details. * | |
15 * * | |
16 * You should have received a copy of the GNU General Public License * | |
17 * along with this program; if not, write to the * | |
18 * Free Software Foundation, Inc., * | |
19 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA * | |
20 ***************************************************************************/ | |
21 | |
22 #ifndef FIFE_MODEL_ABSTRACTPATHER_H | |
23 #define FIFE_MODEL_ABSTRACTPATHER_H | |
24 | |
25 // Standard C++ library includes | |
26 #include <string> | |
27 | |
28 // 3rd party library includes | |
29 | |
30 // FIFE includes | |
31 // These includes are split up in two parts, separated by one empty line | |
32 // First block: files included from the FIFE root src directory | |
33 // Second block: files included from the same folder | |
34 | |
35 namespace FIFE { | |
36 class Map; | |
37 class Location; | |
38 class Instance; | |
39 | |
40 enum | |
41 { | |
42 HIGH_PRIORITY, | |
43 MEDIUM_PRIORITY, | |
44 LOW_PRIORITY | |
45 }; | |
46 | |
47 class AbstractPather { | |
48 public: | |
49 virtual ~AbstractPather() {}; | |
50 | |
51 /** Gets next location from pathfinder | |
52 * Model will call this function periodically when instances should | |
53 * move on map. Pather must return next location where instance should be moved. | |
54 * Pather must be able to store multiple sessions for multiple simultaneous searches | |
55 * (coming from multiple instances) | |
56 * | |
57 * @param instance Instance making the call | |
58 * @param target Target of the movement. This must be always on same layer as curpos | |
59 * @param distance_to_travel Distance how far caller can travel (in layer units) | |
60 * @param nextLocation next location returned by the pather | |
61 * @param facingLocation next facing location returned by the pather | |
62 * @param session_id pather can do pathfinding in increments. | |
63 * Further increments are bind to previous ones with given session_id | |
64 * @param priority The priority to assign to search (high are pushed to the front of the queue). | |
65 * @return session_id to use with further calls | |
66 */ | |
67 virtual int getNextLocation(const Instance* instance, const Location& target, | |
68 double distance_to_travel, Location& nextLocation, | |
69 Location& facingLocation, int session_id=-1, | |
70 int priority = MEDIUM_PRIORITY) = 0; | |
71 | |
72 /** Updates the pather (should it need updating). | |
73 * | |
74 * The update method is called by the model. Pathfinders which require per loop updating | |
75 * (in the case of pathfinders which implement A* for instance) should use this method | |
76 * as an oppurtunity to update the search. Generally the method should be constrained to | |
77 * a maximum amount of search updating to prevent this method from stalling the application. | |
78 */ | |
79 virtual void update() = 0; | |
80 | |
81 /** Cancels a given session. | |
82 * | |
83 * This function is called when (for instance) the user changes their mind about | |
84 * a destination while the agent is already moving, the old session needs to be | |
85 * cancelled and a new one created. | |
86 * | |
87 * @param session_id The id of the session to cancel. | |
88 * @return A boolean to signify whether the session was successfully found and cancelled. | |
89 */ | |
90 virtual bool cancelSession(const int session_id) = 0; | |
91 | |
92 /** Gets the name of this pather | |
93 */ | |
94 virtual std::string getName() const = 0; | |
95 }; | |
96 } | |
97 | |
98 #endif |