1
0

ChildAgentDataUpdate.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710
  1. /*
  2. * Copyright (c) Contributors, http://opensimulator.org/
  3. * See CONTRIBUTORS.TXT for a full list of copyright holders.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions are met:
  7. * * Redistributions of source code must retain the above copyright
  8. * notice, this list of conditions and the following disclaimer.
  9. * * Redistributions in binary form must reproduce the above copyright
  10. * notice, this list of conditions and the following disclaimer in the
  11. * documentation and/or other materials provided with the distribution.
  12. * * Neither the name of the OpenSimulator Project nor the
  13. * names of its contributors may be used to endorse or promote products
  14. * derived from this software without specific prior written permission.
  15. *
  16. * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
  17. * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
  18. * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  19. * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
  20. * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
  21. * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
  22. * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
  23. * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  24. * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
  25. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  26. */
  27. using System;
  28. using System.Collections;
  29. using System.Collections.Generic;
  30. using System.Reflection;
  31. using log4net;
  32. using OpenMetaverse;
  33. using OpenMetaverse.StructuredData;
  34. namespace OpenSim.Framework
  35. {
  36. // Soon to be dismissed
  37. [Serializable]
  38. public class ChildAgentDataUpdate
  39. {
  40. public Guid ActiveGroupID;
  41. public Guid AgentID;
  42. public bool alwaysrun;
  43. public float AVHeight;
  44. public Vector3 cameraPosition;
  45. public float drawdistance;
  46. public float godlevel;
  47. public uint GroupAccess;
  48. public Vector3 Position;
  49. public ulong regionHandle;
  50. public byte[] throttles;
  51. public Vector3 Velocity;
  52. public ChildAgentDataUpdate()
  53. {
  54. }
  55. }
  56. public interface IAgentData
  57. {
  58. UUID AgentID { get; set; }
  59. OSDMap Pack();
  60. void Unpack(OSDMap map, IScene scene);
  61. }
  62. /// <summary>
  63. /// Replacement for ChildAgentDataUpdate. Used over RESTComms and LocalComms.
  64. /// </summary>
  65. public class AgentPosition : IAgentData
  66. {
  67. private UUID m_id;
  68. public UUID AgentID
  69. {
  70. get { return m_id; }
  71. set { m_id = value; }
  72. }
  73. public ulong RegionHandle;
  74. public uint CircuitCode;
  75. public UUID SessionID;
  76. public float Far;
  77. public Vector3 Position;
  78. public Vector3 Velocity;
  79. public Vector3 Center;
  80. public Vector3 Size;
  81. public Vector3 AtAxis;
  82. public Vector3 LeftAxis;
  83. public Vector3 UpAxis;
  84. public bool ChangedGrid;
  85. // This probably shouldn't be here
  86. public byte[] Throttles;
  87. public OSDMap Pack()
  88. {
  89. OSDMap args = new OSDMap();
  90. args["message_type"] = OSD.FromString("AgentPosition");
  91. args["region_handle"] = OSD.FromString(RegionHandle.ToString());
  92. args["circuit_code"] = OSD.FromString(CircuitCode.ToString());
  93. args["agent_uuid"] = OSD.FromUUID(AgentID);
  94. args["session_uuid"] = OSD.FromUUID(SessionID);
  95. args["position"] = OSD.FromString(Position.ToString());
  96. args["velocity"] = OSD.FromString(Velocity.ToString());
  97. args["center"] = OSD.FromString(Center.ToString());
  98. args["size"] = OSD.FromString(Size.ToString());
  99. args["at_axis"] = OSD.FromString(AtAxis.ToString());
  100. args["left_axis"] = OSD.FromString(LeftAxis.ToString());
  101. args["up_axis"] = OSD.FromString(UpAxis.ToString());
  102. args["far"] = OSD.FromReal(Far);
  103. args["changed_grid"] = OSD.FromBoolean(ChangedGrid);
  104. if ((Throttles != null) && (Throttles.Length > 0))
  105. args["throttles"] = OSD.FromBinary(Throttles);
  106. return args;
  107. }
  108. public void Unpack(OSDMap args, IScene scene)
  109. {
  110. if (args.ContainsKey("region_handle"))
  111. UInt64.TryParse(args["region_handle"].AsString(), out RegionHandle);
  112. if (args["circuit_code"] != null)
  113. UInt32.TryParse((string)args["circuit_code"].AsString(), out CircuitCode);
  114. if (args["agent_uuid"] != null)
  115. AgentID = args["agent_uuid"].AsUUID();
  116. if (args["session_uuid"] != null)
  117. SessionID = args["session_uuid"].AsUUID();
  118. if (args["position"] != null)
  119. Vector3.TryParse(args["position"].AsString(), out Position);
  120. if (args["velocity"] != null)
  121. Vector3.TryParse(args["velocity"].AsString(), out Velocity);
  122. if (args["center"] != null)
  123. Vector3.TryParse(args["center"].AsString(), out Center);
  124. if (args["size"] != null)
  125. Vector3.TryParse(args["size"].AsString(), out Size);
  126. if (args["at_axis"] != null)
  127. Vector3.TryParse(args["at_axis"].AsString(), out AtAxis);
  128. if (args["left_axis"] != null)
  129. Vector3.TryParse(args["left_axis"].AsString(), out LeftAxis);
  130. if (args["up_axis"] != null)
  131. Vector3.TryParse(args["up_axis"].AsString(), out UpAxis);
  132. if (args["changed_grid"] != null)
  133. ChangedGrid = args["changed_grid"].AsBoolean();
  134. if (args["far"] != null)
  135. Far = (float)(args["far"].AsReal());
  136. if (args["throttles"] != null)
  137. Throttles = args["throttles"].AsBinary();
  138. }
  139. /// <summary>
  140. /// Soon to be decommissioned
  141. /// </summary>
  142. /// <param name="cAgent"></param>
  143. public void CopyFrom(ChildAgentDataUpdate cAgent)
  144. {
  145. AgentID = new UUID(cAgent.AgentID);
  146. // next: ???
  147. Size = new Vector3();
  148. Size.Z = cAgent.AVHeight;
  149. Center = cAgent.cameraPosition;
  150. Far = cAgent.drawdistance;
  151. Position = cAgent.Position;
  152. RegionHandle = cAgent.regionHandle;
  153. Throttles = cAgent.throttles;
  154. Velocity = cAgent.Velocity;
  155. }
  156. }
  157. public class AgentGroupData
  158. {
  159. public UUID GroupID;
  160. public ulong GroupPowers;
  161. public bool AcceptNotices;
  162. public AgentGroupData(UUID id, ulong powers, bool notices)
  163. {
  164. GroupID = id;
  165. GroupPowers = powers;
  166. AcceptNotices = notices;
  167. }
  168. public AgentGroupData(OSDMap args)
  169. {
  170. UnpackUpdateMessage(args);
  171. }
  172. public OSDMap PackUpdateMessage()
  173. {
  174. OSDMap groupdata = new OSDMap();
  175. groupdata["group_id"] = OSD.FromUUID(GroupID);
  176. groupdata["group_powers"] = OSD.FromString(GroupPowers.ToString());
  177. groupdata["accept_notices"] = OSD.FromBoolean(AcceptNotices);
  178. return groupdata;
  179. }
  180. public void UnpackUpdateMessage(OSDMap args)
  181. {
  182. if (args["group_id"] != null)
  183. GroupID = args["group_id"].AsUUID();
  184. if (args["group_powers"] != null)
  185. UInt64.TryParse((string)args["group_powers"].AsString(), out GroupPowers);
  186. if (args["accept_notices"] != null)
  187. AcceptNotices = args["accept_notices"].AsBoolean();
  188. }
  189. }
  190. public class ControllerData
  191. {
  192. public UUID ItemID;
  193. public uint IgnoreControls;
  194. public uint EventControls;
  195. public ControllerData(UUID item, uint ignore, uint ev)
  196. {
  197. ItemID = item;
  198. IgnoreControls = ignore;
  199. EventControls = ev;
  200. }
  201. public ControllerData(OSDMap args)
  202. {
  203. UnpackUpdateMessage(args);
  204. }
  205. public OSDMap PackUpdateMessage()
  206. {
  207. OSDMap controldata = new OSDMap();
  208. controldata["item"] = OSD.FromUUID(ItemID);
  209. controldata["ignore"] = OSD.FromInteger(IgnoreControls);
  210. controldata["event"] = OSD.FromInteger(EventControls);
  211. return controldata;
  212. }
  213. public void UnpackUpdateMessage(OSDMap args)
  214. {
  215. if (args["item"] != null)
  216. ItemID = args["item"].AsUUID();
  217. if (args["ignore"] != null)
  218. IgnoreControls = (uint)args["ignore"].AsInteger();
  219. if (args["event"] != null)
  220. EventControls = (uint)args["event"].AsInteger();
  221. }
  222. }
  223. public class AgentData : IAgentData
  224. {
  225. private UUID m_id;
  226. public UUID AgentID
  227. {
  228. get { return m_id; }
  229. set { m_id = value; }
  230. }
  231. public UUID RegionID;
  232. public uint CircuitCode;
  233. public UUID SessionID;
  234. public Vector3 Position;
  235. public Vector3 Velocity;
  236. public Vector3 Center;
  237. public Vector3 Size;
  238. public Vector3 AtAxis;
  239. public Vector3 LeftAxis;
  240. public Vector3 UpAxis;
  241. public bool ChangedGrid;
  242. public float Far;
  243. public float Aspect;
  244. //public int[] Throttles;
  245. public byte[] Throttles;
  246. public uint LocomotionState;
  247. public Quaternion HeadRotation;
  248. public Quaternion BodyRotation;
  249. public uint ControlFlags;
  250. public float EnergyLevel;
  251. public Byte GodLevel;
  252. public bool AlwaysRun;
  253. public UUID PreyAgent;
  254. public Byte AgentAccess;
  255. public UUID ActiveGroupID;
  256. public AgentGroupData[] Groups;
  257. public Animation[] Anims;
  258. public UUID GranterID;
  259. // Appearance
  260. public AvatarAppearance Appearance;
  261. // DEBUG ON
  262. private static readonly ILog m_log =
  263. LogManager.GetLogger(
  264. MethodBase.GetCurrentMethod().DeclaringType);
  265. // DEBUG OFF
  266. /*
  267. public byte[] AgentTextures;
  268. public byte[] VisualParams;
  269. public UUID[] Wearables;
  270. public AvatarAttachment[] Attachments;
  271. */
  272. // Scripted
  273. public ControllerData[] Controllers;
  274. public string CallbackURI;
  275. // These two must have the same Count
  276. public List<ISceneObject> AttachmentObjects;
  277. public List<string> AttachmentObjectStates;
  278. public virtual OSDMap Pack()
  279. {
  280. m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Pack data");
  281. OSDMap args = new OSDMap();
  282. args["message_type"] = OSD.FromString("AgentData");
  283. args["region_id"] = OSD.FromString(RegionID.ToString());
  284. args["circuit_code"] = OSD.FromString(CircuitCode.ToString());
  285. args["agent_uuid"] = OSD.FromUUID(AgentID);
  286. args["session_uuid"] = OSD.FromUUID(SessionID);
  287. args["position"] = OSD.FromString(Position.ToString());
  288. args["velocity"] = OSD.FromString(Velocity.ToString());
  289. args["center"] = OSD.FromString(Center.ToString());
  290. args["size"] = OSD.FromString(Size.ToString());
  291. args["at_axis"] = OSD.FromString(AtAxis.ToString());
  292. args["left_axis"] = OSD.FromString(LeftAxis.ToString());
  293. args["up_axis"] = OSD.FromString(UpAxis.ToString());
  294. args["changed_grid"] = OSD.FromBoolean(ChangedGrid);
  295. args["far"] = OSD.FromReal(Far);
  296. args["aspect"] = OSD.FromReal(Aspect);
  297. if ((Throttles != null) && (Throttles.Length > 0))
  298. args["throttles"] = OSD.FromBinary(Throttles);
  299. args["locomotion_state"] = OSD.FromString(LocomotionState.ToString());
  300. args["head_rotation"] = OSD.FromString(HeadRotation.ToString());
  301. args["body_rotation"] = OSD.FromString(BodyRotation.ToString());
  302. args["control_flags"] = OSD.FromString(ControlFlags.ToString());
  303. args["energy_level"] = OSD.FromReal(EnergyLevel);
  304. args["god_level"] = OSD.FromString(GodLevel.ToString());
  305. args["always_run"] = OSD.FromBoolean(AlwaysRun);
  306. args["prey_agent"] = OSD.FromUUID(PreyAgent);
  307. args["agent_access"] = OSD.FromString(AgentAccess.ToString());
  308. args["active_group_id"] = OSD.FromUUID(ActiveGroupID);
  309. if ((Groups != null) && (Groups.Length > 0))
  310. {
  311. OSDArray groups = new OSDArray(Groups.Length);
  312. foreach (AgentGroupData agd in Groups)
  313. groups.Add(agd.PackUpdateMessage());
  314. args["groups"] = groups;
  315. }
  316. if ((Anims != null) && (Anims.Length > 0))
  317. {
  318. OSDArray anims = new OSDArray(Anims.Length);
  319. foreach (Animation aanim in Anims)
  320. anims.Add(aanim.PackUpdateMessage());
  321. args["animations"] = anims;
  322. }
  323. if (Appearance != null)
  324. args["packed_appearance"] = Appearance.Pack();
  325. //if ((AgentTextures != null) && (AgentTextures.Length > 0))
  326. //{
  327. // OSDArray textures = new OSDArray(AgentTextures.Length);
  328. // foreach (UUID uuid in AgentTextures)
  329. // textures.Add(OSD.FromUUID(uuid));
  330. // args["agent_textures"] = textures;
  331. //}
  332. // The code to pack textures, visuals, wearables and attachments
  333. // should be removed; packed appearance contains the full appearance
  334. // This is retained for backward compatibility only
  335. if (Appearance.Texture != null)
  336. {
  337. byte[] rawtextures = Appearance.Texture.GetBytes();
  338. args["texture_entry"] = OSD.FromBinary(rawtextures);
  339. }
  340. if ((Appearance.VisualParams != null) && (Appearance.VisualParams.Length > 0))
  341. args["visual_params"] = OSD.FromBinary(Appearance.VisualParams);
  342. // We might not pass this in all cases...
  343. if ((Appearance.Wearables != null) && (Appearance.Wearables.Length > 0))
  344. {
  345. OSDArray wears = new OSDArray(Appearance.Wearables.Length);
  346. foreach (AvatarWearable awear in Appearance.Wearables)
  347. wears.Add(awear.Pack());
  348. args["wearables"] = wears;
  349. }
  350. List<AvatarAttachment> attachments = Appearance.GetAttachments();
  351. if ((attachments != null) && (attachments.Count > 0))
  352. {
  353. OSDArray attachs = new OSDArray(attachments.Count);
  354. foreach (AvatarAttachment att in attachments)
  355. attachs.Add(att.Pack());
  356. args["attachments"] = attachs;
  357. }
  358. // End of code to remove
  359. if ((Controllers != null) && (Controllers.Length > 0))
  360. {
  361. OSDArray controls = new OSDArray(Controllers.Length);
  362. foreach (ControllerData ctl in Controllers)
  363. controls.Add(ctl.PackUpdateMessage());
  364. args["controllers"] = controls;
  365. }
  366. if ((CallbackURI != null) && (!CallbackURI.Equals("")))
  367. args["callback_uri"] = OSD.FromString(CallbackURI);
  368. // Attachment objects for fatpack messages
  369. if (AttachmentObjects != null)
  370. {
  371. int i = 0;
  372. OSDArray attObjs = new OSDArray(AttachmentObjects.Count);
  373. foreach (ISceneObject so in AttachmentObjects)
  374. {
  375. OSDMap info = new OSDMap(4);
  376. info["sog"] = OSD.FromString(so.ToXml2());
  377. info["extra"] = OSD.FromString(so.ExtraToXmlString());
  378. info["modified"] = OSD.FromBoolean(so.HasGroupChanged);
  379. try
  380. {
  381. info["state"] = OSD.FromString(AttachmentObjectStates[i++]);
  382. }
  383. catch (IndexOutOfRangeException)
  384. {
  385. m_log.WarnFormat("[CHILD AGENT DATA]: scripts list is shorter than object list.");
  386. }
  387. attObjs.Add(info);
  388. }
  389. args["attach_objects"] = attObjs;
  390. }
  391. return args;
  392. }
  393. /// <summary>
  394. /// Deserialization of agent data.
  395. /// Avoiding reflection makes it painful to write, but that's the price!
  396. /// </summary>
  397. /// <param name="hash"></param>
  398. public virtual void Unpack(OSDMap args, IScene scene)
  399. {
  400. m_log.InfoFormat("[CHILDAGENTDATAUPDATE] Unpack data");
  401. if (args.ContainsKey("region_id"))
  402. UUID.TryParse(args["region_id"].AsString(), out RegionID);
  403. if (args["circuit_code"] != null)
  404. UInt32.TryParse((string)args["circuit_code"].AsString(), out CircuitCode);
  405. if (args["agent_uuid"] != null)
  406. AgentID = args["agent_uuid"].AsUUID();
  407. if (args["session_uuid"] != null)
  408. SessionID = args["session_uuid"].AsUUID();
  409. if (args["position"] != null)
  410. Vector3.TryParse(args["position"].AsString(), out Position);
  411. if (args["velocity"] != null)
  412. Vector3.TryParse(args["velocity"].AsString(), out Velocity);
  413. if (args["center"] != null)
  414. Vector3.TryParse(args["center"].AsString(), out Center);
  415. if (args["size"] != null)
  416. Vector3.TryParse(args["size"].AsString(), out Size);
  417. if (args["at_axis"] != null)
  418. Vector3.TryParse(args["at_axis"].AsString(), out AtAxis);
  419. if (args["left_axis"] != null)
  420. Vector3.TryParse(args["left_axis"].AsString(), out AtAxis);
  421. if (args["up_axis"] != null)
  422. Vector3.TryParse(args["up_axis"].AsString(), out AtAxis);
  423. if (args["changed_grid"] != null)
  424. ChangedGrid = args["changed_grid"].AsBoolean();
  425. if (args["far"] != null)
  426. Far = (float)(args["far"].AsReal());
  427. if (args["aspect"] != null)
  428. Aspect = (float)args["aspect"].AsReal();
  429. if (args["throttles"] != null)
  430. Throttles = args["throttles"].AsBinary();
  431. if (args["locomotion_state"] != null)
  432. UInt32.TryParse(args["locomotion_state"].AsString(), out LocomotionState);
  433. if (args["head_rotation"] != null)
  434. Quaternion.TryParse(args["head_rotation"].AsString(), out HeadRotation);
  435. if (args["body_rotation"] != null)
  436. Quaternion.TryParse(args["body_rotation"].AsString(), out BodyRotation);
  437. if (args["control_flags"] != null)
  438. UInt32.TryParse(args["control_flags"].AsString(), out ControlFlags);
  439. if (args["energy_level"] != null)
  440. EnergyLevel = (float)(args["energy_level"].AsReal());
  441. if (args["god_level"] != null)
  442. Byte.TryParse(args["god_level"].AsString(), out GodLevel);
  443. if (args["always_run"] != null)
  444. AlwaysRun = args["always_run"].AsBoolean();
  445. if (args["prey_agent"] != null)
  446. PreyAgent = args["prey_agent"].AsUUID();
  447. if (args["agent_access"] != null)
  448. Byte.TryParse(args["agent_access"].AsString(), out AgentAccess);
  449. if (args["active_group_id"] != null)
  450. ActiveGroupID = args["active_group_id"].AsUUID();
  451. if ((args["groups"] != null) && (args["groups"]).Type == OSDType.Array)
  452. {
  453. OSDArray groups = (OSDArray)(args["groups"]);
  454. Groups = new AgentGroupData[groups.Count];
  455. int i = 0;
  456. foreach (OSD o in groups)
  457. {
  458. if (o.Type == OSDType.Map)
  459. {
  460. Groups[i++] = new AgentGroupData((OSDMap)o);
  461. }
  462. }
  463. }
  464. if ((args["animations"] != null) && (args["animations"]).Type == OSDType.Array)
  465. {
  466. OSDArray anims = (OSDArray)(args["animations"]);
  467. Anims = new Animation[anims.Count];
  468. int i = 0;
  469. foreach (OSD o in anims)
  470. {
  471. if (o.Type == OSDType.Map)
  472. {
  473. Anims[i++] = new Animation((OSDMap)o);
  474. }
  475. }
  476. }
  477. //if ((args["agent_textures"] != null) && (args["agent_textures"]).Type == OSDType.Array)
  478. //{
  479. // OSDArray textures = (OSDArray)(args["agent_textures"]);
  480. // AgentTextures = new UUID[textures.Count];
  481. // int i = 0;
  482. // foreach (OSD o in textures)
  483. // AgentTextures[i++] = o.AsUUID();
  484. //}
  485. Appearance = new AvatarAppearance();
  486. // The code to unpack textures, visuals, wearables and attachments
  487. // should be removed; packed appearance contains the full appearance
  488. // This is retained for backward compatibility only
  489. if (args["texture_entry"] != null)
  490. {
  491. byte[] rawtextures = args["texture_entry"].AsBinary();
  492. Primitive.TextureEntry textures = new Primitive.TextureEntry(rawtextures,0,rawtextures.Length);
  493. Appearance.SetTextureEntries(textures);
  494. }
  495. if (args["visual_params"] != null)
  496. Appearance.SetVisualParams(args["visual_params"].AsBinary());
  497. if ((args["wearables"] != null) && (args["wearables"]).Type == OSDType.Array)
  498. {
  499. OSDArray wears = (OSDArray)(args["wearables"]);
  500. for (int i = 0; i < wears.Count / 2; i++)
  501. {
  502. AvatarWearable awear = new AvatarWearable((OSDArray)wears[i]);
  503. Appearance.SetWearable(i,awear);
  504. }
  505. }
  506. if ((args["attachments"] != null) && (args["attachments"]).Type == OSDType.Array)
  507. {
  508. OSDArray attachs = (OSDArray)(args["attachments"]);
  509. foreach (OSD o in attachs)
  510. {
  511. if (o.Type == OSDType.Map)
  512. {
  513. // We know all of these must end up as attachments so we
  514. // append rather than replace to ensure multiple attachments
  515. // per point continues to work
  516. // m_log.DebugFormat("[CHILDAGENTDATAUPDATE]: Appending attachments for {0}", AgentID);
  517. Appearance.AppendAttachment(new AvatarAttachment((OSDMap)o));
  518. }
  519. }
  520. }
  521. // end of code to remove
  522. if (args.ContainsKey("packed_appearance") && (args["packed_appearance"]).Type == OSDType.Map)
  523. Appearance = new AvatarAppearance((OSDMap)args["packed_appearance"]);
  524. else
  525. m_log.WarnFormat("[CHILDAGENTDATAUPDATE] No packed appearance");
  526. if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array)
  527. {
  528. OSDArray controls = (OSDArray)(args["controllers"]);
  529. Controllers = new ControllerData[controls.Count];
  530. int i = 0;
  531. foreach (OSD o in controls)
  532. {
  533. if (o.Type == OSDType.Map)
  534. {
  535. Controllers[i++] = new ControllerData((OSDMap)o);
  536. }
  537. }
  538. }
  539. if (args["callback_uri"] != null)
  540. CallbackURI = args["callback_uri"].AsString();
  541. // Attachment objects
  542. if (args["attach_objects"] != null && args["attach_objects"].Type == OSDType.Array)
  543. {
  544. OSDArray attObjs = (OSDArray)(args["attach_objects"]);
  545. AttachmentObjects = new List<ISceneObject>();
  546. AttachmentObjectStates = new List<string>();
  547. foreach (OSD o in attObjs)
  548. {
  549. if (o.Type == OSDType.Map)
  550. {
  551. OSDMap info = (OSDMap)o;
  552. ISceneObject so = scene.DeserializeObject(info["sog"].AsString());
  553. so.ExtraFromXmlString(info["extra"].AsString());
  554. so.HasGroupChanged = info["modified"].AsBoolean();
  555. AttachmentObjects.Add(so);
  556. AttachmentObjectStates.Add(info["state"].AsString());
  557. }
  558. }
  559. }
  560. }
  561. public AgentData()
  562. {
  563. }
  564. public AgentData(Hashtable hash)
  565. {
  566. //UnpackUpdateMessage(hash);
  567. }
  568. public void Dump()
  569. {
  570. System.Console.WriteLine("------------ AgentData ------------");
  571. System.Console.WriteLine("UUID: " + AgentID);
  572. System.Console.WriteLine("Region: " + RegionID);
  573. System.Console.WriteLine("Position: " + Position);
  574. }
  575. }
  576. public class CompleteAgentData : AgentData
  577. {
  578. public override OSDMap Pack()
  579. {
  580. return base.Pack();
  581. }
  582. public override void Unpack(OSDMap map, IScene scene)
  583. {
  584. base.Unpack(map, scene);
  585. }
  586. }
  587. }