public class SectionDungeonGenerator extends java.lang.Object implements IDungeonGenerator
Modifier and Type | Class and Description |
---|---|
static class |
SectionDungeonGenerator.FillEffect
The effects that can be applied to this dungeon.
|
Modifier and Type | Field and Description |
---|---|
static int |
ALL
Constant for features being added to all environment types.
|
static int |
CAVE
Constant for features being added to all environment types.
|
java.util.EnumMap<SectionDungeonGenerator.FillEffect,java.lang.Integer> |
caveFX
The effects that will be applied when generate is called.
|
static int |
CORRIDOR
Constant for features being added to all environment types.
|
java.util.EnumMap<SectionDungeonGenerator.FillEffect,java.lang.Integer> |
corridorFX
The effects that will be applied when generate is called.
|
char |
deepLakeGlyph
The char to use for deep lake cells.
|
int |
doorFX
Percentage of viable positions to fill with doors, represented by '+' for east-to-west connections or '/' for
north-to-south ones; this number will be negative if filling two-cell wide positions but will be made positive
when needed.
|
protected char[][] |
dungeon |
protected int |
environmentType |
RoomFinder |
finder
Potentially important if you need to identify specific rooms, corridors, or cave areas in a map.
|
protected int |
height |
int |
lakeFX
The approximate percentage of non-room, non-cave, non-edge-of-map wall cells to try to fill with lake.
|
boolean |
markStairsDown |
boolean |
markStairsUp |
int |
mazeFX
The approximate percentage of non-room, non-cave, non-edge-of-map wall cells to try to fill with maze.
|
Placement |
placement
Configured by this class after you call generate(), this Placement can be used to locate areas of the dungeon
that fit certain properties, like "out of sight from a door" or "a large flat section of wall that could be used
to place a straight-line object." You can use this as-needed; it does only a small amount of work at the start,
and does the calculations for what areas have certain properties on request.
|
protected long |
rebuildSeed |
StatefulRNG |
rng |
static int |
ROOM
Constant for features being added to all environment types.
|
java.util.EnumMap<SectionDungeonGenerator.FillEffect,java.lang.Integer> |
roomFX
The effects that will be applied when generate is called.
|
protected boolean |
seedFixed |
char |
shallowLakeGlyph
The char to use for shallow lake cells.
|
Coord |
stairsDown |
Coord |
stairsUp |
DungeonUtility |
utility |
protected int |
width |
Constructor and Description |
---|
SectionDungeonGenerator()
Make a SectionDungeonGenerator with a LightRNG using a random seed, height 40, and width 40.
|
SectionDungeonGenerator(int width,
int height)
Make a SectionDungeonGenerator with the given height and width; the RNG used for generating a dungeon and
adding features will be a LightRNG using a random seed.
|
SectionDungeonGenerator(int width,
int height,
IRNG rng)
Make a SectionDungeonGenerator with the given height, width, and RNG.
|
SectionDungeonGenerator(SectionDungeonGenerator copying)
Copies all fields from copying and makes a new DungeonGenerator.
|
Modifier and Type | Method and Description |
---|---|
SectionDungeonGenerator |
addBoulders(int env,
int percentage)
Turns the given percentage of floor cells not already adjacent to walls into wall cells, represented by '#'.
|
SectionDungeonGenerator |
addDoors(int percentage,
boolean doubleDoors)
Turns the given percentage of viable doorways into doors, represented by '+' for doors that allow travel along
the x-axis and '/' for doors that allow travel along the y-axis.
|
SectionDungeonGenerator |
addGrass(int env,
int percentage)
Turns the majority of the given percentage of floor cells into grass cells, represented by '"'.
|
SectionDungeonGenerator |
addLake(int percentage)
Instructs the generator to add a lake (here, of water) into a large area that can be filled without overwriting
rooms, caves, or the edge of the map; wall cells will become the deep lake glyph (here, '~'), unless they are
close to an existing room or cave, in which case they become the shallow lake glyph (here, ','), and corridors
that are "covered" by a lake will become bridges, the glyph ':'.
|
SectionDungeonGenerator |
addLake(int percentage,
char deepLake,
char shallowLake)
Instructs the generator to add a lake into a large area that can be filled without overwriting rooms, caves, or
the edge of the map; wall cells will become the char deepLake, unless they are close to an existing room or cave,
in which case they become the char shallowLake, and corridors that are "covered" by a lake will become bridges,
the glyph ':'.
|
SectionDungeonGenerator |
addMaze(int percentage)
Instructs the generator to add a winding section of corridors into a large area that can be filled without
overwriting rooms, caves, or the edge of the map; wall cells will become either '#' or '.' and corridors will be
overwritten.
|
SectionDungeonGenerator |
addStairs()
Enables drawing stairs up, as '<', and stairs down, as '>', when a map is generated.
|
SectionDungeonGenerator |
addStairs(boolean up,
boolean down)
Potentially enables drawing stairs up, as '<', and stairs down, as '>', when a map is generated.
|
SectionDungeonGenerator |
addTraps(int env,
int percentage)
Turns the given percentage of open area floor cells into trap cells, represented by '^'.
|
SectionDungeonGenerator |
addWater(int env,
int percentage)
Turns the majority of the given percentage of floor cells into water cells, represented by '~'.
|
SectionDungeonGenerator |
addWater(int env,
int percentage,
int islandSpacing)
Turns the majority of the given percentage of floor cells into water cells, represented by '~'.
|
SectionDungeonGenerator |
clearEffects()
Removes any door, water, or trap insertion effects that this DungeonGenerator would put in future dungeons.
|
char[][] |
generate()
Generate a char[][] dungeon using TilesetType.DEFAULT_DUNGEON; this produces a dungeon appropriate for a level
of ruins or a partially constructed dungeon.
|
char[][] |
generate(char[][] baseDungeon,
int[][] environment)
Generate a char[][] dungeon with extra features given a baseDungeon that has already been generated and an
environment as an int[][], which can often be obtained from MixedGenerator or classes that use it, like
SerpentMapGenerator, with their getEnvironment method.
|
char[][] |
generate(TilesetType kind)
Generate a char[][] dungeon given a TilesetType; the comments in that class provide some opinions on what
each TilesetType value could be used for in a game.
|
char[][] |
generateRespectingStairs(char[][] baseDungeon,
int[][] environment)
Generate a char[][] dungeon with extra features given a baseDungeon that has already been generated, with
staircases represented by greater than and less than signs, and an environment as an int[][], which can often be
obtained from MixedGenerator or classes that use it, like SerpentMapGenerator, with their getEnvironment method.
|
char[][] |
getBareDungeon()
Get the most recently generated char[][] dungeon out of this class without any chars other than '#' or '.', for
walls and floors respectively.
|
char[][] |
getDungeon()
Get the most recently generated char[][] dungeon out of this class.
|
int |
getHeight()
Height of the dungeon in cells.
|
long |
getRebuildSeed()
Gets the seed that can be used to rebuild an identical dungeon to the latest one generated (or the seed that
will be used to generate the first dungeon if none has been made yet).
|
int |
getWidth()
Width of the dungeon in cells.
|
protected char[][] |
innerGenerate() |
protected char[][] |
innerGenerate(char[][] map,
java.util.EnumMap<SectionDungeonGenerator.FillEffect,java.lang.Integer> fx) |
protected char[][] |
makeDoors(java.util.ArrayList<char[][]> rooms,
java.util.ArrayList<char[][]> corridors,
char[][] allCaves,
char[][] allCorridors) |
protected char[][][] |
makeLake(java.util.ArrayList<char[][]> rooms,
java.util.ArrayList<char[][]> caves) |
protected OrderedSet<Coord> |
removeAdjacent(OrderedSet<Coord> coll,
Coord pt) |
protected OrderedSet<Coord> |
removeAdjacent(OrderedSet<Coord> coll,
Coord pt1,
Coord pt2) |
protected OrderedSet<Coord> |
removeNearby(OrderedSet<Coord> coll,
char[][] disallowed) |
void |
setDungeon(char[][] dungeon)
Change the underlying char[][]; only affects the toString method, and of course getDungeon.
|
java.lang.String |
toString()
Provides a string representation of the latest generated dungeon.
|
protected OrderedSet<Coord> |
viableDoorways(boolean doubleDoors,
char[][] map,
char[][] allCaves,
char[][] allCorridors) |
public static final int ALL
public static final int ROOM
public static final int CORRIDOR
public static final int CAVE
public java.util.EnumMap<SectionDungeonGenerator.FillEffect,java.lang.Integer> roomFX
public java.util.EnumMap<SectionDungeonGenerator.FillEffect,java.lang.Integer> corridorFX
public java.util.EnumMap<SectionDungeonGenerator.FillEffect,java.lang.Integer> caveFX
public int doorFX
public char deepLakeGlyph
public char shallowLakeGlyph
public int lakeFX
public int mazeFX
public DungeonUtility utility
protected int height
protected int width
public Coord stairsUp
public Coord stairsDown
public boolean markStairsUp
public boolean markStairsDown
public StatefulRNG rng
protected long rebuildSeed
protected boolean seedFixed
protected int environmentType
protected char[][] dungeon
public RoomFinder finder
public Placement placement
public SectionDungeonGenerator()
public SectionDungeonGenerator(int width, int height)
width
- The width of the dungeon in cellsheight
- The height of the dungeon in cellspublic SectionDungeonGenerator(int width, int height, IRNG rng)
width
- The width of the dungeon in cellsheight
- The height of the dungeon in cellsrng
- The RNG to use for all purposes in this class; if it is a StatefulRNG, then it will be used as-is,
but if it is not a StatefulRNG, a new StatefulRNG will be used, randomly seeded by this parameterpublic SectionDungeonGenerator(SectionDungeonGenerator copying)
copying
- the DungeonGenerator to copypublic char[][] getDungeon()
getDungeon
in interface IDungeonGenerator
public char[][] getBareDungeon()
public void setDungeon(char[][] dungeon)
dungeon
- a char[][], probably produced by an earlier call to this class and then modified.public int getHeight()
public int getWidth()
public SectionDungeonGenerator addWater(int env, int percentage)
env
- the environment to apply this to; uses MixedGenerator's constants, or 0 for "all environments"percentage
- the percentage of floor cells to fill with waterpublic SectionDungeonGenerator addWater(int env, int percentage, int islandSpacing)
env
- the environment to apply this to; uses MixedGenerator's constants, or 0 for "all environments"percentage
- the percentage of floor cells to fill with waterislandSpacing
- if greater than 1, islands will be placed randomly this many cells apart.public SectionDungeonGenerator addGrass(int env, int percentage)
env
- the environment to apply this to; uses MixedGenerator's constants, or 0 for "all environments"percentage
- the percentage of floor cells to fill with grass; this can vary quite a lot. It may be
difficult to fill very high (over 66%) percentages of map with grass, though you can do this by
giving a percentage of between 100 and 150.public SectionDungeonGenerator addBoulders(int env, int percentage)
env
- the environment to apply this to; uses MixedGenerator's constants, or 0 for "all environments"percentage
- the percentage of floor cells not adjacent to walls to fill with boulders.public SectionDungeonGenerator addDoors(int percentage, boolean doubleDoors)
percentage
- the percentage of valid openings to corridors to fill with doors; should be between 10 and
20 if you want doors to appear more than a few times, but not fill every possible opening.doubleDoors
- true if you want two-cell-wide openings to receive a door and a wall; false if only
one-cell-wide openings should receive doors. Usually, this should be true.public SectionDungeonGenerator addMaze(int percentage)
percentage
- The percentage of non-room, non-cave, non-edge-of-map wall cells to try to fill with maze.public SectionDungeonGenerator addLake(int percentage)
percentage
- The percentage of non-room, non-cave, non-edge-of-map wall cells to try to fill with lake.public SectionDungeonGenerator addLake(int percentage, char deepLake, char shallowLake)
percentage
- The percentage of non-room, non-cave, non-edge-of-map wall cells to try to fill with lake.deepLake
- the char to use for deep lake cells, such as '~'shallowLake
- the char to use for shallow lake cells, such as ','public SectionDungeonGenerator addTraps(int env, int percentage)
env
- the environment to apply this to; uses MixedGenerator's constants, or 0 for "all environments"percentage
- the percentage of valid cells to fill with traps; should be no higher than 5 unless
the dungeon floor is meant to be a kill screen or minefield.public SectionDungeonGenerator addStairs()
public SectionDungeonGenerator addStairs(boolean up, boolean down)
up
- if true, stairs up will be marked as '<'; if false, no up stairs will be markeddown
- if true, stairs down will be marked as '>'; if false, no down stairs will be markedpublic SectionDungeonGenerator clearEffects()
protected OrderedSet<Coord> removeAdjacent(OrderedSet<Coord> coll, Coord pt)
protected OrderedSet<Coord> removeAdjacent(OrderedSet<Coord> coll, Coord pt1, Coord pt2)
protected OrderedSet<Coord> removeNearby(OrderedSet<Coord> coll, char[][] disallowed)
protected OrderedSet<Coord> viableDoorways(boolean doubleDoors, char[][] map, char[][] allCaves, char[][] allCorridors)
public char[][] generate()
generate
in interface IDungeonGenerator
public char[][] generate(TilesetType kind)
kind
- a TilesetType enum value, such as TilesetType.DEFAULT_DUNGEONTilesetType
public char[][] generate(char[][] baseDungeon, int[][] environment)
DungeonUtility.ensurePath(dungeon, rng, '\t', '#');
then
passing dungeon (which that code modifies) in as baseDungeon to this method. Because tabs will always be replaced
by floors ('.'), this considers any tabs that overlap with what the environment considers a wall (cave wall, room
wall, corridor wall, or untouched) to really refer to a corridor floor, but doesn't reconsider tabs that overlap
with floors already (it keeps the state of actual room, cave, and corridor floors). This is useful so you only
have to call ensurePath or a similar method on the 2D char array and can leave the 2D int array alone.baseDungeon
- a pre-made dungeon consisting of '#' for walls and '.' for floors; may be modified in-placeenvironment
- stores whether a cell is room, corridor, or cave; getEnvironment() typically gives thispublic char[][] generateRespectingStairs(char[][] baseDungeon, int[][] environment)
baseDungeon
- a pre-made dungeon consisting of '#' for walls and '.' for floors, with stairs already in;
may be modified in-placeenvironment
- stores whether a cell is room, corridor, or cave; getEnvironment() typically gives thisprotected char[][] innerGenerate()
protected char[][] makeDoors(java.util.ArrayList<char[][]> rooms, java.util.ArrayList<char[][]> corridors, char[][] allCaves, char[][] allCorridors)
protected char[][][] makeLake(java.util.ArrayList<char[][]> rooms, java.util.ArrayList<char[][]> caves)
protected char[][] innerGenerate(char[][] map, java.util.EnumMap<SectionDungeonGenerator.FillEffect,java.lang.Integer> fx)
public long getRebuildSeed()
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © Eben Howard 2012–2022. All rights reserved.