refactor: simplify DetachSingleAttachmentToGround() by retrieving the scene object group direct
parent
040ad11e61
commit
ae614c1264
|
@ -449,29 +449,30 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient)
|
public void DetachSingleAttachmentToGround(UUID sceneObjectID, IClientAPI remoteClient)
|
||||||
{
|
{
|
||||||
SceneObjectPart part = m_scene.GetSceneObjectPart(itemID);
|
SceneObjectGroup so = m_scene.GetSceneObjectGroup(sceneObjectID);
|
||||||
if (part == null || part.ParentGroup == null)
|
|
||||||
|
if (so == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (part.ParentGroup.RootPart.AttachedAvatar != remoteClient.AgentId)
|
if (so.RootPart.AttachedAvatar != remoteClient.AgentId)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
UUID inventoryID = part.ParentGroup.GetFromItemID();
|
UUID inventoryID = so.GetFromItemID();
|
||||||
|
|
||||||
ScenePresence presence;
|
ScenePresence presence;
|
||||||
if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
|
if (m_scene.TryGetScenePresence(remoteClient.AgentId, out presence))
|
||||||
{
|
{
|
||||||
if (!m_scene.Permissions.CanRezObject(
|
if (!m_scene.Permissions.CanRezObject(
|
||||||
part.ParentGroup.PrimCount, remoteClient.AgentId, presence.AbsolutePosition))
|
so.PrimCount, remoteClient.AgentId, presence.AbsolutePosition))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
bool changed = presence.Appearance.DetachAttachment(itemID);
|
bool changed = presence.Appearance.DetachAttachment(sceneObjectID);
|
||||||
if (changed && m_scene.AvatarFactory != null)
|
if (changed && m_scene.AvatarFactory != null)
|
||||||
m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId);
|
m_scene.AvatarFactory.QueueAppearanceSave(remoteClient.AgentId);
|
||||||
|
|
||||||
part.ParentGroup.DetachToGround();
|
so.DetachToGround();
|
||||||
|
|
||||||
List<UUID> uuids = new List<UUID>();
|
List<UUID> uuids = new List<UUID>();
|
||||||
uuids.Add(inventoryID);
|
uuids.Add(inventoryID);
|
||||||
|
@ -479,7 +480,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
remoteClient.SendRemoveInventoryItem(inventoryID);
|
remoteClient.SendRemoveInventoryItem(inventoryID);
|
||||||
}
|
}
|
||||||
|
|
||||||
m_scene.EventManager.TriggerOnAttach(part.ParentGroup.LocalId, itemID, UUID.Zero);
|
m_scene.EventManager.TriggerOnAttach(so.LocalId, sceneObjectID, UUID.Zero);
|
||||||
}
|
}
|
||||||
|
|
||||||
// What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards.
|
// What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards.
|
||||||
|
|
|
@ -105,9 +105,9 @@ namespace OpenSim.Region.Framework.Interfaces
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Detach the given item to the ground.
|
/// Detach the given item to the ground.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="itemID"></param>
|
/// <param name="sceneObjectID"></param>
|
||||||
/// <param name="remoteClient"></param>
|
/// <param name="remoteClient"></param>
|
||||||
void DetachSingleAttachmentToGround(UUID itemID, IClientAPI remoteClient);
|
void DetachSingleAttachmentToGround(UUID sceneObjectID, IClientAPI remoteClient);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Detach the given item so that it remains in the user's inventory.
|
/// Detach the given item so that it remains in the user's inventory.
|
||||||
|
|
Loading…
Reference in New Issue