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); OSSL_Api osslApi = new OSSL_Api(); osslApi.Initialize(m_engine, inWorldObj.RootPart, scriptItem); // Create an object embedded inside the first TaskInventoryHelpers.AddNotecard( m_scene, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, TestHelpers.ParseTail(0x900)); 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 TestOsAgentSaveAppearance() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); UUID ownerId = TestHelpers.ParseTail(0x1); UUID nonOwnerId = TestHelpers.ParseTail(0x2); float newHeight = 1.9f; ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, nonOwnerId); sp.Appearance.AvatarHeight = newHeight; SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, ownerId, 0x10); SceneObjectPart part = so.RootPart; m_scene.AddSceneObject(so); OSSL_Api osslApi = new OSSL_Api(); osslApi.Initialize(m_engine, part, null); string notecardName = "appearanceNc"; osslApi.osAgentSaveAppearance(new LSL_Types.LSLString(nonOwnerId.ToString()), notecardName); IList <TaskInventoryItem> items = part.Inventory.GetInventoryItems(notecardName); Assert.That(items.Count, Is.EqualTo(1)); TaskInventoryItem ncItem = items[0]; Assert.That(ncItem.Name, Is.EqualTo(notecardName)); AssetBase ncAsset = m_scene.AssetService.Get(ncItem.AssetID.ToString()); Assert.That(ncAsset, Is.Not.Null); AssetNotecard anc = new AssetNotecard(UUID.Zero, ncAsset.Data); anc.Decode(); OSDMap appearanceOsd = (OSDMap)OSDParser.DeserializeLLSDXml(anc.BodyText); AvatarAppearance savedAppearance = new AvatarAppearance(); savedAppearance.Unpack(appearanceOsd); Assert.That(savedAppearance.AvatarHeight, Is.EqualTo(sp.Appearance.AvatarHeight)); }
public void TestOsNpcLoadAppearanceNotExistingNotecard() { TestHelpers.InMethod(); // Store an avatar with a different height from default in a notecard. UUID userId = TestHelpers.ParseTail(0x1); float firstHeight = 1.9f; float secondHeight = 2.1f; string firstAppearanceNcName = "appearanceNc1"; string secondAppearanceNcName = "appearanceNc2"; ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); sp.Appearance.AvatarHeight = firstHeight; SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10); SceneObjectPart part = so.RootPart; m_scene.AddSceneObject(so); OSSL_Api osslApi = new OSSL_Api(); osslApi.Initialize(m_engine, part, null); osslApi.osOwnerSaveAppearance(firstAppearanceNcName); string npcRaw = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), firstAppearanceNcName); bool gotExpectedException = false; try { osslApi.osNpcLoadAppearance(npcRaw, secondAppearanceNcName); } catch (ScriptException) { gotExpectedException = true; } Assert.That(gotExpectedException, Is.True); UUID npcId = new UUID(npcRaw); ScenePresence npc = m_scene.GetScenePresence(npcId); Assert.That(npc, Is.Not.Null); Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(firstHeight)); }
public void TestOsForceAttachToAvatarFromInventory() { 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); // SceneObjectGroup sog1 = SceneHelpers.CreateSceneObject(1, ua1.PrincipalID); // Create an object embedded inside the first TaskInventoryHelpers.AddSceneObject(m_scene, inWorldObj.RootPart, taskInvObjItemName, taskInvObjItemId, ua1.PrincipalID); osslApi.osForceAttachToAvatarFromInventory(taskInvObjItemName, (int)attachPoint); // 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(taskInvObjItemName)); 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(1)); Assert.That(sp.Appearance.GetAttachpoint(attachmentsInAppearance[0].ItemID), Is.EqualTo((uint)attachPoint)); }
public void TestOsNpcRemoveUnowned() { TestHelpers.InMethod(); // log4net.Config.XmlConfigurator.Configure(); // Store an avatar with a different height from default in a notecard. UUID userId = TestHelpers.ParseTail(0x1); float newHeight = 1.9f; ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); sp.Appearance.AvatarHeight = newHeight; SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10); SceneObjectPart part = so.RootPart; m_scene.AddSceneObject(so); OSSL_Api osslApi = new OSSL_Api(); osslApi.Initialize(m_engine, part, null); string notecardName = "appearanceNc"; osslApi.osOwnerSaveAppearance(notecardName); string npcRaw = osslApi.osNpcCreate( "Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), notecardName, ScriptBaseClass.OS_NPC_NOT_OWNED); osslApi.osNpcRemove(npcRaw); UUID npcId = new UUID(npcRaw); ScenePresence npc = m_scene.GetScenePresence(npcId); Assert.That(npc, Is.Null); }
public void TestOsNpcCreateUsingAppearanceFromAvatar() { TestHelpers.InMethod(); // TestHelpers.EnableLogging(); // Store an avatar with a different height from default in a notecard. UUID userId = TestHelpers.ParseTail(0x1); float newHeight = 1.9f; ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); sp.Appearance.AvatarHeight = newHeight; SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10); SceneObjectPart part = so.RootPart; m_scene.AddSceneObject(so); OSSL_Api osslApi = new OSSL_Api(); osslApi.Initialize(m_engine, part, null); string notecardName = "appearanceNc"; osslApi.osOwnerSaveAppearance(notecardName); // Try creating a bot using the existing avatar's appearance string npcRaw = osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), sp.UUID.ToString()); Assert.That(npcRaw, Is.Not.Null); UUID npcId = new UUID(npcRaw); ScenePresence npc = m_scene.GetScenePresence(npcId); Assert.That(npc, Is.Not.Null); Assert.That(npc.Appearance.AvatarHeight, Is.EqualTo(newHeight)); }
public void TestOsNpcCreateNotExistingNotecard() { TestHelpers.InMethod(); UUID userId = TestHelpers.ParseTail(0x1); SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, userId, 0x10); m_scene.AddSceneObject(so); OSSL_Api osslApi = new OSSL_Api(); osslApi.Initialize(m_engine, so.RootPart, null, null); bool gotExpectedException = false; try { osslApi.osNpcCreate("Jane", "Doe", new LSL_Types.Vector3(128, 128, 128), "not existing notecard name"); } catch (ScriptException) { gotExpectedException = true; } Assert.That(gotExpectedException, Is.True); }