|
||||||||||
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
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 GameMap
t
- the Terrain object to use for the default locations.public void setDefaultTerrain(java.lang.String terrain) throws java.lang.Exception
GameMap
For sparse maps, the default terrain is what's used anywhere the terrain hasn't been set explicitly.
setDefaultTerrain
in interface GameMap
terrain
- the archetype to use (e.g. "terrain/water")
java.lang.Exception
public Terrain getDefaultTerrain()
GameMap
getDefaultTerrain
in interface GameMap
public void setStartLocation(Point start)
GameMap
setStartLocation
in interface GameMap
start
- the starting locationpublic Point getStartLocation()
GameMap
getStartLocation
in interface GameMap
public java.lang.String getName()
GameMap
getName
in interface GameMap
public void setName(java.lang.String name)
GameMap
setName
in interface GameMap
public java.util.Set getPlayerList()
GameMap
getPlayerList
in interface GameMap
public java.util.Set getMonsterList()
GameMap
getMonsterList
in interface GameMap
public int[][] getTerrainInfo(int x, int y, int w, int h)
GameMap
getTerrainInfo
in interface GameMap
x
- 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 GameMap
x
- 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, int w, int h)
GameMap
updateTerrainCache
in interface GameMap
x
- map x coordinate where the terrain is locatedy
- map y coordinate where the terrain is locatedw
- the width of the rectangle to update (usually 1)h
- the height of the rectangle to update (usually 1)public int getTerrainRecord(int x, int y)
GameMap
getTerrainRecord
in interface GameMap
x
- the map x coordinatey
- the map y coordinate
Here's a picture of it:
+-------------------------------+ |1|1|1| 13 bits | 16 bits | +-------------------------------+ / | | border layer tile flags priority number
public int getTerrainRecord(int x, int y, boolean useCache)
x
- map xy
- map yuseCache
- true to look in the cache, false to re-compute
the terrain record (only used for updating the cache, of course)public GameObject findAt(Point loc, Predicate p)
public GameObject findAt(Point loc, java.lang.String name)
public GameObject findAt(int x, int y, java.lang.String name)
public GameObject findAt(int x, int y, Predicate p)
GameMap
findAt
in interface GameMap
x
- map xy
- map yp
- a Predicate to filter the objects at (x, y)
Predicate
public GameObject findUnder(GameObject obj, Predicate filter)
GameMap
findUnder
in interface GameMap
obj
- the object to look underfilter
- the Predicate for looking for a particular object
public boolean isEmpty(Point p)
public boolean isEmpty(int x, int y)
GameMap
isEmpty
in interface GameMap
x
- x locationy
- y location
public void visitObjectsAt(int x, int y, Visitor v)
GameMap
visitObjectsAt
in interface GameMap
x
- x locationy
- y locationv
- the Visitor to send to each object at location (x, y)Visitor
public GameObject findInRect(int x, int y, int w, int h, Predicate p)
GameMap
findInRect
in interface GameMap
x
- x (world coordinates)y
- y (world coordinates)w
- rectangle widthh
- rectangle heightp
- a Predicate filter to check each object in turn.Predicate
public java.util.List getObjectsAt(int x, int y)
GameMap
getObjectsAt
in interface GameMap
x
- map x coordinatey
- map y coordinate
public Music getMusic()
GameMap
getMusic
in interface GameMap
public Location getRestartLoc()
GameMap
getRestartLoc
in interface GameMap
public Area getArea()
GameMap
getArea
in interface GameMap
public Resource getResource()
GameMap
getResource
in interface GameMap
public void add(int x, int y, GameObject obj)
GameMap
Adding the same object to a position it already occupies is not recommended, but it's not explicitly prevented, either.
This method will attempt to add the object to *some* map, even if the requested position is out of this map's bounds. Typically this is handled by passing the request up to the map's parent, which finds the right place to put the object. If for some reason the object simply can't be placed at (x, y), an ArrayIndexOutOfBoundsException results.
This method will invalidate the map using the bounds of the passed object. It's the same as calling add(x, y, obj, true).
add
in interface GameMap
x
- the map location x coordinatey
- the map location y coordinateobj
- the GameObject to add to the map at (x, y)GameObject
protected void addPlayer(Player p)
protected void addMonster(Monster mon)
protected void addTeleporter(Teleporter t)
public java.util.Set getExits()
GameMap
getExits
in interface GameMap
public void remove(int x, int y, GameObject obj)
GameMap
Note: this is -not- the correct way to remove most objects from a map.
This method will remove the requested object no matter what kind of object it is (e.g. spell effect, static object), with one exception: it will not remove the default Terrain object at (x, y). You can try, but it won't work - there always has to be a Terrain object at each location, so if the location is empty, the game will use the default terrain for the map. This method automatically invalidates the map at each location the object occupies. If you want to remove it without invalidating the map (which would be weird, because everyone would think it was still there), you'd have to to call map.remove(x, y, obj, false).
remove
in interface GameMap
x
- the map location x coordinatey
- the map location y coordinateobj
- the object at (x, y) to remove.GameObject
protected void trackSpecialRemoves(GameObject obj)
protected void removePlayer(Player player)
player
- a reference to the Player being removedprotected void removeTeleporter(Teleporter t)
public GameObject removeFirst(int x, int y, Predicate p)
GameMap
removeFirst
in interface GameMap
x
- the map location x coordinatey
- the map location y coordinatep
- the Predicate to filter the object. Returns null if no
objects at (x, y) satisfy the predicate.Predicate
,
GameObject
public void addPlayerListener(MapPlayerListener listener)
GameMap
addPlayerListener
in interface GameMap
listener
- the MapPlayerListenerpublic void removePlayerListener(MapPlayerListener listener)
GameMap
removePlayerListener
in interface GameMap
listener
- the MapPlayerListenerpublic void notifyPlayerListeners(int type, Player player, Point source)
GameMap
notifyPlayerListeners
in interface GameMap
public void addMapLifecycleListener(MapLifecycleListener l)
GameMap
addMapLifecycleListener
in interface GameMap
l
- the MapLifecycleListenerpublic void removeMapLifecycleListener(MapLifecycleListener l)
GameMap
removeMapLifecycleListener
in interface GameMap
l
- the MapLifecycleListenerprotected void fireMapLoaded()
protected void fireMapUnloaded()
protected void fireMapSuspended()
protected void fireMapResumed()
public java.lang.String[] getHooks()
Hookable
The list doesn't include names of default hooks for built-in commands.
getHooks
in interface Hookable
public HookList getHookList()
Hookable
getHookList
in interface Hookable
public RoomHookList getRoomHookList()
GameMap
getRoomHookList
in interface GameMap
public ProximityHookList getProximityHookList()
GameMap
getProximityHookList
in interface GameMap
public void addHook(HookCallback callback, java.lang.String hookName)
Hookable
The reserved pseudo-command "any" is reserved for callbacks that need to get every single command that comes through the queue. This should very rarely be necessary, and can hurt overall game performance considerably if abused.
addHook
in interface Hookable
callback
- the HookCallback to notify when the hook is run.hookName
- the name of the hook list to register on.public void removeHook(HookCallback callback, java.lang.String hookName)
Hookable
removeHook
in interface Hookable
callback
- the HookCallback to remove from the listhookName
- the name of the hook list to unregister from.public void runPreHook(CommandEvent event)
Hookable
Callbacks may veto the event, but it's still passed to any other callbacks on the list, and eventually to the Command. For callbacks, it typically doesn't really matter if the flag has been set by a previous callback; callbacks should do the same thing they would have done even if it wasn't vetoed, because the Command (or any other callback downstream) may un-veto it.
The callbacks may modify any of the event parameters. Callbacks aren't required to do rigorous checking of the validity of their changes. For example, a simple callback registered on a player's preMoveHook might change the direction in the MoveEvent randomly.
To prevent callbacks from generating illegal event parameters, the Command handling the event is implicitly the last hook on the list. Before executing the command it re-checks the preconditions to make sure the move is still legal, and if it isn't, it vetoes it and issues an error message. The message, of course, is a modifiable parameter of the event.
If a HookCallback wants to force an "illegal" event, it has to change the game state (in the agent, the map, the Command, or whatever) to make the move legal. For example, if the hook wants to make sure the player moves over a wall, the hook can set a property on the player (or the wall) that allows this move, before returning control to this method.
runPreHook
in interface Hookable
event
- a CommandEvent that has already run. Calling
getVerb() should return the canonical verb for this command,
such as "move" or "get". The verb is used to construct the
hook name, by appending "PreHook" to the verb.public void runPostHook(CommandEvent event)
Hookable
runPostHook
in interface Hookable
event
- a CommandEvent that has already run. Calling
getVerb() should return the canonical verb for this command,
such as "move" or "get". The verb is used to construct the
hook name, by appending "PostHook" to the verb.public void runFailedPostHook(CommandEvent event)
Hookable
Changing the event parameters will have no effect at this point.
runFailedPostHook
in interface Hookable
event
- a CommandEvent that has failed for some reason.
getVerb() should return the canonical verb for this command,
such as "move" or "get". The verb is used to construct the
hook name, by appending "FailedPostHook" to the verb.public void addMethodHook(MethodHookCallback callback, java.lang.String methodName)
MethodHookable
addMethodHook
in interface MethodHookable
methodName
- the name of the method to hook intocallback
- the MethodHookCallback object to notify on the hookpublic void removeMethodHook(MethodHookCallback callback, java.lang.String methodName)
MethodHookable
removeMethodHook
in interface MethodHookable
methodName
- the name of the methodcallback
- the MethodHookCallback object to notify on the hookpublic void runMethodHook(java.lang.String methodName, java.lang.Object data)
MethodHookable
runMethodHook
in interface MethodHookable
methodName
- the name of the method, e.g. "add"data
- any data to pass to the callbacks; can be nullpublic void addRoomHook(RoomHookCallback callback, java.lang.String hookName, Rectangle room)
GameMap
addRoomHook
in interface GameMap
callback
- the RoomHookCallback to notify when the hook is run.hookName
- the name of the hook list to register onroom
- the rectangle to listen in. Events outside the
rectangle are not passed to the callback object.public void removeRoomHook(RoomHookCallback callback, java.lang.String hookName, Rectangle room)
GameMap
removeRoomHook
in interface GameMap
callback
- the RoomHookCallback to remove from the listhookName
- the name of the hook list to unregister from
rectangle are not passed to the callback object.room
- the room which the callback was interested in.
It is necessary to pass the room so that if the callback was
registered for more than one room, the map will know which
room to remove it from.public void addProximityHook(ProximityCallback callback, java.lang.String hookName, GameObject target, Rectangle range)
GameMap
A proximity-hook is implemented by placing the target object within the passed range rectangle. The rectangle is translated to the target's reference location, which for rectangular targets is almost always its upper-left corner.
For example, to register interest in the 8 squares surrounding a 1x1 monster, pass a range of (-1, -1, 3, 3). If the monster is currently at (5, 5), the proximity area will extend from (4, 4) to (6, 6).
addProximityHook
in interface GameMap
callback
- the HookCallback to notify when the hook is run.hookName
- the name of the hook list to register ontarget
- the roaming object at the center of the range.
May be the same as the callback object.range
- the local coordinates around the target object
that define the bounding box of interest.public void removeProximityHook(ProximityCallback callback, java.lang.String hookName, GameObject target, Rectangle range)
GameMap
removeProximityHook
in interface GameMap
callback
- the HookCallback to remove from the listhookName
- the name of the hook list to unregister from
rectangle are not passed to the callback object.target
- the roaming object at the center of the range.
May be the same as the callback object.range
- the local coordinates around the target object
that define the bounding box of interest. The range needs
to be passed in case the target was registered for hooks in
more than one range.public void registerCommand(java.lang.String command, Command handler, Rectangle room)
GameMap
For instance, the Shop object registers the "list" command with the map the Shop is in. Whenever a player types "list" in a Shop, and "list" isn't a command registered in their local command-list (usually it isn't), then the game engine checks whether someone has registered the command with the map the player is in, and if so, invokes that Command to handle it (via the Command's createEvent and execute methods).
registerCommand
in interface GameMap
command
- the command to handlehandler
- the callback object to handle the commandroom
- the map sub-rectangle in which to register
interest. It can be the entire map bounds if the handler
wants to handle the command no matter where the agent is.
The rectangle is clipped against the map bounds, so it's
not an error if it specifies an area outside the map bounds.
(Optionally, you can pass null to use the map bounds).public void unregisterCommand(java.lang.String command, Command handler, Rectangle room)
GameMap
unregisterCommand
in interface GameMap
command
- the command to unregisterhandler
- the handler to unregisterroom
- the map sub-rectangle to unregister
(Optionally, you can pass null to use the entire map bounds).public Command getCommand(CommandEvent event, Commandable agent)
GameMap
getCommand
in interface GameMap
event
- the event to look for a handler foragent
- the agent doing the command
public void invalidate(int x, int y, int width, int height)
GameMap
invalidate
in interface GameMap
x
- the left side of the update rectangley
- the right side of the update rectanglewidth
- the width of the update rectheight
- the height of the update rectpublic void enableVisUpdates(boolean enable)
GameMap
Caution: if you accidentally leave updates off, changes to the map won't get propagated to the cameras, and players in the map will have a "frozen" map display.
enableVisUpdates
in interface GameMap
enable
- true to turn on updates, false to turn them offpublic void visUpdate(GameObject obj)
GameMap
visUpdate
in interface GameMap
obj
- the GameObject whose appearance has changed. Its bounds
(via getBounds()) will be used to determine the update region.public MapDirtyRegions getUpdateList()
GameMap
getUpdateList
in interface GameMap
public java.lang.String toString()
PList
toString
in class PList
public java.lang.String getPath()
GameMap
getPath
in interface GameMap
public java.lang.String getVirtualPath()
GameMap
getVirtualPath
in interface GameMap
public void setPerPlayer(java.lang.String name)
GameMap
setPerPlayer
in interface GameMap
name
- the player name for whom this map is uniquepublic boolean isPerPlayer()
GameMap
isPerPlayer
in interface GameMap
public void setPath(java.lang.String path)
GameMap
This method is typically only used for maps that are created dynamically by some other means than reading them from a map file.
setPath
in interface GameMap
path
- the new path to the map.public GameObject findTop(int x, int y)
GameMap
findTop
in interface GameMap
x
- the map x locationy
- the map y location
public GameObject findTop(Point p)
public GameObject findTop(int x, int y, Predicate p)
GameMap
findTop
in interface GameMap
x
- the map x locationy
- the map y locationp
- the predicate to use: returns true if it likes the object
public GameObject findByName(Point p, java.lang.String name)
GameMap
findByName
in interface GameMap
p
- the map (x, y) coordinatesname
- the name to matchGameMap.findByName(int, int, java.lang.String)
public GameObject findByName(int x, int y, java.lang.String name)
GameMap
findByName
in interface GameMap
name
- the name to matchx
- the x location to look aty
- the y location to look at
public int getDangerLevel()
GameMap
getDangerLevel
in interface GameMap
public void setDangerLevel(int level)
GameMap
setDangerLevel
in interface GameMap
level
- the new danger level (1-20)public Player getClaim()
GameMap
getClaim
in interface GameMap
public Point findFreeSpot(Point request, GameObject obj)
GameMap
findFreeSpot
in interface GameMap
request
- preferred map locationobj
- the object to add to the map
public Point findFreeSpot(int x, int y, GameObject obj)
public void addLight(int x, int y, LightSource light)
GameMap
addLight
in interface GameMap
x
- the x location of the light sourcey
- the y location of the light sourcelight
- the light sourcepublic void removeLight(int x, int y, LightSource light)
GameMap
removeLight
in interface GameMap
x
- the x location of the light sourcey
- the y location of the light sourcelight
- the light sourcepublic boolean isLit()
GameMap
isLit
in interface GameMap
public void setLit(boolean lit)
GameMap
setLit
in interface GameMap
lit
- true if the map is completely lit, false if it's darkpublic int getLightingLevel()
GameMap
getLightingLevel
in interface GameMap
public void setLightingLevel(int ambient)
GameMap
setLightingLevel
in interface GameMap
ambient
- the new ambient lighting level for the mappublic int getLightLevel(int x, int y)
GameMap
getLightLevel
in interface GameMap
x
- map x locationy
- map y location
public void resetOpaqueFlag(Point p)
public void resetOpaqueFlag(int x, int y)
GameMap
resetOpaqueFlag
in interface GameMap
x
- map x location to rescany
- map y location to rescanpublic boolean isOpaque(int x, int y)
isOpaque
in interface wyvern.kernel.lighting.Obstructions
public boolean hasObstructions(int x, int y, int w, int h)
hasObstructions
in interface wyvern.kernel.lighting.Obstructions
protected void updateOpaque(int x, int y, boolean opaque)
protected void recomputeLights(int x, int y)
protected abstract void addIntensityArray(int x, int y, int[][] array, boolean add)
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 local array; false to subtract itpublic abstract void adjustIntensity(int x, int y, int intensity)
adjustIntensity
in interface GameMap
x
- the x location to adjusty
- the y location to adjustintensity
- the +/- amount by which to adjust the lighting levelpublic void broadcast(java.lang.String msg)
GameMap
broadcast
in interface GameMap
msg
- the message to broadcast.public void broadcast(java.lang.String msg, byte style)
GameMap
broadcast
in interface GameMap
msg
- the message to broadcast.style
- the RPCConstants.TextStyle to useRPCConstants
public void wakeMonsters(Point loc, int range)
GameMap
wakeMonsters
in interface GameMap
loc
- the point near which to wake monstersrange
- the radius within which to wake thempublic void wakeAllMonsters()
GameMap
wakeAllMonsters
in interface GameMap
public void addLocalArchetype(Archetype arch)
GameMap
As useful as they are for cutting down map sizes (both on disk and in-memory), we're not sure yet how to handle an instance of a local archetype moving out of its map, so be careful only to use local archetypes for immovable objects like walls and terrain.
addLocalArchetype
in interface GameMap
arch
- the local archetype to add to the cache.
The name must be set via setName() before calling this
method. If another archetype was already registered
under this name, the previous archetype will be replaced
by the new one.public Archetype getLocalArchetype(java.lang.String name)
getLocalArchetype
in interface GameMap
name
- the name, in the form "local/whatever".
GameMap.getLocalArchetype(java.lang.String)
public Archetype removeLocalArchetype(java.lang.String name)
removeLocalArchetype
in interface GameMap
name
- the name, in the form "local/whatever"
GameMap.removeLocalArchetype(java.lang.String)
public java.util.List getLocalArchetypes()
GameMap
getLocalArchetypes
in interface GameMap
public void setFavorite(int index, Archetype arch)
GameMap
setFavorite
in interface GameMap
index
- the index in the favorites list to set it atarch
- the archetype to set; null to clear itpublic java.util.Map getFavorites()
GameMap
Favorites are stored in the map file as string properties, where the property name is "favorite-n" (n being the index), and the property value is the path to the archetype. This method enumerates over the map's properties and retrieves any of them that match "favorite-n", and puts them in the return map.
getFavorites
in interface GameMap
public int getUnloadDelay()
GameMap
getUnloadDelay
in interface GameMap
public void setUnloadDelay(int delay)
GameMap
setUnloadDelay
in interface GameMap
delay
- the length of time (in millis) to remain suspendedpublic boolean inMapEditor()
GameMap
inMapEditor
in interface GameMap
public void setAutoload()
GameMap
setAutoload
in interface GameMap
public boolean wasAutoloaded()
public void readData(org.w3c.dom.Node bean) throws java.lang.Exception
SelfExternalizable
readData
in interface SelfExternalizable
bean
- the XML DOM representation of the externalized
bean object. Its child could be a text node, in which case
the bean has to do all the parsing for the data. It could
also wrap a series of elements (e.g. archetypes), in which case
the bean may wish to leverage the XML parsing utilities that
the game provides in the ArchetypeManager.
java.lang.Exception
public java.util.List writeData() throws java.lang.Exception
SelfExternalizable
writeData
in interface SelfExternalizable
java.lang.Exception
public boolean shouldWrite()
SelfExternalizable
shouldWrite
in interface SelfExternalizable
public int dismantle()
GameMap
This method runs the method-hook "unload" before unloading the map.
dismantle
in interface GameMap
public void startSuspendTimer()
public void startUnloadTimer()
public void startUnloadTimer(int delay)
public void suspend()
GameMap
The map runs the "suspend" method-hook on this call.
suspend
in interface GameMap
public boolean isSuspended()
GameMap
isSuspended
in interface GameMap
public int getSuspendTime()
GameMap
getSuspendTime
in interface GameMap
public void resume()
GameMap
resume
in interface GameMap
public void unload()
GameMap
unload
in interface GameMap
public boolean isUnloaded()
GameMap
isUnloaded
in interface GameMap
public boolean isMap()
Container
isMap
in interface Container
public boolean isBag()
Container
isBag
in interface Container
public boolean isInventory()
Container
isInventory
in interface Container
public void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
GameMap
addPropertyChangeListener
in interface GameMap
public void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
GameMap
addPropertyChangeListener
in interface GameMap
public void firePropertyChange(java.beans.PropertyChangeEvent evt)
GameMap
firePropertyChange
in interface GameMap
evt
- the PropertyChangeEvent objectpublic void firePropertyChange(java.lang.String propertyName, boolean oldValue, boolean newValue)
GameMap
firePropertyChange
in interface GameMap
public void firePropertyChange(java.lang.String propertyName, int oldValue, int newValue)
GameMap
firePropertyChange
in interface GameMap
public void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
GameMap
firePropertyChange
in interface GameMap
public java.beans.PropertyChangeListener[] getPropertyChangeListeners()
GameMap
getPropertyChangeListeners
in interface GameMap
public java.beans.PropertyChangeListener[] getPropertyChangeListeners(java.lang.String propertyName)
GameMap
getPropertyChangeListeners
in interface GameMap
public boolean hasListeners(java.lang.String propertyName)
GameMap
hasListeners
in interface GameMap
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
GameMap
removePropertyChangeListener
in interface GameMap
public void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener l)
GameMap
removePropertyChangeListener
in interface GameMap
public static java.lang.String getProfilingInfo()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |