bool IsWall(int x, int z, IsaacRoomLayout layout) { var center = IsaacBuilderUtils.GetTileAt(x, z, layout); if (center.tileType == IsaacRoomTileType.Floor) { return(false); } for (int dx = -1; dx <= 1; dx++) { for (int dz = -1; dz <= 1; dz++) { if (dx == 0 && dz == 0) { continue; } var cell = IsaacBuilderUtils.GetTileAt(x + dx, z + dz, layout); if (cell.tileType == IsaacRoomTileType.Floor) { // Contains an adjacent floor tile return(true); } } } return(false); }
void EmitLevelMarkers() { var tileSize = new Vector3(isaacConfig.tileSize.x, 0, isaacConfig.tileSize.y); var roomSizeWorld = new IntVector(isaacConfig.roomWidth, 0, isaacConfig.roomHeight) * tileSize; var roomPadding = new Vector3(isaacConfig.roomPadding.x, 0, isaacConfig.roomPadding.y); foreach (var room in isaacModel.rooms) { var roomBasePosition = room.position * (roomSizeWorld + roomPadding); var roomWidth = room.layout.Tiles.GetLength(0); var roomHeight = room.layout.Tiles.GetLength(1); for (int x = -1; x < roomWidth + 1; x++) { for (int z = -1; z < roomHeight + 1; z++) { var tilePosition = new IntVector(x, 0, z); var tileOffset = tilePosition * tileSize; var markerPosition = roomBasePosition + tileOffset; var transformation = Matrix4x4.TRS(markerPosition, Quaternion.identity, Vector3.one); var tile = IsaacBuilderUtils.GetTileAt(x, z, room.layout); if (tile.tileType == IsaacRoomTileType.Floor) { EmitMarker("Ground", transformation, tilePosition, room.roomId); } else if (IsaacBuilderUtils.ContainsDoorAt(x, z, room)) { EmitMarker("Door2D", transformation, tilePosition, room.roomId); EmitMarker("Door", transformation, tilePosition, room.roomId); } else if (IsWall(x, z, room.layout)) { EmitMarker("Wall2D", transformation, tilePosition, room.roomId); EmitMarker("Wall", transformation, tilePosition, room.roomId); } } } } }