public void TestRezAttachmentFromInventory()
        {
            TestHelpers.InMethod();
            //            log4net.Config.XmlConfigurator.Configure();

            Scene         scene = CreateTestScene();
            UserAccount   ua1   = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
            ScenePresence sp    = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID);

            InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20);

            {
                scene.AttachmentsModule.RezSingleAttachmentFromInventory(
                    sp, attItem.ID, (uint)AttachmentPoint.Chest);

                // Check scene presence status
                Assert.That(sp.HasAttachments(), Is.True);
                List <SceneObjectGroup> attachments = sp.GetAttachments();
                Assert.That(attachments.Count, Is.EqualTo(1));
                SceneObjectGroup attSo = attachments[0];
                Assert.That(attSo.Name, Is.EqualTo(attItem.Name));
                Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
                Assert.That(attSo.IsAttachment);
                Assert.That(attSo.UsesPhysics, Is.False);
                Assert.That(attSo.IsTemporary, Is.False);

                // Check appearance status
                Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1));
                Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));
                Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));

                // Check events
                Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1));
            }

            // Test attaching an already attached attachment
            {
                scene.AttachmentsModule.RezSingleAttachmentFromInventory(
                    sp, attItem.ID, (uint)AttachmentPoint.Chest);

                // Check scene presence status
                Assert.That(sp.HasAttachments(), Is.True);
                List <SceneObjectGroup> attachments = sp.GetAttachments();
                Assert.That(attachments.Count, Is.EqualTo(1));
                SceneObjectGroup attSo = attachments[0];
                Assert.That(attSo.Name, Is.EqualTo(attItem.Name));
                Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
                Assert.That(attSo.IsAttachment);
                Assert.That(attSo.UsesPhysics, Is.False);
                Assert.That(attSo.IsTemporary, Is.False);

                // Check appearance status
                Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1));
                Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));
                Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));

                // Check events
                Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1));
            }
        }
        public void TestAddAttachmentFromGround()
        {
            TestHelpers.InMethod();
//            log4net.Config.XmlConfigurator.Configure();

            AddPresence();
            string attName = "att";

            SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName).ParentGroup;

            m_attMod.AttachObject(m_presence, so, (uint)AttachmentPoint.Chest, false);

            // Check status on scene presence
            Assert.That(m_presence.HasAttachments(), Is.True);
            List <SceneObjectGroup> attachments = m_presence.GetAttachments();

            Assert.That(attachments.Count, Is.EqualTo(1));
            SceneObjectGroup attSo = attachments[0];

            Assert.That(attSo.Name, Is.EqualTo(attName));
            Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
            Assert.That(attSo.IsAttachment);
            Assert.That(attSo.UsesPhysics, Is.False);
            Assert.That(attSo.IsTemporary, Is.False);

            // Check item status
            Assert.That(m_presence.Appearance.GetAttachpoint(
                            attSo.GetFromItemID()), Is.EqualTo((int)AttachmentPoint.Chest));
        }
Пример #3
0
        public void TestAddSatOnAttachmentFromGround()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            m_numberOfAttachEventsFired = 0;

            Scene         scene = CreateTestScene();
            UserAccount   ua1   = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
            ScenePresence sp    = SceneHelpers.AddScenePresence(scene, ua1);

            string attName = "att";

            SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID);

            UserAccount   ua2 = UserAccountHelpers.CreateUserWithInventory(scene, 0x2);
            ScenePresence sp2 = SceneHelpers.AddScenePresence(scene, ua2);

            // Put avatar within 10m of the prim so that sit doesn't fail.
            sp2.AbsolutePosition = new Vector3(0, 0, 0);
            sp2.HandleAgentRequestSit(sp2.ControllingClient, sp2.UUID, so.UUID, Vector3.Zero);

            scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, false);

            Assert.That(sp.HasAttachments(), Is.False);
            Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));

            // Check events
            Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0));
        }
