diff options
-rw-r--r-- | game/network/rail.cpp | 9 | ||||
-rw-r--r-- | game/network/rail.h | 1 |
2 files changed, 10 insertions, 0 deletions
diff --git a/game/network/rail.cpp b/game/network/rail.cpp index 25b3376..8ec6893 100644 --- a/game/network/rail.cpp +++ b/game/network/rail.cpp @@ -37,6 +37,15 @@ RailLinks::joinLinks(const LinkPtr & l) const } } +NodePtr +RailLinks::findNodeAt(glm::vec3 pos) const +{ + if (const auto n = nodes.find(std::make_shared<Node>(pos)); n != nodes.end()) { + return *n; + } + return {}; +} + std::shared_ptr<RailLink> RailLinks::addLinksBetween(glm::vec3 start, glm::vec3 end) { diff --git a/game/network/rail.h b/game/network/rail.h index d25964d..4460fcd 100644 --- a/game/network/rail.h +++ b/game/network/rail.h @@ -72,6 +72,7 @@ public: } std::shared_ptr<RailLink> addLinksBetween(glm::vec3 start, glm::vec3 end); + [[nodiscard]] NodePtr findNodeAt(glm::vec3) const; private: using Nodes = std::set<NodePtr, PtrSorter<NodePtr>>; |