diff options
author | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-03-09 01:21:46 +0000 |
---|---|---|
committer | Dan Goodliffe <dan@randomdan.homeip.net> | 2021-03-09 01:21:46 +0000 |
commit | d39c6dd18248927044d2f75cefd2ed8ba12eb3b7 (patch) | |
tree | 49f165919282a3791d2545d2f18aaf9549586e95 /game/vehicles | |
parent | Split ActivityOf<> into its own file (diff) | |
download | ilt-d39c6dd18248927044d2f75cefd2ed8ba12eb3b7.tar.bz2 ilt-d39c6dd18248927044d2f75cefd2ed8ba12eb3b7.tar.xz ilt-d39c6dd18248927044d2f75cefd2ed8ba12eb3b7.zip |
Make objectives responsible for navigation
Diffstat (limited to 'game/vehicles')
-rw-r--r-- | game/vehicles/vehicle.cpp | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/game/vehicles/vehicle.cpp b/game/vehicles/vehicle.cpp index db61564..e30cbf9 100644 --- a/game/vehicles/vehicle.cpp +++ b/game/vehicles/vehicle.cpp @@ -12,7 +12,6 @@ #include <iterator> #include <location.hpp> #include <maths.h> -#include <random> #include <utility> #include <vector> @@ -26,7 +25,6 @@ Vehicle::Vehicle(const LinkPtr & l, float ld) : linkDist {ld} void Vehicle::move(TickDuration dur) { - static std::mt19937 gen(std::random_device {}()); linkDist += dur.count() * speed; auto curLink {linkHist.getCurrent()}; while (linkDist > curLink.first->length) { @@ -36,9 +34,10 @@ Vehicle::move(TickDuration dur) return std::abs(normalize(n.first.lock()->ends[n.second].second - ang)) > 0.1F; }); if (last != nexts.begin()) { - auto off = std::uniform_int_distribution<>(0, std::distance(nexts.begin(), last) - 1)(gen); + auto next = (std::distance(nexts.begin(), last) > 1) ? orders.current()->navigate(nexts.cbegin(), last) + : nexts.front(); linkDist -= curLink.first->length; - curLink = linkHist.add(nexts[off].first, nexts[off].second); + curLink = linkHist.add(next.first, next.second); } else { linkDist = curLink.first->length; |