示例#1
0
        private static UUID CreateItem(Dictionary <UUID, InventoryBase> inventory, UUID parentID, string name, string description,
                                       WearableType wearableType, UUID assetID, string assetType, UUID agentID)
        {
            InventoryItem item = new InventoryItem();

            item.ID           = UUID.Random();
            item.Name         = name;
            item.Description  = description;
            item.OwnerID      = agentID;
            item.ParentID     = parentID;
            item.AssetID      = assetID;
            item.ContentType  = assetType;
            item.CreationDate = DateTime.UtcNow;

            // HACK: Set LLInventoryItem flags
            item.ExtraData["flags"] = OSD.FromInteger((int)wearableType);

            // HACK: Set default LLInventoryItem permissions
            Permissions perm = Permissions.NoPermissions;

            perm.BaseMask                 = PermissionMask.All;
            perm.OwnerMask                = PermissionMask.All;
            perm.NextOwnerMask            = PermissionMask.All;
            item.ExtraData["permissions"] = perm.GetOSD();

            InventoryBase parent;

            if (inventory.TryGetValue(parentID, out parent) && parent is InventoryFolder)
            {
                ((InventoryFolder)parent).Children[item.ID] = item;
            }

            inventory[item.ID] = item;
            return(item.ID);
        }
示例#2
0
        public WearableInfo this[WearableType type, uint index]
        {
            get
            {
                if (index >= 5)
                {
                    throw new KeyNotFoundException();
                }
                return(m_WearablesUpdateLock.AcquireReaderLock(() => m_Wearables[type][(int)index]));
            }

            set
            {
                m_WearablesUpdateLock.AcquireWriterLock(() =>
                {
                    var wearableList = m_Wearables[type];
                    if (wearableList.Count <= index)
                    {
                        if (index >= 5)
                        {
                            throw new KeyNotFoundException();
                        }
                        wearableList.Add(value);
                    }
                    else
                    {
                        wearableList[(int)index] = value;
                    }
                });
            }
        }
示例#3
0
 public WearableSprite(XElement subElement, WearableType type)
 {
     Type          = type;
     SourceElement = subElement;
     SpritePath    = subElement.GetAttributeString("texture", string.Empty);
     Init();
     switch (type)
     {
     case WearableType.Hair:
     case WearableType.Beard:
     case WearableType.Moustache:
     case WearableType.FaceAttachment:
     case WearableType.JobIndicator:
     case WearableType.Husk:
     case WearableType.Herpes:
         Limb                = LimbType.Head;
         HideLimb            = type == WearableType.Husk || type == WearableType.Herpes;
         HideOtherWearables  = false;
         InheritLimbDepth    = true;
         InheritTextureScale = true;
         InheritOrigin       = true;
         InheritSourceRect   = true;
         break;
     }
 }
示例#4
0
 /// <summary>
 /// Gets the path for a new patch operation to add a wearable.
 /// </summary>
 /// <param name="type">Wearable type.</param>
 /// <returns>Patch path.</returns>
 private static string GetPatchPath(WearableType type)
 {
     switch (type)
     {
     default:
         return(string.Format("/{0}/-", type.ToString().ToLowerInvariant()));
     }
 }
示例#5
0
        public bool Wear(WearableType type, BodyPartType bodyPart, BodyOrientation orientation, CharacterGender gender)
        {
            State.CurrentOrientation = orientation;
            State.CurrentGender      = gender;
            //update the current state
            worlditem.State = StateName(this);

            return(false);
        }
示例#6
0
 public void Add(WearableType type, WearableInfo w)
 {
     m_WearablesUpdateLock.AcquireWriterLock(() =>
     {
         if (m_Wearables[type].Count >= 5)
         {
             throw new ArgumentException("Too many elements in list");
         }
         m_Wearables[type].Add(w);
     });
 }
 public TextureEntry(
     string name,
     bool isLocal,
     BakedTextureIndex bakedTextureIndex = BakedTextureIndex.NumIndices,
     string defaultImageName             = "",
     WearableType wearableType           = WearableType.Invalid)
 {
     IsLocal = isLocal;
     IsBaked = !isLocal;
     IsUsedByBakedTexture = bakedTextureIndex != BakedTextureIndex.NumIndices;
     BakedTextureIndex    = bakedTextureIndex;
     DefaultImageName     = defaultImageName;
     WearableType         = wearableType;
 }
示例#8
0
        /// <summary>
        /// Replaces the current outfit and updates COF links accordingly
        /// </summary>
        /// <param name="outfit">List of new wearables and attachments that comprise the new outfit</param>
        public void ReplaceOutfit(List <InventoryItem> newOutfit)
        {
            // Resolve inventory links
            List <InventoryItem> outfit = new List <InventoryItem>();

            foreach (var item in newOutfit)
            {
                outfit.Add(RealInventoryItem(item));
            }

            // Remove links to all exiting items
            List <UUID> toRemove = new List <UUID>();

            ContentLinks().ForEach(item =>
            {
                if (IsBodyPart(item))
                {
                    WearableType linkType = ((InventoryWearable)RealInventoryItem(item)).WearableType;
                    bool hasBodyPart      = newOutfit.Select(RealInventoryItem).Where(IsBodyPart).Any(newItem =>
                                                                                                      ((InventoryWearable)newItem).WearableType == linkType);

                    if (hasBodyPart)
                    {
                        toRemove.Add(item.UUID);
                    }
                }
                else
                {
                    toRemove.Add(item.UUID);
                }
            });

            Client.Inventory.Remove(toRemove, null);

            // Add links to new items
            List <InventoryItem> newItems = outfit.FindAll(CanBeWorn);

            foreach (var item in newItems)
            {
                AddLink(item);
            }

            Client.Appearance.ReplaceOutfit(outfit, false);
            WorkPool.QueueUserWorkItem(sync =>
            {
                Thread.Sleep(2000);
                Client.Appearance.RequestSetAppearance(true);
            });
        }
示例#9
0
        /// <summary>
        /// Adds an item name to the proper wearables array.
        /// </summary>
        /// <param name="path">Asset path used to determine item type.</param>
        /// <param name="item">Item json.</param>
        /// <param name="wearables">Wearables to add the item name to.</param>
        private static void HandleItemName(string path, string item, Dictionary <WearableType, JArray> wearables)
        {
            try
            {
                JObject      wearable     = JObject.Parse(item);
                WearableType wearableType = GetWearableType(Path.GetExtension(path));

                string itemName = wearable["itemName"].Value <string>();
                wearables[wearableType].Add(itemName);
            }
            catch (Exception exc)
            {
                Console.WriteLine("Skipped file '{0}': {1}", path, exc.Message);
            }
        }
示例#10
0
        /// <summary>
        /// Adds an item to the proper wearables array.
        /// </summary>
        /// <param name="path">Asset path (including file name).</param>
        /// <param name="item">Item json.</param>
        /// <param name="wearables">Wearables to add wearable item to.</param>
        /// <param name="parameters">Optional additional parameters to copy from the item.</param>
        private static void HandleItem(string path, string item, Dictionary <WearableType, JArray> wearables, string[] parameters = null)
        {
            try
            {
                JObject      wearable     = JObject.Parse(item);
                WearableType wearableType = GetWearableType(Path.GetExtension(path));
                wearable = WearableConverter.Convert(wearable, path.Substring(0, path.LastIndexOf("/") + 1), path.Substring(path.LastIndexOf("/") + 1), parameters);

                wearables[wearableType].Add(wearable);
            }
            catch (Exception exc)
            {
                Console.WriteLine("Skipped file '{0}': {1}", path, exc.Message);
            }
        }
