summaryrefslogtreecommitdiff
path: root/game/network/network.cpp
blob: 52d88ecbc8f83756c8c68e09674d384371701c31 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include "network.h"
#include <cache.h>
#include <game/network/link.h>
#include <gfx/models/texture.h>
#include <utility>

Network::Network(const std::string & tn) : texture {Texture::cachedTexture.get(tn)} { }

NodePtr
Network::nodeAt(glm::vec3 pos)
{
	return *nodes.insert(std::make_shared<Node>(pos)).first;
}

std::pair<NodePtr, bool>
Network::newNodeAt(glm::vec3 pos)
{
	const auto i = nodes.insert(std::make_shared<Node>(pos));
	return {*i.first, i.second};
}

NodePtr
Network::findNodeAt(glm::vec3 pos) const
{
	if (const auto n = nodes.find(std::make_shared<Node>(pos)); n != nodes.end()) {
		return *n;
	}
	return {};
}