当前位置: 首页>>代码示例>>C#>>正文


C# IScenePresence.GetAttachments方法代码示例

本文整理汇总了C#中IScenePresence.GetAttachments方法的典型用法代码示例。如果您正苦于以下问题:C# IScenePresence.GetAttachments方法的具体用法?C# IScenePresence.GetAttachments怎么用?C# IScenePresence.GetAttachments使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IScenePresence的用法示例。


在下文中一共展示了IScenePresence.GetAttachments方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AttachObjectInternal

        /// <summary>
        /// Internal method which actually does all the work for attaching an object.
        /// </summary>
        /// <returns>The object attached.</returns>
        /// <param name='sp'></param>
        /// <param name='group'>The object to attach.</param>
        /// <param name='attachmentPt'></param>
        /// <param name='silent'></param>
        /// <param name='addToInventory'>If true then add object to user inventory.</param>
        /// <param name='resumeScripts'>If true then scripts are resumed on the attached object.</param>
        /// <param name='append'>Append to attachment point rather than replace.</param>
        private bool AttachObjectInternal(
            IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool addToInventory, bool resumeScripts, bool append)
        {
            if (group.GetSittingAvatarsCount() != 0)
            {
                if (DebugLevel > 0)
                    m_log.WarnFormat(
                        "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since {4} avatars are still sitting on it",
                        group.Name, group.LocalId, sp.Name, attachmentPt, group.GetSittingAvatarsCount());

                return false;
            }

            Vector3 attachPos = group.AbsolutePosition;
            // If the attachment point isn't the same as the one previously used
            // set it's offset position = 0 so that it appears on the attachment point
            // and not in a weird location somewhere unknown.
            if (attachmentPt != (uint)AttachmentPoint.Default && attachmentPt != group.AttachmentPoint)
            {
                attachPos = Vector3.Zero;
            }

            // if the attachment point is the same as previous, make sure we get the saved
            // position info.
            if (attachmentPt != 0 && attachmentPt == group.RootPart.Shape.LastAttachPoint)
            {
                attachPos = group.RootPart.AttachedPos;
            }

            // AttachmentPt 0 means the client chose to 'wear' the attachment.
            if (attachmentPt == (uint)AttachmentPoint.Default)
            {
                // Check object for stored attachment point
                attachmentPt = group.AttachmentPoint;
            }

            // if we didn't find an attach point, look for where it was last attached
            if (attachmentPt == 0)
            {
                attachmentPt = (uint)group.RootPart.Shape.LastAttachPoint;
                attachPos = group.RootPart.AttachedPos;
                group.HasGroupChanged = true;
            }

            // if we still didn't find a suitable attachment point.......
            if (attachmentPt == 0)
            {
                // Stick it on left hand with Zero Offset from the attachment point.
                attachmentPt = (uint)AttachmentPoint.LeftHand;
                attachPos = Vector3.Zero;
            }

            group.AttachmentPoint = attachmentPt;
            group.AbsolutePosition = attachPos;

            List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);

            if (attachments.Contains(group))
            {
                if (DebugLevel > 0)
                    m_log.WarnFormat(
                        "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached",
                        group.Name, group.LocalId, sp.Name, attachmentPt);

                return false;
            }

            // If we already have 5, remove the oldest until only 4 are left. Skip over temp ones
            while (attachments.Count >= 5)
            {
                if (attachments[0].FromItemID != UUID.Zero)
                    DetachSingleAttachmentToInv(sp, attachments[0]);
                attachments.RemoveAt(0);
            }

            // If we're not appending, remove the rest as well
            if (attachments.Count != 0 && !append)
            {
                foreach (SceneObjectGroup g in attachments)
                {
                    if (g.FromItemID != UUID.Zero)
                        DetachSingleAttachmentToInv(sp, g);
                }
            }

            lock (sp.AttachmentsSyncLock)
            {
                if (addToInventory && sp.PresenceType != PresenceType.Npc)
                    UpdateUserInventoryWithAttachment(sp, group, attachmentPt, append);
//.........这里部分代码省略.........
开发者ID:BogusCurry,项目名称:arribasim-dev,代码行数:101,代码来源:AttachmentsModule.cs

示例2: DeRezAttachments

        public void DeRezAttachments(IScenePresence sp)
        {
            if (!Enabled)
                return;

            if (DebugLevel > 0)
                m_log.DebugFormat("[ATTACHMENTS MODULE]: Saving changed attachments for {0}", sp.Name);

            List<SceneObjectGroup> attachments = sp.GetAttachments();

            if (attachments.Count <= 0)
                return;

            Dictionary<SceneObjectGroup, string> scriptStates = new Dictionary<SceneObjectGroup, string>();

            foreach (SceneObjectGroup so in attachments)
            {
                // Scripts MUST be snapshotted before the object is
                // removed from the scene because doing otherwise will
                // clobber the run flag
                // This must be done outside the sp.AttachmentSyncLock so that there is no risk of a deadlock from
                // scripts performing attachment operations at the same time.  Getting object states stops the scripts.
                scriptStates[so] = PrepareScriptInstanceForSave(so, false);
            }

            lock (sp.AttachmentsSyncLock)
            {
                foreach (SceneObjectGroup so in attachments)
                    UpdateDetachedObject(sp, so, scriptStates[so]);
    
                sp.ClearAttachments();
            }
        }
开发者ID:BogusCurry,项目名称:arribasim-dev,代码行数:33,代码来源:AttachmentsModule.cs

示例3: DeleteAttachmentsFromScene

        public void DeleteAttachmentsFromScene(IScenePresence sp, bool silent)
        {
            if (!Enabled)
                return;

            if (DebugLevel > 0)
                m_log.DebugFormat(
                    "[ATTACHMENTS MODULE]: Deleting attachments from scene {0} for {1}, silent = {2}",
                    m_scene.RegionInfo.RegionName, sp.Name, silent);            

            foreach (SceneObjectGroup sop in sp.GetAttachments())
            {
                sop.Scene.DeleteSceneObject(sop, silent);
            }

            sp.ClearAttachments();
        }
开发者ID:BogusCurry,项目名称:arribasim-dev,代码行数:17,代码来源:AttachmentsModule.cs

示例4: CopyAttachments

        public void CopyAttachments(IScenePresence sp, AgentData ad)
        {
            lock (sp.AttachmentsSyncLock)
            {
                // Attachment objects
                List<SceneObjectGroup> attachments = sp.GetAttachments();
                if (attachments.Count > 0)
                {
                    ad.AttachmentObjects = new List<ISceneObject>();
                    ad.AttachmentObjectStates = new List<string>();
    //                IScriptModule se = m_scene.RequestModuleInterface<IScriptModule>();
                    sp.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;
                        ad.AttachmentObjects.Add(clone);
                        string state = sog.GetStateSnapshot();
                        ad.AttachmentObjectStates.Add(state);
                        sp.InTransitScriptStates.Add(state);

                        // Scripts of the originals will be removed when the Agent is successfully removed.
                        // sog.RemoveScriptInstances(true);
                    }
                }
            }
        }
