From ea8ae67d068fc5a1a2229e1ed17c795498024c71 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Tue, 9 Mar 2021 00:28:33 +0000 Subject: Push link based movement into Vehicle I think it's fair to make all vehicles uses links and nodes to navigate... even if those links, nodes are private to that vehicle --- game/vehicles/train.cpp | 29 ----------------------------- 1 file changed, 29 deletions(-) (limited to 'game/vehicles/train.cpp') diff --git a/game/vehicles/train.cpp b/game/vehicles/train.cpp index f7b5515..f887be4 100644 --- a/game/vehicles/train.cpp +++ b/game/vehicles/train.cpp @@ -5,38 +5,9 @@ #include "gfx/renderable.h" #include "location.hpp" #include -#include #include -#include -#include -#include -#include #include -void -Train::move(TickDuration dur) -{ - static std::mt19937 gen(std::random_device {}()); - linkDist += dur.count() * speed; - auto curLink {linkHist.getCurrent()}; - while (linkDist > curLink.first->length) { - const auto location = curLink.first->positionAt(curLink.first->length, curLink.second); - auto nexts {curLink.first->nexts[1 - curLink.second]}; - auto last = std::remove_if(nexts.begin(), nexts.end(), [ang = location.rot.y](const Link::Next & n) { - 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); - linkDist -= curLink.first->length; - curLink = linkHist.add(nexts[off].first, nexts[off].second); - } - else { - linkDist = curLink.first->length; - speed = 0; - } - } -} - void Train::render(const Shader & shader) const { -- cgit v1.2.3