Package squidpony.squidgrid.mapping
Class RectangleRoomFinder
java.lang.Object
squidpony.squidgrid.mapping.RectangleRoomFinder
public class RectangleRoomFinder extends Object
An algorithm to find rectangle areas in dungeons. It is a simpler and faster
alternative to
RoomFinder
. You can execute
RectangleRoomsFinderTest
to see how it performs.- Author:
- smelC
- See Also:
A fancier room finder
-
Field Summary
Fields Modifier and Type Field Description protected char[][]
dungeon
protected int
dungeonHeight
protected int
dungeonWidth
protected Set<Character>
floors
int
minimumDiagonal
The minimum number of cells that the diagonal of a room must have.boolean
onlySquareRooms
true
to restrictthis
to find square rooms -
Constructor Summary
Constructors Constructor Description RectangleRoomFinder(char[][] dungeon)
-
Method Summary
Modifier and Type Method Description boolean
addFloorCharacter(char c)
Adds a character considered as a floor.protected Rectangle
extendRoom(boolean[][] assigneds, Rectangle r, Direction d)
protected Rectangle
extendRoomOnce(boolean[][] assigneds, Rectangle r, Direction d)
List<Rectangle>
findRectangles()
protected boolean
isFloor(char c)
protected boolean
isInDungeon(Coord c)
boolean
removeFloorCharacter(char c)
Removes a character from being considered as a floor.
-
Field Details
-
dungeon
-
dungeonWidth
-
dungeonHeight
-
floors
-
minimumDiagonal
The minimum number of cells that the diagonal of a room must have. Having 3 here means that, by default, only rooms at most 3x3 are considered. -
onlySquareRooms
true
to restrictthis
to find square rooms
-
-
Constructor Details
-
Method Details
-
addFloorCharacter
Adds a character considered as a floor.- Parameters:
c
-- Returns:
true
ifc
wasn't a floor character.
-
removeFloorCharacter
Removes a character from being considered as a floor.- Parameters:
c
-- Returns:
true
ifc
was a floor character.
-
findRectangles
- Returns:
- The rectangles of the dungeon given at creation time.
-
extendRoom
- Parameters:
assigneds
- Cells already in a room.d
- A cardinal direction.- Returns:
- A variant of
r
extended to the directiond
, if possible.r
itself if unaffected.
-
extendRoomOnce
- Parameters:
assigneds
- Cells already in a room. This array is muted by this call.
-
isFloor
-
isInDungeon
-