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


C# LLAgent.GetChildren方法代码示例

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


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

示例1: ObjectAttachHandler

        void ObjectAttachHandler(Packet packet, LLAgent agent)
        {
            ObjectAttachPacket attach = (ObjectAttachPacket)packet;

            for (int i = 0; i < attach.ObjectData.Length; i++)
            {
                ObjectAttachPacket.ObjectDataBlock block = attach.ObjectData[i];

                ISceneEntity entity;
                if (m_scene.TryGetEntity(block.ObjectLocalID, out entity) && entity is LLPrimitive)
                {
                    LLPrimitive obj = (LLPrimitive)entity;

                    // Permission check
                    if (obj.OwnerID != agent.ID)
                    {
                        m_log.Warn(agent.Name + " tried to attach " + obj.ID + " owned by " + obj.OwnerID);
                        continue;
                    }

                    // Sanity checks
                    if (obj.Parent != null)
                    {
                        m_log.Warn(agent.Name + " tried to attach child prim " + obj.ID);
                        continue;
                    }
                    ILinkable[] childObjs = obj.GetChildren();
                    for (int j = 0; j < childObjs.Length; j++)
                    {
                        if (childObjs[i] is IScenePresence)
                        {
                            m_log.Warn(agent.Name + " attempted to attach " + obj.ID + " with an avatar sitting on it");
                            continue;
                        }
                    }

                    // Determine what attach point to use
                    AttachmentPoint requestedAttachPoint = (AttachmentPoint)attach.AgentData.AttachmentPoint;
                    AttachmentPoint attachPoint = (requestedAttachPoint == AttachmentPoint.Default ? obj.LastAttachmentPoint : requestedAttachPoint);
                    if (attachPoint == AttachmentPoint.Default)
                        attachPoint = AttachmentPoint.RightHand;

                    // If we are attaching to a new attachment point, reset the attachment position and rotation for this object
                    if (attachPoint != obj.LastAttachmentPoint)
                    {
                        obj.AttachmentPosition = Vector3.Zero;
                        obj.AttachmentRotation = Quaternion.Identity;
                    }

                    // Check if something is already attached to the target attachment point
                    ILinkable[] attachments = agent.GetChildren();
                    for (int j = 0; j < attachments.Length; j++)
                    {
                        if (attachments[j] is LLPrimitive)
                        {
                            LLPrimitive primAttachment = (LLPrimitive)attachments[j];
                            if (primAttachment.Prim.PrimData.AttachmentPoint == attachPoint)
                            {
                                DetachObject(agent, primAttachment);
                                break;
                            }
                        }
                    }

                    // Attaching destroys undo history
                    obj.ClearUndoHistory();

                    // Set the attachment point
                    obj.Prim.PrimData.AttachmentPoint = attachPoint;
                    obj.LastAttachmentPoint = attachPoint;
                    obj.BeforeAttachmentRotation = block.Rotation;

                    // Create the inventory item for this attachment
                    if (m_inventory != null)
                    {
                        // Serialize this prim and any children
                        string contentType = LLUtil.LLAssetTypeToContentType((int)AssetType.Object);
                        byte[] assetData = System.Text.Encoding.UTF8.GetBytes(
                            OpenMetaverse.StructuredData.OSDParser.SerializeJsonString(LLPrimitive.SerializeLinkset(obj)));

                        LLInventoryItem item = m_inventory.ObjectToInventory(agent.ID, obj, assetData, contentType, (uint)attachPoint, true, UUID.Zero, UUID.Zero, false, 0);

                        if (item != null)
                        {
                            obj.Prim.Properties.ItemID = item.ID;
                            obj.Prim.Properties.FolderID = item.ParentID;
                        }
                        else
                        {
                            m_log.Warn(agent.Name + " failed to store attachment " + obj.ID + " to inventory");
                        }
                    }

                    // Do the actual attachment
                    obj.RelativePosition = obj.AttachmentPosition;
                    obj.RelativeRotation = obj.AttachmentRotation;
                    obj.SetParent(agent, false, false);

                    // Send an update out to everyone
                    m_scene.EntityAddOrUpdate(this, obj, UpdateFlags.Parent | UpdateFlags.Position | UpdateFlags.Rotation, (uint)LLUpdateFlags.AttachmentPoint);
//.........这里部分代码省略.........
开发者ID:osgrid,项目名称:openmetaverse,代码行数:101,代码来源:Objects.cs


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