mirror of
https://github.com/opensim/opensim.git
synced 2026-08-11 20:05:33 +08:00
refactor: Move ScenePresence <-> AgentData attachments copying code into AttachmentsModule.
This commit is contained in:
@@ -3084,31 +3084,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
}
|
||||
catch { }
|
||||
|
||||
// Attachment objects
|
||||
List<SceneObjectGroup> attachments = GetAttachments();
|
||||
if (attachments.Count > 0)
|
||||
{
|
||||
cAgent.AttachmentObjects = new List<ISceneObject>();
|
||||
cAgent.AttachmentObjectStates = new List<string>();
|
||||
// IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>();
|
||||
InTransitScriptStates.Clear();
|
||||
|
||||
foreach (SceneObjectGroup sog in attachments)
|
||||
{
|
||||
// We need to make a copy and pass that copy
|
||||
// because of transfers withn the same sim
|
||||
ISceneObject clone = sog.CloneForNewScene();
|
||||
// Attachment module assumes that GroupPosition holds the offsets...!
|
||||
((SceneObjectGroup)clone).RootPart.GroupPosition = sog.RootPart.AttachedPos;
|
||||
((SceneObjectGroup)clone).IsAttachment = false;
|
||||
cAgent.AttachmentObjects.Add(clone);
|
||||
string state = sog.GetStateSnapshot();
|
||||
cAgent.AttachmentObjectStates.Add(state);
|
||||
InTransitScriptStates.Add(state);
|
||||
// Let's remove the scripts of the original object here
|
||||
sog.RemoveScriptInstances(true);
|
||||
}
|
||||
}
|
||||
if (Scene.AttachmentsModule != null)
|
||||
Scene.AttachmentsModule.CopyAttachments(this, cAgent);
|
||||
}
|
||||
|
||||
private void CopyFrom(AgentData cAgent)
|
||||
@@ -3178,18 +3155,8 @@ namespace OpenSim.Region.Framework.Scenes
|
||||
if (cAgent.Anims != null)
|
||||
Animator.Animations.FromArray(cAgent.Anims);
|
||||
|
||||
if (cAgent.AttachmentObjects != null && cAgent.AttachmentObjects.Count > 0)
|
||||
{
|
||||
m_attachments = new List<SceneObjectGroup>();
|
||||
int i = 0;
|
||||
foreach (ISceneObject so in cAgent.AttachmentObjects)
|
||||
{
|
||||
((SceneObjectGroup)so).LocalId = 0;
|
||||
((SceneObjectGroup)so).RootPart.ClearUpdateSchedule();
|
||||
so.SetState(cAgent.AttachmentObjectStates[i++], m_scene);
|
||||
m_scene.IncomingCreateObject(Vector3.Zero, so);
|
||||
}
|
||||
}
|
||||
if (Scene.AttachmentsModule != null)
|
||||
Scene.AttachmentsModule.CopyAttachments(cAgent, this);
|
||||
}
|
||||
|
||||
public bool CopyAgent(out IAgentData agent)
|
||||
|
||||
Reference in New Issue
Block a user