diff options
author | UbitUmarov | 2012-07-17 00:54:23 +0100 |
---|---|---|
committer | UbitUmarov | 2012-07-17 00:54:23 +0100 |
commit | d5f4fb7b50fb7c594b018f8241399e22f88fc951 (patch) | |
tree | 8f3dab3d170596f02b1d1d836a0bc08a3e6b8ebd /OpenSim/Region/OptionalModules/World | |
parent | UbitOde: remove useless water collider from active code. (diff) | |
parent | Merge branch 'avination' into careminster (diff) | |
download | opensim-SC-d5f4fb7b50fb7c594b018f8241399e22f88fc951.zip opensim-SC-d5f4fb7b50fb7c594b018f8241399e22f88fc951.tar.gz opensim-SC-d5f4fb7b50fb7c594b018f8241399e22f88fc951.tar.bz2 opensim-SC-d5f4fb7b50fb7c594b018f8241399e22f88fc951.tar.xz |
Merge branch 'avination' into ubitwork
Diffstat (limited to 'OpenSim/Region/OptionalModules/World')
4 files changed, 129 insertions, 41 deletions
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs index 8996865..97db7e1 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs | |||
@@ -76,22 +76,27 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
76 | 76 | ||
77 | public void Say(string message) | 77 | public void Say(string message) |
78 | { | 78 | { |
79 | SendOnChatFromClient(message, ChatTypeEnum.Say); | 79 | SendOnChatFromClient(0, message, ChatTypeEnum.Say); |
80 | } | 80 | } |
81 | 81 | ||
82 | public void Shout(string message) | 82 | public void Say(int channel, string message) |
83 | { | 83 | { |
84 | SendOnChatFromClient(message, ChatTypeEnum.Shout); | 84 | SendOnChatFromClient(channel, message, ChatTypeEnum.Say); |
85 | } | 85 | } |
86 | 86 | ||
87 | public void Whisper(string message) | 87 | public void Shout(int channel, string message) |
88 | { | 88 | { |
89 | SendOnChatFromClient(message, ChatTypeEnum.Whisper); | 89 | SendOnChatFromClient(channel, message, ChatTypeEnum.Shout); |
90 | } | ||
91 | |||
92 | public void Whisper(int channel, string message) | ||
93 | { | ||
94 | SendOnChatFromClient(channel, message, ChatTypeEnum.Whisper); | ||
90 | } | 95 | } |
91 | 96 | ||
92 | public void Broadcast(string message) | 97 | public void Broadcast(string message) |
93 | { | 98 | { |
94 | SendOnChatFromClient(message, ChatTypeEnum.Broadcast); | 99 | SendOnChatFromClient(0, message, ChatTypeEnum.Broadcast); |
95 | } | 100 | } |
96 | 101 | ||
97 | public void GiveMoney(UUID target, int amount) | 102 | public void GiveMoney(UUID target, int amount) |
@@ -99,6 +104,45 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
99 | OnMoneyTransferRequest(m_uuid, target, amount, 1, "Payment"); | 104 | OnMoneyTransferRequest(m_uuid, target, amount, 1, "Payment"); |
100 | } | 105 | } |
101 | 106 | ||
107 | public bool Touch(UUID target) | ||
108 | { | ||
109 | SceneObjectPart part = m_scene.GetSceneObjectPart(target); | ||
110 | if (part == null) | ||
111 | return false; | ||
112 | bool objectTouchable = hasTouchEvents(part); // Only touch an object that is scripted to respond | ||
113 | if (!objectTouchable && !part.IsRoot) | ||
114 | objectTouchable = hasTouchEvents(part.ParentGroup.RootPart); | ||
115 | if (!objectTouchable) | ||
116 | return false; | ||
117 | // Set up the surface args as if the touch is from a client that does not support this | ||
118 | SurfaceTouchEventArgs surfaceArgs = new SurfaceTouchEventArgs(); | ||
119 | surfaceArgs.FaceIndex = -1; // TOUCH_INVALID_FACE | ||
120 | surfaceArgs.Binormal = Vector3.Zero; // TOUCH_INVALID_VECTOR | ||
121 | surfaceArgs.Normal = Vector3.Zero; // TOUCH_INVALID_VECTOR | ||
122 | surfaceArgs.STCoord = new Vector3(-1.0f, -1.0f, 0.0f); // TOUCH_INVALID_TEXCOORD | ||
123 | surfaceArgs.UVCoord = surfaceArgs.STCoord; // TOUCH_INVALID_TEXCOORD | ||
124 | List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>(); | ||
125 | touchArgs.Add(surfaceArgs); | ||
126 | Vector3 offset = part.OffsetPosition * -1.0f; | ||
127 | if (OnGrabObject == null) | ||
128 | return false; | ||
129 | OnGrabObject(part.LocalId, offset, this, touchArgs); | ||
130 | if (OnGrabUpdate != null) | ||
131 | OnGrabUpdate(part.UUID, offset, part.ParentGroup.RootPart.GroupPosition, this, touchArgs); | ||
132 | if (OnDeGrabObject != null) | ||
133 | OnDeGrabObject(part.LocalId, this, touchArgs); | ||
134 | return true; | ||
135 | } | ||
136 | |||
137 | private bool hasTouchEvents(SceneObjectPart part) | ||
138 | { | ||
139 | if ((part.ScriptEvents & scriptEvents.touch) != 0 || | ||
140 | (part.ScriptEvents & scriptEvents.touch_start) != 0 || | ||
141 | (part.ScriptEvents & scriptEvents.touch_end) != 0) | ||
142 | return true; | ||
143 | return false; | ||
144 | } | ||
145 | |||
102 | public void InstantMessage(UUID target, string message) | 146 | public void InstantMessage(UUID target, string message) |
103 | { | 147 | { |
104 | OnInstantMessage(this, new GridInstantMessage(m_scene, | 148 | OnInstantMessage(this, new GridInstantMessage(m_scene, |
@@ -146,10 +190,18 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
146 | 190 | ||
147 | #region Internal Functions | 191 | #region Internal Functions |
148 | 192 | ||
149 | private void SendOnChatFromClient(string message, ChatTypeEnum chatType) | 193 | private void SendOnChatFromClient(int channel, string message, ChatTypeEnum chatType) |
150 | { | 194 | { |
195 | if (channel == 0) | ||
196 | { | ||
197 | message = message.Trim(); | ||
198 | if (string.IsNullOrEmpty(message)) | ||
199 | { | ||
200 | return; | ||
201 | } | ||
202 | } | ||
151 | OSChatMessage chatFromClient = new OSChatMessage(); | 203 | OSChatMessage chatFromClient = new OSChatMessage(); |
152 | chatFromClient.Channel = 0; | 204 | chatFromClient.Channel = channel; |
153 | chatFromClient.From = Name; | 205 | chatFromClient.From = Name; |
154 | chatFromClient.Message = message; | 206 | chatFromClient.Message = message; |
155 | chatFromClient.Position = StartPos; | 207 | chatFromClient.Position = StartPos; |
@@ -900,11 +952,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
900 | { | 952 | { |
901 | } | 953 | } |
902 | 954 | ||
903 | public EndPoint GetClientEP() | ||
904 | { | ||
905 | return null; | ||
906 | } | ||
907 | |||
908 | public ClientInfo GetClientInfo() | 955 | public ClientInfo GetClientInfo() |
909 | { | 956 | { |
910 | return null; | 957 | return null; |
@@ -1046,10 +1093,6 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
1046 | { | 1093 | { |
1047 | } | 1094 | } |
1048 | 1095 | ||
1049 | public void KillEndDone() | ||
1050 | { | ||
1051 | } | ||
1052 | |||
1053 | public void SendEventInfoReply (EventData info) | 1096 | public void SendEventInfoReply (EventData info) |
1054 | { | 1097 | { |
1055 | } | 1098 | } |
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs index ebf5e84..b37aba3 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs | |||
@@ -155,18 +155,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
155 | ScenePresence sp; | 155 | ScenePresence sp; |
156 | if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) | 156 | if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) |
157 | { | 157 | { |
158 | m_log.DebugFormat( | ||
159 | "[NPC MODULE]: Successfully retrieved scene presence for NPC {0} {1}", sp.Name, sp.UUID); | ||
160 | |||
161 | sp.CompleteMovement(npcAvatar, false); | 158 | sp.CompleteMovement(npcAvatar, false); |
162 | m_avatars.Add(npcAvatar.AgentId, npcAvatar); | 159 | m_avatars.Add(npcAvatar.AgentId, npcAvatar); |
160 | m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name); | ||
163 | } | 161 | } |
164 | else | ||
165 | { | ||
166 | m_log.WarnFormat("[NPC MODULE]: Could not find scene presence for NPC {0} {1}", sp.Name, sp.UUID); | ||
167 | npcAvatar.AgentId = UUID.Zero; | ||
168 | } | ||
169 | |||
170 | } | 162 | } |
171 | ev.Set(); | 163 | ev.Set(); |
172 | }); | 164 | }); |
@@ -178,7 +170,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
178 | return npcAvatar.AgentId; | 170 | return npcAvatar.AgentId; |
179 | } | 171 | } |
180 | 172 | ||
181 | public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget) | 173 | public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget, bool running) |
182 | { | 174 | { |
183 | lock (m_avatars) | 175 | lock (m_avatars) |
184 | { | 176 | { |
@@ -192,6 +184,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
192 | sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget); | 184 | sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget); |
193 | 185 | ||
194 | sp.MoveToTarget(pos, noFly, landAtTarget); | 186 | sp.MoveToTarget(pos, noFly, landAtTarget); |
187 | sp.SetAlwaysRun = running; | ||
195 | 188 | ||
196 | return true; | 189 | return true; |
197 | } | 190 | } |
@@ -221,6 +214,29 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
221 | 214 | ||
222 | public bool Say(UUID agentID, Scene scene, string text) | 215 | public bool Say(UUID agentID, Scene scene, string text) |
223 | { | 216 | { |
217 | return Say(agentID, scene, text, 0); | ||
218 | } | ||
219 | |||
220 | public bool Say(UUID agentID, Scene scene, string text, int channel) | ||
221 | { | ||
222 | lock (m_avatars) | ||
223 | { | ||
224 | if (m_avatars.ContainsKey(agentID)) | ||
225 | { | ||
226 | ScenePresence sp; | ||
227 | scene.TryGetScenePresence(agentID, out sp); | ||
228 | |||
229 | m_avatars[agentID].Say(channel, text); | ||
230 | |||
231 | return true; | ||
232 | } | ||
233 | } | ||
234 | |||
235 | return false; | ||
236 | } | ||
237 | |||
238 | public bool Shout(UUID agentID, Scene scene, string text, int channel) | ||
239 | { | ||
224 | lock (m_avatars) | 240 | lock (m_avatars) |
225 | { | 241 | { |
226 | if (m_avatars.ContainsKey(agentID)) | 242 | if (m_avatars.ContainsKey(agentID)) |
@@ -228,7 +244,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
228 | ScenePresence sp; | 244 | ScenePresence sp; |
229 | scene.TryGetScenePresence(agentID, out sp); | 245 | scene.TryGetScenePresence(agentID, out sp); |
230 | 246 | ||
231 | m_avatars[agentID].Say(text); | 247 | m_avatars[agentID].Shout(channel, text); |
232 | 248 | ||
233 | return true; | 249 | return true; |
234 | } | 250 | } |
@@ -255,6 +271,24 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
255 | return false; | 271 | return false; |
256 | } | 272 | } |
257 | 273 | ||
274 | public bool Whisper(UUID agentID, Scene scene, string text, int channel) | ||
275 | { | ||
276 | lock (m_avatars) | ||
277 | { | ||
278 | if (m_avatars.ContainsKey(agentID)) | ||
279 | { | ||
280 | ScenePresence sp; | ||
281 | scene.TryGetScenePresence(agentID, out sp); | ||
282 | |||
283 | m_avatars[agentID].Whisper(channel, text); | ||
284 | |||
285 | return true; | ||
286 | } | ||
287 | } | ||
288 | |||
289 | return false; | ||
290 | } | ||
291 | |||
258 | public bool Stand(UUID agentID, Scene scene) | 292 | public bool Stand(UUID agentID, Scene scene) |
259 | { | 293 | { |
260 | lock (m_avatars) | 294 | lock (m_avatars) |
@@ -272,6 +306,16 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
272 | return false; | 306 | return false; |
273 | } | 307 | } |
274 | 308 | ||
309 | public bool Touch(UUID agentID, UUID objectID) | ||
310 | { | ||
311 | lock (m_avatars) | ||
312 | { | ||
313 | if (m_avatars.ContainsKey(agentID)) | ||
314 | return m_avatars[agentID].Touch(objectID); | ||
315 | return false; | ||
316 | } | ||
317 | } | ||
318 | |||
275 | public UUID GetOwner(UUID agentID) | 319 | public UUID GetOwner(UUID agentID) |
276 | { | 320 | { |
277 | lock (m_avatars) | 321 | lock (m_avatars) |
@@ -308,7 +352,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC | |||
308 | scene.RemoveClient(agentID, false); | 352 | scene.RemoveClient(agentID, false); |
309 | m_avatars.Remove(agentID); | 353 | m_avatars.Remove(agentID); |
310 | 354 | ||
311 | // m_log.DebugFormat("[NPC MODULE]: Removed {0} {1}", agentID, av.Name); | 355 | m_log.DebugFormat("[NPC MODULE]: Removed NPC {0} {1}", agentID, av.Name); |
312 | return true; | 356 | return true; |
313 | } | 357 | } |
314 | } | 358 | } |
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs index eea0b2e..9179966 100644 --- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs +++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs | |||
@@ -85,7 +85,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
85 | m_attMod = new AttachmentsModule(); | 85 | m_attMod = new AttachmentsModule(); |
86 | m_npcMod = new NPCModule(); | 86 | m_npcMod = new NPCModule(); |
87 | 87 | ||
88 | m_scene = SceneHelpers.SetupScene(); | 88 | m_scene = new SceneHelpers().SetupScene(); |
89 | SceneHelpers.SetupSceneModules(m_scene, config, m_afMod, m_umMod, m_attMod, m_npcMod, new BasicInventoryAccessModule()); | 89 | SceneHelpers.SetupSceneModules(m_scene, config, m_afMod, m_umMod, m_attMod, m_npcMod, new BasicInventoryAccessModule()); |
90 | } | 90 | } |
91 | 91 | ||
@@ -242,7 +242,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
242 | Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); | 242 | Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); |
243 | 243 | ||
244 | Vector3 targetPos = startPos + new Vector3(0, 10, 0); | 244 | Vector3 targetPos = startPos + new Vector3(0, 10, 0); |
245 | m_npcMod.MoveToTarget(npc.UUID, m_scene, targetPos, false, false); | 245 | m_npcMod.MoveToTarget(npc.UUID, m_scene, targetPos, false, false, false); |
246 | 246 | ||
247 | Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); | 247 | Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); |
248 | //Assert.That(npc.Rotation, Is.EqualTo(new Quaternion(0, 0, 0.7071068f, 0.7071068f))); | 248 | //Assert.That(npc.Rotation, Is.EqualTo(new Quaternion(0, 0, 0.7071068f, 0.7071068f))); |
@@ -267,7 +267,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
267 | // Try a second movement | 267 | // Try a second movement |
268 | startPos = npc.AbsolutePosition; | 268 | startPos = npc.AbsolutePosition; |
269 | targetPos = startPos + new Vector3(10, 0, 0); | 269 | targetPos = startPos + new Vector3(10, 0, 0); |
270 | m_npcMod.MoveToTarget(npc.UUID, m_scene, targetPos, false, false); | 270 | m_npcMod.MoveToTarget(npc.UUID, m_scene, targetPos, false, false, false); |
271 | 271 | ||
272 | Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); | 272 | Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos)); |
273 | // Assert.That(npc.Rotation, Is.EqualTo(new Quaternion(0, 0, 0, 1))); | 273 | // Assert.That(npc.Rotation, Is.EqualTo(new Quaternion(0, 0, 0, 1))); |
@@ -301,7 +301,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
301 | UUID npcId = m_npcMod.CreateNPC("John", "Smith", startPos, UUID.Zero, true, m_scene, sp.Appearance); | 301 | UUID npcId = m_npcMod.CreateNPC("John", "Smith", startPos, UUID.Zero, true, m_scene, sp.Appearance); |
302 | 302 | ||
303 | ScenePresence npc = m_scene.GetScenePresence(npcId); | 303 | ScenePresence npc = m_scene.GetScenePresence(npcId); |
304 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); | 304 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; |
305 | 305 | ||
306 | part.SitTargetPosition = new Vector3(0, 0, 1); | 306 | part.SitTargetPosition = new Vector3(0, 0, 1); |
307 | m_npcMod.Sit(npc.UUID, part.UUID, m_scene); | 307 | m_npcMod.Sit(npc.UUID, part.UUID, m_scene); |
@@ -333,7 +333,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests | |||
333 | UUID npcId = m_npcMod.CreateNPC("John", "Smith", startPos, UUID.Zero, true, m_scene, sp.Appearance); | 333 | UUID npcId = m_npcMod.CreateNPC("John", "Smith", startPos, UUID.Zero, true, m_scene, sp.Appearance); |
334 | 334 | ||
335 | ScenePresence npc = m_scene.GetScenePresence(npcId); | 335 | ScenePresence npc = m_scene.GetScenePresence(npcId); |
336 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene); | 336 | SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart; |
337 | 337 | ||
338 | m_npcMod.Sit(npc.UUID, part.UUID, m_scene); | 338 | m_npcMod.Sit(npc.UUID, part.UUID, m_scene); |
339 | 339 | ||
diff --git a/OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs b/OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs index 48c242d..1aee39a 100644 --- a/OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs +++ b/OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs | |||
@@ -113,14 +113,15 @@ namespace OpenSim.Region.OptionalModules.World.WorldView | |||
113 | if (!m_Enabled) | 113 | if (!m_Enabled) |
114 | return new Byte[0]; | 114 | return new Byte[0]; |
115 | 115 | ||
116 | Bitmap bmp = m_Generator.CreateViewImage(pos, rot, fov, width, | 116 | using (Bitmap bmp = m_Generator.CreateViewImage(pos, rot, fov, width, height, usetex)) |
117 | height, usetex); | 117 | { |
118 | 118 | using (MemoryStream str = new MemoryStream()) | |
119 | MemoryStream str = new MemoryStream(); | 119 | { |
120 | 120 | bmp.Save(str, ImageFormat.Jpeg); | |
121 | bmp.Save(str, ImageFormat.Jpeg); | ||
122 | 121 | ||
123 | return str.ToArray(); | 122 | return str.ToArray(); |
123 | } | ||
124 | } | ||
124 | } | 125 | } |
125 | } | 126 | } |
126 | } | 127 | } |