Dragonfly 4.20
A text-based game engine
PathManager.h
1///
2/// PathManager.h
3///
4/// Manage pathfinding for all Objects.
5///
6
7#ifndef __PATH_MANAGER_H__
8#define __PATH_MANAGER_H__
9
10// System includes.
11#include <string>
12#include <vector>
13
14// Engine includes.
15#include "Manager.h"
16#include "PathFind.h"
17
18// Two-letter acronym for easier access to manager.
19#define PM df::PathManager::getInstance()
20
21namespace df {
22
23class PathManager : public Manager {
24
25 private:
26 PathManager(); ///< Private since a singleton.
27 PathManager(PathManager const&); ///< Don't allow copy.
28 void operator=(PathManager const&); ///< Don't allow assignment.
29 std::vector<PathFind *> m_finder; ///< PathFind's registered.
30 int m_min_cycle_time; ///< Min pathfinding time, in millisec.
31
32 public:
33
34 /// Get the one and only instance of the PathManager.
36
37 /// Start up PathManager.
38 /// Set min cycle time default to 1/10 frame time.
39 int startUp() override;
40
41 /// Shut down PathManager.
42 void shutDown() override;
43
44 /// Register PathFind with PathManager.
45 /// Return 0 if ok, else -1.
46 int registerPathFind(PathFind *p_path_find);
47
48 /// Unregister PathFind with PathManager.
49 /// Return 0 if ok, else -1.
50 int unregisterPathFind(PathFind *p_path_find);
51
52 /// Set minimum cycle time (minimum game loop time spent pathfinding).
53 void setMinCycleTime(int new_min_cycle_time);
54
55 /// Get minimum cycle time (minimum game loop time spent pathfinding).
56 int getMinCycleTime() const;
57
58 /// Return number of PathFind-ers.
59 int getPathFinders() const;
60
61 /// Cycle through registered PathFinders.
62 /// Spend at least min_cycle time, but no more than max_cycle_time.
63 void cycle(int max_cycle_time=-1);
64};
65
66} // end of namespace df
67
68#endif // __PATH_MANAGER_H__
Definition: Manager.h:24
Definition: PathFind.h:31
Definition: PathManager.h:23
int startUp() override
Start up PathManager.
PathManager()
Private since a singleton.
static PathManager & getInstance()
Get the one and only instance of the PathManager.
std::vector< PathFind * > m_finder
PathFind's registered.
Definition: PathManager.h:29
int registerPathFind(PathFind *p_path_find)
Register PathFind with PathManager.
void setMinCycleTime(int new_min_cycle_time)
Set minimum cycle time (minimum game loop time spent pathfinding).
int getMinCycleTime() const
Get minimum cycle time (minimum game loop time spent pathfinding).
void cycle(int max_cycle_time=-1)
Cycle through registered PathFinders.
int getPathFinders() const
Return number of PathFind-ers.
PathManager(PathManager const &)
Don't allow copy.
int m_min_cycle_time
Min pathfinding time, in millisec.
Definition: PathManager.h:30
int unregisterPathFind(PathFind *p_path_find)
Unregister PathFind with PathManager.
void operator=(PathManager const &)
Don't allow assignment.
void shutDown() override
Shut down PathManager.
An animation for a sprite.
Definition: Animation.h:15