diff options
Diffstat (limited to 'OpenSim/Region/ScriptEngine/XEngine/EventManager.cs')
-rw-r--r-- | OpenSim/Region/ScriptEngine/XEngine/EventManager.cs | 293 |
1 files changed, 293 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs new file mode 100644 index 0000000..734c837 --- /dev/null +++ b/OpenSim/Region/ScriptEngine/XEngine/EventManager.cs | |||
@@ -0,0 +1,293 @@ | |||
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 | using System; | ||
29 | using libsecondlife; | ||
30 | using OpenSim.Framework; | ||
31 | using OpenSim.Region.Environment.Modules.Avatar.Currency.SampleMoney; | ||
32 | using OpenSim.Region.Environment.Scenes; | ||
33 | using OpenSim.Region.Environment.Interfaces; | ||
34 | using OpenSim.Region.ScriptEngine.XEngine.Script; | ||
35 | using Axiom.Math; | ||
36 | |||
37 | namespace OpenSim.Region.ScriptEngine.XEngine | ||
38 | { | ||
39 | /// <summary> | ||
40 | /// Prepares events so they can be directly executed upon a script by EventQueueManager, then queues it. | ||
41 | /// </summary> | ||
42 | public class EventManager | ||
43 | { | ||
44 | private XEngine myScriptEngine; | ||
45 | |||
46 | public EventManager(XEngine _ScriptEngine) | ||
47 | { | ||
48 | myScriptEngine = _ScriptEngine; | ||
49 | |||
50 | myScriptEngine.Log.Info("[XEngine] Hooking up to server events"); | ||
51 | myScriptEngine.World.EventManager.OnObjectGrab += touch_start; | ||
52 | myScriptEngine.World.EventManager.OnObjectDeGrab += touch_end; | ||
53 | myScriptEngine.World.EventManager.OnScriptChangedEvent += changed; | ||
54 | myScriptEngine.World.EventManager.OnScriptAtTargetEvent += at_target; | ||
55 | myScriptEngine.World.EventManager.OnScriptNotAtTargetEvent += not_at_target; | ||
56 | myScriptEngine.World.EventManager.OnScriptControlEvent += control; | ||
57 | IMoneyModule money=myScriptEngine.World.RequestModuleInterface<IMoneyModule>(); | ||
58 | if (money != null) | ||
59 | { | ||
60 | money.OnObjectPaid+=HandleObjectPaid; | ||
61 | } | ||
62 | } | ||
63 | |||
64 | private void HandleObjectPaid(LLUUID objectID, LLUUID agentID, | ||
65 | int amount) | ||
66 | { | ||
67 | SceneObjectPart part = | ||
68 | myScriptEngine.World.GetSceneObjectPart(objectID); | ||
69 | |||
70 | if (part != null) | ||
71 | { | ||
72 | money(part.LocalId, agentID, amount); | ||
73 | } | ||
74 | } | ||
75 | |||
76 | public void touch_start(uint localID, LLVector3 offsetPos, | ||
77 | IClientAPI remoteClient) | ||
78 | { | ||
79 | // Add to queue for all scripts in ObjectID object | ||
80 | XDetectParams[] det = new XDetectParams[1]; | ||
81 | det[0].Key = remoteClient.AgentId; | ||
82 | |||
83 | myScriptEngine.PostObjectEvent(localID, new XEventParams( | ||
84 | "touch_start", new Object[] { new LSL_Types.LSLInteger(1) }, | ||
85 | det)); | ||
86 | } | ||
87 | |||
88 | public void touch(uint localID, LLVector3 offsetPos, | ||
89 | IClientAPI remoteClient) | ||
90 | { | ||
91 | // Add to queue for all scripts in ObjectID object | ||
92 | XDetectParams[] det = new XDetectParams[1]; | ||
93 | det[0].Key = remoteClient.AgentId; | ||
94 | det[0].OffsetPos = new LSL_Types.Vector3(offsetPos.X, | ||
95 | offsetPos.Y, | ||
96 | offsetPos.Z); | ||
97 | |||
98 | myScriptEngine.PostObjectEvent(localID, new XEventParams( | ||
99 | "touch", new Object[] { new LSL_Types.LSLInteger(1) }, | ||
100 | det)); | ||
101 | } | ||
102 | |||
103 | public void touch_end(uint localID, IClientAPI remoteClient) | ||
104 | { | ||
105 | // Add to queue for all scripts in ObjectID object | ||
106 | XDetectParams[] det = new XDetectParams[1]; | ||
107 | det[0].Key = remoteClient.AgentId; | ||
108 | |||
109 | myScriptEngine.PostObjectEvent(localID, new XEventParams( | ||
110 | "touch_end", new Object[] { new LSL_Types.LSLInteger(1) }, | ||
111 | det)); | ||
112 | } | ||
113 | |||
114 | public void changed(uint localID, uint change) | ||
115 | { | ||
116 | // Add to queue for all scripts in localID, Object pass change. | ||
117 | myScriptEngine.PostObjectEvent(localID, new XEventParams( | ||
118 | "changed",new object[] { new LSL_Types.LSLInteger(change) }, | ||
119 | new XDetectParams[0])); | ||
120 | } | ||
121 | |||
122 | // state_entry: not processed here | ||
123 | // state_exit: not processed here | ||
124 | |||
125 | public void money(uint localID, LLUUID agentID, int amount) | ||
126 | { | ||
127 | myScriptEngine.PostObjectEvent(localID, new XEventParams( | ||
128 | "money", new object[] { | ||
129 | new LSL_Types.LSLString(agentID.ToString()), | ||
130 | new LSL_Types.LSLInteger(amount) }, | ||
131 | new XDetectParams[0])); | ||
132 | } | ||
133 | |||
134 | public void collision_start(uint localID, LLUUID itemID, | ||
135 | IClientAPI remoteClient) | ||
136 | { | ||
137 | // Add to queue for all scripts in ObjectID object | ||
138 | XDetectParams[] det = new XDetectParams[1]; | ||
139 | det[0].Key = remoteClient.AgentId; | ||
140 | |||
141 | myScriptEngine.PostObjectEvent(localID, new XEventParams( | ||
142 | "collision_start", | ||
143 | new Object[] { new LSL_Types.LSLInteger(1) }, | ||
144 | det)); | ||
145 | } | ||
146 | |||
147 | public void collision(uint localID, LLUUID itemID, | ||
148 | IClientAPI remoteClient) | ||
149 | { | ||
150 | // Add to queue for all scripts in ObjectID object | ||
151 | XDetectParams[] det = new XDetectParams[1]; | ||
152 | det[0].Key = remoteClient.AgentId; | ||
153 | |||
154 | myScriptEngine.PostObjectEvent(localID, new XEventParams( | ||
155 | "collision", new Object[] { new LSL_Types.LSLInteger(1) }, | ||
156 | det)); | ||
157 | } | ||
158 | |||
159 | public void collision_end(uint localID, LLUUID itemID, | ||
160 | IClientAPI remoteClient) | ||
161 | { | ||
162 | // Add to queue for all scripts in ObjectID object | ||
163 | XDetectParams[] det = new XDetectParams[1]; | ||
164 | det[0].Key = remoteClient.AgentId; | ||
165 | |||
166 | myScriptEngine.PostObjectEvent(localID, new XEventParams( | ||
167 | "collision_end", | ||
168 | new Object[] { new LSL_Types.LSLInteger(1) }, | ||
169 | det)); | ||
170 | } | ||
171 | |||
172 | public void land_collision_start(uint localID, LLUUID itemID) | ||
173 | { | ||
174 | myScriptEngine.PostObjectEvent(localID, new XEventParams( | ||
175 | "land_collision_start", | ||
176 | new object[0], | ||
177 | new XDetectParams[0])); | ||
178 | } | ||
179 | |||
180 | public void land_collision(uint localID, LLUUID itemID) | ||
181 | { | ||
182 | myScriptEngine.PostObjectEvent(localID, new XEventParams( | ||
183 | "land_collision", | ||
184 | new object[0], | ||
185 | new XDetectParams[0])); | ||
186 | } | ||
187 | |||
188 | public void land_collision_end(uint localID, LLUUID itemID) | ||
189 | { | ||
190 | myScriptEngine.PostObjectEvent(localID, new XEventParams( | ||
191 | "land_collision_end", | ||
192 | new object[0], | ||
193 | new XDetectParams[0])); | ||
194 | } | ||
195 | |||
196 | // timer: not handled here | ||
197 | // listen: not handled here | ||
198 | |||
199 | public void on_rez(uint localID, LLUUID itemID, int startParam) | ||
200 | { | ||
201 | myScriptEngine.PostObjectEvent(localID, new XEventParams( | ||
202 | "on_rez",new object[] { | ||
203 | new LSL_Types.LSLInteger(startParam)}, | ||
204 | new XDetectParams[0])); | ||
205 | } | ||
206 | |||
207 | public void control(uint localID, LLUUID itemID, LLUUID agentID, uint held, uint change) | ||
208 | { | ||
209 | myScriptEngine.PostObjectEvent(localID, new XEventParams( | ||
210 | "control",new object[] { | ||
211 | new LSL_Types.LSLString(agentID.ToString()), | ||
212 | new LSL_Types.LSLInteger(held), | ||
213 | new LSL_Types.LSLInteger(change)}, | ||
214 | new XDetectParams[0])); | ||
215 | } | ||
216 | |||
217 | public void email(uint localID, LLUUID itemID, string timeSent, | ||
218 | string address, string subject, string message, int numLeft) | ||
219 | { | ||
220 | myScriptEngine.PostObjectEvent(localID, new XEventParams( | ||
221 | "email",new object[] { | ||
222 | new LSL_Types.LSLString(timeSent), | ||
223 | new LSL_Types.LSLString(address), | ||
224 | new LSL_Types.LSLString(subject), | ||
225 | new LSL_Types.LSLString(message), | ||
226 | new LSL_Types.LSLInteger(numLeft)}, | ||
227 | new XDetectParams[0])); | ||
228 | } | ||
229 | |||
230 | public void at_target(uint localID, uint handle, LLVector3 targetpos, | ||
231 | LLVector3 atpos) | ||
232 | { | ||
233 | myScriptEngine.PostObjectEvent(localID, new XEventParams( | ||
234 | "at_target", new object[] { | ||
235 | new LSL_Types.LSLInteger(handle), | ||
236 | new LSL_Types.Vector3(targetpos.X,targetpos.Y,targetpos.Z), | ||
237 | new LSL_Types.Vector3(atpos.X,atpos.Y,atpos.Z) }, | ||
238 | new XDetectParams[0])); | ||
239 | } | ||
240 | |||
241 | public void not_at_target(uint localID) | ||
242 | { | ||
243 | myScriptEngine.PostObjectEvent(localID, new XEventParams( | ||
244 | "not_at_target",new object[0], | ||
245 | new XDetectParams[0])); | ||
246 | } | ||
247 | |||
248 | public void at_rot_target(uint localID, LLUUID itemID) | ||
249 | { | ||
250 | myScriptEngine.PostObjectEvent(localID, new XEventParams( | ||
251 | "at_rot_target",new object[0], | ||
252 | new XDetectParams[0])); | ||
253 | } | ||
254 | |||
255 | public void not_at_rot_target(uint localID, LLUUID itemID) | ||
256 | { | ||
257 | myScriptEngine.PostObjectEvent(localID, new XEventParams( | ||
258 | "not_at_rot_target",new object[0], | ||
259 | new XDetectParams[0])); | ||
260 | } | ||
261 | |||
262 | // run_time_permissions: not handled here | ||
263 | |||
264 | public void attach(uint localID, LLUUID itemID, LLUUID avatar) | ||
265 | { | ||
266 | myScriptEngine.PostObjectEvent(localID, new XEventParams( | ||
267 | "attach",new object[] { | ||
268 | new LSL_Types.LSLString(avatar.ToString()) }, | ||
269 | new XDetectParams[0])); | ||
270 | } | ||
271 | |||
272 | // dataserver: not handled here | ||
273 | // link_message: not handled here | ||
274 | |||
275 | public void moving_start(uint localID, LLUUID itemID) | ||
276 | { | ||
277 | myScriptEngine.PostObjectEvent(localID, new XEventParams( | ||
278 | "moving_start",new object[0], | ||
279 | new XDetectParams[0])); | ||
280 | } | ||
281 | |||
282 | public void moving_end(uint localID, LLUUID itemID) | ||
283 | { | ||
284 | myScriptEngine.PostObjectEvent(localID, new XEventParams( | ||
285 | "moving_end",new object[0], | ||
286 | new XDetectParams[0])); | ||
287 | } | ||
288 | |||
289 | // object_rez: not handled here | ||
290 | // remote_data: not handled here | ||
291 | // http_response: not handled here | ||
292 | } | ||
293 | } | ||