wyvern.lib.classes.construct
Class Gate
java.lang.Object
wyvern.kernel.properties.PList
wyvern.kernel.maps.MapObject
wyvern.kernel.commands.AbstractCommandable
wyvern.lib.classes.construct.Gate
- All Implemented Interfaces:
- Activatable, Broadcaster, Commandable, GameObject, Hookable, MethodHookable, PropertyList, RemoteAudio, Timed
- public class Gate
- extends AbstractCommandable
- implements Activatable, Timed
This class implements a gate that opens slowly & animates while
it opens. A gate is typically activated (opened or closed) via
a lever, switch or button of some sort.
The Gate class extends AbstractCommandable because it needs to
be able to damage monsters. The combat system used to require
attackers to be Commandable objects. It can now accept any
GameObject as an attacker, but the Gate class hasn't been updated.
You can set a property called "opaque-closed" on the gate, and
it will block visibility when it closes.
- Version:
- 1.0, Nov 10, 1998
- Author:
- Steve Yegge
Field Summary |
static int |
CLOSED
|
static int |
CLOSING
|
static int |
DEFAULT_RATE
Default speed at which the gate opens or closes. |
int |
ignore_
How many opening attempts to ignore. |
static int |
OPEN
Valid states for the gate. |
static int |
OPENING
|
protected Timer |
timer_
Timer for opening or closing the gate. |
Constructor Summary |
Gate()
|
Method Summary |
void |
activate()
Activates the gate (toggles its position). |
protected void |
beginClosing(int state)
Starts closing the gate. |
protected void |
beginOpening(int state)
Starts opening the gate. |
protected boolean |
checkBlocked(java.lang.String base,
int suffix,
int min,
int max)
See if we're being blocked open by something. |
protected void |
continueClosing(java.lang.String base,
int suffix,
int min,
int max)
Closes the gate one more step. |
protected void |
continueOpening(java.lang.String base,
int suffix,
int min,
int max)
Opens the gate one more step. |
protected void |
damageMonster(Monster m)
Does crush and/or spike damage to a monster. |
void |
destroy()
Destroys the object. |
protected void |
determineInitialState()
Determines whether it's blocking, what the initial image is,
etc. from the "open" property. |
protected void |
ensureBaseImage()
Makes sure there's a "base-bmp" (string prop) image specified. |
int |
getRate()
Returns the rate at which the gate opens or closes. |
int |
getState()
Returns the current (transient) state of the gate,
stored in the @state int property. |
protected int |
getSuffix()
Returns the current bitmap number we're displaying, stored in
the @suffix property. |
void |
initialize()
Adds class-default properties.
|
void |
setMap(GameMap map,
int x,
int y)
Sets the gate in the map. |
void |
setRate(int rate)
Sets the rate at which the gate opens or closes. |
void |
setState(int state)
Sets the current state of the gate. |
protected void |
setSuffix(int suffix)
Sets the current bitmap number we're displaying. |
void |
timerExpired()
Our timer went off. |
protected void |
updateOpaqueFlag()
Tells the map to recalculate the visibility bit at our location. |
Methods inherited from class wyvern.kernel.commands.AbstractCommandable |
addAttack, addHook, addMessageListener, addMethodHook, checkAnimated, command, command, commandNow, ensureAI, ensureEventQueue, fireMessageReceived, getAI, getCapName, getCombatQueue, getCommand, getEncumbrance, getFiringPoint, getHookList, getHooks, getInventory, getName, getQueue, isCommandable, isStarted, isTelnet, message, message, message, pauseSound, playAlert, playAlert, playDefaultMusic, playPriorityMusic, playPriorityMusic, playSound, playSound, registerCommand, removeAttack, removeHook, removeMessageListener, removeMethodHook, resumeSound, runFailedPostHook, runMethodHook, runPostHook, runPreHook, sendPicture, sendPicture, setAI, setEncumbrance, setMusicGain, setName, setSoundGain, start, stop, stopAllSounds, stopMusic, stopSound, unregisterCommand |
Methods inherited from class wyvern.kernel.maps.MapObject |
addContainerChangeListener, addDefaultProperty, addMapChangeListener, addMapMotionListener, addMotionTracker, addObjectTracker, addPrefix, addSuffix, addToMap, bless, broadcast, broadcast, broadcast, broadcast, broadcast, canEnter, canEnterBlockedBy, canMove, canMove, canMoveBlockedBy, canMoveBlockedBy, canMoveTo, canMoveToBlockedBy, checkDrop, curse, cycleFrame, 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, isCursed, isDamned, isGroupable, isIdentified, isMonster, isMonsterOrPlayer, isPlayer, isTerrain, isUncursed, isUnpaid, isWizard, makeClone, markPaid, markUnpaid, move, occupies, positionAt, positionAtMap, remove, removeContainerChangeListener, removeFromMap, removeMapChangeListener, removeMapMotionListener, removeMotionTracker, removeObjectTracker, removePrefix, removeSuffix, 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.GameObject |
addContainerChangeListener, addMapChangeListener, addMapMotionListener, addMotionTracker, addObjectTracker, addPrefix, addSuffix, bless, canEnter, canEnterBlockedBy, canMove, canMove, canMoveBlockedBy, canMoveBlockedBy, canMoveTo, canMoveToBlockedBy, checkDrop, curse, cycleFrame, externalize, getAlpha, getAppearance, getArchetype, 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, inContainer, inMapEditor, invalidate, invalidateImage, invalidateParent, invalidateText, isAnimated, isAttackable, isBlessed, isCursed, isDamned, isGroupable, isIdentified, isMonster, isMonsterOrPlayer, isPlayer, isTerrain, isUncursed, isUnpaid, isWizard, makeClone, markPaid, markUnpaid, move, occupies, positionAt, positionAtMap, remove, removeContainerChangeListener, removeMapChangeListener, removeMapMotionListener, removeMotionTracker, removeObjectTracker, removePrefix, removeSuffix, setAlpha, setAnimated, setBitmap, setCategory, setContainer, setDirection, setImage, setImage, setLayer, setLocations, setMapLink, setQuantity, setShape, setSize, setTransientSize, setWeight, setWeight, teleport |
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 |
OPEN
public static final int OPEN
- Valid states for the gate.
- See Also:
- Constant Field Values
CLOSED
public static final int CLOSED
- See Also:
- Constant Field Values
OPENING
public static final int OPENING
- See Also:
- Constant Field Values
CLOSING
public static final int CLOSING
- See Also:
- Constant Field Values
DEFAULT_RATE
public static final int DEFAULT_RATE
- Default speed at which the gate opens or closes.
- See Also:
- Constant Field Values
timer_
protected Timer timer_
- Timer for opening or closing the gate. Null when the
gate is completely open or completely closed.
ignore_
public int ignore_
- How many opening attempts to ignore.
Gate
public Gate()
initialize
public void initialize()
- Adds class-default properties.
A gate expects to find a base image name set as its bitmap,
such as "iron_gate". It will append a "4" to it (the fully
closed version of the image), unless it finds an "open" property
in its archetype, in which case it appends a "1".
- Specified by:
initialize
in interface GameObject
- Overrides:
initialize
in class MapObject
determineInitialState
protected void determineInitialState()
- Determines whether it's blocking, what the initial image is,
etc. from the "open" property.
ensureBaseImage
protected void ensureBaseImage()
- Makes sure there's a "base-bmp" (string prop) image specified.
activate
public void activate()
throws java.lang.Exception
- Activates the gate (toggles its position).
- Specified by:
activate
in interface Activatable
- Throws:
any
- exception if we can't activate
java.lang.Exception
beginOpening
protected void beginOpening(int state)
- Starts opening the gate. If the gate is already open,
or already opening, does nothing.
beginClosing
protected void beginClosing(int state)
- Starts closing the gate. If the gate is already closed,
or already closing, does nothing.
timerExpired
public void timerExpired()
- Our timer went off.
- Specified by:
timerExpired
in interface Timed
continueOpening
protected void continueOpening(java.lang.String base,
int suffix,
int min,
int max)
- Opens the gate one more step.
checkBlocked
protected boolean checkBlocked(java.lang.String base,
int suffix,
int min,
int max)
- See if we're being blocked open by something.
- Returns:
- true if we were blocked
damageMonster
protected void damageMonster(Monster m)
- Does crush and/or spike damage to a monster. For now,
damage is hardwired in both type and WC.
continueClosing
protected void continueClosing(java.lang.String base,
int suffix,
int min,
int max)
- Closes the gate one more step.
getState
public int getState()
- Returns the current (transient) state of the gate,
stored in the @state int property.
setState
public void setState(int state)
- Sets the current state of the gate.
setMap
public void setMap(GameMap map,
int x,
int y)
- Sets the gate in the map. Updates opaque flag.
- Specified by:
setMap
in interface GameObject
- Overrides:
setMap
in class MapObject
updateOpaqueFlag
protected void updateOpaqueFlag()
- Tells the map to recalculate the visibility bit at our location.
getSuffix
protected int getSuffix()
- Returns the current bitmap number we're displaying, stored in
the @suffix property.
setSuffix
protected void setSuffix(int suffix)
- Sets the current bitmap number we're displaying.
setRate
public void setRate(int rate)
- Sets the rate at which the gate opens or closes.
getRate
public int getRate()
- Returns the rate at which the gate opens or closes.
destroy
public void destroy()
- Destroys the object.
- Specified by:
destroy
in interface GameObject
- Overrides:
destroy
in class AbstractCommandable