|
||||||||||
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.MapObject
The top level implementation of the Wyvern class heirarchy.
Field Summary | |
protected static boolean |
IN_MAP_EDITOR
|
protected GameObjectEventSupport |
listenerList_
A lazily-instantiated helper class that registers event listeners. |
Fields inherited from class wyvern.kernel.properties.PList |
readOnly_ |
Fields inherited from interface wyvern.lib.PropertyList |
PROPERTY_PACKAGE |
Constructor Summary | |
MapObject()
|
Method Summary | |
void |
addContainerChangeListener(ContainerChangeListener l)
Adds a listener to be notified when an object enters or leaves a container. |
protected void |
addDefaultProperty(java.lang.String name)
Adds a (boolean) property to the object if the object doesn't already have the property. |
void |
addMapChangeListener(MapChangeListener l)
Adds a listener to be notified when the object is added to or removed from a map. |
void |
addMapMotionListener(MapMotionListener l)
Adds a listener to be notified when an object moves in its map. |
void |
addMethodHook(MethodHookCallback callback,
java.lang.String methodName)
Registers for the specified method-hook. |
void |
addMotionTracker(MotionTracker t)
Adds a MotionTracker to get map-change and map-motion events. |
void |
addObjectTracker(ObjectTracker t)
Adds an ObjectTracker to get map-change, map-motion, and container-change events all delivered to a single place. |
void |
addPrefix(java.lang.String prefix,
boolean id)
Adds a prefix to the short description, such as "+3". |
void |
addSuffix(java.lang.String suffix,
boolean id)
Adds a suffix to the short description, such as "of Durability". |
protected void |
addToMap(GameMap map,
java.util.List newpos)
Places the object in the specified map at all locations in the passed list. |
boolean |
bless()
Blesses the object, or if it's cursed, upgrades it to uncursed. |
java.util.List |
broadcast(java.lang.String msg)
Broadcasts a message to every player in sight of this object, not including the player who initiated it (if this is a player). |
java.util.List |
broadcast(java.lang.String msg,
byte style)
Broadcasts a message to every player in earshot of this object, not including the player who initiated it (if this is a player). |
java.util.List |
broadcast(java.lang.String msg,
Predicate p)
Sends the specified message to players in earshot of this object, not including the player who initiated it (if this is a player). |
java.util.List |
broadcast(java.lang.String msg,
Predicate p,
byte style)
Sends the specified message to player in sight of this object, not including the player who initiated it (if this is a player). |
java.util.List |
broadcast(java.lang.String msg,
Predicate p,
byte style,
int radius)
Sends the specified message to everyone in sight. |
boolean |
canEnter(GameMap map,
Point p)
Determines if it's possible for the (part of) object to enter this square. |
GameObject |
canEnterBlockedBy(GameMap map,
Point p)
Determines if it's possible for the (part of) object to enter this square. |
boolean |
canMove(GameMap map,
java.util.List dest)
Checks each point in the destination list to see if the object could go there. |
boolean |
canMove(int dir)
Determines whether it's possible for the agent to move to the passed location. |
GameObject |
canMoveBlockedBy(GameMap map,
java.util.List dest)
Checks each point in the destination list to see if the object could go there. |
GameObject |
canMoveBlockedBy(int dir)
Determines whether it's possible for the agent to move to the passed location. |
boolean |
canMoveTo(GameMap map,
Point p)
Determines whether it's possible for the agent to be teleported to the passed location without changing shape. |
GameObject |
canMoveToBlockedBy(GameMap map,
Point p)
Determines whether it's possible for the agent to be teleported to the passed location without changing shape. |
java.lang.String |
checkDrop(Commandable agent,
Container destination)
Checks whether the object can be dropped, thrown, given away, put in a bag, or otherwise disposed of by the bearer. |
boolean |
curse()
Curses the object, or if it's blessed, downgrades it to uncursed. |
void |
cycleFrame()
Cycles the animation frame for the object. |
void |
destroy()
Tells the object to destroy itself. |
protected void |
ensureListenerList()
Lazily creates the EventSupport object so we can start adding various custom EventListeners. |
protected void |
ensureWeight(java.lang.String weight)
This method is for the convenience of subclasses. |
java.util.LinkedList |
externalize()
Produces a text-serialized version of the object and its properties. |
protected void |
fireContainerEntered(Bag bag)
|
protected void |
fireContainerExited(Bag bag)
|
protected void |
fireEnteredMap(GameMap map,
int x,
int y)
|
protected void |
fireExitedMap(GameMap map,
int x,
int y)
|
protected void |
fireMovedInMap(GameMap map,
java.util.List src,
java.util.List dest)
|
int |
getAlpha()
Returns the alpha value for this object (1-100). |
Appearance |
getAppearance()
Returns the object's Appearance property. |
Archetype |
getArchetype()
Returns the parent archetype for this object. |
java.lang.String |
getBaseName()
Returns the basic description of the object, usually the "short" or the "id" property. |
long |
getBaseWeight()
Returns the weight of a single unit of the object. |
java.lang.String |
getBitmap()
Returns the bitmap string for this object (it's also stored in the Appearance property, so this method is just for convenience). |
Rectangle |
getBounds()
Returns the bounding rectangle for this object. |
java.lang.String |
getCanonicalClassName()
Returns the name of the object's class in a form suitable for writing to a map file. |
java.lang.String |
getCategory()
Returns the relative path for this object (it's also stored in the appearance property, so this method is just for convenience). |
Bag |
getContainer()
Returns the container (Bag or Inventory) this object is in, or null if it's not in a container. |
java.lang.String |
getCreator()
Returns the name of the Wizard who created this object, if any. |
java.lang.String |
getDamagedDescription()
Returns a message like "It is badly damaged". |
java.lang.String |
getDescription()
Returns a long-description for the object. |
int |
getDirection()
Returns the direction this object is facing. |
java.lang.String |
getGenderPossessive()
Returns "his", "her" or "its", as appropriate to the Player (or GameObject's) "sex" property. |
java.lang.String |
getGenderPronoun()
Returns "him", "her" or "it", as appropriate to the Player (or GameObject's) "sex" property. |
java.lang.String |
getImage()
Returns the image path, such as "monsters/dragon/red_dragon", or "wiz/foo/bar/bugbear" |
int[] |
getImageDescriptor(int x,
int y)
Returns a single appearance descriptor for the object at the specified (x, y) location. |
int[] |
getImageDescriptors()
Returns an appearance descriptor for the object. |
int |
getLayer()
Returns the drawing layer this object should be drawn in. |
java.util.List |
getLocations()
Returns all the map locations this object occupies. |
GameMap |
getMap()
Returns the GameMap reference stored in the instance data for this object, set by setMapLink(). |
GameMap |
getMapLink()
Returns the GameMap reference stored in the instance data for this object, set by setMapLink(). |
Material |
getMaterial()
Returns the (primary) Material this object is made from. |
java.lang.String |
getMaterialDescription()
Returns "It is made of |
Mover |
getMover()
Returns the Mover used by this object. |
java.lang.String |
getOwningPlayer()
Returns the owner of this object. |
GameMap |
getParentMap()
Returns the map this object resides in. |
java.util.List |
getPrefixes(boolean id)
Returns a list of prefixes that are to be prepended to the object's short description. |
int |
getQuantity()
Convenience method for returning the value of the "quantity" property. |
Point |
getReferenceLoc()
Returns the "reference location" for this object, which is the first Point in the object's location list. |
java.util.List |
getRelativeLocs()
Returns a list of relative locations. |
java.lang.String |
getShortDesc()
Returns a short description for the object. |
java.util.List |
getSuffixes(boolean id)
Returns a list of suffixes that are to be appended to the object's short description. |
int |
getTile(int xloc,
int yloc)
Returns the tile number for this object at this location. |
int |
getTile(Point p)
Returns the tile number for this object at this location. |
int |
getValue()
Returns the amount (in gold pieces) that the object would cost in a standard shop. |
long |
getWeight()
Returns the weight of this object in grams. |
protected java.lang.String |
groupString(java.lang.String desc)
Mangles the short description to include quantity information. |
boolean |
inContainer()
Returns true if the object is currently in a Bag or Inventory. |
void |
initialize()
Initializes the object's default properties. |
protected void |
initLocs()
Initializes the location list to 1 point. |
boolean |
inMapEditor()
Returns true if we're currently in the Map Editor rather than in a live game. |
void |
invalidate()
Notifies the parent container (bag, inv or map) that a visual change has occurred in this object. |
void |
invalidateImage()
Notifies the object's parent container (bag, inv or map) that the object's image has changed. |
void |
invalidateParent()
Notifies the object's parent container (bag, inv or map) that this object's image and/or text description have changed. |
void |
invalidateText()
Notifies the parent container (bag, inv or map) that a textual change has occurred in this object. |
boolean |
isAnimated()
Returns true if the item has an "anima" property, typically an AnimationParams. |
boolean |
isAttackable()
Returns true if this is an Attackable. |
boolean |
isBlessed()
Returns true if the object is blessed. |
boolean |
isCommandable()
Returns true if (and only if) this object has an event queue and can be commanded (i.e. it's an instance of Commandable). |
boolean |
isCursed()
Returns true if the object is cursed (or damned). |
boolean |
isDamned()
Returns true if the object is damned (a more powerful curse). |
boolean |
isGroupable()
Returns true if the object has the "groupable" property, so that it will combine with similar objects to form a group (or "stack", as many players call it). |
boolean |
isIdentified()
Returns true if the item is identified. |
boolean |
isMonster()
Returns true if (and only if) this is a Monster (and not a Player). |
boolean |
isMonsterOrPlayer()
Returns true if this is a Monster or Player |
boolean |
isPlayer()
Returns true if (and only if) this is a Player. |
boolean |
isTerrain()
Returns true if (and only if) this object is an instance of class Terrain, or a subclass. |
boolean |
isUncursed()
Returns true if the object is uncursed, meaning it's not damned, cursed, or blessed. |
boolean |
isUnpaid()
Returns true if the item has the "unpaid" property. |
boolean |
isWizard()
Returns true if (and only if) this is a Player with the "wizard" property. |
GameObject |
makeClone()
Produces a clone of this object. |
void |
markPaid()
Marks the object as paid-for. |
void |
markUnpaid()
Marks the object as unpaid. |
void |
move(int xoffset,
int yoffset)
Translates the object to a new relative location. |
boolean |
occupies(int x,
int y)
Returns true if the object (in whole or in part) occupies the specified location. |
void |
positionAt(GameObject obj)
Sets the object in the map where another object is located. |
void |
positionAtMap(GameMap map,
GameObject obj)
Sets the object in the map where another object is located. |
void |
remove()
Removes this object from its map. |
void |
removeContainerChangeListener(ContainerChangeListener l)
Removes a ContainerChangeListener that was previously added with addContainerChangeListener(). |
protected void |
removeFromMap(GameMap map,
java.util.List locations)
Removes all references to the object from the map. |
void |
removeMapChangeListener(MapChangeListener l)
Removes a MapChangeListener that was previously added with addMapChangeListener(). |
void |
removeMapMotionListener(MapMotionListener l)
Removes a MapMotionListener that was previously added with addMapMotionListener(). |
void |
removeMethodHook(MethodHookCallback callback,
java.lang.String methodName)
Unregisters for the specified method-hook. |
void |
removeMotionTracker(MotionTracker t)
Removes a MotionTracker previously added with addMotionTracker. |
void |
removeObjectTracker(ObjectTracker t)
Removes an ObjectTracker previously added with addObjectTracker(). |
void |
removePrefix(java.lang.String prefix,
boolean id)
Removes a prefix from the list of prefixes for the short description. |
void |
removeSuffix(java.lang.String suffix,
boolean id)
Removes a suffix from the list of suffixes for the short description. |
void |
runMethodHook(java.lang.String hookName,
java.lang.Object data)
Runs the specific method hook. |
void |
setAlpha(int alpha)
Sets the alpha value for this appearance (1-100). |
void |
setAnimated(boolean animate)
Starts or stops the object's animation timer. |
void |
setBitmap(java.lang.String bitmap)
Sets just the file basename for the GameObject's appearance. |
void |
setCategory(java.lang.String category)
Sets the relative path for the object's image |
Bag |
setContainer(Bag container)
Sets the link to the parent container. |
protected void |
setDefaultBitmap(java.lang.String bmp)
Deprecated. setDefaultBitmap() and setDefaultCategory() are deprecated - use setDefaultImage(path) instead |
protected void |
setDefaultCategory(java.lang.String cat)
Deprecated. setDefaultBitmap() and setDefaultCategory() are deprecated - use setDefaultImage(path) instead |
protected void |
setDefaultDesc(java.lang.String desc)
Sets long description if we don't have one. |
protected void |
setDefaultImage(java.lang.String path)
Sets image if we don't have it already |
protected void |
setDefaultIntProperty(java.lang.String name,
int value)
Sets an int property if it's not already set. |
protected void |
setDefaultLayer(int layer)
Sets the layer for the image if getLayer() == 0. |
protected void |
setDefaultMaterial(Material material)
If we don't already have a "material" property from the object's archetype, sets "material" to the passed Material. |
protected void |
setDefaultProperty(java.lang.String name,
java.lang.Object value)
Sets a property if it's not already set. |
protected void |
setDefaultShortDesc(java.lang.String shortdesc)
Sets short description if we don't have one. |
void |
setDirection(int direction)
Sets the direction this object is facing. |
void |
setImage(java.lang.String image)
Sets the image (relative path + filename) for this object. |
void |
setImage(java.lang.String path,
java.lang.String img)
Sets the image (relative path + filename) for this object. |
void |
setLayer(int layer)
Sets the drawing layer this object appears in. |
void |
setLocations(java.util.List dest)
Sets an object's location-list using absolute coordinates. |
void |
setMap(GameMap map,
int x,
int y)
Sets the parent map for this object, passing requested location at which to put the object. |
GameMap |
setMapLink(GameMap map)
Sets the parent map for this object. |
void |
setQuantity(int quantity)
Sets a quantity on the object. |
void |
setShape(java.util.List new_shape)
This is the setSize() method for non-rectangular objects. |
void |
setSize(int width,
int height)
Shapes the object into a rectangle of the specified dimensions. |
void |
setTransientSize(int width,
int height)
Calls setSize, but saves our original size first, in a transient property called "real-size". |
void |
setWeight(long weight)
Sets the weight of the object in grams. |
void |
setWeight(java.lang.String weight)
Sets a new weight for the object. |
void |
teleport(int x,
int y)
Teleports the object to a completely new map location. |
java.lang.String |
toString()
Returns the short (usually one-line) description of the object. |
protected void |
updateMapLocation(java.util.List src,
java.util.List dest)
This method is called by move(), teleport() and setLocations() to remove the object from its old locations and place it in its new locations. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
protected static final boolean IN_MAP_EDITOR
protected GameObjectEventSupport listenerList_
Constructor Detail |
public MapObject()
Method Detail |
public void initialize()
GameObject
initialize
in interface GameObject
public java.util.List getLocations()
GameObject
getLocations
in interface GameObject
protected void initLocs()
public java.util.List getRelativeLocs()
GameObject
getRelativeLocs
in interface GameObject
public boolean occupies(int x, int y)
GameObject
occupies
in interface GameObject
x
- the x coordinate to checky
- the y coordinate to check
public Point getReferenceLoc()
GameObject
For rectangular objects, it defaults to the upper-left corner of the object. Objects can return any point they like for their reference location, although it's recommended that they return a point that exists in their location-list.
getReferenceLoc
in interface GameObject
public void setSize(int width, int height)
GameObject
You can also use the setShape() method, but this is much easier for the 90+ percent of all objects that are rectangular.
This method keeps the object at the same reference location. That is, it obtains the object's current "position" by taking the first location from its locations list, and it makes sure the locations are all relative to this point, which is treated as the object's upper-left corner for the new rectangle.
Note that this is a "low-level" method: it doesn't do any checking to ensure that the object won't wind up in an invalid state (such as overlapping a wall) when it resizes. The caller should perform such checks before calling this method.
setSize
in interface GameObject
width
- the new width of the objectheight
- the new height of the objectpublic void setTransientSize(int width, int height)
GameObject
setTransientSize
in interface GameObject
width
- the width of the object, in map coordinatesheight
- the height of the object, in map coordinatespublic void setShape(java.util.List new_shape)
GameObject
You pass in a list of Points consisting of the relative positions the object occupies. They will be translated to the object's previous "reference position" (defined as the first location in its old locations list).
setShape
in interface GameObject
new_shape
- a list of points that the object occupiespublic void setLocations(java.util.List dest)
GameObject
This method assumes you know what you're doing, and will let you do things like put a player in a wall, so be careful.
The passed destination is used "as-is" as the new location list. Don't use the list again after passing it in to this method. (Typically you should pass in an ArrayList for performance).
setLocations
in interface GameObject
dest
- the new set of locations the object occupies.public void move(int xoffset, int yoffset)
GameObject
The preferred way to move a Commandable is to command() it with command ( "move <direction>" ). This will ensure that the object only moves as fast as it can, and will run the pre- and post-move hooks so that others can participate in the event, possibly vetoing it if it's not allowed.
move
in interface GameObject
xoffset
- the x offset to move the objectyoffset
- the y offset to move the objectpublic void teleport(int x, int y)
GameObject
teleport
in interface GameObject
x
- the new x location for the object.y
- the new y location for the object.public void remove()
GameObject
remove
in interface GameObject
public void positionAt(GameObject obj)
GameObject
positionAt
in interface GameObject
obj
- another GameObject to use for the location.
We will be placed at the passed object's reference location.GameObject.setMap(wyvern.lib.GameMap, int, int)
public void positionAtMap(GameMap map, GameObject obj)
GameObject
positionAtMap
in interface GameObject
map
- the new parent map for this objectobj
- another GameObject to use for the location.
We will be placed at the passed object's reference location.GameObject.setMap(wyvern.lib.GameMap, int, int)
public void setMap(GameMap map, int x, int y)
GameObject
For example, if a 2x2 object is placed at (10,10), then the object's upper-left corner is its reference loc, so a reference to the object is placed at (10,10). The remaining three locations are placed at (11,10), (10,11) and (11,11).
For objects that wish to subclass this method, it does the following:
setMap
in interface GameObject
map
- the new parent map for this objectx
- the x coord in the map to place the object.y
- the y coord in the map to place the object.public GameMap setMapLink(GameMap map)
GameObject
Doesn't actually put the object in the map - you have to call map.add(obj, x, y) for each location the object occupies in order for it to really be in the map.
setMapLink
in interface GameObject
map
- the map the object should think it's in.
getMap() will return this value.
public GameMap getParentMap()
GameObject
getParentMap
in interface GameObject
public GameMap getMap()
GameObject
getMap
in interface GameObject
public GameMap getMapLink()
GameObject
getMapLink
in interface GameObject
public boolean inContainer()
GameObject
inContainer
in interface GameObject
public Bag getContainer()
GameObject
getContainer
in interface GameObject
public Bag setContainer(Bag container)
GameObject
setContainer
in interface GameObject
container
- the container we've been placed in, or
null to remove the link. Returns whatever container we
were in before the change, or null if none.public Rectangle getBounds()
GameObject
getBounds
in interface GameObject
public boolean canMoveTo(GameMap map, Point p)
GameObject
Keep in mind that the map contents can change (e.g. monsters can move in the way, walls can appear and disappear), so the results from this method can become stale if you wait too long. It's safe if you call it on the Scheduler thread and then use the results before relinquishing the Scheduler thread.
Generally speaking, this method is useful for computing paths, such as for AIs determining where their monster should try to go.
canMoveTo
in interface GameObject
map
- the map to teleport top
- the point in that map
public GameObject canMoveToBlockedBy(GameMap map, Point p)
GameObject
Keep in mind that the map contents can change (e.g. monsters can move in the way, walls can appear and disappear), so the results from this method can become stale if you wait too long. It's safe if you call it on the Scheduler thread and then use the results before relinquishing the Scheduler thread.
Generally speaking, this method is useful for computing paths, such as for AIs determining where their monster should try to go.
canMoveToBlockedBy
in interface GameObject
map
- the map to teleport top
- the point in that map
public boolean canMove(int dir)
GameObject
canMove
in interface GameObject
dir
- the wyvern.lib.Direction constant consisting of
a direction to move from the monster's current location.public GameObject canMoveBlockedBy(int dir)
GameObject
canMoveBlockedBy
in interface GameObject
dir
- the wyvern.lib.Direction constant consisting of
a direction to move from the monster's current location.public boolean canMove(GameMap map, java.util.List dest)
GameObject
canMove
in interface GameObject
map
- the destination mapdest
- the proposed destination list (map locations)
public GameObject canMoveBlockedBy(GameMap map, java.util.List dest)
GameObject
canMoveBlockedBy
in interface GameObject
map
- the destination mapdest
- the proposed destination list (map locations)
public boolean canEnter(GameMap map, Point p)
GameObject
canEnter
in interface GameObject
map
- the map to teleport top
- the point in that map
public GameObject canEnterBlockedBy(GameMap map, Point p)
GameObject
canEnterBlockedBy
in interface GameObject
map
- the map to teleport top
- the point in that map
public Mover getMover()
GameObject
getMover
in interface GameObject
public int getTile(Point p)
GameObject
getTile
in interface GameObject
p
- object (x, y) location
public int getTile(int xloc, int yloc)
GameObject
getTile
in interface GameObject
xloc
- object x locationyloc
- object y location
public int[] getImageDescriptors()
GameObject
Normally you don't need to mess with this method. It's for the client and the map editor.
getImageDescriptors
in interface GameObject
public int[] getImageDescriptor(int x, int y)
GameObject
The descriptor consists of an offset and a bitmap number. The offset specifies where to draw the bitmap, in absolute coordinates, so that the specified square has the correct representation. This is used primarily by the Map Editor to draw a particular square of an object, but anyone can use it for that purpose.
Normally you don't need to mess with this method. It's for the client and the map editor.
getImageDescriptor
in interface GameObject
public java.lang.String getBitmap()
GameObject
getBitmap
in interface GameObject
public java.lang.String getCategory()
GameObject
getCategory
in interface GameObject
public int getLayer()
GameObject
getLayer
in interface GameObject
public int getDirection()
GameObject
getDirection
in interface GameObject
public void setImage(java.lang.String path, java.lang.String img)
GameObject
setImage
in interface GameObject
path
- the relative path, such as "monsters/goblin"img
- the file name, with no extension, and usually
no direction or animation specifiers, e.g. "red_dragon".public void setImage(java.lang.String image)
GameObject
setImage
in interface GameObject
image
- the relative path and file basename for the
object, such as "armor/gloves/gauntlets_of_power". Shouldn't
include any directional or animation specifiers like ".E1",
and shouldn't include the image file extension.public java.lang.String getImage()
GameObject
getImage
in interface GameObject
public void setBitmap(java.lang.String bitmap)
GameObject
setBitmap
in interface GameObject
bitmap
- the path (in the art-cache directory) to the bitmappublic void setCategory(java.lang.String category)
GameObject
setCategory
in interface GameObject
category
- the relative path, such as "wiz/foo/myart",
or "armor/misc".public void setLayer(int layer)
GameObject
setLayer
in interface GameObject
layer
- the drawing layerpublic int getAlpha()
GameObject
getAlpha
in interface GameObject
public void setAlpha(int alpha)
GameObject
setAlpha
in interface GameObject
alpha
- the alpha valuepublic void setDirection(int direction)
GameObject
setDirection
in interface GameObject
direction
- a valid wyvern.lib.Direction constant. Direction.NONE
is valid, but Direction.ILLEGAL_DIR isn't. (Direction.SOUTH, etc.
are valid).public void invalidate()
GameObject
invalidate
in interface GameObject
public void invalidateText()
GameObject
invalidateText
in interface GameObject
public void invalidateImage()
GameObject
invalidateImage
in interface GameObject
public void invalidateParent()
GameObject
invalidateParent
in interface GameObject
public void setAnimated(boolean animate)
GameObject
An object's animation properties (frame rate, number of frames) are stored an an AnimationParams bean property called "anima".
Calling setAnimated(true) will start the timer based on the parameters in that property. If no such property exists, a default one will be created and added to the object.
To change an object's animation cycle:
setAnimated(false)
setAnimated(true)
setAnimated
in interface GameObject
animate
- true to start animation, false to stop itAnimationParams
public void cycleFrame()
GameObject
Normally this method is called by the object's animation timer.
cycleFrame
in interface GameObject
public java.util.LinkedList externalize()
GameObject
Before writing the object, we call getDefaultProperties() and don't write any properties on the object that are considered defaults by the object's class.
Transient properties are not included in the externalized text.
externalize
in interface GameObject
public Archetype getArchetype()
GameObject
getArchetype
in interface GameObject
public java.lang.String getCanonicalClassName()
GameObject
getCanonicalClassName
in interface GameObject
public long getWeight()
GameObject
getWeight
in interface GameObject
protected void ensureWeight(java.lang.String weight)
Many game objects have no weight property. It makes no sense to put a weight property on an object that can never be picked up or weighed. This category includes terrain, roads, walls and buildings. For this reason, MapObject doesn't try to force a default weight; the default is zero, and it'll never come into play for objects such as the ones above.
Note: for grouped items such as coins, the weight specified here is the weight of a single coin. getWeight() will return the total weight of the group by multiplying this weight by the group quantity.
weight
- a weight specifier such as "10.5 lb" or "50gm"
java.lang.IllegalArgumentException
- if the weight doesn't parseWeight
public long getBaseWeight()
GameObject
This method is equivalent to ((Weight)getProperty("weight")).getValue().
getBaseWeight
in interface GameObject
public void setWeight(java.lang.String weight)
GameObject
setWeight
in interface GameObject
weight
- the weight as a parseable string, such as "10 lb"
or "22gm".Weight
public void setWeight(long weight)
GameObject
setWeight
in interface GameObject
weight
- the new weight, in grams.Weight
public Appearance getAppearance()
GameObject
getAppearance
in interface GameObject
public java.lang.String checkDrop(Commandable agent, Container destination)
GameObject
checkDrop
in interface GameObject
agent
- the person trying to drop itdestination
- the intended destination for the dropped
object. It can be a Bag ("put"), a GameMap ("drop, throw"),
or an Inventory ("give"). Should never be null.
public java.util.List broadcast(java.lang.String msg)
Broadcaster
broadcast
in interface Broadcaster
msg
- the message to broadcast.
public java.util.List broadcast(java.lang.String msg, byte style)
Broadcaster
broadcast
in interface Broadcaster
msg
- the message to broadcast.style
- the RPCConstants.TextStyle to use
public java.util.List broadcast(java.lang.String msg, Predicate p)
Broadcaster
broadcast
in interface Broadcaster
msg
- the message to sendp
- an optional predicate used to filter the recipients.
If p is false for a potential recipient, the message is not
delivered to that recipient.
public java.util.List broadcast(java.lang.String msg, Predicate p, byte style)
Broadcaster
broadcast
in interface Broadcaster
msg
- the message to sendp
- an optional predicate used to filter the recipients.
If p is false for a potential recipient, the message is not
delivered to that recipient.style
- the RPCConstants.TextStyle to use
public java.util.List broadcast(java.lang.String msg, Predicate p, byte style, int radius)
Broadcaster
broadcast
in interface Broadcaster
msg
- the message to sendp
- an optional predicate used to filter the recipients.
If p is false for a potential recipient, the message is not
delivered to that recipient.style
- the RPCConstants.TextStyle to useradius
- the radius around the player to broadcast to.
Includes the player's location, so a radius of 7 would cover
their whole view.
public java.lang.String toString()
toString
in class PList
public java.lang.String getBaseName()
public java.lang.String getDescription()
GameObject
getDescription
in interface GameObject
public java.lang.String getShortDesc()
GameObject
getShortDesc
in interface GameObject
public java.lang.String getMaterialDescription()
GameObject
getMaterialDescription
in interface GameObject
public Material getMaterial()
GameObject
getMaterial
in interface GameObject
public java.lang.String getDamagedDescription()
GameObject
getDamagedDescription
in interface GameObject
public void addPrefix(java.lang.String prefix, boolean id)
GameObject
addPrefix
in interface GameObject
prefix
- the prefix to addid
- true if it's only supposed to show when the
item is identified. If false, it's always visible.public void addSuffix(java.lang.String suffix, boolean id)
GameObject
addSuffix
in interface GameObject
suffix
- the suffix to addid
- true if the suffix should only show up when the
item is identified. If false, it's always visible.public void removePrefix(java.lang.String prefix, boolean id)
GameObject
removePrefix
in interface GameObject
prefix
- the prefix to remove; does nothing if the
prefix wasn't already in the listid
- which list to use: if true, removes from the
identified-prefixes list; else removes from the prefixes
that are always visible.public void removeSuffix(java.lang.String suffix, boolean id)
GameObject
removeSuffix
in interface GameObject
suffix
- the suffix to remove; does nothing if the
suffix wasn't already in the listid
- which list to use: if true, removes from the
identified-suffixes list; else removes from the suffixes
that are always visible.public java.util.List getPrefixes(boolean id)
GameObject
getPrefixes
in interface GameObject
id
- which list to use: if true, removes from the
identified-prefixes list; else returns the prefixes
that are always visible.
public java.util.List getSuffixes(boolean id)
GameObject
getSuffixes
in interface GameObject
id
- which list to use: if true, removes from the
identified-suffixes list; else returns the suffixes
that are always visible.
protected java.lang.String groupString(java.lang.String desc)
desc
- the short description of the object returned by
the getBaseName() method.
public boolean isGroupable()
GameObject
isGroupable
in interface GameObject
public void setQuantity(int quantity)
GameObject
The general contract of groupable items is that you treat the group as a single object when querying its properties. For instance, getWeight() will return the weight of the composite; you don't have to multiply by the quantity. The short and long descriptions will automatically be updated to reflect the quantity. getValue() will return the total value of the items in the group, and so on.
setQuantity
in interface GameObject
quantity
- the new number of items in the grouppublic int getQuantity()
GameObject
getQuantity
in interface GameObject
public int getValue()
GameObject
getValue
in interface GameObject
public boolean curse()
GameObject
curse
in interface GameObject
public boolean bless()
GameObject
bless
in interface GameObject
public boolean isCursed()
GameObject
isCursed
in interface GameObject
public boolean isBlessed()
GameObject
isBlessed
in interface GameObject
public boolean isDamned()
GameObject
isDamned
in interface GameObject
public boolean isUncursed()
GameObject
isUncursed
in interface GameObject
public boolean isIdentified()
GameObject
isIdentified
in interface GameObject
public void markPaid()
GameObject
markPaid
in interface GameObject
public void markUnpaid()
GameObject
markUnpaid
in interface GameObject
public boolean isUnpaid()
GameObject
isUnpaid
in interface GameObject
public boolean isAnimated()
GameObject
isAnimated
in interface GameObject
protected void updateMapLocation(java.util.List src, java.util.List dest)
src
- the location list that the object occupied.dest
- the new positions to useprotected void removeFromMap(GameMap map, java.util.List locations)
Runs a method hook called "remove", whose data parameter is depends on whether we're moving within the map, or being removed completely from the map. If we're just moving, the data parameter is null. If we're being removed, the data parameter is a List. The lists's first element is the map we're being removed from. The remaining elements are Point objects representing our location list when we occupied the map.
map
- the map to remove fromlocations
- the locations the object occupiesprotected void addToMap(GameMap map, java.util.List newpos)
map
- the map to add tonewpos
- the new locations for the objectpublic void runMethodHook(java.lang.String hookName, java.lang.Object data)
MethodHookable
runMethodHook
in interface MethodHookable
hookName
- the name of the method, e.g. "add"data
- any data to pass to the callbacks; can be nullpublic 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 hookprotected void setDefaultImage(java.lang.String path)
path
- the path to the imageprotected void setDefaultCategory(java.lang.String cat)
cat
- the default category to useprotected void setDefaultBitmap(java.lang.String bmp)
bmp
- the default bitmap to useprotected void addDefaultProperty(java.lang.String name)
protected void setDefaultProperty(java.lang.String name, java.lang.Object value)
name
- the property namevalue
- the property valueprotected void setDefaultIntProperty(java.lang.String name, int value)
name
- the property namevalue
- the int valueprotected void setDefaultMaterial(Material material)
material
- the default material to use for this object/classprotected void setDefaultShortDesc(java.lang.String shortdesc)
protected void setDefaultDesc(java.lang.String desc)
protected void setDefaultLayer(int layer)
public GameObject makeClone()
GameObject
makeClone
in interface GameObject
public void destroy()
GameObject
This method is called when the object's parent map is unloaded, when a wizard disposes the object, or when the object is destroyed via some natural force (e.g. a fireball). If you override this method, make sure to call the superclass version, so the superclass can perform its own cleanup if needed.
destroy
in interface GameObject
public java.lang.String getGenderPossessive()
GameObject
getGenderPossessive
in interface GameObject
public java.lang.String getGenderPronoun()
GameObject
getGenderPronoun
in interface GameObject
public java.lang.String getOwningPlayer()
GameObject
getOwningPlayer
in interface GameObject
public java.lang.String getCreator()
GameObject
getCreator
in interface GameObject
public boolean isPlayer()
GameObject
isPlayer
in interface GameObject
public boolean isMonster()
GameObject
isMonster
in interface GameObject
public boolean isWizard()
GameObject
isWizard
in interface GameObject
public boolean isTerrain()
GameObject
isTerrain
in interface GameObject
public boolean isCommandable()
GameObject
isCommandable
in interface GameObject
public boolean isMonsterOrPlayer()
GameObject
isMonsterOrPlayer
in interface GameObject
public boolean isAttackable()
GameObject
isAttackable
in interface GameObject
public boolean inMapEditor()
GameObject
inMapEditor
in interface GameObject
public void addMapChangeListener(MapChangeListener l)
GameObject
addMapChangeListener
in interface GameObject
public void removeMapChangeListener(MapChangeListener l)
GameObject
removeMapChangeListener
in interface GameObject
protected void fireEnteredMap(GameMap map, int x, int y)
protected void fireExitedMap(GameMap map, int x, int y)
public void addMapMotionListener(MapMotionListener l)
GameObject
addMapMotionListener
in interface GameObject
public void removeMapMotionListener(MapMotionListener l)
GameObject
removeMapMotionListener
in interface GameObject
protected void fireMovedInMap(GameMap map, java.util.List src, java.util.List dest)
public void addContainerChangeListener(ContainerChangeListener l)
GameObject
addContainerChangeListener
in interface GameObject
public void removeContainerChangeListener(ContainerChangeListener l)
GameObject
removeContainerChangeListener
in interface GameObject
protected void fireContainerEntered(Bag bag)
protected void fireContainerExited(Bag bag)
public void addMotionTracker(MotionTracker t)
GameObject
addMotionTracker
in interface GameObject
public void removeMotionTracker(MotionTracker t)
GameObject
removeMotionTracker
in interface GameObject
public void addObjectTracker(ObjectTracker t)
GameObject
addObjectTracker
in interface GameObject
public void removeObjectTracker(ObjectTracker t)
GameObject
removeObjectTracker
in interface GameObject
protected void ensureListenerList()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |