public class Splash extends Object
Spill
, whose purpose is to have a simpler API. You
can specify the characters that are impassable (in other words: that should
not be spilled on) using addImpassableChar(char)
and
removeImpassableChar(char)
. By default the set of impassable characters
is '#'
.An alternative implementation of spilling.
Modifier and Type | Field and Description |
---|---|
protected Set<Character> |
impassable |
Constructor and Description |
---|
Splash()
A fresh instance, whose only impassable character is '#'.
|
Splash(Set<Character> blocked)
A fresh instance, adding the chars in blocked to the set of impassable characters,
then also adding '#' if it isn't present.
|
Modifier and Type | Method and Description |
---|---|
void |
addImpassableChar(char c)
Adds
c to the set of impassable characters. |
protected boolean |
passable(char c) |
boolean |
removeImpassableChar(char c)
Removes
c from the set of impassable characters. |
List<Coord> |
spill(RNG rng,
char[][] level,
Coord start,
int volume) |
static List<Coord> |
spill(RNG rng,
char[][] level,
Coord start,
int volume,
Set<Character> impassable) |
protected final Set<Character> impassable
public Splash()
public Splash(Set<Character> blocked)
removeImpassableChar(char)
if you use '#' to mean something non-blocking.public void addImpassableChar(char c)
c
to the set of impassable characters.c
- The character to add.public boolean removeImpassableChar(char c)
c
from the set of impassable characters.c
- The character to remove.public List<Coord> spill(RNG rng, char[][] level, Coord start, int volume)
rng
- used to randomize the floodfilllevel
- char 2D array with x, y indices for the dungeon/map levelstart
- Where the spill should start. It should be passable, otherwise
an empty list gets returned. Consider using
DungeonUtility.getRandomCell(RNG, char[][], Set, int)
to find it.volume
- The number of cells to spill on.start
)
valid in level
that are all adjacent and whose symbol is
passable. If non-empty, this is guaranteed to be an
ArrayList
.protected boolean passable(char c)
public static List<Coord> spill(RNG rng, char[][] level, Coord start, int volume, Set<Character> impassable)
rng
- used to randomize the floodfilllevel
- char 2D array with x, y indices for the dungeon/map levelstart
- Where the spill should start. It should be passable, otherwise
an empty list gets returned. Consider using
DungeonUtility.getRandomCell(RNG, char[][], Set, int)
to find it.volume
- The number of cells to spill on.impassable
- the set of chars on the level that block the spill, such
as walls or maybe other spilled things (oil and water).
May be null, which makes this treat '#' as impassable.start
)
valid in level
that are all adjacent and whose symbol is
passable. If non-empty, this is guaranteed to be an
ArrayList
.Copyright © 2012–2016. All rights reserved.