/// <summary>
        /// Remove an attachment if it exists
        /// </summary>
        /// <param name="itemID"></param>
        /// <returns>The AssetID for detached asset or UUID.Zero</returns>
        public UUID DetachAttachment(UUID itemID)
        {
            UUID assetID;

            lock (m_attachments)
            {
                foreach (KeyValuePair <int, List <AvatarAttachment> > kvp in m_attachments)
                {
                    int index = kvp.Value.FindIndex(delegate(AvatarAttachment a) { return(a.ItemID == itemID); });
                    if (index >= 0)
                    {
                        AvatarAttachment attachment = m_attachments[kvp.Key][index];
                        assetID = attachment.AssetID;

                        // Remove it from the list of attachments at that attach point
                        m_attachments[kvp.Key].RemoveAt(index);

                        // And remove the list if there are no more attachments here
                        if (m_attachments[kvp.Key].Count == 0)
                        {
                            m_attachments.Remove(kvp.Key);
                        }

                        return(assetID);
                    }
                }
            }

            return(UUID.Zero);
        }
        internal void ReplaceAttachment(AvatarAttachment attach)
        {
//            m_log.DebugFormat(
//                "[AVATAR APPEARANCE]: Replacing itemID={0}, assetID={1} at {2}",
//                attach.ItemID, attach.AssetID, attach.AttachPoint);

            lock (m_attachments)
            {
                m_attachments[attach.AttachPoint] = new List <AvatarAttachment>();
                m_attachments[attach.AttachPoint].Add(attach);
            }
        }
        internal void AppendAttachment(AvatarAttachment attach)
        {
//            m_log.DebugFormat(
//                "[AVATAR APPEARNCE]: Appending itemID={0}, assetID={1} at {2}",
//                attach.ItemID, attach.AssetID, attach.AttachPoint);

            lock (m_attachments)
            {
                if (!m_attachments.ContainsKey(attach.AttachPoint))
                {
                    m_attachments[attach.AttachPoint] = new List <AvatarAttachment>();
                }

                m_attachments[attach.AttachPoint].Add(attach);
            }
        }
        void SetAttachmentsString(string data)
        {
            string[] strings = data.Split(new char[] { ',' });
            int      i       = 0;

            List <AvatarAttachment> attachments = new List <AvatarAttachment>();

            while (strings.Length - i > 2)
            {
                int  attachpoint = Int32.Parse(strings[i]);
                UUID item        = new UUID(strings[i + 1]);
                UUID sogId       = new UUID(strings[i + 2]);
                i += 3;

                AvatarAttachment attachment = new AvatarAttachment(attachpoint, item, sogId);
                attachments.Add(attachment);
            }

            SetAttachments(attachments);
        }
Beispiel #5
0
 public AvatarAttachment(AvatarAttachment attach)
 {
     AttachPoint = attach.AttachPoint;
     ItemID      = attach.ItemID;
     AssetID     = attach.AssetID;
 }
 internal void ReplaceAttachment(AvatarAttachment attach)
 {
     m_attachments[attach.AttachPoint] = new List<AvatarAttachment>();
     m_attachments[attach.AttachPoint].Add(attach);
 }
