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


C# SceneObjectGroup.Clear方法代码示例

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


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

示例1: DeleteSceneObject

        /// <summary>
        /// Synchronously delete the given object from the scene.
        /// </summary>
        /// <param name="group">Object Id</param>
        /// <param name="silent">Suppress broadcasting changes to other clients.</param>
        /// <param name="removeScripts">If true, then scripts are removed.  If false, then they are only stopped.</para>
        public void DeleteSceneObject(SceneObjectGroup group, bool silent, bool removeScripts)
        {
            // m_log.DebugFormat("[SCENE]: Deleting scene object {0} {1}", group.Name, group.UUID);

            if (removeScripts)
                group.RemoveScriptInstances(true);
            else
                group.StopScriptInstances();

            List<ScenePresence> avatars = group.GetSittingAvatars();
            foreach (ScenePresence av in avatars)
            {
                if(av.ParentUUID == UUID.Zero)
                    av.StandUp();
            }

            SceneObjectPart[] partList = group.Parts;

            foreach (SceneObjectPart part in partList)
            {
                if (part.KeyframeMotion != null)
                {
                    part.KeyframeMotion.Delete();
                    part.KeyframeMotion = null;
                }

                if (part.IsJoint() && ((part.Flags & PrimFlags.Physics) != 0))
                {
                    PhysicsScene.RequestJointDeletion(part.Name); // FIXME: what if the name changed?
                }
                else if (part.PhysActor != null)
                {
                    part.RemoveFromPhysics();
                }
            }

            if (UnlinkSceneObject(group, false))
            {
                EventManager.TriggerObjectBeingRemovedFromScene(group);
                EventManager.TriggerParcelPrimCountTainted();
            }

            group.DeleteGroupFromScene(silent);

            // use this to mean also full delete
            if (removeScripts)
                group.Clear();
            partList = null;
            // m_log.DebugFormat("[SCENE]: Exit DeleteSceneObject() for {0} {1}", group.Name, group.UUID);          
        }
开发者ID:emperorstarfinder,项目名称:Opensim2,代码行数:56,代码来源:Scene.cs

示例2: DetachSingleAttachmentToInv

        public void DetachSingleAttachmentToInv(IScenePresence sp, SceneObjectGroup so)
        {
            if (so.AttachedAvatar != sp.UUID)
            {
                m_log.WarnFormat(
                    "[ATTACHMENTS MODULE]: Tried to detach object {0} from {1} {2} but attached avatar id was {3} in {4}",
                    so.Name, sp.Name, sp.UUID, so.AttachedAvatar, m_scene.RegionInfo.RegionName);

                return;
            }

            // If this didn't come from inventory, it also shouldn't go there
            // on detach. It's likely a temp attachment.
            if (so.FromItemID == UUID.Zero)
            {
                // Retirn value is ignored
                PrepareScriptInstanceForSave(so, true);

                lock (sp.AttachmentsSyncLock)
                {
                    bool changed = sp.Appearance.DetachAttachment(so.FromItemID);
                    if (changed && m_scene.AvatarFactory != null)
                        m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID);

                    sp.RemoveAttachment(so);
                }

                m_scene.DeleteSceneObject(so, false, false);
                so.RemoveScriptInstances(true);
                so.Clear();

                return;
            }

            if (DebugLevel > 0)
                m_log.DebugFormat(
                    "[ATTACHMENTS MODULE]: Detaching object {0} {1} (FromItemID {2}) for {3} in {4}", 
                    so.Name, so.LocalId, so.FromItemID, sp.Name, m_scene.Name);

            // 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.
            string scriptedState = PrepareScriptInstanceForSave(so, true);

            lock (sp.AttachmentsSyncLock)
            {
                // Save avatar attachment information
//                m_log.Debug("[ATTACHMENTS MODULE]: Detaching from UserID: " + sp.UUID + ", ItemID: " + itemID);

                bool changed = sp.Appearance.DetachAttachment(so.FromItemID);
                if (changed && m_scene.AvatarFactory != null)
                    m_scene.AvatarFactory.QueueAppearanceSave(sp.UUID);

                sp.RemoveAttachment(so);
                UpdateDetachedObject(sp, so, scriptedState);
            }
        }
开发者ID:emperorstarfinder,项目名称:Opensim2,代码行数:59,代码来源:AttachmentsModule.cs

示例3: CrossAsync


