aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Interfaces
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Services/Interfaces')
-rw-r--r--OpenSim/Services/Interfaces/IAvatarService.cs95
1 files changed, 94 insertions, 1 deletions
diff --git a/OpenSim/Services/Interfaces/IAvatarService.cs b/OpenSim/Services/Interfaces/IAvatarService.cs
index 682616a..39368f1 100644
--- a/OpenSim/Services/Interfaces/IAvatarService.cs
+++ b/OpenSim/Services/Interfaces/IAvatarService.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections;
29using System.Collections.Generic; 30using System.Collections.Generic;
30 31
31using OpenSim.Framework; 32using OpenSim.Framework;
@@ -93,7 +94,16 @@ namespace OpenSim.Services.Interfaces
93 94
94 public AvatarData(Dictionary<string, object> kvp) 95 public AvatarData(Dictionary<string, object> kvp)
95 { 96 {
96 // TODO 97 Data = new Dictionary<string, string>();
98
99 if (kvp.ContainsKey("AvatarType"))
100 Int32.TryParse(kvp["AvatarType"].ToString(), out AvatarType);
101
102 foreach (KeyValuePair<string, object> _kvp in kvp)
103 {
104 if (_kvp.Value != null)
105 Data[_kvp.Key] = _kvp.Value.ToString();
106 }
97 } 107 }
98 108
99 /// <summary> 109 /// <summary>
@@ -101,7 +111,90 @@ namespace OpenSim.Services.Interfaces
101 /// <returns></returns> 111 /// <returns></returns>
102 public Dictionary<string, object> ToKeyValuePairs() 112 public Dictionary<string, object> ToKeyValuePairs()
103 { 113 {
114 Dictionary<string, object> result = new Dictionary<string, object>();
115
116 result["AvatarType"] = AvatarType.ToString();
117 foreach (KeyValuePair<string, string> _kvp in Data)
118 {
119 if (_kvp.Value != null)
120 result[_kvp.Key] = _kvp.Value;
121 }
104 return null; 122 return null;
105 } 123 }
124
125 public AvatarData(AvatarAppearance appearance)
126 {
127 AvatarType = 1; // SL avatars
128 Data = new Dictionary<string, string>();
129
130 // Wearables
131 Data["AvatarHeight"] = appearance.AvatarHeight.ToString();
132 Data["BodyItem"] = appearance.BodyItem.ToString();
133 Data["EyesItem"] = appearance.EyesItem.ToString();
134 Data["GlovesItem"] = appearance.GlovesItem.ToString();
135 Data["HairItem"] = appearance.HairItem.ToString();
136 //Data["HipOffset"] = appearance.HipOffset.ToString();
137 Data["JacketItem"] = appearance.JacketItem.ToString();
138 Data["Owner"] = appearance.Owner.ToString();
139 Data["PantsItem"] = appearance.PantsItem.ToString();
140 Data["Serial"] = appearance.Serial.ToString();
141 Data["ShirtItem"] = appearance.ShirtItem.ToString();
142 Data["ShoesItem"] = appearance.ShoesItem.ToString();
143 Data["SkinItem"] = appearance.SkinItem.ToString();
144 Data["SkirtItem"] = appearance.SkirtItem.ToString();
145 Data["SocksItem"] = appearance.SocksItem.ToString();
146 Data["UnderPantsItem"] = appearance.UnderPantsItem.ToString();
147 Data["UnderShirtItem"] = appearance.UnderShirtItem.ToString();
148
149 // Attachments
150 Hashtable attachs = appearance.GetAttachments();
151 foreach (KeyValuePair<int, Hashtable> kvp in attachs)
152 {
153 Data["_ap_" + kvp.Key] = kvp.Value["item"].ToString();
154 }
155 }
156
157 public AvatarAppearance ToAvatarAppearance()
158 {
159 AvatarAppearance appearance = new AvatarAppearance();
160 // Wearables
161 appearance.AvatarHeight = float.Parse(Data["AvatarHeight"]);
162 appearance.BodyItem = UUID.Parse(Data["BodyItem"]);
163 appearance.EyesItem = UUID.Parse(Data["EyesItem"]);
164 appearance.GlovesItem = UUID.Parse(Data["GlovesItem"]);
165 appearance.HairItem = UUID.Parse(Data["HairItem"]);
166 //appearance.HipOffset = float.Parse(Data["HipOffset"]);
167 appearance.JacketItem = UUID.Parse(Data["JacketItem"]);
168 appearance.Owner = UUID.Parse(Data["Owner"]);
169 appearance.PantsItem = UUID.Parse(Data["PantsItem"]);
170 appearance.Serial = Int32.Parse(Data["Serial"]);
171 appearance.ShirtItem = UUID.Parse(Data["ShirtItem"]);
172 appearance.ShoesItem = UUID.Parse(Data["ShoesItem"]);
173 appearance.SkinItem = UUID.Parse(Data["SkinItem"]);
174 appearance.SkirtItem = UUID.Parse(Data["SkirtItem"]);
175 appearance.SocksItem = UUID.Parse(Data["SocksItem"]);
176 appearance.UnderPantsItem = UUID.Parse(Data["UnderPantsItem"]);
177 appearance.UnderShirtItem = UUID.Parse(Data["UnderShirtItem"]);
178
179 // Attachments
180 Dictionary<string, string> attchs = new Dictionary<string, string>();
181 foreach (KeyValuePair<string, string> _kvp in Data)
182 if (_kvp.Key.StartsWith("_ap_"))
183 attchs[_kvp.Key] = _kvp.Value;
184 Hashtable aaAttachs = new Hashtable();
185 foreach (KeyValuePair<string, string> _kvp in attchs)
186 {
187 string pointStr = _kvp.Key.Substring(4);
188 int point = 0;
189 if (!Int32.TryParse(pointStr, out point))
190 continue;
191 Hashtable tmp = new Hashtable();
192 tmp["item"] = _kvp.Value;
193 tmp["asset"] = UUID.Zero.ToString();
194 aaAttachs[point] = tmp;
195 }
196
197 return appearance;
198 }
106 } 199 }
107} 200}