本文整理汇总了C#中System.Object.DeleteTargetTeleporter方法的典型用法代码示例。如果您正苦于以下问题:C# Object.DeleteTargetTeleporter方法的具体用法?C# Object.DeleteTargetTeleporter怎么用?C# Object.DeleteTargetTeleporter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Object
的用法示例。
在下文中一共展示了Object.DeleteTargetTeleporter方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Use
public void Use(IActor actor)
{
//set up needed Variables
IGameServer Server = actor.State as IGameServer;
IBiomeSystem currentSystem = ((IGameServer)actor.State).Biomes.GetSystems()[actor.InstanceID];
//Permission Check, is the Player allowed to use the Teleporter?
if (currentSystem.Nation != string.Empty && currentSystem.Nation != actor.Nation)
{
Server.ChatManager.SendActorMessage("You must be in the Nation that claimed this System to use the Teleporter.", actor);
return;
}
//Set up ChunkDictionary so we can access the Chunks in System (We need the Chunk to Teleport the player to later)
Dictionary<Point3D, IChunk> ChunkDictionary = SNScriptUtils._Utils.CreateChunkDictionary(currentSystem);
//create offset List (the 4 Positions around our Activator where we expect at least one Teleporter)
List<Point3D> offsetList = new List<Point3D>();
offsetList.Add(new Point3D(0, -1, -1)); offsetList.Add(new Point3D(0, -1, 1));offsetList.Add(new Point3D(1, -1, 0)); offsetList.Add(new Point3D(-1, -1, 0));
List<Object[,]> SpecialBlockList = null;
Teleporter nearbyTeleporter = new Object() as Teleporter;
//Get List of Teleporters in vicinity to the Activator based on offsetList (expected Teleporter locations)
if (SNScriptUtils._Utils.FindCustomSpecialBlocksAround(this.Position, this.Chunk, offsetList, (uint)7100, ChunkDictionary, out SpecialBlockList))
{
//just take the first one found for now
IChunk tmpChunk = SpecialBlockList[0][0, 1] as IChunk;
Point3D TeleporterLocalPos = (Point3D)SpecialBlockList[0][0, 0];
ISpecialBlock targetSpecialBlock = tmpChunk.GetSpecialBlocks().FirstOrDefault(item => (item is Teleporter) && ((item as Teleporter).Position == TeleporterLocalPos));
nearbyTeleporter = targetSpecialBlock as Teleporter;
}
else
{
Server.ChatManager.SendActorMessage("There is no Teleporter around the Activator!", actor);
return;
}
//Check if Player is standing on the Teleporter right now
Point3D teleporterPadFakeGlobalPos = new Point3D(
nearbyTeleporter.Position.X + (int)((IChunk)SpecialBlockList[0][0, 1]).Position.X,
nearbyTeleporter.Position.Y + (int)((IChunk)SpecialBlockList[0][0, 1]).Position.Y + 1,
nearbyTeleporter.Position.Z + (int)((IChunk)SpecialBlockList[0][0, 1]).Position.Z
);
Point3D actorPos = _Utils.GetActorFakeGlobalPos(actor, new Point3D(0, -1, 0));
if (teleporterPadFakeGlobalPos != actorPos)
{
Server.ChatManager.SendActorMessage("You have to stand on the Teleporter platform to use the Teleporter!", actor);
return;
}
//Get TargetTeleporterPos
Point3D TargetTeleporterFakeGlobalPos = nearbyTeleporter.GetTargetTeleporter();
//Check if TargetTeleporter exists
//Get Chunk where the TargetTeleporter is in
IChunk targetChunk = new Object() as IChunk;
if (SNScriptUtils._Utils.getChunkObjFromFakeGlobalPos(TargetTeleporterFakeGlobalPos, ChunkDictionary, out targetChunk))
{
Point3D TargetTeleporterLocalPos = new Point3D(
TargetTeleporterFakeGlobalPos.X - (int)targetChunk.Position.X,
TargetTeleporterFakeGlobalPos.Y - (int)targetChunk.Position.Y,
TargetTeleporterFakeGlobalPos.Z - (int)targetChunk.Position.Z
);
ushort targetBlockID = new ushort();
targetBlockID = targetChunk.Blocks[targetChunk.GetBlockIndex(TargetTeleporterLocalPos.X, TargetTeleporterLocalPos.Y, TargetTeleporterLocalPos.Z)];
if ((targetBlockID) == (ushort)7100) //TargetTeleporter still exists!
{
ISpecialBlock targetSpecialBlock = targetChunk.GetSpecialBlocks().FirstOrDefault(item => (item is Teleporter) && ((item as Teleporter).Position == TargetTeleporterLocalPos));
Teleporter targetTeleporter = targetSpecialBlock as Teleporter;
//Teleport Player to TargetTeleporterPos + Offset (2.1 Blocks Up (Y)) or he'd get stuck in the Teleporter
double playerTeleportLocalPosY = (double)targetTeleporter.Position.Y + 2.1;
DoubleVector3 playerTeleportLocalPos = new DoubleVector3((double)targetTeleporter.Position.X, playerTeleportLocalPosY, (double)targetTeleporter.Position.Z);
actor.SetLocalPosition(targetChunk.ID, targetChunk.World, playerTeleportLocalPos);
}
else
{
if (debug) { Console.WriteLine("TargetTeleporter does not exist anymore, other block ID found: " + ((int)targetBlockID).ToString()); };
if (debug) { Console.WriteLine("I've been looking at Position: " + TargetTeleporterLocalPos.ToString()); };
Server.ChatManager.SendActorMessage("The Teleporter you wanted to teleport to, does not exist anymore!", actor);
nearbyTeleporter.DeleteTargetTeleporter();
return;
}
}
else
{
if (debug) { Console.WriteLine("Chunk does not exist! Pos: " + TargetTeleporterFakeGlobalPos.ToString()); };
Server.ChatManager.SendActorMessage("The Teleporter you wanted to teleport to, does not exist anymore!", actor);
nearbyTeleporter.DeleteTargetTeleporter();
return;
}
}