本文整理汇总了C#中AgentData类的典型用法代码示例。如果您正苦于以下问题:C# AgentData类的具体用法?C# AgentData怎么用?C# AgentData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AgentData类属于命名空间,在下文中一共展示了AgentData类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateAgent
void CreateAgent(Coord coordinates, GameObject agent, float elevation)
{
var agentData = new AgentData() { coords = new int[] { coordinates.X, coordinates.Y }, prefId = _agentInfoIDs[agent.name] };
var go = Instantiate(agent, Grid.CoordToPosition(coordinates) + (1 + elevation) * Vector3.up, Quaternion.AngleAxis(45, Vector3.up)) as GameObject;
go.active = false;
foreach(var comp in go.GetComponents<Component>())
{
if(!comp is Renderer)
{
if (comp is MonoBehaviour)
{
(comp as MonoBehaviour).enabled = false;
}
}
}
foreach(var comp in go.GetComponentsInChildren<Component>())
{
if(!comp is Renderer)
{
if (comp is MonoBehaviour)
{
(comp as MonoBehaviour).enabled = false;
}
}
}
agentData.obj = go;
_agentObjects.Add(go);
_agents.Add(agentData);
go.active = true;
}
示例2: Deserialize
/// <summary>
/// Deserialize the message
/// </summary>
/// <param name="map">An <see cref="OSDMap"/> containing the data</param>
public void Deserialize(OSDMap map)
{
OSDArray agentDataArray = (OSDArray)map["AgentData"];
AgentDataBlock = new AgentData[agentDataArray.Count];
for (int i = 0; i < agentDataArray.Count; i++)
{
OSDMap agentMap = (OSDMap)agentDataArray[i];
AgentData agentData = new AgentData();
agentData.AgentID = agentMap["AgentID"].AsUUID();
agentData.GroupID = agentMap["GroupID"].AsUUID();
AgentDataBlock[i] = agentData;
}
}
示例3: ChildAgentDataUpdate
public void ChildAgentDataUpdate(AgentData cAgentData)
{
//MainConsole.Instance.Debug(" >>> ChildAgentDataUpdate <<< " + Scene.RegionInfo.RegionName);
//if (!IsChildAgent)
// return;
CopyFrom(cAgentData);
}
示例4: InformClientOfNeighbor
/// <summary>
/// Async component for informing client of which neighbors exist
/// </summary>
/// <remarks>
/// This needs to run asynchronously, as a network timeout may block the thread for a long while
/// </remarks>
/// <param name = "remoteClient"></param>
/// <param name = "a"></param>
/// <param name = "regionHandle"></param>
/// <param name = "endPoint"></param>
public virtual bool InformClientOfNeighbor(UUID AgentID, ulong requestingRegion, AgentCircuitData circuitData,
ref GridRegion neighbor,
uint TeleportFlags, AgentData agentData, out string reason,
out bool useCallbacks)
{
useCallbacks = true;
if (neighbor == null || neighbor.RegionHandle == 0)
{
reason = "Could not find neighbor to inform";
return false;
}
/*if ((neighbor.Flags & (int)Aurora.Framework.RegionFlags.RegionOnline) == 0 &&
(neighbor.Flags & (int)(Aurora.Framework.RegionFlags.Foreign | Aurora.Framework.RegionFlags.Hyperlink)) == 0)
{
reason = "The region you are attempting to teleport to is offline";
return false;
}*/
MainConsole.Instance.Info("[AgentProcessing]: Starting to inform client about neighbor " + neighbor.RegionName);
//Notes on this method
// 1) the SimulationService.CreateAgent MUST have a fixed CapsUrl for the region, so we have to create (if needed)
// a new Caps handler for it.
// 2) Then we can call the methods (EnableSimulator and EstatablishAgentComm) to tell the client the new Urls
// 3) This allows us to make the Caps on the grid server without telling any other regions about what the
// Urls are.
ISimulationService SimulationService = m_registry.RequestModuleInterface<ISimulationService>();
if (SimulationService != null)
{
ICapsService capsService = m_registry.RequestModuleInterface<ICapsService>();
IClientCapsService clientCaps = capsService.GetClientCapsService(AgentID);
IRegionClientCapsService oldRegionService = clientCaps.GetCapsService(neighbor.RegionHandle);
//If its disabled, it should be removed, so kill it!
if (oldRegionService != null && oldRegionService.Disabled)
{
clientCaps.RemoveCAPS(neighbor.RegionHandle);
oldRegionService = null;
}
bool newAgent = oldRegionService == null;
IRegionClientCapsService otherRegionService = clientCaps.GetOrCreateCapsService(neighbor.RegionHandle,
CapsUtil.GetCapsSeedPath
(CapsUtil.
GetRandomCapsObjectPath
()),
circuitData, 0);
if (!newAgent)
{
//Note: if the agent is already there, send an agent update then
bool result = true;
if (agentData != null)
{
agentData.IsCrossing = false;
result = SimulationService.UpdateAgent(neighbor, agentData);
}
if (result)
oldRegionService.Disabled = false;
reason = "";
return result;
}
ICommunicationService commsService = m_registry.RequestModuleInterface<ICommunicationService>();
if (commsService != null)
commsService.GetUrlsForUser(neighbor, circuitData.AgentID);
//Make sure that we make userURLs if we need to
circuitData.CapsPath = CapsUtil.GetCapsPathFromCapsSeed(otherRegionService.CapsUrl); //For OpenSim
circuitData.firstname = clientCaps.AccountInfo.FirstName;
circuitData.lastname = clientCaps.AccountInfo.LastName;
int requestedPort = 0;
if (circuitData.child)
circuitData.reallyischild = true;
bool regionAccepted = CreateAgent(neighbor, otherRegionService, ref circuitData, SimulationService, ref requestedPort, out reason);
if (regionAccepted)
{
IPAddress ipAddress = neighbor.ExternalEndPoint.Address;
string otherRegionsCapsURL;
//If the region accepted us, we should get a CAPS url back as the reason, if not, its not updated or not an Aurora region, so don't touch it.
if (reason != "" && reason != "authorized")
{
OSDMap responseMap = (OSDMap) OSDParser.DeserializeJson(reason);
OSDMap SimSeedCaps = (OSDMap) responseMap["CapsUrls"];
if (responseMap.ContainsKey("OurIPForClient"))
{
string ip = responseMap["OurIPForClient"].AsString();
if (!IPAddress.TryParse(ip, out ipAddress))
//.........这里部分代码省略.........
示例5: spawnAgent
private void spawnAgent()
{
Vector3 spawnPos = GameObject.FindGameObjectWithTag("Spawn").transform.position;
Quaternion rotate = GameObject.FindGameObjectWithTag("Spawn").transform.rotation;
GameObject npc = Instantiate(SpawnList[0], spawnPos, rotate) as GameObject;
AgentData tempData = new AgentData();
Debug.Log ("ID from npc : " + npc.GetInstanceID());
tempData.setID(npc.GetInstanceID());
Debug.Log ("ID from data : " + tempData.getID());
tempData.setOtherAgents(findOtherAgents());
Debug.Log ("OtherAgents : " + tempData.getOtherAgents());
Debug.Log ("Name from npc : " + npc.name);
tempData.setInitial(npc.name);
Debug.Log ("Name from data : " + tempData.getInitial());
npc.GetComponent<Sentry>().setAgentData(tempData);
Debug.Log (npc.GetComponent<Sentry>().getAgentData().getInitial());
History.Add(tempData);
//if (History[agentAttempts] == null) Debug.Log (agentAttempts + " was null");
//Debug.Log ("History ID : " + History[agentAttempts].getInitial());
//Debug.Log ("History: " + History.Count());
agentAttempts++;
SpawnList.RemoveAt(0);
Debug.Log ("After SpawnList Remove");
setWaypointsForNPCs();
}
示例6: InformClientOfNeighbor
public override bool InformClientOfNeighbor(UUID AgentID, ulong requestingRegion, AgentCircuitData circuitData, ref GridRegion neighbor, uint TeleportFlags, AgentData agentData, out string reason, out bool useCallbacks)
{
useCallbacks = true;
if (neighbor == null)
{
reason = "Could not find neighbor to inform";
return false;
}
MainConsole.Instance.Info ("[AgentProcessing]: Starting to inform client about neighbor " + neighbor.RegionName);
//Notes on this method
// 1) the SimulationService.CreateAgent MUST have a fixed CapsUrl for the region, so we have to create (if needed)
// a new Caps handler for it.
// 2) Then we can call the methods (EnableSimulator and EstatablishAgentComm) to tell the client the new Urls
// 3) This allows us to make the Caps on the grid server without telling any other regions about what the
// Urls are.
ISimulationService SimulationService = m_registry.RequestModuleInterface<ISimulationService> ();
if (SimulationService != null)
{
ICapsService capsService = m_registry.RequestModuleInterface<ICapsService> ();
IClientCapsService clientCaps = capsService.GetClientCapsService (AgentID);
GridRegion originalDest = neighbor;
if ((neighbor.Flags & (int)Aurora.Framework.RegionFlags.Hyperlink) == (int)Aurora.Framework.RegionFlags.Hyperlink)
{
neighbor = GetFinalDestination (neighbor);
if (neighbor == null || neighbor.RegionHandle == 0)
{
reason = "Could not find neighbor to inform";
return false;
}
//Remove any offenders
clientCaps.RemoveCAPS (originalDest.RegionHandle);
clientCaps.RemoveCAPS (neighbor.RegionHandle);
}
IRegionClientCapsService oldRegionService = clientCaps.GetCapsService (neighbor.RegionHandle);
//If its disabled, it should be removed, so kill it!
if (oldRegionService != null && oldRegionService.Disabled)
{
clientCaps.RemoveCAPS (neighbor.RegionHandle);
oldRegionService = null;
}
bool newAgent = oldRegionService == null;
IRegionClientCapsService otherRegionService = clientCaps.GetOrCreateCapsService (neighbor.RegionHandle,
CapsUtil.GetCapsSeedPath (CapsUtil.GetRandomCapsObjectPath ()), circuitData, 0);
if (!newAgent)
{
//Note: if the agent is already there, send an agent update then
bool result = true;
if (agentData != null)
{
agentData.IsCrossing = false;
result = SimulationService.UpdateAgent (neighbor, agentData);
}
if (result)
oldRegionService.Disabled = false;
reason = "";
return result;
}
ICommunicationService commsService = m_registry.RequestModuleInterface<ICommunicationService> ();
if (commsService != null)
commsService.GetUrlsForUser (neighbor, circuitData.AgentID);//Make sure that we make userURLs if we need to
circuitData.CapsPath = CapsUtil.GetCapsPathFromCapsSeed (otherRegionService.CapsUrl);
if (clientCaps.AccountInfo != null)
{
circuitData.firstname = clientCaps.AccountInfo.FirstName;
circuitData.lastname = clientCaps.AccountInfo.LastName;
}
bool regionAccepted = false;
int requestedUDPPort = 0;
if ((originalDest.Flags & (int)Aurora.Framework.RegionFlags.Hyperlink) == (int)Aurora.Framework.RegionFlags.Hyperlink)
{
if (circuitData.ServiceURLs == null || circuitData.ServiceURLs.Count == 0)
{
if (clientCaps.AccountInfo != null)
{
circuitData.ServiceURLs = new Dictionary<string, object> ();
circuitData.ServiceURLs[GetHandlers.Helpers_HomeURI] = GetHandlers.GATEKEEPER_URL;
circuitData.ServiceURLs[GetHandlers.Helpers_GatekeeperURI] = GetHandlers.GATEKEEPER_URL;
circuitData.ServiceURLs[GetHandlers.Helpers_InventoryServerURI] = GetHandlers.GATEKEEPER_URL;
circuitData.ServiceURLs[GetHandlers.Helpers_AssetServerURI] = GetHandlers.GATEKEEPER_URL;
circuitData.ServiceURLs[GetHandlers.Helpers_ProfileServerURI] = GetHandlers.GATEKEEPER_URL;
circuitData.ServiceURLs[GetHandlers.Helpers_FriendsServerURI] = GetHandlers.GATEKEEPER_URL;
circuitData.ServiceURLs[GetHandlers.Helpers_IMServerURI] = GetHandlers.IM_URL;
clientCaps.AccountInfo.ServiceURLs = circuitData.ServiceURLs;
//Store the new urls
m_registry.RequestModuleInterface<IUserAccountService> ().StoreUserAccount (clientCaps.AccountInfo);
}
}
string userAgentDriver = circuitData.ServiceURLs[GetHandlers.Helpers_HomeURI].ToString ();
IUserAgentService connector = new UserAgentServiceConnector (userAgentDriver);
regionAccepted = connector.LoginAgentToGrid (circuitData, originalDest, neighbor, out reason);
}
//.........这里部分代码省略.........
示例7: CrossAgent
public virtual bool CrossAgent(GridRegion crossingRegion, Vector3 pos,
Vector3 velocity, AgentCircuitData circuit, AgentData cAgent, UUID AgentID,
ulong requestingRegion, out string reason)
{
try
{
IClientCapsService clientCaps =
m_registry.RequestModuleInterface<ICapsService>().GetClientCapsService(AgentID);
IRegionClientCapsService requestingRegionCaps = clientCaps.GetCapsService(requestingRegion);
ISimulationService SimulationService = m_registry.RequestModuleInterface<ISimulationService>();
if (SimulationService != null)
{
//Note: we have to pull the new grid region info as the one from the region cannot be trusted
IGridService GridService = m_registry.RequestModuleInterface<IGridService>();
if (GridService != null)
{
//Set the user in transit so that we block duplicate tps and reset any cancelations
if (!SetUserInTransit(AgentID))
{
reason = "Already in a teleport";
return false;
}
bool result = false;
//We need to get it from the grid service again so that we can get the simulation service urls correctly
// as regions don't get that info
crossingRegion = GridService.GetRegionByUUID(clientCaps.AccountInfo.AllScopeIDs, crossingRegion.RegionID);
cAgent.IsCrossing = true;
if (!SimulationService.UpdateAgent(crossingRegion, cAgent))
{
MainConsole.Instance.Warn("[AgentProcessing]: Failed to cross agent " + AgentID +
" because region did not accept it. Resetting.");
reason = "Failed to update an agent";
}
else
{
IEventQueueService EQService = m_registry.RequestModuleInterface<IEventQueueService>();
//Add this for the viewer, but not for the sim, seems to make the viewer happier
int XOffset = crossingRegion.RegionLocX - requestingRegionCaps.RegionX;
pos.X += XOffset;
int YOffset = crossingRegion.RegionLocY - requestingRegionCaps.RegionY;
pos.Y += YOffset;
IRegionClientCapsService otherRegion = clientCaps.GetCapsService(crossingRegion.RegionHandle);
//Tell the client about the transfer
EQService.CrossRegion(crossingRegion.RegionHandle, pos, velocity,
otherRegion.LoopbackRegionIP,
otherRegion.CircuitData.RegionUDPPort,
otherRegion.CapsUrl,
AgentID,
circuit.SessionID,
crossingRegion.RegionSizeX,
crossingRegion.RegionSizeY,
requestingRegion);
result = WaitForCallback(AgentID);
if (!result)
{
MainConsole.Instance.Warn("[AgentProcessing]: Callback never came in crossing agent " + circuit.AgentID +
". Resetting.");
reason = "Crossing timed out";
}
else
{
// Next, let's close the child agent connections that are too far away.
//Fix the root agent status
otherRegion.RootAgent = true;
requestingRegionCaps.RootAgent = false;
CloseNeighborAgents(requestingRegionCaps.Region, crossingRegion, AgentID);
reason = "";
}
}
//All done
ResetFromTransit(AgentID);
return result;
}
else
reason = "Could not find the GridService";
}
else
reason = "Could not find the SimulationService";
}
catch (Exception ex)
{
MainConsole.Instance.WarnFormat("[AgentProcessing]: Failed to cross an agent into a new region. {0}", ex);
}
ResetFromTransit(AgentID);
reason = "Exception occured";
return false;
}
示例8: IncomingChildAgentDataUpdate
/// <summary>
/// We've got an update about an agent that sees into this region,
/// send it to ScenePresence for processing It's the full data.
/// </summary>
/// <param name="scene"></param>
/// <param name="cAgentData">Agent that contains all of the relevant things about an agent.
/// Appearance, animations, position, etc.</param>
/// <returns>true if we handled it.</returns>
public virtual bool IncomingChildAgentDataUpdate (IScene scene, AgentData cAgentData)
{
MainConsole.Instance.DebugFormat(
"[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, scene.RegionInfo.RegionName);
//No null updates!
if (cAgentData == null)
return false;
// We have to wait until the viewer contacts this region after receiving EAC.
// That calls AddNewClient, which finally creates the ScenePresence and then this gets set up
// So if the client isn't here yet, save the update for them when they get into the region fully
IScenePresence SP = scene.GetScenePresence (cAgentData.AgentID);
if (SP != null)
SP.ChildAgentDataUpdate (cAgentData);
else
lock (m_incomingChildAgentData)
{
if (!m_incomingChildAgentData.ContainsKey (scene))
m_incomingChildAgentData.Add (scene, new Dictionary<UUID, AgentData> ());
m_incomingChildAgentData[scene][cAgentData.AgentID] = cAgentData;
return false;//The agent doesn't exist
}
return true;
}
示例9: DoTeleport
public virtual void DoTeleport(IScenePresence sp, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags)
{
sp.ControllingClient.SendTeleportProgress(teleportFlags, "sending_dest");
if (finalDestination == null)
{
sp.ControllingClient.SendTeleportFailed("Unable to locate destination");
return;
}
MainConsole.Instance.DebugFormat(
"[ENTITY TRANSFER MODULE]: Request Teleport to {0}:{1}/{2}",
finalDestination.ServerURI, finalDestination.RegionName, position);
sp.ControllingClient.SendTeleportProgress(teleportFlags, "arriving");
sp.SetAgentLeaving(finalDestination);
// Fixing a bug where teleporting while sitting results in the avatar ending up removed from
// both regions
if (sp.ParentID != UUID.Zero)
sp.StandUp();
AgentCircuitData agentCircuit = BuildCircuitDataForPresence(sp, position);
AgentData agent = new AgentData();
sp.CopyTo(agent);
//Fix the position
agent.Position = position;
IEventQueueService eq = sp.Scene.RequestModuleInterface<IEventQueueService>();
if (eq != null)
{
ISyncMessagePosterService syncPoster = sp.Scene.RequestModuleInterface<ISyncMessagePosterService>();
if (syncPoster != null)
{
//This does CreateAgent and sends the EnableSimulator/EstablishAgentCommunication/TeleportFinish
// messages if they need to be called and deals with the callback
syncPoster.Get(SyncMessageHelper.TeleportAgent((int)sp.DrawDistance,
agentCircuit, agent, teleportFlags, finalDestination, sp.Scene.RegionInfo.RegionHandle),
sp.UUID, sp.Scene.RegionInfo.RegionHandle, (map) =>
{
if (map == null || !map["success"].AsBoolean())
{
// Fix the agent status
sp.IsChildAgent = false;
//Tell modules about it
sp.AgentFailedToLeave();
sp.ControllingClient.SendTeleportFailed(map != null
? map["Reason"].AsString()
: "Teleport Failed");
return;
}
//Get the new destintation, it may have changed
if (map.ContainsKey("Destination"))
{
finalDestination = new GridRegion();
finalDestination.FromOSD((OSDMap)map["Destination"]);
}
MakeChildAgent(sp, finalDestination, false);
});
}
}
}
示例10: CreateAgent
public virtual bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags,
AgentData data, out int requestedUDPPort, out string reason)
{
reason = String.Empty;
// Try local first
if (m_localBackend.CreateAgent(destination, aCircuit, teleportFlags, data, out requestedUDPPort,
out reason))
return true;
requestedUDPPort = destination.ExternalEndPoint.Port; //Just make sure..
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();
string resultStr = WebUtils.PostToService(uri, args);
//Pull out the result and set it as the reason
if (resultStr == "")
return false;
OSDMap result = OSDParser.DeserializeJson(resultStr) as OSDMap;
reason = result["reason"] != null ? result["reason"].AsString() : "";
if (result["success"].AsBoolean())
{
//Not right... don't return true except for opensim combatibility :/
if (reason == "" || reason == "authorized")
return true;
//We were able to contact the region
try
{
//We send the CapsURLs through, so we need these
OSDMap responseMap = (OSDMap) OSDParser.DeserializeJson(reason);
if (responseMap.ContainsKey("Reason"))
reason = responseMap["Reason"].AsString();
if (responseMap.ContainsKey("requestedUDPPort"))
requestedUDPPort = responseMap["requestedUDPPort"];
return result["success"].AsBoolean();
}
catch
{
//Something went wrong
return false;
}
}
reason = result.ContainsKey("Message") ? result["Message"].AsString() : "Could not contact the region";
return false;
}
catch (Exception e)
{
MainConsole.Instance.Warn("[REMOTE SIMULATION CONNECTOR]: CreateAgent failed with exception: " + e);
reason = e.Message;
}
return false;
}
示例11: GeneratePlatformData
public PlatformData GeneratePlatformData(AgentData agentData)
{
var platformData = new PlatformData(agentData);
ComponentData[] pendingComponentData = QueryHistory.Select(qh => ComponentDataRetriever.GetData(qh.Value.ToArray()))
.Where(c => c != null).ToArray();
pendingComponentData.ForEach(platformData.AddComponent);
return platformData;
}
示例12: UpdateAgent
public bool UpdateAgent(GridRegion destination, AgentData data)
{
return UpdateAgent(destination, (IAgentData) data);
}
示例13: RetrieveAgent
public bool RetrieveAgent(GridRegion destination, UUID id, bool agentIsLeaving, out AgentData agent,
out AgentCircuitData circuitData)
{
agent = null;
// Try local first
if (m_localBackend.RetrieveAgent(destination, id, agentIsLeaving, out agent, out circuitData))
return true;
// else do the remote thing
if (!m_localBackend.IsLocalRegion(destination.RegionHandle))
{
// Eventually, we want to use a caps url instead of the agentID
string uri = MakeUri(destination, true) + id + "/" + destination.RegionID.ToString() + "/" +
agentIsLeaving.ToString() + "/";
try
{
string resultStr = WebUtils.GetFromService(uri);
if (resultStr != "")
{
OSDMap result = OSDParser.DeserializeJson(resultStr) as OSDMap;
if (result["Result"] == "Not Found")
return false;
agent = new AgentData();
if (!result.ContainsKey("AgentData"))
return false; //Disable old simulators
agent.Unpack((OSDMap)result["AgentData"]);
circuitData = new AgentCircuitData();
circuitData.UnpackAgentCircuitData((OSDMap)result["CircuitData"]);
return true;
}
}
catch (Exception e)
{
MainConsole.Instance.Warn("[REMOTE SIMULATION CONNECTOR]: UpdateAgent failed with exception: " + e);
}
return false;
}
return false;
}
示例14: PopulationData
public PopulationData(ArrayList tested, ArrayList untested)
{
testedPools = new ArrayList();
untestedPools = new ArrayList();
foreach (ArrayList gen in tested)
{
ArrayList newGen = new ArrayList();
foreach(Agent agent in gen)
{
AgentData newAgent = new AgentData(agent);
newGen.Add(newAgent);
}
testedPools.Add(newGen);
}
foreach (ArrayList gen in untested)
{
ArrayList newGen = new ArrayList();
foreach (Agent agent in gen)
{
AgentData newAgent = new AgentData(agent);
newGen.Add(newAgent);
}
untestedPools.Add(newGen);
}
}
示例15: RestartStatsAndState
protected abstract void RestartStatsAndState(float percentage, AgentData data);