opensim-development – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | eva | 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 OpenSimulator 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 System.IO; |
||
30 | using System.Threading; |
||
31 | using System.Collections; |
||
32 | using System.Collections.Generic; |
||
33 | using System.Runtime.Serialization; |
||
34 | using OpenMetaverse; |
||
35 | using OpenSim.Framework; |
||
36 | using OpenSim.Region.CoreModules; |
||
37 | using OpenSim.Region.Framework.Scenes; |
||
38 | using OpenSim.Region.Framework.Interfaces; |
||
39 | |||
40 | namespace OpenSim.Region.ScriptEngine.Shared |
||
41 | { |
||
42 | [Serializable] |
||
43 | public class EventAbortException : Exception |
||
44 | { |
||
45 | public EventAbortException() |
||
46 | { |
||
47 | } |
||
48 | |||
49 | protected EventAbortException( |
||
50 | SerializationInfo info, |
||
51 | StreamingContext context) |
||
52 | { |
||
53 | } |
||
54 | } |
||
55 | |||
56 | [Serializable] |
||
57 | public class SelfDeleteException : Exception |
||
58 | { |
||
59 | public SelfDeleteException() |
||
60 | { |
||
61 | } |
||
62 | |||
63 | protected SelfDeleteException( |
||
64 | SerializationInfo info, |
||
65 | StreamingContext context) |
||
66 | { |
||
67 | } |
||
68 | } |
||
69 | |||
70 | [Serializable] |
||
71 | public class ScriptDeleteException : Exception |
||
72 | { |
||
73 | public ScriptDeleteException() |
||
74 | { |
||
75 | } |
||
76 | |||
77 | protected ScriptDeleteException( |
||
78 | SerializationInfo info, |
||
79 | StreamingContext context) |
||
80 | { |
||
81 | } |
||
82 | } |
||
83 | |||
84 | /// <summary> |
||
85 | /// Used to signal when the script is stopping in co-operation with the script engine |
||
86 | /// (instead of through Thread.Abort()). |
||
87 | /// </summary> |
||
88 | [Serializable] |
||
89 | public class ScriptCoopStopException : Exception |
||
90 | { |
||
91 | public ScriptCoopStopException() |
||
92 | { |
||
93 | } |
||
94 | |||
95 | protected ScriptCoopStopException( |
||
96 | SerializationInfo info, |
||
97 | StreamingContext context) |
||
98 | { |
||
99 | } |
||
100 | } |
||
101 | |||
102 | public class DetectParams |
||
103 | { |
||
104 | public const int AGENT = 1; |
||
105 | public const int ACTIVE = 2; |
||
106 | public const int PASSIVE = 4; |
||
107 | public const int SCRIPTED = 8; |
||
108 | public const int OS_NPC = 0x01000000; |
||
109 | |||
110 | public DetectParams() |
||
111 | { |
||
112 | Key = UUID.Zero; |
||
113 | OffsetPos = new LSL_Types.Vector3(); |
||
114 | LinkNum = 0; |
||
115 | Group = UUID.Zero; |
||
116 | Name = String.Empty; |
||
117 | Owner = UUID.Zero; |
||
118 | Position = new LSL_Types.Vector3(); |
||
119 | Rotation = new LSL_Types.Quaternion(); |
||
120 | Type = 0; |
||
121 | Velocity = new LSL_Types.Vector3(); |
||
122 | initializeSurfaceTouch(); |
||
123 | } |
||
124 | |||
125 | public UUID Key; |
||
126 | public LSL_Types.Vector3 OffsetPos; |
||
127 | public int LinkNum; |
||
128 | public UUID Group; |
||
129 | public string Name; |
||
130 | public UUID Owner; |
||
131 | public LSL_Types.Vector3 Position; |
||
132 | public LSL_Types.Quaternion Rotation; |
||
133 | public int Type; |
||
134 | public LSL_Types.Vector3 Velocity; |
||
135 | |||
136 | private LSL_Types.Vector3 touchST; |
||
137 | public LSL_Types.Vector3 TouchST { get { return touchST; } } |
||
138 | |||
139 | private LSL_Types.Vector3 touchNormal; |
||
140 | public LSL_Types.Vector3 TouchNormal { get { return touchNormal; } } |
||
141 | |||
142 | private LSL_Types.Vector3 touchBinormal; |
||
143 | public LSL_Types.Vector3 TouchBinormal { get { return touchBinormal; } } |
||
144 | |||
145 | private LSL_Types.Vector3 touchPos; |
||
146 | public LSL_Types.Vector3 TouchPos { get { return touchPos; } } |
||
147 | |||
148 | private LSL_Types.Vector3 touchUV; |
||
149 | public LSL_Types.Vector3 TouchUV { get { return touchUV; } } |
||
150 | |||
151 | private int touchFace; |
||
152 | public int TouchFace { get { return touchFace; } } |
||
153 | |||
154 | // This can be done in two places including the constructor |
||
155 | // so be carefull what gets added here |
||
156 | private void initializeSurfaceTouch() |
||
157 | { |
||
158 | touchST = new LSL_Types.Vector3(-1.0, -1.0, 0.0); |
||
159 | touchNormal = new LSL_Types.Vector3(); |
||
160 | touchBinormal = new LSL_Types.Vector3(); |
||
161 | touchPos = new LSL_Types.Vector3(); |
||
162 | touchUV = new LSL_Types.Vector3(-1.0, -1.0, 0.0); |
||
163 | touchFace = -1; |
||
164 | } |
||
165 | |||
166 | /* |
||
167 | * Set up the surface touch detected values |
||
168 | */ |
||
169 | public SurfaceTouchEventArgs SurfaceTouchArgs |
||
170 | { |
||
171 | set |
||
172 | { |
||
173 | if (value == null) |
||
174 | { |
||
175 | // Initialise to defaults if no value |
||
176 | initializeSurfaceTouch(); |
||
177 | } |
||
178 | else |
||
179 | { |
||
180 | // Set the values from the touch data provided by the client |
||
181 | touchST = new LSL_Types.Vector3(value.STCoord); |
||
182 | touchUV = new LSL_Types.Vector3(value.UVCoord); |
||
183 | touchNormal = new LSL_Types.Vector3(value.Normal); |
||
184 | touchBinormal = new LSL_Types.Vector3(value.Binormal); |
||
185 | touchPos = new LSL_Types.Vector3(value.Position); |
||
186 | touchFace = value.FaceIndex; |
||
187 | } |
||
188 | } |
||
189 | } |
||
190 | |||
191 | public void Populate(Scene scene) |
||
192 | { |
||
193 | SceneObjectPart part = scene.GetSceneObjectPart(Key); |
||
194 | if (part == null) // Avatar, maybe? |
||
195 | { |
||
196 | ScenePresence presence = scene.GetScenePresence(Key); |
||
197 | if (presence == null) |
||
198 | return; |
||
199 | |||
200 | Name = presence.Firstname + " " + presence.Lastname; |
||
201 | Owner = Key; |
||
202 | Position = new LSL_Types.Vector3(presence.AbsolutePosition); |
||
203 | Rotation = new LSL_Types.Quaternion( |
||
204 | presence.Rotation.X, |
||
205 | presence.Rotation.Y, |
||
206 | presence.Rotation.Z, |
||
207 | presence.Rotation.W); |
||
208 | Velocity = new LSL_Types.Vector3(presence.Velocity); |
||
209 | |||
210 | if (presence.PresenceType != PresenceType.Npc) |
||
211 | { |
||
212 | Type = AGENT; |
||
213 | } |
||
214 | else |
||
215 | { |
||
216 | Type = OS_NPC; |
||
217 | |||
218 | INPCModule npcModule = scene.RequestModuleInterface<INPCModule>(); |
||
219 | INPC npcData = npcModule.GetNPC(presence.UUID, presence.Scene); |
||
220 | |||
221 | if (npcData.SenseAsAgent) |
||
222 | { |
||
223 | Type |= AGENT; |
||
224 | } |
||
225 | } |
||
226 | |||
227 | if (presence.Velocity != Vector3.Zero) |
||
228 | Type |= ACTIVE; |
||
229 | |||
230 | Group = presence.ControllingClient.ActiveGroupId; |
||
231 | |||
232 | return; |
||
233 | } |
||
234 | |||
235 | part = part.ParentGroup.RootPart; // We detect objects only |
||
236 | |||
237 | LinkNum = 0; // Not relevant |
||
238 | |||
239 | Group = part.GroupID; |
||
240 | Name = part.Name; |
||
241 | Owner = part.OwnerID; |
||
242 | if (part.Velocity == Vector3.Zero) |
||
243 | Type = PASSIVE; |
||
244 | else |
||
245 | Type = ACTIVE; |
||
246 | |||
247 | foreach (SceneObjectPart p in part.ParentGroup.Parts) |
||
248 | { |
||
249 | if (p.Inventory.ContainsScripts()) |
||
250 | { |
||
251 | Type |= SCRIPTED; // Scripted |
||
252 | break; |
||
253 | } |
||
254 | } |
||
255 | |||
256 | Position = new LSL_Types.Vector3(part.AbsolutePosition); |
||
257 | |||
258 | Quaternion wr = part.ParentGroup.GroupRotation; |
||
259 | Rotation = new LSL_Types.Quaternion(wr.X, wr.Y, wr.Z, wr.W); |
||
260 | |||
261 | Velocity = new LSL_Types.Vector3(part.Velocity); |
||
262 | } |
||
263 | } |
||
264 | |||
265 | /// <summary> |
||
266 | /// Holds all the data required to execute a scripting event. |
||
267 | /// </summary> |
||
268 | public class EventParams |
||
269 | { |
||
270 | public EventParams(string eventName, Object[] eventParams, DetectParams[] detectParams) |
||
271 | { |
||
272 | EventName = eventName; |
||
273 | Params = eventParams; |
||
274 | DetectParams = detectParams; |
||
275 | } |
||
276 | |||
277 | public string EventName; |
||
278 | public Object[] Params; |
||
279 | public DetectParams[] DetectParams; |
||
280 | } |
||
281 | } |