From 74f89fb22da159a940e942192d0cb59163e78987 Mon Sep 17 00:00:00 2001 From: Melanie Thielker Date: Sat, 4 Oct 2008 01:09:22 +0000 Subject: Add "Drop" functionality to pie menu --- OpenSim/Framework/IClientAPI.cs | 2 ++ .../Region/ClientStack/LindenUDP/LLClientView.cs | 14 ++++++++++ .../Environment/Modules/World/NPC/NPCAvatar.cs | 1 + OpenSim/Region/Environment/Scenes/InnerScene.cs | 21 ++++++++++++++- .../Region/Environment/Scenes/Scene.Inventory.cs | 31 ++++++++++++++++++++++ OpenSim/Region/Environment/Scenes/Scene.cs | 1 + .../Region/Environment/Scenes/SceneObjectGroup.cs | 12 ++++----- .../Region/Examples/SimpleModule/MyNpcCharacter.cs | 1 + 8 files changed, 76 insertions(+), 7 deletions(-) (limited to 'OpenSim') diff --git a/OpenSim/Framework/IClientAPI.cs b/OpenSim/Framework/IClientAPI.cs index d2ee770..3a5402c 100644 --- a/OpenSim/Framework/IClientAPI.cs +++ b/OpenSim/Framework/IClientAPI.cs @@ -112,6 +112,7 @@ namespace OpenSim.Framework IClientAPI remoteClient, UUID AgentID, uint RequestFlags, UUID TaskID); public delegate void ObjectDeselect(uint localID, IClientAPI remoteClient); + public delegate void ObjectDrop(uint localID, IClientAPI remoteClient); public delegate void UpdatePrimFlags(uint localID, Packet packet, IClientAPI remoteClient); @@ -380,6 +381,7 @@ namespace OpenSim.Framework event UUIDNameRequest OnDetachAttachmentIntoInv; event ObjectAttach OnObjectAttach; event ObjectDeselect OnObjectDetach; + event ObjectDrop OnObjectDrop; event StartAnim OnStartAnim; event StopAnim OnStopAnim; event LinkObjects OnLinkObjects; diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs index 5aa0f2e..e3efb42 100644 --- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs @@ -242,6 +242,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP private ObjectBuy handlerObjectBuy = null; //private BuyObjectInventory handlerBuyObjectInventory = null; private ObjectDeselect handlerObjectDetach = null; + private ObjectDrop handlerObjectDrop = null; private AgentSit handlerOnUndo = null; private ForceReleaseControls handlerForceReleaseControls = null; @@ -848,6 +849,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP public event UUIDNameRequest OnDetachAttachmentIntoInv; public event ObjectAttach OnObjectAttach; public event ObjectDeselect OnObjectDetach; + public event ObjectDrop OnObjectDrop; public event GenericCall2 OnCompleteMovementToRegion; public event UpdateAgent OnAgentUpdate; public event AgentRequestSit OnAgentRequestSit; @@ -4296,6 +4298,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP } break; + case PacketType.ObjectDrop: + ObjectDropPacket dropp = (ObjectDropPacket)Pack; + for (int j = 0; j < dropp.ObjectData.Length; j++) + { + uint obj = dropp.ObjectData[j].ObjectLocalID; + handlerObjectDrop = OnObjectDrop; + if (handlerObjectDrop != null) + { + handlerObjectDrop(obj, this); + } + } + break; case PacketType.SetAlwaysRun: SetAlwaysRunPacket run = (SetAlwaysRunPacket)Pack; diff --git a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs index 33eade2..3d3d41c 100644 --- a/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs +++ b/OpenSim/Region/Environment/Modules/World/NPC/NPCAvatar.cs @@ -171,6 +171,7 @@ namespace OpenSim.Region.Environment.Modules.World.NPC public event UUIDNameRequest OnDetachAttachmentIntoInv; public event ObjectAttach OnObjectAttach; public event ObjectDeselect OnObjectDetach; + public event ObjectDrop OnObjectDrop; public event StartAnim OnStartAnim; public event StopAnim OnStopAnim; public event LinkObjects OnLinkObjects; diff --git a/OpenSim/Region/Environment/Scenes/InnerScene.cs b/OpenSim/Region/Environment/Scenes/InnerScene.cs index 65fa544..869111c 100644 --- a/OpenSim/Region/Environment/Scenes/InnerScene.cs +++ b/OpenSim/Region/Environment/Scenes/InnerScene.cs @@ -358,6 +358,24 @@ namespace OpenSim.Region.Environment.Scenes m_activeScripts += number; } + protected internal void DropObject(uint objectLocalID, IClientAPI remoteClient) + { + List EntityList = GetEntities(); + + foreach (EntityBase obj in EntityList) + { + if (obj is SceneObjectGroup) + { + if (((SceneObjectGroup)obj).LocalId == objectLocalID) + { + SceneObjectGroup group = (SceneObjectGroup)obj; + + m_parentScene.DetachSingleAttachmentToGround(group.UUID,remoteClient); + } + } + } + } + protected internal void DetachObject(uint objectLocalID, IClientAPI remoteClient) { List EntityList = GetEntities(); @@ -441,10 +459,11 @@ namespace OpenSim.Region.Environment.Scenes (uint)(PermissionMask.Copy | PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer), (uint)(PermissionMask.Copy | PermissionMask.Move | PermissionMask.Modify | PermissionMask.Transfer), ItemFlags, false, false, remoteClient.AgentId, true); - objatt.SetAttachmentPoint(Convert.ToByte(AttachmentPt)); if (objatt != null) { + objatt.SetAttachmentPoint(Convert.ToByte(AttachmentPt)); + AttachObject(remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition); objatt.ScheduleGroupForFullUpdate(); } diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs index a7bce49..c139fd9 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs @@ -2293,6 +2293,37 @@ namespace OpenSim.Region.Environment.Scenes m_innerScene.AttachObject(controllingClient, localID, attachPoint, rot, pos); } + public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient) + { + SceneObjectPart part = GetSceneObjectPart(itemID); + if(part == null || part.ParentGroup == null) + return; + + UUID inventoryID = part.ParentGroup.GetFromAssetID(); + + ScenePresence presence; + if (TryGetAvatar(remoteClient.AgentId, out presence)) + { + if(!ExternalChecks.ExternalChecksCanRezObject(part.ParentGroup.Children.Count, remoteClient.AgentId, presence.AbsolutePosition)) + return; + + presence.Appearance.DetachAttachment(itemID); + IAvatarFactory ava = RequestModuleInterface(); + if (ava != null) + { + ava.UpdateDatabase(remoteClient.AgentId, presence.Appearance); + } + part.ParentGroup.DetachToGround(); + CachedUserInfo userInfo = + CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); + if (userInfo != null) + { + userInfo.DeleteItem(inventoryID); + remoteClient.SendRemoveInventoryItem(inventoryID); + } + } + } + public void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient) { ScenePresence presence; diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs index 5ab40cc..f90c6fb 100644 --- a/OpenSim/Region/Environment/Scenes/Scene.cs +++ b/OpenSim/Region/Environment/Scenes/Scene.cs @@ -2172,6 +2172,7 @@ namespace OpenSim.Region.Environment.Scenes client.OnDetachAttachmentIntoInv += DetachSingleAttachmentToInv; client.OnObjectAttach += m_innerScene.AttachObject; client.OnObjectDetach += m_innerScene.DetachObject; + client.OnObjectDrop += m_innerScene.DropObject; client.OnNameFromUUIDRequest += CommsManager.HandleUUIDNameRequest; client.OnObjectDescription += m_innerScene.PrimDescription; client.OnObjectName += m_innerScene.PrimName; diff --git a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs index 6cd0bae..18322ee 100644 --- a/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Environment/Scenes/SceneObjectGroup.cs @@ -766,19 +766,19 @@ namespace OpenSim.Region.Environment.Scenes { ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.AttachedAvatar); Vector3 detachedpos = new Vector3(127f,127f,127f); - if (avatar != null) - { - detachedpos = avatar.AbsolutePosition; - avatar.RemoveAttachment(this); - } + if (avatar == null) + return; + + detachedpos = avatar.AbsolutePosition; + AbsolutePosition = detachedpos; m_rootPart.AttachedAvatar = UUID.Zero; m_rootPart.SetParentLocalId(0); SetAttachmentPoint((byte)0); - m_rootPart.IsAttachment = false; m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim); HasGroupChanged = true; AttachToBackup(); + m_scene.EventManager.TriggerParcelPrimCountTainted(); m_rootPart.ScheduleFullUpdate(); m_rootPart.ClearUndoState(); } diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs index fa6ff22..c8d542c 100644 --- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs +++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs @@ -66,6 +66,7 @@ namespace OpenSim.Region.Examples.SimpleModule public event UUIDNameRequest OnDetachAttachmentIntoInv; public event ObjectAttach OnObjectAttach; public event ObjectDeselect OnObjectDetach; + public event ObjectDrop OnObjectDrop; public event StartAnim OnStartAnim; public event StopAnim OnStopAnim; public event LinkObjects OnLinkObjects; -- cgit v1.1