Converting the ISoundModule implementation from an IRegionModule to an INonSharedRegionModule

integration
SignpostMarv 2012-10-05 13:50:12 +01:00 committed by Justin Clark-Casey (justincc)
parent 7560010f34
commit ed162a10be
1 changed files with 58 additions and 20 deletions

View File

@ -1,4 +1,4 @@
/* /*
* Copyright (c) Contributors, http://opensimulator.org/ * Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders. * See CONTRIBUTORS.TXT for a full list of copyright holders.
* *
@ -24,43 +24,79 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/ */
using System; using System;
using System.Reflection;
using Nini.Config; using Nini.Config;
using OpenMetaverse; using OpenMetaverse;
using log4net;
using Mono.Addins;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
using System.Reflection;
using log4net;
namespace OpenSim.Region.CoreModules.World.Sound namespace OpenSim.Region.CoreModules.World.Sound
{ {
public class SoundModule : IRegionModule, ISoundModule [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SoundModuleNonShared")]
public class SoundModuleNonShared : INonSharedRegionModule, ISoundModule
{ {
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
protected Scene m_scene;
private Scene m_scene;
public void Initialise(Scene scene, IConfigSource source)
public bool Enabled { get; private set; }
#region INonSharedRegionModule
public void Initialise(IConfigSource configSource)
{ {
IConfig config = configSource.Configs["Sounds"];
Enabled = (config != null && config.GetString("Module", "SoundModuleNonShared") == "SoundModuleNonShared");
}
public void AddRegion(Scene scene) { }
public void RemoveRegion(Scene scene)
{
m_scene.EventManager.OnClientLogin -= OnNewClient;
}
public void RegionLoaded(Scene scene)
{
if (!Enabled)
return;
m_scene = scene; m_scene = scene;
m_scene.EventManager.OnClientLogin += OnNewClient;
m_scene.EventManager.OnNewClient += OnNewClient;
m_scene.RegisterModuleInterface<ISoundModule>(this); m_scene.RegisterModuleInterface<ISoundModule>(this);
} }
public void PostInitialise() {} public void Close() { }
public void Close() {}
public Type ReplaceableInterface
{
get { return typeof(ISoundModule); }
}
public string Name { get { return "Sound Module"; } } public string Name { get { return "Sound Module"; } }
public bool IsSharedModule { get { return false; } }
#endregion
#region Event Handlers
private void OnNewClient(IClientAPI client) private void OnNewClient(IClientAPI client)
{ {
client.OnSoundTrigger += TriggerSound; client.OnSoundTrigger += TriggerSound;
} }
#endregion
#region ISoundModule
public virtual void PlayAttachedSound( public virtual void PlayAttachedSound(
UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags, float radius) UUID soundID, UUID ownerID, UUID objectID, double gain, Vector3 position, byte flags, float radius)
{ {
@ -96,7 +132,7 @@ namespace OpenSim.Region.CoreModules.World.Sound
sp.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, thisSpGain, flags); sp.ControllingClient.SendPlayAttachedSound(soundID, objectID, ownerID, thisSpGain, flags);
}); });
} }
public virtual void TriggerSound( public virtual void TriggerSound(
UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle, float radius) UUID soundId, UUID ownerID, UUID objectID, UUID parentID, double gain, Vector3 position, UInt64 handle, float radius)
{ {
@ -137,5 +173,7 @@ namespace OpenSim.Region.CoreModules.World.Sound
soundId, ownerID, objectID, parentID, handle, position, thisSpGain); soundId, ownerID, objectID, parentID, handle, position, thisSpGain);
}); });
} }
#endregion
} }
} }