public class Spill
extends java.lang.Object
implements java.io.Serializable
Modifier and Type | Field and Description |
---|---|
int |
filled
The amount of cells filled by this Spill, which may be less than the volume passed to start() if the boundaries
are reached on all sides and the Spill has no more room to fill.
|
int |
height
Height of the map.
|
Measurement |
measurement
This affects how distance is measured on diagonal directions vs.
|
boolean[][] |
physicalMap
Stores which parts of the map are accessible (with a value of true) and which are not (with a value of false,
including both walls and unreachable sections of the map).
|
IStatefulRNG |
rng
The IStatefulRNG used to decide which one of multiple equally-short paths to take.
|
boolean[][] |
spillMap
The cells that are filled by the Spill when it reaches its volume or limits will be true; others will be false.
|
java.util.ArrayList<Coord> |
spreadPattern
The list of points that the Spill will randomly fill, starting with what is passed to start(), in order of when
they are reached.
|
int |
width
Width of the map.
|
Constructor and Description |
---|
Spill()
Construct a Spill without a level to actually scan.
|
Spill(boolean[][] level)
Used to construct a Spill from the output of another.
|
Spill(boolean[][] level,
Measurement measurement)
Used to construct a Spill from the output of another, specifying a distance calculation.
|
Spill(char[][] level)
Constructor meant to take a char[][] returned by
IDungeonGenerator.generate() , or any other
char[][] where '#' means a wall and anything else is a walkable tile. |
Spill(char[][] level,
char alternateWall)
Constructor meant to take a char[][] returned by DungeonBoneGen.generate(), or any other
char[][] where one char means a wall and anything else is a walkable tile.
|
Spill(char[][] level,
Measurement measurement)
Constructor meant to take a char[][] returned by DungeonBoneGen.generate(), or any other
char[][] where '#' means a wall and anything else is a walkable tile.
|
Spill(char[][] level,
Measurement measurement,
IRNG random)
Constructor meant to take a char[][] returned by DungeonBoneGen.generate(), or any other
char[][] where '#' means a wall and anything else is a walkable tile.
|
Spill(char[][] level,
Measurement measurement,
IStatefulRNG random)
Constructor meant to take a char[][] returned by DungeonBoneGen.generate(), or any other
char[][] where '#' means a wall and anything else is a walkable tile.
|
Spill(IRNG random)
Construct a Spill without a level to actually scan.
|
Spill(IStatefulRNG random)
Construct a Spill without a level to actually scan.
|
Modifier and Type | Method and Description |
---|---|
Spill |
initialize(boolean[][] level)
Used to initialize or re-initialize a Spill that needs a new PhysicalMap because it either wasn't given
one when it was constructed, or because the contents of the terrain have changed permanently.
|
Spill |
initialize(char[][] level)
Used to initialize or re-initialize a Spill that needs a new PhysicalMap because it either wasn't given
one when it was constructed, or because the contents of the terrain have changed permanently.
|
Spill |
initialize(char[][] level,
char alternateWall)
Used to initialize or re-initialize a Spill that needs a new PhysicalMap because it either wasn't given
one when it was constructed, or because the contents of the terrain have changed permanently.
|
void |
reset()
Resets this Spill to a state with an empty spillMap and an empty spreadPattern.
|
void |
resetCell(Coord pt)
Reverts a cell to an unfilled state (false in spillMap).
|
void |
resetCell(int x,
int y)
Reverts a cell to an unfilled state (false in spillMap).
|
void |
resetMap()
Resets the spillMap to being empty.
|
protected void |
setFresh(Coord pt)
Used internally to mark a cell as just-now being expanded from.
|
protected void |
setFresh(int x,
int y)
Used internally to mark a cell as just-now being expanded from.
|
java.util.ArrayList<Coord> |
start(Coord entry,
int volume,
java.util.Collection<Coord> impassable)
Recalculate the spillMap and return the spreadPattern.
|
public Measurement measurement
public boolean[][] physicalMap
public boolean[][] spillMap
public java.util.ArrayList<Coord> spreadPattern
public int height
public int width
public int filled
public IStatefulRNG rng
GWTRNG
or StatefulRNG
.public Spill()
public Spill(IRNG random)
public Spill(IStatefulRNG random)
StatefulRNG
or GWTRNG
, which will be referenced in this class (if the state of random changes
because this object needed a random number, the state change will be reflected in the code that passed random to
here). If you use this constructor, you must call an initialize() method before using this class.public Spill(boolean[][] level)
level
- the level as a 2D rectangular boolean array, using false
to represent wallspublic Spill(boolean[][] level, Measurement measurement)
level
- the level as a 2D rectangular boolean array, using false
to represent wallsmeasurement
- a Measurement
enum; usually Measurement.MANHATTAN
is idealpublic Spill(char[][] level)
IDungeonGenerator.generate()
, or any other
char[][] where '#' means a wall and anything else is a walkable tile. If you only have
a map that uses box-drawing characters, use DungeonUtility.linesToHashes() to get a
map that can be used here.level
- the level as a 2D rectangular char array, using '#'
to represent wallspublic Spill(char[][] level, char alternateWall)
level
- the level as a 2D rectangular char array, using alternateWall
to represent wallsalternateWall
- the char that will be interpreted as a wall in level
public Spill(char[][] level, Measurement measurement)
level
- the level as a 2D rectangular char array, using '#'
to represent wallsmeasurement
- a Measurement
enum; usually Measurement.MANHATTAN
is idealpublic Spill(char[][] level, Measurement measurement, IRNG random)
level
- the level as a 2D rectangular char array, using '#'
to represent wallsmeasurement
- a Measurement
enum; usually Measurement.MANHATTAN
is idealpublic Spill(char[][] level, Measurement measurement, IStatefulRNG random)
level
- the level as a 2D rectangular char array, using '#'
to represent wallsmeasurement
- a Measurement
enum; usually Measurement.MANHATTAN
is idealpublic Spill initialize(boolean[][] level)
level
- the level as a 2D rectangular boolean array, using false
to represent wallspublic Spill initialize(char[][] level)
level
- the level as a 2D rectangular char array, using '#'
to represent wallspublic Spill initialize(char[][] level, char alternateWall)
'#'
.level
- the level as a 2D rectangular char array, using alternateWall
to represent wallsalternateWall
- the char that will be interpreted as a wall in level
public void resetMap()
public void reset()
public void resetCell(int x, int y)
x
- the x position of the cell to resety
- the y position of the cell to resetpublic void resetCell(Coord pt)
pt
- the position of the cell to resetprotected void setFresh(int x, int y)
x
- the x position of the cell to resety
- the y position of the cell to resetprotected void setFresh(Coord pt)
pt
- the position of the cell to resetpublic java.util.ArrayList<Coord> start(Coord entry, int volume, java.util.Collection<Coord> impassable)
entry
- The first cell to spread from, which should really be passable.volume
- The total number of cells to attempt to fill, which must be non-negative.impassable
- A Set or other Collection of Coord keys representing the locations of moving obstacles to a
path that cannot be moved through; this can be null if there are no such obstacles.Copyright © Eben Howard 2012–2022. All rights reserved.