aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules/World/NPC
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/OptionalModules/World/NPC')
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs38
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs26
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs18
3 files changed, 54 insertions, 28 deletions
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index 4674489..c88ccc5 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -44,6 +44,20 @@ namespace OpenSim.Region.OptionalModules.World.NPC
44 { 44 {
45 public bool SenseAsAgent { get; set; } 45 public bool SenseAsAgent { get; set; }
46 46
47 public delegate void ChatToNPC(
48 string message, byte type, Vector3 fromPos, string fromName,
49 UUID fromAgentID, UUID ownerID, byte source, byte audible);
50
51 /// <summary>
52 /// Fired when the NPC receives a chat message.
53 /// </summary>
54 public event ChatToNPC OnChatToNPC;
55
56 /// <summary>
57 /// Fired when the NPC receives an instant message.
58 /// </summary>
59 public event Action<GridInstantMessage> OnInstantMessageToNPC;
60
47 private readonly string m_firstname; 61 private readonly string m_firstname;
48 private readonly string m_lastname; 62 private readonly string m_lastname;
49 private readonly Vector3 m_startPos; 63 private readonly Vector3 m_startPos;
@@ -259,6 +273,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
259 public event Action<IClientAPI, bool> OnCompleteMovementToRegion; 273 public event Action<IClientAPI, bool> OnCompleteMovementToRegion;
260 public event UpdateAgent OnPreAgentUpdate; 274 public event UpdateAgent OnPreAgentUpdate;
261 public event UpdateAgent OnAgentUpdate; 275 public event UpdateAgent OnAgentUpdate;
276 public event UpdateAgent OnAgentCameraUpdate;
262 public event AgentRequestSit OnAgentRequestSit; 277 public event AgentRequestSit OnAgentRequestSit;
263 public event AgentSit OnAgentSit; 278 public event AgentSit OnAgentSit;
264 public event AvatarPickerRequest OnAvatarPickerRequest; 279 public event AvatarPickerRequest OnAvatarPickerRequest;
@@ -393,6 +408,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
393 public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest; 408 public event EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest;
394 public event EstateChangeInfo OnEstateChangeInfo; 409 public event EstateChangeInfo OnEstateChangeInfo;
395 public event EstateManageTelehub OnEstateManageTelehub; 410 public event EstateManageTelehub OnEstateManageTelehub;
411 public event CachedTextureRequest OnCachedTextureRequest;
396 public event ScriptReset OnScriptReset; 412 public event ScriptReset OnScriptReset;
397 public event GetScriptRunning OnGetScriptRunning; 413 public event GetScriptRunning OnGetScriptRunning;
398 public event SetScriptRunning OnSetScriptRunning; 414 public event SetScriptRunning OnSetScriptRunning;
@@ -573,6 +589,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC
573 { 589 {
574 } 590 }
575 591
592 public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List<CachedTextureResponseArg> cachedTextures)
593 {
594
595 }
596
576 public virtual void Kick(string message) 597 public virtual void Kick(string message)
577 { 598 {
578 } 599 }
@@ -590,7 +611,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
590 611
591 } 612 }
592 613
593 public virtual void SendKillObject(ulong regionHandle, List<uint> localID) 614 public virtual void SendKillObject(List<uint> localID)
594 { 615 {
595 } 616 }
596 617
@@ -617,17 +638,18 @@ namespace OpenSim.Region.OptionalModules.World.NPC
617 string message, byte type, Vector3 fromPos, string fromName, 638 string message, byte type, Vector3 fromPos, string fromName,
618 UUID fromAgentID, UUID ownerID, byte source, byte audible) 639 UUID fromAgentID, UUID ownerID, byte source, byte audible)
619 { 640 {
620 } 641 ChatToNPC ctn = OnChatToNPC;
621 642
622 public virtual void SendChatMessage( 643 if (ctn != null)
623 byte[] message, byte type, Vector3 fromPos, string fromName, 644 ctn(message, type, fromPos, fromName, fromAgentID, ownerID, source, audible);
624 UUID fromAgentID, UUID ownerID, byte source, byte audible)
625 {
626 } 645 }
627 646
628 public void SendInstantMessage(GridInstantMessage im) 647 public void SendInstantMessage(GridInstantMessage im)
629 { 648 {
630 649 Action<GridInstantMessage> oimtn = OnInstantMessageToNPC;
650
651 if (oimtn != null)
652 oimtn(im);
631 } 653 }
632 654
633 public void SendGenericMessage(string method, UUID invoice, List<string> message) 655 public void SendGenericMessage(string method, UUID invoice, List<string> message)
@@ -1236,7 +1258,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
1236 { 1258 {
1237 } 1259 }
1238 1260
1239 public void StopFlying(ISceneEntity presence) 1261 public void SendAgentTerseUpdate(ISceneEntity presence)
1240 { 1262 {
1241 } 1263 }
1242 1264
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index 8c9c006..9ec4740 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -116,7 +116,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC
116 return false; 116 return false;
117 117
118 // Delete existing npc attachments 118 // Delete existing npc attachments
119 scene.AttachmentsModule.DeleteAttachmentsFromScene(npc, false); 119 if(scene.AttachmentsModule != null)
120 scene.AttachmentsModule.DeleteAttachmentsFromScene(npc, false);
120 121
121 // XXX: We can't just use IAvatarFactoryModule.SetAppearance() yet 122 // XXX: We can't just use IAvatarFactoryModule.SetAppearance() yet
122 // since it doesn't transfer attachments 123 // since it doesn't transfer attachments
@@ -125,7 +126,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC
125 npc.Appearance = npcAppearance; 126 npc.Appearance = npcAppearance;
126 127
127 // Rez needed npc attachments 128 // Rez needed npc attachments
128 scene.AttachmentsModule.RezAttachments(npc); 129 if (scene.AttachmentsModule != null)
130 scene.AttachmentsModule.RezAttachments(npc);
129 131
130 IAvatarFactoryModule module = 132 IAvatarFactoryModule module =
131 scene.RequestModuleInterface<IAvatarFactoryModule>(); 133 scene.RequestModuleInterface<IAvatarFactoryModule>();
@@ -174,7 +176,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
174 lock (m_avatars) 176 lock (m_avatars)
175 { 177 {
176 scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd); 178 scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
177 scene.AddNewClient(npcAvatar, PresenceType.Npc); 179 scene.AddNewAgent(npcAvatar, PresenceType.Npc);
178 180
179 ScenePresence sp; 181 ScenePresence sp;
180 if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp)) 182 if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
@@ -205,8 +207,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC
205 if (scene.TryGetScenePresence(agentID, out sp)) 207 if (scene.TryGetScenePresence(agentID, out sp))
206 { 208 {
207// m_log.DebugFormat( 209// m_log.DebugFormat(
208// "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}", 210// "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}",
209// sp.Name, pos, scene.RegionInfo.RegionName, noFly, landAtTarget); 211// sp.Name, pos, scene.RegionInfo.RegionName,
212// noFly, landAtTarget);
210 213
211 sp.MoveToTarget(pos, noFly, landAtTarget); 214 sp.MoveToTarget(pos, noFly, landAtTarget);
212 sp.SetAlwaysRun = running; 215 sp.SetAlwaysRun = running;
@@ -283,9 +286,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
283 ScenePresence sp; 286 ScenePresence sp;
284 if (scene.TryGetScenePresence(agentID, out sp)) 287 if (scene.TryGetScenePresence(agentID, out sp))
285 { 288 {
286 sp.HandleAgentRequestSit(m_avatars[agentID], agentID, 289 sp.HandleAgentRequestSit(m_avatars[agentID], agentID, partID, Vector3.Zero);
287 partID, Vector3.Zero);
288 //sp.HandleAgentSit(m_avatars[agentID], agentID);
289 290
290 return true; 291 return true;
291 } 292 }
@@ -375,10 +376,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC
375 m_log.DebugFormat("[NPC MODULE]: Found {0} {1} to remove", 376 m_log.DebugFormat("[NPC MODULE]: Found {0} {1} to remove",
376 agentID, av.Name); 377 agentID, av.Name);
377 */ 378 */
378 scene.RemoveClient(agentID, false); 379
380 scene.CloseAgent(agentID, false);
381
379 m_avatars.Remove(agentID); 382 m_avatars.Remove(agentID);
380 383
381// m_log.DebugFormat("[NPC MODULE]: Removed NPC {0} {1}", agentID, av.Name); 384 /*
385 m_log.DebugFormat("[NPC MODULE]: Removed NPC {0} {1}",
386 agentID, av.Name);
387 */
382 return true; 388 return true;
383 } 389 }
384 } 390 }
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
index 34362af..14eb25b 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
@@ -155,7 +155,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
155 public void TestCreateWithAttachments() 155 public void TestCreateWithAttachments()
156 { 156 {
157 TestHelpers.InMethod(); 157 TestHelpers.InMethod();
158// log4net.Config.XmlConfigurator.Configure(); 158// TestHelpers.EnableLogging();
159 159
160 UUID userId = TestHelpers.ParseTail(0x1); 160 UUID userId = TestHelpers.ParseTail(0x1);
161 UserAccountHelpers.CreateUserWithInventory(m_scene, userId); 161 UserAccountHelpers.CreateUserWithInventory(m_scene, userId);
@@ -321,9 +321,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
321 321
322 Assert.That(part.SitTargetAvatar, Is.EqualTo(npcId)); 322 Assert.That(part.SitTargetAvatar, Is.EqualTo(npcId));
323 Assert.That(npc.ParentID, Is.EqualTo(part.LocalId)); 323 Assert.That(npc.ParentID, Is.EqualTo(part.LocalId));
324 Assert.That( 324// Assert.That(
325 npc.AbsolutePosition, 325// npc.AbsolutePosition,
326 Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT)); 326// Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT));
327 327
328 m_npcMod.Stand(npc.UUID, m_scene); 328 m_npcMod.Stand(npc.UUID, m_scene);
329 329
@@ -335,7 +335,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
335 public void TestSitAndStandWithNoSitTarget() 335 public void TestSitAndStandWithNoSitTarget()
336 { 336 {
337 TestHelpers.InMethod(); 337 TestHelpers.InMethod();
338// log4net.Config.XmlConfigurator.Configure(); 338// TestHelpers.EnableLogging();
339 339
340 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1)); 340 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1));
341 341
@@ -353,13 +353,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
353 Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero)); 353 Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
354 Assert.That(npc.ParentID, Is.EqualTo(part.LocalId)); 354 Assert.That(npc.ParentID, Is.EqualTo(part.LocalId));
355 355
356 // FIXME: This is different for live avatars - z position is adjusted. This is half the height of the 356 // We should really be using the NPC size but this would mean preserving the physics actor since it is
357 // default avatar. 357 // removed on sit.
358 // Curiously, Vector3.ToString() will not display the last two places of the float. For example,
359 // printing out npc.AbsolutePosition will give <0, 0, 0.8454993> not <0, 0, 0.845499337>
360 Assert.That( 358 Assert.That(
361 npc.AbsolutePosition, 359 npc.AbsolutePosition,
362 Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, 0.845499337f))); 360 Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, sp.PhysicsActor.Size.Z / 2)));
363 361
364 m_npcMod.Stand(npc.UUID, m_scene); 362 m_npcMod.Stand(npc.UUID, m_scene);
365 363