/// <summary> /// Attempts to place a Room perimeter in an open area of the RoomGroup. /// </summary> /// <param name="room">The Room from which to derive the Polygon to place.</param> /// <returns> /// True if the room was successfully placed. /// </returns> private bool AddToPerimeter(Room room, IList <Polygon> among) { var polygon = RoomPerimeter(room); if (polygon.Area > AvailableArea) { return(false); } if (Rooms.Count == 0) { polygon = polygon.MoveFromTo(new Vector3(), Box.SW); polygon = Perimeter.Intersection(polygon).First(); if (among != null && polygon.Intersects(among)) { return(false); } room.Perimeter = polygon; Rooms.Add(room); return(true); } foreach (Polygon adjacentTo in PerimetersRooms) { var adjPolygon = Place.Adjacent(polygon, adjacentTo, Perimeter, PerimetersRooms); if (adjPolygon != null) { room.Perimeter = adjPolygon; Rooms.Add(room); return(true); } } return(false); }