public class DungeonGenerator extends java.lang.Object implements IDungeonGenerator
Modifier and Type | Class and Description |
---|---|
static class |
DungeonGenerator.FillEffect
The effects that can be applied to this dungeon.
|
Modifier and Type | Field and Description |
---|---|
protected char[][] |
dungeon |
java.util.EnumMap<DungeonGenerator.FillEffect,java.lang.Integer> |
fx
The effects that will be applied when generate is called.
|
protected DungeonBoneGen |
gen |
protected int |
height |
boolean |
markStairsDown |
boolean |
markStairsUp |
protected long |
rebuildSeed |
IStatefulRNG |
rng |
protected boolean |
seedFixed |
Coord |
stairsDown |
Coord |
stairsUp |
DungeonUtility |
utility |
protected int |
width |
Constructor and Description |
---|
DungeonGenerator()
Make a DungeonGenerator with a GWTRNG using a random seed, height 40, and width 40.
|
DungeonGenerator(DungeonGenerator copying)
Copies all fields from copying and makes a new DungeonGenerator.
|
DungeonGenerator(int width,
int height)
Make a DungeonGenerator with the given height and width; a GWTRNG will be used for generating a dungeon and
adding features using a random seed.
|
DungeonGenerator(int width,
int height,
IRNG rng)
Make a DungeonGenerator with the given height, width, and RNG.
|
Modifier and Type | Method and Description |
---|---|
DungeonGenerator |
addBoulders(int percentage)
Turns the given percentage of floor cells not already adjacent to walls into wall cells, represented by '#'.
|
DungeonGenerator |
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.
|
DungeonGenerator |
addGrass(int percentage)
Turns the majority of the given percentage of floor cells into grass cells, represented by '"'.
|
DungeonGenerator |
addStairs()
Enables drawing stairs up, as '<', and stairs down, as '>', when a map is generated.
|
DungeonGenerator |
addStairs(boolean up,
boolean down)
Potentially enables drawing stairs up, as '<', and stairs down, as '>', when a map is generated.
|
DungeonGenerator |
addTraps(int percentage)
Turns the given percentage of open area floor cells into trap cells, represented by '^'.
|
DungeonGenerator |
addWater(int percentage)
Turns the majority of the given percentage of floor cells into water cells, represented by '~'.
|
DungeonGenerator |
addWater(int percentage,
int islandSpacing)
Turns the majority of the given percentage of floor cells into water cells, represented by '~'.
|
DungeonGenerator |
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)
Generate a char[][] dungeon with extra features given a baseDungeon that has already been generated.
|
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)
Generate a char[][] dungeon with extra features given a baseDungeon that has already been generated, and that
already has staircases represented by greater than and less than signs.
|
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 OrderedSet<Coord> |
removeAdjacent(OrderedSet<Coord> coll,
Coord pt) |
protected OrderedSet<Coord> |
removeAdjacent(OrderedSet<Coord> coll,
Coord pt1,
Coord pt2) |
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) |
public java.util.EnumMap<DungeonGenerator.FillEffect,java.lang.Integer> fx
protected DungeonBoneGen gen
public DungeonUtility utility
protected int height
protected int width
public Coord stairsUp
public Coord stairsDown
public boolean markStairsUp
public boolean markStairsDown
public IStatefulRNG rng
protected long rebuildSeed
protected boolean seedFixed
protected char[][] dungeon
public DungeonGenerator()
public DungeonGenerator(int width, int height)
width
- The width of the dungeon in cellsheight
- The height of the dungeon in cellspublic DungeonGenerator(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 DungeonGenerator(DungeonGenerator 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 DungeonGenerator addWater(int percentage)
percentage
- the percentage of floor cells to fill with waterpublic DungeonGenerator addWater(int percentage, int islandSpacing)
percentage
- the percentage of floor cells to fill with waterislandSpacing
- if greater than 1, islands will be placed randomly this many cells apart.public DungeonGenerator addGrass(int percentage)
percentage
- the percentage of floor cells to fill with grasspublic DungeonGenerator addBoulders(int percentage)
percentage
- the percentage of floor cells not adjacent to walls to fill with boulders.public DungeonGenerator 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 DungeonGenerator addTraps(int percentage)
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 DungeonGenerator addStairs()
public DungeonGenerator 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 DungeonGenerator clearEffects()
protected OrderedSet<Coord> removeAdjacent(OrderedSet<Coord> coll, Coord pt)
protected OrderedSet<Coord> removeAdjacent(OrderedSet<Coord> coll, Coord pt1, Coord pt2)
protected OrderedSet<Coord> viableDoorways(boolean doubleDoors, char[][] map)
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)
DungeonUtility.ensurePath(dungeon, rng, '\t', '#');
then
passing dungeon (which that code modifies) in as baseDungeon to this method.baseDungeon
- a pre-made dungeon consisting of '#' for walls and '.' for floors; may be modified in-placepublic char[][] generateRespectingStairs(char[][] baseDungeon)
baseDungeon
- a pre-made dungeon consisting of '#' for walls and '.' for floors, with stairs already in;
may be modified in-placepublic long getRebuildSeed()
public java.lang.String toString()
toString
in class java.lang.Object
Copyright © Eben Howard 2012–2022. All rights reserved.