summaryrefslogtreecommitdiff
path: root/game/vehicles/train.h
blob: c823aed497a2c67cee235a82fe8de4e34cd8f047 (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
39
40
#ifndef TRAIN_H
#define TRAIN_H

#include "chronology.hpp"
#include "game/activities/go.h" // IWYU pragma: keep
#include "game/activities/idle.h" // IWYU pragma: keep
#include "game/activity.h"
#include "game/network/link.h"
#include "railVehicle.h"
#include "vehicle.h"
#include <collection.hpp>
#include <glm/glm.hpp>
#include <location.hpp>
#include <memory>
#include <vector>

class Shader;

class Train : public Vehicle, public Collection<RailVehicle, false>, public Can<Go>, public Can<Idle> {
public:
	explicit Train(const LinkPtr & link, float linkDist = 0) : Vehicle {link, linkDist} { }

	[[nodiscard]] const Location &
	getLocation() const override
	{
		return objects.front()->location;
	}

	void render(const Shader & shader) const override;

	[[nodiscard]] bool intersectRay(const glm::vec3 &, const glm::vec3 &, glm::vec2 *, float *) const override;

	void tick(TickDuration elapsed) override;
	void doActivity(Go *, TickDuration) override;
	void doActivity(Idle *, TickDuration) override;

	[[nodiscard]] Location getBogiePosition(float linkDist, float dist) const;
};

#endif