29 using System.Collections;
30 using System.Collections.Generic;
31 using System.Reflection;
34 using OpenMetaverse.StructuredData;
36 namespace OpenSim.Framework
62 UUID AgentID {
get; set; }
97 public Dictionary<ulong, string> ChildrenCapSeeds = null;
102 args[
"message_type"] = OSD.FromString(
"AgentPosition");
104 args[
"region_handle"] = OSD.FromString(RegionHandle.ToString());
105 args[
"circuit_code"] = OSD.FromString(CircuitCode.ToString());
106 args[
"agent_uuid"] = OSD.FromUUID(AgentID);
107 args[
"session_uuid"] = OSD.FromUUID(SessionID);
109 args[
"position"] = OSD.FromString(Position.ToString());
110 args[
"velocity"] = OSD.FromString(Velocity.ToString());
111 args[
"center"] = OSD.FromString(Center.ToString());
112 args[
"size"] = OSD.FromString(Size.ToString());
113 args[
"at_axis"] = OSD.FromString(AtAxis.ToString());
114 args[
"left_axis"] = OSD.FromString(LeftAxis.ToString());
115 args[
"up_axis"] = OSD.FromString(UpAxis.ToString());
117 args[
"far"] = OSD.FromReal(Far);
118 args[
"changed_grid"] = OSD.FromBoolean(ChangedGrid);
120 if ((Throttles != null) && (Throttles.Length > 0))
121 args[
"throttles"] = OSD.FromBinary(Throttles);
123 if (ChildrenCapSeeds != null && ChildrenCapSeeds.Count > 0)
126 foreach (KeyValuePair<ulong, string> kvp
in ChildrenCapSeeds)
129 pair[
"handle"] = OSD.FromString(kvp.Key.ToString());
130 pair[
"seed"] = OSD.FromString(kvp.Value);
131 childrenSeeds.Add(pair);
133 args[
"children_seeds"] = childrenSeeds;
141 if (args.ContainsKey(
"region_handle"))
142 UInt64.TryParse(args[
"region_handle"].AsString(), out RegionHandle);
144 if (args[
"circuit_code"] != null)
145 UInt32.TryParse((string)args[
"circuit_code"].AsString(), out CircuitCode);
147 if (args[
"agent_uuid"] != null)
148 AgentID = args[
"agent_uuid"].AsUUID();
150 if (args[
"session_uuid"] != null)
151 SessionID = args[
"session_uuid"].AsUUID();
153 if (args[
"position"] != null)
154 Vector3.TryParse(args[
"position"].AsString(), out
Position);
156 if (args[
"velocity"] != null)
157 Vector3.TryParse(args[
"velocity"].AsString(), out
Velocity);
159 if (args[
"center"] != null)
160 Vector3.TryParse(args[
"center"].AsString(), out Center);
162 if (args[
"size"] != null)
163 Vector3.TryParse(args[
"size"].AsString(), out
Size);
165 if (args[
"at_axis"] != null)
166 Vector3.TryParse(args[
"at_axis"].AsString(), out AtAxis);
168 if (args[
"left_axis"] != null)
169 Vector3.TryParse(args[
"left_axis"].AsString(), out LeftAxis);
171 if (args[
"up_axis"] != null)
172 Vector3.TryParse(args[
"up_axis"].AsString(), out UpAxis);
174 if (args[
"changed_grid"] != null)
175 ChangedGrid = args[
"changed_grid"].AsBoolean();
177 if (args[
"far"] != null)
178 Far = (float)(args[
"far"].AsReal());
180 if (args[
"throttles"] != null)
181 Throttles = args[
"throttles"].AsBinary();
183 if (args.ContainsKey(
"children_seeds") && (args[
"children_seeds"] != null) &&
184 (args[
"children_seeds"].
Type == OSDType.Array))
187 ChildrenCapSeeds =
new Dictionary<ulong, string>();
188 foreach (
OSD o
in childrenSeeds)
190 if (o.Type == OSDType.Map)
195 if (pair[
"handle"] != null)
196 if (!UInt64.TryParse(pair[
"handle"].AsString(), out handle))
198 if (pair[
"seed"] != null)
199 seed = pair[
"seed"].AsString();
200 if (!ChildrenCapSeeds.ContainsKey(handle))
201 ChildrenCapSeeds.Add(handle, seed);
214 AgentID =
new UUID(cAgent.
AgentID);
218 Size =
new Vector3();
219 Size.Z = cAgent.AVHeight;
221 Center = cAgent.cameraPosition;
222 Far = cAgent.drawdistance;
224 RegionHandle = cAgent.regionHandle;
225 Throttles = cAgent.throttles;
239 GroupPowers = powers;
240 AcceptNotices = notices;
245 UnpackUpdateMessage(args);
251 groupdata[
"group_id"] = OSD.FromUUID(GroupID);
252 groupdata[
"group_powers"] = OSD.FromString(GroupPowers.ToString());
253 groupdata[
"accept_notices"] = OSD.FromBoolean(AcceptNotices);
260 if (args[
"group_id"] != null)
261 GroupID = args[
"group_id"].AsUUID();
262 if (args[
"group_powers"] != null)
263 UInt64.TryParse((string)args[
"group_powers"].AsString(), out GroupPowers);
264 if (args[
"accept_notices"] != null)
265 AcceptNotices = args[
"accept_notices"].AsBoolean();
280 IgnoreControls = ignore;
286 UnpackUpdateMessage(args);
292 controldata[
"object"] = OSD.FromUUID(ObjectID);
293 controldata[
"item"] = OSD.FromUUID(ItemID);
294 controldata[
"ignore"] = OSD.FromInteger(IgnoreControls);
295 controldata[
"event"] = OSD.FromInteger(EventControls);
303 if (args[
"object"] != null)
304 ObjectID = args[
"object"].AsUUID();
305 if (args[
"item"] != null)
306 ItemID = args[
"item"].AsUUID();
307 if (args[
"ignore"] != null)
308 IgnoreControls = (uint)args[
"ignore"].AsInteger();
309 if (args[
"event"] != null)
310 EventControls = (uint)args[
"event"].AsInteger();
320 set { m_id = value; }
358 public Dictionary<ulong, string> ChildrenCapSeeds = null;
362 public Byte MotionState = 0;
372 private static readonly ILog m_log =
373 LogManager.GetLogger(
374 MethodBase.GetCurrentMethod().DeclaringType);
392 public Dictionary<string, UUID> MovementAnimationOverRides =
new Dictionary<string, UUID>();
396 int wearablesCount = -1;
401 args[
"message_type"] = OSD.FromString(
"AgentData");
403 args[
"region_id"] = OSD.FromString(RegionID.ToString());
404 args[
"circuit_code"] = OSD.FromString(CircuitCode.ToString());
405 args[
"agent_uuid"] = OSD.FromUUID(AgentID);
406 args[
"session_uuid"] = OSD.FromUUID(SessionID);
408 args[
"position"] = OSD.FromString(Position.ToString());
409 args[
"velocity"] = OSD.FromString(Velocity.ToString());
410 args[
"center"] = OSD.FromString(Center.ToString());
411 args[
"size"] = OSD.FromString(Size.ToString());
412 args[
"at_axis"] = OSD.FromString(AtAxis.ToString());
413 args[
"left_axis"] = OSD.FromString(LeftAxis.ToString());
414 args[
"up_axis"] = OSD.FromString(UpAxis.ToString());
417 args[
"changed_grid"] = OSD.FromBoolean(SenderWantsToWaitForRoot);
418 args[
"wait_for_root"] = OSD.FromBoolean(SenderWantsToWaitForRoot);
419 args[
"far"] = OSD.FromReal(Far);
420 args[
"aspect"] = OSD.FromReal(Aspect);
422 if ((Throttles != null) && (Throttles.Length > 0))
423 args[
"throttles"] = OSD.FromBinary(Throttles);
425 args[
"locomotion_state"] = OSD.FromString(LocomotionState.ToString());
426 args[
"head_rotation"] = OSD.FromString(HeadRotation.ToString());
427 args[
"body_rotation"] = OSD.FromString(BodyRotation.ToString());
428 args[
"control_flags"] = OSD.FromString(ControlFlags.ToString());
430 args[
"energy_level"] = OSD.FromReal(EnergyLevel);
431 args[
"god_level"] = OSD.FromString(GodLevel.ToString());
432 args[
"always_run"] = OSD.FromBoolean(AlwaysRun);
433 args[
"prey_agent"] = OSD.FromUUID(PreyAgent);
434 args[
"agent_access"] = OSD.FromString(AgentAccess.ToString());
436 args[
"active_group_id"] = OSD.FromUUID(ActiveGroupID);
438 if ((Groups != null) && (Groups.Length > 0))
442 groups.Add(agd.PackUpdateMessage());
443 args[
"groups"] = groups;
446 if (ChildrenCapSeeds != null && ChildrenCapSeeds.Count > 0)
449 foreach (KeyValuePair<ulong, string> kvp
in ChildrenCapSeeds)
452 pair[
"handle"] = OSD.FromString(kvp.Key.ToString());
453 pair[
"seed"] = OSD.FromString(kvp.Value);
454 childrenSeeds.Add(pair);
456 args[
"children_seeds"] = childrenSeeds;
459 if ((Anims != null) && (Anims.Length > 0))
463 anims.Add(aanim.PackUpdateMessage());
464 args[
"animations"] = anims;
467 if (DefaultAnim != null)
469 args[
"default_animation"] = DefaultAnim.PackUpdateMessage();
472 if (AnimState != null)
474 args[
"animation_state"] = AnimState.PackUpdateMessage();
477 if (MovementAnimationOverRides.Count > 0)
481 foreach (KeyValuePair<string, UUID> kvp
in MovementAnimationOverRides)
484 ao[
"state"] = OSD.FromString(kvp.Key);
485 ao[
"uuid"] = OSD.FromUUID(kvp.Value);
489 args[
"movementAO"] = AOs;
492 if (MotionState != 0)
494 args[
"motion_state"] = OSD.FromInteger(MotionState);
497 if (Appearance != null)
498 args[
"packed_appearance"] = Appearance.Pack(ctx);
542 if ((Controllers != null) && (Controllers.Length > 0))
546 controls.Add(ctl.PackUpdateMessage());
547 args[
"controllers"] = controls;
550 if ((CallbackURI != null) && (!CallbackURI.Equals(
"")))
551 args[
"callback_uri"] = OSD.FromString(CallbackURI);
554 if (AttachmentObjects != null)
561 info[
"sog"] = OSD.FromString(so.ToXml2());
562 info[
"extra"] = OSD.FromString(so.ExtraToXmlString());
563 info[
"modified"] = OSD.FromBoolean(so.HasGroupChanged);
566 info[
"state"] = OSD.FromString(AttachmentObjectStates[i++]);
568 catch (IndexOutOfRangeException)
570 m_log.WarnFormat(
"[CHILD AGENT DATA]: scripts list is shorter than object list.");
575 args[
"attach_objects"] = attObjs;
578 args[
"parent_part"] = OSD.FromUUID(ParentPart);
579 args[
"sit_offset"] = OSD.FromString(SitOffset.ToString());
593 if (args.ContainsKey(
"region_id"))
594 UUID.TryParse(args[
"region_id"].AsString(), out RegionID);
596 if (args[
"circuit_code"] != null)
597 UInt32.TryParse((string)args[
"circuit_code"].AsString(), out CircuitCode);
599 if (args[
"agent_uuid"] != null)
600 AgentID = args[
"agent_uuid"].AsUUID();
602 if (args[
"session_uuid"] != null)
603 SessionID = args[
"session_uuid"].AsUUID();
605 if (args[
"position"] != null)
606 Vector3.TryParse(args[
"position"].AsString(), out
Position);
608 if (args[
"velocity"] != null)
609 Vector3.TryParse(args[
"velocity"].AsString(), out
Velocity);
611 if (args[
"center"] != null)
612 Vector3.TryParse(args[
"center"].AsString(), out Center);
614 if (args[
"size"] != null)
615 Vector3.TryParse(args[
"size"].AsString(), out
Size);
617 if (args[
"at_axis"] != null)
618 Vector3.TryParse(args[
"at_axis"].AsString(), out AtAxis);
620 if (args[
"left_axis"] != null)
621 Vector3.TryParse(args[
"left_axis"].AsString(), out AtAxis);
623 if (args[
"up_axis"] != null)
624 Vector3.TryParse(args[
"up_axis"].AsString(), out AtAxis);
626 if (args.ContainsKey(
"wait_for_root") && args[
"wait_for_root"] != null)
627 SenderWantsToWaitForRoot = args[
"wait_for_root"].AsBoolean();
629 if (args[
"far"] != null)
630 Far = (float)(args[
"far"].AsReal());
632 if (args[
"aspect"] != null)
633 Aspect = (float)args[
"aspect"].AsReal();
635 if (args[
"throttles"] != null)
636 Throttles = args[
"throttles"].AsBinary();
638 if (args[
"locomotion_state"] != null)
639 UInt32.TryParse(args[
"locomotion_state"].AsString(), out LocomotionState);
641 if (args[
"head_rotation"] != null)
642 Quaternion.TryParse(args[
"head_rotation"].AsString(), out HeadRotation);
644 if (args[
"body_rotation"] != null)
645 Quaternion.TryParse(args[
"body_rotation"].AsString(), out BodyRotation);
647 if (args[
"control_flags"] != null)
648 UInt32.TryParse(args[
"control_flags"].AsString(), out ControlFlags);
650 if (args[
"energy_level"] != null)
651 EnergyLevel = (float)(args[
"energy_level"].AsReal());
653 if (args[
"god_level"] != null)
654 Byte.TryParse(args[
"god_level"].AsString(), out GodLevel);
656 if (args[
"always_run"] != null)
657 AlwaysRun = args[
"always_run"].AsBoolean();
659 if (args[
"prey_agent"] != null)
660 PreyAgent = args[
"prey_agent"].AsUUID();
662 if (args[
"agent_access"] != null)
663 Byte.TryParse(args[
"agent_access"].AsString(), out AgentAccess);
665 if (args[
"active_group_id"] != null)
666 ActiveGroupID = args[
"active_group_id"].AsUUID();
668 if ((args[
"groups"] != null) && (args[
"groups"]).
Type == OSDType.Array)
673 foreach (
OSD o
in groups)
675 if (o.Type == OSDType.Map)
682 if (args.ContainsKey(
"children_seeds") && (args[
"children_seeds"] != null) &&
683 (args[
"children_seeds"].
Type == OSDType.Array))
686 ChildrenCapSeeds =
new Dictionary<ulong, string>();
687 foreach (
OSD o
in childrenSeeds)
689 if (o.Type == OSDType.Map)
694 if (pair[
"handle"] != null)
695 if (!UInt64.TryParse(pair[
"handle"].AsString(), out handle))
697 if (pair[
"seed"] != null)
698 seed = pair[
"seed"].AsString();
699 if (!ChildrenCapSeeds.ContainsKey(handle))
700 ChildrenCapSeeds.Add(handle, seed);
705 if ((args[
"animations"] != null) && (args[
"animations"]).
Type == OSDType.Array)
710 foreach (
OSD o
in anims)
712 if (o.Type == OSDType.Map)
719 if (args[
"default_animation"] != null)
731 if (args[
"animation_state"] != null)
743 MovementAnimationOverRides.Clear();
745 if (args[
"movementAO"] != null && args[
"movementAO"].
Type == OSDType.Array)
748 int count = AOs.Count;
750 for (
int i = 0; i < count; i++)
753 if (ao[
"state"] != null && ao[
"uuid"] != null)
755 string state = ao[
"state"].AsString();
756 UUID
id = ao[
"uuid"].AsUUID();
757 MovementAnimationOverRides[state] = id;
762 if (args.ContainsKey(
"motion_state"))
763 MotionState = (byte)args[
"motion_state"].AsInteger();
776 if (args.ContainsKey(
"packed_appearance") && (args[
"packed_appearance"]).
Type == OSDType.Map)
778 m_log.WarnFormat(
"[CHILDAGENTDATAUPDATE] got packed appearance");
784 m_log.WarnFormat(
"[CHILDAGENTDATAUPDATE] No packed appearance, checking old method");
791 if (args[
"texture_entry"] != null)
793 byte[] rawtextures = args[
"texture_entry"].AsBinary();
794 Primitive.TextureEntry textures =
new Primitive.TextureEntry(rawtextures, 0, rawtextures.Length);
795 Appearance.SetTextureEntries(textures);
798 if (args[
"visual_params"] != null)
799 Appearance.SetVisualParams(args[
"visual_params"].AsBinary());
801 if ((args[
"wearables"] != null) && (args[
"wearables"]).
Type == OSDType.Array)
805 for (
int i = 0; i < wears.Count / 2; i++)
808 Appearance.SetWearable(i, awear);
812 if ((args[
"attachments"] != null) && (args[
"attachments"]).
Type == OSDType.Array)
815 foreach (
OSD o
in attachs)
817 if (o.Type == OSDType.Map)
835 if ((args[
"controllers"] != null) && (args[
"controllers"]).
Type == OSDType.Array)
840 foreach (
OSD o
in controls)
842 if (o.Type == OSDType.Map)
849 if (args[
"callback_uri"] != null)
850 CallbackURI = args[
"callback_uri"].AsString();
853 if (args[
"attach_objects"] != null && args[
"attach_objects"].
Type == OSDType.Array)
856 AttachmentObjects =
new List<ISceneObject>();
857 AttachmentObjectStates =
new List<string>();
858 foreach (
OSD o
in attObjs)
860 if (o.Type == OSDType.Map)
863 ISceneObject so = scene.DeserializeObject(info[
"sog"].AsString());
864 so.ExtraFromXmlString(info[
"extra"].AsString());
865 so.HasGroupChanged = info[
"modified"].AsBoolean();
866 AttachmentObjects.Add(so);
867 AttachmentObjectStates.Add(info[
"state"].AsString());
872 if (args[
"parent_part"] != null)
873 ParentPart = args[
"parent_part"].AsUUID();
874 if (args[
"sit_offset"] != null)
875 Vector3.TryParse(args[
"sit_offset"].AsString(), out SitOffset);
889 System.Console.WriteLine(
"------------ AgentData ------------");
890 System.Console.WriteLine(
"UUID: " + AgentID);
891 System.Console.WriteLine(
"Region: " + RegionID);
892 System.Console.WriteLine(
"Position: " +
Position);
900 return base.Pack(ctx);
905 base.Unpack(map, scene, ctx);
OSDMap Pack(EntityTransferContext ctx)
OpenMetaverse.StructuredData.OSDArray OSDArray
AgentData(Hashtable hash)
List< string > AttachmentObjectStates
bool SenderWantsToWaitForRoot
Signal on a V2 teleport that Scene.IncomingChildAgentDataUpdate(AgentData ad) should wait for the sce...
Contains the Avatar's Appearance and methods to manipulate the appearance.
Information about an Animation
OpenMetaverse.StructuredData.OSDMap OSDMap
ControllerData(OSDMap args)
override OSDMap Pack(EntityTransferContext ctx)
AgentGroupData(UUID id, ulong powers, bool notices)
void CopyFrom(ChildAgentDataUpdate cAgent, UUID sid)
Soon to be decommissioned
List< ISceneObject > AttachmentObjects
override void Unpack(OSDMap map, IScene scene, EntityTransferContext ctx)
Deserialization of agent data. Avoiding reflection makes it painful to write, but that's the price! ...
AgentGroupData(OSDMap args)
OSDMap PackUpdateMessage()
void UnpackUpdateMessage(OSDMap args)
virtual void Unpack(OSDMap args, IScene scene, EntityTransferContext ctx)
Deserialization of agent data. Avoiding reflection makes it painful to write, but that's the price! ...
OpenMetaverse.StructuredData.OSD OSD
Replacement for ChildAgentDataUpdate. Used over RESTComms and LocalComms.
virtual OSDMap Pack(EntityTransferContext ctx)
OpenSim.Framework.Animation Animation
ControllerData[] Controllers
ControllerData(UUID obj, UUID item, uint ignore, uint ev)
void UnpackUpdateMessage(OSDMap args)
OSDMap PackUpdateMessage()
AvatarAppearance Appearance
void Unpack(OSDMap args, IScene scene, EntityTransferContext ctx)