aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine/Shared/Helpers.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ScriptEngine/Shared/Helpers.cs')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Helpers.cs121
1 files changed, 121 insertions, 0 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Helpers.cs b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs
new file mode 100644
index 0000000..8e312c5
--- /dev/null
+++ b/OpenSim/Region/ScriptEngine/Shared/Helpers.cs
@@ -0,0 +1,121 @@
1using System;
2using System.IO;
3using System.Threading;
4using System.Collections;
5using System.Collections.Generic;
6using libsecondlife;
7using OpenSim.Framework;
8using OpenSim.Region.Environment;
9using OpenSim.Region.Environment.Scenes;
10
11namespace OpenSim.Region.ScriptEngine.Shared
12{
13 public class DetectParams
14 {
15 public DetectParams()
16 {
17 Key = LLUUID.Zero;
18 OffsetPos = new LSL_Types.Vector3();
19 LinkNum = 0;
20 Group = LLUUID.Zero;
21 Name = String.Empty;
22 Owner = LLUUID.Zero;
23 Position = new LSL_Types.Vector3();
24 Rotation = new LSL_Types.Quaternion();
25 Type = 0;
26 Velocity = new LSL_Types.Vector3();
27 }
28
29 public LLUUID Key;
30 public LSL_Types.Vector3 OffsetPos;
31 public int LinkNum;
32 public LLUUID Group;
33 public string Name;
34 public LLUUID Owner;
35 public LSL_Types.Vector3 Position;
36 public LSL_Types.Quaternion Rotation;
37 public int Type;
38 public LSL_Types.Vector3 Velocity;
39
40 public void Populate(Scene scene)
41 {
42 SceneObjectPart part = scene.GetSceneObjectPart(Key);
43 if (part == null) // Avatar, maybe?
44 {
45 ScenePresence presence = scene.GetScenePresence(Key);
46 if (presence == null)
47 return;
48
49 Name = presence.Firstname + " " + presence.Lastname;
50 Owner = Key;
51 Position = new LSL_Types.Vector3(
52 presence.AbsolutePosition.X,
53 presence.AbsolutePosition.X,
54 presence.AbsolutePosition.Z);
55 Rotation = new LSL_Types.Quaternion(
56 presence.Rotation.x,
57 presence.Rotation.y,
58 presence.Rotation.z,
59 presence.Rotation.w);
60 Velocity = new LSL_Types.Vector3(
61 presence.Velocity.X,
62 presence.Velocity.X,
63 presence.Velocity.Z);
64
65 Type = 0x01; // Avatar
66 if (presence.Velocity != LLVector3.Zero)
67 Type |= 0x02; // Active
68
69 Group = presence.ControllingClient.ActiveGroupId;
70
71 return;
72 }
73
74 part=part.ParentGroup.RootPart; // We detect objects only
75
76 LinkNum = 0; // Not relevant
77
78 Group = part.GroupID;
79 Name = part.Name;
80 Owner = part.OwnerID;
81 if (part.Velocity == LLVector3.Zero)
82 Type = 0x04; // Passive
83 else
84 Type = 0x02; // Passive
85
86 foreach (SceneObjectPart p in part.ParentGroup.Children.Values)
87 {
88 if (p.ContainsScripts())
89 {
90 Type |= 0x08; // Scripted
91 break;
92 }
93 }
94
95 Position = new LSL_Types.Vector3(part.AbsolutePosition.X,
96 part.AbsolutePosition.Y,
97 part.AbsolutePosition.Z);
98
99 LLQuaternion wr = part.GetWorldRotation();
100 Rotation = new LSL_Types.Quaternion(wr.X, wr.Y, wr.Z, wr.W);
101
102 Velocity = new LSL_Types.Vector3(part.Velocity.X,
103 part.Velocity.Y,
104 part.Velocity.Z);
105 }
106 }
107
108 public class EventParams
109 {
110 public EventParams(string eventName, Object[] eventParams, DetectParams[] detectParams)
111 {
112 EventName=eventName;
113 Params=eventParams;
114 DetectParams=detectParams;
115 }
116
117 public string EventName;
118 public Object[] Params;
119 public DetectParams[] DetectParams;
120 }
121}