1
0

NPCModuleTests.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  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. using System;
  28. using System.Collections.Generic;
  29. using System.Reflection;
  30. using log4net;
  31. using Nini.Config;
  32. using NUnit.Framework;
  33. using OpenMetaverse;
  34. using OpenSim.Framework;
  35. using OpenSim.Region.CoreModules.Avatar.Attachments;
  36. using OpenSim.Region.CoreModules.Avatar.AvatarFactory;
  37. using OpenSim.Region.CoreModules.Framework.InventoryAccess;
  38. using OpenSim.Region.CoreModules.Framework.UserManagement;
  39. using OpenSim.Region.CoreModules.ServiceConnectorsOut.Avatar;
  40. using OpenSim.Region.Framework.Interfaces;
  41. using OpenSim.Region.Framework.Scenes;
  42. using OpenSim.Services.AvatarService;
  43. using OpenSim.Tests.Common;
  44. namespace OpenSim.Region.OptionalModules.World.NPC.Tests
  45. {
  46. [TestFixture]
  47. public class NPCModuleTests : OpenSimTestCase
  48. {
  49. private TestScene m_scene;
  50. private AvatarFactoryModule m_afMod;
  51. private UserManagementModule m_umMod;
  52. private AttachmentsModule m_attMod;
  53. private NPCModule m_npcMod;
  54. [TestFixtureSetUp]
  55. public void FixtureInit()
  56. {
  57. // Don't allow tests to be bamboozled by asynchronous events. Execute everything on the same thread.
  58. Util.FireAndForgetMethod = FireAndForgetMethod.None;
  59. }
  60. [TestFixtureTearDown]
  61. public void TearDown()
  62. {
  63. // We must set this back afterwards, otherwise later tests will fail since they're expecting multiple
  64. // threads. Possibly, later tests should be rewritten not to worry about such things.
  65. Util.FireAndForgetMethod = Util.DefaultFireAndForgetMethod;
  66. }
  67. public void SetUpScene()
  68. {
  69. SetUpScene(256, 256);
  70. }
  71. public void SetUpScene(uint sizeX, uint sizeY)
  72. {
  73. IConfigSource config = new IniConfigSource();
  74. config.AddConfig("NPC");
  75. config.Configs["NPC"].Set("Enabled", "true");
  76. config.AddConfig("Modules");
  77. config.Configs["Modules"].Set("InventoryAccessModule", "BasicInventoryAccessModule");
  78. m_afMod = new AvatarFactoryModule();
  79. m_umMod = new UserManagementModule();
  80. m_attMod = new AttachmentsModule();
  81. m_npcMod = new NPCModule();
  82. m_scene = new SceneHelpers().SetupScene("test scene", UUID.Random(), 1000, 1000, sizeX, sizeY, config);
  83. SceneHelpers.SetupSceneModules(m_scene, config, m_afMod, m_umMod, m_attMod, m_npcMod, new BasicInventoryAccessModule());
  84. }
  85. [Test]
  86. public void TestCreate()
  87. {
  88. TestHelpers.InMethod();
  89. // log4net.Config.XmlConfigurator.Configure();
  90. SetUpScene();
  91. ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1));
  92. // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
  93. // 8 is the index of the first baked texture in AvatarAppearance
  94. UUID originalFace8TextureId = TestHelpers.ParseTail(0x10);
  95. Primitive.TextureEntry originalTe = new Primitive.TextureEntry(UUID.Zero);
  96. Primitive.TextureEntryFace originalTef = originalTe.CreateFace(8);
  97. originalTef.TextureID = originalFace8TextureId;
  98. // We also need to add the texture to the asset service, otherwise the AvatarFactoryModule will tell
  99. // ScenePresence.SendInitialData() to reset our entire appearance.
  100. m_scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId));
  101. m_afMod.SetAppearance(sp, originalTe, null, new WearableCacheItem[0] );
  102. UUID npcId = m_npcMod.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, sp.Appearance);
  103. ScenePresence npc = m_scene.GetScenePresence(npcId);
  104. Assert.That(npc, Is.Not.Null);
  105. Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId));
  106. Assert.That(m_umMod.GetUserName(npc.UUID), Is.EqualTo(string.Format("{0} {1}", npc.Firstname, npc.Lastname)));
  107. IClientAPI client;
  108. Assert.That(m_scene.TryGetClient(npcId, out client), Is.True);
  109. // Have to account for both SP and NPC.
  110. Assert.That(m_scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(2));
  111. }
  112. [Test]
  113. public void TestRemove()
  114. {
  115. TestHelpers.InMethod();
  116. // log4net.Config.XmlConfigurator.Configure();
  117. SetUpScene();
  118. ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1));
  119. // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
  120. Vector3 startPos = new Vector3(128, 128, 30);
  121. UUID npcId = m_npcMod.CreateNPC("John", "Smith", startPos, UUID.Zero, true, m_scene, sp.Appearance);
  122. m_npcMod.DeleteNPC(npcId, m_scene);
  123. ScenePresence deletedNpc = m_scene.GetScenePresence(npcId);
  124. Assert.That(deletedNpc, Is.Null);
  125. IClientAPI client;
  126. Assert.That(m_scene.TryGetClient(npcId, out client), Is.False);
  127. // Have to account for SP still present.
  128. Assert.That(m_scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1));
  129. }
  130. [Test]
  131. public void TestCreateWithAttachments()
  132. {
  133. TestHelpers.InMethod();
  134. // TestHelpers.EnableLogging();
  135. SetUpScene();
  136. UUID userId = TestHelpers.ParseTail(0x1);
  137. UserAccountHelpers.CreateUserWithInventory(m_scene, userId);
  138. ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
  139. UUID attItemId = TestHelpers.ParseTail(0x2);
  140. UUID attAssetId = TestHelpers.ParseTail(0x3);
  141. string attName = "att";
  142. UserInventoryHelpers.CreateInventoryItem(m_scene, attName, attItemId, attAssetId, sp.UUID, InventoryType.Object);
  143. m_attMod.RezSingleAttachmentFromInventory(sp, attItemId, (uint)AttachmentPoint.Chest);
  144. UUID npcId = m_npcMod.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, sp.Appearance);
  145. ScenePresence npc = m_scene.GetScenePresence(npcId);
  146. // Check scene presence status
  147. Assert.That(npc.HasAttachments(), Is.True);
  148. List<SceneObjectGroup> attachments = npc.GetAttachments();
  149. Assert.That(attachments.Count, Is.EqualTo(1));
  150. SceneObjectGroup attSo = attachments[0];
  151. // Just for now, we won't test the name since this is (wrongly) the asset part name rather than the item
  152. // name. TODO: Do need to fix ultimately since the item may be renamed before being passed on to an NPC.
  153. // Assert.That(attSo.Name, Is.EqualTo(attName));
  154. Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
  155. Assert.That(attSo.IsAttachment);
  156. Assert.That(attSo.UsesPhysics, Is.False);
  157. Assert.That(attSo.IsTemporary, Is.False);
  158. Assert.That(attSo.OwnerID, Is.EqualTo(npc.UUID));
  159. }
  160. [Test]
  161. public void TestCreateWithMultiAttachments()
  162. {
  163. TestHelpers.InMethod();
  164. // TestHelpers.EnableLogging();
  165. SetUpScene();
  166. // m_attMod.DebugLevel = 1;
  167. UUID userId = TestHelpers.ParseTail(0x1);
  168. UserAccountHelpers.CreateUserWithInventory(m_scene, userId);
  169. ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
  170. InventoryItemBase att1Item
  171. = UserInventoryHelpers.CreateInventoryItem(
  172. m_scene, "att1", TestHelpers.ParseTail(0x2), TestHelpers.ParseTail(0x3), sp.UUID, InventoryType.Object);
  173. InventoryItemBase att2Item
  174. = UserInventoryHelpers.CreateInventoryItem(
  175. m_scene, "att2", TestHelpers.ParseTail(0x12), TestHelpers.ParseTail(0x13), sp.UUID, InventoryType.Object);
  176. m_attMod.RezSingleAttachmentFromInventory(sp, att1Item.ID, (uint)AttachmentPoint.Chest);
  177. m_attMod.RezSingleAttachmentFromInventory(sp, att2Item.ID, (uint)AttachmentPoint.Chest | 0x80);
  178. UUID npcId = m_npcMod.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, sp.Appearance);
  179. ScenePresence npc = m_scene.GetScenePresence(npcId);
  180. // Check scene presence status
  181. Assert.That(npc.HasAttachments(), Is.True);
  182. List<SceneObjectGroup> attachments = npc.GetAttachments();
  183. Assert.That(attachments.Count, Is.EqualTo(2));
  184. // Just for now, we won't test the name since this is (wrongly) the asset part name rather than the item
  185. // name. TODO: Do need to fix ultimately since the item may be renamed before being passed on to an NPC.
  186. // Assert.That(attSo.Name, Is.EqualTo(attName));
  187. TestAttachedObject(attachments[0], AttachmentPoint.Chest, npc.UUID);
  188. TestAttachedObject(attachments[1], AttachmentPoint.Chest, npc.UUID);
  189. // Attached objects on the same point must have different FromItemIDs to be shown to other avatars, at least
  190. // on Singularity 1.8.5. Otherwise, only one (the first ObjectUpdate sent) appears.
  191. Assert.AreNotEqual(attachments[0].FromItemID, attachments[1].FromItemID);
  192. }
  193. private void TestAttachedObject(SceneObjectGroup attSo, AttachmentPoint attPoint, UUID ownerId)
  194. {
  195. Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)attPoint));
  196. Assert.That(attSo.IsAttachment);
  197. Assert.That(attSo.UsesPhysics, Is.False);
  198. Assert.That(attSo.IsTemporary, Is.False);
  199. Assert.That(attSo.OwnerID, Is.EqualTo(ownerId));
  200. }
  201. [Test]
  202. public void TestLoadAppearance()
  203. {
  204. TestHelpers.InMethod();
  205. // log4net.Config.XmlConfigurator.Configure();
  206. SetUpScene();
  207. UUID userId = TestHelpers.ParseTail(0x1);
  208. UserAccountHelpers.CreateUserWithInventory(m_scene, userId);
  209. ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
  210. UUID npcId = m_npcMod.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, sp.Appearance);
  211. // Now add the attachment to the original avatar and use that to load a new appearance
  212. // TODO: Could also run tests loading from a notecard though this isn't much different for our purposes here
  213. UUID attItemId = TestHelpers.ParseTail(0x2);
  214. UUID attAssetId = TestHelpers.ParseTail(0x3);
  215. string attName = "att";
  216. UserInventoryHelpers.CreateInventoryItem(m_scene, attName, attItemId, attAssetId, sp.UUID, InventoryType.Object);
  217. m_attMod.RezSingleAttachmentFromInventory(sp, attItemId, (uint)AttachmentPoint.Chest);
  218. m_npcMod.SetNPCAppearance(npcId, sp.Appearance, m_scene);
  219. ScenePresence npc = m_scene.GetScenePresence(npcId);
  220. // Check scene presence status
  221. Assert.That(npc.HasAttachments(), Is.True);
  222. List<SceneObjectGroup> attachments = npc.GetAttachments();
  223. Assert.That(attachments.Count, Is.EqualTo(1));
  224. SceneObjectGroup attSo = attachments[0];
  225. // Just for now, we won't test the name since this is (wrongly) the asset part name rather than the item
  226. // name. TODO: Do need to fix ultimately since the item may be renamed before being passed on to an NPC.
  227. // Assert.That(attSo.Name, Is.EqualTo(attName));
  228. Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
  229. Assert.That(attSo.IsAttachment);
  230. Assert.That(attSo.UsesPhysics, Is.False);
  231. Assert.That(attSo.IsTemporary, Is.False);
  232. Assert.That(attSo.OwnerID, Is.EqualTo(npc.UUID));
  233. }
  234. [Test]
  235. public void TestMove()
  236. {
  237. TestHelpers.InMethod();
  238. // TestHelpers.EnableLogging();
  239. SetUpScene();
  240. ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1));
  241. // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
  242. Vector3 startPos = new Vector3(128, 128, 30);
  243. UUID npcId = m_npcMod.CreateNPC("John", "Smith", startPos, UUID.Zero, true, m_scene, sp.Appearance);
  244. ScenePresence npc = m_scene.GetScenePresence(npcId);
  245. Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
  246. // For now, we'll make the scene presence fly to simplify this test, but this needs to change.
  247. npc.Flying = true;
  248. m_scene.Update(1);
  249. Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
  250. Vector3 targetPos = startPos + new Vector3(0, 10, 0);
  251. m_npcMod.MoveToTarget(npc.UUID, m_scene, targetPos, false, false, false);
  252. Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
  253. //Assert.That(npc.Rotation, Is.EqualTo(new Quaternion(0, 0, 0.7071068f, 0.7071068f)));
  254. Assert.That(
  255. npc.Rotation, new QuaternionToleranceConstraint(new Quaternion(0, 0, 0.7071068f, 0.7071068f), 0.000001));
  256. m_scene.Update(1);
  257. // We should really check the exact figure.
  258. Assert.That(npc.AbsolutePosition.X, Is.EqualTo(startPos.X));
  259. Assert.That(npc.AbsolutePosition.Y, Is.GreaterThan(startPos.Y));
  260. Assert.That(npc.AbsolutePosition.Z, Is.EqualTo(startPos.Z));
  261. Assert.That(npc.AbsolutePosition.Z, Is.LessThan(targetPos.X));
  262. m_scene.Update(10);
  263. double distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos);
  264. Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on first move");
  265. Assert.That(npc.AbsolutePosition, Is.EqualTo(targetPos));
  266. Assert.That(npc.AgentControlFlags, Is.EqualTo((uint)AgentManager.ControlFlags.NONE));
  267. // Try a second movement
  268. startPos = npc.AbsolutePosition;
  269. targetPos = startPos + new Vector3(10, 0, 0);
  270. m_npcMod.MoveToTarget(npc.UUID, m_scene, targetPos, false, false, false);
  271. Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
  272. // Assert.That(npc.Rotation, Is.EqualTo(new Quaternion(0, 0, 0, 1)));
  273. Assert.That(
  274. npc.Rotation, new QuaternionToleranceConstraint(new Quaternion(0, 0, 0, 1), 0.000001));
  275. m_scene.Update(1);
  276. // We should really check the exact figure.
  277. Assert.That(npc.AbsolutePosition.X, Is.GreaterThan(startPos.X));
  278. Assert.That(npc.AbsolutePosition.X, Is.LessThan(targetPos.X));
  279. Assert.That(npc.AbsolutePosition.Y, Is.EqualTo(startPos.Y));
  280. Assert.That(npc.AbsolutePosition.Z, Is.EqualTo(startPos.Z));
  281. m_scene.Update(10);
  282. distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos);
  283. Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on second move");
  284. Assert.That(npc.AbsolutePosition, Is.EqualTo(targetPos));
  285. }
  286. [Test]
  287. public void TestMoveInVarRegion()
  288. {
  289. TestHelpers.InMethod();
  290. // TestHelpers.EnableLogging();
  291. SetUpScene(512, 512);
  292. ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1));
  293. // ScenePresence originalAvatar = scene.GetScenePresence(originalClient.AgentId);
  294. Vector3 startPos = new Vector3(128, 246, 30);
  295. UUID npcId = m_npcMod.CreateNPC("John", "Smith", startPos, UUID.Zero, true, m_scene, sp.Appearance);
  296. ScenePresence npc = m_scene.GetScenePresence(npcId);
  297. Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
  298. // For now, we'll make the scene presence fly to simplify this test, but this needs to change.
  299. npc.Flying = true;
  300. m_scene.Update(1);
  301. Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
  302. Vector3 targetPos = startPos + new Vector3(0, 20, 0);
  303. m_npcMod.MoveToTarget(npc.UUID, m_scene, targetPos, false, false, false);
  304. Assert.That(npc.AbsolutePosition, Is.EqualTo(startPos));
  305. //Assert.That(npc.Rotation, Is.EqualTo(new Quaternion(0, 0, 0.7071068f, 0.7071068f)));
  306. Assert.That(
  307. npc.Rotation, new QuaternionToleranceConstraint(new Quaternion(0, 0, 0.7071068f, 0.7071068f), 0.000001));
  308. m_scene.Update(1);
  309. // We should really check the exact figure.
  310. Assert.That(npc.AbsolutePosition.X, Is.EqualTo(startPos.X));
  311. Assert.That(npc.AbsolutePosition.Y, Is.GreaterThan(startPos.Y));
  312. Assert.That(npc.AbsolutePosition.Z, Is.EqualTo(startPos.Z));
  313. Assert.That(npc.AbsolutePosition.Z, Is.LessThan(targetPos.X));
  314. for (int i = 0; i < 20; i++)
  315. {
  316. m_scene.Update(1);
  317. // Console.WriteLine("pos: {0}", npc.AbsolutePosition);
  318. }
  319. double distanceToTarget = Util.GetDistanceTo(npc.AbsolutePosition, targetPos);
  320. Assert.That(distanceToTarget, Is.LessThan(1), "NPC not within 1 unit of target position on first move");
  321. Assert.That(npc.AbsolutePosition, Is.EqualTo(targetPos));
  322. Assert.That(npc.AgentControlFlags, Is.EqualTo((uint)AgentManager.ControlFlags.NONE));
  323. }
  324. [Test]
  325. public void TestSitAndStandWithSitTarget()
  326. {
  327. TestHelpers.InMethod();
  328. // log4net.Config.XmlConfigurator.Configure();
  329. SetUpScene();
  330. ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1));
  331. Vector3 startPos = new Vector3(128, 128, 30);
  332. UUID npcId = m_npcMod.CreateNPC("John", "Smith", startPos, UUID.Zero, true, m_scene, sp.Appearance);
  333. ScenePresence npc = m_scene.GetScenePresence(npcId);
  334. SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart;
  335. part.SitTargetPosition = new Vector3(0, 0, 1);
  336. m_npcMod.Sit(npc.UUID, part.UUID, m_scene);
  337. Assert.That(part.SitTargetAvatar, Is.EqualTo(npcId));
  338. Assert.That(npc.ParentID, Is.EqualTo(part.LocalId));
  339. // Assert.That(
  340. // npc.AbsolutePosition,
  341. // Is.EqualTo(part.AbsolutePosition + part.SitTargetPosition + ScenePresence.SIT_TARGET_ADJUSTMENT));
  342. m_npcMod.Stand(npc.UUID, m_scene);
  343. Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
  344. Assert.That(npc.ParentID, Is.EqualTo(0));
  345. }
  346. [Test]
  347. public void TestSitAndStandWithNoSitTarget()
  348. {
  349. TestHelpers.InMethod();
  350. // TestHelpers.EnableLogging();
  351. SetUpScene();
  352. ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, TestHelpers.ParseTail(0x1));
  353. // FIXME: To get this to work for now, we are going to place the npc right next to the target so that
  354. // the autopilot doesn't trigger
  355. Vector3 startPos = new Vector3(1, 1, 1);
  356. UUID npcId = m_npcMod.CreateNPC("John", "Smith", startPos, UUID.Zero, true, m_scene, sp.Appearance);
  357. ScenePresence npc = m_scene.GetScenePresence(npcId);
  358. SceneObjectPart part = SceneHelpers.AddSceneObject(m_scene).RootPart;
  359. m_npcMod.Sit(npc.UUID, part.UUID, m_scene);
  360. Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
  361. Assert.That(npc.ParentID, Is.EqualTo(part.LocalId));
  362. // We should really be using the NPC size but this would mean preserving the physics actor since it is
  363. // removed on sit.
  364. Assert.That(
  365. npc.AbsolutePosition,
  366. Is.EqualTo(part.AbsolutePosition + new Vector3(0, 0, sp.PhysicsActor.Size.Z / 2)));
  367. m_npcMod.Stand(npc.UUID, m_scene);
  368. Assert.That(part.SitTargetAvatar, Is.EqualTo(UUID.Zero));
  369. Assert.That(npc.ParentID, Is.EqualTo(0));
  370. }
  371. }
  372. }