summaryrefslogtreecommitdiff
path: root/game/network/network.h
diff options
context:
space:
mode:
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;
};