|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectwyvern.kernel.properties.PList
wyvern.kernel.maps.AbstractGameMap
This class implements those common utility methods from the GameMap interface that can be implemented without needing to know the underlying representation. It is not a requirement for GameMap implementations to extend this class, but it's highly recommended - it handles a lot of stuff.
| Nested Class Summary |
| Nested classes inherited from class wyvern.lib.GameMap |
GameMap.UnloadMapConstants |
| Field Summary | |
protected int |
ambient_
|
protected BitMatrix |
changeList_
|
protected MapCommandList |
commands_
|
protected boolean |
dark_
|
protected Terrain |
defaultTerrain_
|
protected int |
dense_
|
protected MapDirtyRegions |
dirtyRegions_
|
protected wyvern.kernel.data.MultiHashMap |
lights_
|
protected java.util.HashMap |
locals_
|
protected HookList |
mapHooks_
|
protected java.util.Set |
monsters_
|
protected java.lang.String |
name_
|
protected BitMatrix |
opaqueMap_
|
protected java.lang.String |
path_
|
protected java.lang.String |
perPlayer_
|
protected java.util.Set |
players_
|
protected ProximityHookList |
proxHooks_
|
protected RoomHookList |
roomHooks_
|
protected boolean |
suspended_
|
protected int |
suspendTime_
|
protected wyvern.kernel.maps.SuspendTimer |
suspendTimer_
|
protected java.util.Set |
teleporters_
|
protected boolean |
unloadImmediately_
|
protected boolean |
unloading_
|
protected boolean |
visUpdates_
|
protected java.lang.String |
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 | |
AbstractGameMap()
|
|
| Method Summary | |
void |
add(int x,
int y,
GameObject obj)
Adds the specified object to the map at the specified location. |
void |
addHook(HookCallback callback,
java.lang.String hookName)
Registers a HookCallback object for the specified hook. |
protected abstract void |
addIntensityArray(int x,
int y,
int[][] array,
boolean add)
Calls the subclass to merge in (add or subtract) the contribution from a single LightSource into the subclass's internal lighting array. |
void |
addLight(int x,
int y,
LightSource light)
Adds a light source to the map. |
void |
addLocalArchetype(Archetype arch)
Adds a local archetype to this map. |
void |
addMapLifecycleListener(MapLifecycleListener l)
Registers with the map to be notified whenever it loads, unloads, suspends, or resumes. |
void |
addMethodHook(MethodHookCallback callback,
java.lang.String methodName)
Registers for the specified method-hook. |
protected void |
addMonster(Monster mon)
Called whenever a non-Player Monster is added to the map. |
protected void |
addPlayer(Player p)
Called whenever a Player is added to the map. |
void |
addPlayerListener(MapPlayerListener listener)
Registers with the map to be notified whenever players enter or leave the map, or move within the map. |
void |
addPropertyChangeListener(java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener to the listener list. |
void |
addPropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener listener)
Adds a PropertyChangeListener for a specific property. |
void |
addProximityHook(ProximityCallback callback,
java.lang.String hookName,
GameObject target,
Rectangle range)
Registers for hook notifications for events occurring within a fixed range of a given object. |
void |
addRoomHook(RoomHookCallback callback,
java.lang.String hookName,
Rectangle room)
Registers for a specific area of interest in the map. |
protected void |
addTeleporter(Teleporter t)
Called whenever a teleporter is added to the map. |
abstract void |
adjustIntensity(int x,
int y,
int intensity)
Manually adjusts the light intensity by a fixed amount at the passed (x, y) location. |
void |
broadcast(java.lang.String msg)
Broadcasts a message to every player in the map. |
void |
broadcast(java.lang.String msg,
byte style)
Broadcasts a message to every player in the map. |
int |
dismantle()
Do NOT call this method - use World.unloadMap(mapname) instead, unless you have created the map yourself without registering it with the World. |
void |
doneLoading()
Notification from the MapLoader that we've finished adding objects to the map. |
void |
enableVisUpdates(boolean enable)
While the map is being loaded; that is, while objects are initially being added to it, turning off visual updates will improve the load time. |
GameObject |
findAt(int x,
int y,
Predicate p)
Looks for an object at the passed map location that passes the specified Predicate. |
GameObject |
findAt(int x,
int y,
java.lang.String name)
|
GameObject |
findAt(Point loc,
Predicate p)
|
GameObject |
findAt(Point loc,
java.lang.String name)
|
GameObject |
findByName(int x,
int y,
java.lang.String name)
Finds the first object at the specified location that matches the passed name, using a standard NameMatchPredicate. |
GameObject |
findByName(Point p,
java.lang.String name)
Returns the topmost visible object at the passed location. |
Point |
findFreeSpot(int x,
int y,
GameObject obj)
|
Point |
findFreeSpot(Point request,
GameObject obj)
Tries to find a free spot to put this object in. |
GameObject |
findInRect(int x,
int y,
int w,
int h,
Predicate p)
Searches the objects in the specified rectangle and returns the first one that satisfies the passed Predicate. |
GameObject |
findTop(int x,
int y)
Returns the "topmost" object at this location. |
GameObject |
findTop(int x,
int y,
Predicate p)
Returns the topmost object at the specified location that passes a specified predicate. |
GameObject |
findTop(Point p)
|
GameObject |
findUnder(GameObject obj,
Predicate filter)
Looks under the passed GameObject's locations for an object that matches the passed Predicate. |
protected void |
fireMapLoaded()
|
protected void |
fireMapResumed()
|
protected void |
fireMapSuspended()
|
protected void |
fireMapUnloaded()
|
void |
firePropertyChange(java.beans.PropertyChangeEvent evt)
Fires an existing PropertyChangeEvent to any registered listeners. |
void |
firePropertyChange(java.lang.String propertyName,
boolean oldValue,
boolean newValue)
Reports a boolean bound property update to any registered listeners. |
void |
firePropertyChange(java.lang.String propertyName,
int oldValue,
int newValue)
Reports an int bound property update to any registered listeners. |
void |
firePropertyChange(java.lang.String propertyName,
java.lang.Object oldValue,
java.lang.Object newValue)
Reports a bound property update to any registered listeners. |
Area |
getArea()
Returns the parent Area for this map. |
Player |
getClaim()
Returns the player currently claiming the map, if any. |
Command |
getCommand(CommandEvent event,
Commandable agent)
Checks the list of Commands who have registered this command with the map, and returns the first one whose rectangle of interest contains the agent issuing the command. |
int |
getDangerLevel()
Returns the danger level for this map. |
Terrain |
getDefaultTerrain()
Returns the default terrain for this map. |
java.util.Set |
getExits()
Returns the set of all teleporters in this map that happen to have destinations - even if the teleporter's destination is to another point in this map. |
java.util.Map |
getFavorites()
Returns the set of favorite archetypes for this map, for use in the map editor. |
HookList |
getHookList()
Returns the HookList containing the registered hooks for this object. |
java.lang.String[] |
getHooks()
Returns a list of custom hooks implemented by this object. |
int |
getLightingLevel()
Returns the lighting level of this map. |
int |
getLightLevel(int x,
int y)
Returns the lighting level at the specified location. |
Archetype |
getLocalArchetype(java.lang.String name)
Retrieves a local archetype from the map's cache. |
java.util.List |
getLocalArchetypes()
Returns a list of the names of all local archetypes registered with this map. |
java.util.Set |
getMonsterList()
Returns the set of monsters currently active in this map. |
Music |
getMusic()
Returns the background music for this map. |
java.lang.String |
getName()
Returns the name of this map. |
java.util.List |
getObjectsAt(int x,
int y)
Returns a list of the objects at a location. |
java.lang.String |
getPath()
Returns the (relative) path to the map file this map was loaded from, e.g. |
java.util.Set |
getPlayerList()
Returns the set of players currently playing in this map. |
static java.lang.String |
getProfilingInfo()
Returns profiling string. |
java.beans.PropertyChangeListener[] |
getPropertyChangeListeners()
Returns an array of all the PropertyChangeListeners added to this map with addPropertyChangeListener(); |
java.beans.PropertyChangeListener[] |
getPropertyChangeListeners(java.lang.String propertyName)
Returns an array of all the listeners which have been associated with the named property. |
ProximityHookList |
getProximityHookList()
Returns the ProximityHookList containing the registered proximity-hooks for this map. |
Resource |
getResource()
Returns the Resource for this map, so you can query if it's a wiz map, how big it is, what the relative file path is, and so on. |
Location |
getRestartLoc()
Returns the restart-location for this map: where players teleport to when they die in this map. |
RoomHookList |
getRoomHookList()
Returns the RoomHookList containing the registered room-hooks for this map. |
Point |
getStartLocation()
Returns the default starting location for the map. |
int |
getSuspendTime()
Returns the length of time, in milliseconds, since this map was suspended. |
int[][] |
getTerrainInfo(int x,
int y,
int w,
int h)
Returns enough information about the terrain in the passed rectangle to be able to draw the terrain (with borders) in a client program. |
int |
getTerrainRecord(int x,
int y)
Returns a packed record describing the terrain at (x, y), suitable for use in drawing terrain borders. |
int |
getTerrainRecord(int x,
int y,
boolean useCache)
Retrieves a terrain record, either by going out and building it, or by looking in the cache. |
int |
getUnloadDelay()
Returns the time, in milliseconds, that we'll wait, after we suspend, before unloading the map. |
MapDirtyRegions |
getUpdateList()
Returns a list of updates that have occurred since the last query. |
java.lang.String |
getVirtualPath()
This is exactly the same as getPath() normal maps, but returns "players/whoever/" + getPath() for per-player maps. |
boolean |
hasListeners(java.lang.String propertyName)
Checks if there are any listeners for a specific property. |
boolean |
hasObstructions(int x,
int y,
int w,
int h)
|
void |
initCommon()
Common initialization for construction & deserialization. |
boolean |
inMapEditor()
Returns true if we're being loaded in the map editor. |
void |
invalidate(int x,
int y,
int width,
int height)
Forces the map to refresh a particular area. |
boolean |
isBag()
Returns true if this container is a Bag (or Inventory, or other implementation of the Bag interface). |
boolean |
isEmpty(int x,
int y)
Returns true if there's nothing in the map at the passed location except terrain. |
boolean |
isEmpty(Point p)
|
boolean |
isInventory()
Returns true if this container is an Inventory. |
boolean |
isLit()
Returns true if the map is completely lit, e.g. by daylight. |
boolean |
isMap()
Returns true if this container is a GameMap. |
boolean |
isOpaque(int x,
int y)
|
boolean |
isPerPlayer()
Returns true if this map is a per-player map, meaning it was loaded by a teleporter with the "per-player" property. |
boolean |
isSuspended()
Returns true if the map is currently suspended. |
boolean |
isUnloaded()
Returns true if the map has started the unload process. |
protected abstract java.util.Iterator |
iterator(int x,
int y)
|
void |
notifyPlayerListeners(int type,
Player player,
Point source)
Don't call this. |
protected abstract java.util.List |
objectsAt(int x,
int y)
|
protected abstract java.util.Iterator |
objectsInRect(int x,
int y,
int w,
int h)
|
void |
readData(org.w3c.dom.Node bean)
Tells the object to parse its externalized representation from a list of lines. |
protected void |
recomputeLights(int x,
int y)
|
void |
registerCommand(java.lang.String command,
Command handler,
Rectangle room)
Whenever someone enters a command that isn't in their local command-list, the game engine passes the command to the agent's GameMap to see if anyone has registered the command with the map itself. |
void |
remove(int x,
int y,
GameObject obj)
Removes an object reference at the specified map location (x, y). |
GameObject |
removeFirst(int x,
int y,
Predicate p)
Removes and returns the first object that satisfies the passed Predicate. |
void |
removeHook(HookCallback callback,
java.lang.String hookName)
Removes a callback from a specified hook list. |
void |
removeLight(int x,
int y,
LightSource light)
Removes a light source from the map. |
Archetype |
removeLocalArchetype(java.lang.String name)
Removes a local archetype from the map's cache. |
void |
removeMapLifecycleListener(MapLifecycleListener l)
Removes a MapLifecycleListener from this map. |
void |
removeMethodHook(MethodHookCallback callback,
java.lang.String methodName)
Unregisters for the specified method-hook. |
protected void |
removePlayer(Player player)
Removes a reference to a player from the map. |
void |
removePlayerListener(MapPlayerListener listener)
Removes an MapPlayerListener from this map. |
void |
removePropertyChangeListener(java.beans.PropertyChangeListener listener)
Removes a PropertyChangeListener from the listener list. |
void |
removePropertyChangeListener(java.lang.String propertyName,
java.beans.PropertyChangeListener l)
Removes a PropertyChangeListener for a specific property. |
void |
removeProximityHook(ProximityCallback callback,
java.lang.String hookName,
GameObject target,
Rectangle range)
Removes a callback from the specified proximity-hook. |
void |
removeRoomHook(RoomHookCallback callback,
java.lang.String hookName,
Rectangle room)
Removes a callback from the specified room-hook. |
protected void |
removeTeleporter(Teleporter t)
Called when a Teleporter is removed from a map. |
void |
resetOpaqueFlag(int x,
int y)
Tells the map to re-scan the specified location to see if there are any opaque objects there. |
void |
resetOpaqueFlag(Point p)
|
void |
resume()
Resumes the map (if it was suspended.) |
void |
runFailedPostHook(CommandEvent event)
Notifies all the objects registered on this post-hook that the command failed (for whatever reason). |
void |
runMethodHook(java.lang.String methodName,
java.lang.Object data)
Runs the specific method hook. |
void |
runPostHook(CommandEvent event)
Notifies all the objects registered on this post-hook that the event completed successfully. |
void |
runPreHook(CommandEvent event)
Calls all objects registered for a particular event and gives them a chance to deal with the event before it happens. |
void |
setAutoload()
Tells the map that it was autoloaded. |
void |
setDangerLevel(int level)
Sets the danger level for this map. |
void |
setDefaultTerrain(java.lang.String terrain)
Sets the default terrain for the map. |
void |
setDefaultTerrain(Terrain t)
Sets the default terrain for the map: the terrain that will be returned if a query is made on a location where no terrain type has been set explicitly using setTerrain(). |
void |
setFavorite(int index,
Archetype arch)
Adds a "favorite" archetype to the map, for use in the map editor. |
void |
setLightingLevel(int ambient)
Sets the global, ambient lighting level for the map. |
void |
setLit(boolean lit)
Marks the map as having lighting effects, or not. |
void |
setName(java.lang.String name)
Sets the name of the map. |
void |
setPath(java.lang.String path)
Sets the path to the map. |
void |
setPerPlayer(java.lang.String name)
Marks the map as being a per-player map. |
void |
setStartLocation(Point start)
Sets the location at which players start when they enter the map, if the teleporter asks the map where to start. |
void |
setTerrain(int x,
int y,
Terrain t)
Sets (or removes) the terrain at the specified map location. |
void |
setTerrain(Point p,
Terrain t)
|
void |
setUnloadDelay(int delay)
Sets the amount of time to wait (in millis) after suspending before the map is unloaded. |
boolean |
shouldWrite()
Allows the object to determine whether it wants to be written out at all. |
void |
startSuspendTimer()
|
void |
startUnloadTimer()
|
void |
startUnloadTimer(int delay)
|
void |
suspend()
Tells the map to suspend itself. |
java.lang.String |
toString()
Returns a string representation of this PropertyList. |
protected void |
trackSpecialRemoves(GameObject obj)
|
void |
unload()
Tells the map to unload. |
void |
unregisterCommand(java.lang.String command,
Command handler,
Rectangle room)
Removes the specified Command from the map's command-list. |
protected void |
updateOpaque(int x,
int y,
boolean opaque)
|
void |
updateTerrainCache(int x,
int y,
int w,
int h)
Call this whenever you change the appearance of a particular piece of terrain. |
void |
visitObjectsAt(int x,
int y,
Visitor v)
Performs an operation on a set of objects at the specified location. |
void |
visUpdate(GameObject obj)
Forces the map to refresh a particular area. |
void |
wakeAllMonsters()
Wakes up all the monsters in the map, e.g. if a loud noise occurred. |
void |
wakeMonsters(Point loc,
int range)
Wakes up monsters near the specified point. |
boolean |
wasAutoloaded()
|
java.util.List |
writeData()
Tells the object to write its properties out to a text file. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface wyvern.lib.GameMap |
add, getBounds, getObjectCount, getOutOfBoundsTerrain, getProperties, getPropertyList, getSize, initialize, initialize, isSparse, keySet, registerAddRemoveListener, remove, setOutOfBoundsTerrain, setSize, terrainAt, unregisterAddRemoveListener, visitRect |
| Field Detail |
protected transient int dense_
protected transient HookList mapHooks_
protected transient RoomHookList roomHooks_
protected transient ProximityHookList proxHooks_
protected transient BitMatrix changeList_
protected transient MapDirtyRegions dirtyRegions_
protected transient MapCommandList commands_
protected transient java.util.Set players_
protected transient java.util.Set monsters_
protected transient java.util.Set teleporters_
protected transient Terrain defaultTerrain_
protected transient wyvern.kernel.data.MultiHashMap lights_
protected transient int ambient_
protected transient java.util.HashMap locals_
protected transient BitMatrix opaqueMap_
protected transient boolean visUpdates_
protected transient boolean unloading_
protected transient boolean suspended_
protected transient wyvern.kernel.maps.SuspendTimer suspendTimer_
protected transient int suspendTime_
protected transient boolean unloadImmediately_
protected transient java.lang.String name_
protected transient java.lang.String path_
protected transient java.lang.String vpath_
protected transient boolean dark_
protected transient java.lang.String perPlayer_
| Constructor Detail |
public AbstractGameMap()
| Method Detail |
public void initCommon()
public void doneLoading()
doneLoading in interface GameMap
protected abstract java.util.List objectsAt(int x,
int y)
protected abstract java.util.Iterator iterator(int x,
int y)
protected abstract java.util.Iterator objectsInRect(int x,
int y,
int w,
int h)
public void setDefaultTerrain(Terrain t)
GameMap
setDefaultTerrain in interface GameMapt - the Terrain object to use for the default locations.
public void setDefaultTerrain(java.lang.String terrain)
throws java.lang.Exception
GameMapFor sparse maps, the default terrain is what's used anywhere the terrain hasn't been set explicitly.
setDefaultTerrain in interface GameMapterrain - the archetype to use (e.g. "terrain/water")
java.lang.Exceptionpublic Terrain getDefaultTerrain()
GameMap
getDefaultTerrain in interface GameMappublic void setStartLocation(Point start)
GameMap
setStartLocation in interface GameMapstart - the starting locationpublic Point getStartLocation()
GameMap
getStartLocation in interface GameMappublic java.lang.String getName()
GameMap
getName in interface GameMappublic void setName(java.lang.String name)
GameMap
setName in interface GameMappublic java.util.Set getPlayerList()
GameMap
getPlayerList in interface GameMappublic java.util.Set getMonsterList()
GameMap
getMonsterList in interface GameMap
public int[][] getTerrainInfo(int x,
int y,
int w,
int h)
GameMap
getTerrainInfo in interface GameMapx - map xy - map yw - rect widthh - rect height
public void setTerrain(Point p,
Terrain t)
public void setTerrain(int x,
int y,
Terrain t)
GameMap
setTerrain in interface GameMapx - the map location x coordinatey - the map location y coordinatet - the Terrain object to place there. If null, sets
the terrain at that location to the default terrain for
the map.
public void updateTerrainCache(int x,
int y,
i