Beispiel #7
0
        /// <summary>
        /// Unpack and OSDMap and initialize the appearance
        /// from it
        /// </summary>
        public void Unpack(OSDMap data)
        {
			if (m_log.IsDebugEnabled) {
				m_log.DebugFormat ("{0} called", System.Reflection.MethodBase.GetCurrentMethod ().Name);
			}

            if ((data != null) && (data["serial"] != null))
                m_serial = data["serial"].AsInteger();
            if ((data != null) && (data["height"] != null))
                m_avatarHeight = (float)data["height"].AsReal();

            try
            {
                // Hashes
                m_texturehashes = new UUID[AvatarAppearance.TEXTURE_COUNT];
                if ((data != null) && (data["hashes"] != null) && (data["hashes"]).Type == OSDType.Array)
                {
                    OSDArray hashes = (OSDArray)(data["hashes"]);
                    for (int i = 0; i < AvatarAppearance.TEXTURE_COUNT; i++)
                    {
                        UUID hashID = UUID.Zero;
                        if (i < hashes.Count && hashes[i] != null)
                            hashID = hashes[i].AsUUID();
                        m_texturehashes[i] = hashID;
                    }
                }
                else
                {
                    for (uint i = 0; i < AvatarAppearance.TEXTURE_COUNT; i++)
                        m_texturehashes[i] = UUID.Zero;
                }
                
                // Wearables
                SetDefaultWearables();
                if ((data != null) && (data["wearables"] != null) && (data["wearables"]).Type == OSDType.Array)
                {
                    OSDArray wears = (OSDArray)(data["wearables"]);
                    for (int i = 0; i < wears.Count; i++)
                        m_wearables[i] = new AvatarWearable((OSDArray)wears[i]);
                }
                else
                {
                    m_log.Warn("[AVATAR APPEARANCE]: failed to unpack wearables");
                }

                // Avatar Textures
                SetDefaultTexture();
                if ((data != null) && (data["textures"] != null) && (data["textures"]).Type == OSDType.Array)
                {
                    OSDArray textures = (OSDArray)(data["textures"]);
                    for (int i = 0; i < AvatarAppearance.TEXTURE_COUNT && i < textures.Count; i++)
                    {
                        UUID textureID = AppearanceManager.DEFAULT_AVATAR_TEXTURE;
                        if (textures[i] != null)
                            textureID = textures[i].AsUUID();
                        m_texture.CreateFace((uint)i).TextureID = new UUID(textureID);
                    }
                }
                else
                {
                    m_log.Warn("[AVATAR APPEARANCE]: failed to unpack textures");
                }

                // Visual Parameters
                SetDefaultParams();
                if ((data != null) && (data["visualparams"] != null))
                {
                    if ((data["visualparams"].Type == OSDType.Binary) || (data["visualparams"].Type == OSDType.Array))
                        m_visualparams = data["visualparams"].AsBinary();
                }
                else
                {
                    m_log.Warn("[AVATAR APPEARANCE]: failed to unpack visual parameters");
                }

                // Attachments
                m_attachments = new Dictionary<int, List<AvatarAttachment>>();
                if ((data != null) && (data["attachments"] != null) && (data["attachments"]).Type == OSDType.Array)
                {
                    OSDArray attachs = (OSDArray)(data["attachments"]);
                    for (int i = 0; i < attachs.Count; i++)
                    {
                        AvatarAttachment att = new AvatarAttachment((OSDMap)attachs[i]);
                        AppendAttachment(att);
                        
//                        m_log.DebugFormat(
//                            "[AVATAR APPEARANCE]: Unpacked attachment itemID {0}, assetID {1}, point {2}",
//                            att.ItemID, att.AssetID, att.AttachPoint);
                    }
                }
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[AVATAR APPEARANCE]: unpack failed badly: {0}{1}", e.Message, e.StackTrace);
            }
        }
 public void SetAttachments(ISceneEntity[] attachments)
 {
     ClearAttachments();
     foreach (ISceneEntity e in attachments)
     {
         AvatarAttachment a = new AvatarAttachment(e.GetAttachmentPoint(), e.RootChild.FromUserInventoryItemID, e.RootChild.FromUserInventoryAssetID);
         if (!m_attachments.ContainsKey(e.GetAttachmentPoint()))
             m_attachments.Add(e.GetAttachmentPoint(), new List<AvatarAttachment>());
         m_attachments[e.GetAttachmentPoint()].Add(a);
     }
 }
