wyvern.lib.classes
Class Vault

java.lang.Object
  extended bywyvern.kernel.properties.PList
      extended bywyvern.kernel.maps.AbstractGameMap
          extended bywyvern.kernel.maps.DenseMap
              extended bywyvern.lib.classes.Vault
All Implemented Interfaces:
Container, GameMap, GameMap.UnloadMapConstants, Hookable, HookCallback, MethodHookable, wyvern.kernel.lighting.Obstructions, PropertyList, SelfExternalizable

public class Vault
extends DenseMap
implements HookCallback

A personal, per-player storage area. Players can drop stuff in their vault and it will persist across resets. Should be instantiated via a mapfile that uses this as its map class.

Version:
1.0, Oct 13, 2000
Author:
Steve Yegge

Nested Class Summary
protected  class Vault.VaultTimer
          Receives the timer callback.
 
Nested classes inherited from class wyvern.lib.GameMap
GameMap.UnloadMapConstants
 
Field Summary
 
Fields inherited from class wyvern.kernel.maps.DenseMap
addRemoveListeners_, cachedBounds_, count_, lighting_, objects_, outOfBoundsTerrain_, size_
 
Fields inherited from class wyvern.kernel.maps.AbstractGameMap
ambient_, changeList_, commands_, dark_, defaultTerrain_, dense_, dirtyRegions_, lights_, locals_, mapHooks_, monsters_, name_, opaqueMap_, path_, perPlayer_, players_, proxHooks_, roomHooks_, suspended_, suspendTime_, suspendTimer_, teleporters_, unloadImmediately_, unloading_, visUpdates_, vpath_
 
Fields inherited from class wyvern.kernel.properties.PList
readOnly_
 
Fields inherited from interface wyvern.lib.GameMap
MAX_HEIGHT, MAX_SEARCH_RADIUS, MAX_WIDTH
 
Fields inherited from interface wyvern.lib.PropertyList
PROPERTY_PACKAGE
 
Fields inherited from interface wyvern.lib.GameMap.UnloadMapConstants
MAP_CONTAINS_PLAYERS, MAP_NOT_LOADED, SUCCESS
 
Constructor Summary
Vault(Dimension d)
          Constructs a new Vault
 
Method Summary
 void add(int x, int y, GameObject obj)
          Adds an object to the map.
 void hookEvent(java.lang.String hookName, CommandEvent ev)
          Gives the HookCallback a chance to do something with the passed event.
 void remove(int x, int y, GameObject obj)
          When the player leaves, save the vault contents.
 void removeBogusObjects()
          Goes through all the objects in the vault and removes any that shouldn't be saved out, such as monsters.
 void saveVault()
          Saves the vault contents to the vault file.
 void setTimer()
          Sets a timer after the last player leaves.
protected  boolean wantToRemove(java.lang.Object ob)
          Checks if we want to remove an object from the vault instead of saving it out.
 void writeVault()
          Writes the vault contents on a non-kernel thread.
 
Methods inherited from class wyvern.kernel.maps.DenseMap
add, addIntensityArray, adjustIntensity, checkBounds, checkBounds, createLightMatrix, dismantle, getBounds, getLightLevel, getObjectCount, getOrCreatecell, getOutOfBoundsTerrain, getProperties, getPropertyList, getSize, initialize, initialize, isSparse, iterator, keySet, objectsAt, objectsInRect, registerAddRemoveListener, remove, setOutOfBoundsTerrain, setOutOfBoundsTerrain, setSize, setTerrain, terrainAt, unregisterAddRemoveListener, visitRect
 
