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