diff options
author | opensim mirror account | 2010-10-29 17:50:04 -0700 |
---|---|---|
committer | opensim mirror account | 2010-10-29 17:50:04 -0700 |
commit | f8471de0043a811c10048c513d54e4a318b2851a (patch) | |
tree | cb83ceabb71ebe4b3de7d34e8f20c24cb775d174 /OpenSim/Framework/AvatarWearable.cs | |
parent | Merge branch 'master' of /var/git/opensim/ (diff) | |
parent | Merge branch 'master' of melanie@opensimulator.org:/var/git/opensim (diff) | |
download | opensim-SC-f8471de0043a811c10048c513d54e4a318b2851a.zip opensim-SC-f8471de0043a811c10048c513d54e4a318b2851a.tar.gz opensim-SC-f8471de0043a811c10048c513d54e4a318b2851a.tar.bz2 opensim-SC-f8471de0043a811c10048c513d54e4a318b2851a.tar.xz |
Merge branch 'master' of /var/git/opensim/
Diffstat (limited to 'OpenSim/Framework/AvatarWearable.cs')
-rw-r--r-- | OpenSim/Framework/AvatarWearable.cs | 157 |
1 files changed, 131 insertions, 26 deletions
diff --git a/OpenSim/Framework/AvatarWearable.cs b/OpenSim/Framework/AvatarWearable.cs index 87098bf..631971f 100644 --- a/OpenSim/Framework/AvatarWearable.cs +++ b/OpenSim/Framework/AvatarWearable.cs | |||
@@ -26,11 +26,24 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
29 | using OpenMetaverse; | 30 | using OpenMetaverse; |
30 | using OpenMetaverse.StructuredData; | 31 | using OpenMetaverse.StructuredData; |
31 | 32 | ||
32 | namespace OpenSim.Framework | 33 | namespace 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 = 15; | ||
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,158 @@ 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 | |||
92 | protected Dictionary<UUID, UUID> m_items = new Dictionary<UUID, UUID>(); | ||
93 | protected List<UUID> m_ids = new List<UUID>(); | ||
72 | 94 | ||
73 | public AvatarWearable() | 95 | public AvatarWearable() |
74 | { | 96 | { |
75 | } | 97 | } |
76 | 98 | ||
77 | public AvatarWearable(UUID itemId, UUID assetId) | 99 | public AvatarWearable(UUID itemID, UUID assetID) |
78 | { | 100 | { |
79 | AssetID = assetId; | 101 | Wear(itemID, assetID); |
80 | ItemID = itemId; | ||
81 | } | 102 | } |
82 | 103 | ||
83 | public AvatarWearable(OSDMap args) | 104 | public AvatarWearable(OSDArray args) |
84 | { | 105 | { |
85 | Unpack(args); | 106 | Unpack(args); |
86 | } | 107 | } |
87 | 108 | ||
88 | public OSDMap Pack() | 109 | public OSD Pack() |
110 | { | ||
111 | OSDArray wearlist = new OSDArray(); | ||
112 | |||
113 | foreach (UUID id in m_ids) | ||
114 | { | ||
115 | OSDMap weardata = new OSDMap(); | ||
116 | weardata["item"] = OSD.FromUUID(id); | ||
117 | weardata["asset"] = OSD.FromUUID(m_items[id]); | ||
118 | wearlist.Add(weardata); | ||
119 | } | ||
120 | |||
121 | return wearlist; | ||
122 | } | ||
123 | |||
124 | public void Unpack(OSDArray args) | ||
125 | { | ||
126 | Clear(); | ||
127 | |||
128 | foreach (OSDMap weardata in args) | ||
129 | { | ||
130 | Add(weardata["item"].AsUUID(), weardata["asset"].AsUUID()); | ||
131 | } | ||
132 | } | ||
133 | |||
134 | public int Count | ||
135 | { | ||
136 | get { return m_ids.Count; } | ||
137 | } | ||
138 | |||
139 | public void Add(UUID itemID, UUID assetID) | ||
140 | { | ||
141 | if (itemID == UUID.Zero) | ||
142 | return; | ||
143 | if (m_items.ContainsKey(itemID)) | ||
144 | { | ||
145 | m_items[itemID] = assetID; | ||
146 | return; | ||
147 | } | ||
148 | if (m_ids.Count >= 5) | ||
149 | return; | ||
150 | |||
151 | m_ids.Add(itemID); | ||
152 | m_items[itemID] = assetID; | ||
153 | } | ||
154 | |||
155 | public void Wear(UUID itemID, UUID assetID) | ||
89 | { | 156 | { |
90 | OSDMap weardata = new OSDMap(); | 157 | Clear(); |
91 | weardata["item"] = OSD.FromUUID(ItemID); | 158 | Add(itemID, assetID); |
92 | weardata["asset"] = OSD.FromUUID(AssetID); | 159 | } |
93 | 160 | ||
94 | return weardata; | 161 | public void Clear() |
162 | { | ||
163 | m_ids.Clear(); | ||
164 | m_items.Clear(); | ||
95 | } | 165 | } |
96 | 166 | ||
97 | public void Unpack(OSDMap args) | 167 | public void RemoveItem(UUID itemID) |
98 | { | 168 | { |
99 | ItemID = (args["item"] != null) ? args["item"].AsUUID() : UUID.Zero; | 169 | if (m_items.ContainsKey(itemID)) |
100 | AssetID = (args["asset"] != null) ? args["asset"].AsUUID() : UUID.Zero; | 170 | { |
171 | m_ids.Remove(itemID); | ||
172 | m_items.Remove(itemID); | ||
173 | } | ||
174 | } | ||
175 | |||
176 | public void RemoveAsset(UUID assetID) | ||
177 | { | ||
178 | UUID itemID = UUID.Zero; | ||
179 | |||
180 | foreach (KeyValuePair<UUID, UUID> kvp in m_items) | ||
181 | { | ||
182 | if (kvp.Value == assetID) | ||
183 | { | ||
184 | itemID = kvp.Key; | ||
185 | break; | ||
186 | } | ||
187 | } | ||
188 | |||
189 | if (itemID != UUID.Zero) | ||
190 | { | ||
191 | m_ids.Remove(itemID); | ||
192 | m_items.Remove(itemID); | ||
193 | } | ||
194 | } | ||
195 | |||
196 | public WearableItem this [int idx] | ||
197 | { | ||
198 | get | ||
199 | { | ||
200 | if (idx >= m_ids.Count || idx < 0) | ||
201 | return new WearableItem(UUID.Zero, UUID.Zero); | ||
202 | |||
203 | return new WearableItem(m_ids[idx], m_items[m_ids[idx]]); | ||
204 | } | ||
101 | } | 205 | } |
102 | 206 | ||
103 | public static AvatarWearable[] DefaultWearables | 207 | public static AvatarWearable[] DefaultWearables |
104 | { | 208 | { |
105 | get | 209 | get |
106 | { | 210 | { |
107 | AvatarWearable[] defaultWearables = new AvatarWearable[MAX_WEARABLES]; //should be 13 of these | 211 | AvatarWearable[] defaultWearables = new AvatarWearable[MAX_WEARABLES]; //should be 15 of these |
108 | for (int i = 0; i < MAX_WEARABLES; i++) | 212 | for (int i = 0; i < MAX_WEARABLES; i++) |
109 | { | 213 | { |
110 | defaultWearables[i] = new AvatarWearable(); | 214 | defaultWearables[i] = new AvatarWearable(); |
111 | } | 215 | } |
112 | 216 | ||
113 | // Body | 217 | // Body |
114 | defaultWearables[0].ItemID = DEFAULT_BODY_ITEM; | 218 | defaultWearables[BODY].Add(DEFAULT_BODY_ITEM, DEFAULT_BODY_ASSET); |
115 | defaultWearables[0].AssetID = DEFAULT_BODY_ASSET; | ||
116 | 219 | ||
117 | // Hair | 220 | // Hair |
118 | defaultWearables[2].ItemID = DEFAULT_HAIR_ITEM; | 221 | defaultWearables[HAIR].Add(DEFAULT_HAIR_ITEM, DEFAULT_HAIR_ASSET); |
119 | defaultWearables[2].AssetID = DEFAULT_HAIR_ASSET; | ||
120 | 222 | ||
121 | // Skin | 223 | // Skin |
122 | defaultWearables[1].ItemID = DEFAULT_SKIN_ITEM; | 224 | defaultWearables[SKIN].Add(DEFAULT_SKIN_ITEM, DEFAULT_SKIN_ASSET); |
123 | defaultWearables[1].AssetID = DEFAULT_SKIN_ASSET; | ||
124 | 225 | ||
125 | // Shirt | 226 | // Shirt |
126 | defaultWearables[4].ItemID = DEFAULT_SHIRT_ITEM; | 227 | defaultWearables[SHIRT].Add(DEFAULT_SHIRT_ITEM, DEFAULT_SHIRT_ASSET); |
127 | defaultWearables[4].AssetID = DEFAULT_SHIRT_ASSET; | ||
128 | 228 | ||
129 | // Pants | 229 | // Pants |
130 | defaultWearables[5].ItemID = DEFAULT_PANTS_ITEM; | 230 | defaultWearables[PANTS].Add(DEFAULT_PANTS_ITEM, DEFAULT_PANTS_ASSET); |
131 | defaultWearables[5].AssetID = DEFAULT_PANTS_ASSET; | 231 | |
232 | // Alpha | ||
233 | defaultWearables[ALPHA].Add(DEFAULT_ALPHA_ITEM, DEFAULT_ALPHA_ASSET); | ||
234 | |||
235 | // Tattoo | ||
236 | defaultWearables[TATTOO].Add(DEFAULT_TATTOO_ITEM, DEFAULT_TATTOO_ASSET); | ||
132 | 237 | ||
133 | return defaultWearables; | 238 | return defaultWearables; |
134 | } | 239 | } |