Methods inherited from class wyvern.kernel.maps.AbstractGameMap
addHook, addLight, addLocalArchetype, addMapLifecycleListener, addMethodHook, addMonster, addPlayer, addPlayerListener, addPropertyChangeListener, addPropertyChangeListener, addProximityHook, addRoomHook, addTeleporter, broadcast, broadcast, doneLoading, enableVisUpdates, findAt, findAt, findAt, findAt, findByName, findByName, findFreeSpot, findFreeSpot, findInRect, findTop, findTop, findTop, findUnder, fireMapLoaded, fireMapResumed, fireMapSuspended, fireMapUnloaded, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getArea, getClaim, getCommand, getDangerLevel, getDefaultTerrain, getExits, getFavorites, getHookList, getHooks, getLightingLevel, getLocalArchetype, getLocalArchetypes, getMonsterList, getMusic, getName, getObjectsAt, getPath, getPlayerList, getProfilingInfo, getPropertyChangeListeners, getPropertyChangeListeners, getProximityHookList, getResource, getRestartLoc, getRoomHookList, getStartLocation, getSuspendTime, getTerrainInfo, getTerrainRecord, getTerrainRecord, getUnloadDelay, getUpdateList, getVirtualPath, hasListeners, hasObstructions, initCommon, inMapEditor, invalidate, isBag, isEmpty, isEmpty, isInventory, isLit, isMap, isOpaque, isPerPlayer, isSuspended, isUnloaded, notifyPlayerListeners, readData, recomputeLights, registerCommand, removeFirst, removeHook, removeLight, removeLocalArchetype, removeMapLifecycleListener, removeMethodHook, removePlayer, removePlayerListener, removePropertyChangeListener, removePropertyChangeListener, removeProximityHook, removeRoomHook, removeTeleporter, resetOpaqueFlag, resetOpaqueFlag, resume, runFailedPostHook, runMethodHook, runPostHook, runPreHook, setAutoload, setDangerLevel, setDefaultTerrain, setDefaultTerrain, setFavorite, setLightingLevel, setLit, setName, setPath, setPerPlayer, setStartLocation, setTerrain, setUnloadDelay, shouldWrite, startSuspendTimer, startUnloadTimer, startUnloadTimer, suspend, toString, trackSpecialRemoves, unload, unregisterCommand, updateOpaque, updateTerrainCache, visitObjectsAt, visUpdate, wakeAllMonsters, wakeMonsters, wasAutoloaded, writeData
 
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, 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
 

Constructor Detail

Vault

public Vault(Dimension d)
Constructs a new Vault

Method Detail

add

public void add(int x,
                int y,
                GameObject obj)
Adds an object to the map.

Specified by:
add in interface GameMap
Overrides:
add in class DenseMap
Parameters:
x - map x location
y - map y location
obj - the object to add

remove

public void remove(int x,
                   int y,
                   GameObject obj)
When the player leaves, save the vault contents.

Specified by:
remove in interface GameMap
Overrides:
remove in class DenseMap
Parameters:
x - map x location
y - map y location
obj - the object reference to remove. Does nothing if the specified obj reference isn't found at (x, y).

setTimer

public void setTimer()
Sets a timer after the last player leaves. If the player reenters, the timer is stopped. If the timer expires, the vault will save its contents. The timer is necessary to prevent the vault from saving every time the player moves, which is really expensive.


saveVault

public void saveVault()
Saves the vault contents to the vault file.


writeVault

public void writeVault()
Writes the vault contents on a non-kernel thread.


removeBogusObjects

public void removeBogusObjects()
Goes through all the objects in the vault and removes any that shouldn't be saved out, such as monsters.


wantToRemove

protected boolean wantToRemove(java.lang.Object ob)
Checks if we want to remove an object from the vault instead of saving it out.

Parameters:
ob - a GameObject in the vault
Returns:
true if we want to remove it (i.e. not save it)

hookEvent

public void hookEvent(java.lang.String hookName,
                      CommandEvent ev)
Gives the HookCallback a chance to do something with the passed event. Sometimes more than one command is registered with the same verb (e.g. "turn wheel", "turn ring"), so the HookCallback should check the class of the passed CommandEvent and make sure it's the right event.

Specified by:
hookEvent in interface HookCallback
Parameters:
hookName - the name of the hook, such as "movePreHook".
ev - the CommandEvent encapsulating the event parameters