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


C# SceneObjectGroup.GetFromItemID方法代码示例

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


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

示例1: UpdateAttachmentPosition

 public void UpdateAttachmentPosition(IClientAPI client, SceneObjectGroup sog, Vector3 pos)
 {
     // If this is an attachment, then we need to save the modified
     // object back into the avatar's inventory. First we save the
     // attachment point information, then we update the relative 
     // positioning (which caused this method to get driven in the
     // first place. Then we have to mark the object as NOT an
     // attachment. This is necessary in order to correctly save
     // and retrieve GroupPosition information for the attachment.
     // Then we save the asset back into the appropriate inventory
     // entry. Finally, we restore the object's attachment status.
     byte attachmentPoint = (byte)sog.RootPart.AttachmentPoint;
     sog.UpdateGroupPosition(pos, true);
     sog.RootPart.IsAttachment = false;
     sog.AbsolutePosition = sog.RootPart.AttachedPos;
     UpdateKnownItem(client, sog, sog.GetFromItemID(), sog.OwnerID);
     sog.SetAttachmentPoint(attachmentPoint);
 }
开发者ID:shangcheng,项目名称:Aurora,代码行数:18,代码来源:AttachmentsModule.cs

示例2: AttachObject

        public bool AttachObject(IClientAPI remoteClient, SceneObjectGroup group, int AttachmentPt, bool silent)
        {
            Vector3 attachPos = group.AbsolutePosition;

            if (m_scene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId))
            {
                // 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 != (int)group.GetAttachmentPoint())
                {
                    attachPos = Vector3.Zero;
                }

                // AttachmentPt 0 means the client chose to 'wear' the attachment.
                /*if (AttachmentPt == 0)
                {
                    // Check object for stored attachment point
                    AttachmentPt = (int)group.GetAttachmentPoint();
                    attachPos = group.GetAttachmentPos();
                }*/

                if (AttachmentPt == 0)
                {
                    // Check object for older stored attachment point
                    AttachmentPt = group.RootPart.Shape.State;
                    //attachPos = group.AbsolutePosition;
                }

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

                group.SetAttachmentPoint((byte)AttachmentPt);
                group.AbsolutePosition = attachPos;

                // Remove any previous attachments
                ScenePresence sp = m_scene.GetScenePresence(remoteClient.AgentId);
                UUID itemID = UUID.Zero;
                if (sp != null)
                {
                    foreach (SceneObjectGroup grp in sp.GetAttachments(AttachmentPt))
                    {
                        itemID = grp.GetFromItemID();
                        if (itemID != UUID.Zero)
                            DetachSingleAttachmentToInv(itemID, remoteClient);
                    }
                }

                if (group.GetFromItemID() == UUID.Zero)
                {
                    m_scene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId, out itemID);
                }
                else
                {
                    itemID = group.GetFromItemID();
                }

                ShowAttachInUserInventory(remoteClient, AttachmentPt, itemID, group);

                AttachToAgent(sp, group, AttachmentPt, attachPos, silent);
            }
            else
            {
                remoteClient.SendAgentAlertMessage(
                    "You don't have sufficient permissions to attach this object", false);

                return false;
            }

            return true;
        }
开发者ID:shangcheng,项目名称:Aurora,代码行数:80,代码来源:AttachmentsModule.cs

示例3: UpdateKnownItem

        /// <summary>
        /// Update the attachment asset for the new sog details if they have changed.
        /// </summary>
        /// <remarks>
        /// This is essential for preserving attachment attributes such as permission.  Unlike normal scene objects,
        /// these details are not stored on the region.
        /// </remarks>
        /// <param name="sp"></param>
        /// <param name="grp"></param>
        private void UpdateKnownItem(IScenePresence sp, SceneObjectGroup grp)
        {
            if (grp.HasGroupChanged || grp.ContainsScripts())
            {
                m_log.DebugFormat(
                    "[ATTACHMENTS MODULE]: Updating asset for attachment {0}, attachpoint {1}",
                    grp.UUID, grp.AttachmentPoint);

                string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(grp);

                InventoryItemBase item = new InventoryItemBase(grp.GetFromItemID(), sp.UUID);
                item = m_scene.InventoryService.GetItem(item);

                if (item != null)
                {
                    AssetBase asset = m_scene.CreateAsset(
                        grp.GetPartName(grp.LocalId),
                        grp.GetPartDescription(grp.LocalId),
                        (sbyte)AssetType.Object,
                        Utils.StringToBytes(sceneObjectXml),
                        sp.UUID);
                    m_scene.AssetService.Store(asset);

                    item.AssetID = asset.FullID;
                    item.Description = asset.Description;
                    item.Name = asset.Name;
                    item.AssetType = asset.Type;
                    item.InvType = (int)InventoryType.Object;

                    m_scene.InventoryService.UpdateItem(item);

                    // this gets called when the agent logs off!
                    if (sp.ControllingClient != null)
                        sp.ControllingClient.SendInventoryItemCreateUpdate(item, 0);
                }
            }
            else
            {
                m_log.DebugFormat(
                    "[ATTACHMENTS MODULE]: Don't need to update asset for unchanged attachment {0}, attachpoint {1}",
                    grp.UUID, grp.AttachmentPoint);
            }
        }
开发者ID:4U2NV,项目名称:opensim,代码行数:52,代码来源:AttachmentsModule.cs

示例4: 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

