本文整理汇总了C#中TeleportStatus类的典型用法代码示例。如果您正苦于以下问题:C# TeleportStatus类的具体用法?C# TeleportStatus怎么用?C# TeleportStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TeleportStatus类属于命名空间,在下文中一共展示了TeleportStatus类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RequestTeleport
/// <summary>
/// Request teleport to a another simulator
/// </summary>
/// <param name="regionHandle">handle of region to teleport agent to</param>
/// <param name="position"><seealso cref="Vector3"/> position in destination sim to teleport to</param>
/// <param name="lookAt"><seealso cref="Vector3"/> direction in destination sim agent will look at</param>
public void RequestTeleport(ulong regionHandle, Vector3 position, Vector3 lookAt)
{
if (Client.Network.CurrentSim != null &&
Client.Network.CurrentSim.Caps != null &&
Client.Network.CurrentSim.Caps.IsEventQueueRunning)
{
TeleportLocationRequestPacket teleport = new TeleportLocationRequestPacket();
teleport.AgentData.AgentID = Client.Self.AgentID;
teleport.AgentData.SessionID = Client.Self.SessionID;
teleport.Info.LookAt = lookAt;
teleport.Info.Position = position;
teleport.Info.RegionHandle = regionHandle;
Logger.Log("Requesting teleport to region handle " + regionHandle.ToString(), Helpers.LogLevel.Info, Client);
Client.Network.SendPacket(teleport);
}
else
{
teleportMessage = "CAPS event queue is not running";
teleportEvent.Set();
teleportStat = TeleportStatus.Failed;
}
}
示例2: Teleport
/// <summary>
/// Attempt to look up a simulator name and teleport to the discovered
/// destination
/// </summary>
/// <param name="simName">Region name to look up</param>
/// <param name="position">Position to teleport to</param>
/// <param name="lookAt">Target to look at</param>
/// <returns>True if the lookup and teleport were successful, otherwise
/// false</returns>
public bool Teleport(string simName, Vector3 position, Vector3 lookAt)
{
if (Client.Network.CurrentSim == null)
return false;
teleportStat = TeleportStatus.None;
if (simName != Client.Network.CurrentSim.Name)
{
// Teleporting to a foreign sim
GridRegion region;
if (Client.Grid.GetGridRegion(simName, GridLayerType.Objects, out region))
{
return Teleport(region.RegionHandle, position, lookAt);
}
else
{
teleportMessage = "Unable to resolve name: " + simName;
teleportStat = TeleportStatus.Failed;
return false;
}
}
else
{
// Teleporting to the sim we're already in
return Teleport(Client.Network.CurrentSim.Handle, position, lookAt);
}
}
示例3: TeleportHandler
/// <summary>
/// Handler for teleport Requests
/// </summary>
/// <param name="packet">Incoming TeleportHandler packet</param>
/// <param name="simulator">Simulator sending teleport information</param>
private void TeleportHandler(Packet packet, Simulator simulator)
{
bool finished = false;
TeleportFlags flags = TeleportFlags.Default;
if (packet.Type == PacketType.TeleportStart)
{
TeleportStartPacket start = (TeleportStartPacket)packet;
teleportMessage = "Teleport started";
flags = (TeleportFlags)start.Info.TeleportFlags;
teleportStat = TeleportStatus.Start;
Client.DebugLog("TeleportStart received, Flags: " + flags.ToString());
}
else if (packet.Type == PacketType.TeleportProgress)
{
TeleportProgressPacket progress = (TeleportProgressPacket)packet;
teleportMessage = Helpers.FieldToUTF8String(progress.Info.Message);
flags = (TeleportFlags)progress.Info.TeleportFlags;
teleportStat = TeleportStatus.Progress;
Client.DebugLog("TeleportProgress received, Message: " + teleportMessage + ", Flags: " + flags.ToString());
}
else if (packet.Type == PacketType.TeleportFailed)
{
TeleportFailedPacket failed = (TeleportFailedPacket)packet;
teleportMessage = Helpers.FieldToUTF8String(failed.Info.Reason);
teleportStat = TeleportStatus.Failed;
finished = true;
Client.DebugLog("TeleportFailed received, Reason: " + teleportMessage);
}
else if (packet.Type == PacketType.TeleportFinish)
{
TeleportFinishPacket finish = (TeleportFinishPacket)packet;
flags = (TeleportFlags)finish.Info.TeleportFlags;
string seedcaps = Helpers.FieldToUTF8String(finish.Info.SeedCapability);
finished = true;
Client.DebugLog("TeleportFinish received, Flags: " + flags.ToString());
// Connect to the new sim
Simulator newSimulator = Client.Network.Connect(new IPAddress(finish.Info.SimIP),
finish.Info.SimPort, finish.Info.RegionHandle, true, seedcaps);
if (newSimulator != null)
{
teleportMessage = "Teleport finished";
teleportStat = TeleportStatus.Finished;
// Disconnect from the previous sim
Client.Network.DisconnectSim(simulator, true);
Client.Log("Moved to new sim " + newSimulator.ToString(), Helpers.LogLevel.Info);
}
else
{
teleportMessage = "Failed to connect to the new sim after a teleport";
teleportStat = TeleportStatus.Failed;
// We're going to get disconnected now
Client.Log(teleportMessage, Helpers.LogLevel.Error);
}
}
else if (packet.Type == PacketType.TeleportCancel)
{
//TeleportCancelPacket cancel = (TeleportCancelPacket)packet;
teleportMessage = "Cancelled";
teleportStat = TeleportStatus.Cancelled;
finished = true;
Client.DebugLog("TeleportCancel received from " + simulator.ToString());
}
else if (packet.Type == PacketType.TeleportLocal)
{
TeleportLocalPacket local = (TeleportLocalPacket)packet;
teleportMessage = "Teleport finished";
flags = (TeleportFlags)local.Info.TeleportFlags;
teleportStat = TeleportStatus.Finished;
relativePosition = local.Info.Position;
Movement.Camera.LookDirection(local.Info.LookAt);
// This field is apparently not used for anything
//local.Info.LocationID;
finished = true;
Client.DebugLog("TeleportLocal received, Flags: " + flags.ToString());
}
if (OnTeleport != null)
//.........这里部分代码省略.........
示例4: RecallInfo
public RecallInfo(EnemyInfo enemyInfo)
{
EnemyInfo = enemyInfo;
type = TeleportType.Unknown;
status = TeleportStatus.Unknown;
duration = 0;
start = 0;
abduration = 0;
abstart = 0;
IncomingDamage = new Dictionary<int, float>();
}
示例5: Teleport
/// <summary>
/// Teleport agent to another region
/// </summary>
/// <param name="regionHandle">handle of region to teleport agent to</param>
/// <param name="position"><seealso cref="libsecondlife.LLVector3"/> position in destination sim to teleport to</param>
/// <param name="lookAt"><seealso cref="libsecondlife.LLVector3"/> direction in destination sim agent will look at</param>
/// <returns>true on success, false on failure</returns>
/// <remarks>This call is blocking</remarks>
public bool Teleport(ulong regionHandle, LLVector3 position, LLVector3 lookAt)
{
teleportStat = TeleportStatus.None;
teleportEvent.Reset();
RequestTeleport(regionHandle, position, lookAt);
teleportEvent.WaitOne(Client.Settings.TELEPORT_TIMEOUT, false);
if (teleportStat == TeleportStatus.None ||
teleportStat == TeleportStatus.Start ||
teleportStat == TeleportStatus.Progress)
{
teleportMessage = "Teleport timed out.";
teleportStat = TeleportStatus.Failed;
}
return (teleportStat == TeleportStatus.Finished);
}
示例6: Teleport
/// <summary>
///
/// </summary>
/// <param name="simName"></param>
/// <param name="position"></param>
/// <param name="lookAt"></param>
/// <returns></returns>
public bool Teleport(string simName, LLVector3 position, LLVector3 lookAt)
{
int attempts = 0;
TeleportStat = TeleportStatus.None;
simName = simName.ToLower();
GridRegion region = Client.Grid.GetGridRegion(simName);
if (region != null)
{
return Teleport(region.RegionHandle, position, lookAt);
}
else
{
while (attempts++ < 5)
{
region = Client.Grid.GetGridRegion(simName);
if (region != null)
{
return Teleport(region.RegionHandle, position, lookAt);
}
else
{
// Request the region info again
Client.Grid.AddSim(simName);
System.Threading.Thread.Sleep(1000);
}
}
}
if (OnTeleport != null)
{
TeleportMessage = "Unable to resolve name: " + simName;
TeleportStat = TeleportStatus.Failed;
OnTeleport(TeleportMessage, TeleportStat);
}
return false;
}
示例7: TeleportHandler
/// <summary>
///
/// </summary>
/// <param name="packet"></param>
/// <param name="simulator"></param>
private void TeleportHandler(Packet packet, Simulator simulator)
{
if (packet.Type == PacketType.TeleportStart)
{
TeleportMessage = "Teleport started";
TeleportStat = TeleportStatus.Start;
if (OnBeginTeleport != null)
{
OnBeginTeleport(TeleportMessage, TeleportStat);
}
}
else if (packet.Type == PacketType.TeleportProgress)
{
TeleportMessage = Helpers.FieldToString(((TeleportProgressPacket)packet).Info.Message);
TeleportStat = TeleportStatus.Progress;
if (OnBeginTeleport != null)
{
OnBeginTeleport(TeleportMessage, TeleportStat);
}
}
else if (packet.Type == PacketType.TeleportFailed)
{
TeleportMessage = Helpers.FieldToString(((TeleportFailedPacket)packet).Info.Reason);
TeleportStat = TeleportStatus.Failed;
if (OnBeginTeleport != null)
{
OnBeginTeleport(TeleportMessage, TeleportStat);
}
OnBeginTeleport = null;
}
else if (packet.Type == PacketType.TeleportFinish)
{
TeleportFinishPacket finish = (TeleportFinishPacket)packet;
// Connect to the new sim
Simulator sim = Client.Network.Connect(new IPAddress((long)finish.Info.SimIP), finish.Info.SimPort,
simulator.CircuitCode, true);
if ( sim != null)
{
TeleportMessage = "Teleport finished";
TeleportStat = TeleportStatus.Finished;
// Move the avatar in to the new sim
CompleteAgentMovementPacket move = new CompleteAgentMovementPacket();
move.AgentData.AgentID = Client.Network.AgentID;
move.AgentData.SessionID = Client.Network.SessionID;
move.AgentData.CircuitCode = simulator.CircuitCode;
Client.Network.SendPacket((Packet)move);
Client.DebugLog(move.ToString());
Client.Log("Moved to new sim " + Client.Network.CurrentSim.Region.Name + "(" +
Client.Network.CurrentSim.IPEndPoint.ToString() + ")",
Helpers.LogLevel.Info);
if (OnBeginTeleport != null)
{
OnBeginTeleport(TeleportMessage, TeleportStat);
}
else
{
// Sleep a little while so we can collect parcel information
System.Threading.Thread.Sleep(1000);
}
}
else
{
TeleportMessage = "Failed to connect to the new sim after a teleport";
TeleportStat = TeleportStatus.Failed;
Client.Log(TeleportMessage, Helpers.LogLevel.Warning);
if (OnBeginTeleport != null)
{
OnBeginTeleport(TeleportMessage, TeleportStat);
}
}
OnBeginTeleport = null;
}
}
示例8: TeleportHandler
/// <summary>
/// Handler for teleport Requests
/// </summary>
/// <param name="packet">Incoming TeleportHandler packet</param>
/// <param name="simulator">Simulator sending teleport information</param>
private void TeleportHandler(Packet packet, Simulator simulator)
{
if (packet.Type == PacketType.TeleportStart)
{
Client.DebugLog("TeleportStart received from " + simulator.ToString());
teleportMessage = "Teleport started";
TeleportStat = TeleportStatus.Start;
if (OnBeginTeleport != null)
{
OnBeginTeleport(Client.Network.CurrentSim, teleportMessage, TeleportStat);
}
}
else if (packet.Type == PacketType.TeleportProgress)
{
Client.DebugLog("TeleportProgress received from " + simulator.ToString());
teleportMessage = Helpers.FieldToString(((TeleportProgressPacket)packet).Info.Message);
TeleportStat = TeleportStatus.Progress;
if (OnBeginTeleport != null)
{
OnBeginTeleport(Client.Network.CurrentSim, teleportMessage, TeleportStat);
}
}
else if (packet.Type == PacketType.TeleportFailed)
{
Client.DebugLog("TeleportFailed received from " + simulator.ToString());
teleportMessage = Helpers.FieldToString(((TeleportFailedPacket)packet).Info.Reason);
TeleportStat = TeleportStatus.Failed;
if (OnBeginTeleport != null)
{
OnBeginTeleport(Client.Network.CurrentSim, teleportMessage, TeleportStat);
}
OnBeginTeleport = null;
}
else if (packet.Type == PacketType.TeleportFinish)
{
Client.DebugLog("TeleportFinish received from " + simulator.ToString());
TeleportFinishPacket finish = (TeleportFinishPacket)packet;
Simulator previousSim = Client.Network.CurrentSim;
// Connect to the new sim
String seedcaps = Encoding.UTF8.GetString(finish.Info.SeedCapability).Replace("\x00","");
Simulator sim = Client.Network.Connect(new IPAddress((long)finish.Info.SimIP), finish.Info.SimPort,
simulator.CircuitCode, true, seedcaps);
if (sim != null)
{
teleportMessage = "Teleport finished";
TeleportStat = TeleportStatus.Finished;
// Move the avatar in to the new sim
CompleteAgentMovementPacket move = new CompleteAgentMovementPacket();
move.AgentData.AgentID = Client.Network.AgentID;
move.AgentData.SessionID = Client.Network.SessionID;
move.AgentData.CircuitCode = simulator.CircuitCode;
Client.Network.SendPacket(move, sim);
// Disconnect from the previous sim
Client.Network.DisconnectSim(previousSim);
Client.Log("Moved to new sim " + sim.ToString(), Helpers.LogLevel.Info);
if (OnBeginTeleport != null)
{
OnBeginTeleport(sim, teleportMessage, TeleportStat);
}
else
{
// Sleep a little while so we can collect parcel information
// NOTE: This doesn't belong in libsecondlife
// System.Threading.Thread.Sleep(1000);
}
}
else
{
teleportMessage = "Failed to connect to the new sim after a teleport";
TeleportStat = TeleportStatus.Failed;
// FIXME: Set the previous CurrentSim to the current simulator again
Client.Log(teleportMessage, Helpers.LogLevel.Warning);
if (OnBeginTeleport != null)
{
OnBeginTeleport(Client.Network.CurrentSim, teleportMessage, TeleportStat);
}
}
//.........这里部分代码省略.........
示例9: Teleport
/// <summary>
/// Teleport agent to another region
/// </summary>
/// <param name="regionHandle">handle of region to teleport agent to</param>
/// <param name="position"><seealso cref="Vector3"/> position in destination sim to teleport to</param>
/// <param name="lookAt"><seealso cref="Vector3"/> direction in destination sim agent will look at</param>
/// <returns>true on success, false on failure</returns>
/// <remarks>This call is blocking</remarks>
public bool Teleport(ulong regionHandle, Vector3 position, Vector3 lookAt)
{
if (Network.CurrentSim == null ||
Network.CurrentSim.Caps == null ||
!Network.CurrentSim.Caps.IsEventQueueRunning)
{
// Wait a bit to see if the event queue comes online
AutoResetEvent queueEvent = new AutoResetEvent(false);
NetworkManager.EventQueueRunningCallback queueCallback =
delegate(Simulator simulator)
{
if (simulator == Network.CurrentSim)
queueEvent.Set();
};
Network.OnEventQueueRunning += queueCallback;
queueEvent.WaitOne(10 * 1000, false);
Network.OnEventQueueRunning -= queueCallback;
}
teleportStat = TeleportStatus.None;
teleportEvent.Reset();
RequestTeleport(regionHandle, position, lookAt);
teleportEvent.WaitOne(TeleportTimeout, false);
if (teleportStat == TeleportStatus.None ||
teleportStat == TeleportStatus.Start ||
teleportStat == TeleportStatus.Progress)
{
teleportMessage = "Teleport timed out.";
teleportStat = TeleportStatus.Failed;
}
return (teleportStat == TeleportStatus.Finished);
}
示例10: UpdateRecall
public EnemyInfo UpdateRecall(TeleportType t, TeleportStatus s, int dur, int st)
{
IncomingDamage.Clear();
LockedTarget = false;
EstimatedShootT = 0;
if (t == TeleportType.Recall && s == TeleportStatus.Abort)
{
abduration = dur;
abstart = st;
AbortedT = Utils.TickCount;
}
else
{
AbortedT = 0;
}
type = t;
status = s;
if (s == TeleportStatus.Start)
{
duration = dur;
}
start = st;
Console.WriteLine("" + t + " " + s + " " + duration + " " + start + "");
return EnemyInfo;
}
示例11: TeleportHandler
/// <summary>Process an incoming packet and raise the appropriate events</summary>
/// <param name="sender">The sender</param>
/// <param name="e">The EventArgs object containing the packet data</param>
protected void TeleportHandler(object sender, PacketReceivedEventArgs e)
{
Packet packet = e.Packet;
Simulator simulator = e.Simulator;
bool finished = false;
TeleportFlags flags = TeleportFlags.Default;
if (packet.Type == PacketType.TeleportStart)
{
TeleportStartPacket start = (TeleportStartPacket)packet;
teleportMessage = "Teleport started";
flags = (TeleportFlags)start.Info.TeleportFlags;
teleportStat = TeleportStatus.Start;
Logger.DebugLog("TeleportStart received, Flags: " + flags.ToString(), Client);
}
else if (packet.Type == PacketType.TeleportProgress)
{
TeleportProgressPacket progress = (TeleportProgressPacket)packet;
teleportMessage = Utils.BytesToString(progress.Info.Message);
flags = (TeleportFlags)progress.Info.TeleportFlags;
teleportStat = TeleportStatus.Progress;
Logger.DebugLog("TeleportProgress received, Message: " + teleportMessage + ", Flags: " + flags.ToString(), Client);
}
else if (packet.Type == PacketType.TeleportFailed)
{
TeleportFailedPacket failed = (TeleportFailedPacket)packet;
teleportMessage = Utils.BytesToString(failed.Info.Reason);
teleportStat = TeleportStatus.Failed;
finished = true;
Logger.DebugLog("TeleportFailed received, Reason: " + teleportMessage, Client);
}
else if (packet.Type == PacketType.TeleportFinish)
{
TeleportFinishPacket finish = (TeleportFinishPacket)packet;
flags = (TeleportFlags)finish.Info.TeleportFlags;
string seedcaps = Utils.BytesToString(finish.Info.SeedCapability);
finished = true;
Logger.DebugLog("TeleportFinish received, Flags: " + flags.ToString(), Client);
// Connect to the new sim
Simulator newSimulator = Client.Network.Connect(new IPAddress(finish.Info.SimIP),
finish.Info.SimPort, finish.Info.RegionHandle, true, seedcaps);
if (newSimulator != null)
{
teleportMessage = "Teleport finished";
teleportStat = TeleportStatus.Finished;
Logger.Log("Moved to new sim " + newSimulator.ToString(), Helpers.LogLevel.Info, Client);
}
else
{
teleportMessage = "Failed to connect to the new sim after a teleport";
teleportStat = TeleportStatus.Failed;
// We're going to get disconnected now
Logger.Log(teleportMessage, Helpers.LogLevel.Error, Client);
}
}
else if (packet.Type == PacketType.TeleportCancel)
{
//TeleportCancelPacket cancel = (TeleportCancelPacket)packet;
teleportMessage = "Cancelled";
teleportStat = TeleportStatus.Cancelled;
finished = true;
Logger.DebugLog("TeleportCancel received from " + simulator.ToString(), Client);
}
else if (packet.Type == PacketType.TeleportLocal)
{
TeleportLocalPacket local = (TeleportLocalPacket)packet;
teleportMessage = "Teleport finished";
flags = (TeleportFlags)local.Info.TeleportFlags;
teleportStat = TeleportStatus.Finished;
relativePosition = local.Info.Position;
Movement.Camera.LookDirection(local.Info.LookAt);
// This field is apparently not used for anything
//local.Info.LocationID;
finished = true;
Logger.DebugLog("TeleportLocal received, Flags: " + flags.ToString(), Client);
}
if (m_Teleport != null)
{
OnTeleport(new TeleportEventArgs(teleportMessage, teleportStat, flags));
//.........这里部分代码省略.........
示例12: Avatar_OnTeleportMessage
private void Avatar_OnTeleportMessage(string message, TeleportStatus status)
{
Console.WriteLine(message);
if (status == TeleportStatus.Finished || status == TeleportStatus.Failed)
{
DoneTeleporting = true;
}
}
示例13: TeleportEventArgs
public TeleportEventArgs(string message, TeleportStatus status, TeleportFlags flags)
{
this.m_Message = message;
this.m_Status = status;
this.m_Flags = flags;
}
示例14: Teleport
/// <summary>
/// Attempt to look up a simulator name and teleport to the discovered
/// destination
/// </summary>
/// <param name="simName">Region name to look up</param>
/// <param name="position">Position to teleport to</param>
/// <param name="lookAt">Target to look at</param>
/// <returns>True if the lookup and teleport were successful, otherwise
/// false</returns>
public bool Teleport(string simName, LLVector3 position, LLVector3 lookAt)
{
TeleportStat = TeleportStatus.None;
simName = simName.ToLower();
if (simName != Client.Network.CurrentSim.Name.ToLower())
{
// Teleporting to a foreign sim
GridRegion region;
if (Client.Grid.GetGridRegion(simName, out region))
{
return Teleport(region.RegionHandle, position, lookAt);
}
else
{
teleportMessage = "Unable to resolve name: " + simName;
TeleportStat = TeleportStatus.Failed;
return false;
}
}
else
{
// Teleporting to the sim we're already in
return Teleport(Client.Network.CurrentSim.Handle, position, lookAt);
}
}