|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
A GameMap represents an area that players can visit; a game server will have thousands of individual maps.
A map is a 2D coordinate space. You can do all the standard things you'd expect to be able to do:
When you're looking for objects in a map, you're usually only interested in a subset of the objects. For example, you might only want the Living objects. The Map interface supports passing a filter function, called a Predicate, so you only get the objects you're interested in. A Predicate simply looks at an Object and returns true if it's interesting, false otherwise. There are a few predefined predicates in wyvern.lib.predicates, and you can also define your own.
Sometimes you want to do something to a set of objects in a map. For example, you might want to blast all the living things in rectangle R with a fireball. The map supports this by allowing you to pass in a Visitor object that is allowed to process each object in turn.
Nested Class Summary | |
static interface |
GameMap.UnloadMapConstants
Codes returned by the GameMap.dismantle() method, which attempts to unload a map from memory. |
Field Summary | |
static int |
MAX_HEIGHT
|
static int |
MAX_SEARCH_RADIUS
The max distance from the center that findFreeSpot() will search for an unblocked location. |
static int |
MAX_WIDTH
Dense maps use normal arrays to store their contents, so we limit the size of dense maps so that the arrays don't get too big. |
Fields inherited from interface wyvern.lib.PropertyList |
PROPERTY_PACKAGE |
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 to the map, optionally invalidating the map. |
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 listener)
Registers with the map to be notified whenever it loads, unloads, suspends, or resumes. |
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. |
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 |
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(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 |
findUnder(GameObject obj,
Predicate p)
Looks under the passed GameObject's locations for an object that matches the passed Predicate. |
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. |
Rectangle |
getBounds()
Returns the bounds of the map, in local coordinates. |
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. |
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. |
int |
getObjectCount()
Returns an approximate count of the GameObjects in this map, including terrain. |
java.util.List |
getObjectsAt(int x,
int y)
Returns a list of the objects at a location. |
Terrain |
getOutOfBoundsTerrain()
Returns what we use for the out-of-bounds terrain. |
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. |
PropertyList |
getProperties(int x,
int y)
You can get and set properties on a specific map location. |
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. |
PropertyList |
getPropertyList(int x,
int y)
Returns the property list for the given (x, y) map location, creating the list if necessary. |
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. |
Dimension |
getSize()
Returns the size of the 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 |
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. |
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 |
inMapEditor()
Returns true if we're being loaded in the map editor. |
void |
invalidate(int x,
int y,
int w,
int h)
Forces the map to refresh a particular area. |
boolean |
isEmpty(int x,
int y)
Returns true if there's nothing in the map at the passed location except terrain. |
boolean |
isLit()
Returns true if the map is completely lit, e.g. by daylight. |
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 |
isSparse()
Sparse maps have been retired, and this method will now always return false. |
boolean |
isSuspended()
Returns true if the map is currently suspended. |
boolean |
isUnloaded()
Returns true if the map has started the unload process. |
java.util.Set |
keySet()
Returns the set of nonempty points in this map. |
void |
notifyPlayerListeners(int type,
Player player,
Point source)
Don't call this. |
void |
registerAddRemoveListener(MapAddRemoveListener listener)
Registers with the map to be notified whenever objects are added to, or removed from, the map. |
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). |
void |
remove(int x,
int y,
GameObject obj,
boolean invalidate)
Removes an object from the map, optionally invalidating. |
GameObject |
removeFirst(int x,
int y,
Predicate p)
Removes and returns the first object that satisfies the passed Predicate. |
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 listener)
Removes a MapLifecycleListener from this 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 listener)
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. |
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 |
resume()
Resumes the map (if it was suspended.) |
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 |
setOutOfBoundsTerrain(Terrain t)
Sets the terrain to use outside the valid map bounds. |
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 |
setSize(Dimension size)
Changes the size of the 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 |
setUnloadDelay(int delay)
Sets the amount of time to wait (in millis) after suspending before the map is unloaded. |
void |
suspend()
Tells the map to suspend itself. |
Terrain |
terrainAt(int x,
int y)
Returns the Terrain at the passed location. |
void |
unload()
Tells the map to unload. |
void |
unregisterAddRemoveListener(MapAddRemoveListener listener)
Removes an MapAddRemoveListener from this map. |
void |
unregisterCommand(java.lang.String command,
Command handler,
Rectangle room)
Removes the specified Command from the map's command-list. |
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 |
visitRect(int x,
int y,
int w,
int h,
Visitor v)
Visits all the objects in the specified rectangle, optionally doing something to them. |
void |
visUpdate(GameObject m)
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. |
Methods inherited from interface wyvern.lib.Hookable |
addHook, getHookList, getHooks, removeHook, runFailedPostHook, runPostHook, runPreHook |
Methods inherited from interface wyvern.lib.MethodHookable |
addMethodHook, removeMethodHook, runMethodHook |
Methods inherited from interface wyvern.kernel.lighting.Obstructions |
hasObstructions, isOpaque |
Methods inherited from interface wyvern.lib.Container |
isBag, isInventory, isMap |
Field Detail |
public static final int MAX_WIDTH
public static final int MAX_HEIGHT
public static final int MAX_SEARCH_RADIUS
Method Detail |
public GameObject findAt(int x, int y, Predicate p)
x
- map xy
- map yp
- a Predicate to filter the objects at (x, y)
Predicate
public GameObject findUnder(GameObject obj, Predicate p)
obj
- the object to look underp
- the Predicate for looking for a particular object
public boolean isEmpty(int x, int y)
x
- x locationy
- y location
public Terrain terrainAt(int x, int y)
x
- x locationy
- y location
Terrain
public void visitObjectsAt(int x, int y, Visitor v)
x
- x locationy
- y locationv
- the Visitor to send to each object at location (x, y)Visitor
public void visitRect(int x, int y, int w, int h, Visitor v)
x
- x map coordinatey
- y map coordinatew
- rectangle widthh
- rectangle heightv
- a Visitor object. It checks each object in turn,
and if the object satisfies whatever criteria the Visitor
establishes, then it performs an operation on the object.Visitor
public GameObject findInRect(int x, int y, int w, int h, Predicate p)
x
- x (world coordinates)y
- y (world coordinates)w
- rectangle widthh
- rectangle heightp
- a Predicate filter to check each object in turn.Predicate
public int[][] getTerrainInfo(int x, int y, int w, int h)
x
- map xy
- map yw
- rect widthh
- rect height
public int getTerrainRecord(int x, int y)
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 void add(int x, int y, GameObject obj)
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).
x
- the map location x coordinatey
- the map location y coordinateobj
- the GameObject to add to the map at (x, y)GameObject
public void add(int x, int y, GameObject obj, boolean invalidate)
invalidate
parameter. When you've finished adding
all the references, you should invalidate the map manually.
Alternately you may choose to pass true when adding the last
reference, if the object is rectangular, so that the entire
bounds of the object are invalidated in the map at once.
x
- the map location x coordinatey
- the map location y coordinateobj
- the GameObject to add to the map at (x, y)invalidate
- true to call visUpdate on the map, passing
in the object's bounding rectangle. If false, you must call
visUpdate manually on any locations that have been changed
visibly by the add.public void remove(int x, int y, GameObject obj)
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).
x
- the map location x coordinatey
- the map location y coordinateobj
- the object at (x, y) to remove.
java.lang.ArrayIndexOutOfBoundsException
- if the point is invalidGameObject
public void remove(int x, int y, GameObject obj, boolean invalidate)
x
- the map location x coordinatey
- the map location y coordinateobj
- the GameObject to remove from the map at (x, y)invalidate
- true to call visUpdate on the map, passing
in the object's bounding rectangle. If false, you must invalidate
the map manually by calling visUpdate() on any areas that have
been changed visibly by the remove.public GameObject removeFirst(int x, int y, Predicate p)
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 setTerrain(int x, int y, Terrain t)
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.
java.lang.ArrayIndexOutOfBoundsException
- if (x, y) is out
of bounds.public void updateTerrainCache(int x, int y, int w, int h)
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 void setDefaultTerrain(Terrain t)
t
- the Terrain object to use for the default locations.public void setDefaultTerrain(java.lang.String terrain) throws java.lang.Exception
For sparse maps, the default terrain is what's used anywhere the terrain hasn't been set explicitly.
terrain
- the archetype to use (e.g. "terrain/water")
an
- Exception if the passed archetype name is invalid
java.lang.Exception
public void setOutOfBoundsTerrain(Terrain t)
public Terrain getOutOfBoundsTerrain()
public Terrain getDefaultTerrain()
public void setStartLocation(Point start)
start
- the starting locationpublic Point getStartLocation()
public Point findFreeSpot(Point request, GameObject obj)
request
- preferred map locationobj
- the object to add to the map
public int dismantle()
This method runs the method-hook "unload" before unloading the map.
public void unload()
public void suspend()
The map runs the "suspend" method-hook on this call.
public boolean isSuspended()
public int getSuspendTime()
public void resume()
public void addRoomHook(RoomHookCallback callback, java.lang.String hookName, Rectangle room)
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)
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 RoomHookList getRoomHookList()
public void addProximityHook(ProximityCallback callback, java.lang.String hookName, GameObject target, Rectangle range)
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).
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)
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 ProximityHookList getProximityHookList()
public void registerCommand(java.lang.String command, Command handler, Rectangle room)
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).
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)
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)
event
- the event to look for a handler foragent
- the agent doing the command
public void registerAddRemoveListener(MapAddRemoveListener listener)
listener
- the MapAddRemoveListenerpublic void unregisterAddRemoveListener(MapAddRemoveListener listener)
listener
- the MapAddRemoveListenerpublic void addPlayerListener(MapPlayerListener listener)
listener
- the MapPlayerListenerpublic void removePlayerListener(MapPlayerListener listener)
listener
- the MapPlayerListenerpublic void notifyPlayerListeners(int type, Player player, Point source)
public void addMapLifecycleListener(MapLifecycleListener listener)
listener
- the MapLifecycleListenerpublic void removeMapLifecycleListener(MapLifecycleListener listener)
listener
- the MapLifecycleListenerpublic 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
public java.lang.String getName()
public void setName(java.lang.String name)
public java.lang.String getPath()
public java.lang.String getVirtualPath()
public void setPath(java.lang.String path)
This method is typically only used for maps that are created dynamically by some other means than reading them from a map file.
path
- the new path to the map.public void setPerPlayer(java.lang.String name)
name
- the player name for whom this map is uniquepublic boolean isPerPlayer()
public java.util.Set getPlayerList()
public java.util.Set getMonsterList()
public java.util.Set getExits()
public void invalidate(int x, int y, int w, int h)
x
- the left side of the update rectangley
- the right side of the update rectanglew
- the width of the update recth
- the height of the update rectpublic void visUpdate(GameObject m)
m
- the GameObject whose appearance has changed. Its bounds
(via getBounds()) will be used to determine the update region.public MapDirtyRegions getUpdateList()
public void enableVisUpdates(boolean enable)
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.
enable
- true to turn on updates, false to turn them offpublic Dimension getSize()
public Rectangle getBounds()
public java.util.List getObjectsAt(int x, int y)
x
- map x coordinatey
- map y coordinate
public boolean isSparse()
public boolean inMapEditor()
public void setAutoload()
public int getDangerLevel()
public void setDangerLevel(int level)
level
- the new danger level (1-20)
java.lang.IllegalArgumentException
- if the passed level
is zero or negative.public Player getClaim()
public int getObjectCount()
public Music getMusic()
public Area getArea()
public Resource getResource()
public Location getRestartLoc()
public void addLight(int x, int y, LightSource light)
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)
x
- the x location of the light sourcey
- the y location of the light sourcelight
- the light sourcepublic void adjustIntensity(int x, int y, int intensity)
x
- the x location to adjusty
- the y location to adjustintensity
- the +/- amount by which to adjust the lighting levelpublic boolean isLit()
public void setLit(boolean lit)
lit
- true if the map is completely lit, false if it's darkpublic int getLightingLevel()
public void setLightingLevel(int ambient)
ambient
- the new ambient lighting level for the mappublic int getLightLevel(int x, int y)
x
- map x locationy
- map y location
public void resetOpaqueFlag(int x, int y)
x
- map x location to rescany
- map y location to rescanpublic void broadcast(java.lang.String msg)
msg
- the message to broadcast.public void broadcast(java.lang.String msg, byte style)
msg
- the message to broadcast.style
- the RPCConstants.TextStyle to useRPCConstants
public void wakeMonsters(Point loc, int range)
loc
- the point near which to wake monstersrange
- the radius within which to wake thempublic void wakeAllMonsters()
public GameObject findTop(int x, int y)
x
- the map x locationy
- the map y location
public GameObject findTop(int x, int y, Predicate p)
x
- the map x locationy
- the map y locationp
- the predicate to use: returns true if it likes the object
public GameObject findByName(int x, int y, java.lang.String name)
name
- the name to matchx
- the x location to look aty
- the y location to look at
public GameObject findByName(Point p, java.lang.String name)
p
- the map (x, y) coordinatesname
- the name to matchfindByName(int, int, java.lang.String)
public void addLocalArchetype(Archetype arch)
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.
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.
java.lang.IllegalArgumentException
- if the archetype
has no name to use as a key in the cache.public Archetype getLocalArchetype(java.lang.String name)
name
- the name, in the form "local/whatever".
public Archetype removeLocalArchetype(java.lang.String name)
name
- the name, in the form "local/whatever"
public java.util.List getLocalArchetypes()
public void setFavorite(int index, Archetype arch)
index
- the index in the favorites list to set it atarch
- the archetype to set; null to clear itpublic java.util.Map getFavorites()
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.
public void doneLoading()
public boolean isUnloaded()
public int getUnloadDelay()
public void setUnloadDelay(int delay)
delay
- the length of time (in millis) to remain suspendedpublic java.util.Set keySet()
public void setSize(Dimension size)
size
- the size for the mappublic void initialize(int width, int height)
width
- the map widthheight
- the map height
java.lang.IllegalStateException
- if the map has already
been initializedpublic void initialize(Dimension size)
size
- the size for the map
java.lang.IllegalStateException
- if the map has already
been initializedpublic void addPropertyChangeListener(java.beans.PropertyChangeListener listener)
public void addPropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
public void firePropertyChange(java.beans.PropertyChangeEvent evt)
evt
- the PropertyChangeEvent objectpublic void firePropertyChange(java.lang.String propertyName, boolean oldValue, boolean newValue)
public void firePropertyChange(java.lang.String propertyName, int oldValue, int newValue)
public void firePropertyChange(java.lang.String propertyName, java.lang.Object oldValue, java.lang.Object newValue)
public java.beans.PropertyChangeListener[] getPropertyChangeListeners()
public java.beans.PropertyChangeListener[] getPropertyChangeListeners(java.lang.String propertyName)
public boolean hasListeners(java.lang.String propertyName)
public void removePropertyChangeListener(java.beans.PropertyChangeListener listener)
public void removePropertyChangeListener(java.lang.String propertyName, java.beans.PropertyChangeListener listener)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |