summaryrefslogtreecommitdiff
path: root/game/vehicles/vehicle.h
blob: bbfa6eaf86e0081e18399b16a997f4fb706b751f (plain)
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
#ifndef VEHICLE_H
#define VEHICLE_H

#include <game/network/link.h>
#include <game/worldobject.h>
#include <gfx/renderable.h>
#include <memory>
#include <string>
#include <utility>
#include <vector>

class LinkHistory {
public:
	using WEntry = std::pair<LinkWPtr, unsigned char /*dir*/>;
	using Entry = std::pair<LinkCPtr, unsigned char /*dir*/>;
	Entry add(const LinkWPtr &, unsigned char);
	[[nodiscard]] Entry getCurrent() const;
	[[nodiscard]] Entry getAt(float, float *) const;

private:
	std::vector<WEntry> links;
	float totalLen {0.F};
};

class Vehicle : public WorldObject, public Renderable {
public:
	explicit Vehicle(const LinkPtr & link, float linkDist = 0);
	float linkDist; // distance long current link
	float speed {50}; // speed in m/s (~75 km/h)

	Transform location;

protected:
	LinkHistory linkHist;
};
using VehicleWPtr = std::weak_ptr<Vehicle>;

#endif