Add scripted controllers into agent intersim messaging

This commit is contained in:
Melanie Thielker
2010-07-11 14:26:57 +02:00
parent 922e874653
commit 7f0f11304f
3 changed files with 102 additions and 0 deletions

View File

@@ -265,6 +265,46 @@ namespace OpenSim.Framework
}
}
public class ControllerData
{
public UUID ItemID;
public uint IgnoreControls;
public uint EventControls;
public ControllerData(UUID item, uint ignore, uint ev)
{
ItemID = item;
IgnoreControls = ignore;
EventControls = ev;
}
public ControllerData(OSDMap args)
{
UnpackUpdateMessage(args);
}
public OSDMap PackUpdateMessage()
{
OSDMap controldata = new OSDMap();
controldata["item"] = OSD.FromUUID(ItemID);
controldata["ignore"] = OSD.FromInteger(IgnoreControls);
controldata["event"] = OSD.FromInteger(EventControls);
return controldata;
}
public void UnpackUpdateMessage(OSDMap args)
{
if (args["item"] != null)
ItemID = args["item"].AsUUID();
if (args["ignore"] != null)
IgnoreControls = (uint)args["ignore"].AsInteger();
if (args["event"] != null)
EventControls = (uint)args["event"].AsInteger();
}
}
public class AgentData : IAgentData
{
private UUID m_id;
@@ -313,6 +353,9 @@ namespace OpenSim.Framework
public UUID[] Wearables;
public AttachmentData[] Attachments;
// Scripted
public ControllerData[] Controllers;
public string CallbackURI;
public virtual OSDMap Pack()
@@ -403,6 +446,14 @@ namespace OpenSim.Framework
args["attachments"] = attachs;
}
if ((Controllers != null) && (Controllers.Length > 0))
{
OSDArray controls = new OSDArray(Controllers.Length);
foreach (ControllerData ctl in Controllers)
controls.Add(ctl.PackUpdateMessage());
args["controllers"] = controls;
}
if ((CallbackURI != null) && (!CallbackURI.Equals("")))
args["callback_uri"] = OSD.FromString(CallbackURI);
@@ -559,6 +610,20 @@ namespace OpenSim.Framework
}
}
if ((args["controllers"] != null) && (args["controllers"]).Type == OSDType.Array)
{
OSDArray controls = (OSDArray)(args["controllers"]);
Controllers = new ControllerData[controls.Count];
int i = 0;
foreach (OSD o in controls)
{
if (o.Type == OSDType.Map)
{
Controllers[i++] = new ControllerData((OSDMap)o);
}
}
}
if (args["callback_uri"] != null)
CallbackURI = args["callback_uri"].AsString();
}