Package squidpony.squidgrid.mapping
Class MapModule
java.lang.Object
squidpony.squidgrid.mapping.MapModule
- All Implemented Interfaces:
Serializable
,Comparable<MapModule>
@Beta public class MapModule extends Object implements Comparable<MapModule>, Serializable
A subsection of a (typically modern-day or sci-fi) area map that can be placed by ModularMapGenerator.
This is marked Beta because both MapModule and
Created by Tommy Ettinger on 4/4/2016.
This is marked Beta because both MapModule and
ModularMapGenerator
need improvement to be actually usable,
but it might be a while before there's a clear pathway towards how they can be improved.
Created by Tommy Ettinger on 4/4/2016.
- See Also:
- Serialized Form
-
Field Summary
Fields Modifier and Type Field Description ArrayList<Coord>
bottomDoors
int
category
int[][]
environment
The room/cave/corridor/wall status for each cell of this section of map.ArrayList<Coord>
leftDoors
char[][]
map
The contents of this section of map.Coord
max
The maximum point on the bounding rectangle of the room, including walls.Coord
min
The minimum point on the bounding rectangle of the room, including walls.ArrayList<Coord>
rightDoors
ArrayList<Coord>
topDoors
GreasedRegion
validDoors
Stores Coords just outside the contents of the MapModule, where doors are allowed to connect into this. -
Constructor Summary
Constructors Constructor Description MapModule()
MapModule(char[][] map)
Constructs a MapModule given only a 2D char array as the contents of this section of map.MapModule(char[][] map, GreasedRegion validDoors, Coord min, Coord max)
Constructs a MapModule from the given arguments without modifying them, copying map without changing its size, copying validDoors, and using the same min and max (which are immutable, so they can be reused).MapModule(MapModule other)
Copies another MapModule and uses it to construct a new one. -
Method Summary
-
Field Details
-
map
The contents of this section of map. -
environment
The room/cave/corridor/wall status for each cell of this section of map. -
validDoors
Stores Coords just outside the contents of the MapModule, where doors are allowed to connect into this. Uses Coord positions that are relative to this MapModule's map field, not whatever this is being placed into. -
min
The minimum point on the bounding rectangle of the room, including walls. -
max
The maximum point on the bounding rectangle of the room, including walls. -
leftDoors
-
rightDoors
-
topDoors
-
bottomDoors
-
category
-
-
Constructor Details
-
MapModule
public MapModule() -
MapModule
Constructs a MapModule given only a 2D char array as the contents of this section of map. The actual MapModule will use doors in the 2D char array as '+' or '/' if present. Otherwise, the valid locations for doors will be any outer wall adjacent to a floor ('.'), shallow water (','), grass ('"'), trap ('^'), or staircase (less than or greater than signs). The max and min Coords of the bounding rectangle, including one layer of outer walls, will also be calculated. The map you pass to this does need to have outer walls present in it already.- Parameters:
map
- the 2D char array that contains the contents of this section of map
-
MapModule
Constructs a MapModule from the given arguments without modifying them, copying map without changing its size, copying validDoors, and using the same min and max (which are immutable, so they can be reused).- Parameters:
map
- the 2D char array that contains the contents of this section of map; will be copied exactlyvalidDoors
- a Coord array that stores viable locations to place doors in map; will be clonedmin
- the minimum Coord of this MapModule's bounding rectanglemax
- the maximum Coord of this MapModule's bounding rectangle
-
MapModule
Copies another MapModule and uses it to construct a new one.- Parameters:
other
- an already-constructed MapModule that this will copy
-
-
Method Details
-
rotate
Rotates a copy of this MapModule by the given number of 90-degree turns. Describing the turns as clockwise or counter-clockwise depends on whether the y-axis "points up" or "points down." If higher values for y are toward the bottom of the screen (the default for when 2D arrays are printed), a turn of 1 is clockwise 90 degrees, but if the opposite is true and higher y is toward the top, then a turn of 1 is counter-clockwise 90 degrees.- Parameters:
turns
- the number of 90 degree turns to adjust this by- Returns:
- a new MapModule (copied from this one) that has been rotated by the given amount
-
flip
-
compareTo
- Specified by:
compareTo
in interfaceComparable<MapModule>
-