本文整理汇总了C#中OpenSim.Framework.AgentData类的典型用法代码示例。如果您正苦于以下问题:C# AgentData类的具体用法?C# AgentData怎么用?C# AgentData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AgentData类属于OpenSim.Framework命名空间,在下文中一共展示了AgentData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateAgent
public virtual bool CreateAgent(GridRegion destination, ref AgentCircuitData aCircuit, uint teleportFlags, AgentData data, out string reason)
{
reason = String.Empty;
// Try local first
if (m_localBackend.CreateAgent(destination, ref aCircuit, teleportFlags, data, out reason))
return true;
reason = String.Empty;
string uri = MakeUri(destination, true) + aCircuit.AgentID + "/";
try
{
OSDMap args = aCircuit.PackAgentCircuitData();
args["destination_x"] = OSD.FromString(destination.RegionLocX.ToString());
args["destination_y"] = OSD.FromString(destination.RegionLocY.ToString());
args["destination_name"] = OSD.FromString(destination.RegionName);
args["destination_uuid"] = OSD.FromString(destination.RegionID.ToString());
args["teleport_flags"] = OSD.FromString(teleportFlags.ToString());
if(data != null)
args["agent_data"] = data.Pack();
OSDMap result = WebUtils.PostToService (uri, args, true, false);
OSDMap results = WebUtils.GetOSDMap(result["_RawResult"].AsString());
//Pull out the result and set it as the reason
if (results == null)
return false;
reason = results["reason"] != null ? results["reason"].AsString() : "";
if (result["Success"].AsBoolean())
{
//Not right... don't return true except for opensim combatibility :/
if (reason == "")
return true;
try
{
OSDMap responseMap = (OSDMap)OSDParser.DeserializeJson(reason);
if (responseMap.ContainsKey("Reason"))
reason = responseMap["Reason"].AsString();
return responseMap["Success"].AsBoolean();
}
catch
{
//Not right... don't return true except for opensim combatibility :/
return true;
}
}
reason = result["Message"] != null ? result["Message"].AsString() : "error";
return false;
}
catch (Exception e)
{
m_log.Warn("[REMOTE SIMULATION CONNECTOR]: CreateAgent failed with exception: " + e.ToString());
reason = e.Message;
}
return false;
}
示例2: DoTeleport
//.........这里部分代码省略.........
{
endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
}
#endregion
capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
if (eq != null)
{
eq.EnableSimulator(destinationHandle, endPoint, sp.UUID);
// ES makes the client send a UseCircuitCode message to the destination,
// which triggers a bunch of things there.
// So let's wait
Thread.Sleep(200);
eq.EstablishAgentCommunication(sp.UUID, endPoint, capsPath);
}
else
{
sp.ControllingClient.InformClientOfNeighbour(destinationHandle, endPoint);
}
}
else
{
agentCircuit.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, reg.RegionHandle);
capsPath = finalDestination.ServerURI + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
}
SetInTransit(sp.UUID);
// Let's send a full update of the agent. This is a synchronous call.
AgentData agent = new AgentData();
sp.CopyTo(agent);
agent.Position = position;
SetCallbackURL(agent, sp.Scene.RegionInfo);
//sp.ControllingClient.SendTeleportProgress(teleportFlags, "Updating agent...");
if (!UpdateAgent(reg, finalDestination, agent))
{
// Region doesn't take it
m_log.WarnFormat(
"[ENTITY TRANSFER MODULE]: UpdateAgent failed on teleport of {0} to {1}. Returning avatar to source region.",
sp.Name, finalDestination.RegionName);
Fail(sp, finalDestination);
return;
}
sp.ControllingClient.SendTeleportProgress(teleportFlags | (uint)TeleportFlags.DisableCancel, "sending_dest");
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, sp.UUID);
if (eq != null)
{
eq.TeleportFinishEvent(destinationHandle, 13, endPoint,
0, teleportFlags, capsPath, sp.UUID);
}
else
{
sp.ControllingClient.SendRegionTeleport(destinationHandle, 13, endPoint, 4,
teleportFlags, capsPath);
}
示例3: CrossAgent
public static OSDMap CrossAgent(GridRegion crossingRegion, Vector3 pos,
Vector3 velocity, AgentCircuitData circuit, AgentData cAgent, ulong RequestingRegion)
{
OSDMap llsdBody = new OSDMap();
llsdBody.Add("Pos", pos);
llsdBody.Add("Vel", velocity);
llsdBody.Add("Region", crossingRegion.ToOSD());
llsdBody.Add("Circuit", circuit.PackAgentCircuitData());
llsdBody.Add("AgentData", cAgent.Pack());
return buildEvent("CrossAgent", llsdBody, circuit.AgentID, RequestingRegion);
}
示例4: UpdateAgent
public bool UpdateAgent(GridRegion destination, AgentData cAgentData)
{
if (destination == null)
return false;
bool retVal = false;
foreach (Scene s in m_sceneList)
{
IEntityTransferModule transferModule = s.RequestModuleInterface<IEntityTransferModule> ();
if(transferModule != null)
if(retVal)
transferModule.IncomingChildAgentDataUpdate (s, cAgentData);
else
retVal = transferModule.IncomingChildAgentDataUpdate (s, cAgentData);
}
// m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for ChildAgentUpdate", regionHandle);
return retVal;
}
示例5: CreateAgent
/**
* Agent-related communications
*/
public bool CreateAgent(GridRegion destination, ref AgentCircuitData aCircuit, uint teleportFlags, AgentData data, out string reason)
{
if (destination == null)
{
reason = "Given destination was null";
m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: CreateAgent was given a null destination");
return false;
}
foreach (Scene s in m_sceneList)
{
if (s.RegionInfo.RegionID == destination.RegionID)
{
//m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: Found region {0} to send SendCreateChildAgent", destination.RegionName);
if (data != null)
UpdateAgent(destination, data);
IEntityTransferModule transferModule = s.RequestModuleInterface<IEntityTransferModule> ();
if (transferModule != null)
return transferModule.NewUserConnection (s, aCircuit, teleportFlags, out reason);
}
}
m_log.DebugFormat("[LOCAL SIMULATION CONNECTOR]: Did not find region {0} for CreateAgent", destination.RegionName);
OSDMap map = new OSDMap();
map["Reason"] = "Did not find region " + destination.RegionName;
map["Success"] = false;
reason = OSDParser.SerializeJsonString(map);
return false;
}
示例6: DoTeleport
//.........这里部分代码省略.........
#endregion
eq.EnableSimulator(destinationHandle, endPoint, sp.UUID);
// ES makes the client send a UseCircuitCode message to the destination,
// which triggers a bunch of things there.
// So let's wait
Thread.Sleep(200);
eq.EstablishAgentCommunication(sp.UUID, endPoint, capsPath);
}
else
{
sp.ControllingClient.InformClientOfNeighbour(destinationHandle, endPoint);
}
}
else
{
agentCircuit.CapsPath = sp.Scene.CapsModule.GetChildSeed(sp.UUID, reg.RegionHandle);
capsPath = "http://" + finalDestination.ExternalHostName + ":" + finalDestination.HttpPort
+ "/CAPS/" + agentCircuit.CapsPath + "0000/";
}
if (m_cancelingAgents.Contains(sp.UUID))
{
Cancel(sp);
return;
}
SetInTransit(sp.UUID);
// Let's send a full update of the agent. This is a synchronous call.
AgentData agent = new AgentData();
sp.CopyTo(agent);
agent.Position = position;
SetCallbackURL(agent, sp.Scene.RegionInfo);
//sp.ControllingClient.SendTeleportProgress(teleportFlags, "Updating agent...");
if (!UpdateAgent(reg, finalDestination, agent))
{
// Region doesn't take it
Fail(sp, finalDestination);
return;
}
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, sp.UUID);
if (eq != null)
{
eq.TeleportFinishEvent(destinationHandle, 13, endPoint,
0, teleportFlags, capsPath, sp.UUID, teleportFlags);
}
else
{
sp.ControllingClient.SendRegionTeleport(destinationHandle, 13, endPoint, 4,
teleportFlags, capsPath);
}
// Let's set this to true tentatively. This does not trigger OnChildAgent
sp.IsChildAgent = true;
// TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which
// trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation
示例7: SendChildAgentUpdate
public bool SendChildAgentUpdate(ulong regionHandle, AgentData cAgentData)
{
int childAgentUpdateStart = Environment.TickCount;
try
{
// Try local first
if (m_localBackend.SendChildAgentUpdate(regionHandle, cAgentData))
return true;
// else do the remote thing
if (!m_localBackend.IsLocalRegion(regionHandle))
{
RegionInfo regInfo = m_commsManager.GridService.RequestNeighbourInfo(regionHandle);
if (regInfo != null)
{
return m_regionClient.DoChildAgentUpdateCall(regInfo, cAgentData);
}
//else
// m_log.Warn("[REST COMMS]: Region not found " + regionHandle);
}
return false;
}
finally
{
m_log.DebugFormat("[REST COMM] SendCreateChildAgent: {0} ms", Environment.TickCount - childAgentUpdateStart);
}
}
示例8: UpdateChildAgent
public void UpdateChildAgent(AgentData cAgentData)
{
// m_log.Debug(" >>> ChildAgentDataUpdate <<< " + Scene.RegionInfo.RegionName);
if (!IsChildAgent)
return;
CopyFrom(cAgentData);
}
示例9: CopyFrom
private void CopyFrom(AgentData cAgent)
{
m_callbackURI = cAgent.CallbackURI;
// m_log.DebugFormat(
// "[SCENE PRESENCE]: Set callback for {0} in {1} to {2} in CopyFrom()",
// Name, m_scene.RegionInfo.RegionName, m_callbackURI);
m_pos = cAgent.Position;
m_velocity = cAgent.Velocity;
CameraPosition = cAgent.Center;
CameraAtAxis = cAgent.AtAxis;
CameraLeftAxis = cAgent.LeftAxis;
CameraUpAxis = cAgent.UpAxis;
ParentUUID = cAgent.ParentPart;
PrevSitOffset = cAgent.SitOffset;
// When we get to the point of re-computing neighbors everytime this
// changes, then start using the agent's drawdistance rather than the
// region's draw distance.
DrawDistance = cAgent.Far;
//DrawDistance = Scene.DefaultDrawDistance;
if (cAgent.ChildrenCapSeeds != null && cAgent.ChildrenCapSeeds.Count > 0)
{
if (Scene.CapsModule != null)
{
Scene.CapsModule.SetChildrenSeed(UUID, cAgent.ChildrenCapSeeds);
}
KnownRegions = cAgent.ChildrenCapSeeds;
}
if ((cAgent.Throttles != null) && cAgent.Throttles.Length > 0)
ControllingClient.SetChildAgentThrottle(cAgent.Throttles);
m_headrotation = cAgent.HeadRotation;
Rotation = cAgent.BodyRotation;
m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags;
if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID)))
GodLevel = cAgent.GodLevel;
SetAlwaysRun = cAgent.AlwaysRun;
Appearance = new AvatarAppearance(cAgent.Appearance);
/*
bool isFlying = ((m_AgentControlFlags & AgentManager.ControlFlags.AGENT_CONTROL_FLY) != 0);
if (PhysicsActor != null)
{
RemoveFromPhysicalScene();
AddToPhysicalScene(isFlying);
}
*/
try
{
lock (scriptedcontrols)
{
if (cAgent.Controllers != null)
{
scriptedcontrols.Clear();
foreach (ControllerData c in cAgent.Controllers)
{
ScriptControllers sc = new ScriptControllers();
sc.objectID = c.ObjectID;
sc.itemID = c.ItemID;
sc.ignoreControls = (ScriptControlled)c.IgnoreControls;
sc.eventControls = (ScriptControlled)c.EventControls;
scriptedcontrols[sc.itemID] = sc;
}
}
}
}
catch { }
Animator.ResetAnimations();
Overrides.CopyAOPairsFrom(cAgent.MovementAnimationOverRides);
// FIXME: Why is this null check necessary? Where are the cases where we get a null Anims object?
if (cAgent.DefaultAnim != null)
Animator.Animations.SetDefaultAnimation(cAgent.DefaultAnim.AnimID, cAgent.DefaultAnim.SequenceNum, UUID.Zero);
if (cAgent.AnimState != null)
Animator.Animations.SetImplicitDefaultAnimation(cAgent.AnimState.AnimID, cAgent.AnimState.SequenceNum, UUID.Zero);
if (cAgent.Anims != null)
Animator.Animations.FromArray(cAgent.Anims);
if (cAgent.MotionState != 0)
Animator.currentControlState = (ScenePresenceAnimator.motionControlStates) cAgent.MotionState;
if (Scene.AttachmentsModule != null)
Scene.AttachmentsModule.CopyAttachments(cAgent, this);
lock (m_originRegionIDAccessLock)
m_originRegionID = cAgent.RegionID;
}
示例10: SendChildAgentUpdate
public bool SendChildAgentUpdate(ulong regionHandle, AgentData cAgentData)
{
foreach (Scene s in m_sceneList)
{
if (s.RegionInfo.RegionHandle == regionHandle)
{
//m_log.DebugFormat(
// "[LOCAL COMMS]: Found region {0} {1} to send ChildAgentUpdate",
// s.RegionInfo.RegionName, regionHandle);
s.IncomingChildAgentDataUpdate(cAgentData);
return true;
}
}
// m_log.DebugFormat("[LOCAL COMMS]: Did not find region {0} for ChildAgentUpdate", regionHandle);
return false;
}
示例11: SendChildAgentUpdate2
public ChildAgentUpdate2Response SendChildAgentUpdate2(SimpleRegionInfo regionInfo, AgentData data)
{
foreach (Scene s in m_sceneList)
{
if (s.RegionInfo.RegionHandle == regionInfo.RegionHandle)
{
return s.IncomingChildAgentDataUpdate2(data);
}
}
return ChildAgentUpdate2Response.Error;
}
示例12: DoAgentPut
protected void DoAgentPut(Hashtable request, Hashtable responsedata)
{
OSDMap args = Utils.GetOSDMap((string)request["body"]);
if (args == null)
{
responsedata["int_response_code"] = HttpStatusCode.BadRequest;
responsedata["str_response_string"] = "Bad request";
return;
}
// retrieve the input arguments
int x = 0, y = 0;
UUID uuid = UUID.Zero;
string regionname = string.Empty;
if (args.ContainsKey("destination_x") && args["destination_x"] != null)
Int32.TryParse(args["destination_x"].AsString(), out x);
if (args.ContainsKey("destination_y") && args["destination_y"] != null)
Int32.TryParse(args["destination_y"].AsString(), out y);
if (args.ContainsKey("destination_uuid") && args["destination_uuid"] != null)
UUID.TryParse(args["destination_uuid"].AsString(), out uuid);
if (args.ContainsKey("destination_name") && args["destination_name"] != null)
regionname = args["destination_name"].ToString();
GridRegion destination = new GridRegion();
destination.RegionID = uuid;
destination.RegionLocX = x;
destination.RegionLocY = y;
destination.RegionName = regionname;
string messageType;
if (args["message_type"] != null)
messageType = args["message_type"].AsString();
else
{
m_log.Warn("[AGENT HANDLER]: Agent Put Message Type not found. ");
messageType = "AgentData";
}
bool result = true;
if ("AgentData".Equals(messageType))
{
AgentData agent = new AgentData();
try
{
agent.Unpack(args, m_SimulationService.GetScene(destination.RegionHandle));
}
catch (Exception ex)
{
m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildAgentUpdate message {0}", ex.Message);
responsedata["int_response_code"] = HttpStatusCode.BadRequest;
responsedata["str_response_string"] = "Bad request";
return;
}
//agent.Dump();
// This is one of the meanings of PUT agent
result = UpdateAgent(destination, agent);
}
else if ("AgentPosition".Equals(messageType))
{
AgentPosition agent = new AgentPosition();
try
{
agent.Unpack(args, m_SimulationService.GetScene(destination.RegionHandle));
}
catch (Exception ex)
{
m_log.InfoFormat("[AGENT HANDLER]: exception on unpacking ChildAgentUpdate message {0}", ex.Message);
return;
}
//agent.Dump();
// This is one of the meanings of PUT agent
result = m_SimulationService.UpdateAgent(destination, agent);
}
responsedata["int_response_code"] = HttpStatusCode.OK;
responsedata["str_response_string"] = result.ToString();
//responsedata["str_response_string"] = OSDParser.SerializeJsonString(resp); ??? instead
}
示例13: UpdateAgent
// subclasses can override this
protected virtual bool UpdateAgent(GridRegion destination, AgentData agent)
{
return m_SimulationService.UpdateAgent(destination, agent);
}
示例14: CrossAgentSittingToNewRegionAsync
/// <summary>
/// This Closes child agents on neighboring regions
/// Calls an asynchronous method to do so.. so it doesn't lag the sim.
/// </summary>
protected ScenePresence CrossAgentSittingToNewRegionAsync(ScenePresence agent, GridRegion neighbourRegion, SceneObjectGroup grp)
{
Scene m_scene = agent.Scene;
if (agent.ValidateAttachments())
{
AgentData cAgent = new AgentData();
agent.CopyTo(cAgent);
cAgent.Position = grp.AbsolutePosition;
cAgent.CallbackURI = "http://" + m_scene.RegionInfo.ExternalHostName + ":" + m_scene.RegionInfo.HttpPort +
"/agent/" + agent.UUID.ToString() + "/" + m_scene.RegionInfo.RegionID.ToString() + "/release/";
if (!m_scene.SimulationService.UpdateAgent(neighbourRegion, cAgent))
{
// region doesn't take it
ResetFromTransit(agent.UUID);
return agent;
}
// Next, let's close the child agent connections that are too far away.
agent.CloseChildAgents((uint)neighbourRegion.RegionLocX / 256, (uint)neighbourRegion.RegionLocY / 256);
string agentcaps;
if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps))
{
m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: No ENTITY TRANSFER MODULE information for region handle {0}, exiting CrossToNewRegion.",
neighbourRegion.RegionHandle);
return agent;
}
// TODO Should construct this behind a method
string capsPath =
"http://" + neighbourRegion.ExternalHostName + ":" + neighbourRegion.HttpPort
+ "/CAPS/" + agentcaps /*circuitdata.CapsPath*/ + "0000/";
m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID);
IEventQueue eq = agent.Scene.RequestModuleInterface<IEventQueue>();
if (eq != null)
{
eq.CrossRegion(neighbourRegion.RegionHandle, agent.AbsolutePosition, agent.Velocity, neighbourRegion.ExternalEndPoint,
capsPath, agent.UUID, agent.ControllingClient.SessionId);
}
else
{
agent.ControllingClient.CrossRegion(neighbourRegion.RegionHandle, agent.AbsolutePosition, agent.Velocity, neighbourRegion.ExternalEndPoint,
capsPath);
}
agent.MakeChildAgent();
// now we have a child agent in this region. Request all interesting data about other (root) agents
agent.SendInitialFullUpdateToAllClients();
CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true);
}
return agent;
}
示例15: CrossAgentToNewRegionAsync
/// <summary>
/// This Closes child agents on neighboring regions
/// Calls an asynchronous method to do so.. so it doesn't lag the sim.
/// </summary>
protected ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying)
{
m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury);
Scene m_scene = agent.Scene;
ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize);
GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
if (neighbourRegion != null && agent.ValidateAttachments())
{
pos = pos + (agent.Velocity);
SetInTransit(agent.UUID);
AgentData cAgent = new AgentData();
agent.CopyTo(cAgent);
cAgent.Position = pos;
if (isFlying)
cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
cAgent.CallbackURI = "http://" + m_scene.RegionInfo.ExternalHostName + ":" + m_scene.RegionInfo.HttpPort +
"/agent/" + agent.UUID.ToString() + "/" + m_scene.RegionInfo.RegionID.ToString() + "/release/";
if (!m_scene.SimulationService.UpdateAgent(neighbourRegion, cAgent))
{
// region doesn't take it
ResetFromTransit(agent.UUID);
return agent;
}
agent.ControllingClient.RequestClientInfo();
string agentcaps;
if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps))
{
m_log.ErrorFormat("[ENTITY TRANSFER MODULE]: No ENTITY TRANSFER MODULE information for region handle {0}, exiting CrossToNewRegion.",
neighbourRegion.RegionHandle);
return agent;
}
// TODO Should construct this behind a method
string capsPath =
"http://" + neighbourRegion.ExternalHostName + ":" + neighbourRegion.HttpPort
+ "/CAPS/" + agentcaps /*circuitdata.CapsPath*/ + "0000/";
m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID);
IEventQueue eq = agent.Scene.RequestModuleInterface<IEventQueue>();
if (eq != null)
{
eq.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint,
capsPath, agent.UUID, agent.ControllingClient.SessionId);
}
else
{
agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint,
capsPath);
}
if (!WaitForCallback(agent.UUID))
{
m_log.Debug("[ENTITY TRANSFER MODULE]: Callback never came in crossing agent");
ResetFromTransit(agent.UUID);
// Yikes! We should just have a ref to scene here.
//agent.Scene.InformClientOfNeighbours(agent);
EnableChildAgents(agent);
return agent;
}
// Next, let's close the child agent connections that are too far away.
agent.CloseChildAgents(neighbourx, neighboury);
agent.MakeChildAgent();
// now we have a child agent in this region. Request all interesting data about other (root) agents
agent.SendInitialFullUpdateToAllClients();
CrossAttachmentsIntoNewRegion(neighbourRegion, agent, true);
}
//m_log.Debug("AFTER CROSS");
//Scene.DumpChildrenSeeds(UUID);
//DumpKnownRegions();
return agent;
}