Пример #4
0
        public void TestDetachAttachmentToInventory()
        {
            TestHelpers.InMethod();

            Scene         scene = CreateTestScene();
            UserAccount   ua1   = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
            ScenePresence sp    = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID);

            InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20);

            SceneObjectGroup so
                = (SceneObjectGroup)scene.AttachmentsModule.RezSingleAttachmentFromInventory(
                      sp, attItem.ID, (uint)AttachmentPoint.Chest);

            m_numberOfAttachEventsFired = 0;
            scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, so);

            // Check status on scene presence
            Assert.That(sp.HasAttachments(), Is.False);
            List <SceneObjectGroup> attachments = sp.GetAttachments();

            Assert.That(attachments.Count, Is.EqualTo(0));

            // Check item status
            Assert.That(sp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo(0));

            Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(0));

            // Check events
            Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1));
        }
Пример #5
0
        public void TestOsForceAttachToOtherAvatarFromInventory()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            string          taskInvObjItemName = "sphere";
            UUID            taskInvObjItemId   = UUID.Parse("00000000-0000-0000-0000-100000000000");
            AttachmentPoint attachPoint        = AttachmentPoint.Chin;

            UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(m_scene, "user", "one", 0x1, "pass");
            UserAccount ua2 = UserAccountHelpers.CreateUserWithInventory(m_scene, "user", "two", 0x2, "pass");

            ScenePresence     sp         = SceneHelpers.AddScenePresence(m_scene, ua1);
            SceneObjectGroup  inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID);
            TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene, inWorldObj.RootPart);

            new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem, null);
            OSSL_Api osslApi = new OSSL_Api();

            osslApi.Initialize(m_engine, inWorldObj.RootPart, scriptItem, null);

            // Create an object embedded inside the first
            TaskInventoryHelpers.AddSceneObject(
                m_scene, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, ua1.PrincipalID);

            ScenePresence sp2 = SceneHelpers.AddScenePresence(m_scene, ua2);

            osslApi.osForceAttachToOtherAvatarFromInventory(sp2.UUID.ToString(), taskInvObjItemName, (int)attachPoint);

            // Check scene presence status
            Assert.That(sp.HasAttachments(), Is.False);
            List <SceneObjectGroup> attachments = sp.GetAttachments();

            Assert.That(attachments.Count, Is.EqualTo(0));

            Assert.That(sp2.HasAttachments(), Is.True);
            List <SceneObjectGroup> attachments2 = sp2.GetAttachments();

            Assert.That(attachments2.Count, Is.EqualTo(1));
            SceneObjectGroup attSo = attachments2[0];

            Assert.That(attSo.Name, Is.EqualTo(taskInvObjItemName));
            Assert.That(attSo.OwnerID, Is.EqualTo(ua2.PrincipalID));
            Assert.That(attSo.AttachmentPoint, Is.EqualTo((uint)attachPoint));
            Assert.That(attSo.IsAttachment);
            Assert.That(attSo.UsesPhysics, Is.False);
            Assert.That(attSo.IsTemporary, Is.False);

            // Check appearance status
            List <AvatarAttachment> attachmentsInAppearance = sp.Appearance.GetAttachments();

            Assert.That(attachmentsInAppearance.Count, Is.EqualTo(0));

            List <AvatarAttachment> attachmentsInAppearance2 = sp2.Appearance.GetAttachments();

            Assert.That(attachmentsInAppearance2.Count, Is.EqualTo(1));
            Assert.That(sp2.Appearance.GetAttachpoint(attachmentsInAppearance2[0].ItemID), Is.EqualTo((uint)attachPoint));
        }
Пример #6
0
        public void T031_RemoveAttachments()
        {
            TestHelper.InMethod();

            ScenePresence presence = scene.GetScenePresence(agent1);

            presence.RemoveAttachment(sog1);
            presence.RemoveAttachment(sog2);
            presence.RemoveAttachment(sog3);
            Assert.That(presence.HasAttachments(), Is.False);
        }
        public void TestAddAttachmentFromGround()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            m_numberOfAttachEventsFired = 0;

            Scene         scene = CreateTestScene();
            UserAccount   ua1   = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
            ScenePresence sp    = SceneHelpers.AddScenePresence(scene, ua1);

            string attName = "att";

            SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, attName, sp.UUID);

            Assert.That(so.Backup, Is.True);

            m_numberOfAttachEventsFired = 0;
            scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Chest, false, true, false);

            // Check status on scene presence
            Assert.That(sp.HasAttachments(), Is.True);
            List <SceneObjectGroup> attachments = sp.GetAttachments();

            Assert.That(attachments.Count, Is.EqualTo(1));
            SceneObjectGroup attSo = attachments[0];

            Assert.That(attSo.Name, Is.EqualTo(attName));
            Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
            Assert.That(attSo.IsAttachment);
            Assert.That(attSo.UsesPhysics, Is.False);
            Assert.That(attSo.IsTemporary, Is.False);
            Assert.That(attSo.Backup, Is.False);

            // Check item status
            Assert.That(
                sp.Appearance.GetAttachpoint(attSo.FromItemID),
                Is.EqualTo((int)AttachmentPoint.Chest));

            InventoryItemBase attachmentItem = scene.InventoryService.GetItem(new InventoryItemBase(attSo.FromItemID));

            Assert.That(attachmentItem, Is.Not.Null);
            Assert.That(attachmentItem.Name, Is.EqualTo(attName));

            InventoryFolderBase targetFolder = scene.InventoryService.GetFolderForType(sp.UUID, AssetType.Object);

            Assert.That(attachmentItem.Folder, Is.EqualTo(targetFolder.ID));

            Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));

            // Check events
            Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1));
        }
Пример #8
0
        // I'm commenting this test because scene setup NEEDS InventoryService to
        // be non-null
        //[Test]
        public void T032_CrossAttachments()
        {
            TestHelper.InMethod();

            ScenePresence presence  = scene.GetScenePresence(agent1);
            ScenePresence presence2 = scene2.GetScenePresence(agent1);

            presence2.AddAttachment(sog1);
            presence2.AddAttachment(sog2);

            ISharedRegionModule serialiser = new SerialiserModule();

            SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), serialiser);
            SceneSetupHelpers.SetupSceneModules(scene2, new IniConfigSource(), serialiser);

            Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross");

            //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful");
            Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted");
            Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects");
        }
Пример #9
0
        public void T030_TestAddAttachments()
        {
            TestHelper.InMethod();

            ScenePresence presence = scene.GetScenePresence(agent1);

            presence.AddAttachment(sog1);
            presence.AddAttachment(sog2);
            presence.AddAttachment(sog3);

            Assert.That(presence.HasAttachments(), Is.True);
            Assert.That(presence.ValidateAttachments(), Is.True);
        }
Пример #10
0
        public void TestOsForceAttachToAvatarFromInventoryNotObject()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            string          taskInvObjItemName = "sphere";
            UUID            taskInvObjItemId   = UUID.Parse("00000000-0000-0000-0000-100000000000");
            AttachmentPoint attachPoint        = AttachmentPoint.Chin;

            UserAccount       ua1        = UserAccountHelpers.CreateUserWithInventory(m_scene, 0x1);
            ScenePresence     sp         = SceneHelpers.AddScenePresence(m_scene, ua1.PrincipalID);
            SceneObjectGroup  inWorldObj = SceneHelpers.AddSceneObject(m_scene, "inWorldObj", ua1.PrincipalID);
            TaskInventoryItem scriptItem = TaskInventoryHelpers.AddScript(m_scene, inWorldObj.RootPart);

            new LSL_Api().Initialize(m_engine, inWorldObj.RootPart, scriptItem, null);
            OSSL_Api osslApi = new OSSL_Api();

            osslApi.Initialize(m_engine, inWorldObj.RootPart, scriptItem, null);

            // Create an object embedded inside the first
            TaskInventoryHelpers.AddNotecard(
                m_scene, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, TestHelpers.ParseTail(0x900), "Hello World!");

            bool exceptionCaught = false;

            try
            {
                osslApi.osForceAttachToAvatarFromInventory(taskInvObjItemName, (int)attachPoint);
            }
            catch (Exception)
            {
                exceptionCaught = true;
            }

            Assert.That(exceptionCaught, Is.True);

            // Check scene presence status
            Assert.That(sp.HasAttachments(), Is.False);
            List <SceneObjectGroup> attachments = sp.GetAttachments();

            Assert.That(attachments.Count, Is.EqualTo(0));

            // Check appearance status
            List <AvatarAttachment> attachmentsInAppearance = sp.Appearance.GetAttachments();

            Assert.That(attachmentsInAppearance.Count, Is.EqualTo(0));
        }
Пример #11
0
        public void TestLoadAppearance()
        {
            TestHelpers.InMethod();
//            log4net.Config.XmlConfigurator.Configure();

            SetUpScene();

            UUID userId = TestHelpers.ParseTail(0x1);

            UserAccountHelpers.CreateUserWithInventory(m_scene, userId);
            ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);

            UUID npcId = m_npcMod.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, sp.Appearance);

            // Now add the attachment to the original avatar and use that to load a new appearance
            // TODO: Could also run tests loading from a notecard though this isn't much different for our purposes here
            UUID   attItemId  = TestHelpers.ParseTail(0x2);
            UUID   attAssetId = TestHelpers.ParseTail(0x3);
            string attName    = "att";

            UserInventoryHelpers.CreateInventoryItem(m_scene, attName, attItemId, attAssetId, sp.UUID, InventoryType.Object);

            m_attMod.RezSingleAttachmentFromInventory(sp, attItemId, (uint)AttachmentPoint.Chest);

            m_npcMod.SetNPCAppearance(npcId, sp.Appearance, m_scene);

            ScenePresence npc = m_scene.GetScenePresence(npcId);

            // Check scene presence status
            Assert.That(npc.HasAttachments(), Is.True);
            List <SceneObjectGroup> attachments = npc.GetAttachments();

            Assert.That(attachments.Count, Is.EqualTo(1));
            SceneObjectGroup attSo = attachments[0];

            // Just for now, we won't test the name since this is (wrongly) the asset part name rather than the item
            // name.  TODO: Do need to fix ultimately since the item may be renamed before being passed on to an NPC.
//            Assert.That(attSo.Name, Is.EqualTo(attName));

            Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
            Assert.That(attSo.IsAttachment);
            Assert.That(attSo.UsesPhysics, Is.False);
            Assert.That(attSo.IsTemporary, Is.False);
            Assert.That(attSo.OwnerID, Is.EqualTo(npc.UUID));
        }
Пример #12
0
        public void TestRezAttachmentsOnAvatarEntrance()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            Scene             scene   = CreateTestScene();
            UserAccount       ua1     = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
            InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20);

            AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID);

            acd.Appearance = new AvatarAppearance();
            acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID);

            m_numberOfAttachEventsFired = 0;
            ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd);

            Assert.That(presence.HasAttachments(), Is.True);
            List <SceneObjectGroup> attachments = presence.GetAttachments();

            Assert.That(attachments.Count, Is.EqualTo(1));
            SceneObjectGroup attSo = attachments[0];

            Assert.That(attSo.Name, Is.EqualTo(attItem.Name));
            Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
            Assert.That(attSo.IsAttachment);
            Assert.That(attSo.UsesPhysics, Is.False);
            Assert.That(attSo.IsTemporary, Is.False);
            Assert.IsFalse(attSo.Backup);

            // Check appearance status
            List <AvatarAttachment> retreivedAttachments = presence.Appearance.GetAttachments();

            Assert.That(retreivedAttachments.Count, Is.EqualTo(1));
            Assert.That(retreivedAttachments[0].AttachPoint, Is.EqualTo((int)AttachmentPoint.Chest));
            Assert.That(retreivedAttachments[0].ItemID, Is.EqualTo(attItem.ID));
            Assert.That(retreivedAttachments[0].AssetID, Is.EqualTo(attItem.AssetID));
            Assert.That(presence.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest));

            Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));

            // Check events.  We expect OnAttach to fire on login.
            Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1));
        }
Пример #13
0
        public void TestCreateWithMultiAttachments()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            SetUpScene();
//            m_attMod.DebugLevel = 1;

            UUID userId = TestHelpers.ParseTail(0x1);

            UserAccountHelpers.CreateUserWithInventory(m_scene, userId);
            ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);

            InventoryItemBase att1Item
                = UserInventoryHelpers.CreateInventoryItem(
                      m_scene, "att1", TestHelpers.ParseTail(0x2), TestHelpers.ParseTail(0x3), sp.UUID, InventoryType.Object);
            InventoryItemBase att2Item
                = UserInventoryHelpers.CreateInventoryItem(
                      m_scene, "att2", TestHelpers.ParseTail(0x12), TestHelpers.ParseTail(0x13), sp.UUID, InventoryType.Object);

            m_attMod.RezSingleAttachmentFromInventory(sp, att1Item.ID, (uint)AttachmentPoint.Chest);
            m_attMod.RezSingleAttachmentFromInventory(sp, att2Item.ID, (uint)AttachmentPoint.Chest | 0x80);

            UUID npcId = m_npcMod.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, sp.Appearance);

            ScenePresence npc = m_scene.GetScenePresence(npcId);

            // Check scene presence status
            Assert.That(npc.HasAttachments(), Is.True);
            List <SceneObjectGroup> attachments = npc.GetAttachments();

            Assert.That(attachments.Count, Is.EqualTo(2));

            // Just for now, we won't test the name since this is (wrongly) the asset part name rather than the item
            // name.  TODO: Do need to fix ultimately since the item may be renamed before being passed on to an NPC.
//            Assert.That(attSo.Name, Is.EqualTo(attName));

            TestAttachedObject(attachments[0], AttachmentPoint.Chest, npc.UUID);
            TestAttachedObject(attachments[1], AttachmentPoint.Chest, npc.UUID);

            // Attached objects on the same point must have different FromItemIDs to be shown to other avatars, at least
            // on Singularity 1.8.5.  Otherwise, only one (the first ObjectUpdate sent) appears.
            Assert.AreNotEqual(attachments[0].FromItemID, attachments[1].FromItemID);
        }
        public void TestRezAttachmentsOnAvatarEntrance()
        {
            TestHelpers.InMethod();
//            log4net.Config.XmlConfigurator.Configure();

            UUID   userId     = TestHelpers.ParseTail(0x1);
            UUID   attItemId  = TestHelpers.ParseTail(0x2);
            UUID   attAssetId = TestHelpers.ParseTail(0x3);
            string attName    = "att";

            UserAccountHelpers.CreateUserWithInventory(scene, userId);
            InventoryItemBase attItem
                = UserInventoryHelpers.CreateInventoryItem(
                      scene, attName, attItemId, attAssetId, userId, InventoryType.Object);

            AgentCircuitData acd = SceneHelpers.GenerateAgentData(userId);

            acd.Appearance = new AvatarAppearance();
            acd.Appearance.SetAttachment((int)AttachmentPoint.Chest, attItem.ID, attItem.AssetID);
            ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd);

            Assert.That(presence.HasAttachments(), Is.True);
            List <SceneObjectGroup> attachments = presence.GetAttachments();

            Assert.That(attachments.Count, Is.EqualTo(1));
            SceneObjectGroup attSo = attachments[0];

            Assert.That(attSo.Name, Is.EqualTo(attName));
            Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
            Assert.That(attSo.IsAttachment);
            Assert.That(attSo.UsesPhysics, Is.False);
            Assert.That(attSo.IsTemporary, Is.False);

            // Check appearance status
            List <AvatarAttachment> retreivedAttachments = presence.Appearance.GetAttachments();

            Assert.That(retreivedAttachments.Count, Is.EqualTo(1));
            Assert.That(retreivedAttachments[0].AttachPoint, Is.EqualTo((int)AttachmentPoint.Chest));
            Assert.That(retreivedAttachments[0].ItemID, Is.EqualTo(attItemId));
            Assert.That(retreivedAttachments[0].AssetID, Is.EqualTo(attAssetId));
            Assert.That(presence.Appearance.GetAttachpoint(attItemId), Is.EqualTo((int)AttachmentPoint.Chest));
        }
Пример #15
0
        public void TestAttachments()
        {
            TestHelpers.InMethod();
//            log4net.Config.XmlConfigurator.Configure();

            UUID userId = TestHelpers.ParseTail(0x1);

            UserAccountHelpers.CreateUserWithInventory(scene, userId);
            ScenePresence sp = SceneHelpers.AddScenePresence(scene, userId);

            UUID   attItemId  = TestHelpers.ParseTail(0x2);
            UUID   attAssetId = TestHelpers.ParseTail(0x3);
            string attName    = "att";

            UserInventoryHelpers.CreateInventoryItem(scene, attName, attItemId, attAssetId, sp.UUID, InventoryType.Object);

            am.RezSingleAttachmentFromInventory(sp, attItemId, (uint)AttachmentPoint.Chest);

            INPCModule npcModule = scene.RequestModuleInterface <INPCModule>();
            UUID       npcId     = npcModule.CreateNPC("John", "Smith", new Vector3(128, 128, 30), scene, sp.Appearance);

            ScenePresence npc = scene.GetScenePresence(npcId);

            // Check scene presence status
            Assert.That(npc.HasAttachments(), Is.True);
            List <SceneObjectGroup> attachments = npc.GetAttachments();

            Assert.That(attachments.Count, Is.EqualTo(1));
            SceneObjectGroup attSo = attachments[0];

            // Just for now, we won't test the name since this is (wrongly) the asset part name rather than the item
            // name.  TODO: Do need to fix ultimately since the item may be renamed before being passed on to an NPC.
//            Assert.That(attSo.Name, Is.EqualTo(attName));

            Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.Chest));
            Assert.That(attSo.IsAttachment);
            Assert.That(attSo.UsesPhysics, Is.False);
            Assert.That(attSo.IsTemporary, Is.False);
            Assert.That(attSo.OwnerID, Is.EqualTo(npc.UUID));
        }
Пример #16
0
        public void TestDetachAttachmentToGround()
        {
            TestHelpers.InMethod();
//            log4net.Config.XmlConfigurator.Configure();

            Scene         scene = CreateTestScene();
            UserAccount   ua1   = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
            ScenePresence sp    = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID);

            InventoryItemBase attItem = CreateAttachmentItem(scene, ua1.PrincipalID, "att", 0x10, 0x20);

            ISceneEntity so
                = scene.AttachmentsModule.RezSingleAttachmentFromInventory(
                      sp, attItem.ID, (uint)AttachmentPoint.Chest);

            m_numberOfAttachEventsFired = 0;
            scene.AttachmentsModule.DetachSingleAttachmentToGround(sp, so.LocalId);

            // Check scene presence status
            Assert.That(sp.HasAttachments(), Is.False);
            List <SceneObjectGroup> attachments = sp.GetAttachments();

            Assert.That(attachments.Count, Is.EqualTo(0));

            // Check appearance status
            Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(0));

            // Check item status
            Assert.That(scene.InventoryService.GetItem(new InventoryItemBase(attItem.ID)), Is.Null);

            // Check object in scene
            SceneObjectGroup soInScene = scene.GetSceneObjectGroup("att");

            Assert.That(soInScene, Is.Not.Null);
            Assert.IsTrue(soInScene.Backup);

            // Check events
            Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1));
        }
Пример #17
0
        public void TestWearAttachmentFromGround()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            Scene         scene = CreateTestScene();
            UserAccount   ua1   = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
            ScenePresence sp    = SceneHelpers.AddScenePresence(scene, ua1);

            SceneObjectGroup so2 = SceneHelpers.AddSceneObject(scene, "att2", sp.UUID);

            {
                SceneObjectGroup so = SceneHelpers.AddSceneObject(scene, "att1", sp.UUID);

                m_numberOfAttachEventsFired = 0;
                scene.AttachmentsModule.AttachObject(sp, so, (uint)AttachmentPoint.Default, false, true, false);

                // Check status on scene presence
                Assert.That(sp.HasAttachments(), Is.True);
                List <SceneObjectGroup> attachments = sp.GetAttachments();
                Assert.That(attachments.Count, Is.EqualTo(1));
                SceneObjectGroup attSo = attachments[0];
                Assert.That(attSo.Name, Is.EqualTo(so.Name));
                Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand));
                Assert.That(attSo.IsAttachment);
                Assert.That(attSo.UsesPhysics, Is.False);
                Assert.That(attSo.IsTemporary, Is.False);

                // Check item status
                Assert.That(
                    sp.Appearance.GetAttachpoint(attSo.FromItemID),
                    Is.EqualTo((int)AttachmentPoint.LeftHand));

                InventoryItemBase attachmentItem = scene.InventoryService.GetItem(new InventoryItemBase(attSo.FromItemID));
                Assert.That(attachmentItem, Is.Not.Null);
                Assert.That(attachmentItem.Name, Is.EqualTo(so.Name));

                InventoryFolderBase targetFolder = scene.InventoryService.GetFolderForType(sp.UUID, AssetType.Object);
                Assert.That(attachmentItem.Folder, Is.EqualTo(targetFolder.ID));

                Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(2));

                // Check events
                Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1));
            }

            // Test wearing a different attachment from the ground.
            {
                scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, true, false);

                // Check status on scene presence
                Assert.That(sp.HasAttachments(), Is.True);
                List <SceneObjectGroup> attachments = sp.GetAttachments();
                Assert.That(attachments.Count, Is.EqualTo(1));
                SceneObjectGroup attSo = attachments[0];
                Assert.That(attSo.Name, Is.EqualTo(so2.Name));
                Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand));
                Assert.That(attSo.IsAttachment);
                Assert.That(attSo.UsesPhysics, Is.False);
                Assert.That(attSo.IsTemporary, Is.False);

                // Check item status
                Assert.That(
                    sp.Appearance.GetAttachpoint(attSo.FromItemID),
                    Is.EqualTo((int)AttachmentPoint.LeftHand));

                InventoryItemBase attachmentItem = scene.InventoryService.GetItem(new InventoryItemBase(attSo.FromItemID));
                Assert.That(attachmentItem, Is.Not.Null);
                Assert.That(attachmentItem.Name, Is.EqualTo(so2.Name));

                InventoryFolderBase targetFolder = scene.InventoryService.GetFolderForType(sp.UUID, AssetType.Object);
                Assert.That(attachmentItem.Folder, Is.EqualTo(targetFolder.ID));

                Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));

                // Check events
                Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(3));
            }

            // Test rewearing an already worn attachment from ground.  Nothing should happen.
            {
                scene.AttachmentsModule.AttachObject(sp, so2, (uint)AttachmentPoint.Default, false, true, false);

                // Check status on scene presence
                Assert.That(sp.HasAttachments(), Is.True);
                List <SceneObjectGroup> attachments = sp.GetAttachments();
                Assert.That(attachments.Count, Is.EqualTo(1));
                SceneObjectGroup attSo = attachments[0];
                Assert.That(attSo.Name, Is.EqualTo(so2.Name));
                Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand));
                Assert.That(attSo.IsAttachment);
                Assert.That(attSo.UsesPhysics, Is.False);
                Assert.That(attSo.IsTemporary, Is.False);

                // Check item status
                Assert.That(
                    sp.Appearance.GetAttachpoint(attSo.FromItemID),
                    Is.EqualTo((int)AttachmentPoint.LeftHand));

                InventoryItemBase attachmentItem = scene.InventoryService.GetItem(new InventoryItemBase(attSo.FromItemID));
                Assert.That(attachmentItem, Is.Not.Null);
                Assert.That(attachmentItem.Name, Is.EqualTo(so2.Name));

                InventoryFolderBase targetFolder = scene.InventoryService.GetFolderForType(sp.UUID, AssetType.Object);
                Assert.That(attachmentItem.Folder, Is.EqualTo(targetFolder.ID));

                Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));

                // Check events
                Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(3));
            }
        }
