]> git.tdb.fi Git - r2c2.git/blob - source/libr2c2/aicontrol.h
Make AIControl states clearer
[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 void set_control(const std::string &, float);
39         virtual const Control &get_control(const std::string &) const;
40
41         virtual float get_speed() const;
42         virtual bool get_reverse() const;
43         virtual float get_braking_distance() const;
44
45         virtual void tick(const Msp::Time::TimeDelta &);
46
47 private:
48         void control_changed(const Control &);
49         void arrived();
50 };
51
52 } // namespace R2C2
53
54 #endif