aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/ScriptEngine/Components/DotNetEngine/Events/LSLEventProvider.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/ScriptEngine/Components/DotNetEngine/Events/LSLEventProvider.cs')
-rw-r--r--OpenSim/ScriptEngine/Components/DotNetEngine/Events/LSLEventProvider.cs81
1 files changed, 77 insertions, 4 deletions
diff --git a/OpenSim/ScriptEngine/Components/DotNetEngine/Events/LSLEventProvider.cs b/OpenSim/ScriptEngine/Components/DotNetEngine/Events/LSLEventProvider.cs
index b42ceec..794b132 100644
--- a/OpenSim/ScriptEngine/Components/DotNetEngine/Events/LSLEventProvider.cs
+++ b/OpenSim/ScriptEngine/Components/DotNetEngine/Events/LSLEventProvider.cs
@@ -27,19 +27,92 @@
27using System; 27using System;
28using System.Collections.Generic; 28using System.Collections.Generic;
29using System.Text; 29using System.Text;
30using OpenSim.ApplicationPlugins.ScriptEngine.Components; 30using OpenMetaverse;
31using OpenSim.Framework;
32using OpenSim.Region.Environment.Scenes;
33using OpenSim.Region.ScriptEngine.Shared;
34using OpenSim.ScriptEngine.Shared;
35using EventParams=OpenSim.ScriptEngine.Shared.EventParams;
31 36
32namespace OpenSim.ScriptEngine.Components.DotNetEngine.Events 37namespace OpenSim.ScriptEngine.Components.DotNetEngine.Events
33{ 38{
34 public class LSLEventProvider: EventBase 39 public class LSLEventProvider : IScriptEventProvider
35 { 40 {
41 public delegate void RezScriptDelegate(uint localID, UUID itemID, string script, int startParam, bool postOnRez,
42 string engine);
43 public event RezScriptDelegate RezScript;
44 public delegate void RemoveScriptDelegate(uint localID, UUID itemID);
45 public event RemoveScriptDelegate RemoveScript;
46 public delegate void ScriptChangedDelegate(uint localID, uint change);
47 public event ScriptChangedDelegate ScriptChanged;
36 48
37 public override void Start() 49 private RegionInfoStructure CurrentRegion;
50 public void Initialize(RegionInfoStructure currentRegion)
38 { 51 {
52 CurrentRegion = currentRegion;
53 HookupEvents();
39 } 54 }
40 55
41 public override void Close() 56 private void HookupEvents()
42 { 57 {
58 CurrentRegion.Scene.EventManager.OnObjectGrab += OnObjectGrab;
59 CurrentRegion.Scene.EventManager.OnRezScript += OnRezScript;
60 CurrentRegion.Scene.EventManager.OnRemoveScript += OnRemoveScript;
61 CurrentRegion.Scene.EventManager.OnScriptChangedEvent += OnScriptChangedEvent;
62
63
64 }
65
66 private void OnScriptChangedEvent(uint localID, uint change)
67 {
68 // Script is being changed, fire event
69 if (ScriptChanged != null)
70 ScriptChanged(localID, change);
71 }
72
73 private void OnRemoveScript(uint localID, UUID itemID)
74 {
75 // Script is being removed, fire event
76 if (RemoveScript != null)
77 RemoveScript(localID, itemID);
78 }
79
80 private void OnRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine)
81 {
82 // New script being created, fire event
83 if (RezScript != null)
84 RezScript(localID, itemID, script, startParam, postOnRez, engine);
85 }
86
87 private void OnObjectGrab(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient)
88 {
89 // Add to queue for all scripts in ObjectID object
90 DetectParams[] det = new DetectParams[1];
91 det[0] = new DetectParams();
92 det[0].Key = remoteClient.AgentId;
93 //det[0].Populate(World);
94
95 if (originalID == 0)
96 {
97 SceneObjectPart part =
98 CurrentRegion.Scene.GetSceneObjectPart(localID);
99
100 if (part == null)
101 return;
102
103 det[0].LinkNum = part.LinkNum;
104 }
105 else
106 {
107 SceneObjectPart originalPart =
108 CurrentRegion.Scene.GetSceneObjectPart(originalID);
109 det[0].LinkNum = originalPart.LinkNum;
110 }
111
112 Shared.EventParams ep =
113 new Shared.EventParams(localID, "touch_start", new Object[] {new LSL_Types.LSLInteger(1)}, det);
114 CurrentRegion.Executors_Execute(ep);
115
43 } 116 }
44 } 117 }
45} 118}