refactor: migrate DropObject handling fully into AttachmentsModule from Scene
parent
37a5cf5783
commit
1de68b34d9
|
@ -51,7 +51,7 @@ namespace OpenSim.Framework
|
|||
UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
|
||||
bool RezSelected, bool RemoveItem, UUID fromTaskID);
|
||||
|
||||
public delegate UUID RezSingleAttachmentFromInv(IClientAPI remoteClient, UUID itemID, uint AttachmentPt);
|
||||
public delegate ISceneEntity RezSingleAttachmentFromInv(IClientAPI remoteClient, UUID itemID, uint AttachmentPt);
|
||||
|
||||
public delegate void RezMultipleAttachmentsFromInv(IClientAPI remoteClient, RezMultipleAttachmentsFromInvPacket.HeaderDataBlock header,
|
||||
RezMultipleAttachmentsFromInvPacket.ObjectDataBlock[] objects);
|
||||
|
|
|
@ -46,7 +46,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
|||
{
|
||||
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
|
||||
|
||||
private Scene m_scene = null;
|
||||
private Scene m_scene;
|
||||
private IDialogModule m_dialogModule;
|
||||
|
||||
public string Name { get { return "Attachments Module"; } }
|
||||
|
@ -83,6 +83,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
|||
client.OnObjectAttach += AttachObject;
|
||||
client.OnObjectDetach += DetachObject;
|
||||
client.OnDetachAttachmentIntoInv += DetachSingleAttachmentToInv;
|
||||
client.OnObjectDrop += DetachSingleAttachmentToGround;
|
||||
}
|
||||
|
||||
public void UnsubscribeFromClientEvents(IClientAPI client)
|
||||
|
@ -92,6 +93,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
|||
client.OnObjectAttach -= AttachObject;
|
||||
client.OnObjectDetach -= DetachObject;
|
||||
client.OnDetachAttachmentIntoInv -= DetachSingleAttachmentToInv;
|
||||
client.OnObjectDrop -= DetachSingleAttachmentToGround;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -250,12 +252,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
|||
}
|
||||
}
|
||||
|
||||
public UUID RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
|
||||
public ISceneEntity RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
|
||||
{
|
||||
return RezSingleAttachmentFromInventory(remoteClient, itemID, AttachmentPt, true);
|
||||
}
|
||||
|
||||
public UUID RezSingleAttachmentFromInventory(
|
||||
public ISceneEntity RezSingleAttachmentFromInventory(
|
||||
IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
|
@ -269,7 +271,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
|||
m_log.ErrorFormat(
|
||||
"[ATTACHMENTS MODULE]: Could not find presence for client {0} {1} in RezSingleAttachmentFromInventory()",
|
||||
remoteClient.Name, remoteClient.AgentId);
|
||||
return UUID.Zero;
|
||||
return null;
|
||||
}
|
||||
|
||||
// TODO: this short circuits multiple attachments functionality in LL viewer 2.1+ and should
|
||||
|
@ -286,10 +288,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
|||
ShowAttachInUserInventory(att, sp, itemID, AttachmentPt);
|
||||
}
|
||||
|
||||
if (null == att)
|
||||
return UUID.Zero;
|
||||
else
|
||||
return att.UUID;
|
||||
return att;
|
||||
}
|
||||
|
||||
private SceneObjectGroup RezSingleAttachmentFromInventoryInternal(
|
||||
|
@ -449,13 +448,13 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
|||
}
|
||||
}
|
||||
|
||||
public void DetachSingleAttachmentToGround(UUID sceneObjectID, IClientAPI remoteClient)
|
||||
public void DetachSingleAttachmentToGround(uint soLocalId, IClientAPI remoteClient)
|
||||
{
|
||||
// m_log.DebugFormat(
|
||||
// "[ATTACHMENTS MODULE]: DetachSingleAttachmentToGround() for {0}, object {1}",
|
||||
// remoteClient.Name, sceneObjectID);
|
||||
|
||||
SceneObjectGroup so = m_scene.GetSceneObjectGroup(sceneObjectID);
|
||||
SceneObjectGroup so = m_scene.GetGroupByPrim(soLocalId);
|
||||
|
||||
if (so == null)
|
||||
return;
|
||||
|
@ -489,7 +488,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
|||
remoteClient.SendRemoveInventoryItem(inventoryID);
|
||||
}
|
||||
|
||||
m_scene.EventManager.TriggerOnAttach(so.LocalId, sceneObjectID, UUID.Zero);
|
||||
m_scene.EventManager.TriggerOnAttach(so.LocalId, so.UUID, UUID.Zero);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -168,12 +168,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
|||
UserInventoryHelpers.CreateInventoryItem(
|
||||
scene, attName, attItemId, attAssetId, m_presence.UUID, InventoryType.Object);
|
||||
|
||||
// Check item status
|
||||
Assert.That(scene.InventoryService.GetItem(new InventoryItemBase(attItemId)), Is.Not.Null);
|
||||
|
||||
UUID attSoId = m_attMod.RezSingleAttachmentFromInventory(
|
||||
ISceneEntity so = m_attMod.RezSingleAttachmentFromInventory(
|
||||
m_presence.ControllingClient, attItemId, (uint)AttachmentPoint.Chest);
|
||||
m_attMod.DetachSingleAttachmentToGround(attSoId, m_presence.ControllingClient);
|
||||
m_attMod.DetachSingleAttachmentToGround(so.LocalId, m_presence.ControllingClient);
|
||||
|
||||
// Check scene presence status
|
||||
Assert.That(m_presence.HasAttachments(), Is.False);
|
||||
|
|
|
@ -64,7 +64,7 @@ namespace OpenSim.Region.Framework.Interfaces
|
|||
/// <param name="itemID"></param>
|
||||
/// <param name="AttachmentPt"></param>
|
||||
/// <returns>The scene object that was attached. Null if the scene object could not be found</returns>
|
||||
UUID RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt);
|
||||
ISceneEntity RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt);
|
||||
|
||||
/// <summary>
|
||||
/// Rez an attachment from user inventory
|
||||
|
@ -77,7 +77,7 @@ namespace OpenSim.Region.Framework.Interfaces
|
|||
/// False is required so that we don't attempt to update information when a user enters a scene with the
|
||||
/// attachment already correctly set up in inventory.
|
||||
/// <returns>The uuid of the scene object that was attached. Null if the scene object could not be found</returns>
|
||||
UUID RezSingleAttachmentFromInventory(
|
||||
ISceneEntity RezSingleAttachmentFromInventory(
|
||||
IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus);
|
||||
|
||||
/// <summary>
|
||||
|
@ -105,9 +105,9 @@ namespace OpenSim.Region.Framework.Interfaces
|
|||
/// <summary>
|
||||
/// Detach the given item to the ground.
|
||||
/// </summary>
|
||||
/// <param name="sceneObjectID"></param>
|
||||
/// <param name="objectLocalID"></param>
|
||||
/// <param name="remoteClient"></param>
|
||||
void DetachSingleAttachmentToGround(UUID sceneObjectID, IClientAPI remoteClient);
|
||||
void DetachSingleAttachmentToGround(uint objectLocalID, IClientAPI remoteClient);
|
||||
|
||||
/// <summary>
|
||||
/// Detach the given item so that it remains in the user's inventory.
|
||||
|
|
|
@ -2772,7 +2772,6 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
client.OnUndo += m_sceneGraph.HandleUndo;
|
||||
client.OnRedo += m_sceneGraph.HandleRedo;
|
||||
client.OnObjectDescription += m_sceneGraph.PrimDescription;
|
||||
client.OnObjectDrop += m_sceneGraph.DropObject;
|
||||
client.OnObjectIncludeInSearch += m_sceneGraph.MakeObjectSearchable;
|
||||
client.OnObjectOwner += ObjectOwner;
|
||||
}
|
||||
|
@ -2899,7 +2898,6 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
client.OnUndo -= m_sceneGraph.HandleUndo;
|
||||
client.OnRedo -= m_sceneGraph.HandleRedo;
|
||||
client.OnObjectDescription -= m_sceneGraph.PrimDescription;
|
||||
client.OnObjectDrop -= m_sceneGraph.DropObject;
|
||||
client.OnObjectIncludeInSearch -= m_sceneGraph.MakeObjectSearchable;
|
||||
client.OnObjectOwner -= ObjectOwner;
|
||||
}
|
||||
|
|
|
@ -548,13 +548,6 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
m_activeScripts += number;
|
||||
}
|
||||
|
||||
public void DropObject(uint objectLocalID, IClientAPI remoteClient)
|
||||
{
|
||||
SceneObjectGroup group = GetGroupByPrim(objectLocalID);
|
||||
if (group != null)
|
||||
m_parentScene.AttachmentsModule.DetachSingleAttachmentToGround(group.UUID, remoteClient);
|
||||
}
|
||||
|
||||
protected internal void HandleUndo(IClientAPI remoteClient, UUID primId)
|
||||
{
|
||||
if (primId != UUID.Zero)
|
||||
|
|
Loading…
Reference in New Issue