Beispiel #9
0
        /// <summary>
        /// Unpack and OSDMap and initialize the appearance
        /// from it
        /// </summary>
        public void Unpack(OSDMap data)
        {
            if (data == null)
            {
                m_log.Warn("[AVATAR APPEARANCE]: failed to unpack avatar appearance");
                return;
            }

            if (data.ContainsKey("owner"))
                m_owner = data["owner"].AsUUID();
            else
                m_owner = UUID.Zero;

            if (data.ContainsKey("serial"))
                m_serial = data["serial"].AsInteger();

            if (data.ContainsKey("height"))
                m_avatarHeight = (float)data["height"].AsReal();

            try
            {
                // Wearablles
                m_wearables = new Dictionary<int, AvatarWearable>();
                ClearWearables();

                if (data.ContainsKey("wearables") && ((data["wearables"]).Type == OSDType.Array))
                {
                    OSDArray wears = (OSDArray)data["wearables"];
                    for (int i = 0; i < wears.Count; i++)
                    {
                        AvatarWearable wearable = new AvatarWearable((OSDMap)wears[i]);
                        SetWearable(wearable);
                    }
                }
                else
                {
                    m_log.Warn("[AVATAR APPEARANCE]: failed to unpack wearables");
                }

                // Avatar Textures
                SetDefaultTexture();
                if (data.ContainsKey("textures") && ((data["textures"]).Type == OSDType.Array))
                {
                    OSDArray textures = (OSDArray)(data["textures"]);
                    for (int i = 0; i < AvatarAppearance.TEXTURE_COUNT && i < textures.Count; i++)
                    {
                        UUID textureID = AppearanceManager.DEFAULT_AVATAR_TEXTURE;
                        if (textures[i] != null)
                            textureID = textures[i].AsUUID();
                        m_texture.CreateFace((uint)i).TextureID = new UUID(textureID);
                    }
                }
                else
                {
                    m_log.Warn("[AVATAR APPEARANCE]: failed to unpack textures");
                }

                // Visual Parameters
                SetDefaultParams();
                if (data.ContainsKey("visualparams"))
                {
                    if ((data["visualparams"].Type == OSDType.Binary) || (data["visualparams"].Type == OSDType.Array))
                        m_visualparams = data["visualparams"].AsBinary();
                }
                else
                {
                    m_log.Warn("[AVATAR APPEARANCE]: failed to unpack visual parameters");
                }

                // Attachments
                m_attachments = new Dictionary<int, List<AvatarAttachment>>();
                if (data.ContainsKey("attachments") && ((data["attachments"]).Type == OSDType.Array))
                {
                    OSDArray attachs = (OSDArray)(data["attachments"]);
                    for (int i = 0; i < attachs.Count; i++)
                    {
                        AvatarAttachment att = new AvatarAttachment((OSDMap)attachs[i]);
                        AppendAttachment(att);
                    }
                }
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[AVATAR APPEARANCE]: unpack failed badly: {0}{1}", e.Message, e.StackTrace);
            }
        }
Beispiel #10
0
        internal void ReplaceAttachment(AvatarAttachment attach)
        {
			if (m_log.IsDebugEnabled) {
				m_log.DebugFormat ("{0} called", System.Reflection.MethodBase.GetCurrentMethod ().Name);
				m_log.DebugFormat("Replacing itemID={0}, assetID={1} at {2}",attach.ItemID, attach.AssetID, attach.AttachPoint);
			}


            lock (m_attachments)
            {
                m_attachments[attach.AttachPoint] = new List<AvatarAttachment>();
                m_attachments[attach.AttachPoint].Add(attach);
            }
        }
Beispiel #11
0
        internal void ReplaceAttachment(AvatarAttachment attach)
        {
//            m_log.DebugFormat(
//                "[AVATAR APPEARANCE]: Replacing itemID={0}, assetID={1} at {2}",
//                attach.ItemID, attach.AssetID, attach.AttachPoint);

            lock (m_attachments)
            {
                m_attachments[attach.AttachPoint] = new List<AvatarAttachment>();
                m_attachments[attach.AttachPoint].Add(attach);
            }
        }
 internal void AppendAttachment(AvatarAttachment attach)
 {
     if (!m_attachments.ContainsKey(attach.AttachPoint))
         m_attachments[attach.AttachPoint] = new List<AvatarAttachment>();
     m_attachments[attach.AttachPoint].Add(attach);
 }
