Roguelike
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
timemanager.h
Go to the documentation of this file.
1 #ifndef ROGUELIKE_ACTION_TIME_TIMEMANAGER_H_
2 #define ROGUELIKE_ACTION_TIME_TIMEMANAGER_H_
3 
4 // Inheritance
5 #include <ugdk/action/task.h>
6 
7 // External Dependencies
8 #include <map>
9 #include <vector>
10 
11 // Internal Dependencies
13 #include "game/base/gameobject.h"
14 #include "game/component/energy.h"
15 
16 // Forward Declarations
17 #include "game/base.h"
18 
19 namespace game {
20 namespace action {
21 namespace time {
22 
23 typedef std::set< base::GameObject*, bool (*)(const base::GameObject*, const base::GameObject*) > ObjectQueue;
24 
25 class TimeManager : public ugdk::action::Task {
26  typedef ugdk::action::Task super;
27  struct SortStructure {
28  TimeManager* manager_;
29  SortStructure(TimeManager* manager) { manager_ = manager; };
30 
32  if (manager_->actors_time_[a] < manager_->actors_time_[b] )
33  return true;
34  else if (manager_->actors_time_[a] > manager_->actors_time_[b])
35  return false;
36  else {
37  double mean_a = a->energy_component()->Mean();
38  double mean_b = b->energy_component()->Mean();
39  return mean_a > mean_b || ( mean_a == mean_b && a < b );
40  }
41  }
42  };
43 
44  public:
45  TimeManager() : current_tick_(0) {}
48 
49  void operator()(double dt);
50 
51  private:
52  int current_tick_;
53  void time_has_passed(const TimeElapsed& time);
54  std::map<base::GameObject*, int> actors_time_;
55  std::vector<base::GameObject*> actors_;
56 
57  // ObjectQueue& actors_;
58 };
59 
60 } // namespace time
61 } // namespace action
62 } // namespace game
63 
64 #endif /* ROGUELIKE_ACTION_TIME_TIMEMANAGER_H_ */
Definition: gameobject.h:53
~TimeManager()
Definition: timemanager.h:46
std::set< base::GameObject *, bool(*)(const base::GameObject *, const base::GameObject *) > ObjectQueue
Definition: timemanager.h:23
Definition: aim.cc:15
Definition: timeelapsed.h:20
Definition: timemanager.h:25
void operator()(double dt)
Definition: timemanager.cc:30
bool CompareFunction(base::GameObject *a, base::GameObject *b)
TimeManager()
Definition: timemanager.h:45