public class RoomFinder
extends java.lang.Object
A simpler but faster alternative
Modifier and Type | Field and Description |
---|---|
GreasedRegion |
allCaves |
GreasedRegion |
allCorridors |
GreasedRegion |
allFloors |
GreasedRegion |
allRooms |
char[][] |
basic
A copy of the dungeon map, however it was passed to the constructor.
|
OrderedMap<GreasedRegion,java.util.List<GreasedRegion>> |
caves
Not likely to be used directly, but there may be things you can do with these that are cumbersome using only
RoomFinder's simpler API.
|
Coord[] |
connections
When a RoomFinder is constructed, it stores all points of rooms that are adjacent to another region here.
|
OrderedMap<GreasedRegion,java.util.List<GreasedRegion>> |
corridors
Not likely to be used directly, but there may be things you can do with these that are cumbersome using only
RoomFinder's simpler API.
|
Coord[] |
doorways
When a RoomFinder is constructed, it stores all points of rooms that are adjacent to another region here.
|
int[][] |
environment |
int |
height |
char[][] |
map
A copy of the dungeon map, however it was passed to the constructor.
|
Coord[] |
mouths
When a RoomFinder is constructed, it stores all points of rooms that are adjacent to another region here.
|
OrderedMap<GreasedRegion,java.util.List<GreasedRegion>> |
rooms
Not likely to be used directly, but there may be things you can do with these that are cumbersome using only
RoomFinder's simpler API.
|
int |
width |
Constructor and Description |
---|
RoomFinder(char[][] dungeon)
Constructs a RoomFinder given a dungeon map, and finds rooms, corridors, and their connections on the map.
|
RoomFinder(char[][] dungeon,
int environmentKind)
Constructs a RoomFinder given a dungeon map and a general kind of environment for the whole map, then finds
rooms, corridors, and their connections on the map.
|
RoomFinder(char[][] dungeon,
int[][] environment)
Constructs a RoomFinder given a dungeon map and an environment map (which currently is only produced by
MixedGenerator by the getEnvironment() method after generate() is called, but other classes that use
MixedGenerator may also expose that environment, such as SerpentMapGenerator.getEnvironment()), and finds rooms,
corridors, caves, and their connections on the map.
|
Modifier and Type | Method and Description |
---|---|
java.util.ArrayList<char[][]> |
findCaves()
Gets all the caves this found during construction, returning them as an ArrayList of 2D char arrays, where an
individual room is "masked" so only its contents have normal map chars and the rest have only '#'.
|
java.util.ArrayList<char[][]> |
findCorridors()
Gets all the corridors this found during construction, returning them as an ArrayList of 2D char arrays, where an
individual corridor is "masked" so only its contents have normal map chars and the rest have only '#'.
|
java.util.ArrayList<char[][]> |
findRegions()
Gets all the rooms, corridors, and caves this found during construction, returning them as an ArrayList of 2D
char arrays, where an individual room or corridor is "masked" so only its contents have normal map chars and the
rest have only '#'.
|
java.util.ArrayList<char[][]> |
findRooms()
Gets all the rooms this found during construction, returning them as an ArrayList of 2D char arrays, where an
individual room is "masked" so only its contents have normal map chars and the rest have only '#'.
|
static char[][] |
merge(java.util.ArrayList<char[][]> regions,
int width,
int height)
Merges multiple 2D char arrays where the '#' character means "no value", and combines them so all cells with
value are on one map, with '#' filling any other cells.
|
char[][] |
regionAt(int x,
int y)
Takes an x, y position and finds the room, corridor, or cave at that position, if there is one, returning the
same 2D char array format as the other methods.
|
java.util.ArrayList<char[][]> |
regionsConnected(int x,
int y)
Takes an x, y position and finds the rooms or corridors that are directly connected to the room, corridor or cave
at that position, and returns the group as an ArrayList of 2D char arrays, one per connecting region.
|
char[][] |
regionsNear(int x,
int y)
Takes an x, y position and finds the room or corridor at that position and the rooms, corridors or caves that it
directly connects to, and returns the group as one merged 2D char array.
|
public char[][] map
public char[][] basic
public int[][] environment
public OrderedMap<GreasedRegion,java.util.List<GreasedRegion>> rooms
public OrderedMap<GreasedRegion,java.util.List<GreasedRegion>> corridors
public OrderedMap<GreasedRegion,java.util.List<GreasedRegion>> caves
public GreasedRegion allRooms
public GreasedRegion allCaves
public GreasedRegion allCorridors
public GreasedRegion allFloors
public Coord[] connections
public Coord[] doorways
public Coord[] mouths
public int width
public int height
public RoomFinder(char[][] dungeon)
dungeon
- a 2D char array that uses '#', box drawing characters, or ' ' for walls.public RoomFinder(char[][] dungeon, int environmentKind)
environmentKind
is MixedGenerator.ROOM_FLOOR
(or its equivalent, 1).dungeon
- a 2D char array that uses '#', box drawing characters, or ' ' for walls.environmentKind
- if 1 (MixedGenerator.ROOM_FLOOR
), this will find rooms and corridors, else cavespublic RoomFinder(char[][] dungeon, int[][] environment)
dungeon
- a 2D char array that uses '#' for walls.environment
- a 2D int array using constants from MixedGenerator; typically produced by a call to
getEnvironment() in MixedGenerator or SerpentMapGenerator after dungeon generation.public java.util.ArrayList<char[][]> findRooms()
public java.util.ArrayList<char[][]> findCorridors()
public java.util.ArrayList<char[][]> findCaves()
public java.util.ArrayList<char[][]> findRegions()
public static char[][] merge(java.util.ArrayList<char[][]> regions, int width, int height)
regions
- An ArrayList of 2D char array regions, where '#' is an empty value and all others will be mergedwidth
- the width of any map this returnsheight
- the height of any map this returnspublic char[][] regionAt(int x, int y)
x
- the x coordinate of a position that should be in a room or corridory
- the y coordinate of a position that should be in a room or corridorpublic char[][] regionsNear(int x, int y)
x
- the x coordinate of a position that should be in a room or corridory
- the y coordinate of a position that should be in a room or corridorpublic java.util.ArrayList<char[][]> regionsConnected(int x, int y)
x
- the x coordinate of a position that should be in a room or corridory
- the y coordinate of a position that should be in a room or corridorCopyright © Eben Howard 2012–2022. All rights reserved.