Beispiel #13
0
 public AvatarAttachment(AvatarAttachment attach)
 {
     AttachPoint = attach.AttachPoint;
     ItemID = attach.ItemID;
     AssetID = attach.AssetID;
 }
        internal void AppendAttachment(AvatarAttachment attach)
        {
            //            m_log.DebugFormat(
            //                "[AVATAR APPEARNCE]: Appending itemID={0}, assetID={1} at {2}",
            //                attach.ItemID, attach.AssetID, attach.AttachPoint);

            m_attachmentsRwLock.AcquireWriterLock(-1);
            try
            {
                if (!m_attachments.ContainsKey(attach.AttachPoint))
                    m_attachments[attach.AttachPoint] = new List<AvatarAttachment>();

                m_attachments[attach.AttachPoint].Add(attach);
            }
            finally
            {
                m_attachmentsRwLock.ReleaseWriterLock();
            }
        }
        internal void ReplaceAttachment(AvatarAttachment attach)
        {
            //            m_log.DebugFormat(
            //                "[AVATAR APPEARANCE]: Replacing itemID={0}, assetID={1} at {2}",
            //                attach.ItemID, attach.AssetID, attach.AttachPoint);

            m_attachmentsRwLock.AcquireWriterLock(-1);
            try
            {
                m_attachments[attach.AttachPoint] = new List<AvatarAttachment>();
                m_attachments[attach.AttachPoint].Add(attach);
            }
            finally
            {
                m_attachmentsRwLock.ReleaseWriterLock();
            }
        }
        /// <summary>
        /// Unpack and OSDMap and initialize the appearance
        /// from it
        /// </summary>
        public void Unpack(OSDMap data)
        {
            if (data == null)
            {
                m_log.Warn("[AVATAR APPEARANCE]: failed to unpack avatar appearance");
                return;
            }

            if (data.ContainsKey("owner"))
            {
                m_owner = data["owner"].AsUUID();
            }
            else
            {
                m_owner = UUID.Zero;
            }

            if (data.ContainsKey("serial"))
            {
                m_serial = data["serial"].AsInteger();
            }

            if (data.ContainsKey("height"))
            {
                m_avatarHeight = (float)data["height"].AsReal();
            }

            try
            {
                // Wearablles
                m_wearables = new Dictionary <int, AvatarWearable>();
                ClearWearables();

                if (data.ContainsKey("wearables") && ((data["wearables"]).Type == OSDType.Array))
                {
                    OSDArray wears = (OSDArray)data["wearables"];
                    for (int i = 0; i < wears.Count; i++)
                    {
                        AvatarWearable wearable = new AvatarWearable((OSDMap)wears[i]);
                        SetWearable(wearable);
                    }
                }
                else
                {
                    m_log.Warn("[AVATAR APPEARANCE]: failed to unpack wearables");
                }

                // Avatar Textures
                SetDefaultTexture();
                if (data.ContainsKey("textures") && ((data["textures"]).Type == OSDType.Array))
                {
                    OSDArray textures = (OSDArray)(data["textures"]);
                    for (int i = 0; i < AvatarAppearance.TEXTURE_COUNT && i < textures.Count; i++)
                    {
                        UUID textureID = AppearanceManager.DEFAULT_AVATAR_TEXTURE;
                        if (textures[i] != null)
                        {
                            textureID = textures[i].AsUUID();
                        }
                        m_texture.CreateFace((uint)i).TextureID = new UUID(textureID);
                    }
                }
                else
                {
                    m_log.Warn("[AVATAR APPEARANCE]: failed to unpack textures");
                }

                // Visual Parameters
                SetDefaultParams();
                if (data.ContainsKey("visualparams"))
                {
                    if ((data["visualparams"].Type == OSDType.Binary) || (data["visualparams"].Type == OSDType.Array))
                    {
                        m_visualparams = data["visualparams"].AsBinary();
                    }
                }
                else
                {
                    m_log.Warn("[AVATAR APPEARANCE]: failed to unpack visual parameters");
                }

                // Attachments
                m_attachments = new Dictionary <int, List <AvatarAttachment> >();
                if (data.ContainsKey("attachments") && ((data["attachments"]).Type == OSDType.Array))
                {
                    OSDArray attachs = (OSDArray)(data["attachments"]);
                    for (int i = 0; i < attachs.Count; i++)
                    {
                        AvatarAttachment att = new AvatarAttachment((OSDMap)attachs[i]);
                        AppendAttachment(att);
                    }
                }
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[AVATAR APPEARANCE]: unpack failed badly: {0}{1}", e.Message, e.StackTrace);
            }
        }