示例#11
0
        public List <InventoryItem> GetWornAt(WearableType type)
        {
            var ret = new List <InventoryItem>();

            ContentLinks().ForEach(link =>
            {
                var item = RealInventoryItem(link);
                if (item is InventoryWearable)
                {
                    var w = (InventoryWearable)item;
                    if (w.WearableType == type)
                    {
                        ret.Add(item);
                    }
                }
            });

            return(ret);
        }
示例#12
0
        public WearableData(WearableData data)
        {
            Type             = data.Type;
            this.impactSound = data.impactSound;
            this.stepSound   = data.stepSound;

            Attributes = new List <ItemAttribute>();
            for (int i = 0; i < data.Attributes.Count; i++)
            {
                Attributes.Add(data.Attributes[i]);
            }

            Resistances = new List <ResistanceData>();
            if (data.Resistances != null)
            {
                for (int i = 0; i < data.Resistances.Count; i++)
                {
                    Resistances.Add(new ResistanceData(data.Resistances[i]));
                }
            }
        }
示例#13
0
        public WearableData(WearableType type, int armor, int dodge, int block, int actions, List <ResistanceData> resistances, string impactSound, string stepSound)
        {
            Type             = type;
            this.impactSound = impactSound;
            this.stepSound   = stepSound;

            Attributes = new List <ItemAttribute>();
            Attributes.Add(new ItemAttribute((int)WearableAttributes.Actions, actions));
            Attributes.Add(new ItemAttribute((int)WearableAttributes.Armor, armor));
            Attributes.Add(new ItemAttribute((int)WearableAttributes.Block, block));
            Attributes.Add(new ItemAttribute((int)WearableAttributes.Dodge, dodge));

            Resistances = new List <ResistanceData>();
            if (resistances != null)
            {
                for (int i = 0; i < resistances.Count; i++)
                {
                    Resistances.Add(new ResistanceData(resistances[i]));
                }
            }
        }
示例#14
0
        public static bool CanWear(WearableType type, BodyPartType bodyPart, BodyOrientation orientation, IWIBase itemBase)
        {
            WorldItem item = null;

            if (itemBase.IsWorldItem)
            {
                item = itemBase.worlditem;
            }
            else
            {
                //use the item to get the template
                WorldItem prefab = null;
                WorldItems.Get.PackPrefab(itemBase.PackName, itemBase.PrefabName, out item);
            }

            if (item == null)
            {
                //whoops, not sure what went wrong here
                return(false);
            }

            bool     result   = false;
            Wearable wearable = null;

            if (item.worlditem.Is <Wearable>(out wearable))
            {
                bool matchesType        = Flags.Check((uint)wearable.Type, (uint)type, Flags.CheckType.MatchAny);
                bool matchesOrientation = (wearable.Orientation == BodyOrientation.None && orientation == BodyOrientation.None) ||
                                          Flags.Check((uint)wearable.Orientation, (uint)orientation, Flags.CheckType.MatchAny);
                bool matchesBodyPart = wearable.BodyPart == bodyPart;
                //Debug.Log("Matches type? " + matchesType.ToString() + " matches orientation? " + matchesOrientation.ToString() + " matchesBodyPart? " + matchesBodyPart.ToString());
                result = matchesType & matchesOrientation & matchesBodyPart;
            }
            else
            {
                Debug.Log("World item " + itemBase.FileName + " is not wearable");
            }
            return(result);
        }
示例#15
0
        public List <WearableInfo> this[WearableType type]
        {
            get
            {
                return(m_WearablesUpdateLock.AcquireReaderLock(() =>
                {
                    /* do not give access to our internal data via references */
                    List <WearableInfo> s = m_Wearables[type];
                    var l = new List <WearableInfo>();
                    foreach (var i in s)
                    {
                        l.Add(i);
                    }
                    return l;
                }));
            }

            set
            {
                var nl = new List <WearableInfo>();
                if (value.Count > 5)
                {
                    throw new ArgumentException("Too many elements in list");
                }
                /* do not give access to our internal data */
                foreach (var wi in value)
                {
                    nl.Add(wi);
                }
                if (nl.Count > 5)
                {
                    throw new ArgumentException("Too many elements in list");
                }
                m_WearablesUpdateLock.AcquireWriterLock(() =>
                {
                    m_Wearables[type] = nl;
                });
            }
        }
示例#16
0
 /// <summary>
 /// Removes an existing wearable object.
 /// </summary>
 /// <param name="wearableType"></param>
 /// <param name="editorMode">Is Editor Mode or not.</param>
 public void RemoveWearable(WearableType wearableType, bool editorMode)
 {
     if (_wearables != null)
     {
         //Iterate over all the associated wearables and remove the active one.
         foreach (Wearable w in _wearables)
         {
             if (w.WearableType == wearableType && w.IsActive)
             {
                 if (editorMode)
                 {
                     DestroyImmediate(w.AttachedGameObject);
                 }
                 else
                 {
                     Destroy(w.AttachedGameObject);
                 }
                 w.RemoveGameObject();
             }
         }
     }
 }
示例#17
0
        public bool IsWearing(WearableType typeOfWearable, BodyPartType onBodyPart, BodyOrientation orientation, string articlePrefabName)
        {
            bool             upperBody = true;
            int              index     = Wearables.GetWearableIndex(onBodyPart, orientation, ref upperBody);
            WIStackContainer container = null;

            if (upperBody)
            {
                container = State.UpperBodyContainer;
            }
            else
            {
                container = State.LowerBodyContainer;
            }
            WIStack stack = container.StackList[index];
            IWIBase wearableItem;

            if (stack.HasTopItem)
            {
                wearableItem = stack.TopItem;
                if (Wearable.CanWear(typeOfWearable, onBodyPart, orientation, wearableItem))
                {
                    //has top item and we can wear that item, so yes we are wearing it
                    if (!string.IsNullOrEmpty(articlePrefabName))
                    {
                        if (string.Equals(wearableItem.PrefabName, articlePrefabName))
                        {
                            return(true);
                        }
                    }
                    else
                    {
                        // no need to check for article
                        return(true);
                    }
                }
            }
            return(false);
        }
示例#18
0
        private WearableSprite GetWearableSprite(WearableType type, bool random = false)
        {
            var info = character.Info;

            if (info == null)
            {
                return(null);
            }
            XElement element;

            if (random)
            {
                element = info.FilterByTypeAndHeadID(character.Info.FilterElementsByGenderAndRace(character.Info.Wearables), type)?.GetRandom(Rand.RandSync.ClientOnly);
            }
            else
            {
                element = info.FilterByTypeAndHeadID(character.Info.FilterElementsByGenderAndRace(character.Info.Wearables), type)?.FirstOrDefault();
            }
            if (element != null)
            {
                return(new WearableSprite(element.Element("sprite"), type));
            }
            return(null);
        }
示例#19
0
        /// <summary>
        /// Returns the assetID for a given WearableType 
        /// </summary>
        /// <param name="type">the <seealso cref="OpenMetaverse.WearableType"/> of the asset</param>
        /// <returns>The <seealso cref="OpenMetaverse.Guid"/> of the WearableType</returns>
        public Guid GetWearableAsset(WearableType type)
        {
            WearableData wearable;

            if (Wearables.TryGetValue(type, out wearable))
                return wearable.Item.AssetGuid;
            else
                return Guid.Empty;
        }
示例#20
0
 /// <summary>
 /// Converts a WearableType to a bodypart or clothing WearableType
 /// </summary>
 /// <param name="type">A WearableType</param>
 /// <returns>AssetType.Bodypart or AssetType.Clothing or AssetType.Unknown</returns>
 public static AssetType WearableTypeToAssetType(WearableType type)
 {
     switch (type)
     {
         case WearableType.Shape:
         case WearableType.Skin:
         case WearableType.Hair:
         case WearableType.Eyes:
             return AssetType.Bodypart;
         case WearableType.Shirt:
         case WearableType.Pants:
         case WearableType.Shoes:
         case WearableType.Socks:
         case WearableType.Jacket:
         case WearableType.Gloves:
         case WearableType.Undershirt:
         case WearableType.Underpants:
         case WearableType.Skirt:
         case WearableType.Tattoo:
         case WearableType.Alpha:
         case WearableType.Physics:
             return AssetType.Clothing;
         default:
             return AssetType.Unknown;
     }
 }
