summaryrefslogtreecommitdiff
path: root/game/network/rail.h
blob: 758beb68de644403cdc58ee20250f9ad7b2e09ac (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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#pragma once

#include "chronology.hpp"
#include "game/worldobject.h"
#include "gfx/models/mesh.h"
#include "gfx/renderable.h"
#include "link.h"
#include "network.h"
#include <glm/glm.hpp>
#include <memory>
#include <span>
#include <special_members.hpp>

class Shader;
class Vertex;
struct Arc;

// A piece of rail track
class RailLink : public virtual Link, public Renderable {
public:
	RailLink() = default;
	inline ~RailLink() override = 0;
	void render(const Shader &) const override;
	NO_COPY(RailLink);
	NO_MOVE(RailLink);

protected:
	[[nodiscard]] glm::vec3 vehiclePositionOffset() const override;
	[[nodiscard]] static MeshPtr defaultMesh(const std::span<Vertex> vertices);

	MeshPtr mesh;
};
RailLink::~RailLink() = default;

class RailLinkStraight : public RailLink, public LinkStraight {
public:
	RailLinkStraight(const NodePtr &, const NodePtr &);

private:
	RailLinkStraight(NodePtr, NodePtr, const glm::vec3 & diff);
};

class RailLinkCurve : public RailLink, public LinkCurve {
public:
	RailLinkCurve(const NodePtr &, const NodePtr &, glm::vec2);

private:
	RailLinkCurve(const NodePtr &, const NodePtr &, glm::vec3, const Arc);
};

class RailLinks : public NetworkOf<RailLink>, public WorldObject {
public:
	RailLinks();

	std::shared_ptr<RailLink> addLinksBetween(glm::vec3 start, glm::vec3 end);

private:
	void tick(TickDuration elapsed) override;
};