aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs64
1 files changed, 41 insertions, 23 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
index 4521f8e..f24bcdc 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
@@ -38,6 +38,7 @@ using System.Security.Policy;
38using System.Text; 38using System.Text;
39using log4net; 39using log4net;
40using Microsoft.CSharp; 40using Microsoft.CSharp;
41using Mono.Addins;
41using Nini.Config; 42using Nini.Config;
42using OpenMetaverse; 43using OpenMetaverse;
43using OpenSim.Framework; 44using OpenSim.Framework;
@@ -46,7 +47,8 @@ using OpenSim.Region.Framework.Scenes;
46 47
47namespace OpenSim.Region.OptionalModules.Scripting.Minimodule 48namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
48{ 49{
49 public class MRMModule : IRegionModule, IMRMModule 50 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
51 public class MRMModule : INonSharedRegionModule, IMRMModule
50 { 52 {
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 53 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52 private Scene m_scene; 54 private Scene m_scene;
@@ -62,12 +64,14 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
62 64
63 private IConfig m_config; 65 private IConfig m_config;
64 66
67 private bool m_hidden = true;
68
65 public void RegisterExtension<T>(T instance) 69 public void RegisterExtension<T>(T instance)
66 { 70 {
67 m_extensions[typeof (T)] = instance; 71 m_extensions[typeof (T)] = instance;
68 } 72 }
69 73
70 public void Initialise(Scene scene, IConfigSource source) 74 public void Initialise(IConfigSource source)
71 { 75 {
72 if (source.Configs["MRM"] != null) 76 if (source.Configs["MRM"] != null)
73 { 77 {
@@ -76,19 +80,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
76 if (source.Configs["MRM"].GetBoolean("Enabled", false)) 80 if (source.Configs["MRM"].GetBoolean("Enabled", false))
77 { 81 {
78 m_log.Info("[MRM] Enabling MRM Module"); 82 m_log.Info("[MRM] Enabling MRM Module");
79 m_scene = scene; 83
80
81 // when hidden, we don't listen for client initiated script events 84 // when hidden, we don't listen for client initiated script events
82 // only making the MRM engine available for region modules 85 // only making the MRM engine available for region modules
83 if (!source.Configs["MRM"].GetBoolean("Hidden", false)) 86 m_hidden = source.Configs["MRM"].GetBoolean("Hidden", false);
84 {
85 scene.EventManager.OnRezScript += EventManager_OnRezScript;
86 scene.EventManager.OnStopScript += EventManager_OnStopScript;
87 }
88
89 scene.EventManager.OnFrame += EventManager_OnFrame;
90
91 scene.RegisterModuleInterface<IMRMModule>(this);
92 } 87 }
93 else 88 else
94 { 89 {
@@ -101,6 +96,39 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
101 } 96 }
102 } 97 }
103 98
99 public Type ReplaceableInterface
100 {
101 get { return null; }
102 }
103
104 public void AddRegion(Scene scene)
105 {
106 m_scene = scene;
107 if (!m_hidden)
108 {
109 scene.EventManager.OnRezScript += EventManager_OnRezScript;
110 scene.EventManager.OnStopScript += EventManager_OnStopScript;
111 }
112 scene.EventManager.OnFrame += EventManager_OnFrame;
113
114 scene.RegisterModuleInterface<IMRMModule>(this);
115 }
116 public void RegionLoaded(Scene scene)
117 {
118 }
119
120 public void RemoveRegion(Scene scene)
121 {
122 if (!m_hidden)
123 {
124 scene.EventManager.OnRezScript -= EventManager_OnRezScript;
125 scene.EventManager.OnStopScript -= EventManager_OnStopScript;
126 }
127 scene.EventManager.OnFrame -= EventManager_OnFrame;
128
129 scene.UnregisterModuleInterface<IMRMModule>(this);
130 }
131
104 void EventManager_OnStopScript(uint localID, UUID itemID) 132 void EventManager_OnStopScript(uint localID, UUID itemID)
105 { 133 {
106 if (m_scripts.ContainsKey(itemID)) 134 if (m_scripts.ContainsKey(itemID))
@@ -302,11 +330,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
302 mmb.InitMiniModule(world, host, itemID); 330 mmb.InitMiniModule(world, host, itemID);
303 } 331 }
304 332
305 public void PostInitialise()
306 {
307
308 }
309
310 public void Close() 333 public void Close()
311 { 334 {
312 foreach (KeyValuePair<UUID, MRMBase> pair in m_scripts) 335 foreach (KeyValuePair<UUID, MRMBase> pair in m_scripts)
@@ -320,11 +343,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
320 get { return "MiniRegionModule"; } 343 get { return "MiniRegionModule"; }
321 } 344 }
322 345
323 public bool IsSharedModule
324 {
325 get { return false; }
326 }
327
328 /// <summary> 346 /// <summary>
329 /// Stolen from ScriptEngine Common 347 /// Stolen from ScriptEngine Common
330 /// </summary> 348 /// </summary>