aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs259
1 files changed, 259 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs
new file mode 100644
index 0000000..a5ad911
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Common/ScriptEngineBase/EventManager.cs
@@ -0,0 +1,259 @@
1/*
2* Copyright (c) Contributors, http://opensimulator.org/
3* See CONTRIBUTORS.TXT for a full list of copyright holders.
4*
5* Redistribution and use in source and binary forms, with or without
6* modification, are permitted provided that the following conditions are met:
7* * Redistributions of source code must retain the above copyright
8* notice, this list of conditions and the following disclaimer.
9* * Redistributions in binary form must reproduce the above copyright
10* notice, this list of conditions and the following disclaimer in the
11* documentation and/or other materials provided with the distribution.
12* * Neither the name of the OpenSim Project nor the
13* names of its contributors may be used to endorse or promote products
14* derived from this software without specific prior written permission.
15*
16* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26*
27*/
28/* Original code: Tedd Hansen */
29using System;
30using libsecondlife;
31using OpenSim.Framework;
32
33namespace OpenSim.Region.ScriptEngine.Common.ScriptEngineBase
34{
35 /// <summary>
36 /// Prepares events so they can be directly executed upon a script by EventQueueManager, then queues it.
37 /// </summary>
38 [Serializable]
39 public class EventManager : OpenSim.Region.ScriptEngine.Common.ScriptServerInterfaces.RemoteEvents
40 {
41
42 //
43 // Class is instanced in "ScriptEngine" and Uses "EventQueueManager" that is also instanced in "ScriptEngine".
44 // This class needs a bit of explaining:
45 //
46 // This class it the link between an event inside OpenSim and the corresponding event in a user script being executed.
47 //
48 // For example when an user touches an object then the "myScriptEngine.World.EventManager.OnObjectGrab" event is fired inside OpenSim.
49 // We hook up to this event and queue a touch_start in EventQueueManager with the proper LSL parameters.
50 // It will then be delivered to the script by EventQueueManager.
51 //
52 // You can check debug C# dump of an LSL script if you need to verify what exact parameters are needed.
53 //
54
55
56 private ScriptEngine myScriptEngine;
57 //public IScriptHost TEMP_OBJECT_ID;
58 public EventManager(ScriptEngine _ScriptEngine, bool performHookUp)
59 {
60 myScriptEngine = _ScriptEngine;
61
62 // Hook up to events from OpenSim
63 // We may not want to do it because someone is controlling us and will deliver events to us
64 if (performHookUp)
65 {
66 myScriptEngine.Log.Verbose("ScriptEngine", "Hooking up to server events");
67 myScriptEngine.World.EventManager.OnObjectGrab += touch_start;
68 myScriptEngine.World.EventManager.OnRezScript += OnRezScript;
69 myScriptEngine.World.EventManager.OnRemoveScript += OnRemoveScript;
70 // TODO: HOOK ALL EVENTS UP TO SERVER!
71 }
72 }
73
74 public void touch_start(uint localID, LLVector3 offsetPos, IClientAPI remoteClient)
75 {
76 // Add to queue for all scripts in ObjectID object
77 myScriptEngine.m_EventQueueManager.AddToObjectQueue(localID, "touch_start", new object[] {(int) 1});
78 }
79
80 public void OnRezScript(uint localID, LLUUID itemID, string script)
81 {
82 Console.WriteLine("OnRezScript localID: " + localID + " LLUID: " + itemID.ToString() + " Size: " +
83 script.Length);
84 myScriptEngine.m_ScriptManager.StartScript(localID, itemID, script);
85 }
86
87 public void OnRemoveScript(uint localID, LLUUID itemID)
88 {
89 Console.WriteLine("OnRemoveScript localID: " + localID + " LLUID: " + itemID.ToString());
90 myScriptEngine.m_ScriptManager.StopScript(
91 localID,
92 itemID
93 );
94 }
95
96 // TODO: Replace placeholders below
97 // NOTE! THE PARAMETERS FOR THESE FUNCTIONS ARE NOT CORRECT!
98 // These needs to be hooked up to OpenSim during init of this class
99 // then queued in EventQueueManager.
100 // When queued in EventQueueManager they need to be LSL compatible (name and params)
101
102 public void state_exit(uint localID, LLUUID itemID)
103 {
104 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "state_exit");
105 }
106
107 public void touch(uint localID, LLUUID itemID)
108 {
109 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "touch");
110 }
111
112 public void touch_end(uint localID, LLUUID itemID)
113 {
114 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "touch_end");
115 }
116
117 public void collision_start(uint localID, LLUUID itemID)
118 {
119 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision_start");
120 }
121
122 public void collision(uint localID, LLUUID itemID)
123 {
124 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision");
125 }
126
127 public void collision_end(uint localID, LLUUID itemID)
128 {
129 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "collision_end");
130 }
131
132 public void land_collision_start(uint localID, LLUUID itemID)
133 {
134 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "land_collision_start");
135 }
136
137 public void land_collision(uint localID, LLUUID itemID)
138 {
139 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "land_collision");
140 }
141
142 public void land_collision_end(uint localID, LLUUID itemID)
143 {
144 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "land_collision_end");
145 }
146
147 // Handled by long commands
148 public void timer(uint localID, LLUUID itemID)
149 {
150 //myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "");
151 }
152
153 public void listen(uint localID, LLUUID itemID)
154 {
155 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "listen");
156 }
157
158 public void on_rez(uint localID, LLUUID itemID)
159 {
160 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "on_rez");
161 }
162
163 public void sensor(uint localID, LLUUID itemID)
164 {
165 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "sensor");
166 }
167
168 public void no_sensor(uint localID, LLUUID itemID)
169 {
170 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "no_sensor");
171 }
172
173 public void control(uint localID, LLUUID itemID)
174 {
175 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "control");
176 }
177
178 public void money(uint localID, LLUUID itemID)
179 {
180 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "money");
181 }
182
183 public void email(uint localID, LLUUID itemID)
184 {
185 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "email");
186 }
187
188 public void at_target(uint localID, LLUUID itemID)
189 {
190 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "at_target");
191 }
192
193 public void not_at_target(uint localID, LLUUID itemID)
194 {
195 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "not_at_target");
196 }
197
198 public void at_rot_target(uint localID, LLUUID itemID)
199 {
200 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "at_rot_target");
201 }
202
203 public void not_at_rot_target(uint localID, LLUUID itemID)
204 {
205 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "not_at_rot_target");
206 }
207
208 public void run_time_permissions(uint localID, LLUUID itemID)
209 {
210 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "run_time_permissions");
211 }
212
213 public void changed(uint localID, LLUUID itemID)
214 {
215 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "changed");
216 }
217
218 public void attach(uint localID, LLUUID itemID)
219 {
220 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "attach");
221 }
222
223 public void dataserver(uint localID, LLUUID itemID)
224 {
225 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "dataserver");
226 }
227
228 public void link_message(uint localID, LLUUID itemID)
229 {
230 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "link_message");
231 }
232
233 public void moving_start(uint localID, LLUUID itemID)
234 {
235 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "moving_start");
236 }
237
238 public void moving_end(uint localID, LLUUID itemID)
239 {
240 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "moving_end");
241 }
242
243 public void object_rez(uint localID, LLUUID itemID)
244 {
245 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "object_rez");
246 }
247
248 public void remote_data(uint localID, LLUUID itemID)
249 {
250 myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "remote_data");
251 }
252
253 // Handled by long commands
254 public void http_response(uint localID, LLUUID itemID)
255 {
256 // myScriptEngine.m_EventQueueManager.AddToScriptQueue(localID, itemID, "http_response");
257 }
258 }
259} \ No newline at end of file