From c30b5ee0144faf60bcdaf6f79c91e3eeb316f104 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Fri, 29 May 2009 23:49:48 +0000 Subject: * Adds World.Audio.* to MRM * This includes methods such as PlaySound which take a Position as an argument, allowing you to trigger sounds arbitrarily across the scene without needing a parent object in the position. --- .../Scripting/Minimodule/Interfaces/IWorld.cs | 3 ++ .../OptionalModules/Scripting/Minimodule/World.cs | 33 +++++++++++++++++++++- .../Scripting/Minimodule/WorldX/IWorldAudio.cs | 13 +++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 OpenSim/Region/OptionalModules/Scripting/Minimodule/WorldX/IWorldAudio.cs diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IWorld.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IWorld.cs index acb569f..3c14ed5 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IWorld.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IWorld.cs @@ -26,6 +26,7 @@ */ using System; +using OpenSim.Region.OptionalModules.Scripting.Minimodule.WorldX; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { @@ -50,6 +51,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule IAvatar[] Avatars { get; } IParcel[] Parcels { get; } IHeightmap Terrain { get; } + IWorldAudio Audio { get; } + event OnChatDelegate OnChat; event OnNewUserDelegate OnNewUser; diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs index dc80dcc..1ec4a33 100644 --- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs @@ -26,13 +26,15 @@ */ using System.Collections.Generic; +using OpenMetaverse; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.OptionalModules.Scripting.Minimodule.WorldX; namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { - public class World : System.MarshalByRefObject, IWorld + public class World : System.MarshalByRefObject, IWorld, IWorldAudio { private readonly Scene m_internalScene; private readonly Heightmap m_heights; @@ -93,6 +95,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule private event OnChatDelegate _OnChat; private bool _OnChatActive; + public IWorldAudio Audio + { + get { return this; } + } + public event OnChatDelegate OnChat { add @@ -211,5 +218,29 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule { get { return m_heights; } } + + #region Implementation of IWorldAudio + + public void PlaySound(UUID audio, Vector3 position, double volume) + { + ISoundModule soundModule = m_internalScene.RequestModuleInterface(); + if (soundModule != null) + { + soundModule.TriggerSound(audio, UUID.Zero, UUID.Zero, UUID.Zero, volume, position, + m_internalScene.RegionInfo.RegionHandle); + } + } + + public void PlaySound(UUID audio, Vector3 position) + { + ISoundModule soundModule = m_internalScene.RequestModuleInterface(); + if (soundModule != null) + { + soundModule.TriggerSound(audio, UUID.Zero, UUID.Zero, UUID.Zero, 1.0, position, + m_internalScene.RegionInfo.RegionHandle); + } + } + + #endregion } } diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/WorldX/IWorldAudio.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/WorldX/IWorldAudio.cs new file mode 100644 index 0000000..a131567 --- /dev/null +++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/WorldX/IWorldAudio.cs @@ -0,0 +1,13 @@ +using System; +using System.Collections.Generic; +using System.Text; +using OpenMetaverse; + +namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.WorldX +{ + public interface IWorldAudio + { + void PlaySound(UUID audio, Vector3 position, double volume); + void PlaySound(UUID audio, Vector3 position); + } +} -- cgit v1.1