3 This file is part of R²C²
4 Copyright © 2010 Mikkosoft Productions, Mikko Rasa
5 Distributed under the GPL
8 #ifndef LIBR2C2_VEHICLE_H_
9 #define LIBR2C2_VEHICLE_H_
12 #include "vehicletype.h"
33 const VehicleType::Axle *type;
36 Axle(const VehicleType::Axle &);
41 const VehicleType::Bogie *type;
43 std::vector<Axle> axles;
45 Bogie(const VehicleType::Bogie &);
50 const VehicleType::Rod *type;
54 Rod(const VehicleType::Rod &);
65 TrackPosition(Track *, unsigned, float);
67 TrackPoint get_point() const;
71 const VehicleType &type;
74 TrackPosition track_pos;
77 std::vector<Axle> axles;
78 std::vector<Bogie> bogies;
79 std::vector<Rod> rods;
80 unsigned front_sensor;
84 Vehicle(Layout &, const VehicleType &);
87 const VehicleType &get_type() const { return type; }
89 void attach_back(Vehicle &);
90 void attach_front(Vehicle &);
93 Vehicle *get_next() const { return next; }
94 Vehicle *get_previous() const { return prev; }
96 void place(Track &, unsigned, float, PlaceMode = CENTER);
99 Track *get_track() const { return track_pos.track; }
100 unsigned get_entry() const { return track_pos.ep; }
101 float get_offset() const { return track_pos.offs; }
102 const Vector &get_position() const { return position; }
103 float get_direction() const { return direction; }
104 const Axle &get_axle(unsigned) const;
105 const Bogie &get_bogie(unsigned) const;
106 const Axle &get_bogie_axle(unsigned, unsigned) const;
107 const Rod &get_rod(unsigned) const;
109 void update_position();
110 void update_position_from(const Vehicle &);
111 void propagate_position();
112 void propagate_forward();
113 void propagate_backward();
114 void check_sensor(float, unsigned &);
115 void turn_axles(float);
118 void adjust_for_distance(TrackPosition &, TrackPosition &, float, float = 0.5) const;
119 TrackPoint get_point(const Vector &, const Vector &, float = 0.5) const;
120 TrackPoint get_point(const TrackPosition &, float, float = 0.5) const;