Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches

◆ Teleport()

static void Terraria.Wiring.Teleport ( )
inlinestaticprivate

Definition at line 2776 of file Wiring.cs.

2777 {
2778 if (_teleport[0].X < _teleport[1].X + 3f && _teleport[0].X > _teleport[1].X - 3f && _teleport[0].Y > _teleport[1].Y - 3f && _teleport[0].Y < _teleport[1].Y)
2779 {
2780 return;
2781 }
2782 Rectangle[] array = new Rectangle[2];
2783 array[0].X = (int)(_teleport[0].X * 16f);
2784 array[0].Width = 48;
2785 array[0].Height = 48;
2786 array[0].Y = (int)(_teleport[0].Y * 16f - (float)array[0].Height);
2787 array[1].X = (int)(_teleport[1].X * 16f);
2788 array[1].Width = 48;
2789 array[1].Height = 48;
2790 array[1].Y = (int)(_teleport[1].Y * 16f - (float)array[1].Height);
2791 for (int i = 0; i < 2; i++)
2792 {
2793 Vector2 vector = new Vector2(array[1].X - array[0].X, array[1].Y - array[0].Y);
2794 if (i == 1)
2795 {
2796 vector = new Vector2(array[0].X - array[1].X, array[0].Y - array[1].Y);
2797 }
2799 {
2800 for (int j = 0; j < 255; j++)
2801 {
2802 if (Main.player[j].active && !Main.player[j].dead && !Main.player[j].teleporting && TeleporterHitboxIntersects(array[i], Main.player[j].Hitbox))
2803 {
2804 Vector2 vector2 = Main.player[j].position + vector;
2805 Main.player[j].teleporting = true;
2806 if (Main.netMode == 2)
2807 {
2808 RemoteClient.CheckSection(j, vector2);
2809 }
2810 Main.player[j].Teleport(vector2);
2811 if (Main.netMode == 2)
2812 {
2813 NetMessage.SendData(65, -1, -1, null, 0, j, vector2.X, vector2.Y);
2814 }
2815 }
2816 }
2817 }
2818 for (int k = 0; k < 200; k++)
2819 {
2820 if (Main.npc[k].active && !Main.npc[k].teleporting && Main.npc[k].lifeMax > 5 && !Main.npc[k].boss && !Main.npc[k].noTileCollide)
2821 {
2822 int type = Main.npc[k].type;
2823 if (!NPCID.Sets.TeleportationImmune[type] && TeleporterHitboxIntersects(array[i], Main.npc[k].Hitbox))
2824 {
2825 Main.npc[k].teleporting = true;
2826 Main.npc[k].Teleport(Main.npc[k].position + vector);
2827 }
2828 }
2829 }
2830 }
2831 for (int l = 0; l < 255; l++)
2832 {
2833 Main.player[l].teleporting = false;
2834 }
2835 for (int m = 0; m < 200; m++)
2836 {
2837 Main.npc[m].teleporting = false;
2838 }
2839 }
static bool[] TeleportationImmune
Definition NPCID.cs:4168
static bool TeleporterHitboxIntersects(Rectangle teleporter, Rectangle entity)
Definition Wiring.cs:2841
static Vector2[] _teleport
Definition Wiring.cs:37
static bool blockPlayerTeleportationForOneIteration
Definition Wiring.cs:15

References System.array, Terraria.RemoteClient.CheckSection(), Terraria.Main.netMode, Terraria.Main.npc, Terraria.Main.player, Terraria.NetMessage.SendData(), Terraria.ID.NPCID.Sets.TeleportationImmune, System.type, Microsoft.Xna.Framework.Rectangle.X, System.X, and System.Y.

Referenced by Terraria.Wiring.TripWire().