示例#21
0
 private static AssetType WearableTypeToAssetType(WearableType type)
 {
     switch (type)
     {
         case WearableType.Shape:
         case WearableType.Skin:
         case WearableType.Hair:
         case WearableType.Eyes:
             return AssetType.Bodypart;
         case WearableType.Shirt:
         case WearableType.Pants:
         case WearableType.Shoes:
         case WearableType.Socks:
         case WearableType.Jacket:
         case WearableType.Gloves:
         case WearableType.Undershirt:
         case WearableType.Underpants:
         case WearableType.Skirt:
             return AssetType.Clothing;
         default:
             throw new Exception("Unhandled wearable type " + type);
     }
 }
示例#22
0
        /// <summary>
        /// Creates a wearable inventory item referencing an asset upload. 
        /// Second Life v1.9 uses this method to create wearable inventory items.
        /// </summary>
        /// <param name="parentFolder"></param>
        /// <param name="name"></param>
        /// <param name="description"></param>
        /// <param name="type"></param>
        /// <param name="wearableType"></param>
        /// <param name="invType"></param>
        /// <param name="nextOwnerMask"></param>
        /// <param name="callback"></param>
        /// <param name="assetTransactionID">Proper use is to upload the inventory's asset first, then provide the Asset's TransactionID here.</param>
        public void RequestCreateItem(UUID parentFolder, string name, string description, AssetType type, UUID assetTransactionID,
            InventoryType invType, WearableType wearableType, PermissionMask nextOwnerMask, ItemCreatedCallback callback)
        {
            CreateInventoryItemPacket create = new CreateInventoryItemPacket();
            create.AgentData.AgentID = _Agents.AgentID;
            create.AgentData.SessionID = _Agents.SessionID;

            create.InventoryBlock.CallbackID = RegisterItemCreatedCallback(callback);
            create.InventoryBlock.FolderID = parentFolder;
            create.InventoryBlock.TransactionID = assetTransactionID;
            create.InventoryBlock.NextOwnerMask = (uint)nextOwnerMask;
            create.InventoryBlock.Type = (sbyte)type;
            create.InventoryBlock.InvType = (sbyte)invType;
            create.InventoryBlock.WearableType = (byte)wearableType;
            create.InventoryBlock.Name = Utils.StringToBytes(name);
            create.InventoryBlock.Description = Utils.StringToBytes(description);

            _Network.SendPacket(create);
        }
        protected InventorySquareWearable CreateWearableSquare(GameObject parentObject, Vector3 squarePosition, WearableType type, BodyPartType bodyPart, BodyOrientation orientation, WIStack stack)
        {
            //Debug.Log("Creating wearable square: " + type.ToString() + ", " + bodyPart.ToString() + ", " + orientation.ToString());

            GameObject inventorySquareGameObject = NGUITools.AddChild(parentObject, GUIManager.Get.InventorySquareWearable);
            InventorySquareWearable square       = inventorySquareGameObject.GetComponent <InventorySquareWearable>();

            square.BodyPart                = bodyPart;
            square.Orientation             = orientation;
            square.Type                    = type;
            square.transform.localPosition = squarePosition;
            square.SetStack(stack);

            Squares.Add(square);

            stack.RefreshAction += Refresh;

            return(square);
        }
示例#24
0
 public WearableItem(string wearableName)
 {
     WearableName = wearableName;
     WearType = ConvertNameToType(WearableName);
 }
示例#25
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="manager"></param>
 /// <param name="name"></param>
 /// <param name="description"></param>
 /// <param name="folderID"></param>
 /// <param name="uuidOwnerCreater"></param>
 internal InventoryWearable(InventoryManager manager, string name, string description, LLUUID folderID, LLUUID uuidOwnerCreater, WearableType wtype)
     : base(manager, name, description, folderID, 18, (sbyte)wtype, uuidOwnerCreater)
 {
 }
示例#26
0
 /// <summary>
 /// Removes an existing wearable object.
 /// </summary>
 /// <param name="wearableType"></param>
 public void RemoveWearable(WearableType wearableType)
 {
     RemoveWearable(wearableType, false);
 }
示例#27
0
    /// <summary>
    /// Applies the wearable on the character.
    /// </summary>
    /// <param name="wearableType">Type of wearable.</param>
    /// <param name="wearableName">Wearable Name</param>
    /// <param name="editorMode">Is Editor Mode or not.</param>
    public void ApplyWearable(WearableType wearableType, string wearableName, bool editorMode)
    {
        //Check if the person mesh renderer is initialized or not.
        //If not initialized then lazy load it.
        if (_personMeshRenderer == null || _personMeshRenderer.ToString() == "null" || _personBoneMap == null)
        {
            LoadPersonMeshRenderer();
        }

        if (_wearables != null && _wearables.Exists(w => w.Name == wearableName))
        {
            Wearable wearable = _wearables.Find(w => w.Name == wearableName);
            if (wearable != null)
            {
                //Load the wearable gameobject first and cache it.
                GameObject g = Resources.Load(string.Format("Characters/{0}/Wearables/{1}", wearable.CharacterFolderName, wearable.Name), typeof(GameObject)) as GameObject;
                if (g != null)
                {
                    g = Instantiate(g);

                    g.transform.parent        = transform;
                    g.transform.localPosition = new Vector3(0, 0, 0);
                    g.transform.localRotation = Quaternion.identity;

                    //Set the wearable mesh renderer
                    Helper helper = new Helper();
                    _wearableMeshRenderer = helper.GetSkinMeshRecursive(g.transform);

                    g.SetActive(false);
                }

                //Remove the existing wearable
                RemoveWearable(wearableType, editorMode);

                //Apply the new wearable
                if (_wearableMeshRenderer != null)
                {
                    g.SetActive(true);
                    Transform[] newBones = new Transform[_wearableMeshRenderer.bones.Length];
                    for (int i = 0; i < _wearableMeshRenderer.bones.Length; ++i)
                    {
                        GameObject bone = _wearableMeshRenderer.bones[i].gameObject;
                        if (_personBoneMap.ContainsKey(bone.name))
                        {
                            newBones[i] = _personBoneMap[bone.name];
                        }
                        else
                        {
                            newBones[i] = _wearableMeshRenderer.bones[i];
                        }
                    }
                    _wearableMeshRenderer.bones = newBones;
                    wearable.AttachGameObject(g);
                }
                else
                {
                    if (editorMode)
                    {
                        DestroyImmediate(g);
                    }
                    else
                    {
                        Destroy(g);
                    }
                }
            }
        }
    }
示例#28
0
 /// <summary>
 /// Applies the wearable on the character.
 /// </summary>
 /// <param name="wearableType">Type of wearable.</param>
 /// <param name="wearableName">Wearable Name</param>
 public void ApplyWearable(WearableType wearableType, string wearableName)
 {
     ApplyWearable(wearableType, wearableName, false);
 }
