refactor: crudely move DetachSingleAttachmentToGround() over to the AttachmentsModule

slimupdates
Justin Clark-Casey (justincc) 2010-04-16 23:15:13 +01:00
parent 45563e20e0
commit 57c293d604
4 changed files with 40 additions and 33 deletions

View File

@ -341,6 +341,38 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
DetachSingleAttachmentToInv(itemID, remoteClient);
}
public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient)
{
SceneObjectPart part = m_scene.GetSceneObjectPart(itemID);
if (part == null || part.ParentGroup == null)
return;
UUID inventoryID = part.ParentGroup.GetFromItemID();
ScenePresence presence;
if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
{
if (!m_scene.Permissions.CanRezObject(
part.ParentGroup.Children.Count, remoteClient.AgentId, presence.AbsolutePosition))
return;
presence.Appearance.DetachAttachment(itemID);
if (m_scene.AvatarFactory != null)
{
m_scene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
}
part.ParentGroup.DetachToGround();
List<UUID> uuids = new List<UUID>();
uuids.Add(inventoryID);
m_scene.InventoryService.DeleteItems(remoteClient.AgentId, uuids);
remoteClient.SendRemoveInventoryItem(inventoryID);
}
m_scene.EventManager.TriggerOnAttach(part.ParentGroup.LocalId, itemID, UUID.Zero);
}
// What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards.
// To LocalId or UUID, *THAT* is the question. How now Brown UUID??
protected void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient)

View File

@ -92,6 +92,13 @@ namespace OpenSim.Region.Framework.Interfaces
IClientAPI remoteClient,
RezMultipleAttachmentsFromInvPacket.HeaderDataBlock header,
RezMultipleAttachmentsFromInvPacket.ObjectDataBlock[] objects);
/// <summary>
/// Detach the given item to the ground.
/// </summary>
/// <param name="itemID"></param>
/// <param name="remoteClient"></param>
void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient);
/// <summary>
/// Update the user inventory to the attachment of an item

View File

@ -1873,36 +1873,6 @@ namespace OpenSim.Region.Framework.Scenes
EventManager.TriggerOnAttach(localID, itemID, avatarID);
}
public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient)
{
SceneObjectPart part = GetSceneObjectPart(itemID);
if (part == null || part.ParentGroup == null)
return;
UUID inventoryID = part.ParentGroup.GetFromItemID();
ScenePresence presence;
if (TryGetScenePresence(remoteClient.AgentId, out presence))
{
if (!Permissions.CanRezObject(part.ParentGroup.Children.Count, remoteClient.AgentId, presence.AbsolutePosition))
return;
presence.Appearance.DetachAttachment(itemID);
IAvatarFactory ava = RequestModuleInterface<IAvatarFactory>();
if (ava != null)
{
ava.UpdateDatabase(remoteClient.AgentId, presence.Appearance);
}
part.ParentGroup.DetachToGround();
List<UUID> uuids = new List<UUID>();
uuids.Add(inventoryID);
InventoryService.DeleteItems(remoteClient.AgentId, uuids);
remoteClient.SendRemoveInventoryItem(inventoryID);
}
SendAttachEvent(part.ParentGroup.LocalId, itemID, UUID.Zero);
}
public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID)
{
EventManager.TriggerGetScriptRunning(controllingClient, objectID, itemID);

View File

@ -443,9 +443,7 @@ namespace OpenSim.Region.Framework.Scenes
{
SceneObjectGroup group = GetGroupByPrim(objectLocalID);
if (group != null)
{
m_parentScene.DetachSingleAttachmentToGround(group.UUID, remoteClient);
}
m_parentScene.AttachmentsModule.DetachSingleAttachmentToGround(group.UUID, remoteClient);
}
protected internal void DetachObject(uint objectLocalID, IClientAPI remoteClient)