wyvern.lib.classes
Class Instrument
java.lang.Object
wyvern.kernel.properties.PList
wyvern.kernel.maps.MapObject
wyvern.lib.classes.DynamicObject
wyvern.lib.classes.Instrument
- All Implemented Interfaces:
- Applyable, Broadcaster, Command, Damageable, GameObject, HookCallback, MethodHookable, PropertyList, Subscriber
- public class Instrument
- extends DynamicObject
- implements Applyable, Command, HookCallback, Subscriber
A musical instrument. You can play it (or apply to play), and
people around you will hear. If you walk away from the instrument,
it stops playing.
If the instrument has a "must-carry" property, then you must be
carrying it to play it. If it has a "must-drop" property, then it
has to be on the ground to play it. If it has neither property,
then it can be played in either position.
When applied or played, the instrument checks if it has an
"usr-apply-msg" string property. If so, it prints it to the
agent. Next, the instrument checks if it has a "broadcast-msg"
string property. If so, it broadcasts it from the agent. The
agent doesn't hear broadcast messages, since you normally want them
to be in the 3rd person ("he/she"), but agent messages should be in
the 2nd person ("you"). Before sending out the broadcast message,
it substitutes the player's name for any instances of "%n" it finds
in the message.
Next, we check for a "sound-source" property with a Sound bean
value (usually a MovableSoundSource). If it has it, then it calls
the broadcast() method of the sound property.
If there's no "sound-source" property, it checks for a "sound-file"
string property, containing the relative path to a music or sound
file, including its extension. It will create and cache a
MovableSoundSource for this sound, if the file is found, and play
it to everyone in range.
- Version:
- 1.0, Jul 22, 2003
- Author:
- Steve Yegge
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, remove, 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, setMap, 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, destroy, 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, isCommandable, 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, setMap, 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 |
Instrument
public Instrument()
knowsCommand
public boolean knowsCommand(java.lang.String command)
- Returns true if we know the command.
- Specified by:
knowsCommand
in interface Command
- Parameters:
command
- the entire command string, including arguments
- Returns:
- true if we want to handle the command
createEvent
public CommandEvent createEvent(CommandEvent event)
- Creates the "play" event.
- Specified by:
createEvent
in interface Command
- Parameters:
event
- a "blank" CommandEvent containing only the
command text and the agent who's performing the command. This
initial event is created by the originator of the event (e.g.
the AI or player's command preprocessor).
- Returns:
- a CommandEvent subclass encapsulating this command's
execution parameters and state. It should copy in the fields
from the passed-in event.
execute
public boolean execute(CommandEvent event)
- Executes the "play" event.
- Specified by:
execute
in interface Command
- Parameters:
event
- the CommandEvent to execute
- Returns:
- true if the event completed successfully, else false.
apply
public void apply(Commandable agent)
- Calls play().
- Specified by:
apply
in interface Applyable
- Parameters:
agent
- the person applying the object
play
public void play(Commandable agent)
- Agent has started playing the instrument.
Broadcasts
messages and sounds, if specified as properties.
getSound
public Sound getSound()
- Returns a Sound object representing the sound this
instrument plays.
- Returns:
- the Sound to play for this object, or null if
we couldn't load the resource, or it wasn't specified
correctly.
setSound
public void setSound(Sound sound)
- Sets the Sound to use for this object. Normally you don't
call this method - you just set a "sound-source" property on the
Instrument specifying a Sound bean property, or a "sound-file"
property specifying the sound file to play.
- Parameters:
sound
- - stored in a property called "sound-source"
addHooks
public void addHooks(Commandable agent)
- Adds the hooks to the player.
removeHooks
public void removeHooks()
- Removes hooks from the player.
hookEvent
public void hookEvent(java.lang.String hookName,
CommandEvent event)
- The person playing us did something to stop playing.
- Specified by:
hookEvent
in interface HookCallback
- Parameters:
hookName
- the name of the hook, such as "movePreHook".event
- the CommandEvent encapsulating the event parameters
pubsubMessage
public void pubsubMessage(Message m)
- Our sound has stopped on some player's client. Remove hooks.
- Specified by:
pubsubMessage
in interface Subscriber
- Parameters:
m
- the message