GetAttachments() public method

Get a list of the attachments, note that there may be duplicate attachpoints
public GetAttachments ( ) : List
return List
コード例 #1
0
        public AvatarAppearance(AvatarAppearance appearance, bool copyWearables)
        {
            //            m_log.WarnFormat("[AVATAR APPEARANCE] create from an existing appearance");

            if (appearance == null)
            {
                m_serial = 1;
                m_owner = UUID.Zero;

                SetDefaultWearables();
                SetDefaultTexture();
                SetDefaultParams();
                SetHeight();

                m_attachments = new Dictionary<int, List<AvatarAttachment>>();

                return;
            }

            m_serial = appearance.Serial;
            m_owner = appearance.Owner;

            m_wearables = new AvatarWearable[AvatarWearable.MAX_WEARABLES];
            for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++)
                m_wearables[i] = new AvatarWearable();
            if (copyWearables && (appearance.Wearables != null))
            {
                for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++)
                    SetWearable(i, appearance.Wearables[i]);
            }

            m_texture = null;
            if (appearance.Texture != null)
            {
                byte[] tbytes = appearance.Texture.GetBytes();
                m_texture = new Primitive.TextureEntry(tbytes, 0, tbytes.Length);
            }

            m_visualparams = null;
            if (appearance.VisualParams != null)
                m_visualparams = (byte[])appearance.VisualParams.Clone();

            // Copy the attachment, force append mode since that ensures consistency
            m_attachments = new Dictionary<int, List<AvatarAttachment>>();
            foreach (AvatarAttachment attachment in appearance.GetAttachments())
                AppendAttachment(new AvatarAttachment(attachment));
        }
コード例 #2
0
        public AvatarAppearance(AvatarAppearance appearance, bool copyWearables, bool copyBaked)
        {
//            m_log.WarnFormat("[AVATAR APPEARANCE] create from an existing appearance");

            if (appearance == null)
            {
                m_serial = 0;
                SetDefaultWearables();
                SetDefaultTexture();
                SetDefaultParams();
//                SetHeight();
                SetSize(new Vector3(0.45f, 0.6f, 1.9f));
                m_attachments = new Dictionary<int, List<AvatarAttachment>>();

                return;
            }

            m_serial = appearance.Serial;

            if (copyWearables && (appearance.Wearables != null))
            {
                m_wearables = new AvatarWearable[appearance.Wearables.Length];
                for (int i = 0; i < appearance.Wearables.Length; i++)
                {
                    m_wearables[i] = new AvatarWearable();
                    AvatarWearable wearable = appearance.Wearables[i];
                    for (int j = 0; j < wearable.Count; j++)
                            m_wearables[i].Add(wearable[j].ItemID, wearable[j].AssetID);                       
                 }
            }
            else
                ClearWearables();

            m_texture = null;
            if (appearance.Texture != null)
            {
                byte[] tbytes = appearance.Texture.GetBytes();
                m_texture = new Primitive.TextureEntry(tbytes,0,tbytes.Length);
                if (copyBaked && appearance.m_cacheitems != null)
                    m_cacheitems = (WearableCacheItem[])appearance.m_cacheitems.Clone();
                else
                    m_cacheitems = null;
            }

            m_visualparams = null;
            if (appearance.VisualParams != null)
                m_visualparams = (byte[])appearance.VisualParams.Clone();

//            m_avatarHeight = appearance.m_avatarHeight;
            SetSize(appearance.AvatarSize);

            // Copy the attachment, force append mode since that ensures consistency
            m_attachments = new Dictionary<int, List<AvatarAttachment>>();
            foreach (AvatarAttachment attachment in appearance.GetAttachments())
                AppendAttachment(new AvatarAttachment(attachment));
        }
