wyvern.lib.properties
Class ProximityProperty

java.lang.Object
  extended bywyvern.kernel.properties.PList
      extended bywyvern.lib.properties.ProximityProperty
All Implemented Interfaces:
AddRemoveNotify, java.util.EventListener, MapChangeListener, MutableProperty, PropertyList, ProximityCallback
Direct Known Subclasses:
MonsterReactions, QuestInfo

public abstract class ProximityProperty
extends PList
implements MutableProperty, AddRemoveNotify, MapChangeListener, ProximityCallback

A utility class that you can use if you want a property that automatically registers a proximity hook to its object, when the object is placed in a map. The proximity hook will follow the object around as it moves in the map (or to other maps).

Version:
1.0, Aug 15, 2002
Author:
Steve Yegge

Field Summary
 
Fields inherited from class wyvern.kernel.properties.PList
readOnly_
 
Fields inherited from interface wyvern.lib.PropertyList
PROPERTY_PACKAGE
 
Constructor Summary
ProximityProperty()
           
 
Method Summary
 java.lang.Object createClone()
          Clones this property.
abstract  java.lang.String[] getHookNames()
           
abstract  Rectangle getProximityRect()
           
 GameObject getTarget()
          Returns the NPC we're attached to.
abstract  void hookEvent(java.lang.String hookName, GameObject target, CommandEvent data)
          The desired event has taken place within the specified range of the target that was passed to GameMap.addProximityHook().
 void notifyAdd(PropertyList obj)
          Notifies the property it's been added to the target.
 void notifyRemove(PropertyList obj)
          Notifies the property it's been removed from the monster.
 void targetEnteredMap(MapChangeEvent event)
          Notification that the target object has entered a map.
 void targetLeftMap(MapChangeEvent event)
          Notification that the target object has left its map.
 
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, toString, transientlyRemoveProperty
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ProximityProperty

public ProximityProperty()
Method Detail

getHookNames

public abstract java.lang.String[] getHookNames()

getProximityRect

public abstract Rectangle getProximityRect()

hookEvent

public abstract void hookEvent(java.lang.String hookName,
                               GameObject target,
                               CommandEvent data)
Description copied from interface: ProximityCallback
The desired event has taken place within the specified range of the target that was passed to GameMap.addProximityHook().

The callback object should be careful not to do too much processing on the calling thread. However, it's useful to note that when this method is called, the ProximityCallback object has the map-exclusive and can make changes to the map. This isn't true if it pushes the processing onto another thread.

Specified by:
hookEvent in interface ProximityCallback
Parameters:
hookName - the name of the hook (e.g. "sayPostHook") that's being run.
target - the object near which the event took place.
data - the event

notifyAdd

public void notifyAdd(PropertyList obj)
Notifies the property it's been added to the target. It registers with the target's "add" and "remove" hooks, and when the target is added or removed, it updates the proximity-hooks for you.

Specified by:
notifyAdd in interface AddRemoveNotify
Parameters:
obj - the monster to add the property to

notifyRemove

public void notifyRemove(PropertyList obj)
Notifies the property it's been removed from the monster.

Specified by:
notifyRemove in interface AddRemoveNotify
Parameters:
obj - the PropertyList we're being removed from

targetEnteredMap

public void targetEnteredMap(MapChangeEvent event)
Notification that the target object has entered a map. Registers the proximity hook(s) in that map.

Specified by:
targetEnteredMap in interface MapChangeListener

targetLeftMap

public void targetLeftMap(MapChangeEvent event)
Notification that the target object has left its map. Called at the end of the object's remove() function.

Specified by:
targetLeftMap in interface MapChangeListener

getTarget

public GameObject getTarget()
Returns the NPC we're attached to.


createClone

public java.lang.Object createClone()
Clones this property. Only copies the plist properties - if you have normal java instance variables you want copied, you should override this, call the superclass, then copy your instance members to the created object.

Specified by:
createClone in interface MutableProperty