示例#29
0
        public override bool Decode()
        {
            int version = -1;

            Permissions = new Permissions();
            string data = Helpers.FieldToUTF8String(AssetData);

            string[] lines = data.Split('\n');
            for (int stri = 0; stri < lines.Length; stri++)
            {
                if (stri == 0)
                {
                    string versionstring = lines[stri];
                    version = Int32.Parse(versionstring.Split(' ')[2]);
                    if (version != 22 && version != 18)
                    {
                        return(false);
                    }
                }
                else if (stri == 1)
                {
                    Name = lines[stri];
                }
                else if (stri == 2)
                {
                    Description = lines[stri];
                }
                else
                {
                    string   line   = lines[stri].Trim();
                    string[] fields = line.Split('\t');

                    if (fields.Length == 1)
                    {
                        fields = line.Split(' ');
                        if (fields[0] == "parameters")
                        {
                            int count = Int32.Parse(fields[1]) + stri;
                            for (; stri < count;)
                            {
                                stri++;
                                line   = lines[stri].Trim();
                                fields = line.Split(' ');

                                int id = Int32.Parse(fields[0]);
                                if (fields[1] == ",")
                                {
                                    fields[1] = "0";
                                }
                                else
                                {
                                    fields[1] = fields[1].Replace(',', '.');
                                }

                                float weight = float.Parse(fields[1], System.Globalization.NumberStyles.Float,
                                                           Helpers.EnUsCulture.NumberFormat);

                                Params[id] = weight;
                            }
                        }
                        else if (fields[0] == "textures")
                        {
                            int count = Int32.Parse(fields[1]) + stri;
                            for (; stri < count;)
                            {
                                stri++;
                                line   = lines[stri].Trim();
                                fields = line.Split(' ');

                                AppearanceManager.TextureIndex id = (AppearanceManager.TextureIndex)Int32.Parse(fields[0]);
                                LLUUID texture = new LLUUID(fields[1]);

                                Textures[id] = texture;
                            }
                        }
                        else if (fields[0] == "type")
                        {
                            WearableType = (WearableType)Int32.Parse(fields[1]);
                        }
                    }
                    else if (fields.Length == 2)
                    {
                        switch (fields[0])
                        {
                        case "creator_mask":
                            // Deprecated, apply this as the base mask
                            Permissions.BaseMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                            break;

                        case "base_mask":
                            Permissions.BaseMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                            break;

                        case "owner_mask":
                            Permissions.OwnerMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                            break;

                        case "group_mask":
                            Permissions.GroupMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                            break;

                        case "everyone_mask":
                            Permissions.EveryoneMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                            break;

                        case "next_owner_mask":
                            Permissions.NextOwnerMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                            break;

                        case "creator_id":
                            Creator = new LLUUID(fields[1]);
                            break;

                        case "owner_id":
                            Owner = new LLUUID(fields[1]);
                            break;

                        case "last_owner_id":
                            LastOwner = new LLUUID(fields[1]);
                            break;

                        case "group_id":
                            Group = new LLUUID(fields[1]);
                            break;

                        case "group_owned":
                            GroupOwned = (Int32.Parse(fields[1]) != 0);
                            break;

                        case "sale_type":
                            ForSale = InventoryManager.StringToSaleType(fields[1]);
                            break;

                        case "sale_price":
                            SalePrice = Int32.Parse(fields[1]);
                            break;

                        case "sale_info":
                            // Container for sale_type and sale_price, ignore
                            break;

                        default:
                            return(false);
                        }
                    }
                }
            }

            return(true);
        }
示例#30
0
        public List<InventoryItem> GetWornAt(WearableType type)
        {
            var ret = new List<InventoryItem>();
            ContentLinks().ForEach(link =>
            {
                var item = RealInventoryItem(link);
                if (item is InventoryWearable)
                {
                    var w = (InventoryWearable)item;
                    if (w.WearableType == type)
                    {
                        ret.Add(item);
                    }
                }
            });

            return ret;
        }
示例#31
0
        public override void Decode()
        {
            int version = -1;
            int n = -1;
            string data = Helpers.FieldToUTF8String(AssetData);

            n = data.IndexOf('\n');
            version = Int32.Parse(data.Substring(19, n - 18));
            data = data.Remove(0, n);

            if (version != 22)
                throw new Exception("Wearable asset has unrecognized version " + version);

            n = data.IndexOf('\n');
            Name = data.Substring(0, n);
            data = data.Remove(0, n);

            n = data.IndexOf('\n');
            Description = data.Substring(0, n);
            data = data.Remove(0, n);

            // Split in to an upper and lower half
            string[] parts = data.Split(new string[] { "parameters" }, StringSplitOptions.None);
            parts[1] = "parameters" + parts[1];

            Permissions = new Permissions();

            // Parse the upper half
            string[] lines = parts[0].Split('\n');
            foreach (string thisline in lines)
            {
                string line = thisline.Trim();
                string[] fields = line.Split('\t');

                if (fields.Length == 2)
                {
                    if (fields[0] == "creator_mask")
                    {
                        // Deprecated, apply this as the base mask
                        Permissions.BaseMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                    }
                    else if (fields[0] == "base_mask")
                    {
                        Permissions.BaseMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                    }
                    else if (fields[0] == "owner_mask")
                    {
                        Permissions.OwnerMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                    }
                    else if (fields[0] == "group_mask")
                    {
                        Permissions.GroupMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                    }
                    else if (fields[0] == "everyone_mask")
                    {
                        Permissions.EveryoneMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                    }
                    else if (fields[0] == "next_owner_mask")
                    {
                        Permissions.NextOwnerMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                    }
                    else if (fields[0] == "creator_id")
                    {
                        Creator = new LLUUID(fields[1]);
                    }
                    else if (fields[0] == "owner_id")
                    {
                        Owner = new LLUUID(fields[1]);
                    }
                    else if (fields[0] == "last_owner_id")
                    {
                        LastOwner = new LLUUID(fields[1]);
                    }
                    else if (fields[0] == "group_id")
                    {
                        Group = new LLUUID(fields[1]);
                    }
                    else if (fields[0] == "group_owned")
                    {
                        GroupOwned = (Int32.Parse(fields[1]) != 0);
                    }
                    else if (fields[0] == "sale_type")
                    {
                        ForSale = InventoryManager.StringToSaleType(fields[1]);
                    }
                    else if (fields[0] == "sale_price")
                    {
                        SalePrice = Int32.Parse(fields[1]);
                    }
                }
                else if (line.StartsWith("type "))
                {
                    WearableType = (WearableType)Int32.Parse(line.Substring(5));
                    break;
                }
            }

            // Break up the lower half in to parameters and textures
            string[] lowerparts = parts[1].Split(new string[] { "textures" }, StringSplitOptions.None);
            lowerparts[1] = "textures" + lowerparts[1];

            // Parse the parameters
            lines = lowerparts[0].Split('\n');
            foreach (string line in lines)
            {
                string[] fields = line.Split(' ');

                // Use exception handling to deal with all the lines we aren't interested in
                try
                {
                    int id = Int32.Parse(fields[0]);
                    if (fields[1] == ",")
                    {
                        fields[1] = "0";
                    }
                    else
                    {
                        fields[1] = fields[1].Replace(',', '.');
                    }
                    float weight = Single.Parse(fields[1], System.Globalization.NumberStyles.Float,
                        Helpers.EnUsCulture.NumberFormat);

                    Params[id] = weight;
                }
                catch (Exception)
                {
                }
            }

            // Parse the textures
            lines = lowerparts[1].Split('\n');
            foreach (string line in lines)
            {
                string[] fields = line.Split(' ');

                // Use exception handling to deal with all the lines we aren't interested in
                try
                {
                    AppearanceManager.TextureIndex id = (AppearanceManager.TextureIndex)Int32.Parse(fields[0]);
                    LLUUID texture = new LLUUID(fields[1]);

                    Textures[id] = texture;
                }
                catch (Exception)
                {
                }
            }
        }
 /// <summary>
 /// 
 /// </summary>
 /// <param name="manager"></param>
 /// <param name="name"></param>
 /// <param name="description"></param>
 /// <param name="folderID"></param>
 /// <param name="uuidOwnerCreater"></param>
 internal InventoryWearable(InventoryManager manager, string name, string description, LLUUID folderID, LLUUID uuidOwnerCreater, WearableType wtype)
     : base(manager, name, description, folderID, 18, (sbyte)wtype, uuidOwnerCreater)
 {
 }
