|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wyvern.kernel.properties.PList wyvern.kernel.maps.AbstractGameMap wyvern.kernel.maps.DenseMap
This is the standard Wyvern implementation of the GameMap interface. It uses a 2D array of wyvern.kernel.maps.Cell objects, each of which holds one Terrain and zero or more GameObjects.
Nested Class Summary |
Nested classes inherited from class wyvern.lib.GameMap |
GameMap.UnloadMapConstants |
Field Summary | |
protected java.util.ArrayList |
addRemoveListeners_
This is instantiated lazily, when someone calls registerAddRemoveListener(). |
protected Rectangle |
cachedBounds_
|
protected int |
count_
Keeps track of the count of objects in the map. |
protected int[][] |
lighting_
The global light-intensity array for the map. |
protected MapCell[][] |
objects_
|
protected Terrain |
outOfBoundsTerrain_
Terrain to use outside the valid bounds of the map. |
protected Dimension |
size_
|
Fields inherited from class wyvern.kernel.maps.AbstractGameMap |
ambient_, changeList_, commands_, dark_, defaultTerrain_, dense_, dirtyRegions_, lights_, locals_, mapHooks_, monsters_, name_, opaqueMap_, path_, perPlayer_, players_, proxHooks_, roomHooks_, suspended_, suspendTime_, suspendTimer_, teleporters_, unloadImmediately_, unloading_, visUpdates_, vpath_ |
Fields inherited from class wyvern.kernel.properties.PList |
readOnly_ |
Fields inherited from interface wyvern.lib.GameMap |
MAX_HEIGHT, MAX_SEARCH_RADIUS, MAX_WIDTH |
Fields inherited from interface wyvern.lib.PropertyList |
PROPERTY_PACKAGE |
Fields inherited from interface wyvern.lib.GameMap.UnloadMapConstants |
MAP_CONTAINS_PLAYERS, MAP_NOT_LOADED, SUCCESS |
Constructor Summary | |
DenseMap()
Constructs a new DenseMap with no width or height. |
|
DenseMap(Dimension size)
Constructs a new DenseMap |
|
DenseMap(int width,
int height)
Constructs a new DenseMap |
Method Summary | |
void |
add(int x,
int y,
GameObject obj)
Adds the specified object to the map at the specified location. |
void |
add(int x,
int y,
GameObject obj,
boolean invalidate)
Adds specified object, optionally invalidating. |
protected void |
addIntensityArray(int x,
int y,
int[][] array,
boolean add)
Adds or subtracts the contribution from a single LightSource into the map's internal lighting array. |
void |
adjustIntensity(int x,
int y,
int intensity)
Manually adjusts the light intensity by a fixed amount at the passed (x, y) location. |
protected boolean |
checkBounds(int x,
int y)
Makes sure the passed point lies in our bounds. |
protected boolean |
checkBounds(int x,
int y,
int w,
int h)
Checks to make sure rectangle is contained within our bounds. |
protected void |
createLightMatrix()
Creates and initializes the ambient-lighting matrix. |
int |
dismantle()
Unloads the map. |
Rectangle |
getBounds()
Returns the bounds of the map. |
int |
getLightLevel(int x,
int y)
Returns the lighting level at the specified location. |
int |
getObjectCount()
Returns an approximate count of the object references currently in this map. |
protected Cell |
getOrCreatecell(int x,
int y)
Returns the Cell at (x, y), creating it if necessary. |
Terrain |
getOutOfBoundsTerrain()
Returns what we use for the out-of-bounds terrain. |
PropertyList |
getProperties(int x,
int y)
You can get and set properties on a specific map location. |
PropertyList |
getPropertyList(int x,
int y)
Returns the property list for the given (x, y) map location, creating the list if necessary. |
Dimension |
getSize()
Returns the size of the map. |
void |
initialize(Dimension size)
Initializes the map to the specified width and height. |
void |
initialize(int width,
int height)
Initializes the map to the specified width and height. |
boolean |
isSparse()
Returns true if this map implementation is sparse. |
protected java.util.Iterator |
iterator(int x,
int y)
Returns Iterator on objects at (x, y); |
java.util.Set |
keySet()
Returns the set of nonempty points in this map. |
protected java.util.List |
objectsAt(int x,
int y)
Returns the actual list of objects at (x, y). |
protected java.util.Iterator |
objectsInRect(int x,
int y,
int w,
int h)
Implements GameMap.objectsInRect. |
void |
registerAddRemoveListener(MapAddRemoveListener listener)
Registers a listener for adding/removing objects. |
void |
remove(int x,
int y,
GameObject obj)
Removes an object from the map at the specified location. |
void |
remove(int x,
int y,
GameObject obj,
boolean inval)
Removes an object at the specified map location (x, y). |
void |
setOutOfBoundsTerrain(java.lang.String terrain)
Sets the terrain to use outside the valid map bounds. |
void |
setOutOfBoundsTerrain(Terrain t)
Sets the terrain to use outside the valid map bounds. |
void |
setSize(Dimension new_size)
Changes the size of the map. |
void |
setTerrain(int x,
int y,
Terrain t)
Sets the terrain for this map location. |
Terrain |
terrainAt(int x,
int y)
Implements GameMap.terrainAt() |
void |
unregisterAddRemoveListener(MapAddRemoveListener listener)
Unregisters a listener for adding/removing objects. |
void |
visitRect(int x,
int y,
int w,
int h,
Visitor v)
Visits all objects in a rectangle. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected Dimension size_
protected MapCell[][] objects_
protected int[][] lighting_
protected Terrain outOfBoundsTerrain_
protected Rectangle cachedBounds_
protected int count_
protected java.util.ArrayList addRemoveListeners_
Constructor Detail |
public DenseMap()
public DenseMap(int width, int height)
width
- the map widthheight
- the map heightpublic DenseMap(Dimension size)
size
- the map sizeMethod Detail |
public void initialize(int width, int height)
width
- map widthheight
- map widthpublic void initialize(Dimension size)
size
- the size for the map
java.lang.IllegalStateException
- if the map has already
been initializedprotected void createLightMatrix()
public Terrain terrainAt(int x, int y)
x
- map x locationy
- map y location
GameMap.terrainAt(int, int)
public void visitRect(int x, int y, int w, int h, Visitor v)
x
- left edgey
- top edgew
- rect widthh
- rect heightv
- the Visitor to inflict on the objectsVisitor
public void add(int x, int y, GameObject obj)
add
in interface GameMap
add
in class AbstractGameMap
x
- map x locationy
- map y locationobj
- the object to addpublic void add(int x, int y, GameObject obj, boolean invalidate)
x
- map x locationy
- map y locationobj
- the object to addinvalidate
- true to invalidate map on object's boundspublic void remove(int x, int y, GameObject obj)
remove
in interface GameMap
remove
in class AbstractGameMap
x
- map x locationy
- map y locationobj
- the object reference to remove. Does nothing if
the specified obj reference isn't found at (x, y).public void remove(int x, int y, GameObject obj, boolean inval)
x
- map x locationy
- map y locationobj
- the object reference to remove. Does nothing if
the specified obj reference isn't found at (x, y).inval
- true to invalidate on object's boundspublic void setTerrain(int x, int y, Terrain t)
setTerrain
in interface GameMap
setTerrain
in class AbstractGameMap
x
- map x locationy
- map y locationt
- Terrain to put thereprotected void addIntensityArray(int x, int y, int[][] array, boolean add)
addIntensityArray
in class AbstractGameMap
x
- the x location at which to apply the arrayy
- the y location at which to apply the arrayarray
- the array to apply. The light source is typically
centered in the array, but this method doesn't do any
coordinate translation. If you pass (x=3, y=3) and an array
where (width=5, height=5), the lighting will be updated in
the map from locations (3, 3) to (8, 8).add
- true to add the array; false to subtract itpublic void adjustIntensity(int x, int y, int intensity)
adjustIntensity
in interface GameMap
adjustIntensity
in class AbstractGameMap
x
- the x location to adjusty
- the y location to adjustintensity
- the +/- amount by which to adjust the lighting levelpublic int getLightLevel(int x, int y)
getLightLevel
in interface GameMap
getLightLevel
in class AbstractGameMap
x
- map x locationy
- map y location
public Dimension getSize()
public void setSize(Dimension new_size)
new_size
- the size for the map
java.lang.IllegalStateException
- if you call it from
outside the map editor code.public Rectangle getBounds()
public final boolean isSparse()
public void setOutOfBoundsTerrain(Terrain t)
public Terrain getOutOfBoundsTerrain()
public void setOutOfBoundsTerrain(java.lang.String terrain) throws java.lang.Exception
java.lang.Exception
protected java.util.Iterator objectsInRect(int x, int y, int w, int h)
Special Note: this will NOT return any Terrain objects; they must be enumerated separately.
objectsInRect
in class AbstractGameMap
x
- rect xy
- rect yw
- rect widthh
- rect height
protected java.util.Iterator iterator(int x, int y)
iterator
in class AbstractGameMap
x
- map xy
- map y
protected java.util.List objectsAt(int x, int y)
objectsAt
in class AbstractGameMap
protected boolean checkBounds(int x, int y)
x
- map xy
- map y
protected boolean checkBounds(int x, int y, int w, int h)
x
- rect xy
- rect yw
- rect widthh
- rect height
protected Cell getOrCreatecell(int x, int y)
public java.util.Set keySet()
public int dismantle()
dismantle
in interface GameMap
dismantle
in class AbstractGameMap
public int getObjectCount()
public void registerAddRemoveListener(MapAddRemoveListener listener)
listener
- the listenerpublic void unregisterAddRemoveListener(MapAddRemoveListener listener)
listener
- the MapAddRemoveListenerpublic PropertyList getProperties(int x, int y)
This can be handy, for example, if you want to do a very fast check to see if a particular kind of object is at some location (x, y). The object should set a property on the cell saying that it's there, and then others can look for that property. It's faster than going through all the objects at (x, y), checking each one to see if it's the type you're looking for.
x
- map x locationy
- map y location
public PropertyList getPropertyList(int x, int y)
You call this method if you're about to set a property in the list. It creates an empty PropertyList for this map location, if nobody has set any properties at that (x, y) yet.
PLEASE don't call this if you're just checking to see if a location has a certain property. Only call it if you're going to set or adjust a property value for the location.
x
- map x locationy
- map y location
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |