Universe.Region.SceneObjectGroup.Copy C# (CSharp) Method

Copy() public method

Make an exact copy of this group. This does NOT reset any UUIDs, localIDs, or anything, as this is an EXACT copy.
public Copy ( bool clonePhys ) : ISceneEntity
clonePhys bool
return ISceneEntity
        public ISceneEntity Copy(bool clonePhys)
        {
            SceneObjectGroup dupe = (SceneObjectGroup) MemberwiseClone();

            dupe.m_parts = new Dictionary<UUID, SceneObjectPart>();
            dupe.m_partsList = new List<SceneObjectPart>();

            dupe.m_scene = Scene;

            // Warning, The following code related to previousAttachmentStatus is needed so that clones of 
            // attachments do not bordercross while they're being duplicated.  This is hacktastic!
            // Normally, setting AbsolutePosition will bordercross a prim if it's outside the region!
            // unless IsAttachment is true!, so to prevent border crossing, we save it's attachment state 
            // (which should be false anyway) set it as an Attachment and then set it's Absolute Position, 
            // then restore it's attachment state

            // This is only necessary when userExposed is false!

            dupe.ClearChildren();

            dupe.AddChild(m_rootPart.Copy(dupe, clonePhys), m_rootPart.LinkNum);

            bool previousAttachmentStatus = dupe.RootPart.IsAttachment;

            dupe.RootPart.IsAttachment = true;

            dupe.AbsolutePosition = AbsolutePosition;

            dupe.RootPart.IsAttachment = previousAttachmentStatus;

            dupe.m_rootPart.TrimPermissions();

            List<SceneObjectPart> partList = new List<SceneObjectPart>();

            lock (m_partsLock)
            {
                partList.AddRange(m_partsList);
            }

            //Sort the list by link number so that we get them in the right order
            partList.Sort(Scene.SceneGraph.LinkSetSorter);

            foreach (SceneObjectPart part in partList)
            {
                if (part.UUID != m_rootPart.UUID)
                {
                    SceneObjectPart copy = part.Copy(dupe, clonePhys);
                    copy.LinkNum = part.LinkNum;
                    dupe.LinkChild(copy);
                }
            }
            dupe.m_ValidgrpOOB = false;

            return dupe;
        }
SceneObjectGroup