From 789a16e4e97d4050bb8db9cc3aebb01e807ac8c7 Mon Sep 17 00:00:00 2001 From: Dan Goodliffe Date: Wed, 10 Mar 2021 01:54:40 +0000 Subject: Push more RailLinks logic down into NetworkOf --- game/network/network.h | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'game/network/network.h') diff --git a/game/network/network.h b/game/network/network.h index c42f056..c6d4dfa 100644 --- a/game/network/network.h +++ b/game/network/network.h @@ -23,6 +23,8 @@ public: [[nodiscard]] std::pair newNodeAt(glm::vec3); protected: + static void joinLinks(const LinkPtr & l, const LinkPtr & ol); + using Nodes = std::set>; Nodes nodes; std::shared_ptr texture; @@ -33,8 +35,19 @@ protected: using Network::Network; Collection links; + void joinLinks(const LinkPtr &) const; public: + template + std::shared_ptr + addLink(glm::vec3 a, glm::vec3 b, Params &&... params) requires std::is_base_of_v + { + const auto node1 = nodeAt(a), node2 = nodeAt(b); + auto l {links.template create(node1, node2, std::forward(params)...)}; + joinLinks(l); + return l; + } + void render(const Shader &) const override; }; -- cgit v1.2.3