示例#33
0
        public Wearable(AssetData asset)
        {
            var lines = Encoding.UTF8.GetString(asset.Data).Split('\n');

            var versioninfo = lines[0].Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);

            if (versioninfo[0] != "LLWearable")
            {
                throw new NotAWearableFormatException();
            }

            SaleInfo.PermMask = (InventoryPermissionsMask)0x7FFFFFFF;

            Name        = lines[1].Trim();
            Description = lines[2].Trim();

            int idx = 2;

            while (++idx < lines.Length)
            {
                var line = lines[idx].Trim();
                var para = line.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                if (para.Length == 2 && para[0] == "type")
                {
                    int i;
                    if (!int.TryParse(para[1], out i))
                    {
                        throw new NotAWearableFormatException();
                    }
                    Type = (WearableType)i;
                }
                else if (para.Length == 2 && para[0] == "parameters")
                {
                    /* we got a parameter block */
                    uint parametercount;
                    if (!uint.TryParse(para[1], out parametercount))
                    {
                        throw new NotAWearableFormatException();
                    }
                    for (uint paranum = 0; paranum < parametercount; ++paranum)
                    {
                        line = lines[++idx].Trim();
                        para = line.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                        if (para.Length == 2)
                        {
                            uint   index;
                            double v;
                            if (!uint.TryParse(para[0], out index))
                            {
                                throw new NotAWearableFormatException();
                            }
                            if (!double.TryParse(para[1], NumberStyles.Float, CultureInfo.InvariantCulture, out v))
                            {
                                throw new NotAWearableFormatException();
                            }
                            Params[index] = v;
                        }
                    }
                }
                else if (para.Length == 2 && para[0] == "textures")
                {
                    /* we got a textures block */
                    uint texturecount;
                    if (!uint.TryParse(para[1], out texturecount))
                    {
                        throw new NotAWearableFormatException();
                    }
                    for (uint paranum = 0; paranum < texturecount; ++paranum)
                    {
                        line = lines[++idx].Trim();
                        para = line.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                        if (para.Length == 2)
                        {
                            uint index;
                            if (!uint.TryParse(para[0], out index))
                            {
                                throw new NotAWearableFormatException();
                            }

                            Textures[(AvatarTextureIndex)index] = para[1];
                        }
                    }
                }
                else if (para.Length == 2 && para[0] == "permissions")
                {
                    if (lines[++idx].Trim() != "{")
                    {
                        throw new NotAWearableFormatException();
                    }
                    if (idx == lines.Length)
                    {
                        throw new NotAWearableFormatException();
                    }
                    while ((line = lines[idx].Trim()) != "}")
                    {
                        para = line.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                        if (para.Length < 2)
                        {
                            /* less than two parameters is not valid */
                        }
                        else if (para[0] == "base_mask")
                        {
                            uint val;
                            if (!uint.TryParse(para[1], NumberStyles.HexNumber, CultureInfo.InvariantCulture, out val))
                            {
                                throw new NotAWearableFormatException();
                            }
                            Permissions.Base = (InventoryPermissionsMask)val;
                        }
                        else if (para[0] == "owner_mask")
                        {
                            uint val;
                            if (!uint.TryParse(para[1], NumberStyles.HexNumber, CultureInfo.InvariantCulture, out val))
                            {
                                throw new NotAWearableFormatException();
                            }
                            Permissions.Current = (InventoryPermissionsMask)val;
                        }
                        else if (para[0] == "group_mask")
                        {
                            uint val;
                            if (!uint.TryParse(para[1], NumberStyles.HexNumber, CultureInfo.InvariantCulture, out val))
                            {
                                throw new NotAWearableFormatException();
                            }
                            Permissions.Group = (InventoryPermissionsMask)val;
                        }
                        else if (para[0] == "everyone_mask")
                        {
                            uint val;
                            if (!uint.TryParse(para[1], NumberStyles.HexNumber, CultureInfo.InvariantCulture, out val))
                            {
                                throw new NotAWearableFormatException();
                            }
                            Permissions.EveryOne = (InventoryPermissionsMask)val;
                        }
                        else if (para[0] == "next_owner_mask")
                        {
                            uint val;
                            if (!uint.TryParse(para[1], NumberStyles.HexNumber, CultureInfo.InvariantCulture, out val))
                            {
                                throw new NotAWearableFormatException();
                            }
                            Permissions.NextOwner = (InventoryPermissionsMask)val;
                        }
                        else if (para[0] == "creator_id")
                        {
                            Creator.ID = para[1];
                        }
                        else if (para[0] == "owner_id")
                        {
                            Owner.ID = para[1];
                        }
                        else if (para[0] == "last_owner_id")
                        {
                            LastOwner.ID = para[1];
                        }
                        else if (para[0] == "group_id")
                        {
                            Group.ID = para[1];
                        }

                        if (++idx == lines.Length)
                        {
                            throw new NotAWearableFormatException();
                        }
                    }
                }
                else if (para.Length == 2 && para[0] == "sale_info")
                {
                    if (lines[++idx].Trim() != "{")
                    {
                        throw new NotAWearableFormatException();
                    }
                    if (idx == lines.Length)
                    {
                        throw new NotAWearableFormatException();
                    }
                    while ((line = lines[idx].Trim()) != "}")
                    {
                        para = line.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
                        if (para.Length < 2)
                        {
                            /* less than two parameters is not valid */
                        }
                        else if (para[0] == "sale_type")
                        {
                            SaleInfo.TypeName = para[1];
                        }
                        else if (para[0] == "sale_price")
                        {
                            int val;
                            if (!int.TryParse(para[1], out val))
                            {
                                throw new NotAWearableFormatException();
                            }
                            SaleInfo.Price = val;
                        }
                        else if (para[0] == "perm_mask")
                        {
                            uint val;
                            if (!uint.TryParse(para[1], NumberStyles.HexNumber, CultureInfo.InvariantCulture, out val))
                            {
                                throw new NotAWearableFormatException();
                            }
                            SaleInfo.PermMask = (InventoryPermissionsMask)val;
                        }

                        if (++idx == lines.Length)
                        {
                            throw new NotAWearableFormatException();
                        }
                    }
                }
            }
        }
示例#34
0
 public void RequestCreateItem(UUID parentFolder, string name, string description, AssetType type,
     InventoryType invType, WearableType wearableType, PermissionMask nextOwnerMask,
     ItemCreatedCallback callback)
 {
     RequestCreateItem(parentFolder, name, description, type, UUID.Zero, invType, wearableType, nextOwnerMask, callback);
 }
示例#35
0
 public WearableData()
 {
     Type        = WearableType.None;
     Attributes  = new List <ItemAttribute>();
     Resistances = new List <ResistanceData>();
 }
示例#36
0
        bool TryAddWearable(UUID agentID, Dictionary <WearableType, InventoryItem> wearables, WearableType type, UUID itemID)
        {
            InventoryObject obj;

            if (itemID != UUID.Zero && server.Inventory.TryGetInventory(agentID, itemID, out obj) &&
                obj is InventoryItem)
            {
                wearables.Add(type, (InventoryItem)obj);
                return(true);
            }
            else
            {
                return(false);
            }
        }
