blob: 874db46105d6d654424a7b13b0d3eeaf7fb6c4bf (
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
|
#include "train.h"
#include "game/vehicles/linkHistory.h"
#include "game/vehicles/railVehicle.h"
#include "game/vehicles/railVehicleClass.h"
#include "gfx/renderable.h"
#include "location.hpp"
#include <algorithm>
#include <functional>
#include <utility>
void
Train::render(const Shader & shader) const
{
apply(&Renderable::render, shader);
}
Location
Train::getBogiePosition(float linkDist, float dist) const
{
float b2linkDist {};
const auto b2Link = linkHist.getAt(dist - linkDist, &b2linkDist);
return b2Link.first->positionAt(b2linkDist, b2Link.second);
}
void
Train::tick(TickDuration dur)
{
currentActivity->apply(this, dur);
move(dur);
float trailBy {0.F};
apply(&RailVehicle::move, this, std::ref(trailBy));
}
void
Train::doActivity(Go *, TickDuration dur)
{
const auto maxSpeed = objects.front()->rvClass->maxSpeed;
if (speed != maxSpeed) {
speed += ((maxSpeed - speed) * dur.count());
}
}
void
Train::doActivity(Idle *, TickDuration dur)
{
if (speed != 0.F) {
speed -= std::min(speed, 30.F * dur.count());
}
}
|