From cce1b096dbd8aba46c405b7654d67d3ba96de33a Mon Sep 17 00:00:00 2001 From: Justin Clarke Casey Date: Tue, 23 Dec 2008 17:54:13 +0000 Subject: * refactor: Replace part of SceneObjectPart with the identical sound playing code in the SoundModule --- .../Environment/Modules/World/Sound/SoundModule.cs | 23 +++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region/Environment/Modules/World/Sound/SoundModule.cs') diff --git a/OpenSim/Region/Environment/Modules/World/Sound/SoundModule.cs b/OpenSim/Region/Environment/Modules/World/Sound/SoundModule.cs index 7c89466..4547480 100644 --- a/OpenSim/Region/Environment/Modules/World/Sound/SoundModule.cs +++ b/OpenSim/Region/Environment/Modules/World/Sound/SoundModule.cs @@ -61,20 +61,37 @@ namespace OpenSim.Region.Environment.World.Sound client.OnSoundTrigger += TriggerSound; } + public virtual void PlayAttachedSound( + UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags) + { + foreach (ScenePresence p in m_scene.GetAvatars()) + { + double dis = Util.GetDistanceTo(p.AbsolutePosition, position); + if (dis > 100.0) // Max audio distance + continue; + + // Scale by distance + gain = (float)((double)gain*((100.0 - dis) / 100.0)); + + p.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, (float)gain, flags); + } + } + public virtual void TriggerSound( - UUID soundId, UUID ownerID, UUID objectID, UUID parentID, float gain, Vector3 position, UInt64 handle) + UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle) { foreach (ScenePresence p in m_scene.GetAvatars()) { double dis = Util.GetDistanceTo(p.AbsolutePosition, position); if (dis > 100.0) // Max audio distance continue; - + // Scale by distance gain = (float)((double)gain*((100.0 - dis) / 100.0)); + p.ControllingClient.SendTriggeredSound( soundId, ownerID, objectID, parentID, handle, position, (float)gain); } - } + } } } -- cgit v1.1