]> git.tdb.fi Git - r2c2.git/blob - source/libr2c2/aicontrol.h
b0c53d59ce088becb05c853c708e711bcd6cedad
[r2c2.git] / source / libr2c2 / aicontrol.h
1 #ifndef LIBR2C2_AICONTROL_H_
2 #define LIBR2C2_AICONTROL_H_
3
4 #include <sigc++/trackable.h>
5 #include "trainai.h"
6
7 namespace R2C2 {
8
9 class Train;
10
11 class AIControl: public TrainAI, public sigc::trackable
12 {
13 private:
14         enum State
15         {
16                 NORMAL,
17                 APPROACH,
18                 BLOCKED,
19                 FOLLOW
20         };
21
22         float target_speed;
23         bool reverse;
24         bool pending_reverse;
25         State state;
26         bool need_update;
27
28 public:
29         AIControl(Train &);
30
31         void set_target_speed(float);
32         float get_target_speed() const { return target_speed; }
33         void set_reverse(bool);
34         bool get_reverse() const { return reverse; } 
35
36         virtual void message(const Message &);
37         virtual void tick(const Msp::Time::TimeDelta &);
38
39 private:
40         void event(TrainAI &, const Message &);
41 };
42
43 } // namespace R2C2
44
45 #endif