本文整理汇总了C#中Universe.Framework.Services.GridRegion类的典型用法代码示例。如果您正苦于以下问题:C# GridRegion类的具体用法?C# GridRegion怎么用?C# GridRegion使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
GridRegion类属于Universe.Framework.Services命名空间,在下文中一共展示了GridRegion类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateAgent
public bool CreateAgent (GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out CreateAgentResponse response)
{
response = null;
if (destination == null) {
response = new CreateAgentResponse ();
response.Reason = "Could not connect to destination";
response.Success = false;
return false;
}
CreateAgentRequest request = new CreateAgentRequest ();
request.CircuitData = aCircuit;
request.Destination = destination;
request.TeleportFlags = teleportFlags;
AutoResetEvent resetEvent = new AutoResetEvent (false);
OSDMap result = null;
MainConsole.Instance.DebugFormat ("[SimulationServiceConnector]: Sending Create Agent to " + destination.ServerURI);
m_syncMessagePoster.Get (destination.ServerURI, request.ToOSD (), osdresp => {
result = osdresp;
resetEvent.Set ();
});
bool success = resetEvent.WaitOne (10000);
if (!success || result == null) {
response = new CreateAgentResponse ();
response.Reason = "Could not connect to destination";
response.Success = false;
return false;
}
response = new CreateAgentResponse ();
response.FromOSD (result);
return response.Success;
}
示例2: CreateAgent
/// <summary>
/// Agent-related communications
/// </summary>
public bool CreateAgent(GridRegion destination, AgentCircuitData aCircuit, uint teleportFlags, out CreateAgentResponse response)
{
response = new CreateAgentResponse();
IScene Scene = destination == null ? null : GetScene(destination.RegionID);
if (destination == null || Scene == null)
{
response.Reason = "Given destination was null";
response.Success = false;
return false;
}
if (Scene.RegionInfo.RegionID != destination.RegionID)
{
response.Reason = "Did not find region " + destination.RegionName;;
response.Success = false;
return false;
}
IEntityTransferModule transferModule = Scene.RequestModuleInterface<IEntityTransferModule>();
if (transferModule != null)
return transferModule.NewUserConnection(Scene, aCircuit, teleportFlags, out response);
response.Reason = "Did not find region " + destination.RegionName;
response.Success = false;
return false;
}
示例3: CloseNeighborAgents
public virtual void CloseNeighborAgents(GridRegion oldRegion, GridRegion destination, UUID agentID)
{
CloseNeighborCall++;
int CloseNeighborCallNum = CloseNeighborCall;
Util.FireAndForget(delegate
{
//Sleep for 10 seconds to give the agents a chance to cross and get everything right
Thread.Sleep(10000);
if (CloseNeighborCall != CloseNeighborCallNum)
return; //Another was enqueued, kill this one
//Now do a sanity check on the avatar
IClientCapsService clientCaps = m_capsService.GetClientCapsService(agentID);
if (clientCaps == null)
return;
IRegionClientCapsService rootRegionCaps = clientCaps.GetRootCapsService();
if (rootRegionCaps == null)
return;
IRegionClientCapsService ourRegionCaps = clientCaps.GetCapsService(destination.RegionID);
if (ourRegionCaps == null)
return;
//If they handles aren't the same, the agent moved, and we can't be sure that we should close these agents
if (rootRegionCaps.RegionHandle != ourRegionCaps.RegionHandle && !clientCaps.InTeleport)
return;
IGridService service = m_registry.RequestModuleInterface<IGridService>();
if (service != null)
{
List<GridRegion> NeighborsOfOldRegion =
service.GetNeighbors(clientCaps.AccountInfo.AllScopeIDs, oldRegion);
List<GridRegion> NeighborsOfDestinationRegion =
service.GetNeighbors(clientCaps.AccountInfo.AllScopeIDs, destination);
List<GridRegion> byebyeRegions = new List<GridRegion>(NeighborsOfOldRegion)
{oldRegion};
//Add the old region, because it might need closed too
byebyeRegions.RemoveAll(delegate (GridRegion r)
{
if (r.RegionID == destination.RegionID)
return true;
if (NeighborsOfDestinationRegion.Contains(r))
return true;
return false;
});
if (byebyeRegions.Count > 0)
{
MainConsole.Instance.Info("[Agent Processing]: Closing " + byebyeRegions.Count +
" child agents around " + oldRegion.RegionName);
SendCloseChildAgent(agentID, byebyeRegions);
}
}
});
}
示例4: CloseAgent
public bool CloseAgent(GridRegion destination, UUID agentID)
{
CloseAgentRequest request = new CloseAgentRequest();
request.AgentID = agentID;
request.Destination = destination;
m_syncMessagePoster.Post(destination.ServerURI, request.ToOSD());
return true;
}
示例5: CloseAgent
public bool CloseAgent(GridRegion destination, UUID agentID)
{
IScene Scene = destination == null ? null : GetScene(destination.RegionID);
if (Scene == null || destination == null)
return false;
IEntityTransferModule transferModule = Scene.RequestModuleInterface<IEntityTransferModule>();
if (transferModule != null)
return transferModule.IncomingCloseAgent(Scene, agentID);
return false;
}
示例6: IsAuthorizedForRegion
public bool IsAuthorizedForRegion(GridRegion region, AgentCircuitData agent, bool isRootAgent, out string reason)
{
ISceneManager manager = m_registry.RequestModuleInterface<ISceneManager>();
IScene scene = manager == null ? null : manager.Scenes.Find((s) => s.RegionInfo.RegionID == region.RegionID);
if (scene != null)
{
//Found the region, check permissions
return scene.Permissions.AllowedIncomingAgent(agent, isRootAgent, out reason);
}
reason = "Not Authorized as region does not exist.";
return false;
}
示例7: IncomingCapsRequest
public void IncomingCapsRequest (UUID agentID, GridRegion region, ISimulationBase simbase, ref OSDMap capURLs)
{
m_syncMessage = simbase.ApplicationRegistry.RequestModuleInterface<ISyncMessagePosterService> ();
m_appearanceService = simbase.ApplicationRegistry.RequestModuleInterface<IAgentAppearanceService> ();
m_region = region;
m_agentID = agentID;
if (m_appearanceService == null)
return;//Can't bake!
m_uri = "/CAPS/UpdateAvatarAppearance/" + UUID.Random () + "/";
MainServer.Instance.AddStreamHandler (new GenericStreamHandler ("POST", m_uri, UpdateAvatarAppearance));
capURLs ["UpdateAvatarAppearance"] = MainServer.Instance.ServerURI + m_uri;
}
示例8: IncomingCapsRequest
public void IncomingCapsRequest (UUID agentID, GridRegion region, ISimulationBase simbase, ref OSDMap capURLs)
{
m_agentID = agentID;
m_region = region;
m_userScopeIDs = simbase.ApplicationRegistry.RequestModuleInterface<IUserAccountService> ().GetUserAccount (null, m_agentID).AllScopeIDs;
m_gridService = simbase.ApplicationRegistry.RequestModuleInterface<IGridService> ();
IConfig config = simbase.ConfigSource.Configs ["MapCAPS"];
if (config != null)
m_allowCapsMessage = config.GetBoolean ("AllowCapsMessage", m_allowCapsMessage);
HttpServerHandle method = (path, request, httpRequest, httpResponse) => MapLayerRequest (HttpServerHandlerHelpers.ReadString (request), httpRequest, httpResponse);
m_uri = "/CAPS/MapLayer/" + UUID.Random () + "/";
capURLs ["MapLayer"] = MainServer.Instance.ServerURI + m_uri;
capURLs ["MapLayerGod"] = MainServer.Instance.ServerURI + m_uri;
MainServer.Instance.AddStreamHandler (new GenericStreamHandler ("POST", m_uri, method));
}
示例9: Close
public void Close(IScene scene)
{
//Deregister the interface
scene.UnregisterModuleInterface<IGridRegisterModule>(this);
m_scene = null;
MainConsole.Instance.InfoFormat("[RegisterRegionWithGrid]: Deregistering region {0} from the grid...",
scene.RegionInfo.RegionName);
//Deregister from the grid server
GridRegion r = new GridRegion(scene.RegionInfo);
r.IsOnline = false;
string error = "";
if (scene.RegionInfo.HasBeenDeleted || !m_markRegionsAsOffline)
scene.GridService.DeregisterRegion(r);
else if ((error = scene.GridService.UpdateMap(r, false)) != "")
MainConsole.Instance.WarnFormat(
"[RegisterRegionWithGrid]: Deregister from grid failed for region {0}, {1}",
scene.RegionInfo.RegionName, error);
}
示例10: GetExternalCaps
public OSDMap GetExternalCaps(UUID agentID, GridRegion region)
{
if (m_registry == null) return new OSDMap();
OSDMap resp = new OSDMap();
if (m_registry.RequestModuleInterface<IGridServerInfoService>() != null)
{
m_servers = m_registry.RequestModuleInterface<IGridServerInfoService>().GetGridURIs("SyncMessageServerURI");
OSDMap req = new OSDMap();
req["AgentID"] = agentID;
req["Region"] = region.ToOSD();
req["Method"] = "GetCaps";
List<ManualResetEvent> events = new List<ManualResetEvent>();
foreach (string uri in m_servers.Where((u)=>(!u.Contains(MainServer.Instance.Port.ToString()))))
{
ManualResetEvent even = new ManualResetEvent(false);
m_syncPoster.Get(uri, req, (r) =>
{
if (r == null)
return;
foreach (KeyValuePair<string, OSD> kvp in r)
resp.Add(kvp.Key, kvp.Value);
even.Set();
});
events.Add(even);
}
if(events.Count > 0)
ManualResetEvent.WaitAll(events.ToArray());
}
foreach (var h in GetHandlers(agentID, region.RegionID))
{
if (m_allowedCapsModules.Contains(h.Name))
h.IncomingCapsRequest(agentID, region, m_registry.RequestModuleInterface<ISimulationBase>(), ref resp);
}
return resp;
}
示例11: CrossGroupToNewRegion
/// <summary>
/// Move the given scene object into a new region depending on which region its absolute position has moved
/// into.
/// This method locates the new region handle and offsets the prim position for the new region
/// </summary>
/// <param name="attemptedPosition">the attempted out of region position of the scene object</param>
/// <param name="grp">the scene object that we're crossing</param>
/// <param name="destination"></param>
public bool CrossGroupToNewRegion (ISceneEntity grp, Vector3 attemptedPosition, GridRegion destination)
{
if (grp == null)
return false;
if (grp.IsDeleted)
return false;
if (grp.Scene == null)
return false;
if (grp.RootChild.DIE_AT_EDGE) {
// We remove the object here
try {
IBackupModule backup = grp.Scene.RequestModuleInterface<IBackupModule> ();
if (backup != null)
return backup.DeleteSceneObjects (new [] { grp }, true, true);
} catch (Exception) {
MainConsole.Instance.Warn (
"[Database]: exception when trying to remove the prim that crossed the border.");
}
return false;
}
if (grp.RootChild.RETURN_AT_EDGE) {
// We remove the object here
try {
List<ISceneEntity> objects = new List<ISceneEntity> { grp };
ILLClientInventory inventoryModule = grp.Scene.RequestModuleInterface<ILLClientInventory> ();
if (inventoryModule != null)
return inventoryModule.ReturnObjects (objects.ToArray (), UUID.Zero);
} catch (Exception) {
MainConsole.Instance.Warn (
"[Scene]: exception when trying to return the prim that crossed the border.");
}
return false;
}
Vector3 oldGroupPosition = grp.RootChild.GroupPosition;
// If we fail to cross the border, then reset the position of the scene object on that border.
if (destination != null && !CrossPrimGroupIntoNewRegion (destination, grp, attemptedPosition)) {
grp.OffsetForNewRegion (oldGroupPosition);
grp.ScheduleGroupUpdate (PrimUpdateFlags.ForcedFullUpdate);
return false;
}
return true;
}
示例12: Cross
public virtual void Cross (IScenePresence agent, bool isFlying, GridRegion crossingRegion)
{
Vector3 pos = new Vector3 (agent.AbsolutePosition.X, agent.AbsolutePosition.Y, agent.AbsolutePosition.Z);
pos.X = (agent.Scene.RegionInfo.RegionLocX + pos.X) - crossingRegion.RegionLocX;
pos.Y = (agent.Scene.RegionInfo.RegionLocY + pos.Y) - crossingRegion.RegionLocY;
//Make sure that they are within bounds (velocity can push it out of bounds)
if (pos.X < 0)
pos.X = 1;
if (pos.Y < 0)
pos.Y = 1;
if (pos.X > crossingRegion.RegionSizeX)
pos.X = crossingRegion.RegionSizeX - 1;
if (pos.Y > crossingRegion.RegionSizeY)
pos.Y = crossingRegion.RegionSizeY - 1;
InternalCross (agent, pos, isFlying, crossingRegion);
}
示例13: InternalCross
public virtual void InternalCross (IScenePresence agent, Vector3 attemptedPos, bool isFlying,
GridRegion crossingRegion)
{
MainConsole.Instance.DebugFormat ("[Entity transfer]: Crossing agent {0} to region {1}",
agent.Name, crossingRegion.RegionName);
try {
agent.SetAgentLeaving (crossingRegion);
AgentData cAgent = new AgentData ();
agent.CopyTo (cAgent);
cAgent.Position = attemptedPos;
if (isFlying)
cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
AgentCircuitData agentCircuit = BuildCircuitDataForPresence (agent, attemptedPos);
agentCircuit.TeleportFlags = (uint)TeleportFlags.ViaRegionID;
//This does UpdateAgent and closing of child agents
// messages if they need to be called
ISyncMessagePosterService syncPoster =
agent.Scene.RequestModuleInterface<ISyncMessagePosterService> ();
if (syncPoster != null) {
syncPoster.PostToServer (SyncMessageHelper.CrossAgent (crossingRegion, attemptedPos,
agent.Velocity, agentCircuit, cAgent,
agent.Scene.RegionInfo.RegionID));
}
} catch (Exception ex) {
MainConsole.Instance.Warn ("[Entity transfer]: Exception in crossing: " + ex);
}
}
示例14: MakeChildAgent
public void MakeChildAgent (IScenePresence sp, GridRegion finalDestination, bool isCrossing)
{
if (sp == null)
return;
sp.SetAgentLeaving (finalDestination);
//Kill the groups here, otherwise they will become ghost attachments
// and stay in the sim, they'll get re-added below into the new sim
//KillAttachments(sp);
// Well, this is it. The agent is over there.
KillEntity (sp.Scene, sp);
//Make it a child agent for now... the grid will kill us later if we need to close
sp.MakeChildAgent (finalDestination);
if (isCrossing)
sp.SuccessfulCrossingTransit (finalDestination);
}
示例15: RequestTeleportLocation
/// <summary>
/// Tries to teleport agent to other region.
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="reg"></param>
/// <param name="position"></param>
/// <param name="lookAt"></param>
/// <param name="teleportFlags"></param>
public void RequestTeleportLocation (IClientAPI remoteClient, GridRegion reg, Vector3 position,
Vector3 lookAt, uint teleportFlags)
{
IScenePresence sp = remoteClient.Scene.GetScenePresence (remoteClient.AgentId);
if (sp != null) {
Teleport (sp, reg, position, lookAt, teleportFlags);
}
}