private void Shatter(Vector2 newPos, Player player) { try { player.grappling[0] = -1; player.grapCount = 0; for (int i = 0; i < 1000; i++) { if (Main.projectile[i].active && Main.projectile[i].owner == player.whoAmI && Main.projectile[i].aiStyle == 7) { Main.projectile[i].Kill(); } } float num = MathHelper.Clamp(1f - player.teleportTime * 0.99f, 0.01f, 1f); Vector2 position = player.position; ShatterEffect(player.getRect(), player.teleportTime); float num2 = Vector2.Distance(player.position, newPos); PressurePlateHelper.UpdatePlayerPosition(player); player.position = newPos; player.fallStart = (int)(player.position.Y / 16f); if (player.whoAmI == Main.myPlayer) { bool flag = false; if (num2 < new Vector2(Main.screenWidth, Main.screenHeight).Length() / 2f + 100f) { Main.SetCameraLerp(0.1f, 10); flag = true; } else { Main.BlackFadeIn = 255; Main.screenLastPosition = Main.screenPosition; Main.screenPosition.X = player.position.X + (float)(player.width / 2) - (float)(Main.screenWidth / 2); Main.screenPosition.Y = player.position.Y + (float)(player.height / 2) - (float)(Main.screenHeight / 2); } if (num > 0.1f || !flag) { if (Main.mapTime < 5) { Main.mapTime = 5; } Main.maxQ = true; } } PressurePlateHelper.UpdatePlayerPosition(player); for (int i = 0; i < 3; i++) { player.UpdateSocialShadow(); } player.oldPosition = player.position + player.BlehOldPositionFixer; ShatterEffect(player.getRect(), player.teleportTime); } catch { } }
/// <summary> /// Carbon copy of the vanilla Player.Teleport, without effects. Only handles basic code and effects, no netcode /// </summary> /// <param name="player">The player</param> /// <param name="newPos">The teleport position</param> public static void ClickerTeleport(this Player player, Vector2 newPos) { player.RemoveAllGrapplingHooks(); float distance = Vector2.Distance(player.Center, newPos); PressurePlateHelper.UpdatePlayerPosition(player); player.Center = newPos; player.fallStart = (int)(player.position.Y / 16f); if (player.whoAmI == Main.myPlayer) { bool offScreen = true; if (distance < new Vector2(Main.screenWidth, Main.screenHeight).Length() / 2f + 100f) { Main.SetCameraLerp(0.1f, 0); offScreen = false; } else { Main.BlackFadeIn = 255; Lighting.Clear(); Main.screenLastPosition = Main.screenPosition; Main.screenPosition = player.Center - new Vector2(Main.screenWidth / 2, Main.screenHeight / 2); Main.instantBGTransitionCounter = 10; } if (offScreen) { if (Main.mapTime < 5) { Main.mapTime = 5; } Main.maxQ = true; Main.renderNow = true; } } PressurePlateHelper.UpdatePlayerPosition(player); for (int j = 0; j < 3; j++) { player.UpdateSocialShadow(); } player.oldPosition = player.position + player.BlehOldPositionFixer; }
public void Handle(BinaryReader reader, int playerNumber) { if (Main.netMode == 1) { int plr = reader.ReadByte(); var pos = reader.ReadVector2(); var player = Main.player[plr]; player.grappling[0] = -1; player.grapCount = 0; Main.TeleportEffect(player.Hitbox, 0, 0, 1); PressurePlateHelper.UpdatePlayerPosition(player); player.position = pos; player.fallStart = player.fallStart2 = (int)(player.position.Y / 16f); PressurePlateHelper.UpdatePlayerPosition(player); Main.TeleportEffect(player.Hitbox, 0, 0, 1); for (int j = 0; j < 3; j++) { player.UpdateSocialShadow(); } player.oldPosition = player.position + player.BlehOldPositionFixer; } }