//.........这里部分代码省略.........
                if(!entityTransfer.checkAgentAccessToRegion(av, destination, newpos, ctx, out reason))
                {
                    return sog;
                }
                m_log.DebugFormat("[SCENE OBJECT]: Avatar {0} needs to be crossed to {1}", av.Name, destination.RegionName);
            }

            // We unparent the SP quietly so that it won't
            // be made to stand up

            List<avtocrossInfo> avsToCross = new List<avtocrossInfo>();

            foreach (ScenePresence av in sog.m_sittingAvatars)
            {
                byte cflags = 1;

                avtocrossInfo avinfo = new avtocrossInfo();
                SceneObjectPart parentPart = sogScene.GetSceneObjectPart(av.ParentID);
                if (parentPart != null)
                {
                    av.ParentUUID = parentPart.UUID;
                    if(parentPart.SitTargetAvatar == av.UUID)
                        cflags = 7; // low 3 bits set
                    else
                        cflags = 3;
                }

                // 1 is crossing
                // 2 is sitting
                // 4 is sitting at sittarget
                av.crossingFlags = cflags;

                avinfo.av = av;
                avinfo.ParentID = av.ParentID;
                avsToCross.Add(avinfo);

                av.PrevSitOffset = av.OffsetPosition;
                av.ParentID = 0;
            }

            if (entityTransfer.CrossPrimGroupIntoNewRegion(destination, newpos, sog, true, false))
            {
                foreach (avtocrossInfo avinfo in avsToCross)
                {
                    ScenePresence av = avinfo.av;
                    if (!av.IsInTransit) // just in case...
                    {
                        m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar {0} to {1}", av.Name, val);

                        av.IsInTransit = true;

//                        CrossAgentToNewRegionDelegate d = entityTransfer.CrossAgentToNewRegionAsync;
//                        d.BeginInvoke(av, val, destination, av.Flying, version, CrossAgentToNewRegionCompleted, d);
                        entityTransfer.CrossAgentToNewRegionAsync(av, newpos, destination, av.Flying, ctx);
                        if (av.IsChildAgent)
                        {
                            // avatar crossed do some extra cleanup
                            if (av.ParentUUID != UUID.Zero)
                            {
                                av.ClearControls();
                                av.ParentPart = null;
                            }
                        }
                        else
                        {
                            // avatar cross failed we need do dedicated standUp
                            // part of it was done at CrossAgentToNewRegionAsync
                            // so for now just remove the sog controls
                            // this may need extra care 
                            av.UnRegisterSeatControls(sog.UUID);
                        }

                        av.ParentUUID = UUID.Zero;
                        // In any case
                        av.IsInTransit = false;
                        av.crossingFlags = 0;
                        m_log.DebugFormat("[SCENE OBJECT]: Crossing agent {0} {1} completed.", av.Firstname, av.Lastname);
                    }
                    else
                        m_log.DebugFormat("[SCENE OBJECT]: Crossing avatar already in transit {0} to {1}", av.Name, val);
                }
                avsToCross.Clear();
                sog.RemoveScriptInstances(true);
                sog.Clear();
                return sog;
            }
            else // cross failed, put avas back ??
            {
                foreach (avtocrossInfo avinfo in avsToCross)
                {
                    ScenePresence av = avinfo.av;
                    av.ParentUUID = UUID.Zero;
                    av.ParentID = avinfo.ParentID;
                    av.crossingFlags = 0;
                }
            }
            avsToCross.Clear();

            return sog;
        }
开发者ID:emperorstarfinder,项目名称:Opensim2,代码行数:101,代码来源:SceneObjectGroup.cs

示例4: UpdateDetachedObject

        private void UpdateDetachedObject(IScenePresence sp, SceneObjectGroup so, string scriptedState)
        {
            // Don't save attachments for HG visitors, it
            // messes up their inventory. When a HG visitor logs
            // out on a foreign grid, their attachments will be
            // reloaded in the state they were in when they left
            // the home grid. This is best anyway as the visited
            // grid may use an incompatible script engine.
            bool saveChanged
                    = sp.PresenceType != PresenceType.Npc
                    && (m_scene.UserManagementModule == null
                    || m_scene.UserManagementModule.IsLocalGridUser(sp.UUID));

            // Remove the object from the scene so no more updates
            // are sent. Doing this before the below changes will ensure
            // updates can't cause "HUD artefacts"
           
            m_scene.DeleteSceneObject(so, false, false);

            // Prepare sog for storage
            so.AttachedAvatar = UUID.Zero;
            so.RootPart.SetParentLocalId(0);
            so.IsAttachment = false;

            if (saveChanged)
            {
                // We cannot use AbsolutePosition here because that would
                // attempt to cross the prim as it is detached
                so.ForEachPart(x => { x.GroupPosition = so.RootPart.AttachedPos; });

                UpdateKnownItem(sp, so, scriptedState);
            }

            // Now, remove the scripts
            so.RemoveScriptInstances(true);
            so.Clear();
        }
开发者ID:emperorstarfinder,项目名称:Opensim2,代码行数:37,代码来源:AttachmentsModule.cs


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