aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework/AvatarWearable.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--OpenSim/Framework/AvatarWearable.cs170
1 files changed, 144 insertions, 26 deletions
diff --git a/OpenSim/Framework/AvatarWearable.cs b/OpenSim/Framework/AvatarWearable.cs
index 87098bf..0809ab6 100644
--- a/OpenSim/Framework/AvatarWearable.cs
+++ b/OpenSim/Framework/AvatarWearable.cs
@@ -26,11 +26,24 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic;
29using OpenMetaverse; 30using OpenMetaverse;
30using OpenMetaverse.StructuredData; 31using OpenMetaverse.StructuredData;
31 32
32namespace OpenSim.Framework 33namespace OpenSim.Framework
33{ 34{
35 public struct WearableItem
36 {
37 public UUID ItemID;
38 public UUID AssetID;
39
40 public WearableItem(UUID itemID, UUID assetID)
41 {
42 ItemID = itemID;
43 AssetID = assetID;
44 }
45 }
46
34 public class AvatarWearable 47 public class AvatarWearable
35 { 48 {
36 // these are guessed at by the list here - 49 // these are guessed at by the list here -
@@ -49,8 +62,10 @@ namespace OpenSim.Framework
49 public static readonly int UNDERSHIRT = 10; 62 public static readonly int UNDERSHIRT = 10;
50 public static readonly int UNDERPANTS = 11; 63 public static readonly int UNDERPANTS = 11;
51 public static readonly int SKIRT = 12; 64 public static readonly int SKIRT = 12;
65 public static readonly int ALPHA = 13;
66 public static readonly int TATTOO = 14;
52 67
53 public static readonly int MAX_WEARABLES = 13; 68 public static readonly int MAX_WEARABLES = 15;
54 69
55 public static readonly UUID DEFAULT_BODY_ITEM = new UUID("66c41e39-38f9-f75a-024e-585989bfaba9"); 70 public static readonly UUID DEFAULT_BODY_ITEM = new UUID("66c41e39-38f9-f75a-024e-585989bfaba9");
56 public static readonly UUID DEFAULT_BODY_ASSET = new UUID("66c41e39-38f9-f75a-024e-585989bfab73"); 71 public static readonly UUID DEFAULT_BODY_ASSET = new UUID("66c41e39-38f9-f75a-024e-585989bfab73");
@@ -67,68 +82,171 @@ namespace OpenSim.Framework
67 public static readonly UUID DEFAULT_PANTS_ITEM = new UUID("77c41e39-38f9-f75a-0000-5859892f1111"); 82 public static readonly UUID DEFAULT_PANTS_ITEM = new UUID("77c41e39-38f9-f75a-0000-5859892f1111");
68 public static readonly UUID DEFAULT_PANTS_ASSET = new UUID("00000000-38f9-1111-024e-222222111120"); 83 public static readonly UUID DEFAULT_PANTS_ASSET = new UUID("00000000-38f9-1111-024e-222222111120");
69 84
70 public UUID AssetID; 85// public static readonly UUID DEFAULT_ALPHA_ITEM = new UUID("bfb9923c-4838-4d2d-bf07-608c5b1165c8");
71 public UUID ItemID; 86// public static readonly UUID DEFAULT_ALPHA_ASSET = new UUID("1578a2b1-5179-4b53-b618-fe00ca5a5594");
87
88// public static readonly UUID DEFAULT_TATTOO_ITEM = new UUID("c47e22bd-3021-4ba4-82aa-2b5cb34d35e1");
89// public static readonly UUID DEFAULT_TATTOO_ASSET = new UUID("00000000-0000-2222-3333-100000001007");
90
91 private static AvatarWearable[] defaultWearables = null;
92
93 protected Dictionary<UUID, UUID> m_items = new Dictionary<UUID, UUID>();
94 protected List<UUID> m_ids = new List<UUID>();
72 95
73 public AvatarWearable() 96 public AvatarWearable()
74 { 97 {
75 } 98 }
76 99
77 public AvatarWearable(UUID itemId, UUID assetId) 100 public AvatarWearable(UUID itemID, UUID assetID)
78 { 101 {
79 AssetID = assetId; 102 Wear(itemID, assetID);
80 ItemID = itemId;
81 } 103 }
82 104
83 public AvatarWearable(OSDMap args) 105 public AvatarWearable(OSDArray args)
84 { 106 {
85 Unpack(args); 107 Unpack(args);
86 } 108 }
87 109
88 public OSDMap Pack() 110 public OSD Pack()
111 {
112 OSDArray wearlist = new OSDArray();
113
114 foreach (UUID id in m_ids)
115 {
116 OSDMap weardata = new OSDMap();
117 weardata["item"] = OSD.FromUUID(id);
118 weardata["asset"] = OSD.FromUUID(m_items[id]);
119 wearlist.Add(weardata);
120 }
121
122 return wearlist;
123 }
124
125 public void Unpack(OSDArray args)
126 {
127 Clear();
128
129 foreach (OSDMap weardata in args)
130 {
131 Add(weardata["item"].AsUUID(), weardata["asset"].AsUUID());
132 }
133 }
134
135 public int Count
136 {
137 get { return m_ids.Count; }
138 }
139
140 public void Add(UUID itemID, UUID assetID)
141 {
142 if (itemID == UUID.Zero)
143 return;
144 if (m_items.ContainsKey(itemID))
145 {
146 m_items[itemID] = assetID;
147 return;
148 }
149 if (m_ids.Count >= 5)
150 return;
151
152 m_ids.Add(itemID);
153 m_items[itemID] = assetID;
154 }
155
156 public void Wear(WearableItem item)
157 {
158 Wear(item.ItemID, item.AssetID);
159 }
160
161 public void Wear(UUID itemID, UUID assetID)
162 {
163 Clear();
164 Add(itemID, assetID);
165 }
166
167 public void Clear()
168 {
169 m_ids.Clear();
170 m_items.Clear();
171 }
172
173 public void RemoveItem(UUID itemID)
174 {
175 if (m_items.ContainsKey(itemID))
176 {
177 m_ids.Remove(itemID);
178 m_items.Remove(itemID);
179 }
180 }
181
182 public void RemoveAsset(UUID assetID)
89 { 183 {
90 OSDMap weardata = new OSDMap(); 184 UUID itemID = UUID.Zero;
91 weardata["item"] = OSD.FromUUID(ItemID);
92 weardata["asset"] = OSD.FromUUID(AssetID);
93 185
94 return weardata; 186 foreach (KeyValuePair<UUID, UUID> kvp in m_items)
187 {
188 if (kvp.Value == assetID)
189 {
190 itemID = kvp.Key;
191 break;
192 }
193 }
194
195 if (itemID != UUID.Zero)
196 {
197 m_ids.Remove(itemID);
198 m_items.Remove(itemID);
199 }
200 }
201
202 public WearableItem this [int idx]
203 {
204 get
205 {
206 if (idx >= m_ids.Count || idx < 0)
207 return new WearableItem(UUID.Zero, UUID.Zero);
208
209 return new WearableItem(m_ids[idx], m_items[m_ids[idx]]);
210 }
95 } 211 }
96 212
97 public void Unpack(OSDMap args) 213 public UUID GetAsset(UUID itemID)
98 { 214 {
99 ItemID = (args["item"] != null) ? args["item"].AsUUID() : UUID.Zero; 215 if (!m_items.ContainsKey(itemID))
100 AssetID = (args["asset"] != null) ? args["asset"].AsUUID() : UUID.Zero; 216 return UUID.Zero;
217 return m_items[itemID];
101 } 218 }
102 219
103 public static AvatarWearable[] DefaultWearables 220 public static AvatarWearable[] DefaultWearables
104 { 221 {
105 get 222 get
106 { 223 {
107 AvatarWearable[] defaultWearables = new AvatarWearable[MAX_WEARABLES]; //should be 13 of these 224 defaultWearables = new AvatarWearable[MAX_WEARABLES]; //should be 15 of these
108 for (int i = 0; i < MAX_WEARABLES; i++) 225 for (int i = 0; i < MAX_WEARABLES; i++)
109 { 226 {
110 defaultWearables[i] = new AvatarWearable(); 227 defaultWearables[i] = new AvatarWearable();
111 } 228 }
112 229
113 // Body 230 // Body
114 defaultWearables[0].ItemID = DEFAULT_BODY_ITEM; 231 defaultWearables[BODY].Add(DEFAULT_BODY_ITEM, DEFAULT_BODY_ASSET);
115 defaultWearables[0].AssetID = DEFAULT_BODY_ASSET;
116 232
117 // Hair 233 // Hair
118 defaultWearables[2].ItemID = DEFAULT_HAIR_ITEM; 234 defaultWearables[HAIR].Add(DEFAULT_HAIR_ITEM, DEFAULT_HAIR_ASSET);
119 defaultWearables[2].AssetID = DEFAULT_HAIR_ASSET;
120 235
121 // Skin 236 // Skin
122 defaultWearables[1].ItemID = DEFAULT_SKIN_ITEM; 237 defaultWearables[SKIN].Add(DEFAULT_SKIN_ITEM, DEFAULT_SKIN_ASSET);
123 defaultWearables[1].AssetID = DEFAULT_SKIN_ASSET;
124 238
125 // Shirt 239 // Shirt
126 defaultWearables[4].ItemID = DEFAULT_SHIRT_ITEM; 240 defaultWearables[SHIRT].Add(DEFAULT_SHIRT_ITEM, DEFAULT_SHIRT_ASSET);
127 defaultWearables[4].AssetID = DEFAULT_SHIRT_ASSET;
128 241
129 // Pants 242 // Pants
130 defaultWearables[5].ItemID = DEFAULT_PANTS_ITEM; 243 defaultWearables[PANTS].Add(DEFAULT_PANTS_ITEM, DEFAULT_PANTS_ASSET);
131 defaultWearables[5].AssetID = DEFAULT_PANTS_ASSET; 244
245// // Alpha
246// defaultWearables[ALPHA].Add(DEFAULT_ALPHA_ITEM, DEFAULT_ALPHA_ASSET);
247
248// // Tattoo
249// defaultWearables[TATTOO].Add(DEFAULT_TATTOO_ITEM, DEFAULT_TATTOO_ASSET);
132 250
133 return defaultWearables; 251 return defaultWearables;
134 } 252 }