-
Notifications
You must be signed in to change notification settings - Fork 0
/
vehicles.h
129 lines (72 loc) · 1.85 KB
/
vehicles.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
#ifndef INC_VEHICLES_H
#define INC_VEHICLES_H
#include <list>
#include <vector>
#include "common.h"
#include "path.h"
#include "obstacle.h"
#include "vModels.h"
class city;
class vehicles;
class vehicle {
public :
double speed;
int nr;//vehicle nr(id, which doesn't mean vector index!)
vModel *vM;//vehicle model
double progr;//from road beginning
double targetProgr;//last segment's
int lNr;//lane nr
//double avail;
obstacle obs;
path p;//road
point Destination();//vertex i kuri reikia vaziuoti
point pos;
double k;
void Init(int vNr, city *_c, vehicles *_v, vModel *vModel, int bL[2]);
bool Progress(double time);
void Draw();
private :
city *c;
vehicles *v;
point Direction();
void Drive(double d);
void Brake(double time);
void Accelerate(double time);
int GetRoadLanesNr();
//lists
void AddList();
void RemList();
bool BetterAtLane(int nr);
void ChangeLane(int newLane);
int changingLaneFrom;
double changingLaneProgr;
void UpdatePosition();
void UpdateRotation();
};
class vehicles {
public:
std::vector<vehicle> v;
vModels vM;
void Add(int vMNr, int bL[2]);
void Init(city *ct);
void Clear();
obstacle VehicleObstacle(int nr, int lane = -1);
obstacle VehicleObstacleBehind(int nr, int lane = -1);
void Progress(double time);
void Draw();
int GetVehiclesNr();
//statistics
double AverageSpeed();
double AverageMaxSpeed();
int StoppedVehicles();
private:
city *c;
std::vector<bool> availID;
std::list<int> idL;//list of all available ID's
std::list<int>::iterator GetIDLTo(int to);
obstacle RoadAvail(double start, int from, int to, int lane, bool inFront = 1);
void Remove(int id);
void ReleaseID(int id);
int GetFreeID();
};
#endif