aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs130
1 files changed, 90 insertions, 40 deletions
diff --git a/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs
index 934d981..fa4970f 100644
--- a/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs
+++ b/OpenSim/Region/ScriptEngine/DotNetEngine/EventManager.cs
@@ -46,21 +46,26 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
46 public class EventManager : iScriptEngineFunctionModule 46 public class EventManager : iScriptEngineFunctionModule
47 { 47 {
48 // 48 //
49 // Class is instanced in "ScriptEngine" and Uses "EventQueueManager" that is also instanced in "ScriptEngine". 49 // Class is instanced in "ScriptEngine" and Uses "EventQueueManager"
50 // that is also instanced in "ScriptEngine".
50 // This class needs a bit of explaining: 51 // This class needs a bit of explaining:
51 // 52 //
52 // This class it the link between an event inside OpenSim and the corresponding event in a user script being executed. 53 // This class it the link between an event inside OpenSim and
54 // the corresponding event in a user script being executed.
53 // 55 //
54 // For example when an user touches an object then the "myScriptEngine.World.EventManager.OnObjectGrab" event is fired inside OpenSim. 56 // For example when an user touches an object then the
55 // We hook up to this event and queue a touch_start in EventQueueManager with the proper LSL parameters. 57 // "myScriptEngine.World.EventManager.OnObjectGrab" event is fired
58 // inside OpenSim.
59 // We hook up to this event and queue a touch_start in
60 // EventQueueManager with the proper LSL parameters.
56 // It will then be delivered to the script by EventQueueManager. 61 // It will then be delivered to the script by EventQueueManager.
57 // 62 //
58 // You can check debug C# dump of an LSL script if you need to verify what exact parameters are needed. 63 // You can check debug C# dump of an LSL script if you need to
64 // verify what exact parameters are needed.
59 // 65 //
60 66
61
62 private ScriptEngine myScriptEngine; 67 private ScriptEngine myScriptEngine;
63 //public IScriptHost TEMP_OBJECT_ID; 68
64 public EventManager(ScriptEngine _ScriptEngine, bool performHookUp) 69 public EventManager(ScriptEngine _ScriptEngine, bool performHookUp)
65 { 70 {
66 myScriptEngine = _ScriptEngine; 71 myScriptEngine = _ScriptEngine;
@@ -74,28 +79,34 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
74 79
75 public void HookUpEvents() 80 public void HookUpEvents()
76 { 81 {
77 // Hook up to events from OpenSim 82 myScriptEngine.Log.Info("[" + myScriptEngine.ScriptEngineName +
78 // We may not want to do it because someone is controlling us and will deliver events to us 83 "]: Hooking up to server events");
79 84
80 myScriptEngine.Log.Info("[" + myScriptEngine.ScriptEngineName + "]: Hooking up to server events"); 85 myScriptEngine.World.EventManager.OnObjectGrab +=
81 myScriptEngine.World.EventManager.OnObjectGrab += touch_start; 86 touch_start;
82 myScriptEngine.World.EventManager.OnObjectDeGrab += touch_end; 87 myScriptEngine.World.EventManager.OnObjectDeGrab +=
83 myScriptEngine.World.EventManager.OnRemoveScript += OnRemoveScript; 88 touch_end;
84 myScriptEngine.World.EventManager.OnScriptChangedEvent += changed; 89 myScriptEngine.World.EventManager.OnRemoveScript +=
85 myScriptEngine.World.EventManager.OnScriptAtTargetEvent += at_target; 90 OnRemoveScript;
86 myScriptEngine.World.EventManager.OnScriptNotAtTargetEvent += not_at_target; 91 myScriptEngine.World.EventManager.OnScriptChangedEvent +=
87 myScriptEngine.World.EventManager.OnScriptControlEvent += control; 92 changed;
88 myScriptEngine.World.EventManager.OnScriptColliderStart += collision_start; 93 myScriptEngine.World.EventManager.OnScriptAtTargetEvent +=
89 myScriptEngine.World.EventManager.OnScriptColliding += collision; 94 at_target;
90 myScriptEngine.World.EventManager.OnScriptCollidingEnd += collision_end; 95 myScriptEngine.World.EventManager.OnScriptNotAtTargetEvent +=
91 96 not_at_target;
92 // TODO: HOOK ALL EVENTS UP TO SERVER! 97 myScriptEngine.World.EventManager.OnScriptControlEvent +=
93 IMoneyModule money=myScriptEngine.World.RequestModuleInterface<IMoneyModule>(); 98 control;
99 myScriptEngine.World.EventManager.OnScriptColliderStart +=
100 collision_start;
101 myScriptEngine.World.EventManager.OnScriptColliding +=
102 collision;
103 myScriptEngine.World.EventManager.OnScriptCollidingEnd +=
104 collision_end;
105
106 IMoneyModule money =
107 myScriptEngine.World.RequestModuleInterface<IMoneyModule>();
94 if (money != null) 108 if (money != null)
95 {
96 money.OnObjectPaid+=HandleObjectPaid; 109 money.OnObjectPaid+=HandleObjectPaid;
97 }
98
99 } 110 }
100 111
101 public void ReadConfig() 112 public void ReadConfig()
@@ -104,7 +115,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
104 115
105 private void HandleObjectPaid(UUID objectID, UUID agentID, int amount) 116 private void HandleObjectPaid(UUID objectID, UUID agentID, int amount)
106 { 117 {
107 SceneObjectPart part=myScriptEngine.World.GetSceneObjectPart(objectID); 118 SceneObjectPart part =
119 myScriptEngine.World.GetSceneObjectPart(objectID);
120
108 if (part != null) 121 if (part != null)
109 { 122 {
110 money(part.LocalId, agentID, amount); 123 money(part.LocalId, agentID, amount);
@@ -127,8 +140,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
127 new DetectParams[0])); 140 new DetectParams[0]));
128 } 141 }
129 142
130 public void touch_start(uint localID, uint originalID, Vector3 offsetPos, 143 public void touch_start(uint localID, uint originalID,
131 IClientAPI remoteClient) 144 Vector3 offsetPos, IClientAPI remoteClient)
132 { 145 {
133 // Add to queue for all scripts in ObjectID object 146 // Add to queue for all scripts in ObjectID object
134 DetectParams[] det = new DetectParams[1]; 147 DetectParams[] det = new DetectParams[1];
@@ -138,7 +151,9 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
138 151
139 if (originalID == 0) 152 if (originalID == 0)
140 { 153 {
141 SceneObjectPart part = myScriptEngine.World.GetSceneObjectPart(localID); 154 SceneObjectPart part =
155 myScriptEngine.World.GetSceneObjectPart(localID);
156
142 if (part == null) 157 if (part == null)
143 return; 158 return;
144 159
@@ -146,7 +161,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
146 } 161 }
147 else 162 else
148 { 163 {
149 SceneObjectPart originalPart = myScriptEngine.World.GetSceneObjectPart(originalID); 164 SceneObjectPart originalPart =
165 myScriptEngine.World.GetSceneObjectPart(originalID);
150 det[0].LinkNum = originalPart.LinkNum; 166 det[0].LinkNum = originalPart.LinkNum;
151 } 167 }
152 168
@@ -196,7 +212,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
196 212
197 if (originalID == 0) 213 if (originalID == 0)
198 { 214 {
199 SceneObjectPart part = myScriptEngine.World.GetSceneObjectPart(localID); 215 SceneObjectPart part =
216 myScriptEngine.World.GetSceneObjectPart(localID);
200 if (part == null) 217 if (part == null)
201 return; 218 return;
202 219
@@ -204,7 +221,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
204 } 221 }
205 else 222 else
206 { 223 {
207 SceneObjectPart originalPart = myScriptEngine.World.GetSceneObjectPart(originalID); 224 SceneObjectPart originalPart =
225 myScriptEngine.World.GetSceneObjectPart(originalID);
208 det[0].LinkNum = originalPart.LinkNum; 226 det[0].LinkNum = originalPart.LinkNum;
209 } 227 }
210 228
@@ -213,9 +231,12 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
213 det)); 231 det));
214 } 232 }
215 233
216 public void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine) 234 public void OnRezScript(uint localID, UUID itemID, string script,
235 int startParam, bool postOnRez, string engine)
217 { 236 {
218 List<IScriptModule> engines = new List<IScriptModule>(myScriptEngine.World.RequestModuleInterfaces<IScriptModule>()); 237 List<IScriptModule> engines =
238 new List<IScriptModule>(
239 myScriptEngine.World.RequestModuleInterfaces<IScriptModule>());
219 240
220 List<string> names = new List<string>(); 241 List<string> names = new List<string>();
221 foreach (IScriptModule m in engines) 242 foreach (IScriptModule m in engines)
@@ -228,7 +249,8 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
228 string firstline = script.Substring(0, lineEnd).Trim(); 249 string firstline = script.Substring(0, lineEnd).Trim();
229 250
230 int colon = firstline.IndexOf(':'); 251 int colon = firstline.IndexOf(':');
231 if (firstline.Length > 2 && firstline.Substring(0, 2) == "//" && colon != -1) 252 if (firstline.Length > 2 &&
253 firstline.Substring(0, 2) == "//" && colon != -1)
232 { 254 {
233 string engineName = firstline.Substring(2, colon-2); 255 string engineName = firstline.Substring(2, colon-2);
234 256
@@ -237,15 +259,43 @@ namespace OpenSim.Region.ScriptEngine.DotNetEngine
237 engine = engineName; 259 engine = engineName;
238 script = "//" + script.Substring(script.IndexOf(':')+1); 260 script = "//" + script.Substring(script.IndexOf(':')+1);
239 } 261 }
262 else
263 {
264 if (engine == myScriptEngine.ScriptEngineName)
265 {
266 SceneObjectPart part =
267 myScriptEngine.World.GetSceneObjectPart(
268 localID);
269
270 TaskInventoryItem item =
271 part.GetInventoryItem(itemID);
272
273 ScenePresence presence =
274 myScriptEngine.World.GetScenePresence(
275 item.OwnerID);
276
277 if (presence != null)
278 {
279 presence.ControllingClient.SendAgentAlertMessage(
280 "Selected engine unavailable. "+
281 "Running script on "+
282 myScriptEngine.ScriptEngineName,
283 false);
284 }
285 }
286 }
240 } 287 }
241 } 288 }
242 289
243 if (engine != myScriptEngine.ScriptEngineName) 290 if (engine != myScriptEngine.ScriptEngineName)
244 return; 291 return;
245 292
246 myScriptEngine.Log.Debug("OnRezScript localID: " + localID + " LLUID: " + itemID.ToString() + " Size: " + 293 myScriptEngine.Log.Debug("OnRezScript localID: " + localID +
247 script.Length); 294 " LLUID: " + itemID.ToString() + " Size: " +
248 myScriptEngine.m_ScriptManager.StartScript(localID, itemID, script, startParam, postOnRez); 295 script.Length);
296
297 myScriptEngine.m_ScriptManager.StartScript(localID, itemID, script,
298 startParam, postOnRez);
249 } 299 }
250 300
251 public void OnRemoveScript(uint localID, UUID itemID) 301 public void OnRemoveScript(uint localID, UUID itemID)