MCPcopy Create free account
hub / github.com/OpenStarbound/OpenStarbound / TMXMap

Method TMXMap

source/game/StarDungeonTMXPart.cpp:190–214  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

188 }
189
190 TMXMap::TMXMap(Json const& tmx) {
191 if (tmx.getUInt("tileheight") != 8 || tmx.getUInt("tilewidth") != 8)
192 throw StarException("Invalid tile size");
193
194 m_width = tmx.getUInt("width");
195 m_height = tmx.getUInt("height");
196
197 m_tilesets = make_shared<TMXTilesets>(tmx.getArray("tilesets"));
198
199 for (Json const& tmxLayer : tmx.get("layers").iterateArray()) {
200 String layerType = tmxLayer.getString("type");
201
202 if (layerType == "tilelayer") {
203 TMXTileLayerPtr layer = make_shared<TMXTileLayer>(tmxLayer);
204 m_tileLayers.append(layer);
205
206 } else if (layerType == "objectgroup") {
207 TMXObjectGroupPtr group = make_shared<TMXObjectGroup>(tmxLayer, m_tilesets);
208 m_objectGroups.append(group);
209
210 } else {
211 throw StarException(strf("Unknown layer type '{}'", layerType.utf8Ptr()));
212 }
213 }
214 }
215
216 Tiled::Tile const& TMXTileLayer::getTile(TMXTilesetsPtr const& tilesets, Vec2I pos) const {
217 if (!m_rect.contains(pos))

Callers

nothing calls this directly

Calls 9

StarExceptionClass · 0.85
strfFunction · 0.85
getUIntMethod · 0.80
getArrayMethod · 0.80
iterateArrayMethod · 0.80
getStringMethod · 0.80
getMethod · 0.45
appendMethod · 0.45
utf8PtrMethod · 0.45

Tested by

no test coverage detected