示例5: FindAttachmentPoint

        /// <summary>
        /// Attach the object to the avatar
        /// </summary>
        /// <param name="remoteClient">The client that is having the attachment done</param>
        /// <param name="localID">The localID (SceneObjectPart) that is being attached (for the attach script event)</param>
        /// <param name="group">The group (SceneObjectGroup) that is being attached</param>
        /// <param name="AttachmentPt">The point to where the attachment will go</param>
        /// <param name="item">If this is not null, it saves a query in this method to the InventoryService
        /// This is the Item that the object is in (if it is in one yet)</param>
        protected void FindAttachmentPoint(IClientAPI remoteClient, uint localID, SceneObjectGroup group,
            int AttachmentPt, InventoryItemBase item)
        {
            //Make sure that we arn't over the limit of attachments
            SceneObjectGroup[] attachments = GetAttachmentsForAvatar(remoteClient.AgentId);
            if (attachments.Length + 1 > m_maxNumberOfAttachments)
            {
                //Too many
                remoteClient.SendAgentAlertMessage(
                    "You are wearing too many attachments. Take one off to attach this object", false);

                return;
            }
            Vector3 attachPos = group.GetAttachmentPos();
            if(!m_allowMultipleAttachments)
                AttachmentPt &= 0x7f; //Disable it!

            //Did the attachment change position or attachment point?
            bool changedPositionPoint = false;

            // 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.
            //Simplier terms: the attachment point changed, set it to the default 0,0,0 location
            if ((AttachmentPt & 0x7f) != 0 && (AttachmentPt & 0x7f) != (int)group.GetAttachmentPoint())
            {
                attachPos = Vector3.Zero;
                changedPositionPoint = true;
            }
            else
            {
                // AttachmentPt 0 means the client chose to 'wear' the attachment.
                if ((AttachmentPt & 0x7f) == 0)
                {
                    // Check object for stored attachment point
                    AttachmentPt = (int)group.GetSavedAttachmentPoint();
                    attachPos = group.GetAttachmentPos();
                }

                //Check state afterwards... use the newer GetSavedAttachmentPoint and Pos above first
                if ((AttachmentPt & 0x7f) == 0)
                {
                    // Check object for older stored attachment point
                    AttachmentPt = group.RootPart.Shape.State;
                    //attachPos = group.AbsolutePosition;
                }

                // if we still didn't find a suitable attachment point, force it to the default
                //This happens on the first time an avatar 'wears' an object
                if ((AttachmentPt & 0x7f) == 0)
                {
                    // Stick it on right hand with Zero Offset from the attachment point.
                    AttachmentPt = (int)AttachmentPoint.RightHand;
                    //Default location
                    attachPos = Vector3.Zero;
                    changedPositionPoint = true;
                }
            }

            group.HasGroupChanged = changedPositionPoint;

            //Update where we are put
            group.SetAttachmentPoint((byte)AttachmentPt);
            //Fix the position with the one we found
            group.AbsolutePosition = attachPos;

            // Remove any previous attachments
            ScenePresence presence = m_scene.GetScenePresence(remoteClient.AgentId);
            if (presence == null)
                return;
            UUID itemID = UUID.Zero;
            //Check for multiple attachment bits
            //If the numbers are the same, it wants to have the old attachment taken off
            if ((AttachmentPt & 0x7f) == AttachmentPt) 
            {
                foreach (SceneObjectGroup grp in attachments)
                {
                    if (grp.GetAttachmentPoint() == (byte)AttachmentPt)
                    {
                        itemID = grp.GetFromItemID();
                        break;
                    }
                }
                if (itemID != UUID.Zero)
                    DetachSingleAttachmentToInventory(itemID, remoteClient);
            }
            itemID = group.GetFromItemID();

            group.RootPart.AttachedAvatar = presence.UUID;

            //Anakin Lohner bug #3839 
//.........这里部分代码省略.........
开发者ID:mugginsm,项目名称:Aurora-Sim,代码行数:101,代码来源:AttachmentsModule.cs

示例6: AddSceneObject

        /// <summary>
        /// Adds a Scene Object group to the Scene.
        /// Verifies that the creator of the object is not banned from the simulator.
        /// Checks if the item is an Attachment
        /// </summary>
        /// <param name="sceneObject"></param>
        /// <returns>True if the SceneObjectGroup was added, False if it was not</returns>
        public bool AddSceneObject(SceneObjectGroup sceneObject)
        {
            // If the user is banned, we won't let any of their objects
            // enter. Period.
            //
            if (m_regInfo.EstateSettings.IsBanned(sceneObject.OwnerID))
            {
                m_log.Info("[INTERREGION]: Denied prim crossing for " +
                        "banned avatar");

                return false;
            }

            if (sceneObject.IsAttachmentCheckFull()) // Attachment
            {
                sceneObject.RootPart.AddFlag(PrimFlags.TemporaryOnRez);
                sceneObject.RootPart.AddFlag(PrimFlags.Phantom);
                AddPrimToScene(sceneObject);

                // Fix up attachment Parent Local ID
                ScenePresence sp = GetScenePresence(sceneObject.OwnerID);

                if (sp != null)
                {
                    m_log.DebugFormat(
                        "[ATTACHMENT]: Received attachment {0}, inworld asset id {1}", sceneObject.GetFromItemID(), sceneObject.UUID);
                    m_log.DebugFormat(
                        "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, sceneObject.AbsolutePosition);

                    if (AttachmentsModule != null)
                        AttachmentsModule.AttachObject(sp.ControllingClient, sceneObject.LocalId, 0, false);

                    sceneObject.RootPart.RemFlag(PrimFlags.TemporaryOnRez);
                }
                else
                {
                    sceneObject.RootPart.RemFlag(PrimFlags.TemporaryOnRez);
                    sceneObject.RootPart.AddFlag(PrimFlags.TemporaryOnRez);
                }
            }
            else
            {
                if (!Permissions.CanObjectEntry(sceneObject.UUID,
                        true, sceneObject.AbsolutePosition))
                {
                    // Deny non attachments based on parcel settings
                    //
                    m_log.Info("[INTERREGION]: Denied prim crossing " +
                            "because of parcel settings");

                    DeleteSceneObject(sceneObject, false, true);

                    return false;
                }
                AddPrimToScene(sceneObject);
            }
            sceneObject.SendGroupFullUpdate(PrimUpdateFlags.FullUpdate);

            return true;
        }
开发者ID:NickyPerian,项目名称:Aurora,代码行数:67,代码来源:Scene.cs


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