/// <summary> Checks if the given edge is blocked. </summary> /// <param name="begin"> The start of the edge. </param> /// <param name="end"> The end of the edge. </param> /// <param name="r1"> The starting room of the path. </param> /// <param name="r2"> The ending room of the path. </param> /// <param name="floor"> The floor this path is on. </param> /// <param name="upperLayer"> The Layer above this path's floor. </param> /// <param name="lowerLayer"> The layer below this path's floor. </param> /// <returns> True if there is something blocking this edge. </returns> private bool CheckEdgeBlocked(Vector3 begin, Vector3 end, Room r1, Room r2, Floor floor, MiddleLayer upperLayer, MiddleLayer lowerLayer) { Vector3 tl, tr, bl, br; GenerationUtility.BoxBounds(begin, end, this.pathWidth, out tl, out tr, out bl, out br); foreach (Room r in floor.Rooms) { if (r != r1 && r != r2) { if (r.IsIntersectingLine(tl, bl)) { return(true); } if (r.IsIntersectingLine(tr, br)) { return(true); } } } if (upperLayer != null) { foreach (LayerPath l in upperLayer.Paths) { if (l.IsIntersectingLine(tl, bl)) { Vector3 pos = GenerationUtility.LineLineIntersection(tl, bl, l.Start.Position, l.End.Position); bool inRoom = IsInRoom(pos, l.Start, l.End); if (!inRoom) { return(true); } } if (l.IsIntersectingLine(tr, br)) { Vector3 pos = GenerationUtility.LineLineIntersection(tr, br, l.Start.Position, l.End.Position); bool inRoom = IsInRoom(pos, l.Start, l.End); if (!inRoom) { return(true); } } } } if (lowerLayer != null) { foreach (LayerPath l in lowerLayer.Paths) { if (l.IsIntersectingLine(tl, bl)) { Vector3 pos = GenerationUtility.LineLineIntersection(tl, bl, l.Start.Position, l.End.Position); bool inRoom = IsInRoom(pos, l.Start, l.End); if (!inRoom) { return(true); } } if (l.IsIntersectingLine(tr, br)) { Vector3 pos = GenerationUtility.LineLineIntersection(tr, br, l.Start.Position, l.End.Position); bool inRoom = IsInRoom(pos, l.Start, l.End); if (!inRoom) { return(true); } } } } return(false); }