public class SoundMap
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
OrderedMap<Coord,java.lang.Double> |
alerted
The latest results of findAlerted(), with Coord keys representing the positions of creatures that were alerted
and Double values representing how loud the sound was when it reached them.
|
double[][] |
gradientMap
The frequently-changing values that are often the point of using this class; cells producing sound will have a
value greater than 0, cells that cannot possibly be reached by a sound will have a value of exactly 0, and walls
will have a value equal to the WALL constant (a negative number).
|
int |
height
Height of the map.
|
Measurement |
measurement
This affects how sound travels on diagonal directions vs.
|
double[][] |
physicalMap
Stores which parts of the map are accessible and which are not.
|
static double |
SILENT
Cells with no sound are always marked with 0.
|
OrderedMap<Coord,java.lang.Double> |
sounds
Sources of sound on the map; keys are positions, values are how loud the noise is (10.0 should spread 10 cells
away, with diminishing values assigned to further positions).
|
static double |
WALL
Walls, which are solid no-entry cells, are marked with a significant negative number equal to -999500.0 .
|
int |
width
Width of the map.
|
Constructor and Description |
---|
SoundMap()
Construct a SoundMap without a level to actually scan.
|
SoundMap(char[][] level)
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.
|
SoundMap(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.
|
SoundMap(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.
|
SoundMap(double[][] level)
Used to construct a SoundMap from the output of another.
|
SoundMap(double[][] level,
Measurement measurement)
Used to construct a DijkstraMap from the output of another, specifying a distance calculation.
|
Modifier and Type | Method and Description |
---|---|
void |
clearSounds()
Used to remove all sounds.
|
OrderedMap<Coord,java.lang.Double> |
findAlerted(java.util.Set<Coord> creatures,
java.util.Map<Coord,java.lang.Double> extraSounds)
Scans the dungeon using SoundMap.scan(), adding any positions in extraSounds to the group of known sounds before
scanning.
|
SoundMap |
initialize(char[][] level)
Used to initialize or re-initialize a SoundMap 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.
|
SoundMap |
initialize(char[][] level,
char alternateWall)
Used to initialize or re-initialize a SoundMap 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.
|
SoundMap |
initialize(double[][] level)
Used to initialize or re-initialize a SoundMap 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 |
removeSound(Coord pt)
If a sound is being produced at a given location (a Coord), this removes it.
|
void |
removeSound(int x,
int y)
If a sound is being produced at a given (x, y) location, this removes it.
|
void |
reset()
Resets this SoundMap to a state with no sounds, no alerted creatures, and no changes made to gradientMap
relative to physicalMap.
|
void |
resetCell(Coord pt)
Reverts a cell to the value stored in the original state of the level as known by physicalMap.
|
void |
resetCell(int x,
int y)
Reverts a cell to the value stored in the original state of the level as known by physicalMap.
|
void |
resetMap()
Resets the gradientMap to its original value from physicalMap.
|
double[][] |
scan()
Recalculate the sound map and return it.
|
protected void |
setFresh(Coord pt,
double counter) |
protected void |
setFresh(int x,
int y,
double counter) |
void |
setOccupied(int x,
int y)
Marks a specific cell in gradientMap as a wall, which makes sounds potentially unable to pass through it.
|
void |
setSound(Coord pt,
double loudness)
Marks a cell as producing a sound with the given loudness; this can be placed on a wall or unreachable area,
but that may cause the sound to be un-hear-able.
|
void |
setSound(int x,
int y,
double loudness)
Marks a cell as producing a sound with the given loudness; this can be placed on a wall or unreachable area,
but that may cause the sound to be un-hear-able.
|
public Measurement measurement
public double[][] physicalMap
public double[][] gradientMap
public int height
public int width
public OrderedMap<Coord,java.lang.Double> alerted
public static final double SILENT
public static final double WALL
public OrderedMap<Coord,java.lang.Double> sounds
public SoundMap()
public SoundMap(double[][] level)
level
- public SoundMap(double[][] level, Measurement measurement)
level
- measurement
- public SoundMap(char[][] level)
level
- public SoundMap(char[][] level, char alternateWall)
level
- public SoundMap(char[][] level, Measurement measurement)
level
- measurement
- public SoundMap initialize(double[][] level)
level
- public SoundMap initialize(char[][] level)
level
- public SoundMap initialize(char[][] level, char alternateWall)
level
- alternateWall
- public void resetMap()
public void reset()
public void setSound(int x, int y, double loudness)
x
- y
- loudness
- The number of cells the sound should spread away using the current measurement.public void setSound(Coord pt, double loudness)
pt
- loudness
- The number of cells the sound should spread away using the current measurement.public void removeSound(int x, int y)
x
- y
- public void removeSound(Coord pt)
pt
- public void setOccupied(int x, int y)
x
- y
- public void resetCell(int x, int y)
x
- y
- public void resetCell(Coord pt)
pt
- public void clearSounds()
protected void setFresh(int x, int y, double counter)
protected void setFresh(Coord pt, double counter)
public double[][] scan()
public OrderedMap<Coord,java.lang.Double> findAlerted(java.util.Set<Coord> creatures, java.util.Map<Coord,java.lang.Double> extraSounds)
creatures
- extraSounds
- Copyright © Eben Howard 2012–2022. All rights reserved.