本文整理汇总了C#中OpenSim.Region.Framework.Scenes.ScenePresence.StandUp方法的典型用法代码示例。如果您正苦于以下问题:C# ScenePresence.StandUp方法的具体用法?C# ScenePresence.StandUp怎么用?C# ScenePresence.StandUp使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类OpenSim.Region.Framework.Scenes.ScenePresence
的用法示例。
在下文中一共展示了ScenePresence.StandUp方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoTeleport
public void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags, IEventQueue eq)
{
if (reg == null || finalDestination == null)
{
sp.ControllingClient.SendTeleportFailed("Unable to locate destination");
return;
}
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: Request Teleport to {0} ({1}) {2}/{3}",
reg.ServerURI, finalDestination.ServerURI, finalDestination.RegionName, position);
uint newRegionX = (uint)(reg.RegionHandle >> 40);
uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
uint oldRegionX = (uint)(sp.Scene.RegionInfo.RegionHandle >> 40);
uint oldRegionY = (((uint)(sp.Scene.RegionInfo.RegionHandle)) >> 8);
ulong destinationHandle = finalDestination.RegionHandle;
// Let's do DNS resolution only once in this process, please!
// This may be a costly operation. The reg.ExternalEndPoint field is not a passive field,
// it's actually doing a lot of work.
IPEndPoint endPoint = finalDestination.ExternalEndPoint;
if (endPoint.Address != null)
{
// Fixing a bug where teleporting while sitting results in the avatar ending up removed from
// both regions
if (sp.ParentID != (uint)0)
sp.StandUp();
if (!sp.ValidateAttachments())
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: Failed validation of all attachments for teleport of {0} from {1} to {2}. Continuing.",
sp.Name, sp.Scene.RegionInfo.RegionName, finalDestination.RegionName);
// if (!sp.ValidateAttachments())
// {
// sp.ControllingClient.SendTeleportFailed("Inconsistent attachment state");
// return;
// }
string reason;
string version;
if (!m_aScene.SimulationService.QueryAccess(finalDestination, sp.ControllingClient.AgentId, Vector3.Zero, out version, out reason))
{
sp.ControllingClient.SendTeleportFailed("Teleport failed: " + reason);
return;
}
m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Destination is running version {0}", version);
sp.ControllingClient.SendTeleportStart(teleportFlags);
// the avatar.Close below will clear the child region list. We need this below for (possibly)
// closing the child agents, so save it here (we need a copy as it is Clear()-ed).
//List<ulong> childRegions = avatar.KnownRegionHandles;
// Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport
// failure at this point (unlike a border crossing failure). So perhaps this can never fail
// once we reach here...
//avatar.Scene.RemoveCapsHandler(avatar.UUID);
string capsPath = String.Empty;
AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo();
agentCircuit.startpos = position;
agentCircuit.child = true;
agentCircuit.Appearance = sp.Appearance;
if (currentAgentCircuit != null)
{
agentCircuit.ServiceURLs = currentAgentCircuit.ServiceURLs;
agentCircuit.IPAddress = currentAgentCircuit.IPAddress;
agentCircuit.Viewer = currentAgentCircuit.Viewer;
agentCircuit.Channel = currentAgentCircuit.Channel;
agentCircuit.Mac = currentAgentCircuit.Mac;
agentCircuit.Id0 = currentAgentCircuit.Id0;
}
if (NeedsNewAgent(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY))
{
// brand new agent, let's create a new caps seed
agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
}
// Let's create an agent there if one doesn't exist yet.
bool logout = false;
if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout))
{
sp.ControllingClient.SendTeleportFailed(String.Format("Destination refused: {0}",
reason));
return;
}
// OK, it got this agent. Let's close some child agents
sp.CloseChildAgents(newRegionX, newRegionY);
IClientIPEndpoint ipepClient;
if (NeedsNewAgent(sp.DrawDistance, oldRegionX, newRegionX, oldRegionY, newRegionY))
{
//sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent...");
#region IP Translation for NAT
// Uses ipepClient above
//.........这里部分代码省略.........
示例2: DoTeleport
public virtual void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags, IEventQueue eq)
{
sp.ControllingClient.SendTeleportProgress(teleportFlags, "sending_dest");
if (reg == null || finalDestination == null)
{
sp.ControllingClient.SendTeleportFailed("Unable to locate destination");
return;
}
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: Request Teleport to {0}:{1}:{2}/{3}",
reg.ExternalHostName, reg.HttpPort, finalDestination.RegionName, position);
uint newRegionX = (uint)(reg.RegionHandle >> 40);
uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
uint oldRegionX = (uint)(sp.Scene.RegionInfo.RegionHandle >> 40);
uint oldRegionY = (((uint)(sp.Scene.RegionInfo.RegionHandle)) >> 8);
ulong destinationHandle = finalDestination.RegionHandle;
// Let's do DNS resolution only once in this process, please!
// This may be a costly operation. The reg.ExternalEndPoint field is not a passive field,
// it's actually doing a lot of work.
IPEndPoint endPoint = finalDestination.ExternalEndPoint;
if (endPoint.Address != null)
{
sp.ControllingClient.SendTeleportProgress(teleportFlags, "arriving");
if (m_cancelingAgents.Contains(sp.UUID))
{
Cancel(sp);
return;
}
// Fixing a bug where teleporting while sitting results in the avatar ending up removed from
// both regions
if (sp.ParentID != UUID.Zero)
sp.StandUp();
if (!sp.ValidateAttachments())
{
sp.ControllingClient.SendTeleportProgress(teleportFlags, "missing_attach_tport");
sp.ControllingClient.SendTeleportFailed("Inconsistent attachment state");
return;
}
string capsPath = String.Empty;
AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo();
agentCircuit.startpos = position;
agentCircuit.child = true;
agentCircuit.Appearance = sp.Appearance;
if (currentAgentCircuit != null)
{
agentCircuit.ServiceURLs = currentAgentCircuit.ServiceURLs;
agentCircuit.IPAddress = currentAgentCircuit.IPAddress;
agentCircuit.Viewer = currentAgentCircuit.Viewer;
agentCircuit.Channel = currentAgentCircuit.Channel;
agentCircuit.Mac = currentAgentCircuit.Mac;
agentCircuit.Id0 = currentAgentCircuit.Id0;
}
if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY))
{
// brand new agent, let's create a new caps seed
agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
}
string reason = String.Empty;
// Let's create an agent there if one doesn't exist yet.
bool logout = false;
if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason, out logout))
{
sp.ControllingClient.SendTeleportFailed(String.Format("Destination refused: {0}",
reason));
return;
}
// OK, it got this agent. Let's close some child agents
sp.CloseChildAgents(newRegionX, newRegionY);
if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY))
{
//sp.ControllingClient.SendTeleportProgress(teleportFlags, "Creating agent...");
#region IP Translation for NAT
IClientIPEndpoint ipepClient;
if (sp.ClientView.TryGet(out ipepClient))
{
capsPath
= "http://"
+ NetworkUtil.GetHostFor(ipepClient.EndPoint, finalDestination.ExternalHostName)
+ ":"
+ finalDestination.HttpPort
+ CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
}
else
{
capsPath
= "http://"
//.........这里部分代码省略.........
示例3: RequestTeleportToLocation
/// <summary>
/// Try to teleport an agent to a new region.
/// </summary>
/// <param name="remoteClient"></param>
/// <param name="RegionHandle"></param>
/// <param name="position"></param>
/// <param name="lookAt"></param>
/// <param name="flags"></param>
public virtual void RequestTeleportToLocation(ScenePresence avatar, ulong regionHandle, Vector3 position,
Vector3 lookAt, uint teleportFlags)
{
if (!avatar.Scene.Permissions.CanTeleport(avatar.UUID))
return;
bool destRegionUp = true;
IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>();
// Reset animations; the viewer does that in teleports.
avatar.Animator.ResetAnimations();
if (regionHandle == m_regionInfo.RegionHandle)
{
m_log.DebugFormat(
"[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation {0} within {1}",
position, m_regionInfo.RegionName);
// Teleport within the same region
if (IsOutsideRegion(avatar.Scene, position) || position.Z < 0)
{
Vector3 emergencyPos = new Vector3(128, 128, 128);
m_log.WarnFormat(
"[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}",
position, avatar.Name, avatar.UUID, emergencyPos);
position = emergencyPos;
}
// TODO: Get proper AVG Height
float localAVHeight = 1.56f;
float posZLimit = 22;
// TODO: Check other Scene HeightField
if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <=(int)Constants.RegionSize)
{
posZLimit = (float) avatar.Scene.Heightmap[(int) position.X, (int) position.Y];
}
float newPosZ = posZLimit + localAVHeight;
if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
{
position.Z = newPosZ;
}
// Only send this if the event queue is null
if (eq == null)
avatar.ControllingClient.SendTeleportLocationStart();
avatar.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
avatar.Teleport(position);
}
else
{
uint x = 0, y = 0;
Utils.LongToUInts(regionHandle, out x, out y);
GridRegion reg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
if (reg != null)
{
m_log.DebugFormat(
"[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation to {0} in {1}",
position, reg.RegionName);
if (eq == null)
avatar.ControllingClient.SendTeleportLocationStart();
// Let's do DNS resolution only once in this process, please!
// This may be a costly operation. The reg.ExternalEndPoint field is not a passive field,
// it's actually doing a lot of work.
IPEndPoint endPoint = reg.ExternalEndPoint;
if (endPoint.Address == null)
{
// Couldn't resolve the name. Can't TP, because the viewer wants IP addresses.
destRegionUp = false;
}
if (destRegionUp)
{
uint newRegionX = (uint)(reg.RegionHandle >> 40);
uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40);
uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8);
// Fixing a bug where teleporting while sitting results in the avatar ending up removed from
// both regions
if (avatar.ParentID != (uint)0)
avatar.StandUp();
if (!avatar.ValidateAttachments())
{
//.........这里部分代码省略.........
示例4: DoTeleportInternal
/// <summary>
/// Teleports the agent to another region.
/// This method doesn't manage the transfer state; the caller must do that.
/// </summary>
private void DoTeleportInternal(
ScenePresence sp, GridRegion reg, GridRegion finalDestination,
Vector3 position, Vector3 lookAt, uint teleportFlags)
{
if (reg == null || finalDestination == null)
{
sp.ControllingClient.SendTeleportFailed("Unable to locate destination");
return;
}
string homeURI = Scene.GetAgentHomeURI(sp.ControllingClient.AgentId);
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: Teleporting {0} {1} from {2} to {3} ({4}) {5}/{6}",
sp.Name, sp.UUID, sp.Scene.RegionInfo.RegionName,
reg.ServerURI, finalDestination.ServerURI, finalDestination.RegionName, position);
RegionInfo sourceRegion = sp.Scene.RegionInfo;
if (!IsWithinMaxTeleportDistance(sourceRegion, finalDestination))
{
sp.ControllingClient.SendTeleportFailed(
string.Format(
"Can't teleport to {0} ({1},{2}) from {3} ({4},{5}), destination is more than {6} regions way",
finalDestination.RegionName, finalDestination.RegionCoordX, finalDestination.RegionCoordY,
sourceRegion.RegionName, sourceRegion.RegionLocX, sourceRegion.RegionLocY,
MaxTransferDistance));
return;
}
uint newRegionX, newRegionY, oldRegionX, oldRegionY;
Util.RegionHandleToRegionLoc(reg.RegionHandle, out newRegionX, out newRegionY);
Util.RegionHandleToRegionLoc(sp.Scene.RegionInfo.RegionHandle, out oldRegionX, out oldRegionY);
ulong destinationHandle = finalDestination.RegionHandle;
// Let's do DNS resolution only once in this process, please!
// This may be a costly operation. The reg.ExternalEndPoint field is not a passive field,
// it's actually doing a lot of work.
IPEndPoint endPoint = finalDestination.ExternalEndPoint;
if (endPoint == null || endPoint.Address == null)
{
sp.ControllingClient.SendTeleportFailed("Remote Region appears to be down");
return;
}
if (!sp.ValidateAttachments())
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: Failed validation of all attachments for teleport of {0} from {1} to {2}. Continuing.",
sp.Name, sp.Scene.Name, finalDestination.RegionName);
string reason;
string version;
string myversion = string.Format("{0}/{1}", OutgoingTransferVersionName, MaxOutgoingTransferVersion);
if (!Scene.SimulationService.QueryAccess(
finalDestination, sp.ControllingClient.AgentId, homeURI, true, position, myversion, out version, out reason))
{
sp.ControllingClient.SendTeleportFailed(reason);
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: {0} was stopped from teleporting from {1} to {2} because: {3}",
sp.Name, sp.Scene.Name, finalDestination.RegionName, reason);
return;
}
// Before this point, teleport 'failure' is due to checkable pre-conditions such as whether the target
// simulator can be found and is explicitly prepared to allow access. Therefore, we will not count these
// as server attempts.
m_interRegionTeleportAttempts.Value++;
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: {0} max transfer version is {1}/{2}, {3} max version is {4}",
sp.Scene.Name, OutgoingTransferVersionName, MaxOutgoingTransferVersion, finalDestination.RegionName, version);
// Fixing a bug where teleporting while sitting results in the avatar ending up removed from
// both regions
if (sp.ParentID != (uint)0)
sp.StandUp();
else if (sp.Flying)
teleportFlags |= (uint)TeleportFlags.IsFlying;
if (DisableInterRegionTeleportCancellation)
teleportFlags |= (uint)TeleportFlags.DisableCancel;
// At least on LL 3.3.4, this is not strictly necessary - a teleport will succeed without sending this to
// the viewer. However, it might mean that the viewer does not see the black teleport screen (untested).
sp.ControllingClient.SendTeleportStart(teleportFlags);
// the avatar.Close below will clear the child region list. We need this below for (possibly)
// closing the child agents, so save it here (we need a copy as it is Clear()-ed).
//List<ulong> childRegions = avatar.KnownRegionHandles;
// Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport
// failure at this point (unlike a border crossing failure). So perhaps this can never fail
//.........这里部分代码省略.........
示例5: DoTeleport
protected void DoTeleport(ScenePresence sp, GridRegion reg, GridRegion finalDestination, Vector3 position, Vector3 lookAt, uint teleportFlags, IEventQueue eq)
{
if (reg == null || finalDestination == null)
{
sp.ControllingClient.SendTeleportFailed("Unable to locate destination");
return;
}
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: Request Teleport to {0}:{1}:{2}/{3}",
reg.ExternalHostName, reg.HttpPort, finalDestination.RegionName, position);
uint newRegionX = (uint)(reg.RegionHandle >> 40);
uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
uint oldRegionX = (uint)(sp.Scene.RegionInfo.RegionHandle >> 40);
uint oldRegionY = (((uint)(sp.Scene.RegionInfo.RegionHandle)) >> 8);
ulong destinationHandle = finalDestination.RegionHandle;
if (eq == null)
sp.ControllingClient.SendTeleportLocationStart();
// Let's do DNS resolution only once in this process, please!
// This may be a costly operation. The reg.ExternalEndPoint field is not a passive field,
// it's actually doing a lot of work.
IPEndPoint endPoint = finalDestination.ExternalEndPoint;
if (endPoint.Address != null)
{
// Fixing a bug where teleporting while sitting results in the avatar ending up removed from
// both regions
if (sp.ParentID != (uint)0)
sp.StandUp();
if (!sp.ValidateAttachments())
{
sp.ControllingClient.SendTeleportFailed("Inconsistent attachment state");
return;
}
// the avatar.Close below will clear the child region list. We need this below for (possibly)
// closing the child agents, so save it here (we need a copy as it is Clear()-ed).
//List<ulong> childRegions = new List<ulong>(avatar.GetKnownRegionList());
// Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport
// failure at this point (unlike a border crossing failure). So perhaps this can never fail
// once we reach here...
//avatar.Scene.RemoveCapsHandler(avatar.UUID);
string capsPath = String.Empty;
AgentCircuitData currentAgentCircuit = sp.Scene.AuthenticateHandler.GetAgentCircuitData(sp.ControllingClient.CircuitCode);
AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo();
agentCircuit.startpos = position;
agentCircuit.child = true;
agentCircuit.Appearance = sp.Appearance;
if (currentAgentCircuit != null)
{
agentCircuit.ServiceURLs = currentAgentCircuit.ServiceURLs;
agentCircuit.Viewer = currentAgentCircuit.Viewer;
}
if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY))
{
// brand new agent, let's create a new caps seed
agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
}
string reason = String.Empty;
// Let's create an agent there if one doesn't exist yet.
if (!CreateAgent(sp, reg, finalDestination, agentCircuit, teleportFlags, out reason))
{
sp.ControllingClient.SendTeleportFailed(String.Format("Destination refused: {0}",
reason));
return;
}
// OK, it got this agent. Let's close some child agents
sp.CloseChildAgents(newRegionX, newRegionY);
if (NeedsNewAgent(oldRegionX, newRegionX, oldRegionY, newRegionY))
{
#region IP Translation for NAT
IClientIPEndpoint ipepClient;
if (sp.ClientView.TryGet(out ipepClient))
{
capsPath
= "http://"
+ NetworkUtil.GetHostFor(ipepClient.EndPoint, finalDestination.ExternalHostName)
+ ":"
+ finalDestination.HttpPort
+ CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
}
else
{
capsPath
= "http://"
+ finalDestination.ExternalHostName
+ ":"
+ finalDestination.HttpPort
+ CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
//.........这里部分代码省略.........
示例6: ForceAvatarToPosition
private void ForceAvatarToPosition(ScenePresence avatar, Vector3? position)
{
if (m_scene.Permissions.IsGod(avatar.UUID)) return;
if (!position.HasValue)
return;
if(avatar.MovingToTarget)
avatar.ResetMoveToTarget();
avatar.AbsolutePosition = position.Value;
avatar.lastKnownAllowedPosition = position.Value;
avatar.Velocity = Vector3.Zero;
if(avatar.IsSatOnObject)
avatar.StandUp();
forcedPosition.Add(avatar.UUID);
}
示例7: RemoveAgent
/// <summary>
/// Tell a single agent to disconnect from the region.
/// Does not send the DisableSimulator EQM or close child agents
/// </summary>
/// <param name="?"></param>
/// <returns></returns>
public bool RemoveAgent(ScenePresence presence)
{
presence.ControllingClient.Close();
if (presence.ParentID != UUID.Zero)
{
presence.StandUp();
}
m_eventManager.TriggerClientClosed(presence.UUID, this);
m_eventManager.TriggerOnClosingClient(presence.ControllingClient);
m_eventManager.TriggerOnRemovePresence(presence);
ForEachClient(
delegate(IClientAPI client)
{
//We can safely ignore null reference exceptions. It means the avatar is dead and cleaned up anyway
try { client.SendKillObject(presence.Scene.RegionInfo.RegionHandle, new ISceneEntity[] { presence }); }
catch (NullReferenceException) { }
});
try
{
presence.Close();
}
catch (Exception e)
{
m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
}
// Remove the avatar from the scene
m_sceneGraph.RemoveScenePresence(presence.UUID);
m_clientManager.Remove(presence.UUID);
AuthenticateHandler.RemoveCircuit(presence.ControllingClient.CircuitCode);
//m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
//m_log.InfoFormat("[SCENE] Memory post GC {0}", System.GC.GetTotalMemory(true));
return true;
}
示例8: RemoveAvatarFromParcel
public void RemoveAvatarFromParcel(ScenePresence avatar)
{
EntityBase.PositionInfo posInfo = avatar.GetPosInfo();
if (posInfo.Parent != null)
{
// can't find the prim seated on, stand up
avatar.StandUp(null, false, true);
// fall through to unseated avatar code.
}
// If they are moving, stop them. This updates the physics object as well.
avatar.Velocity = Vector3.Zero;
Vector3 pos = avatar.AbsolutePosition; // may have changed from posInfo by StandUp above.
ParcelPropertiesStatus reason2;
if (!avatar.lastKnownAllowedPosition.Equals(Vector3.Zero))
{
pos = avatar.lastKnownAllowedPosition;
}
else
{
// Still a forbidden parcel, they must have been above the limit or entering region for the first time.
// Let's put them up higher, over the restricted parcel.
// We could add 50m to avatar.Scene.Heightmap[x,y] but then we need subscript checks, etc.
// For now, this is simple and safer than TPing them home.
pos.Z += 50.0f;
}
ILandObject parcel = landChannel.GetLandObject(pos.X, pos.Y);
if ((parcel != null) && parcel.DenyParcelAccess(avatar.UUID, out reason2))
{
float minZ = LandChannel.BAN_LINE_SAFETY_HEIGHT + AVATAR_BOUNCE;
if (pos.Z < minZ)
pos.Z = minZ;
}
// Now force the non-sitting avatar to a position above the parcel
avatar.Teleport(pos); // this is really just a move
}
示例9: DoTeleport
public virtual void DoTeleport(ScenePresence 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;
}
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: Request Teleport to {0}:{1}/{2}",
finalDestination.ServerURI, finalDestination.RegionName, position);
int newRegionX = finalDestination.RegionLocX;
int newRegionY = finalDestination.RegionLocY;
int oldRegionX = sp.Scene.RegionInfo.RegionLocX;
int oldRegionY = sp.Scene.RegionInfo.RegionLocY;
sp.ControllingClient.SendTeleportProgress(teleportFlags, "arriving");
// Fixing a bug where teleporting while sitting results in the avatar ending up removed from
// both regions
if (sp.ParentID != UUID.Zero)
sp.StandUp();
//Make sure that all attachments are ready for the teleport
IAttachmentsModule attModule = sp.Scene.RequestModuleInterface<IAttachmentsModule>();
if(attModule != null)
attModule.ValidateAttachments(sp.UUID);
AgentCircuitData agentCircuit = sp.ControllingClient.RequestClientInfo();
agentCircuit.startpos = position;
//The agent will be a root agent
agentCircuit.child = false;
//Make sure the appearnace is right
agentCircuit.Appearance = sp.Appearance;
AgentData agent = new AgentData();
sp.CopyTo(agent);
//Fix the position
agent.Position = position;
IEventQueueService eq = sp.Scene.RequestModuleInterface<IEventQueueService>();
if (eq != null)
{
//This does CreateAgent and sends the EnableSimulator/EstablishAgentCommunication/TeleportFinish
// messages if they need to be called and deals with the callback
if (!eq.TeleportAgent(sp.UUID, (int)sp.DrawDistance,
agentCircuit, agent, teleportFlags, finalDestination, sp.Scene.RegionInfo.RegionHandle))
{
// Fix the agent status
sp.IsChildAgent = false;
sp.ControllingClient.SendTeleportFailed("Destination refused");
return;
}
}
//Kill the groups here, otherwise they will become ghost attachments
// and stay in the sim, they'll get readded below into the new sim
KillAttachments(sp);
// Well, this is it. The agent is over there.
KillEntity(sp.Scene, sp);
INeighborService service = sp.Scene.RequestModuleInterface<INeighborService>();
if (service != null)
{
//Check that the region the client is in right now isn't a part of the
// regions that should be closed as well
if (service.IsOutsideView(sp.Scene.RegionInfo.RegionLocX, finalDestination.RegionLocX,
sp.Scene.RegionInfo.RegionLocY, finalDestination.RegionLocY))
{
Thread.Sleep(1000);
// Fix this so that when we close, we don't have the wrong type
sp.IsChildAgent = false;
//Wait a bit for the agent to leave this region, then close them
sp.Scene.IncomingCloseAgent(sp.UUID);
}
else
sp.MakeChildAgent();
}
}
示例10: DoTeleport
public void DoTeleport(
ScenePresence sp, GridRegion reg, GridRegion finalDestination,
Vector3 position, Vector3 lookAt, uint teleportFlags)
{
// Record that this agent is in transit so that we can prevent simultaneous requests and do later detection
// of whether the destination region completes the teleport.
if (!m_entityTransferStateMachine.SetInTransit(sp.UUID))
{
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: Ignoring teleport request of {0} {1} to {2} ({3}) {4}/{5} - agent is already in transit.",
sp.Name, sp.UUID, reg.ServerURI, finalDestination.ServerURI, finalDestination.RegionName, position);
return;
}
if (reg == null || finalDestination == null)
{
sp.ControllingClient.SendTeleportFailed("Unable to locate destination");
m_entityTransferStateMachine.ResetFromTransit(sp.UUID);
return;
}
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: Teleporting {0} {1} from {2} to {3} ({4}) {5}/{6}",
sp.Name, sp.UUID, sp.Scene.RegionInfo.RegionName,
reg.ServerURI, finalDestination.ServerURI, finalDestination.RegionName, position);
RegionInfo sourceRegion = sp.Scene.RegionInfo;
if (!IsWithinMaxTeleportDistance(sourceRegion, finalDestination))
{
sp.ControllingClient.SendTeleportFailed(
string.Format(
"Can't teleport to {0} ({1},{2}) from {3} ({4},{5}), destination is more than {6} regions way",
finalDestination.RegionName, finalDestination.RegionCoordX, finalDestination.RegionCoordY,
sourceRegion.RegionName, sourceRegion.RegionLocX, sourceRegion.RegionLocY,
MaxTransferDistance));
m_entityTransferStateMachine.ResetFromTransit(sp.UUID);
return;
}
uint newRegionX = (uint)(reg.RegionHandle >> 40);
uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
uint oldRegionX = (uint)(sp.Scene.RegionInfo.RegionHandle >> 40);
uint oldRegionY = (((uint)(sp.Scene.RegionInfo.RegionHandle)) >> 8);
ulong destinationHandle = finalDestination.RegionHandle;
// Let's do DNS resolution only once in this process, please!
// This may be a costly operation. The reg.ExternalEndPoint field is not a passive field,
// it's actually doing a lot of work.
IPEndPoint endPoint = finalDestination.ExternalEndPoint;
if (endPoint.Address == null)
{
sp.ControllingClient.SendTeleportFailed("Remote Region appears to be down");
m_entityTransferStateMachine.ResetFromTransit(sp.UUID);
return;
}
if (!sp.ValidateAttachments())
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: Failed validation of all attachments for teleport of {0} from {1} to {2}. Continuing.",
sp.Name, sp.Scene.RegionInfo.RegionName, finalDestination.RegionName);
// if (!sp.ValidateAttachments())
// {
// sp.ControllingClient.SendTeleportFailed("Inconsistent attachment state");
// return;
// }
string reason;
string version;
if (!Scene.SimulationService.QueryAccess(
finalDestination, sp.ControllingClient.AgentId, Vector3.Zero, out version, out reason))
{
sp.ControllingClient.SendTeleportFailed(reason);
m_entityTransferStateMachine.ResetFromTransit(sp.UUID);
m_log.DebugFormat(
"[ENTITY TRANSFER MODULE]: {0} was stopped from teleporting from {1} to {2} because {3}",
sp.Name, sp.Scene.RegionInfo.RegionName, finalDestination.RegionName, reason);
return;
}
m_log.DebugFormat("[ENTITY TRANSFER MODULE]: Destination is running version {0}", version);
// Fixing a bug where teleporting while sitting results in the avatar ending up removed from
// both regions
if (sp.ParentID != (uint)0)
sp.StandUp();
// At least on LL 3.3.4, this is not strictly necessary - a teleport will succeed without sending this to
// the viewer. However, it might mean that the viewer does not see the black teleport screen (untested).
sp.ControllingClient.SendTeleportStart(teleportFlags);
//.........这里部分代码省略.........
示例11: handleAvatarChangingParcel
public void handleAvatarChangingParcel(ScenePresence avatar, int localLandID, UUID regionID)
{
if (m_scene.RegionInfo.RegionID == regionID)
{
ILandObject parcelAvatarIsEntering;
lock (m_landList)
{
parcelAvatarIsEntering = m_landList[localLandID];
}
if (parcelAvatarIsEntering != null)
{
Vector3 pos = avatar.AbsolutePosition;
if (pos.Z < LandChannel.BAN_LINE_SAFETY_HEIGHT)
{
ParcelPropertiesStatus reason;
if (parcelAvatarIsEntering.DenyParcelAccess(avatar.UUID, out reason))
{
// Check if the avatar is seated and unsit before reposition/teleport in SendNoEntryNotice.
EntityBase.PositionInfo posInfo = avatar.GetPosInfo();
if (posInfo.Parent != null)
avatar.StandUp(null, false, true);
SendNoEntryNotice(avatar, reason);
}
else
{
avatar.lastKnownAllowedPosition = new Vector3(pos);
}
}
else
{
avatar.lastKnownAllowedPosition = new Vector3(pos);
}
}
}
}
示例12: SetPropertyValue
private void SetPropertyValue(ScenePresence sp, SyncableProperties.Type property, SyncedProperty pSyncInfo)
{
if (sp == null || pSyncInfo == null) return;
Object pValue = pSyncInfo.LastUpdateValue;
switch (property)
{
case SyncableProperties.Type.LocalId:
sp.LocalId = (uint)pValue;
break;
case SyncableProperties.Type.AbsolutePosition:
sp.AbsolutePosition = (Vector3)pValue;
break;
case SyncableProperties.Type.AgentCircuitData:
DebugLog.WarnFormat("{0}: Received updated AgentCircuitData. Not implemented", LogHeader);
break;
case SyncableProperties.Type.ParentId:
uint localID = (uint)pValue;
if (localID == 0)
{
// DebugLog.DebugFormat("{0}: SetPropertyValue:ParentID. Standup. Input={1}", LogHeader, localID); // DEBUG DEBUG
sp.StandUp();
}
else
{
SceneObjectPart parentPart = Scene.GetSceneObjectPart(localID);
if (parentPart != null) // TODO ??
{
sp.HandleAgentRequestSit(sp.ControllingClient, sp.ControllingClient.AgentId, parentPart.UUID, Vector3.Zero);
// DebugLog.DebugFormat("{0}: SetPropertyValue:ParentID. SitRequest. Input={1},sp={2},newParentID={3}",
// LogHeader, localID, (string)(sp == null ? "NULL" : sp.Name), sp.ParentID); // DEBUG DEBUG
}
}
//sp.ParentID = (uint)pValue;
break;
case SyncableProperties.Type.AgentControlFlags:
sp.AgentControlFlags = (uint)pValue;
break;
case SyncableProperties.Type.AllowMovement:
sp.AllowMovement = (bool)pValue;
break;
case SyncableProperties.Type.AvatarAppearance:
sp.Appearance.Unpack((OSDMap)pValue);
sp.SendAppearanceToAllOtherAgents();
DebugLog.DebugFormat("{0} Received updated AvatarAppearance for uuid {1}.", LogHeader, sp.UUID);
break;
case SyncableProperties.Type.Animations:
UpdateAvatarAnimations(sp, (OSDArray)pValue);
break;
case SyncableProperties.Type.Rotation:
sp.Rotation = (Quaternion)pValue;
break;
case SyncableProperties.Type.PA_Velocity:
if (sp.PhysicsActor != null)
sp.PhysicsActor.Velocity = (Vector3)pValue;
break;
case SyncableProperties.Type.RealRegion:
////// NOP //////
break;
case SyncableProperties.Type.PA_TargetVelocity:
if(sp.PhysicsActor != null)
sp.PhysicsActor.TargetVelocity = (Vector3)pValue;
break;
case SyncableProperties.Type.Flying:
sp.Flying = (bool)pValue;
break;
case SyncableProperties.Type.PresenceType:
DebugLog.WarnFormat("{0} Received updated PresenceType for uuid {1}. Not implemented", LogHeader, sp.UUID);
break;
case SyncableProperties.Type.IsColliding:
if(sp.PhysicsActor != null)
sp.IsColliding = (bool)pValue;
break;
}
// When presence values are changed, we tell the simulator with an event
GenerateAgentUpdated(sp);
}
示例13: Teleport
public void Teleport(ScenePresence botPresence, Vector3 pos)
{
botPresence.StandUp(null, false, true);
botPresence.Teleport(pos);
}
示例14: RemoveAvatarFromParcel
// Bounce constants are how far above a no-entry parcel we'll place an object or avatar.
public void RemoveAvatarFromParcel(ScenePresence avatar)
{
EntityBase.PositionInfo posInfo = avatar.GetPosInfo();
if (posInfo.Parent != null)
{
// can't find the prim seated on, stand up
avatar.StandUp(false, true);
// fall through to unseated avatar code.
}
// If they are moving, stop them. This updates the physics object as well.
// The avatar needs to be stopped before entering the parcel otherwise there
// are timing windows where the avatar can just pound away at the parcel border
// and get across it due to physics placing them there.
avatar.Velocity = Vector3.Zero;
Vector3 pos = avatar.AbsolutePosition; // may have changed from posInfo by StandUp above.
ParcelPropertiesStatus reason2;
if (!avatar.lastKnownAllowedPosition.Equals(Vector3.Zero))
{
pos = avatar.lastKnownAllowedPosition;
}
ILandObject parcel = landChannel.GetLandObject(pos.X, pos.Y);
float minZ;
if ((parcel != null) && m_scene.TestBelowHeightLimit(avatar.UUID, pos, parcel, out minZ, out reason2))
{
float groundZ = (float)m_scene.Heightmap.CalculateHeightAt(pos.X, pos.Y);
minZ += groundZ;
// make them bounce above the banned parcel if being removed
if (pos.Z < minZ)
pos.Z = minZ + Constants.AVATAR_BOUNCE;
}
// Now force the non-sitting avatar to a position above the parcel
avatar.Teleport(pos); // this is really just a move
}