wyvern.lib.classes.construct
Class Mountains
java.lang.Object
wyvern.kernel.properties.PList
wyvern.kernel.maps.MapObject
wyvern.lib.classes.construct.Mountains
- All Implemented Interfaces:
- Broadcaster, GameObject, MethodHookable, Predicate, PropertyList, Visitor
- public class Mountains
- extends MapObject
- implements Visitor, Predicate
A configurable mountain-range class with support for its own
borders. Mountain borders are first-class objects, unlike terrain
borders, which are just images. Mountains support the "noconnect"
boolean property, which means don't create borders, and the
"nojoin" property, which means to treat objects as neighbors only
if they're of exactly the same class (not subclasses).
- Version:
- 1.0, Jul 23, 2000
- Author:
- Steve Yegge
Method Summary |
void |
addBorder(java.lang.String name,
int x,
int y)
Adds a border to the map. |
protected boolean |
checkNeighbor(GameMap map,
int x,
int y)
Look in specified place for a neighbor of our type.
|
Predicate |
getNeighborPredicate()
Returns a Predicate that says whether a neighboring object
is actually one of our neighbors. |
void |
initialize()
Initializes the object's default properties. |
boolean |
predicate(GameObject obj)
Determines whether a neighboring object is one of our neighbors. |
void |
recomputeBorders(GameMap map,
java.lang.String base,
int x,
int y)
A neighbor to this 2x2 area has been added or removed, so we
need to recompute the borders here, if any. |
void |
redoBorders(GameMap map,
int x,
int y)
Looks at neighboring mountains, and adds borders if necessary. |
void |
remove()
Tell the squares around us to recompute their borders. |
protected boolean |
removeExistingMountains(GameMap map,
int x,
int y)
Removes existing mountains under certain circumstances. |
void |
setMap(GameMap map,
int x,
int y)
Sets the mountain in the map. |
void |
visit(GameObject obj)
Checks whether old borders need to be removed from the map.
|
Methods inherited from class wyvern.kernel.maps.MapObject |
addContainerChangeListener, addDefaultProperty, addMapChangeListener, addMapMotionListener, addMethodHook, addMotionTracker, addObjectTracker, addPrefix, addSuffix, addToMap, bless, broadcast, broadcast, broadcast, broadcast, broadcast, canEnter, canEnterBlockedBy, canMove, canMove, canMoveBlockedBy, canMoveBlockedBy, canMoveTo, canMoveToBlockedBy, checkDrop, curse, cycleFrame, destroy, ensureListenerList, ensureWeight, externalize, fireContainerEntered, fireContainerExited, fireEnteredMap, fireExitedMap, fireMovedInMap, getAlpha, getAppearance, getArchetype, getBaseName, getBaseWeight, getBitmap, getBounds, getCanonicalClassName, getCategory, getContainer, getCreator, getDamagedDescription, getDescription, getDirection, getGenderPossessive, getGenderPronoun, getImage, getImageDescriptor, getImageDescriptors, getLayer, getLocations, getMap, getMapLink, getMaterial, getMaterialDescription, getMover, getOwningPlayer, getParentMap, getPrefixes, getQuantity, getReferenceLoc, getRelativeLocs, getShortDesc, getSuffixes, getTile, getTile, getValue, getWeight, groupString, inContainer, initLocs, inMapEditor, invalidate, invalidateImage, invalidateParent, invalidateText, isAnimated, isAttackable, isBlessed, isCommandable, isCursed, isDamned, isGroupable, isIdentified, isMonster, isMonsterOrPlayer, isPlayer, isTerrain, isUncursed, isUnpaid, isWizard, makeClone, markPaid, markUnpaid, move, occupies, positionAt, positionAtMap, removeContainerChangeListener, removeFromMap, removeMapChangeListener, removeMapMotionListener, removeMethodHook, removeMotionTracker, removeObjectTracker, removePrefix, removeSuffix, runMethodHook, setAlpha, setAnimated, setBitmap, setCategory, setContainer, setDefaultBitmap, setDefaultCategory, setDefaultDesc, setDefaultImage, setDefaultIntProperty, setDefaultLayer, setDefaultMaterial, setDefaultProperty, setDefaultShortDesc, setDirection, setImage, setImage, setLayer, setLocations, setMapLink, setQuantity, setShape, setSize, setTransientSize, setWeight, setWeight, teleport, toString, updateMapLocation |
Methods inherited from class wyvern.kernel.properties.PList |
addProperty, addTransientProperty, adjustDoubleProperty, adjustIntProperty, adjustLongProperty, adjustTransientDoubleProperty, adjustTransientIntProperty, adjustTransientLongProperty, countLocalProperties, debugProperties, dismantlePropertyList, getDoubleProperty, getInheritedProperty, getInteger, getIntProperty, getLocalProperties, getLocalProperty, getLongProperty, getParent, getPersistentDoubleProperty, getPersistentIntProperty, getPersistentLocalProperties, getPersistentLongProperty, getPersistentProperty, getProfilingInfo, getProperties, getProperties, getPropertiesIncludingTransients, getPropertiesIncludingTransients, getProperty, getSerializableProperties, getSerializableProperty, getStringProperty, getTransientDoubleProperty, getTransientIntProperty, getTransientLongProperty, getTransientProperties, getTransientProperty, hasLocalProperty, hasPersistentProperty, hasProperty, hasTransientProperty, inheritProperty, isReadOnly, isRemoved, isTransientlyRemoved, printLocalProperties, printProperties, printProperties, printTransientProperties, removeProperty, removeTransientProperty, setDoubleProperty, setIntProperty, setLongProperty, setParent, setProperty, setReadOnly, setTransientDoubleProperty, setTransientIntProperty, setTransientLongProperty, setTransientProperty, toString, transientlyRemoveProperty |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface wyvern.lib.PropertyList |
addProperty, addTransientProperty, adjustDoubleProperty, adjustIntProperty, adjustLongProperty, adjustTransientDoubleProperty, adjustTransientIntProperty, adjustTransientLongProperty, countLocalProperties, getDoubleProperty, getInheritedProperty, getIntProperty, getLocalProperties, getLocalProperty, getLongProperty, getParent, getPersistentDoubleProperty, getPersistentIntProperty, getPersistentLocalProperties, getPersistentLongProperty, getPersistentProperty, getProperties, getProperties, getPropertiesIncludingTransients, getPropertiesIncludingTransients, getProperty, getSerializableProperties, getSerializableProperty, getStringProperty, getTransientDoubleProperty, getTransientIntProperty, getTransientLongProperty, getTransientProperties, getTransientProperty, hasLocalProperty, hasPersistentProperty, hasProperty, hasTransientProperty, inheritProperty, isReadOnly, isRemoved, isTransientlyRemoved, printLocalProperties, printProperties, printProperties, printTransientProperties, removeProperty, removeTransientProperty, setDoubleProperty, setIntProperty, setLongProperty, setParent, setProperty, setReadOnly, setTransientDoubleProperty, setTransientIntProperty, setTransientLongProperty, setTransientProperty, toString, transientlyRemoveProperty |
Mountains
public Mountains()
initialize
public void initialize()
- Description copied from interface:
GameObject
- Initializes the object's default properties. Any GameObject
implementation that wishes to initialize itself should do so
here, rather than in the constructor. This is because nearly
all game objects inherit from an archetype, and the archetype
parent pointer isn't set until the object's constructor finishes.
This is a good place to add any class-default properties for
an object - properties that the object gets regardless of
which archetype it inherits from.
WARNING: don't forget to call the superclass' initialize()
method, or the object may not function properly. For instance,
it won't become animated even if it specifies animation parameters
in the archetype.
- Specified by:
initialize
in interface GameObject
- Overrides:
initialize
in class MapObject
setMap
public void setMap(GameMap map,
int x,
int y)
- Sets the mountain in the map. Adds border objects for
the mountain if the map is being edited in the map editor.
- Specified by:
setMap
in interface GameObject
- Overrides:
setMap
in class MapObject
remove
public void remove()
- Tell the squares around us to recompute their borders.
- Specified by:
remove
in interface GameObject
- Overrides:
remove
in class MapObject
removeExistingMountains
protected boolean removeExistingMountains(GameMap map,
int x,
int y)
- Removes existing mountains under certain circumstances.
- Parameters:
map
- the proposed mapx
- the proposed x location to add the mountainsy
- the proposed y location to add the mountains
- Returns:
- true if we should continue; false not to set in map
redoBorders
public void redoBorders(GameMap map,
int x,
int y)
- Looks at neighboring mountains, and adds borders if necessary.
recomputeBorders
public void recomputeBorders(GameMap map,
java.lang.String base,
int x,
int y)
- A neighbor to this 2x2 area has been added or removed, so we
need to recompute the borders here, if any.
- Parameters:
map
- the map to recompute the borders for. Required
as a parameter because this method can be called after a
mountain has been removed.base
- the base name for the border bitmap (including path)x
- map x location (upper-left of 2x2 area to recompute)y
- map y location (upper-left of 2x2 area to recompute)
addBorder
public void addBorder(java.lang.String name,
int x,
int y)
- Adds a border to the map.
checkNeighbor
protected boolean checkNeighbor(GameMap map,
int x,
int y)
- Look in specified place for a neighbor of our type.
We're only looking for actual Mountains objects, not borders.
- Parameters:
x
- relative x position at which to check for neighbory
- relative y position at which to check for neighbormap
- map the wall is in (must not be null)
- Returns:
- true if there's a wall of this type there
getNeighborPredicate
public Predicate getNeighborPredicate()
- Returns a Predicate that says whether a neighboring object
is actually one of our neighbors.
- Returns:
- a Predicate that checkNeighbors() will use to determine
if a given object is a connected neighbor.
predicate
public boolean predicate(GameObject obj)
- Determines whether a neighboring object is one of our neighbors.
- Specified by:
predicate
in interface Predicate
- Parameters:
obj
- an object to consider
- Returns:
- true if the passed object is of the same class as us,
is not a border, doesn't have the "noconnect" property, has
the same archetype as we do, and doesn't have "nojoin" plus
a different java class than we do.
visit
public void visit(GameObject obj)
- Checks whether old borders need to be removed from the map.
Called when we're added to the map.
- Specified by:
visit
in interface Visitor