开发者ID:BogusCurry,项目名称:arribasim-dev,代码行数:32,代码来源:AttachmentsModule.cs

示例5: RezAttachments

        public void RezAttachments(IScenePresence sp)
        {
            if (!Enabled)
                return;

            if (null == sp.Appearance)
            {
                m_log.WarnFormat("[ATTACHMENTS MODULE]: Appearance has not been initialized for agent {0}", sp.UUID);

                return;
            }

            if (sp.GetAttachments().Count > 0)
            {
                if (DebugLevel > 0)
                    m_log.DebugFormat(
                        "[ATTACHMENTS MODULE]: Not doing simulator-side attachment rez for {0} in {1} as their viewer has already rezzed attachments", 
                        m_scene.Name, sp.Name);

                  return;
            }

            if (DebugLevel > 0)
                m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing any attachments for {0} from simulator-side", sp.Name);

            List<AvatarAttachment> attachments = sp.Appearance.GetAttachments();
            foreach (AvatarAttachment attach in attachments)
            {
                uint attachmentPt = (uint)attach.AttachPoint;

//                m_log.DebugFormat(
//                    "[ATTACHMENTS MODULE]: Doing initial rez of attachment with itemID {0}, assetID {1}, point {2} for {3} in {4}",
//                    attach.ItemID, attach.AssetID, p, sp.Name, m_scene.RegionInfo.RegionName);

                // For some reason assetIDs are being written as Zero's in the DB -- need to track tat down
                // But they're not used anyway, the item is being looked up for now, so let's proceed.
                //if (UUID.Zero == assetID) 
                //{
                //    m_log.DebugFormat("[ATTACHMENT]: Cannot rez attachment in point {0} with itemID {1}", p, itemID);
                //    continue;
                //}

                try
                {
                    // If we're an NPC then skip all the item checks and manipulations since we don't have an
                    // inventory right now.
                    RezSingleAttachmentFromInventoryInternal(
                        sp, sp.PresenceType == PresenceType.Npc ? UUID.Zero : attach.ItemID, attach.AssetID, attachmentPt, true);
                }
                catch (Exception e)
                {
                    UUID agentId = (sp.ControllingClient == null) ? default(UUID) : sp.ControllingClient.AgentId;
                    m_log.ErrorFormat("[ATTACHMENTS MODULE]: Unable to rez attachment with itemID {0}, assetID {1}, point {2} for {3}: {4}\n{5}",
                        attach.ItemID, attach.AssetID, attachmentPt, agentId, e.Message, e.StackTrace);
                }
            }
        }
