wyvern.lib.classes.construct
Class ConnectedObject

java.lang.Object
  extended bywyvern.kernel.properties.PList
      extended bywyvern.kernel.maps.MapObject
          extended bywyvern.lib.classes.construct.ConnectedObject
All Implemented Interfaces:
Broadcaster, GameObject, MethodHookable, PropertyList
Direct Known Subclasses:
Road, Wall

public abstract class ConnectedObject
extends MapObject

This is the abstract superclass of walls & roads, which share the ability to connect with their neighbors.

Version:
1.0, May 16, 1998
Author:
Steve Yegge

Field Summary
protected  java.lang.String baseBitmapName_
           
 
Fields inherited from class wyvern.kernel.maps.MapObject
IN_MAP_EDITOR, listenerList_
 
Fields inherited from class wyvern.kernel.properties.PList
readOnly_
 
Fields inherited from interface wyvern.lib.PropertyList
PROPERTY_PACKAGE
 
Constructor Summary
ConnectedObject()
           
 
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.
abstract  Predicate getNeighborPredicate()
          Returns a Predicate that says whether a neighboring object is actually one of our neighbors.
 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()
          Initializes the object's default properties.
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()
          Overrides MapObject.remove() and updates neighboring squares.
 void setBaseBitmap()
          Get the base name for our bitmap (no directions)
 void setMap(GameMap map, int x, int y)
          Updates bitmap & 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.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, 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
 

Field Detail

baseBitmapName_

protected java.lang.String baseBitmapName_
Constructor Detail

ConnectedObject

public ConnectedObject()
Method Detail

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

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 coordinate
y - map y coordinate

setMap

public void setMap(GameMap map,
                   int x,
                   int y)
Updates bitmap & neighbors.

Specified by:
setMap in interface GameObject
Overrides:
setMap in class MapObject
Parameters:
map - the map to put the wall in
x - map x coordinate
y - map y coordinate

remove

public void remove()
Overrides MapObject.remove() and updates neighboring squares.

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 map
x - our x location
y - 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 there
dir - the direction string to add to the buffer
x - our map x location
y - our map y location
map - 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 neighbor
y - relative y position at which to check for neighbor
map - 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 map
x - map x coordinate
y - 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 abstract 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.

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.