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


C# SceneObjectGroup.GetNewItemPermissions方法代码示例

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


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

示例1: AttachObjectAssetStore

        public UUID AttachObjectAssetStore(IClientAPI remoteClient, SceneObjectGroup grp, UUID AgentId, UUID destFolderID, out UUID itemID)
        {
            itemID = UUID.Zero;
            if (grp != null)
            {
                byte[] sceneObjectData = this.DoSerializeSingleGroup(grp, SerializationFlags.None);

                CachedUserInfo userInfo =
                    CommsManager.UserService.GetUserDetails(AgentId);
                
                if (userInfo != null)
                {
                    AssetBase asset = CreateAsset(
                        grp.GetPartName(grp.LocalId),
                        grp.GetPartDescription(grp.LocalId),
                        (sbyte)AssetType.Object,
                        sceneObjectData);

                    try
                    {
                        CommsManager.AssetCache.AddAsset(asset, AssetRequestInfo.InternalRequest());
                    }
                    catch (AssetServerException e)
                    {
                        m_log.ErrorFormat("[ATTACHMENT] Unable to attach object. Storing asset failed: {0}", e);
                        return UUID.Zero;
                    }

                    if (destFolderID != UUID.Zero)
                    {
                        //make sure we own the folder this item is headed to and that it exists
                        try
                        {
                            //will throw InventorySecurityException, or InventoryObjectMissingException
                            //if something is wrong
                            userInfo.GetFolderAttributesChecked(destFolderID);
                        }
                        catch (Exception)
                        {
                            destFolderID = UUID.Zero;
                        }
                    }

                    if (destFolderID == UUID.Zero)
                    {
                        InventoryFolderBase objFolder = userInfo.FindFolderForType((int)InventoryType.Object);
                        destFolderID = objFolder.ID;
                    }

                    InventoryItemBase item = new InventoryItemBase();
                    item.CreatorId = grp.RootPart.CreatorID.ToString();
                    item.Owner = remoteClient.AgentId;
                    item.ID = UUID.Random();
                    item.AssetID = asset.FullID;
                    item.Description = asset.Description;
                    item.Name = asset.Name;
                    item.AssetType = asset.Type;
                    item.InvType = (int)InventoryType.Object;

                    item.Folder = destFolderID;
                    item.CreationDate = Util.UnixTimeSinceEpoch();

                    ItemPermissionBlock newPerms = grp.GetNewItemPermissions(remoteClient.AgentId);
                    newPerms.ApplyToOther(item);

                    // sets assetID so client can show asset as 'attached' in inventory
                    grp.SetFromItemID(item.ID);

                    userInfo.AddItem(item);
                    remoteClient.SendInventoryItemCreateUpdate(item, 0);

                    itemID = item.ID;
                    return item.AssetID;
                }
                return UUID.Zero;
            }
            return UUID.Zero;
        }
开发者ID:MatthewBeardmore,项目名称:halcyon,代码行数:78,代码来源:Scene.Inventory.cs

示例2: TestCoalescedSerializationDeserialization

        public void TestCoalescedSerializationDeserialization()
        {
            var sop1 = Util.RandomSOP("Root", 1);
            var sop2 = Util.RandomSOP("Child1", 2);
            var sop3 = Util.RandomSOP("Child2", 3);

            SceneObjectGroup group = new SceneObjectGroup(sop1);
            group.AddPart(sop2);
            group.AddPart(sop3);


            var sop4 = Util.RandomSOP("Root2", 1);
            var sop5 = Util.RandomSOP("Child12", 2);
            var sop6 = Util.RandomSOP("Child22", 3);

            SceneObjectGroup group2 = new SceneObjectGroup(sop4);
            group2.AddPart(sop5);
            group2.AddPart(sop6);

            var gp1perms = group.GetNewItemPermissions(UUID.Random());
            var gp2perms = group2.GetNewItemPermissions(UUID.Random());

            var perms = new Dictionary<UUID, ItemPermissionBlock>();
            perms[group.UUID] = gp1perms;
            perms[group2.UUID] = gp2perms;

            CoalescedObject cobj = new CoalescedObject(
                new List<SceneObjectGroup> { group, group2 }, 
                perms
                );

            var colbytes = serEngine.CoalescedObjectSerializer.SerializeObjectToBytes(cobj, SerializationFlags.None);

            var deserColObj = serEngine.CoalescedObjectSerializer.DeserializeObjectFromBytes(colbytes);

            CompareObjects comp = new CompareObjects();
            comp.CompareStaticFields = false;
            comp.CompareStaticProperties = false;
            comp.ElementsToIgnore = PrimCompareIgnoreList;

            Assert.IsTrue(comp.Compare(cobj, deserColObj), comp.DifferencesString);
        }
开发者ID:kf6kjg,项目名称:halcyon,代码行数:42,代码来源:SerializerTests.cs


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