开发者ID:BogusCurry,项目名称:arribasim-dev,代码行数:57,代码来源:AttachmentsModule.cs

示例6: UpdateUserInventoryWithAttachment

        private void UpdateUserInventoryWithAttachment(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool temp)
        {
            // Remove any previous attachments
            List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);

            // At the moment we can only deal with a single attachment
            if (attachments.Count != 0)
            {
                if (attachments[0].FromItemID != UUID.Zero)
                    DetachSingleAttachmentToInvInternal(sp, attachments[0]);
            // Error logging commented because UUID.Zero now means temp attachment
//                else
//                    m_log.WarnFormat(
//                        "[ATTACHMENTS MODULE]: When detaching existing attachment {0} {1} at point {2} to make way for {3} {4} for {5}, couldn't find the associated item ID to adjust inventory attachment record!",
//                        attachments[0].Name, attachments[0].LocalId, attachmentPt, group.Name, group.LocalId, sp.Name);
            }

            // Add the new attachment to inventory if we don't already have it.
            if (!temp)
            {
                UUID newAttachmentItemID = group.FromItemID;
                if (newAttachmentItemID == UUID.Zero)
                    newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp, group).ID;

                ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group);
            }
        }
开发者ID:p07r0457,项目名称:opensim,代码行数:27,代码来源:AttachmentsModule.cs

示例7: RezSingleAttachmentFromInventory

        public SceneObjectGroup RezSingleAttachmentFromInventory(IScenePresence sp, UUID itemID, uint AttachmentPt)
        {
            if (!Enabled)
                return null;

//            m_log.DebugFormat(
//                "[ATTACHMENTS MODULE]: RezSingleAttachmentFromInventory to point {0} from item {1} for {2}",
//                (AttachmentPoint)AttachmentPt, itemID, sp.Name);

            // TODO: this short circuits multiple attachments functionality  in  LL viewer 2.1+ and should
            // be removed when that functionality is implemented in opensim
            AttachmentPt &= 0x7f;

            // Viewer 2/3 sometimes asks to re-wear items that are already worn (and show up in it's inventory as such).
            // This often happens during login - not sure the exact reason.
            // For now, we will ignore the request.  Unfortunately, this means that we need to dig through all the
            // ScenePresence attachments.  We can't use the data in AvatarAppearance because that's present at login
            // before anything has actually been attached.
            bool alreadyOn = false;
            List<SceneObjectGroup> existingAttachments = sp.GetAttachments();
            foreach (SceneObjectGroup so in existingAttachments)
            {
                if (so.FromItemID == itemID)
                {
                    alreadyOn = true;
                    break;
                }
            }

//            if (sp.Appearance.GetAttachmentForItem(itemID) != null)
            if (alreadyOn)
            {
//                m_log.WarnFormat(
//                    "[ATTACHMENTS MODULE]: Ignoring request by {0} to wear item {1} at {2} since it is already worn",
//                    sp.Name, itemID, AttachmentPt);

                return null;
            }

            return RezSingleAttachmentFromInventoryInternal(sp, itemID, UUID.Zero, AttachmentPt);
        }
