]> git.tdb.fi Git - r2c2.git/blob - source/libr2c2/aicontrol.h
01429cdd01581481918eefe10e1d22abd6d90c0e
[r2c2.git] / source / libr2c2 / aicontrol.h
1 /* $Id$
2
3 This file is part of R²C²
4 Copyright © 2010-2011  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 "trainai.h"
13
14 namespace R2C2 {
15
16 class Train;
17
18 class AIControl: public TrainAI, public sigc::trackable
19 {
20 private:
21         enum State
22         {
23                 NORMAL,
24                 APPROACH,
25                 BLOCKED,
26                 FOLLOW
27         };
28
29         float target_speed;
30         bool reverse;
31         bool pending_reverse;
32         State state;
33         bool need_update;
34
35 public:
36         AIControl(Train &);
37
38         void set_target_speed(float);
39         float get_target_speed() const { return target_speed; }
40         void set_reverse(bool);
41         bool get_reverse() const { return reverse; } 
42
43         virtual void message(const Message &);
44         virtual void tick(const Msp::Time::TimeStamp &, const Msp::Time::TimeDelta &);
45
46 private:
47         void arrived();
48 };
49
50 } // namespace R2C2
51
52 #endif