refactor: move SOG.AttachToAgent() into AttachmentsModule

prebuild-update
Justin Clark-Casey (justincc) 2010-09-01 01:11:52 +01:00
parent c947a67b23
commit 6cbf66827b
2 changed files with 74 additions and 78 deletions

View File

@ -192,12 +192,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
SetAttachmentInventoryStatus(remoteClient, AttachmentPt, itemID, group);
group.AttachToAgent(remoteClient.AgentId, AttachmentPt, attachPos, silent);
// In case it is later dropped again, don't let
// it get cleaned up
group.RootPart.RemFlag(PrimFlags.TemporaryOnRez);
group.HasGroupChanged = false;
AttachToAgent(sp, group, AttachmentPt, attachPos, silent);
}
else
{
@ -525,6 +520,78 @@ namespace OpenSim.Region.CoreModules.Avatar.Attachments
remoteClient.SendInventoryItemCreateUpdate(item, 0);
}
}
}
}
/// <summary>
/// Attach this scene object to the given avatar.
/// </summary>
///
/// This isn't publicly available since attachments should always perform the corresponding inventory
/// operation (to show the attach in user inventory and update the asset with positional information).
///
/// <param name="sp"></param>
/// <param name="so"></param>
/// <param name="attachmentpoint"></param>
/// <param name="AttachOffset"></param>
/// <param name="silent"></param>
protected void AttachToAgent(ScenePresence avatar, SceneObjectGroup so, uint attachmentpoint, Vector3 AttachOffset, bool silent)
{
// don't attach attachments to child agents
if (avatar.IsChildAgent) return;
// m_log.DebugFormat("[ATTACHMENTS MODULE]: Adding attachment {0} to avatar {1}", Name, avatar.Name);
so.DetachFromBackup();
// Remove from database and parcel prim count
m_scene.DeleteFromStorage(so.UUID);
m_scene.EventManager.TriggerParcelPrimCountTainted();
so.RootPart.AttachedAvatar = avatar.UUID;
//Anakin Lohner bug #3839
lock (so.Children)
{
foreach (SceneObjectPart p in so.Children.Values)
{
p.AttachedAvatar = avatar.UUID;
}
}
if (so.RootPart.PhysActor != null)
{
m_scene.PhysicsScene.RemovePrim(so.RootPart.PhysActor);
so.RootPart.PhysActor = null;
}
so.AbsolutePosition = AttachOffset;
so.RootPart.AttachedPos = AttachOffset;
so.RootPart.IsAttachment = true;
so.RootPart.SetParentLocalId(avatar.LocalId);
so.SetAttachmentPoint(Convert.ToByte(attachmentpoint));
avatar.AddAttachment(so);
if (!silent)
{
// Killing it here will cause the client to deselect it
// It then reappears on the avatar, deselected
// through the full update below
//
if (so.IsSelected)
{
m_scene.SendKillObject(so.RootPart.LocalId);
}
so.IsSelected = false; // fudge....
so.ScheduleGroupForFullUpdate();
}
// In case it is later dropped again, don't let
// it get cleaned up
so.RootPart.RemFlag(PrimFlags.TemporaryOnRez);
so.HasGroupChanged = false;
}
}
}

View File

@ -977,77 +977,6 @@ namespace OpenSim.Region.Framework.Scenes
}
}
/// <summary>
/// Attach this scene object to the given avatar.
/// </summary>
/// <param name="agentID"></param>
/// <param name="attachmentpoint"></param>
/// <param name="AttachOffset"></param>
public void AttachToAgent(UUID agentID, uint attachmentpoint, Vector3 AttachOffset, bool silent)
{
ScenePresence avatar = m_scene.GetScenePresence(agentID);
if (avatar != null)
{
// don't attach attachments to child agents
if (avatar.IsChildAgent) return;
// m_log.DebugFormat("[SOG]: Adding attachment {0} to avatar {1}", Name, avatar.Name);
DetachFromBackup();
// Remove from database and parcel prim count
m_scene.DeleteFromStorage(UUID);
m_scene.EventManager.TriggerParcelPrimCountTainted();
m_rootPart.AttachedAvatar = agentID;
//Anakin Lohner bug #3839
lock (m_parts)
{
foreach (SceneObjectPart p in m_parts.Values)
{
p.AttachedAvatar = agentID;
}
}
if (m_rootPart.PhysActor != null)
{
m_scene.PhysicsScene.RemovePrim(m_rootPart.PhysActor);
m_rootPart.PhysActor = null;
}
AbsolutePosition = AttachOffset;
m_rootPart.AttachedPos = AttachOffset;
m_rootPart.IsAttachment = true;
m_rootPart.SetParentLocalId(avatar.LocalId);
SetAttachmentPoint(Convert.ToByte(attachmentpoint));
avatar.AddAttachment(this);
if (!silent)
{
// Killing it here will cause the client to deselect it
// It then reappears on the avatar, deselected
// through the full update below
//
if (IsSelected)
{
m_scene.SendKillObject(m_rootPart.LocalId);
}
IsSelected = false; // fudge....
ScheduleGroupForFullUpdate();
}
}
else
{
m_log.WarnFormat(
"[SOG]: Tried to add attachment {0} to avatar with UUID {1} in region {2} but the avatar is not present",
UUID, agentID, Scene.RegionInfo.RegionName);
}
}
public byte GetAttachmentPoint()
{
return m_rootPart.Shape.State;