コード例 #3
0
ファイル: RemoteAdminPlugin.cs プロジェクト: NovaGrid/opensim
        /// <summary>
        /// This method is called by establishAppearance to do a copy all inventory items
        /// worn or attached to the Clothing inventory folder of the receiving avatar.
        /// In parallel the avatar wearables and attachments are updated.
        /// </summary>

        private void CopyWearablesAndAttachments(UUID destination, UUID source, AvatarAppearance avatarAppearance)
        {
            IInventoryService inventoryService = m_application.SceneManager.CurrentOrFirstScene.InventoryService;

            // Get Clothing folder of receiver
            InventoryFolderBase destinationFolder = inventoryService.GetFolderForType(destination, AssetType.Clothing);

            if (destinationFolder == null)
                throw new Exception("Cannot locate folder(s)");

            // Missing destination folder? This should *never* be the case
            if (destinationFolder.Type != (short)AssetType.Clothing)
            {
                destinationFolder = new InventoryFolderBase();
                
                destinationFolder.ID       = UUID.Random();
                destinationFolder.Name     = "Clothing";
                destinationFolder.Owner    = destination;
                destinationFolder.Type     = (short)AssetType.Clothing;
                destinationFolder.ParentID = inventoryService.GetRootFolder(destination).ID;
                destinationFolder.Version  = 1;
                inventoryService.AddFolder(destinationFolder);     // store base record
                m_log.ErrorFormat("[RADMIN]: Created folder for destination {0}", source);
            }

            // Wearables
            AvatarWearable[] wearables = avatarAppearance.Wearables;
            AvatarWearable wearable;

            for (int i=0; i<wearables.Length; i++)
            {
                wearable = wearables[i];
                if (wearable[0].ItemID != UUID.Zero)
                {
                    // Get inventory item and copy it
                    InventoryItemBase item = new InventoryItemBase(wearable[0].ItemID, source);
                    item = inventoryService.GetItem(item);

                    if (item != null)
                    {
                        InventoryItemBase destinationItem = new InventoryItemBase(UUID.Random(), destination);
                        destinationItem.Name = item.Name;
                        destinationItem.Owner = destination;
                        destinationItem.Description = item.Description;
                        destinationItem.InvType = item.InvType;
                        destinationItem.CreatorId = item.CreatorId;
                        destinationItem.CreatorIdAsUuid = item.CreatorIdAsUuid;
                        destinationItem.CreatorData = item.CreatorData;
                        destinationItem.NextPermissions = item.NextPermissions;
                        destinationItem.CurrentPermissions = item.CurrentPermissions;
                        destinationItem.BasePermissions = item.BasePermissions;
                        destinationItem.EveryOnePermissions = item.EveryOnePermissions;
                        destinationItem.GroupPermissions = item.GroupPermissions;
                        destinationItem.AssetType = item.AssetType;
                        destinationItem.AssetID = item.AssetID;
                        destinationItem.GroupID = item.GroupID;
                        destinationItem.GroupOwned = item.GroupOwned;
                        destinationItem.SalePrice = item.SalePrice;
                        destinationItem.SaleType = item.SaleType;
                        destinationItem.Flags = item.Flags;
                        destinationItem.CreationDate = item.CreationDate;
                        destinationItem.Folder = destinationFolder.ID;
                        ApplyNextOwnerPermissions(destinationItem);

                        m_application.SceneManager.CurrentOrFirstScene.AddInventoryItem(destinationItem);
                        m_log.DebugFormat("[RADMIN]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID);

                        // Wear item
                        AvatarWearable newWearable = new AvatarWearable();
                        newWearable.Wear(destinationItem.ID, wearable[0].AssetID);
                        avatarAppearance.SetWearable(i, newWearable);
                    }
                    else
                    {
                        m_log.WarnFormat("[RADMIN]: Error transferring {0} to folder {1}", wearable[0].ItemID, destinationFolder.ID);
                    }
                }
            }

            // Attachments
            List<AvatarAttachment> attachments = avatarAppearance.GetAttachments();

            foreach (AvatarAttachment attachment in attachments)
            {
                int attachpoint = attachment.AttachPoint;
                UUID itemID = attachment.ItemID;

                if (itemID != UUID.Zero)
                {
                    // Get inventory item and copy it
                    InventoryItemBase item = new InventoryItemBase(itemID, source);
                    item = inventoryService.GetItem(item);

                    if (item != null)
                    {
                        InventoryItemBase destinationItem = new InventoryItemBase(UUID.Random(), destination);
                        destinationItem.Name = item.Name;
                        destinationItem.Owner = destination;
                        destinationItem.Description = item.Description;
                        destinationItem.InvType = item.InvType;
                        destinationItem.CreatorId = item.CreatorId;
                        destinationItem.CreatorIdAsUuid = item.CreatorIdAsUuid;
                        destinationItem.CreatorData = item.CreatorData;
                        destinationItem.NextPermissions = item.NextPermissions;
                        destinationItem.CurrentPermissions = item.CurrentPermissions;
                        destinationItem.BasePermissions = item.BasePermissions;
                        destinationItem.EveryOnePermissions = item.EveryOnePermissions;
                        destinationItem.GroupPermissions = item.GroupPermissions;
                        destinationItem.AssetType = item.AssetType;
                        destinationItem.AssetID = item.AssetID;
                        destinationItem.GroupID = item.GroupID;
                        destinationItem.GroupOwned = item.GroupOwned;
                        destinationItem.SalePrice = item.SalePrice;
                        destinationItem.SaleType = item.SaleType;
                        destinationItem.Flags = item.Flags;
                        destinationItem.CreationDate = item.CreationDate;
                        destinationItem.Folder = destinationFolder.ID;
                        ApplyNextOwnerPermissions(destinationItem);

                        m_application.SceneManager.CurrentOrFirstScene.AddInventoryItem(destinationItem);
                        m_log.DebugFormat("[RADMIN]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID);

                        // Attach item
                        avatarAppearance.SetAttachment(attachpoint, destinationItem.ID, destinationItem.AssetID);
                        m_log.DebugFormat("[RADMIN]: Attached {0}", destinationItem.ID);
                    }
                    else
                    {
                        m_log.WarnFormat("[RADMIN]: Error transferring {0} to folder {1}", itemID, destinationFolder.ID);
                    }
                }
            }


        }
コード例 #4
0
ファイル: IAvatarService.cs プロジェクト: NovaGrid/opensim
        public AvatarData(AvatarAppearance appearance)
        {
            AvatarType = 1; // SL avatars
            Data = new Dictionary<string, string>();

            Data["Serial"] = appearance.Serial.ToString();
            // Wearables
            Data["AvatarHeight"] = appearance.AvatarHeight.ToString();

            for (int i = 0 ; i < AvatarWearable.MAX_WEARABLES ; i++)
            {
                for (int j = 0 ; j < appearance.Wearables[i].Count ; j++)
                {
                    string fieldName = String.Format("Wearable {0}:{1}", i, j);
                    Data[fieldName] = String.Format("{0}:{1}",
                            appearance.Wearables[i][j].ItemID.ToString(),
                            appearance.Wearables[i][j].AssetID.ToString());
                }
            }

            // Visual Params
            string[] vps = new string[AvatarAppearance.VISUALPARAM_COUNT];
            byte[] binary = appearance.VisualParams;

            for (int i = 0 ; i < AvatarAppearance.VISUALPARAM_COUNT ; i++)
            {
                vps[i] = binary[i].ToString();
            }

            Data["VisualParams"] = String.Join(",", vps);

            // Attachments
            List<AvatarAttachment> attachments = appearance.GetAttachments();
            foreach (AvatarAttachment attach in attachments)
            {
                Data["_ap_" + attach.AttachPoint] = attach.ItemID.ToString();
            }
        }
コード例 #5
0
ファイル: MSSQLUserData.cs プロジェクト: ChrisD/opensim
        /// <summary>
        /// Update a user appearence into database
        /// </summary>
        /// <param name="user">the used UUID</param>
        /// <param name="appearance">the appearence</param>
        override public void UpdateUserAppearance(UUID user, AvatarAppearance appearance)
        {
            string sql = @"DELETE FROM avatarappearance WHERE owner=@owner; 
                        INSERT INTO avatarappearance 
                           (owner, serial, visual_params, texture, avatar_height, 
                            body_item, body_asset, skin_item, skin_asset, hair_item, 
                            hair_asset, eyes_item, eyes_asset, shirt_item, shirt_asset, 
                            pants_item, pants_asset, shoes_item, shoes_asset, socks_item, 
                            socks_asset, jacket_item, jacket_asset, gloves_item, gloves_asset, 
                            undershirt_item, undershirt_asset, underpants_item, underpants_asset, 
                            skirt_item, skirt_asset) 
                        VALUES
                           (@owner, @serial, @visual_params, @texture, @avatar_height, 
                            @body_item, @body_asset, @skin_item, @skin_asset, @hair_item, 
                            @hair_asset, @eyes_item, @eyes_asset, @shirt_item, @shirt_asset, 
                            @pants_item, @pants_asset, @shoes_item, @shoes_asset, @socks_item, 
                            @socks_asset, @jacket_item, @jacket_asset, @gloves_item, @gloves_asset, 
                            @undershirt_item, @undershirt_asset, @underpants_item, @underpants_asset, 
                            @skirt_item, @skirt_asset)";

            using (AutoClosingSqlCommand cmd = database.Query(sql))
            {
                cmd.Parameters.Add(database.CreateParameter("@owner", appearance.Owner));
                cmd.Parameters.Add(database.CreateParameter("@serial", appearance.Serial));
                cmd.Parameters.Add(database.CreateParameter("@visual_params", appearance.VisualParams));
                cmd.Parameters.Add(database.CreateParameter("@texture", appearance.Texture.GetBytes()));
                cmd.Parameters.Add(database.CreateParameter("@avatar_height", appearance.AvatarHeight));
                cmd.Parameters.Add(database.CreateParameter("@body_item", appearance.BodyItem));
                cmd.Parameters.Add(database.CreateParameter("@body_asset", appearance.BodyAsset));
                cmd.Parameters.Add(database.CreateParameter("@skin_item", appearance.SkinItem));
                cmd.Parameters.Add(database.CreateParameter("@skin_asset", appearance.SkinAsset));
                cmd.Parameters.Add(database.CreateParameter("@hair_item", appearance.HairItem));
                cmd.Parameters.Add(database.CreateParameter("@hair_asset", appearance.HairAsset));
                cmd.Parameters.Add(database.CreateParameter("@eyes_item", appearance.EyesItem));
                cmd.Parameters.Add(database.CreateParameter("@eyes_asset", appearance.EyesAsset));
                cmd.Parameters.Add(database.CreateParameter("@shirt_item", appearance.ShirtItem));
                cmd.Parameters.Add(database.CreateParameter("@shirt_asset", appearance.ShirtAsset));
                cmd.Parameters.Add(database.CreateParameter("@pants_item", appearance.PantsItem));
                cmd.Parameters.Add(database.CreateParameter("@pants_asset", appearance.PantsAsset));
                cmd.Parameters.Add(database.CreateParameter("@shoes_item", appearance.ShoesItem));
                cmd.Parameters.Add(database.CreateParameter("@shoes_asset", appearance.ShoesAsset));
                cmd.Parameters.Add(database.CreateParameter("@socks_item", appearance.SocksItem));
                cmd.Parameters.Add(database.CreateParameter("@socks_asset", appearance.SocksAsset));
                cmd.Parameters.Add(database.CreateParameter("@jacket_item", appearance.JacketItem));
                cmd.Parameters.Add(database.CreateParameter("@jacket_asset", appearance.JacketAsset));
                cmd.Parameters.Add(database.CreateParameter("@gloves_item", appearance.GlovesItem));
                cmd.Parameters.Add(database.CreateParameter("@gloves_asset", appearance.GlovesAsset));
                cmd.Parameters.Add(database.CreateParameter("@undershirt_item", appearance.UnderShirtItem));
                cmd.Parameters.Add(database.CreateParameter("@undershirt_asset", appearance.UnderShirtAsset));
                cmd.Parameters.Add(database.CreateParameter("@underpants_item", appearance.UnderPantsItem));
                cmd.Parameters.Add(database.CreateParameter("@underpants_asset", appearance.UnderPantsAsset));
                cmd.Parameters.Add(database.CreateParameter("@skirt_item", appearance.SkirtItem));
                cmd.Parameters.Add(database.CreateParameter("@skirt_asset", appearance.SkirtAsset));

                try
                {
                    cmd.ExecuteNonQuery();
                }
                catch (Exception e)
                {
                    m_log.ErrorFormat("[USER DB] Error updating user appearance, error: {0}", e.Message);
                }
            }
            UpdateUserAttachments(user, appearance.GetAttachments());
        }
コード例 #6
0
        private void RemapWornItems(UUID botID, AvatarAppearance appearance)
        {
            // save before Clear calls
            List<AvatarWearable> wearables = appearance.GetWearables();
            List<AvatarAttachment> attachments = appearance.GetAttachments();
            appearance.ClearWearables();
            appearance.ClearAttachments();

            // Remap bot outfit with new item IDs
            foreach (AvatarWearable w in wearables)
            {
                AvatarWearable newWearable = new AvatarWearable(w);
                // store a reversible back-link to the original inventory item ID.
                newWearable.ItemID = w.ItemID ^ botID;
                appearance.SetWearable(newWearable);
            }

            foreach (AvatarAttachment a in attachments)
            {
                // store a reversible back-link to the original inventory item ID.
                UUID itemID = a.ItemID ^ botID;
                appearance.SetAttachment(a.AttachPoint, true, itemID, a.AssetID);
            }
        }
コード例 #7
0
        public bool CheckAttachmentCount(UUID botID, AvatarAppearance appearance, ILandObject parcel, UUID originalOwner, out string reason)
        {
            int landImpact = 0;
            foreach (AvatarAttachment attachment in appearance.GetAttachments())
            {
                // get original itemID
                UUID origItemID = attachment.ItemID ^ botID;
                if (origItemID == UUID.Zero)
                    continue;

                IInventoryProviderSelector inventorySelect = ProviderRegistry.Instance.Get<IInventoryProviderSelector>();
                var provider = inventorySelect.GetProvider(originalOwner);
                InventoryItemBase item = provider.GetItem(origItemID, UUID.Zero);

                SceneObjectGroup grp = m_scene.GetObjectFromItem(item);
                if (grp != null)
                {
                    if ((grp.GetEffectivePermissions(true) & (uint)PermissionMask.Copy) != (uint)PermissionMask.Copy)
                        continue;//No copy objects cannot be attached
                    landImpact += grp.LandImpact;
                }
            }

            if (!m_scene.CheckLandImpact(parcel, landImpact, out reason))
            {
                //Cannot create bot on a parcel that does not allow for rezzing an object
                reason = "Attachments exceed the land impact limit for this " + reason + ".";
                return false;
            }

            reason = null;
            return true;
        }
コード例 #8
0
        public AvatarAppearance(AvatarAppearance appearance, bool copyWearables)
        {
			if (m_log.IsDebugEnabled) {
				m_log.DebugFormat ("{0} called", System.Reflection.MethodBase.GetCurrentMethod ().Name);
                m_log.WarnFormat("create from an existing appearance CopyWearables={0}", copyWearables);
			}


            if (appearance == null)
            {
                m_serial = 0;
                SetDefaultWearables();
                SetDefaultTexture();
                SetDefaultParams();
                SetHeight();
                m_attachments = new Dictionary<int, List<AvatarAttachment>>();

                ResetTextureHashes();
                
                return;
            }

            m_serial = appearance.Serial;

            m_wearables = new AvatarWearable[AvatarWearable.MAX_WEARABLES];
            for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++)
                m_wearables[i] = new AvatarWearable();

            if (copyWearables && (appearance.Wearables != null))
            {
                for (int i = 0; i < AvatarWearable.MAX_WEARABLES; i++)
                    SetWearable(i,appearance.Wearables[i]);
            }

            m_texturehashes = new UUID[AvatarAppearance.TEXTURE_COUNT];
            for (int i = 0; i < AvatarAppearance.TEXTURE_COUNT; i++)
                m_texturehashes[i] = new UUID(appearance.m_texturehashes[i]);

            m_texture = null;
            if (appearance.Texture != null)
            {
                byte[] tbytes = appearance.Texture.GetBytes();
                m_texture = new Primitive.TextureEntry(tbytes,0,tbytes.Length);
            }

            m_visualparams = null;
            if (appearance.VisualParams != null)
                m_visualparams = (byte[])appearance.VisualParams.Clone();

            m_avatarHeight = appearance.m_avatarHeight;

            // Copy the attachment, force append mode since that ensures consistency
            m_attachments = new Dictionary<int, List<AvatarAttachment>>();
            foreach (AvatarAttachment attachment in appearance.GetAttachments())
                AppendAttachment(new AvatarAttachment(attachment));
        }
コード例 #9
0
ファイル: IAvatarService.cs プロジェクト: shangcheng/Aurora
        public AvatarData(AvatarAppearance appearance)
        {
            AvatarType = 1; // SL avatars
            Data = new Dictionary<string, string>();

            Data["Serial"] = appearance.Serial.ToString();
            // Wearables
            Data["AvatarHeight"] = appearance.AvatarHeight.ToString();
            Data["BodyItem"] = appearance.BodyItem.ToString();
            Data["EyesItem"] = appearance.EyesItem.ToString();
            Data["GlovesItem"] = appearance.GlovesItem.ToString();
            Data["HairItem"] = appearance.HairItem.ToString();
            Data["JacketItem"] = appearance.JacketItem.ToString();
            Data["PantsItem"] = appearance.PantsItem.ToString();
            Data["ShirtItem"] = appearance.ShirtItem.ToString();
            Data["ShoesItem"] = appearance.ShoesItem.ToString();
            Data["SkinItem"] = appearance.SkinItem.ToString();
            Data["SkirtItem"] = appearance.SkirtItem.ToString();
            Data["SocksItem"] = appearance.SocksItem.ToString();
            Data["UnderPantsItem"] = appearance.UnderPantsItem.ToString();
            Data["UnderShirtItem"] = appearance.UnderShirtItem.ToString();

            Data["BodyAsset"] = appearance.BodyAsset.ToString();
            Data["EyesAsset"] = appearance.EyesAsset.ToString();
            Data["GlovesAsset"] = appearance.GlovesAsset.ToString();
            Data["HairAsset"] = appearance.HairAsset.ToString();
            Data["JacketAsset"] = appearance.JacketAsset.ToString();
            Data["PantsAsset"] = appearance.PantsAsset.ToString();
            Data["ShirtAsset"] = appearance.ShirtAsset.ToString();
            Data["ShoesAsset"] = appearance.ShoesAsset.ToString();
            Data["SkinAsset"] = appearance.SkinAsset.ToString();
            Data["SkirtAsset"] = appearance.SkirtAsset.ToString();
            Data["SocksAsset"] = appearance.SocksAsset.ToString();
            Data["UnderPantsAsset"] = appearance.UnderPantsAsset.ToString();
            Data["UnderShirtAsset"] = appearance.UnderShirtAsset.ToString();

            Data["AlphaAsset"] = appearance.AlphaAsset.ToString();
            Data["AlphaItem"] = appearance.AlphaItem.ToString();
            Data["TattooAsset"] = appearance.TattooAsset.ToString();
            Data["TattooItem"] = appearance.TattooItem.ToString();

            // Attachments
            Hashtable attachs = appearance.GetAttachments();
            if (attachs != null)
                foreach (DictionaryEntry dentry in attachs)
                {
                    if (dentry.Value != null)
                    {
                        Hashtable tab = (Hashtable)dentry.Value;
                        if (tab.ContainsKey("item") && tab["item"] != null)
                            Data["_ap_" + dentry.Key] = tab["item"].ToString();
                    }
                }
        }
コード例 #10
0
 /// <summary>
 /// Adds an outfit into the database
 /// </summary>
 /// <param name="user">The user UUID</param>
 /// <param name="appearance">The avatar appearance</param>
 // override
 public override void AddOrUpdateBotOutfit(UUID userID, string outfitName, AvatarAppearance appearance)
 {
     try
     {
         appearance.Owner = userID;
         this.insertBotAppearanceRow(outfitName, appearance);
         UpdateBotAttachments(userID, outfitName, appearance.GetAttachments());
     }
     catch (Exception e)
     {
         m_log.Error(e.ToString());
     }
 }
コード例 #11
0
        /// <summary>
        /// This method is called by establishAppearance to do a copy all inventory items
        /// worn or attached to the Clothing inventory folder of the receiving avatar.
        /// In parallel the avatar wearables and attachments are updated.
        /// </summary>

        private void CopyWearablesAndAttachments(UUID destination, UUID source, AvatarAppearance avatarAppearance)
        {
            IInventoryService inventoryService = manager.CurrentOrFirstScene.InventoryService;

            // Get Clothing folder of receiver
            InventoryFolderBase destinationFolder = inventoryService.GetFolderForType (destination, InventoryType.Wearable, AssetType.Clothing);

            if (destinationFolder == null)
                throw new Exception("Cannot locate folder(s)");

            // Missing destination folder? This should *never* be the case
            if (destinationFolder.Type != (short)AssetType.Clothing)
            {
                destinationFolder = new InventoryFolderBase
                                        {
                                            ID = UUID.Random(),
                                            Name = "Clothing",
                                            Owner = destination,
                                            Type = (short) AssetType.Clothing,
                                            ParentID = inventoryService.GetRootFolder(destination).ID,
                                            Version = 1
                                        };

                inventoryService.AddFolder(destinationFolder);     // store base record
                MainConsole.Instance.ErrorFormat("[RADMIN] Created folder for destination {0}", source);
            }

            // Wearables
            AvatarWearable[] wearables = avatarAppearance.Wearables;

            for (int i = 0; i < wearables.Length; i++)
            {
                AvatarWearable wearable = wearables[i];
                if (wearable[0].ItemID != UUID.Zero)
                {
                    // Get inventory item and copy it
                    InventoryItemBase item = new InventoryItemBase(wearable[0].ItemID, source);
                    item = inventoryService.GetItem(item);

                    if (item != null)
                    {
                        InventoryItemBase destinationItem = new InventoryItemBase(UUID.Random(), destination)
                                                                {
                                                                    Name = item.Name,
                                                                    Description = item.Description,
                                                                    InvType = item.InvType,
                                                                    CreatorId = item.CreatorId,
                                                                    CreatorData = item.CreatorData,
                                                                    CreatorIdAsUuid = item.CreatorIdAsUuid,
                                                                    NextPermissions = item.NextPermissions,
                                                                    CurrentPermissions = item.CurrentPermissions,
                                                                    BasePermissions = item.BasePermissions,
                                                                    EveryOnePermissions = item.EveryOnePermissions,
                                                                    GroupPermissions = item.GroupPermissions,
                                                                    AssetType = item.AssetType,
                                                                    AssetID = item.AssetID,
                                                                    GroupID = item.GroupID,
                                                                    GroupOwned = item.GroupOwned,
                                                                    SalePrice = item.SalePrice,
                                                                    SaleType = item.SaleType,
                                                                    Flags = item.Flags,
                                                                    CreationDate = item.CreationDate,
                                                                    Folder = destinationFolder.ID
                                                                };
                        ILLClientInventory inventoryModule = manager.CurrentOrFirstScene.RequestModuleInterface<ILLClientInventory>();
                        if (inventoryModule != null)
                            inventoryModule.AddInventoryItem(destinationItem);
                        MainConsole.Instance.DebugFormat("[RADMIN]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID);

                        // Wear item
                        AvatarWearable newWearable = new AvatarWearable();
                        newWearable.Wear(destinationItem.ID, wearable[0].AssetID);
                        avatarAppearance.SetWearable(i, newWearable);
                    }
                    else
                    {
                        MainConsole.Instance.WarnFormat("[RADMIN]: Error transferring {0} to folder {1}", wearable[0].ItemID, destinationFolder.ID);
                    }
                }
            }

            // Attachments
            List<AvatarAttachment> attachments = avatarAppearance.GetAttachments();

            foreach (AvatarAttachment attachment in attachments)
            {
                int attachpoint = attachment.AttachPoint;
                UUID itemID = attachment.ItemID;

                if (itemID != UUID.Zero)
                {
                    // Get inventory item and copy it
                    InventoryItemBase item = new InventoryItemBase(itemID, source);
                    item = inventoryService.GetItem(item);

                    if (item != null)
                    {
                        InventoryItemBase destinationItem = new InventoryItemBase(UUID.Random(), destination)
                                                                {
                                                                    Name = item.Name,
                                                                    Description = item.Description,
                                                                    InvType = item.InvType,
                                                                    CreatorId = item.CreatorId,
                                                                    CreatorData = item.CreatorData,
                                                                    CreatorIdAsUuid = item.CreatorIdAsUuid,
                                                                    NextPermissions = item.NextPermissions,
                                                                    CurrentPermissions = item.CurrentPermissions,
                                                                    BasePermissions = item.BasePermissions,
                                                                    EveryOnePermissions = item.EveryOnePermissions,
                                                                    GroupPermissions = item.GroupPermissions,
                                                                    AssetType = item.AssetType,
                                                                    AssetID = item.AssetID,
                                                                    GroupID = item.GroupID,
                                                                    GroupOwned = item.GroupOwned,
                                                                    SalePrice = item.SalePrice,
                                                                    SaleType = item.SaleType,
                                                                    Flags = item.Flags,
                                                                    CreationDate = item.CreationDate,
                                                                    Folder = destinationFolder.ID
                                                                };
                        ILLClientInventory inventoryModule = manager.CurrentOrFirstScene.RequestModuleInterface<ILLClientInventory>();
                        if (inventoryModule != null)
                            inventoryModule.AddInventoryItem(destinationItem);
                        MainConsole.Instance.DebugFormat("[RADMIN]: Added item {0} to folder {1}", destinationItem.ID, destinationFolder.ID);

                        // Attach item
                        avatarAppearance.SetAttachment(attachpoint, destinationItem.ID, destinationItem.AssetID);
                        MainConsole.Instance.DebugFormat("[RADMIN]: Attached {0}", destinationItem.ID);
                    }
                    else
                    {
                        MainConsole.Instance.WarnFormat("[RADMIN]: Error transferring {0} to folder {1}", itemID, destinationFolder.ID);
                    }
                }
            }
        }
コード例 #12
0
 /// <summary>
 /// Updates an avatar appearence
 /// </summary>
 /// <param name="user">The user UUID</param>
 /// <param name="appearance">The avatar appearance</param>
 // override
 public override void UpdateUserAppearance(UUID user, AvatarAppearance appearance)
 {
     try
     {
         appearance.Owner = user;
         this.insertAppearanceRow(appearance);
         UpdateUserAttachments(user, appearance.GetAttachments());
     }
     catch (Exception e)
     {
         m_log.Error(e.ToString());
     }
 }
コード例 #13
0
ファイル: IAvatarService.cs プロジェクト: CassieEllen/opensim
        public AvatarData(AvatarAppearance appearance)
        {
            AvatarType = 1; // SL avatars
            Data = new Dictionary<string, string>();

            Data["Serial"] = appearance.Serial.ToString();
            // Wearables
            Data["AvatarHeight"] = appearance.AvatarHeight.ToString();

            // TODO: With COF, is this even needed?
            for (int i = 0 ; i < AvatarWearable.LEGACY_VERSION_MAX_WEARABLES ; i++)
            {
                for (int j = 0 ; j < appearance.Wearables[i].Count ; j++)
                {
                    string fieldName = String.Format("Wearable {0}:{1}", i, j);
                    Data[fieldName] = String.Format("{0}:{1}",
                            appearance.Wearables[i][j].ItemID.ToString(),
                            appearance.Wearables[i][j].AssetID.ToString());
                }
            }

            // Visual Params
            //string[] vps = new string[AvatarAppearance.VISUALPARAM_COUNT];
            //byte[] binary = appearance.VisualParams;

            //            for (int i = 0 ; i < AvatarAppearance.VISUALPARAM_COUNT ; i++)

            byte[] binary = appearance.VisualParams;
            string[] vps = new string[binary.Length];

            for (int i = 0; i < binary.Length; i++)
            {
                vps[i] = binary[i].ToString();
            }

            Data["VisualParams"] = String.Join(",", vps);

            // Attachments
            List<AvatarAttachment> attachments = appearance.GetAttachments();
            Dictionary<int, List<string>> atts = new Dictionary<int, List<string>>();
            foreach (AvatarAttachment attach in attachments)
            {
                if (attach.ItemID != UUID.Zero)
                {
                    if (!atts.ContainsKey(attach.AttachPoint))
                        atts[attach.AttachPoint] = new List<string>();
                    atts[attach.AttachPoint].Add(attach.ItemID.ToString());
                }
            }
            foreach (KeyValuePair<int, List<string>> kvp in atts)
                Data["_ap_" + kvp.Key] = string.Join(",", kvp.Value.ToArray());
        }
コード例 #14
0
ファイル: MySQLUserData.cs プロジェクト: intari/OpenSimMirror
        /// <summary>
        /// Updates an avatar appearence
        /// </summary>
        /// <param name="user">The user UUID</param>
        /// <param name="appearance">The avatar appearance</param>
        // override
        public override void UpdateUserAppearance(UUID user, AvatarAppearance appearance)
        {
            MySQLSuperManager dbm = GetLockedConnection("UpdateUserAppearance");
            try
            {
                appearance.Owner = user;
                dbm.Manager.insertAppearanceRow(appearance);

                UpdateUserAttachments(user, appearance.GetAttachments());
            }
            catch (Exception e)
            {
                dbm.Manager.Reconnect();
                m_log.Error(e.Message, e);
            }
            finally
            {
                dbm.Release();
            }
        }
コード例 #15
0
ファイル: AvatarAppearance.cs プロジェクト: kf6kjg/halcyon
        public AvatarAppearance(AvatarAppearance appearance, bool copyWearables)
        {
//            m_log.WarnFormat("[AVATAR APPEARANCE] create from an existing appearance");

            m_attachments = new Dictionary<int, List<AvatarAttachment>>();
            m_wearables = new Dictionary<int, AvatarWearable>(); 

            if (appearance == null)
            {
                m_serial = VERSION_INITIAL;
                m_owner = UUID.Zero;
                SetDefaultWearables();
                SetDefaultTexture();
                SetDefaultParams();
                SetHeight();
                return;
            }

            m_owner = appearance.Owner;
            m_serial = appearance.Serial;

            if (copyWearables == true)
            {
                ClearWearables();
                SetWearables(appearance.GetWearables());
            }
            else
                SetDefaultWearables();

            m_texture = null;
            if (appearance.Texture != null)
            {
                byte[] tbytes = appearance.Texture.GetBytes();
                m_texture = new Primitive.TextureEntry(tbytes, 0, tbytes.Length);
            }
            else
            {
                SetDefaultTexture();
            }

            m_visualparams = null;
            if (appearance.VisualParams != null)
                m_visualparams = (byte[])appearance.VisualParams.Clone();
            else
                SetDefaultParams();

            IsBotAppearance = appearance.IsBotAppearance;

            SetHeight();

            SetAttachments(appearance.GetAttachments());
        }
コード例 #16
0
        public virtual OSDMap Pack()
        {
//            m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Pack data");

            OSDMap args = new OSDMap();

            args["message_type"] = OSD.FromString("AgentData");

            args["region_id"]    = OSD.FromString(RegionID.ToString());
            args["circuit_code"] = OSD.FromString(CircuitCode.ToString());
            args["agent_uuid"]   = OSD.FromUUID(AgentID);
            args["session_uuid"] = OSD.FromUUID(SessionID);

            args["position"]  = OSD.FromString(Position.ToString());
            args["velocity"]  = OSD.FromString(Velocity.ToString());
            args["center"]    = OSD.FromString(Center.ToString());
            args["size"]      = OSD.FromString(Size.ToString());
            args["at_axis"]   = OSD.FromString(AtAxis.ToString());
            args["left_axis"] = OSD.FromString(LeftAxis.ToString());
            args["up_axis"]   = OSD.FromString(UpAxis.ToString());

            //backwards compatibility
            args["changed_grid"]  = OSD.FromBoolean(SenderWantsToWaitForRoot);
            args["wait_for_root"] = OSD.FromBoolean(SenderWantsToWaitForRoot);
            args["far"]           = OSD.FromReal(Far);
            args["aspect"]        = OSD.FromReal(Aspect);

            if ((Throttles != null) && (Throttles.Length > 0))
            {
                args["throttles"] = OSD.FromBinary(Throttles);
            }

            args["locomotion_state"] = OSD.FromString(LocomotionState.ToString());
            args["head_rotation"]    = OSD.FromString(HeadRotation.ToString());
            args["body_rotation"]    = OSD.FromString(BodyRotation.ToString());
            args["control_flags"]    = OSD.FromString(ControlFlags.ToString());

            args["energy_level"] = OSD.FromReal(EnergyLevel);
            args["god_level"]    = OSD.FromString(GodLevel.ToString());
            args["always_run"]   = OSD.FromBoolean(AlwaysRun);
            args["prey_agent"]   = OSD.FromUUID(PreyAgent);
            args["agent_access"] = OSD.FromString(AgentAccess.ToString());

            args["active_group_id"] = OSD.FromUUID(ActiveGroupID);

            if ((Groups != null) && (Groups.Length > 0))
            {
                OSDArray groups = new OSDArray(Groups.Length);
                foreach (AgentGroupData agd in Groups)
                {
                    groups.Add(agd.PackUpdateMessage());
                }
                args["groups"] = groups;
            }

            if ((Anims != null) && (Anims.Length > 0))
            {
                OSDArray anims = new OSDArray(Anims.Length);
                foreach (Animation aanim in Anims)
                {
                    anims.Add(aanim.PackUpdateMessage());
                }
                args["animations"] = anims;
            }

            if (DefaultAnim != null)
            {
                args["default_animation"] = DefaultAnim.PackUpdateMessage();
            }

            if (AnimState != null)
            {
                args["animation_state"] = AnimState.PackUpdateMessage();
            }

            if (Appearance != null)
            {
                args["packed_appearance"] = Appearance.Pack();
            }

            //if ((AgentTextures != null) && (AgentTextures.Length > 0))
            //{
            //    OSDArray textures = new OSDArray(AgentTextures.Length);
            //    foreach (UUID uuid in AgentTextures)
            //        textures.Add(OSD.FromUUID(uuid));
            //    args["agent_textures"] = textures;
            //}

            // The code to pack textures, visuals, wearables and attachments
            // should be removed; packed appearance contains the full appearance
            // This is retained for backward compatibility only
            if (Appearance.Texture != null)
            {
                byte[] rawtextures = Appearance.Texture.GetBytes();
                args["texture_entry"] = OSD.FromBinary(rawtextures);
            }

            if ((Appearance.VisualParams != null) && (Appearance.VisualParams.Length > 0))
            {
                args["visual_params"] = OSD.FromBinary(Appearance.VisualParams);
            }

            // We might not pass this in all cases...
            if ((Appearance.Wearables != null) && (Appearance.Wearables.Length > 0))
            {
                OSDArray wears = new OSDArray(Appearance.Wearables.Length);
                foreach (AvatarWearable awear in Appearance.Wearables)
                {
                    wears.Add(awear.Pack());
                }

                args["wearables"] = wears;
            }

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

            if ((attachments != null) && (attachments.Count > 0))
            {
                OSDArray attachs = new OSDArray(attachments.Count);
                foreach (AvatarAttachment att in attachments)
                {
                    attachs.Add(att.Pack());
                }
                args["attachments"] = attachs;
            }
            // End of code to remove

            if ((Controllers != null) && (Controllers.Length > 0))
            {
                OSDArray controls = new OSDArray(Controllers.Length);
                foreach (ControllerData ctl in Controllers)
                {
                    controls.Add(ctl.PackUpdateMessage());
                }
                args["controllers"] = controls;
            }

            if ((CallbackURI != null) && (!CallbackURI.Equals("")))
            {
                args["callback_uri"] = OSD.FromString(CallbackURI);
            }

            // Attachment objects for fatpack messages
            if (AttachmentObjects != null)
            {
                int      i       = 0;
                OSDArray attObjs = new OSDArray(AttachmentObjects.Count);
                foreach (ISceneObject so in AttachmentObjects)
                {
                    OSDMap info = new OSDMap(4);
                    info["sog"]      = OSD.FromString(so.ToXml2());
                    info["extra"]    = OSD.FromString(so.ExtraToXmlString());
                    info["modified"] = OSD.FromBoolean(so.HasGroupChanged);
                    try
                    {
                        info["state"] = OSD.FromString(AttachmentObjectStates[i++]);
                    }
                    catch (IndexOutOfRangeException)
                    {
                        m_log.WarnFormat("[CHILD AGENT DATA]: scripts list is shorter than object list.");
                    }

                    attObjs.Add(info);
                }
                args["attach_objects"] = attObjs;
            }

            args["parent_part"] = OSD.FromUUID(ParentPart);
            args["sit_offset"]  = OSD.FromString(SitOffset.ToString());

            return(args);
        }