|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object wyvern.lib.properties.SimpleSound wyvern.lib.properties.MovableSoundSource
An object responsible for managing a single instance of a sound. It keeps track of who can currently hear it, and if they get out of range, it makes sure they stop hearing it.
Every sound is logically attached to an owner, which must be a GameObject. If you want your map to have sounds, you need to create (possibly invisible) objects in the map that emit and manage the sounds, each of which has a MovableSoundSource property.
Field Summary | |
protected java.util.List |
listeners_
The list of players who can currently hear the sound. |
protected GameObject |
owner_
The thing that's emitting the sound: a player, a harp, a music box, or anything else. |
protected int |
repeatDelay_
Number of milliseconds to pause between repeats. |
protected int |
repeats_
Number of times to repeat the sound before stopping. 0 = only play once. |
protected java.lang.String |
subject_
The pubsub subject we listen for, to get a notification that the endsound came in from a client. |
Fields inherited from class wyvern.lib.properties.SimpleSound |
gain_, path_ |
Fields inherited from interface wyvern.lib.Music |
DEFAULT_COMBAT_MUSIC, DEFAULT_FUNERAL_MUSIC, DEFAULT_GAIN, DEFAULT_LEVELUP_MUSIC, DEFAULT_LOW_HP_COMBAT_MUSIC, DEFAULT_REPEAT_DELAY, DEFAULT_REPEATS, LOOP_FOREVER, PRIORITY_HIGH, PRIORITY_NORMAL |
Constructor Summary | |
MovableSoundSource()
Constructs a new MovableSoundSource. |
|
MovableSoundSource(java.lang.String path,
GameObject owner)
Constructs a new MovableSoundSource. |
Method Summary | |
protected void |
addHooks(GameObject agent)
Registers hooks for a particular player, or the owner object. |
void |
addListener(Player player)
Adds a player to the set of players who can hear this sound. |
void |
broadcast()
Broadcasts this sound to all the players within earshot of the owner. |
java.lang.Object |
createClone()
Creates a clone of this object. |
java.lang.String |
getID()
Returns the unique ID for this sound. |
GameObject |
getOwner()
Returns the object that's emitting this sound. |
java.lang.String |
getPath()
Returns the path to the sound file for this MovableSoundSource. |
java.lang.String |
getPropName()
Returns the name of the property we store ourselves under automatically. |
int |
getRepeatDelay()
Returns delay in millis between repeats |
int |
getRepeats()
Returns number of times to repeat before stopping and sending a notification to the server that we're done. |
java.lang.String |
getStopSubject()
Pubsub subject for notification from the client when the sound has finished playing. |
void |
hookEvent(java.lang.String hookName,
CommandEvent event)
Hooks move and teleport for listeners, so we can adjust the sound volume. |
void |
methodCalled(java.lang.String hookName,
MethodHookable target,
java.lang.Object data)
Owner was added to or removed from its map. |
void |
notifyAdd(PropertyList list)
This sound has been added to a GameObject. |
void |
notifyRemove(PropertyList list)
We've been removed from the owner's property list. |
void |
playerLeft(Player p)
Removes a player from the set of people who can hear this sound. |
void |
pubsubMessage(Message m)
We got an #endsound message from the client, with our track ID in it. |
protected void |
removeHooks(GameObject agent)
Removes hooks for a particular player, or the owner object. |
void |
removeListener(java.lang.String name)
Removes a player from our list of people who can hear the sound. |
void |
setCleanupOnStop()
Tells the sound source that as soon as it stops, it should unlink itself from its owner. |
void |
setOwner(GameObject owner)
Sets the owner for this sound. |
void |
setPath(java.lang.String path)
Sets the path on this sound source. |
void |
setRepeatDelay(int repeatDelay)
Sets delay in millis between repeats |
void |
setRepeats(int repeats)
Sets number of times to repeat the music before stopping. |
void |
stop()
Stops the sound. |
void |
targetEnteredContainer(ContainerChangeEvent event)
Target object was added to a bag or inventory. |
void |
targetEnteredMap(MapChangeEvent event)
Notification that the target object has entered a map. |
void |
targetLeftContainer(ContainerChangeEvent event)
Target object was removed from a bag or inventory. |
void |
targetLeftMap(MapChangeEvent event)
Notification that the target object has left its map. |
void |
targetMoved(MapMotionEvent event)
Notification that the target object has moved in its map. |
java.lang.String |
toString()
Returns a debugging string. |
void |
unlinkFromOwner()
Removes ourself from the owner's property list, and removes our hooks from the owner. |
Methods inherited from class wyvern.lib.properties.SimpleSound |
get, getGain, setGain |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface wyvern.lib.Alert |
getGain, setGain |
Field Detail |
protected GameObject owner_
protected java.util.List listeners_
protected java.lang.String subject_
protected int repeats_
protected int repeatDelay_
Constructor Detail |
public MovableSoundSource()
public MovableSoundSource(java.lang.String path, GameObject owner)
owner
- the owner of the sound, so if people move
away from it, the sound volume decreases, and if the owner
moves, the sound moves as well.path
- the relative path to the file to play,
such as "music/midi/riff-harp.mid", or "wiz/foo/music/foo.wav".
The file extension is required. If filename is null,
the method just returns silently.Method Detail |
public void setCleanupOnStop()
public java.lang.String getPropName()
public void setOwner(GameObject owner)
owner
- the new owner of the sound
java.lang.IllegalStateException
- if the owner has already
been initialized.public void setPath(java.lang.String path)
setPath
in interface Alert
setPath
in class SimpleSound
path
- the relative path to the sound file to play.public java.lang.String getPath()
getPath
in interface Alert
getPath
in class SimpleSound
public final java.lang.String getID()
getID
in interface Sound
public GameObject getOwner()
public java.lang.String getStopSubject()
getStopSubject
in interface Sound
Returns null if this is not a stoppable sound, i.e. the ID is "-1".
public int getRepeats()
getRepeats
in interface Music
public void setRepeats(int repeats)
setRepeats
in interface Music
repeats
- number of times to repeat. A value of
zero (0) means to play the piece once and stop, with no
repeats. A value of -1 means to loop continuously.public int getRepeatDelay()
getRepeatDelay
in interface Music
public void setRepeatDelay(int repeatDelay)
setRepeatDelay
in interface Music
repeatDelay
- delay in millis between repeatspublic void notifyAdd(PropertyList list)
notifyAdd
in interface AddRemoveNotify
list
- the PropertyList whose property list we're being
added topublic void notifyRemove(PropertyList list)
notifyRemove
in interface AddRemoveNotify
list
- the PropertyList we're being removed frompublic void pubsubMessage(Message m)
pubsubMessage
in interface Subscriber
m
- the message whose body is the player namepublic void broadcast()
Configurable via properties (TBD).
broadcast
in interface Sound
public void stop()
stop
in interface Sound
public void unlinkFromOwner()
public void addListener(Player player)
public void playerLeft(Player p)
public void removeListener(java.lang.String name)
name
- the name of the playerprotected void addHooks(GameObject agent)
protected void removeHooks(GameObject agent)
public void hookEvent(java.lang.String hookName, CommandEvent event)
hookEvent
in interface HookCallback
hookName
- the name of the hook, such as "movePreHook".event
- the CommandEvent encapsulating the event parameterspublic void methodCalled(java.lang.String hookName, MethodHookable target, java.lang.Object data)
methodCalled
in interface MethodHookCallback
hookName
- the name of the hook being runtarget
- the object on which the method was invoked:
a GameMap or GameObject.data
- a method-specific data object; can be null.
Check the documentation for the method hook to see if
any data is passed to the callbacks.public void targetEnteredMap(MapChangeEvent event)
MapChangeListener
targetEnteredMap
in interface MapChangeListener
public void targetLeftMap(MapChangeEvent event)
MapChangeListener
targetLeftMap
in interface MapChangeListener
public void targetMoved(MapMotionEvent event)
MapMotionListener
targetMoved
in interface MapMotionListener
public void targetEnteredContainer(ContainerChangeEvent event)
ContainerChangeListener
targetEnteredContainer
in interface ContainerChangeListener
public void targetLeftContainer(ContainerChangeEvent event)
ContainerChangeListener
targetLeftContainer
in interface ContainerChangeListener
public java.lang.Object createClone()
createClone
in interface MutableProperty
public java.lang.String toString()
toString
in class SimpleSound
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |