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)); }
private void Client_OnDetachAttachmentIntoInv(UUID itemID, IClientAPI remoteClient) { if (!Enabled) { return; } ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); if (sp != null) { lock (sp.AttachmentsSyncLock) { List <SceneObjectGroup> attachments = sp.GetAttachments(); foreach (SceneObjectGroup group in attachments) { if (group.FromItemID == itemID && group.FromItemID != UUID.Zero) { DetachSingleAttachmentToInv(sp, group); return; } } } } }
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)); }
public void TestRemoveAttachmentsOnAvatarExit() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); 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); ScenePresence presence = SceneHelpers.AddScenePresence(scene, acd); SceneObjectGroup rezzedAtt = presence.GetAttachments()[0]; m_numberOfAttachEventsFired = 0; scene.IncomingCloseAgent(presence.UUID, false); // Check that we can't retrieve this attachment from the scene. Assert.That(scene.GetSceneObjectGroup(rezzedAtt.UUID), Is.Null); // Check events Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0)); }
public void TestUpdateAttachmentPosition() { TestHelpers.InMethod(); 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); ScenePresence sp = SceneHelpers.AddScenePresence(scene, acd); SceneObjectGroup attSo = sp.GetAttachments()[0]; Vector3 newPosition = new Vector3(1, 2, 4); m_numberOfAttachEventsFired = 0; scene.SceneGraph.UpdatePrimGroupPosition(attSo.LocalId, newPosition, sp.ControllingClient); Assert.That(attSo.AbsolutePosition, Is.EqualTo(sp.AbsolutePosition)); Assert.That(attSo.RootPart.AttachedPos, Is.EqualTo(newPosition)); // Check events Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0)); }
private void DetachAttachments(UUID agentID) { ScenePresence sp = m_scene.GetScenePresence(agentID); if ((sp.TeleportFlags & TeleportFlags.ViaLogin) != 0) { // Wait a little, cos there's weird stuff going on at login related to // the Current Outfit Folder Thread.Sleep(8000); } if (sp != null && m_scene.AttachmentsModule != null) { List <SceneObjectGroup> attachs = sp.GetAttachments(); if (attachs != null && attachs.Count > 0) { foreach (SceneObjectGroup sog in attachs) { m_log.DebugFormat("[CAMERA-ONLY MODE]: Forcibly detaching attach {0} from {1} in {2}", sog.Name, sp.Name, m_scene.RegionInfo.RegionName); m_scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, sog); } } } }
public void TestRemoveAttachmentsOnAvatarExit() { 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); SceneObjectGroup rezzedAtt = presence.GetAttachments()[0]; scene.IncomingCloseAgent(presence.UUID); // Check that we can't retrieve this attachment from the scene. Assert.That(scene.GetSceneObjectGroup(rezzedAtt.UUID), Is.Null); }
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)); }
public void CheckWhetherAttachmentsHaveChanged(ScenePresence presence) { foreach (SceneObjectGroup grp in presence.GetAttachments()) { if (CheckWhetherAttachmentShouldBeSent(grp)) { SendGroupUpdate(grp, PrimUpdateFlags.ForcedFullUpdate); } } }
/// <summary> /// Check whether the attachments of the given presence are too heavy /// to be allowed to be used in an outfit /// </summary> /// <param name="presence"></param> /// <returns></returns> private bool CheckAppearanceForAttachmentCount(ScenePresence presence) { int totalAttachmentLandImpact = 0; foreach (SceneObjectGroup grp in presence.GetAttachments()) { totalAttachmentLandImpact += grp.LandImpact; } return(totalAttachmentLandImpact < m_maxLandImpactAllowedByOutfitAttachments); }
private void GetAttachmentsReport(ScenePresence sp, StringBuilder sb) { sb.AppendFormat("Attachments for {0}\n", sp.Name); ConsoleDisplayTable ct = new ConsoleDisplayTable() { Indent = 2 }; ct.Columns.Add(new ConsoleDisplayTableColumn("Attachment Name", 36)); ct.Columns.Add(new ConsoleDisplayTableColumn("Local ID", 10)); ct.Columns.Add(new ConsoleDisplayTableColumn("Item ID", 36)); ct.Columns.Add(new ConsoleDisplayTableColumn("Attach Point", 14)); ct.Columns.Add(new ConsoleDisplayTableColumn("Position", 15)); // sb.AppendFormat( // " {0,-36} {1,-10} {2,-36} {3,-14} {4,-15}\n", // "Attachment Name", "Local ID", "Item ID", "Attach Point", "Position"); List <SceneObjectGroup> attachmentObjects = sp.GetAttachments(); foreach (SceneObjectGroup attachmentObject in attachmentObjects) { // InventoryItemBase attachmentItem // = m_scenes[0].InventoryService.GetItem(new InventoryItemBase(attachmentObject.FromItemID)); // if (attachmentItem == null) // { // sb.AppendFormat( // "WARNING: Couldn't find attachment for item {0} at point {1}\n", // attachmentData.ItemID, (AttachmentPoint)attachmentData.AttachPoint); // continue; // } // else // { // sb.AppendFormat( // " {0,-36} {1,-10} {2,-36} {3,-14} {4,-15}\n", // attachmentObject.Name, attachmentObject.LocalId, attachmentObject.FromItemID, // (AttachmentPoint)attachmentObject.AttachmentPoint, attachmentObject.RootPart.AttachedPos); ct.Rows.Add( new ConsoleDisplayTableRow( new List <string>() { attachmentObject.Name, attachmentObject.LocalId.ToString(), attachmentObject.FromItemID.ToString(), ((AttachmentPoint)attachmentObject.AttachmentPoint).ToString(), attachmentObject.RootPart.AttachedPos.ToString() })); // } } ct.AddToStringBuilder(sb); sb.Append("\n"); }
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)); }
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)); }
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)); }
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(); // 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)); }
protected void OnMakeRootAgent(ScenePresence sp) { m_log.InfoFormat("[WATER WARS]: Processing OnMakeRootAgent for {0}", sp.Name); List <SceneObjectGroup> attachments = sp.GetAttachments(); lock (attachments) { foreach (SceneObjectGroup sog in attachments) { if (sog.Name != HudView.IN_WORLD_NAME) { continue; } RegisterHud(sp.UUID, sog.RootPart); } } }
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)); }
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)); }
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)); }
public bool AttachObject(IClientAPI remoteClient, SceneObjectGroup group, uint AttachmentPt, bool silent) { Vector3 attachPos = group.AbsolutePosition; if (m_scene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId)) { // TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should // be removed when that functionality is implemented in opensim AttachmentPt &= 0x7f; // If the attachment point isn't the same as the one previously used // set it's offset position = 0 so that it appears on the attachment point // and not in a weird location somewhere unknown. if (AttachmentPt != 0 && AttachmentPt != (uint)group.GetAttachmentPoint()) { attachPos = Vector3.Zero; } // AttachmentPt 0 means the client chose to 'wear' the attachment. if (AttachmentPt == 0) { // Check object for stored attachment point AttachmentPt = (uint)group.GetAttachmentPoint(); } // if we still didn't find a suitable attachment point....... if (AttachmentPt == 0) { // Stick it on left hand with Zero Offset from the attachment point. AttachmentPt = (uint)AttachmentPoint.LeftHand; attachPos = Vector3.Zero; } group.SetAttachmentPoint((byte)AttachmentPt); group.AbsolutePosition = attachPos; // Remove any previous attachments ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId); UUID itemID = UUID.Zero; if (sp != null) { foreach (SceneObjectGroup grp in sp.GetAttachments(AttachmentPt)) { itemID = grp.GetFromItemID(); if (itemID != UUID.Zero) { DetachSingleAttachmentToInv(itemID, remoteClient); } } } if (group.GetFromItemID() == UUID.Zero) { m_scene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId, out itemID); } else { itemID = group.GetFromItemID(); } ShowAttachInUserInventory(remoteClient, AttachmentPt, itemID, group); AttachToAgent(sp, group, AttachmentPt, attachPos, silent); } else { remoteClient.SendAgentAlertMessage( "You don't have sufficient permissions to attach this object", false); return(false); } return(true); }
public void TestSameSimulatorNeighbouringRegionsTeleport() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); AttachmentsModule attModA = new AttachmentsModule(); AttachmentsModule attModB = new AttachmentsModule(); EntityTransferModule etmA = new EntityTransferModule(); EntityTransferModule etmB = new EntityTransferModule(); LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); IConfigSource config = new IniConfigSource(); IConfig modulesConfig = config.AddConfig("Modules"); modulesConfig.Set("EntityTransferModule", etmA.Name); modulesConfig.Set("SimulationServices", lscm.Name); IConfig entityTransferConfig = config.AddConfig("EntityTransfer"); // In order to run a single threaded regression test we do not want the entity transfer module waiting // for a callback from the destination scene before removing its avatar data. entityTransferConfig.Set("wait_for_callback", false); modulesConfig.Set("InventoryAccessModule", "BasicInventoryAccessModule"); SceneHelpers sh = new SceneHelpers(); TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000); SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); SceneHelpers.SetupSceneModules( sceneA, config, new CapabilitiesModule(), etmA, attModA, new BasicInventoryAccessModule()); SceneHelpers.SetupSceneModules( sceneB, config, new CapabilitiesModule(), etmB, attModB, new BasicInventoryAccessModule()); UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(sceneA, 0x1); ScenePresence beforeTeleportSp = SceneHelpers.AddScenePresence(sceneA, ua1.PrincipalID, sh.SceneManager); beforeTeleportSp.AbsolutePosition = new Vector3(30, 31, 32); InventoryItemBase attItem = CreateAttachmentItem(sceneA, ua1.PrincipalID, "att", 0x10, 0x20); sceneA.AttachmentsModule.RezSingleAttachmentFromInventory( beforeTeleportSp, attItem.ID, (uint)AttachmentPoint.Chest); Vector3 teleportPosition = new Vector3(10, 11, 12); Vector3 teleportLookAt = new Vector3(20, 21, 22); m_numberOfAttachEventsFired = 0; sceneA.RequestTeleportLocation( beforeTeleportSp.ControllingClient, sceneB.RegionInfo.RegionHandle, teleportPosition, teleportLookAt, (uint)TeleportFlags.ViaLocation); ((TestClient)beforeTeleportSp.ControllingClient).CompleteTeleportClientSide(); // Check attachments have made it into sceneB ScenePresence afterTeleportSceneBSp = sceneB.GetScenePresence(ua1.PrincipalID); // This is appearance data, as opposed to actually rezzed attachments List <AvatarAttachment> sceneBAttachments = afterTeleportSceneBSp.Appearance.GetAttachments(); Assert.That(sceneBAttachments.Count, Is.EqualTo(1)); Assert.That(sceneBAttachments[0].AttachPoint, Is.EqualTo((int)AttachmentPoint.Chest)); Assert.That(sceneBAttachments[0].ItemID, Is.EqualTo(attItem.ID)); Assert.That(sceneBAttachments[0].AssetID, Is.EqualTo(attItem.AssetID)); Assert.That(afterTeleportSceneBSp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); // This is the actual attachment List <SceneObjectGroup> actualSceneBAttachments = afterTeleportSceneBSp.GetAttachments(); Assert.That(actualSceneBAttachments.Count, Is.EqualTo(1)); SceneObjectGroup actualSceneBAtt = actualSceneBAttachments[0]; Assert.That(actualSceneBAtt.Name, Is.EqualTo(attItem.Name)); Assert.That(actualSceneBAtt.AttachmentPoint, Is.EqualTo((uint)AttachmentPoint.Chest)); Assert.That(sceneB.GetSceneObjectGroups().Count, Is.EqualTo(1)); // Check attachments have been removed from sceneA ScenePresence afterTeleportSceneASp = sceneA.GetScenePresence(ua1.PrincipalID); // Since this is appearance data, it is still present on the child avatar! List <AvatarAttachment> sceneAAttachments = afterTeleportSceneASp.Appearance.GetAttachments(); Assert.That(sceneAAttachments.Count, Is.EqualTo(1)); Assert.That(afterTeleportSceneASp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); // This is the actual attachment, which should no longer exist List <SceneObjectGroup> actualSceneAAttachments = afterTeleportSceneASp.GetAttachments(); Assert.That(actualSceneAAttachments.Count, Is.EqualTo(0)); Assert.That(sceneA.GetSceneObjectGroups().Count, Is.EqualTo(0)); // Check events Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(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)); } }
/// <summary> /// Delivers the message to a scene entity. /// </summary> /// <param name='target'> /// Target. /// </param> /// <param name='channel'> /// Channel. /// </param> /// <param name='name'> /// Name. /// </param> /// <param name='id'> /// Identifier. /// </param> /// <param name='msg'> /// Message. /// </param> public void DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg) { if (channel == DEBUG_CHANNEL) { return; } if (target == UUID.Zero) { return; } // Is target an avatar? ScenePresence sp = m_scene.GetScenePresence(target); if (sp != null) { // Send message to avatar if (channel == 0) { // Channel 0 goes to viewer ONLY m_scene.SimChat(Utils.StringToBytes(msg), ChatTypeEnum.Broadcast, 0, pos, name, id, target, false, false); return; } // for now messages to prims don't cross regions if (sp.IsChildAgent) { return; } List <SceneObjectGroup> attachments = sp.GetAttachments(); if (attachments.Count == 0) { return; } // Get uuid of attachments List <UUID> targets = new List <UUID>(); foreach (SceneObjectGroup sog in attachments) { if (!sog.IsDeleted) { SceneObjectPart[] parts = sog.Parts; foreach (SceneObjectPart p in parts) { targets.Add(p.UUID); } } } foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) { UUID liHostID = li.GetHostID(); if (liHostID.Equals(id)) { continue; } if (m_scene.GetSceneObjectPart(liHostID) == null) { continue; } if (targets.Contains(liHostID)) { QueueMessage(new ListenerInfo(li, name, id, msg)); } } return; } SceneObjectPart part = m_scene.GetSceneObjectPart(target); if (part == null) // Not even an object { return; // No error } foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) { UUID liHostID = li.GetHostID(); // Dont process if this message is from yourself! if (liHostID.Equals(id)) { continue; } if (m_scene.GetSceneObjectPart(liHostID) == null) { continue; } if (liHostID.Equals(target)) { QueueMessage(new ListenerInfo(li, name, id, msg)); break; } } }
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)); } }
/// <summary> /// Delivers the message to a scene entity. /// </summary> /// <param name='target'> /// Target. /// </param> /// <param name='channel'> /// Channel. /// </param> /// <param name='name'> /// Name. /// </param> /// <param name='id'> /// Identifier. /// </param> /// <param name='msg'> /// Message. /// </param> public bool DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg, out string error) { error = null; // Is id an avatar? ScenePresence sp = m_scene.GetScenePresence(target); if (sp != null) { // Send message to avatar if (channel == 0) { m_scene.SimChatBroadcast(Utils.StringToBytes(msg), ChatTypeEnum.Owner, 0, pos, name, id, false); } List <SceneObjectGroup> attachments = sp.GetAttachments(); if (attachments.Count == 0) { return(true); } // Get uuid of attachments List <UUID> targets = new List <UUID>(); foreach (SceneObjectGroup sog in attachments) { if (!sog.IsDeleted) { targets.Add(sog.UUID); } } // Need to check each attachment foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) { if (li.GetHostID().Equals(id)) { continue; } if (m_scene.GetSceneObjectPart(li.GetHostID()) == null) { continue; } if (targets.Contains(li.GetHostID())) { QueueMessage(new ListenerInfo(li, name, id, msg)); } } return(true); } // Need to toss an error here if (channel == 0) { error = "Cannot use llRegionSayTo to message objects on channel 0"; return(false); } foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) { // Dont process if this message is from yourself! if (li.GetHostID().Equals(id)) { continue; } SceneObjectPart sPart = m_scene.GetSceneObjectPart(li.GetHostID()); if (sPart == null) { continue; } if (li.GetHostID().Equals(target)) { QueueMessage(new ListenerInfo(li, name, id, msg)); break; } } return(true); }
public void TestSameSimulatorNeighbouringRegionsTeleportV2() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); BaseHttpServer httpServer = new BaseHttpServer(99999); MainServer.AddHttpServer(httpServer); MainServer.Instance = httpServer; AttachmentsModule attModA = new AttachmentsModule(); AttachmentsModule attModB = new AttachmentsModule(); EntityTransferModule etmA = new EntityTransferModule(); EntityTransferModule etmB = new EntityTransferModule(); LocalSimulationConnectorModule lscm = new LocalSimulationConnectorModule(); IConfigSource config = new IniConfigSource(); IConfig modulesConfig = config.AddConfig("Modules"); modulesConfig.Set("EntityTransferModule", etmA.Name); modulesConfig.Set("SimulationServices", lscm.Name); modulesConfig.Set("InventoryAccessModule", "BasicInventoryAccessModule"); SceneHelpers sh = new SceneHelpers(); TestScene sceneA = sh.SetupScene("sceneA", TestHelpers.ParseTail(0x100), 1000, 1000); TestScene sceneB = sh.SetupScene("sceneB", TestHelpers.ParseTail(0x200), 1001, 1000); SceneHelpers.SetupSceneModules(new Scene[] { sceneA, sceneB }, config, lscm); SceneHelpers.SetupSceneModules( sceneA, config, new CapabilitiesModule(), etmA, attModA, new BasicInventoryAccessModule()); SceneHelpers.SetupSceneModules( sceneB, config, new CapabilitiesModule(), etmB, attModB, new BasicInventoryAccessModule()); UserAccount ua1 = UserAccountHelpers.CreateUserWithInventory(sceneA, 0x1); AgentCircuitData acd = SceneHelpers.GenerateAgentData(ua1.PrincipalID); TestClient tc = new TestClient(acd, sceneA); List <TestClient> destinationTestClients = new List <TestClient>(); EntityTransferHelpers.SetupInformClientOfNeighbourTriggersNeighbourClientCreate(tc, destinationTestClients); ScenePresence beforeTeleportSp = SceneHelpers.AddScenePresence(sceneA, tc, acd); beforeTeleportSp.AbsolutePosition = new Vector3(30, 31, 32); Assert.That(destinationTestClients.Count, Is.EqualTo(1)); Assert.That(destinationTestClients[0], Is.Not.Null); InventoryItemBase attItem = CreateAttachmentItem(sceneA, ua1.PrincipalID, "att", 0x10, 0x20); sceneA.AttachmentsModule.RezSingleAttachmentFromInventory( beforeTeleportSp, attItem.ID, (uint)AttachmentPoint.Chest); Vector3 teleportPosition = new Vector3(10, 11, 12); Vector3 teleportLookAt = new Vector3(20, 21, 22); // Here, we need to make clientA's receipt of SendRegionTeleport trigger clientB's CompleteMovement(). This // is to operate the teleport V2 mechanism where the EntityTransferModule will first request the client to // CompleteMovement to the region and then call UpdateAgent to the destination region to confirm the receipt // Both these operations will occur on different threads and will wait for each other. // We have to do this via ThreadPool directly since FireAndForget has been switched to sync for the V1 // test protocol, where we are trying to avoid unpredictable async operations in regression tests. tc.OnTestClientSendRegionTeleport += (regionHandle, simAccess, regionExternalEndPoint, locationID, flags, capsURL) => ThreadPool.UnsafeQueueUserWorkItem(o => destinationTestClients[0].CompleteMovement(), null); m_numberOfAttachEventsFired = 0; sceneA.RequestTeleportLocation( beforeTeleportSp.ControllingClient, sceneB.RegionInfo.RegionHandle, teleportPosition, teleportLookAt, (uint)TeleportFlags.ViaLocation); // Check attachments have made it into sceneB ScenePresence afterTeleportSceneBSp = sceneB.GetScenePresence(ua1.PrincipalID); // This is appearance data, as opposed to actually rezzed attachments List <AvatarAttachment> sceneBAttachments = afterTeleportSceneBSp.Appearance.GetAttachments(); Assert.That(sceneBAttachments.Count, Is.EqualTo(1)); Assert.That(sceneBAttachments[0].AttachPoint, Is.EqualTo((int)AttachmentPoint.Chest)); Assert.That(sceneBAttachments[0].ItemID, Is.EqualTo(attItem.ID)); Assert.That(sceneBAttachments[0].AssetID, Is.EqualTo(attItem.AssetID)); Assert.That(afterTeleportSceneBSp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); // This is the actual attachment List <SceneObjectGroup> actualSceneBAttachments = afterTeleportSceneBSp.GetAttachments(); Assert.That(actualSceneBAttachments.Count, Is.EqualTo(1)); SceneObjectGroup actualSceneBAtt = actualSceneBAttachments[0]; Assert.That(actualSceneBAtt.Name, Is.EqualTo(attItem.Name)); Assert.That(actualSceneBAtt.AttachmentPoint, Is.EqualTo((uint)AttachmentPoint.Chest)); Assert.IsFalse(actualSceneBAtt.Backup); Assert.That(sceneB.GetSceneObjectGroups().Count, Is.EqualTo(1)); // Check attachments have been removed from sceneA ScenePresence afterTeleportSceneASp = sceneA.GetScenePresence(ua1.PrincipalID); // Since this is appearance data, it is still present on the child avatar! List <AvatarAttachment> sceneAAttachments = afterTeleportSceneASp.Appearance.GetAttachments(); Assert.That(sceneAAttachments.Count, Is.EqualTo(1)); Assert.That(afterTeleportSceneASp.Appearance.GetAttachpoint(attItem.ID), Is.EqualTo((int)AttachmentPoint.Chest)); // This is the actual attachment, which should no longer exist List <SceneObjectGroup> actualSceneAAttachments = afterTeleportSceneASp.GetAttachments(); Assert.That(actualSceneAAttachments.Count, Is.EqualTo(0)); Assert.That(sceneA.GetSceneObjectGroups().Count, Is.EqualTo(0)); // Check events Assert.That(m_numberOfAttachEventsFired, Is.EqualTo(0)); }
/// <summary> /// Delivers the message to a scene entity. /// </summary> /// <param name='target'> /// Target. /// </param> /// <param name='channel'> /// Channel. /// </param> /// <param name='name'> /// Name. /// </param> /// <param name='id'> /// Identifier. /// </param> /// <param name='msg'> /// Message. /// </param> public void DeliverMessageTo(UUID target, int channel, Vector3 pos, string name, UUID id, string msg) { // Is id an avatar? ScenePresence sp = m_scene.GetScenePresence(target); if (sp != null) { // ignore if a child agent this is restricted to inside one // region if (sp.IsChildAgent) { return; } // Send message to the avatar. // Channel zero only goes to the avatar // non zero channel messages only go to the attachments if (channel != 0) { List <SceneObjectGroup> attachments = sp.GetAttachments(); if (attachments.Count == 0) { return; } // Get uuid of attachments List <UUID> targets = new List <UUID>(); foreach (SceneObjectGroup sog in attachments) { if (!sog.IsDeleted) { targets.Add(sog.UUID); } } // Need to check each attachment foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) { if (li.GetHostID().Equals(id)) { continue; } if (m_scene.GetSceneObjectPart( li.GetHostID()) == null) { continue; } if (channel == DEBUG_CHANNEL) { msg = "At region " + m_scene.Name + ":\n" + msg; } if (targets.Contains(li.GetHostID())) { QueueMessage(new ListenerInfo(li, name, id, msg)); } } } return; } // No avatar found so look for an object foreach (ListenerInfo li in m_listenerManager.GetListeners(UUID.Zero, channel, name, id, msg)) { // Dont process if this message is from yourself! if (li.GetHostID().Equals(id)) { continue; } SceneObjectPart sPart = m_scene.GetSceneObjectPart( li.GetHostID()); if (sPart == null) { continue; } if (li.GetHostID().Equals(target)) { QueueMessage(new ListenerInfo(li, name, id, msg)); break; } } return; }
protected void OnInstantMessage(IClientAPI client, GridInstantMessage im) { m_log.InfoFormat("[WATER WARS]: GameManagerTopLevelInteraction.OnInstantMessage received"); if (im.dialog == (byte)InstantMessageDialog.InventoryAccepted && client.AgentId == m_playerId) { m_log.InfoFormat("[WATER WARS]: Now we get to do something cool! IMSessionId [{0}]", im.imSessionID); UUID itemId = new UUID(im.imSessionID); Scene scene = client.Scene as Scene; // This really need to be a 'has inventory item' method in Scene.Inventory.cs InventoryItemBase item = new InventoryItemBase(itemId, m_playerId); item = scene.InventoryService.GetItem(item); if (item == null) { m_log.Error("[WATER WARS]: Failed to find item " + itemId); return; } else if (item.Name != HUD_ITEM_NAME) { m_log.InfoFormat( "[WATER WARS]: Ignoring hud item {0} since it's not a {1}", item.Name, HUD_ITEM_NAME); return; } uint attachmentPoint = (uint)AttachmentPoint.HUDTop; ScenePresence sp = scene.GetScenePresence(client.AgentId); List <SceneObjectGroup> existingAttachments = sp.GetAttachments(attachmentPoint); if (existingAttachments.Count == 0) { IAttachmentsModule module = client.Scene.RequestModuleInterface <IAttachmentsModule>(); SceneObjectGroup sog = (SceneObjectGroup)module.RezSingleAttachmentFromInventory( sp, new UUID(im.imSessionID), (uint)AttachmentPoint.HUDTop); // A tempoary messy solution to an occasional race where the attached hud sometimes ends up positioned // on the avatar itself and does not show up as attached within inventory. Thread.Sleep(1000); Vector3 newPos = new Vector3(0, 0, -0.1f); m_log.InfoFormat("[WATER WARS]: Resetting HUD position to {0}", newPos); module.UpdateAttachmentPosition(sog, newPos); /* * sog.UpdateGroupPosition(newPos); * sog.HasGroupChanged = true; * sog.ScheduleGroupForTerseUpdate(); */ } else { m_log.InfoFormat( "[WATER WARS]: Not attaching given hud for {0} since something is already attached at {1}", client.Name, attachmentPoint); } client.OnInstantMessage -= OnInstantMessage; } }