开发者ID:p07r0457,项目名称:opensim,代码行数:41,代码来源:AttachmentsModule.cs

示例8: DeRezAttachments

        public void DeRezAttachments(IScenePresence sp)
        {
            if (!Enabled)
                return;

//            m_log.DebugFormat("[ATTACHMENTS MODULE]: Saving changed attachments for {0}", sp.Name);

            lock (sp.AttachmentsSyncLock)
            {
                foreach (SceneObjectGroup so in sp.GetAttachments())
                {
                    UpdateDetachedObject(sp, so);
                }
    
                sp.ClearAttachments();
            }
        }
开发者ID:p07r0457,项目名称:opensim,代码行数:17,代码来源:AttachmentsModule.cs

示例9: AttachObjectInternal

        private bool AttachObjectInternal(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent, bool temp)
        {
            lock (sp.AttachmentsSyncLock)
            {
//                m_log.DebugFormat(
//                    "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})",
//                    group.Name, group.LocalId, sp.Name, attachmentPt, silent);

                if (group.GetSittingAvatarsCount() != 0)
                {
//                    m_log.WarnFormat(
//                        "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since {4} avatars are still sitting on it",
//                        group.Name, group.LocalId, sp.Name, attachmentPt, group.GetSittingAvatarsCount());
    
                    return false;
                }
    
                if (sp.GetAttachments(attachmentPt).Contains(group))
                {
    //                m_log.WarnFormat(
    //                    "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached",
    //                    group.Name, group.LocalId, sp.Name, AttachmentPt);
    
                    return false;
                }
    
                Vector3 attachPos = group.AbsolutePosition;
    
                // TODO: this short circuits multiple attachments functionality  in  LL viewer 2.1+ and should
                // be removed when that functionality is implemented in opensim
                attachmentPt &= 0x7f;
                
                // If the attachment point isn't the same as the one previously used
                // set it's offset position = 0 so that it appears on the attachment point
                // and not in a weird location somewhere unknown.
                if (attachmentPt != 0 && attachmentPt != group.AttachmentPoint)
                {
                    attachPos = Vector3.Zero;
                }
    
                // AttachmentPt 0 means the client chose to 'wear' the attachment.
                if (attachmentPt == 0)
                {
                    // Check object for stored attachment point
                    attachmentPt = group.AttachmentPoint;
                }
    
                // if we still didn't find a suitable attachment point.......
                if (attachmentPt == 0)
                {
                    // Stick it on left hand with Zero Offset from the attachment point.
                    attachmentPt = (uint)AttachmentPoint.LeftHand;
                    attachPos = Vector3.Zero;
                }
    
                group.AttachmentPoint = attachmentPt;
                group.AbsolutePosition = attachPos;

                if (sp.PresenceType != PresenceType.Npc)
                    UpdateUserInventoryWithAttachment(sp, group, attachmentPt, temp);
    
                AttachToAgent(sp, group, attachmentPt, attachPos, silent);
            }

            return true;
        }
开发者ID:p07r0457,项目名称:opensim,代码行数:66,代码来源:AttachmentsModule.cs