示例#37
0
        private static UUID CreateItem(Dictionary<UUID, InventoryBase> inventory, UUID parentID, string name, string description,
            WearableType wearableType, UUID assetID, string assetType, UUID agentID)
        {
            InventoryItem item = new InventoryItem();
            item.ID = UUID.Random();
            item.Name = name;
            item.Description = description;
            item.OwnerID = agentID;
            item.ParentID = parentID;
            item.AssetID = assetID;
            item.ContentType = assetType;
            item.CreationDate = DateTime.UtcNow;

            // HACK: Set LLInventoryItem flags
            item.ExtraData["flags"] = OSD.FromInteger((int)wearableType);

            // HACK: Set default LLInventoryItem permissions
            Permissions perm = Permissions.NoPermissions;
            perm.BaseMask = PermissionMask.All;
            perm.OwnerMask = PermissionMask.All;
            perm.NextOwnerMask = PermissionMask.All;
            item.ExtraData["permissions"] = perm.GetOSD();

            InventoryBase parent;
            if (inventory.TryGetValue(parentID, out parent) && parent is InventoryFolder)
                ((InventoryFolder)parent).Children[item.ID] = item;

            inventory[item.ID] = item;
            return item.ID;
        }
示例#38
0
        public override bool Decode()
        {
            int version = -1;
            Permissions = new Permissions();
            string data = Utils.BytesToString(AssetData);

            data = data.Replace("\r", String.Empty);
            string[] lines = data.Split('\n');
            for (int stri = 0; stri < lines.Length; stri++)
            {
                if (stri == 0)
                {
                    string versionstring = lines[stri];
                    version = Int32.Parse(versionstring.Split(' ')[2]);
                    if (version != 22 && version != 18)
                        return false;
                }
                else if (stri == 1)
                {
                    Name = lines[stri];
                }
                else if (stri == 2)
                {
                    Description = lines[stri];
                }
                else
                {
                    string line = lines[stri].Trim();
                    string[] fields = line.Split('\t');

                    if (fields.Length == 1)
                    {
                        fields = line.Split(' ');
                        if (fields[0] == "parameters")
                        {
                            int count = Int32.Parse(fields[1]) + stri;
                            for (; stri < count; )
                            {
                                stri++;
                                line = lines[stri].Trim();
                                fields = line.Split(' ');

                                int id = Int32.Parse(fields[0]);
                                if (fields[1] == ",")
                                    fields[1] = "0";
                                else
                                    fields[1] = fields[1].Replace(',', '.');

                                float weight = float.Parse(fields[1], System.Globalization.NumberStyles.Float,
                                    Utils.EnUsCulture.NumberFormat);

                                Params[id] = weight;
                            }
                        }
                        else if (fields[0] == "textures")
                        {
                            int count = Int32.Parse(fields[1]) + stri;
                            for (; stri < count; )
                            {
                                stri++;
                                line = lines[stri].Trim();
                                fields = line.Split(' ');

                                AppearanceManager.TextureIndex id = (AppearanceManager.TextureIndex)Int32.Parse(fields[0]);
                                UUID texture = new UUID(fields[1]);

                                Textures[id] = texture;
                            }
                        }
                        else if (fields[0] == "type")
                        {
                            WearableType = (WearableType)Int32.Parse(fields[1]);
                        }

                    }
                    else if (fields.Length == 2)
                    {
                        switch (fields[0])
                        {
                            case "creator_mask":
                                // Deprecated, apply this as the base mask
                                Permissions.BaseMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                                break;
                            case "base_mask":
                                Permissions.BaseMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                                break;
                            case "owner_mask":
                                Permissions.OwnerMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                                break;
                            case "group_mask":
                                Permissions.GroupMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                                break;
                            case "everyone_mask":
                                Permissions.EveryoneMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                                break;
                            case "next_owner_mask":
                                Permissions.NextOwnerMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                                break;
                            case "creator_id":
                                Creator = new UUID(fields[1]);
                                break;
                            case "owner_id":
                                Owner = new UUID(fields[1]);
                                break;
                            case "last_owner_id":
                                LastOwner = new UUID(fields[1]);
                                break;
                            case "group_id":
                                Group = new UUID(fields[1]);
                                break;
                            case "group_owned":
                                GroupOwned = (Int32.Parse(fields[1]) != 0);
                                break;
                            case "sale_type":
                                ForSale = InventoryManager.StringToSaleType(fields[1]);
                                break;
                            case "sale_price":
                                SalePrice = Int32.Parse(fields[1]);
                                break;
                            case "sale_info":
                                // Container for sale_type and sale_price, ignore
                                break;
                            default:
                                return false;
                        }
                    }
                }
            }

            return true;
        }
示例#39
0
 public bool IsWearing(WearableType typeOfWearable, BodyPartType onBodyPart, BodyOrientation orientation)
 {
     return(IsWearing(typeOfWearable, onBodyPart, orientation, string.Empty));
 }
示例#40
0
        /// <summary>
        /// Returns the AssetID of the asset that is currently being worn in a 
        /// given WearableType slot
        /// </summary>
        /// <param name="type">WearableType slot to get the AssetID for</param>
        /// <returns>The UUID of the asset being worn in the given slot, or
        /// UUID.Zero if no wearable is attached to the given slot or wearables
        /// have not been downloaded yet</returns>
        public UUID GetWearableAsset(WearableType type)
        {
            WearableData wearable;

            if (Wearables.TryGetValue(type, out wearable))
                return wearable.AssetID;
            else
                return UUID.Zero;
        }
