From 164ed57ad35b4496dcd8da6fb8ec6546300c9036 Mon Sep 17 00:00:00 2001 From: Charles Krinke Date: Wed, 19 Nov 2008 18:41:10 +0000 Subject: Mantis#2638. Thank you kindly, Sacha Magne for a patch that: Implementing "Play sound inworld". Currently a WIP . --- OpenSim/Region/Environment/Scenes/Scene.cs | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'OpenSim/Region/Environment/Scenes/Scene.cs') diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 7ea4686..a9014e1 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -2342,12 +2342,31 @@ namespace OpenSim.Region.Environment.Scenes //Gesture client.OnActivateGesture += ActivateGesture; client.OnDeactivateGesture += DeactivateGesture; + //sound + client.OnSoundTrigger += SoundTrigger; client.OnObjectOwner += ObjectOwner; // EventManager.TriggerOnNewClient(client); } + // Sound + public virtual void SoundTrigger( UUID soundId, UUID ownerID, UUID objectID, UUID parentID, + float gain, Vector3 position, UInt64 handle) + { + foreach (ScenePresence p in 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); + } + + } + // Gesture public virtual void ActivateGesture(IClientAPI client, UUID assetId, UUID gestureId) { -- cgit v1.1