wyvern.lib.classes.construct
Class TerrainRoad
java.lang.Object
wyvern.kernel.properties.PList
wyvern.kernel.maps.MapObject
wyvern.lib.classes.Terrain
wyvern.lib.classes.construct.TerrainRoad
- All Implemented Interfaces:
- Broadcaster, GameObject, MethodHookable, Predicate, PropertyList, Terrain.NoFlyweight
- public class TerrainRoad
- extends Terrain
- implements Terrain.NoFlyweight, Predicate
A terrain type that connects itself like a road.
- Version:
- 1.0, May 28, 2001
- Author:
- Steve Yegge
Method Summary |
protected void |
applyBitmap(java.lang.String dirs)
Sets the bitmap based on a direction string. |
GameObject |
checkNeighbor(int x,
int y,
GameMap map)
Look in specified place for a neighbor of our type. |
void |
doUpdate()
Recomputes self & neighbor bitmaps. |
Predicate |
getNeighborPredicate()
Returns a predicate that returns true if the object is
another TerrainRoad. |
java.lang.String |
getWallBaseName()
Returns the unique substring immediately preceding the direction
suffix(es) in the bitmap name. |
boolean |
haveNeighbor(int x,
int y,
GameMap map)
Returns true if we have a neighbor at the specified location. |
void |
initialize()
Sets class-default properties. |
boolean |
predicate(GameObject obj)
Predicate for checking if an object is considered a neighboring wall.
|
protected void |
processNeighbor(java.lang.StringBuffer dirs,
java.lang.String dir,
int x,
int y,
GameMap map)
Helper method to look for a neighbor and tell it to redo
its bitmap. |
void |
remove()
Updates neighbors. |
void |
setBaseBitmap()
Get the base name for our bitmap (no directions) |
void |
setMap(GameMap map,
int x,
int y)
Connects to neighbors. |
protected java.lang.String |
stripDirs(java.lang.String type,
java.lang.String name)
Strips the directions off a wall or road filename. |
void |
teleport(int x,
int y)
Overrides MapObject.teleport(). |
void |
updateBitmap()
Updates our bitmap based on neighboring walls (or roads)
we find in the map. |
void |
updateBitmapAndNeighbors(int x,
int y,
GameMap map)
Chooses a bitmap for a wall based on its neighbors. |
Methods inherited from class wyvern.lib.classes.Terrain |
getCachedTerrain, getPriority, getTile, hasBorders, isCached, isOpaque, isTerrain, letsBordersIn, letsBordersOut, setAppearance, setHasBorders, setLetsBordersIn, setLetsBordersOut, setPriority |
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, getValue, getWeight, groupString, inContainer, initLocs, inMapEditor, invalidate, invalidateImage, invalidateParent, invalidateText, isAnimated, isAttackable, isBlessed, isCommandable, isCursed, isDamned, isGroupable, isIdentified, isMonster, isMonsterOrPlayer, isPlayer, 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, 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 |
baseBitmapName_
protected java.lang.String baseBitmapName_
TerrainRoad
public TerrainRoad()
initialize
public void initialize()
- Sets class-default properties.
- Specified by:
initialize
in interface GameObject
- Overrides:
initialize
in class Terrain
teleport
public void teleport(int x,
int y)
- Overrides MapObject.teleport(). Looks in adjacent squares
for neighboring Wall objects and updates the bitmap to join
with the neighboring walls. Wall.class doesn't override
MapObject.setLocations(), so you can use that method to put a
wall in the map without having it update its image.
- Specified by:
teleport
in interface GameObject
- Overrides:
teleport
in class MapObject
- Parameters:
x
- map x coordinatey
- map y coordinate
setMap
public void setMap(GameMap map,
int x,
int y)
- Connects to neighbors.
- Specified by:
setMap
in interface GameObject
- Overrides:
setMap
in class MapObject
remove
public void remove()
- Updates neighbors.
- Specified by:
remove
in interface GameObject
- Overrides:
remove
in class MapObject
doUpdate
public void doUpdate()
- Recomputes self & neighbor bitmaps.
updateBitmapAndNeighbors
public void updateBitmapAndNeighbors(int x,
int y,
GameMap map)
- Chooses a bitmap for a wall based on its neighbors.
- Parameters:
map
- our mapx
- our x locationy
- our y location
processNeighbor
protected void processNeighbor(java.lang.StringBuffer dirs,
java.lang.String dir,
int x,
int y,
GameMap map)
- Helper method to look for a neighbor and tell it to redo
its bitmap.
- Parameters:
dirs
- buffer to add direction to if we find neighbor theredir
- the direction string to add to the bufferx
- our map x locationy
- our map y locationmap
- our map
checkNeighbor
public GameObject checkNeighbor(int x,
int y,
GameMap map)
- Look in specified place for a neighbor of our type.
- 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
setBaseBitmap
public void setBaseBitmap()
- Get the base name for our bitmap (no directions)
updateBitmap
public void updateBitmap()
- Updates our bitmap based on neighboring walls (or roads)
we find in the map.
haveNeighbor
public boolean haveNeighbor(int x,
int y,
GameMap map)
- Returns true if we have a neighbor at the specified location.
- Parameters:
map
- our mapx
- map x coordinatey
- map y coordinate
- Returns:
- true if there's a neighbor there
applyBitmap
protected void applyBitmap(java.lang.String dirs)
- Sets the bitmap based on a direction string.
- Parameters:
dirs
- a constructed direction string, e.g. "NSE",
derived from the neigboring walls.
stripDirs
protected java.lang.String stripDirs(java.lang.String type,
java.lang.String name)
- Strips the directions off a wall or road filename.
- Parameters:
type
- "wall" or "road"name
- the filename, with no extension
- Returns:
- the base name
getNeighborPredicate
public Predicate getNeighborPredicate()
- Returns a predicate that returns true if the object is
another TerrainRoad.
- Returns:
- a predicate returning true for valid neighbors
predicate
public boolean predicate(GameObject obj)
- Predicate for checking if an object is considered a neighboring wall.
If the wall has "noconnect" set, it never connects to any other
wall. If it has the "nojoin" property, it will only connect to
other walls of it's "join-type". All walls with the same
"join-type" property (not set by default) will join together.
So walls without a "join-type" set will join with other types
that also don't have "join-type" set.
- Specified by:
predicate
in interface Predicate
- Parameters:
obj
- any GameObject
- Returns:
- true if the object passes, else false
getWallBaseName
public java.lang.String getWallBaseName()
- Returns the unique substring immediately preceding the direction
suffix(es) in the bitmap name. For example, if the bitmap name
is CastleWallNSEW, the base name is "wall". Roads return "road",
doors return "door", etc.
Returns the base name set in the "base-name" property, if any,
or "wall" by default.