| 230 | }; |
| 231 | |
| 232 | Tile::Tile(Properties const& tileProperties, TileLayer layer, bool flipX) |
| 233 | : Dungeon::Tile(), properties(tileProperties) { |
| 234 | JsonObject computedProperties; |
| 235 | if (!properties.contains("layer")) { |
| 236 | computedProperties["layer"] = LayerNames.getRight(layer); |
| 237 | } else { |
| 238 | layer = LayerNames.getLeft(properties.get<String>("layer")); |
| 239 | } |
| 240 | |
| 241 | if (flipX) |
| 242 | computedProperties["flipX"] = "true"; |
| 243 | |
| 244 | if (layer == TileLayer::Background && !properties.contains("clear")) |
| 245 | // The magic pink tile/brush has the clear property set to "false". All |
| 246 | // other tiles default to clear="true". |
| 247 | computedProperties["clear"] = "true"; |
| 248 | |
| 249 | properties = properties.inherit(computedProperties); |
| 250 | |
| 251 | PropertyReader<BrushConstPtr> br; |
| 252 | br.optRead<bool, Maybe<BrushConstPtr>>(brushes, "clear", getClearBrush, properties); |
| 253 | br.optRead<String>(brushes, "material", getMaterialBrush, properties); |
| 254 | br.optRead<String>(brushes, "front", getFrontBrush, properties); |
| 255 | br.optRead<String>(brushes, "back", getBackBrush, properties); |
| 256 | br.optRead<String>(brushes, "playerstart", getPlayerStartBrush, properties); |
| 257 | br.optRead<String>(brushes, "object", getObjectBrush, properties); |
| 258 | br.optRead<String>(brushes, "vehicle", getVehicleBrush, properties); |
| 259 | br.optRead<String>(brushes, "wire", getWireBrush, properties); |
| 260 | br.optRead<String>(brushes, "npc", getNpcBrush, properties); |
| 261 | br.optRead<String>(brushes, "monster", getMonsterBrush, properties); |
| 262 | br.optRead<String>(brushes, "stagehand", getStagehandBrush, properties); |
| 263 | br.optRead<String>(brushes, "dungeonid", getDungeonIdBrush, properties); |
| 264 | br.optRead<String>(brushes, "biomeitems", getBiomeItemsBrush, properties); |
| 265 | br.optRead<String>(brushes, "biometree", getBiomeTreeBrush, properties); |
| 266 | br.optRead<String>(brushes, "item", getItemBrush, properties); |
| 267 | br.optRead<String>(brushes, "surface", getSurfaceBrush, properties); |
| 268 | br.optRead<String>(brushes, "liquid", getLiquidBrush, properties); |
| 269 | br.optRead<bool, Maybe<BrushConstPtr>>(brushes, "invalid", getInvalidBrush, properties); |
| 270 | |
| 271 | PropertyReader<RuleConstPtr> rr; |
| 272 | rr.optRead<String>(rules, "worldGenMustContainAir", getAirRule, properties); |
| 273 | rr.optRead<String>(rules, "worldGenMustContainSolid", getSolidRule, properties); |
| 274 | rr.optRead<String>(rules, "worldGenMustContainLiquid", getLiquidRule, properties); |
| 275 | rr.optRead<String>(rules, "worldGenMustNotContainLiquid", getNotLiquidRule, properties); |
| 276 | rr.optRead<String>(rules, "allowOverdrawing", getAllowOverdrawingRule, properties); |
| 277 | |
| 278 | if (auto connectorName = properties.opt<String>("connector")) { |
| 279 | auto newConnector = TileConnector(); |
| 280 | |
| 281 | newConnector.value = *connectorName; |
| 282 | |
| 283 | auto connectForwardOnly = properties.opt<bool>("connectForwardOnly"); |
| 284 | newConnector.forwardOnly = connectForwardOnly.value(false); |
| 285 | |
| 286 | if (auto connectDirection = properties.opt<String>("connectDirection")) |
| 287 | newConnector.direction = DungeonDirectionNames.getLeft(*connectDirection); |
| 288 | |
| 289 | connector = newConnector; |
nothing calls this directly
no test coverage detected