Beispiel #17
0
        public List<AvatarAttachment> GetBotAttachments(UUID agentID, string outfitName)
        {
            Dictionary<string, object> param = new Dictionary<string, object>();
            param["?uuid"] = agentID.ToString();
            param["?outfitName"] = outfitName;
            List<AvatarAttachment> ret = new List<AvatarAttachment>();

            try
            {
                using (ISimpleDB conn = _connFactory.GetConnection())
                {
                    string query = "SELECT attachpoint, item, asset from botattachments WHERE UUID = ?uuid AND outfitName = ?outfitName";
                    using (IDataReader reader = conn.QueryAndUseReader(query, param))
                    {
                        while (reader.Read())
                        {
                            int attachpoint = Convert.ToInt32(reader["attachpoint"]);
                            UUID itemID = new UUID(reader["item"].ToString());
                            UUID assetID = new UUID(reader["asset"].ToString());
                            AvatarAttachment attachment = new AvatarAttachment(attachpoint, itemID, assetID);
                            ret.Add(attachment);
                        }

                        reader.Close();
                        return ret;
                    }
                }
            }
            catch (Exception e)
            {
                m_log.Error(e.ToString());
                return null;
            }
        }
Beispiel #18
0
        internal void AppendAttachment(AvatarAttachment attach)
        {
//            m_log.DebugFormat(
//                "[AVATAR APPEARNCE]: Appending itemID={0}, assetID={1} at {2}",
//                attach.ItemID, attach.AssetID, attach.AttachPoint);

            lock (m_attachments)
            {
                if (!m_attachments.ContainsKey(attach.AttachPoint))
                    m_attachments[attach.AttachPoint] = new List<AvatarAttachment>();
    
                foreach (AvatarAttachment prev in m_attachments[attach.AttachPoint])
                {
                    if (prev.ItemID == attach.ItemID)
                        return;
                }

                m_attachments[attach.AttachPoint].Add(attach);
            }
        }
        internal void AppendAttachment(AvatarAttachment attach)
        {
//            m_log.DebugFormat(
//                "[AVATAR APPEARNCE]: Appending itemID={0}, assetID={1} at {2}",
//                attach.ItemID, attach.AssetID, attach.AttachPoint);
            if (m_attachments[attach.AttachPoint].Find(delegate(AvatarAttachment a) { return a.ItemID == attach.ItemID;  }) == null)
            {
                m_attachments[attach.AttachPoint].Add(attach);
            }
        }
