/// <summary> /// Attach an item to an avatar specifying attachment details /// </summary> /// <param name="itemID">The <seealso cref="libsecondlife.LLUUID"/> of the item to attach</param> /// <param name="ownerID">The <seealso cref="libsecondlife.LLUUID"/> attachments owner</param> /// <param name="name">The name of the attachment</param> /// <param name="description">The description of the attahment</param> /// <param name="perms">The <seealso cref="libsecondlife.Permissions"/> to apply when attached</param> /// <param name="itemFlags">The <seealso cref="libsecondlife.InventoryItemFlags"/> of the attachment</param> /// <param name="attachPoint">the <seealso cref="libsecondlife.AttachmentPoint"/> on the avatar /// to attach the item to</param> public void Attach(LLUUID itemID, LLUUID ownerID, string name, string description, Permissions perms, InventoryItemFlags itemFlags, AttachmentPoint attachPoint) { // TODO: At some point it might be beneficial to have AppearanceManager track what we // are currently wearing for attachments to make enumeration and detachment easier RezSingleAttachmentFromInvPacket attach = new RezSingleAttachmentFromInvPacket(); attach.AgentData.AgentID = Client.Self.AgentID; attach.AgentData.SessionID = Client.Self.SessionID; attach.ObjectData.AttachmentPt = (byte)attachPoint; attach.ObjectData.Description = Helpers.StringToField(description); attach.ObjectData.EveryoneMask = (uint)perms.EveryoneMask; attach.ObjectData.GroupMask = (uint)perms.GroupMask; attach.ObjectData.ItemFlags = (uint)itemFlags; attach.ObjectData.ItemID = itemID; attach.ObjectData.Name = Helpers.StringToField(name); attach.ObjectData.NextOwnerMask = (uint)perms.NextOwnerMask; attach.ObjectData.OwnerID = ownerID; Client.Network.SendPacket(attach); }
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]); 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; }
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) { } } }