MCPcopy Create free account
hub / github.com/OpenApoc/OpenApoc / TileMap

Method TileMap

game/state/tilemap/tilemap.cpp:32–61  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

30{
31
32TileMap::TileMap(Vec3<int> size, Vec3<float> velocityScale, Vec3<int> voxelMapSize,
33 std::vector<std::set<TileObject::Type>> layerMap)
34 : layerMap(layerMap), size(size), voxelMapSize(voxelMapSize), velocityScale(velocityScale)
35{
36 tiles.reserve(size.x * size.y * size.z);
37 for (int z = 0; z < size.z; z++)
38 {
39 for (int y = 0; y < size.y; y++)
40 {
41 for (int x = 0; x < size.x; x++)
42 {
43 tiles.emplace_back(*this, Vec3<int>{x, y, z}, this->getLayerCount());
44 }
45 }
46 }
47
48 // Quick sanity check of the layer map:
49 std::set<TileObject::Type> seenTypes;
50 for (auto &typesInLayer : layerMap)
51 {
52 for (auto &type : typesInLayer)
53 {
54 if (seenTypes.find(type) != seenTypes.end())
55 {
56 LogError("Type %d appears in multiple layers", static_cast<int>(type));
57 }
58 seenTypes.insert(type);
59 }
60 }
61}
62
63TileMap::~TileMap() = default;
64

Callers

nothing calls this directly

Calls 3

getLayerCountMethod · 0.95
endMethod · 0.80
insertMethod · 0.80

Tested by

no test coverage detected