diff --git a/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs b/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs index 16cbbf5d37..c9a263f8be 100644 --- a/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs +++ b/OpenSim/Region/CoreModules/LightShare/LightShareModule.cs @@ -37,11 +37,12 @@ using OpenSim.Framework; using OpenSim.Region.CoreModules.Framework.InterfaceCommander; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; - +using Mono.Addins; namespace OpenSim.Region.CoreModules.World.LightShare { - public class LightShareModule : IRegionModule, ICommandableModule + [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] + public class LightShareModule : INonSharedRegionModule, ICommandableModule { private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private readonly Commander m_commander = new Commander("windlight"); @@ -70,12 +71,8 @@ namespace OpenSim.Region.CoreModules.World.LightShare } } - public void Initialise(Scene scene, IConfigSource config) + public void Initialise(IConfigSource config) { - m_scene = scene; - m_scene.RegisterModuleInterface(this); - m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; - // ini file settings try { @@ -86,19 +83,62 @@ namespace OpenSim.Region.CoreModules.World.LightShare m_log.Debug("[WINDLIGHT]: ini failure for enable_windlight - using default"); } - if (m_enableWindlight) - { - m_scene.EventManager.OnMakeRootAgent += EventManager_OnMakeRootAgent; - m_scene.EventManager.OnSaveNewWindlightProfile += EventManager_OnSaveNewWindlightProfile; - m_scene.EventManager.OnSendNewWindlightProfileTargeted += EventManager_OnSendNewWindlightProfileTargeted; - m_scene.LoadWindlightProfile(); - } + m_log.DebugFormat("[WINDLIGHT]: windlight module {0}", (m_enableWindlight ? "enabled" : "disabled")); + } + + public void AddRegion(Scene scene) + { + if (!m_enableWindlight) + return; + + m_scene = scene; + //m_scene.RegisterModuleInterface(this); + m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; + + m_scene.EventManager.OnMakeRootAgent += EventManager_OnMakeRootAgent; + m_scene.EventManager.OnSaveNewWindlightProfile += EventManager_OnSaveNewWindlightProfile; + m_scene.EventManager.OnSendNewWindlightProfileTargeted += EventManager_OnSendNewWindlightProfileTargeted; + m_scene.LoadWindlightProfile(); InstallCommands(); - - m_log.Debug("[WINDLIGHT]: Initialised windlight module"); } + public void RemoveRegion(Scene scene) + { + if (!m_enableWindlight) + return; + + m_scene.EventManager.OnPluginConsole -= EventManager_OnPluginConsole; + + m_scene.EventManager.OnMakeRootAgent -= EventManager_OnMakeRootAgent; + m_scene.EventManager.OnSaveNewWindlightProfile -= EventManager_OnSaveNewWindlightProfile; + m_scene.EventManager.OnSendNewWindlightProfileTargeted -= EventManager_OnSendNewWindlightProfileTargeted; + + m_scene = null; + } + + public void Close() + { + } + + public string Name + { + get { return "LightShareModule"; } + } + + public void RegionLoaded(Scene scene) + { + } + + public Type ReplaceableInterface + { + get { return null; } + } + + #endregion + + #region events + private List compileWindlightSettings(RegionLightShareData wl) { byte[] mBlock = new Byte[249]; @@ -186,29 +226,6 @@ namespace OpenSim.Region.CoreModules.World.LightShare m_scene.ForEachRootClient(SendProfileToClient); } - public void PostInitialise() - { - - } - - public void Close() - { - } - - public string Name - { - get { return "LightShareModule"; } - } - - public bool IsSharedModule - { - get { return false; } - } - - #endregion - - #region events - #endregion #region ICommandableModule Members