aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs')
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs21
1 files changed, 20 insertions, 1 deletions
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
index a7b63b0..73eb98f 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
@@ -52,6 +52,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
52 52
53 private static readonly CSharpCodeProvider CScodeProvider = new CSharpCodeProvider(); 53 private static readonly CSharpCodeProvider CScodeProvider = new CSharpCodeProvider();
54 54
55 private readonly MicroScheduler m_microthreads = new MicroScheduler();
56
55 public void RegisterExtension<T>(T instance) 57 public void RegisterExtension<T>(T instance)
56 { 58 {
57 m_extensions[typeof (T)] = instance; 59 m_extensions[typeof (T)] = instance;
@@ -66,6 +68,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
66 m_log.Info("[MRM] Enabling MRM Module"); 68 m_log.Info("[MRM] Enabling MRM Module");
67 m_scene = scene; 69 m_scene = scene;
68 scene.EventManager.OnRezScript += EventManager_OnRezScript; 70 scene.EventManager.OnRezScript += EventManager_OnRezScript;
71 scene.EventManager.OnFrame += EventManager_OnFrame;
69 72
70 scene.RegisterModuleInterface<IMRMModule>(this); 73 scene.RegisterModuleInterface<IMRMModule>(this);
71 } 74 }
@@ -80,6 +83,19 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
80 } 83 }
81 } 84 }
82 85
86 void EventManager_OnFrame()
87 {
88 m_microthreads.Tick(1000);
89 }
90
91 static string ConvertMRMKeywords(string script)
92 {
93 script = script.Replace("microthreaded void ", "IEnumerable");
94 script = script.Replace("relax;", "yield return null;");
95
96 return script;
97 }
98
83 void EventManager_OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) 99 void EventManager_OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource)
84 { 100 {
85 if (script.StartsWith("//MRM:C#")) 101 if (script.StartsWith("//MRM:C#"))
@@ -87,11 +103,14 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
87 if (m_scene.GetSceneObjectPart(localID).OwnerID != m_scene.RegionInfo.MasterAvatarAssignedUUID) 103 if (m_scene.GetSceneObjectPart(localID).OwnerID != m_scene.RegionInfo.MasterAvatarAssignedUUID)
88 return; 104 return;
89 105
106 script = ConvertMRMKeywords(script);
107
90 try 108 try
91 { 109 {
92 m_log.Info("[MRM] Found C# MRM"); 110 m_log.Info("[MRM] Found C# MRM");
93 IWorld m_world = new World(m_scene); 111 IWorld m_world = new World(m_scene);
94 IHost m_host = new Host(new SOPObject(m_scene, localID), m_scene, new ExtensionHandler(m_extensions)); 112 IHost m_host = new Host(new SOPObject(m_scene, localID), m_scene, new ExtensionHandler(m_extensions),
113 m_microthreads);
95 114
96 MRMBase mmb = (MRMBase)AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap( 115 MRMBase mmb = (MRMBase)AppDomain.CurrentDomain.CreateInstanceFromAndUnwrap(
97 CompileFromDotNetText(script, itemID.ToString()), 116 CompileFromDotNetText(script, itemID.ToString()),