summaryrefslogtreecommitdiff
path: root/game/network/network.h
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-03-10 01:54:40 +0000
committerDan Goodliffe <dan@randomdan.homeip.net>2021-03-10 01:54:40 +0000
commit789a16e4e97d4050bb8db9cc3aebb01e807ac8c7 (patch)
treea5e0fc0f406c17e1b7b88ba8e16ea0bbb331a6dc /game/network/network.h
parentAdd some more helpers to Network (diff)
downloadilt-789a16e4e97d4050bb8db9cc3aebb01e807ac8c7.tar.bz2
ilt-789a16e4e97d4050bb8db9cc3aebb01e807ac8c7.tar.xz
ilt-789a16e4e97d4050bb8db9cc3aebb01e807ac8c7.zip
Push more RailLinks logic down into NetworkOf
Diffstat (limited to 'game/network/network.h')
-rw-r--r--game/network/network.h13
1 files changed, 13 insertions, 0 deletions
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<NodePtr, bool> newNodeAt(glm::vec3);
protected:
+ static void joinLinks(const LinkPtr & l, const LinkPtr & ol);
+
using Nodes = std::set<NodePtr, PtrSorter<NodePtr>>;
Nodes nodes;
std::shared_ptr<Texture> texture;
@@ -33,8 +35,19 @@ protected:
using Network::Network;
Collection<T> links;
+ void joinLinks(const LinkPtr &) const;
public:
+ template<typename L, typename... Params>
+ std::shared_ptr<L>
+ addLink(glm::vec3 a, glm::vec3 b, Params &&... params) requires std::is_base_of_v<T, L>
+ {
+ const auto node1 = nodeAt(a), node2 = nodeAt(b);
+ auto l {links.template create<L>(node1, node2, std::forward<Params>(params)...)};
+ joinLinks(l);
+ return l;
+ }
+
void render(const Shader &) const override;
};