示例#41
0
        /// <summary>
        /// Decode an assets byte encoded data to a string
        /// </summary>
        /// <returns>true if the asset data was decoded successfully</returns>
        public override bool Decode()
        {
            if (AssetData == null || AssetData.Length == 0)
            {
                return(false);
            }

            int version = -1;

            Permissions = new Permissions();

            try
            {
                string data = Utils.BytesToString(AssetData);

                data = data.Replace("\r", String.Empty);
                string[] lines = data.Split('\n');
                for (int stri = 0; stri < lines.Length; stri++)
                {
                    if (stri == 0)
                    {
                        string versionstring = lines[stri];
                        if (versionstring.Split(' ').Length == 1)
                        {
                            version = Int32.Parse(versionstring);
                        }
                        else
                        {
                            version = Int32.Parse(versionstring.Split(' ')[2]);
                        }
                        if (version != 22 && version != 18 && version != 16 && version != 15)
                        {
                            return(false);
                        }
                    }
                    else if (stri == 1)
                    {
                        Name = lines[stri];
                    }
                    else if (stri == 2)
                    {
                        Description = lines[stri];
                    }
                    else
                    {
                        string   line   = lines[stri].Trim();
                        string[] fields = line.Split('\t');

                        if (fields.Length == 1)
                        {
                            fields = line.Split(' ');
                            if (fields[0] == "parameters")
                            {
                                int count = Int32.Parse(fields[1]) + stri;
                                for (; stri < count;)
                                {
                                    stri++;
                                    line   = lines[stri].Trim();
                                    fields = line.Split(' ');

                                    int id = 0;

                                    // Special handling for -0 edge case
                                    if (fields[0] != "-0")
                                    {
                                        id = Int32.Parse(fields[0]);
                                    }

                                    if (fields[1] == ",")
                                    {
                                        fields[1] = "0";
                                    }
                                    else
                                    {
                                        fields[1] = fields[1].Replace(',', '.');
                                    }

                                    float weight = float.Parse(fields[1], System.Globalization.NumberStyles.Float,
                                                               Utils.EnUsCulture.NumberFormat);

                                    Params[id] = weight;
                                }
                            }
                            else if (fields[0] == "textures")
                            {
                                int count = Int32.Parse(fields[1]) + stri;
                                for (; stri < count;)
                                {
                                    stri++;
                                    line   = lines[stri].Trim();
                                    fields = line.Split(' ');

                                    AvatarTextureIndex id = (AvatarTextureIndex)Int32.Parse(fields[0]);
                                    UUID texture          = new UUID(fields[1]);

                                    Textures[id] = texture;
                                }
                            }
                            else if (fields[0] == "type")
                            {
                                WearableType = (WearableType)Int32.Parse(fields[1]);
                            }
                        }
                        else if (fields.Length == 2)
                        {
                            switch (fields[0])
                            {
                            case "creator_mask":
                                // Deprecated, apply this as the base mask
                                Permissions.BaseMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                                break;

                            case "base_mask":
                                Permissions.BaseMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                                break;

                            case "owner_mask":
                                Permissions.OwnerMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                                break;

                            case "group_mask":
                                Permissions.GroupMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                                break;

                            case "everyone_mask":
                                Permissions.EveryoneMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                                break;

                            case "next_owner_mask":
                                Permissions.NextOwnerMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                                break;

                            case "creator_id":
                                Creator = new UUID(fields[1]);
                                break;

                            case "owner_id":
                                Owner = new UUID(fields[1]);
                                break;

                            case "last_owner_id":
                                LastOwner = new UUID(fields[1]);
                                break;

                            case "group_id":
                                Group = new UUID(fields[1]);
                                break;

                            case "group_owned":
                                GroupOwned = (Int32.Parse(fields[1]) != 0);
                                break;

                            case "sale_type":
                                ForSale = Utils.StringToSaleType(fields[1]);
                                break;

                            case "sale_price":
                                SalePrice = Int32.Parse(fields[1]);
                                break;

                            case "sale_info":
                                // Container for sale_type and sale_price, ignore
                                break;

                            case "perm_mask":
                                // Deprecated, apply this as the next owner mask
                                Permissions.NextOwnerMask = (PermissionMask)UInt32.Parse(fields[1], System.Globalization.NumberStyles.HexNumber);
                                break;

                            default:
                                return(false);
                            }
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Log("Failed decoding wearable asset " + this.AssetID + ": " + ex.Message,
                           Helpers.LogLevel.Warning);
                return(false);
            }

            return(true);
        }
示例#42
0
 public WearableItem(string wearableName, WearableType type)
 {
     WearableName = wearableName;
     WearType = type;
 }
 private void TryAndRepairBrokenWearable(WearableType type, IInventoryService invService, UUID userID,AvatarAppearance appearance)
 {
     UUID defaultwearable = GetDefaultItem(type);
     if (defaultwearable != UUID.Zero)
     {
         UUID newInvItem = UUID.Random();
         InventoryItemBase itembase = new InventoryItemBase(newInvItem, userID)
                     {
                         AssetID = defaultwearable,
                         AssetType = (int)FolderType.BodyPart,
                         CreatorId = userID.ToString(),
                         //InvType = (int)InventoryType.Wearable,
                         Description = "Failed Wearable Replacement",
                         Folder = invService.GetFolderForType(userID, FolderType.BodyPart).ID,
                         Flags = (uint) type, Name = Enum.GetName(typeof (WearableType), type),
                         BasePermissions = (uint) PermissionMask.Copy,
                         CurrentPermissions = (uint) PermissionMask.Copy,
                         EveryOnePermissions = (uint) PermissionMask.Copy,
                         GroupPermissions = (uint) PermissionMask.Copy,
                         NextPermissions = (uint) PermissionMask.Copy
                     };
         invService.AddItem(itembase);
         UUID LinkInvItem = UUID.Random();
         itembase = new InventoryItemBase(LinkInvItem, userID)
                     {
                         AssetID = newInvItem,
                         AssetType = (int)AssetType.Link,
                         CreatorId = userID.ToString(),
                         InvType = (int) InventoryType.Wearable,
                         Description = "Failed Wearable Replacement",
                         Folder = invService.GetFolderForType(userID, FolderType.CurrentOutfit).ID,
                         Flags = (uint) type,
                         Name = Enum.GetName(typeof (WearableType), type),
                         BasePermissions = (uint) PermissionMask.Copy,
                         CurrentPermissions = (uint) PermissionMask.Copy,
                         EveryOnePermissions = (uint) PermissionMask.Copy,
                         GroupPermissions = (uint) PermissionMask.Copy,
                         NextPermissions = (uint) PermissionMask.Copy
                     };
         invService.AddItem(itembase);
         appearance.Wearables[(int)type] = new AvatarWearable(newInvItem, GetDefaultItem(type));
         ScenePresence presence = null;
         if (m_scene.TryGetScenePresence(userID, out presence))
         {
             m_scene.SendInventoryUpdate(presence.ControllingClient,
                         invService.GetFolderForType(userID, FolderType.CurrentOutfit), false, true);
         }
     }
 }
示例#44
0
 public WearableItem(WearableType type)
 {
     WearType = type;
     WearableName = Enum.GetName(typeof(WearableType), type).ToLower();
 }
        private UUID GetDefaultItem(WearableType wearable)
        {
            // These are ruth
            UUID ret = UUID.Zero;
            switch (wearable)
            {
                case WearableType.Eyes:
                    ret = new UUID("4bb6fa4d-1cd2-498a-a84c-95c1a0e745a7");
                    break;
                case WearableType.Hair:
                    ret = new UUID("d342e6c0-b9d2-11dc-95ff-0800200c9a66");
                    break;
                case WearableType.Pants:
                    ret = new UUID("00000000-38f9-1111-024e-222222111120");
                    break;
                case WearableType.Shape:
                    ret = new UUID("66c41e39-38f9-f75a-024e-585989bfab73");
                    break;
                case WearableType.Shirt:
                    ret = new UUID("00000000-38f9-1111-024e-222222111110");
                    break;
                case WearableType.Skin:
                    ret = new UUID("77c41e39-38f9-f75a-024e-585989bbabbb");
                    break;
                case WearableType.Undershirt:
                    ret = new UUID("16499ebb-3208-ec27-2def-481881728f47");
                    break;
                case WearableType.Underpants:
                    ret = new UUID("4ac2e9c7-3671-d229-316a-67717730841d");
                    break;
            }

            return ret;
        }
示例#46
0
        public void RequestCreateItem(LLUUID parentFolder, string name, string description, AssetType type, 
            InventoryType invType, WearableType wearableType, PermissionMask nextOwnerMask, 
            ItemCreatedCallback callback)
        {
            CreateInventoryItemPacket create = new CreateInventoryItemPacket();
            create.AgentData.AgentID = _Client.Self.AgentID;
            create.AgentData.SessionID = _Client.Self.SessionID;

            create.InventoryBlock.CallbackID = RegisterItemCreatedCallback(callback);
            create.InventoryBlock.FolderID = parentFolder;
            create.InventoryBlock.TransactionID = LLUUID.Random();
            create.InventoryBlock.NextOwnerMask = (uint)nextOwnerMask;
            create.InventoryBlock.Type = (sbyte)type;
            create.InventoryBlock.InvType = (sbyte)invType;
            create.InventoryBlock.WearableType = (byte)wearableType;
            create.InventoryBlock.Name = Helpers.StringToField(name);
            create.InventoryBlock.Description = Helpers.StringToField(description);

            _Client.Network.SendPacket(create);
        }
示例#47
0
        public void LoadInventory(METAboltInstance instance, UUID folderID)
        {
            this.instance = instance;
            this.client   = this.instance.Client;
            InventoryFolder      rootFolder = this.client.Inventory.Store.RootFolder;
            List <InventoryBase> contents   = this.client.Inventory.Store.GetContents(folderID);

            if (folderID != this.client.Inventory.Store.RootFolder.UUID)
            {
                if (this.TreeView.Nodes != null)
                {
                    TreeNode[] array = this.TreeView.Nodes.Find(folderID.ToString(), true);
                    if (array.Length > 0)
                    {
                        TreeNodeCollection nodes = array[0].Nodes;
                        nodes.Clear();
                        if (contents.Count == 0)
                        {
                            nodes.Add(UUID.Zero.ToString(), "(empty)");
                            nodes[UUID.Zero.ToString()].Tag       = "empty";
                            nodes[UUID.Zero.ToString()].ForeColor = Color.FromKnownColor(KnownColor.GrayText);
                        }
                        else
                        {
                            List <Primitive> list = this.client.Network.CurrentSim.ObjectsPrimitives.FindAll(delegate(Primitive prim)
                            {
                                bool result;
                                try
                                {
                                    result = (prim.ParentID == instance.Client.Self.LocalID);
                                }
                                catch
                                {
                                    result = false;
                                }
                                return(result);
                            });
                            foreach (InventoryBase current in contents)
                            {
                                string key  = current.UUID.ToString();
                                bool   flag = current is InventoryFolder;
                                try
                                {
                                    string text = string.Empty;
                                    if (!flag)
                                    {
                                        InventoryItem inventoryItem = (InventoryItem)current;
                                        WearableType  wearableType  = this.client.Appearance.IsItemWorn(inventoryItem);
                                        if (wearableType != WearableType.Invalid)
                                        {
                                            text = " (WORN)";
                                        }
                                        UUID lhs = UUID.Zero;
                                        foreach (Primitive current2 in list)
                                        {
                                            if (current2.NameValues != null)
                                            {
                                                for (int i = 0; i < current2.NameValues.Length; i++)
                                                {
                                                    if (current2.NameValues[i].Name == "AttachItemID")
                                                    {
                                                        lhs = (UUID)current2.NameValues[i].Value.ToString();
                                                        if (lhs == inventoryItem.UUID)
                                                        {
                                                            text = " (WORN)";
                                                            break;
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                        nodes.Add(key, current.Name + text);
                                        nodes[key].Tag = current;
                                        if (text == " (WORN)")
                                        {
                                            nodes[key].ForeColor = Color.RoyalBlue;
                                        }
                                        string        empty         = string.Empty;
                                        InventoryType inventoryType = inventoryItem.InventoryType;
                                        switch (inventoryType)
                                        {
                                        case InventoryType.Texture:
                                            nodes[key].ImageKey = "Texture";
                                            continue;

                                        case InventoryType.Sound:
                                        case (InventoryType)4:
                                        case (InventoryType)5:
                                        case InventoryType.Category:
                                        case InventoryType.RootCategory:
                                            break;

                                        case InventoryType.CallingCard:
                                            nodes[key].ImageKey = "CallingCard";
                                            continue;

                                        case InventoryType.Landmark:
                                            nodes[key].ImageKey = "LM";
                                            continue;

                                        case InventoryType.Object:
                                            nodes[key].ImageKey = "Objects";
                                            continue;

                                        case InventoryType.Notecard:
                                            nodes[key].ImageKey = "Notecard";
                                            continue;

                                        case InventoryType.LSL:
                                            nodes[key].ImageKey = "Script";
                                            continue;

                                        default:
                                            if (inventoryType == InventoryType.Snapshot)
                                            {
                                                nodes[key].ImageKey = "Snapshots";
                                                continue;
                                            }
                                            if (inventoryType == InventoryType.Wearable)
                                            {
                                                nodes[key].ImageKey = "Wearable";
                                                continue;
                                            }
                                            break;
                                        }
                                        nodes[key].ImageKey = "Gear";
                                    }
                                    else
                                    {
                                        nodes.Add(key, current.Name);
                                        nodes[key].Tag      = current;
                                        nodes[key].ImageKey = "ClosedFolder";
                                        nodes[key].Nodes.Add(null, "(loading...)").ForeColor = Color.FromKnownColor(KnownColor.GrayText);
                                    }
                                }
                                catch (Exception var_16_4C6)
                                {
                                }
                            }
                        }
                    }
                }
            }
            else
            {
                this.TreeView.Nodes.Clear();
                TreeNode treeNode = this.TreeView.Nodes.Add(rootFolder.UUID.ToString(), "My Inventory");
                treeNode.Tag      = rootFolder;
                treeNode.ImageKey = "OpenFolder";
                if (contents.Count == 0)
                {
                    treeNode.Nodes.Add(UUID.Zero.ToString(), "(empty)");
                    treeNode.Nodes[UUID.Zero.ToString()].Tag       = "empty";
                    treeNode.Nodes[UUID.Zero.ToString()].ForeColor = Color.FromKnownColor(KnownColor.GrayText);
                }
                else
                {
                    List <Primitive> list = this.client.Network.CurrentSim.ObjectsPrimitives.FindAll(delegate(Primitive prim)
                    {
                        bool result;
                        try
                        {
                            result = (prim.ParentID == instance.Client.Self.LocalID);
                        }
                        catch
                        {
                            result = false;
                        }
                        return(result);
                    });
                    foreach (InventoryBase current in contents)
                    {
                        string key  = current.UUID.ToString();
                        bool   flag = current is InventoryFolder;
                        try
                        {
                            string text = string.Empty;
                            if (!flag)
                            {
                                InventoryItem inventoryItem = (InventoryItem)current;
                                WearableType  wearableType  = this.client.Appearance.IsItemWorn(inventoryItem);
                                if (wearableType != WearableType.Invalid)
                                {
                                    text = " (WORN)";
                                }
                                UUID lhs = UUID.Zero;
                                foreach (Primitive current2 in list)
                                {
                                    if (current2.NameValues != null)
                                    {
                                        for (int i = 0; i < current2.NameValues.Length; i++)
                                        {
                                            if (current2.NameValues[i].Name == "AttachItemID")
                                            {
                                                lhs = (UUID)current2.NameValues[i].Value.ToString();
                                                if (lhs == inventoryItem.UUID)
                                                {
                                                    text = " (WORN)";
                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                                treeNode.Nodes.Add(key, current.Name + text);
                                treeNode.Nodes[key].Tag = current;
                                if (text == " (WORN)")
                                {
                                    treeNode.Nodes[key].ForeColor = Color.RoyalBlue;
                                }
                                string        empty         = string.Empty;
                                InventoryType inventoryType = inventoryItem.InventoryType;
                                switch (inventoryType)
                                {
                                case InventoryType.Texture:
                                    treeNode.Nodes[key].ImageKey = "Texture";
                                    continue;

                                case InventoryType.Sound:
                                case (InventoryType)4:
                                case (InventoryType)5:
                                case InventoryType.Category:
                                case InventoryType.RootCategory:
                                    break;

                                case InventoryType.CallingCard:
                                    treeNode.Nodes[key].ImageKey = "CallingCard";
                                    continue;

                                case InventoryType.Landmark:
                                    treeNode.Nodes[key].ImageKey = "LM";
                                    continue;

                                case InventoryType.Object:
                                    treeNode.Nodes[key].ImageKey = "Objects";
                                    continue;

                                case InventoryType.Notecard:
                                    treeNode.Nodes[key].ImageKey = "Notecard";
                                    continue;

                                case InventoryType.LSL:
                                    treeNode.Nodes[key].ImageKey = "Script";
                                    continue;

                                default:
                                    if (inventoryType == InventoryType.Snapshot)
                                    {
                                        treeNode.Nodes[key].ImageKey = "Snapshots";
                                        continue;
                                    }
                                    if (inventoryType == InventoryType.Wearable)
                                    {
                                        treeNode.Nodes[key].ImageKey = "Wearable";
                                        continue;
                                    }
                                    break;
                                }
                                treeNode.Nodes[key].ImageKey = "Gear";
                            }
                            else
                            {
                                treeNode.Nodes.Add(key, current.Name);
                                treeNode.Nodes[key].Tag      = current;
                                treeNode.Nodes[key].ImageKey = "ClosedFolder";
                                treeNode.Nodes[key].Nodes.Add(null, "(loading...)").ForeColor = Color.FromKnownColor(KnownColor.GrayText);
                            }
                        }
                        catch (Exception var_16_4C6)
                        {
                        }
                    }
                    treeNode.Expand();
                }
            }
        }