示例10: RezAttachments

        public void RezAttachments(IScenePresence sp)
        {
            if (!Enabled)
                return;

            if (null == sp.Appearance)
            {
                m_log.WarnFormat("[ATTACHMENTS MODULE]: Appearance has not been initialized for agent {0}", sp.UUID);

                return;
            }

            if (sp.GetAttachments().Count > 0)
            {
                if (DebugLevel > 0)
                    m_log.DebugFormat(
                        "[ATTACHMENTS MODULE]: Not doing simulator-side attachment rez for {0} in {1} as their viewer has already rezzed attachments", 
                        m_scene.Name, sp.Name);

                  return;
            }

            if (DebugLevel > 0)
                m_log.DebugFormat("[ATTACHMENTS MODULE]: Rezzing any attachments for {0} from simulator-side", sp.Name);

            XmlDocument doc = new XmlDocument();
            string stateData = String.Empty;

            IAttachmentsService attServ = m_scene.RequestModuleInterface<IAttachmentsService>();
            if (attServ != null)
            {
                m_log.DebugFormat("[ATTACHMENT]: Loading attachment data from attachment service");
                stateData = attServ.Get(sp.UUID.ToString());
                if (stateData != String.Empty)
                {
                    try
                    {
                        doc.LoadXml(stateData);
                    }
                    catch { }
                }
            }

            Dictionary<UUID, string> itemData = new Dictionary<UUID, string>();

            XmlNodeList nodes = doc.GetElementsByTagName("Attachment");
            if (nodes.Count > 0)
            {
                foreach (XmlNode n in nodes)
                {
                    XmlElement elem = (XmlElement)n;
                    string itemID = elem.GetAttribute("ItemID");
                    string xml = elem.InnerXml;

                    itemData[new UUID(itemID)] = xml;
                }
            }


            List<AvatarAttachment> attachments = sp.Appearance.GetAttachments();

            // Let's get all items at once, so they get cached
            UUID[] items = new UUID[attachments.Count];
            int i = 0;
            foreach (AvatarAttachment attach in attachments)
                items[i++] = attach.ItemID;
            m_scene.InventoryService.GetMultipleItems(sp.UUID, items);

            foreach (AvatarAttachment attach in attachments)
            {
                uint attachmentPt = (uint)attach.AttachPoint;

//                m_log.DebugFormat(
//                    "[ATTACHMENTS MODULE]: Doing initial rez of attachment with itemID {0}, assetID {1}, point {2} for {3} in {4}",
//                    attach.ItemID, attach.AssetID, p, sp.Name, m_scene.RegionInfo.RegionName);

                // For some reason assetIDs are being written as Zero's in the DB -- need to track tat down
                // But they're not used anyway, the item is being looked up for now, so let's proceed.
                //if (UUID.Zero == assetID) 
                //{
                //    m_log.DebugFormat("[ATTACHMENT]: Cannot rez attachment in point {0} with itemID {1}", p, itemID);
                //    continue;
                //}

                try
                {
                    string xmlData;
                    XmlDocument d = null;
                    UUID asset;
                    if (itemData.TryGetValue(attach.ItemID, out xmlData))
                    {
                        d = new XmlDocument();
                        d.LoadXml(xmlData);
                        m_log.InfoFormat("[ATTACHMENT]: Found saved state for item {0}, loading it", attach.ItemID);
                    }

                    // If we're an NPC then skip all the item checks and manipulations since we don't have an
                    // inventory right now.
                    RezSingleAttachmentFromInventoryInternal(
                        sp, sp.PresenceType == PresenceType.Npc ? UUID.Zero : attach.ItemID, attach.AssetID, attachmentPt, true, d);
//.........这里部分代码省略.........
开发者ID:emperorstarfinder,项目名称:Opensim2,代码行数:101,代码来源:AttachmentsModule.cs

示例11: AttachObject

        public bool AttachObject(IScenePresence sp, SceneObjectGroup group, uint attachmentPt, bool silent)
        {
            lock (sp.AttachmentsSyncLock)
            {
//                m_log.DebugFormat(
//                    "[ATTACHMENTS MODULE]: Attaching object {0} {1} to {2} point {3} from ground (silent = {4})",
//                    group.Name, group.LocalId, sp.Name, attachmentPt, silent);
    
                if (sp.GetAttachments(attachmentPt).Contains(group))
                {
    //                m_log.WarnFormat(
    //                    "[ATTACHMENTS MODULE]: Ignoring request to attach {0} {1} to {2} on {3} since it's already attached",
    //                    group.Name, group.LocalId, sp.Name, AttachmentPt);
    
                    return false;
                }
    
                Vector3 attachPos = group.AbsolutePosition;
    
                // TODO: this short circuits multiple attachments functionality  in  LL viewer 2.1+ and should
                // be removed when that functionality is implemented in opensim
                attachmentPt &= 0x7f;
                
                // If the attachment point isn't the same as the one previously used
                // set it's offset position = 0 so that it appears on the attachment point
                // and not in a weird location somewhere unknown.
                if (attachmentPt != 0 && attachmentPt != group.AttachmentPoint)
                {
                    attachPos = Vector3.Zero;
                }
    
                // AttachmentPt 0 means the client chose to 'wear' the attachment.
                if (attachmentPt == 0)
                {
                    // Check object for stored attachment point
                    attachmentPt = group.AttachmentPoint;
                }
    
                // if we still didn't find a suitable attachment point.......
                if (attachmentPt == 0)
                {
                    // Stick it on left hand with Zero Offset from the attachment point.
                    attachmentPt = (uint)AttachmentPoint.LeftHand;
                    attachPos = Vector3.Zero;
                }
    
                group.AttachmentPoint = attachmentPt;
                group.AbsolutePosition = attachPos;
    
                // We also don't want to do any of the inventory operations for an NPC.
                if (sp.PresenceType != PresenceType.Npc)
                {
                    // Remove any previous attachments
                    List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);
    
                    // At the moment we can only deal with a single attachment
                    if (attachments.Count != 0)
                    {
                        UUID oldAttachmentItemID = attachments[0].GetFromItemID();
        
                        if (oldAttachmentItemID != UUID.Zero)
                            DetachSingleAttachmentToInvInternal(sp, oldAttachmentItemID);
                        else
                            m_log.WarnFormat(
                                "[ATTACHMENTS MODULE]: When detaching existing attachment {0} {1} at point {2} to make way for {3} {4} for {5}, couldn't find the associated item ID to adjust inventory attachment record!",
                                attachments[0].Name, attachments[0].LocalId, attachmentPt, group.Name, group.LocalId, sp.Name);
                    }
    
                    // Add the new attachment to inventory if we don't already have it.
                    UUID newAttachmentItemID = group.GetFromItemID();
                    if (newAttachmentItemID == UUID.Zero)
                        newAttachmentItemID = AddSceneObjectAsNewAttachmentInInv(sp, group).ID;
        
                    ShowAttachInUserInventory(sp, attachmentPt, newAttachmentItemID, group);
                }
    
                AttachToAgent(sp, group, attachmentPt, attachPos, silent);
            }

            return true;
        }
开发者ID:4U2NV,项目名称:opensim,代码行数:81,代码来源:AttachmentsModule.cs

示例12: SaveChangedAttachments

        public void SaveChangedAttachments(IScenePresence sp)
        {
//            m_log.DebugFormat("[ATTACHMENTS MODULE]: Saving changed attachments for {0}", sp.Name);

            if (!Enabled)
                return;

            foreach (SceneObjectGroup grp in sp.GetAttachments())
            {
//                if (grp.HasGroupChanged) // Resizer scripts?
//                {
                    grp.IsAttachment = false;
                    grp.AbsolutePosition = grp.RootPart.AttachedPos;
                    UpdateKnownItem(sp, grp);
                    grp.IsAttachment = true;
//                }
            }
        }
开发者ID:4U2NV,项目名称:opensim,代码行数:18,代码来源:AttachmentsModule.cs

示例13: DeRezAttachments

        public void DeRezAttachments(IScenePresence sp, bool saveChanged, bool saveAllScripted)
        {
            if (!Enabled)
                return;

//            m_log.DebugFormat("[ATTACHMENTS MODULE]: Saving changed attachments for {0}", sp.Name);

            lock (sp.AttachmentsSyncLock)
            {
                foreach (SceneObjectGroup grp in sp.GetAttachments())
                {
                    grp.Scene.DeleteSceneObject(grp, false);
    
                    if (saveChanged || saveAllScripted)
                    {
                        grp.IsAttachment = false;
                        grp.AbsolutePosition = grp.RootPart.AttachedPos;
                        UpdateKnownItem(sp, grp, saveAllScripted);
                    }
                }
    
                sp.ClearAttachments();
            }
        }
开发者ID:JAllard,项目名称:opensim,代码行数:24,代码来源:AttachmentsModule.cs

示例14: RezSingleAttachmentFromInventoryInternal

        private SceneObjectGroup RezSingleAttachmentFromInventoryInternal(
            IScenePresence sp, UUID itemID, UUID assetID, uint attachmentPt)
        {
            if (m_invAccessModule == null)
                return null;

            SceneObjectGroup objatt;

            if (itemID != UUID.Zero)
                objatt = m_invAccessModule.RezObject(sp.ControllingClient,
                    itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
                    false, false, sp.UUID, true);
            else
                objatt = m_invAccessModule.RezObject(sp.ControllingClient,
                    null, assetID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
                    false, false, sp.UUID, true);

            if (objatt == null)
            {
                m_log.WarnFormat(
                    "[ATTACHMENTS MODULE]: Could not retrieve item {0} for attaching to avatar {1} at point {2}",
                    itemID, sp.Name, attachmentPt);

                return null;
            }

            // Remove any previous attachments
            List<SceneObjectGroup> attachments = sp.GetAttachments(attachmentPt);

            // At the moment we can only deal with a single attachment
            if (attachments.Count != 0)
                DetachSingleAttachmentToInv(sp, attachments[0]);

            lock (sp.AttachmentsSyncLock)
            {
//                    m_log.DebugFormat(
//                        "[ATTACHMENTS MODULE]: Rezzed single object {0} for attachment to {1} on point {2} in {3}",
//                        objatt.Name, sp.Name, attachmentPt, m_scene.Name);

                // HasGroupChanged is being set from within RezObject.  Ideally it would be set by the caller.
                objatt.HasGroupChanged = false;
                bool tainted = false;
                if (attachmentPt != 0 && attachmentPt != objatt.AttachmentPoint)
                    tainted = true;

                // FIXME: Detect whether it's really likely for AttachObject to throw an exception in the normal
                // course of events.  If not, then it's probably not worth trying to recover the situation
                // since this is more likely to trigger further exceptions and confuse later debugging.  If
                // exceptions can be thrown in expected error conditions (not NREs) then make this consistent
                // since other normal error conditions will simply return false instead.
                // This will throw if the attachment fails
                try
                {
                    AttachObjectInternal(sp, objatt, attachmentPt, false, false);
                }
                catch (Exception e)
                {
                    m_log.ErrorFormat(
                        "[ATTACHMENTS MODULE]: Failed to attach {0} {1} for {2}, exception {3}{4}",
                        objatt.Name, objatt.UUID, sp.Name, e.Message, e.StackTrace);

                    // Make sure the object doesn't stick around and bail
                    sp.RemoveAttachment(objatt);
                    m_scene.DeleteSceneObject(objatt, false);
                    return null;
                }

                if (tainted)
                    objatt.HasGroupChanged = true;

                // Fire after attach, so we don't get messy perms dialogs
                // 4 == AttachedRez
                objatt.CreateScriptInstances(0, true, m_scene.DefaultScriptEngine, 4);
                objatt.ResumeScripts();

                // Do this last so that event listeners have access to all the effects of the attachment
                m_scene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, sp.UUID);

                return objatt;
            }
        }
开发者ID:rryk,项目名称:omp-server,代码行数:81,代码来源:AttachmentsModule.cs


注:本文中的IScenePresence.GetAttachments方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。