29 using System.Collections.Generic;
31 using System.Reflection;
34 using OpenSim.Framework;
35 using OpenSim.Framework.Console;
37 using OpenSim.Services.Interfaces;
44 private static readonly ILog m_log =
46 MethodBase.GetCurrentMethod().DeclaringType);
51 m_log.Debug(
"[AVATAR SERVICE]: Starting avatar service");
57 return avatar.ToAvatarAppearance();
63 return SetAvatar(principalID,avatar);
68 AvatarBaseData[] av = m_Database.Get(
"PrincipalID", principalID.ToString());
70 ret.Data =
new Dictionary<string,string>();
80 if (b.
Data[
"Name"] ==
"AvatarType")
81 ret.AvatarType = Convert.ToInt32(b.Data[
"Value"]);
83 ret.Data[b.Data[
"Name"]] = b.Data[
"Value"];
92 foreach (KeyValuePair<string, string> kvp
in avatar.Data)
93 if (kvp.Key.StartsWith(
"_"))
97 m_Database.Delete(
"PrincipalID", principalID.ToString());
100 av.Data =
new Dictionary<string,string>();
102 av.PrincipalID = principalID;
103 av.Data[
"Name"] =
"AvatarType";
104 av.Data[
"Value"] = avatar.AvatarType.ToString();
106 if (!m_Database.Store(av))
109 foreach (KeyValuePair<string,string> kvp
in avatar.Data)
111 av.Data[
"Name"] = kvp.Key;
118 if (kvp.Key ==
"AvatarHeight")
121 if (!
float.TryParse(kvp.Value, out height) || height < 0 || height > 10)
123 string rawHeight = kvp.Value.Replace(
",",
".");
125 if (!
float.TryParse(rawHeight, out height) || height < 0 || height > 10)
129 "[AVATAR SERVICE]: Rectifying height of avatar {0} from {1} to {2}",
130 principalID, kvp.Value, height);
133 av.Data[
"Value"] = height.ToString();
137 av.Data[
"Value"] = kvp.Value;
140 if (!m_Database.Store(av))
142 m_Database.Delete(
"PrincipalID", principalID.ToString());
152 return m_Database.Delete(
"PrincipalID", principalID.ToString());
155 public bool SetItems(UUID principalID,
string[] names,
string[] values)
158 av.Data =
new Dictionary<string,string>();
159 av.PrincipalID = principalID;
161 if (names.Length != values.Length)
164 for (
int i = 0 ; i < names.Length ; i++)
166 av.Data[
"Name"] = names[i];
167 av.Data[
"Value"] = values[i];
169 if (!m_Database.Store(av))
178 foreach (
string name
in names)
180 m_Database.Delete(principalID, name);
AvatarData GetAvatar(UUID principalID)
Called by the login service
bool ResetAvatar(UUID principalID)
Not sure if it's needed
Dictionary< string, string > Data
Contains the Avatar's Appearance and methods to manipulate the appearance.
bool SetAppearance(UUID principalID, AvatarAppearance appearance)
Called by everyone who can change the avatar data (so, regions)
AvatarAppearance GetAppearance(UUID principalID)
Called by the login service
Interactive OpenSim region server
bool SetAvatar(UUID principalID, AvatarData avatar)
Called by everyone who can change the avatar data (so, regions)
Each region/client that uses avatars will have a data structure of this type representing the avatars...
AvatarService(IConfigSource config)
bool SetItems(UUID principalID, string[] names, string[] values)
These methods raison d'etre: No need to send the entire avatar data (SetAvatar) for changing attachme...
bool RemoveItems(UUID principalID, string[] names)