refactor: move sog.DetachToInventoryPrep() into AttachmentsModule.DetachSingleAttachmentToInv()
parent
fcbed6479a
commit
002313bf13
|
@ -502,17 +502,28 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
|
||||||
if (group.GetFromItemID() == itemID)
|
if (group.GetFromItemID() == itemID)
|
||||||
{
|
{
|
||||||
m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero);
|
m_scene.EventManager.TriggerOnAttach(group.LocalId, itemID, UUID.Zero);
|
||||||
group.DetachToInventoryPrep();
|
sp.RemoveAttachment(group);
|
||||||
// m_log.Debug("[ATTACHMENTS MODULE]: Saving attachpoint: " + ((uint)group.GetAttachmentPoint()).ToString());
|
|
||||||
|
|
||||||
// If an item contains scripts, it's always changed.
|
// Prepare sog for storage
|
||||||
// This ensures script state is saved on detach
|
group.ForEachPart(
|
||||||
foreach (SceneObjectPart p in group.Parts)
|
delegate(SceneObjectPart part)
|
||||||
if (p.Inventory.ContainsScripts())
|
{
|
||||||
|
part.AttachedAvatar = UUID.Zero;
|
||||||
|
|
||||||
|
// If there are any scripts,
|
||||||
|
// then always trigger a new object and state persistence in UpdateKnownItem()
|
||||||
|
if (part.Inventory.ContainsScripts())
|
||||||
group.HasGroupChanged = true;
|
group.HasGroupChanged = true;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
group.RootPart.SetParentLocalId(0);
|
||||||
|
group.RootPart.IsAttachment = false;
|
||||||
|
group.AbsolutePosition = group.RootPart.AttachedPos;
|
||||||
|
|
||||||
UpdateKnownItem(sp.ControllingClient, group, group.GetFromItemID(), group.OwnerID);
|
UpdateKnownItem(sp.ControllingClient, group, group.GetFromItemID(), group.OwnerID);
|
||||||
m_scene.DeleteSceneObject(group, false);
|
m_scene.DeleteSceneObject(group, false);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -147,7 +147,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments.Tests
|
||||||
}
|
}
|
||||||
|
|
||||||
[Test]
|
[Test]
|
||||||
public void TestRemoveAttachment()
|
public void TestDetachAttachmentToInventory()
|
||||||
{
|
{
|
||||||
TestHelpers.InMethod();
|
TestHelpers.InMethod();
|
||||||
// log4net.Config.XmlConfigurator.Configure();
|
// log4net.Config.XmlConfigurator.Configure();
|
||||||
|
|
|
@ -147,15 +147,16 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <value>
|
/// <summary>
|
||||||
/// Is this scene object acting as an attachment?
|
/// Is this scene object acting as an attachment?
|
||||||
///
|
/// </summary>
|
||||||
|
/// <remarks>
|
||||||
/// We return false if the group has already been deleted.
|
/// We return false if the group has already been deleted.
|
||||||
///
|
///
|
||||||
/// TODO: At the moment set must be done on the part itself. There may be a case for doing it here since I
|
/// TODO: At the moment set must be done on the part itself. There may be a case for doing it here since I
|
||||||
/// presume either all or no parts in a linkset can be part of an attachment (in which
|
/// presume either all or no parts in a linkset can be part of an attachment (in which
|
||||||
/// case the value would get proprogated down into all the descendent parts).
|
/// case the value would get proprogated down into all the descendent parts).
|
||||||
/// </value>
|
/// </remarks>
|
||||||
public bool IsAttachment
|
public bool IsAttachment
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
|
@ -1017,31 +1018,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
m_rootPart.ClearUndoState();
|
m_rootPart.ClearUndoState();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DetachToInventoryPrep()
|
|
||||||
{
|
|
||||||
ScenePresence avatar = m_scene.GetScenePresence(m_rootPart.AttachedAvatar);
|
|
||||||
//Vector3 detachedpos = new Vector3(127f, 127f, 127f);
|
|
||||||
if (avatar != null)
|
|
||||||
{
|
|
||||||
//detachedpos = avatar.AbsolutePosition;
|
|
||||||
avatar.RemoveAttachment(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
m_rootPart.AttachedAvatar = UUID.Zero;
|
|
||||||
|
|
||||||
SceneObjectPart[] parts = m_parts.GetArray();
|
|
||||||
for (int i = 0; i < parts.Length; i++)
|
|
||||||
parts[i].AttachedAvatar = UUID.Zero;
|
|
||||||
|
|
||||||
m_rootPart.SetParentLocalId(0);
|
|
||||||
//m_rootPart.SetAttachmentPoint((byte)0);
|
|
||||||
m_rootPart.IsAttachment = false;
|
|
||||||
AbsolutePosition = m_rootPart.AttachedPos;
|
|
||||||
//m_rootPart.ApplyPhysics(m_rootPart.GetEffectiveObjectFlags(), m_scene.m_physicalPrim);
|
|
||||||
//AttachToBackup();
|
|
||||||
//m_rootPart.ScheduleFullUpdate();
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
Loading…
Reference in New Issue