Beispiel #20
0
        /// <summary>
        /// Unpack and OSDMap and initialize the appearance
        /// from it
        /// </summary>
        public void Unpack(OSDMap data)
        {
            if ((data != null) && (data["serial"] != null))
                m_serial = data["serial"].AsInteger();
            if ((data != null) && (data["height"] != null))
//                m_avatarHeight = (float)data["height"].AsReal();
                SetSize(new Vector3(0.45f,0.6f, (float)data["height"].AsReal()));

            try
            {
                // Wearables
                SetDefaultWearables();
                if ((data != null) && (data["wearables"] != null) && (data["wearables"]).Type == OSDType.Array)
                {
                    OSDArray wears = (OSDArray)(data["wearables"]);

                    int count = wears.Count;

                    m_wearables = new AvatarWearable[count];

                    for (int i = 0; i < count; i++)
                        m_wearables[i] = new AvatarWearable((OSDArray)wears[i]);
                }
                else
                {
                    m_log.Warn("[AVATAR APPEARANCE]: failed to unpack wearables");
                }

                // Avatar Textures
                SetDefaultTexture();
                if ((data != null) && (data["textures"] != null) && (data["textures"]).Type == OSDType.Array)
                {
                    OSDArray textures = (OSDArray)(data["textures"]);
                    for (int i = 0; i < AvatarAppearance.TEXTURE_COUNT && i < textures.Count; i++)
                    {
                        UUID textureID = AppearanceManager.DEFAULT_AVATAR_TEXTURE;
                        if (textures[i] != null)
                            textureID = textures[i].AsUUID();
                        m_texture.CreateFace((uint)i).TextureID = new UUID(textureID);
                    }
                }
                else
                {
                    m_log.Warn("[AVATAR APPEARANCE]: failed to unpack textures");
                }

                if ((data != null) && (data["bakedcache"] != null) && (data["bakedcache"]).Type == OSDType.Array)
                {
                    OSDArray bakedOSDArray = (OSDArray)(data["bakedcache"]);
                    m_cacheitems = WearableCacheItem.BakedFromOSD(bakedOSDArray);
                }

                // Visual Parameters
                SetDefaultParams();
                if ((data != null) && (data["visualparams"] != null))
                {
                    if ((data["visualparams"].Type == OSDType.Binary) || (data["visualparams"].Type == OSDType.Array))
                        m_visualparams = data["visualparams"].AsBinary();
                }
                else
                {
                    m_log.Warn("[AVATAR APPEARANCE]: failed to unpack visual parameters");
                }

                // Attachments
                m_attachments = new Dictionary<int, List<AvatarAttachment>>();
                if ((data != null) && (data["attachments"] != null) && (data["attachments"]).Type == OSDType.Array)
                {
                    OSDArray attachs = (OSDArray)(data["attachments"]);
                    for (int i = 0; i < attachs.Count; i++)
                    {
                        AvatarAttachment att = new AvatarAttachment((OSDMap)attachs[i]);
                        AppendAttachment(att);
                        
//                        m_log.DebugFormat(
//                            "[AVATAR APPEARANCE]: Unpacked attachment itemID {0}, assetID {1}, point {2}",
//                            att.ItemID, att.AssetID, att.AttachPoint);
                    }
                }
            }
            catch (Exception e)
            {
                m_log.ErrorFormat("[AVATAR APPEARANCE]: unpack failed badly: {0}{1}", e.Message, e.StackTrace);
            }
        }
        internal void ReplaceAttachment(AvatarAttachment attach)
        {
//            m_log.DebugFormat(
//                "[AVATAR APPEARANCE]: Replacing itemID={0}, assetID={1} at {2}",
//                attach.ItemID, attach.AssetID, attach.AttachPoint);

            ThreadedClasses.RwLockedList<AvatarAttachment> newList = new ThreadedClasses.RwLockedList<AvatarAttachment>();
            newList.Add(attach);
            m_attachments[attach.AttachPoint] = newList;
        }
 /// <summary>
 /// Replace the attachment
 /// </summary>
 /// <param name="attach"></param>
 /// <returns>Whether attachments changed</returns>
 internal bool ReplaceAttachment(AvatarAttachment attach)
 {
     bool result = true;
     if (m_attachments.ContainsKey(attach.AttachPoint))
     {
         if (m_attachments[attach.AttachPoint].Contains(attach))
             result = false;
     }
     m_attachments[attach.AttachPoint] = new List<AvatarAttachment>();
     m_attachments[attach.AttachPoint].Add(attach);
     return result;
 }
Beispiel #23
0
        void SetAttachmentsString(string data)
        {
            string[] strings = data.Split(new char[] { ',' });
            int i = 0;

            List<AvatarAttachment> attachments = new List<AvatarAttachment>();

            while (strings.Length - i > 2)
            {
                int attachpoint = Int32.Parse(strings[i]);
                UUID item = new UUID(strings[i + 1]);
                UUID sogId = new UUID(strings[i + 2]);
                i += 3;

                AvatarAttachment attachment = new AvatarAttachment(attachpoint, item, sogId);
                attachments.Add(attachment);
            }

            SetAttachments(attachments);
        }