Пример #18
0
        public void TestWearAttachmentFromInventory()
        {
            TestHelpers.InMethod();
//            TestHelpers.EnableLogging();

            Scene         scene = CreateTestScene();
            UserAccount   ua1   = UserAccountHelpers.CreateUserWithInventory(scene, 0x1);
            ScenePresence sp    = SceneHelpers.AddScenePresence(scene, ua1.PrincipalID);

            InventoryItemBase attItem1 = CreateAttachmentItem(scene, ua1.PrincipalID, "att1", 0x10, 0x20);
            InventoryItemBase attItem2 = CreateAttachmentItem(scene, ua1.PrincipalID, "att2", 0x11, 0x21);

            {
                m_numberOfAttachEventsFired = 0;
                scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, attItem1.ID, (uint)AttachmentPoint.Default);

                // default attachment point is currently the left hand.
                Assert.That(sp.HasAttachments(), Is.True);
                List <SceneObjectGroup> attachments = sp.GetAttachments();
                Assert.That(attachments.Count, Is.EqualTo(1));
                SceneObjectGroup attSo = attachments[0];
                Assert.That(attSo.Name, Is.EqualTo(attItem1.Name));
                Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand));
                Assert.That(attSo.IsAttachment);

                // Check appearance status
                Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1));
                Assert.That(sp.Appearance.GetAttachpoint(attItem1.ID), Is.EqualTo((int)AttachmentPoint.LeftHand));
                Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));

                // Check events
                Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(1));
            }

            // Test wearing a second attachment at the same position
            // Until multiple attachments at one point is implemented, this will remove the first attachment
            // This test relies on both attachments having the same default attachment point (in this case LeftHand
            // since none other has been set).
            {
                scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, attItem2.ID, (uint)AttachmentPoint.Default);

                // default attachment point is currently the left hand.
                Assert.That(sp.HasAttachments(), Is.True);
                List <SceneObjectGroup> attachments = sp.GetAttachments();
                Assert.That(attachments.Count, Is.EqualTo(1));
                SceneObjectGroup attSo = attachments[0];
                Assert.That(attSo.Name, Is.EqualTo(attItem2.Name));
                Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand));
                Assert.That(attSo.IsAttachment);

                // Check appearance status
                Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1));
                Assert.That(sp.Appearance.GetAttachpoint(attItem2.ID), Is.EqualTo((int)AttachmentPoint.LeftHand));
                Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));

                // Check events
                Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(3));
            }

            // Test wearing an already attached attachment
            {
                scene.AttachmentsModule.RezSingleAttachmentFromInventory(sp, attItem2.ID, (uint)AttachmentPoint.Default);

                // default attachment point is currently the left hand.
                Assert.That(sp.HasAttachments(), Is.True);
                List <SceneObjectGroup> attachments = sp.GetAttachments();
                Assert.That(attachments.Count, Is.EqualTo(1));
                SceneObjectGroup attSo = attachments[0];
                Assert.That(attSo.Name, Is.EqualTo(attItem2.Name));
                Assert.That(attSo.AttachmentPoint, Is.EqualTo((byte)AttachmentPoint.LeftHand));
                Assert.That(attSo.IsAttachment);

                // Check appearance status
                Assert.That(sp.Appearance.GetAttachments().Count, Is.EqualTo(1));
                Assert.That(sp.Appearance.GetAttachpoint(attItem2.ID), Is.EqualTo((int)AttachmentPoint.LeftHand));
                Assert.That(scene.GetSceneObjectGroups().Count, Is.EqualTo(1));

                // Check events
                Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(3));
            }
        }