// Adds both secondary room and corridor tile positions to `_data`. Secondary rooms are the ones // intersecting the corridors. private void AddCorridors() { //Stores existing connections in its keys. var connected = new Dictionary <Vector2, object>(); //Checks if points are connected by a corridor. If not, adds a corridor. foreach (int point1Id in _path.GetPoints()) { foreach (var point2Id in _path.GetPointConnections(point1Id)) { var point1 = _path.GetPointPosition(point1Id); var point2 = _path.GetPointPosition(point2Id); if (connected.ContainsKey(new Vector2(point1Id, point2Id))) { continue;; } point1 = Level.WorldToMap(point1); point2 = Level.WorldToMap(point2); AddCorridor((int)point1.x, (int)point2.x, (int)point1.y, Vector2.Axis.X); AddCorridor((int)point1.x, (int)point2.x, (int)point2.y, Vector2.Axis.Y); //Stores the connection between point 1 and 2. connected[new Vector2(point1Id, point2Id)] = null; connected[new Vector2(point2Id, point1Id)] = null; } } }