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 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 Details

  • Constructor Details

    • MapModule

      public MapModule()
    • MapModule

      public MapModule​(char[][] map)
      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

      public 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).
      Parameters:
      map - the 2D char array that contains the contents of this section of map; will be copied exactly
      validDoors - a Coord array that stores viable locations to place doors in map; will be cloned
      min - the minimum Coord of this MapModule's bounding rectangle
      max - the maximum Coord of this MapModule's bounding rectangle
    • MapModule

      public MapModule​(MapModule other)
      Copies another MapModule and uses it to construct a new one.
      Parameters:
      other - an already-constructed MapModule that this will copy
  • Method Details

    • rotate

      public MapModule rotate​(int turns)
      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

      public MapModule flip​(boolean flipLeftRight, boolean flipUpDown)
    • compareTo

      public int compareTo​(MapModule o)
      Specified by:
      compareTo in interface Comparable<MapModule>