]> git.tdb.fi Git - r2c2.git/blob - source/libr2c2/aicontrol.h
Add control enumeration to Controller
[r2c2.git] / source / libr2c2 / aicontrol.h
1 /* $Id$
2
3 This file is part of R²C²
4 Copyright © 2010  Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
6 */
7
8 #ifndef LIBR2C2_AICONTROL_H_
9 #define LIBR2C2_AICONTROL_H_
10
11 #include <sigc++/trackable.h>
12 #include "controller.h"
13
14 namespace R2C2 {
15
16 class Train;
17
18 class AIControl: public Controller, public sigc::trackable
19 {
20 private:
21         enum State
22         {
23                 NORMAL,
24                 APPROACH,
25                 BLOCKED,
26                 FOLLOW
27         };
28
29         Train &train;
30         Controller *next_ctrl;
31         Control target_speed;
32         State state;
33
34 public:
35         AIControl(Train &, Controller *);
36         virtual ~AIControl();
37
38         virtual const char *enumerate_controls(unsigned) const;
39         virtual void set_control(const std::string &, float);
40         virtual const Control &get_control(const std::string &) const;
41
42         virtual float get_speed() const;
43         virtual bool get_reverse() const;
44         virtual float get_braking_distance() const;
45
46         virtual void tick(const Msp::Time::TimeDelta &);
47
48 private:
49         void control_changed(const Control &);
50         void arrived();
51 };
52
53 } // namespace R2C2
54
55 #endif