internal void StartPipeMovement(Vector2 destination, TeleportType tptype) { this.collidable = false; this.destination = destination; this.teleportType = tptype; Start_First_Pipe_Movement(); }
private void MarioEndPipe() { Timer_Second = null; this.collidable = true; velocityY = 0; teleportType = TeleportType.None; }
public void SettingWarp(TeleportType teleportType) { IsLockMovement = true; IsLockMagic = true; float _temp = 0; if (isVRPlayer) { _temp = vrEyeObject.transform.rotation.eulerAngles.y; } else { _temp = nowPlayerController.transform.rotation.eulerAngles.y; } warpObjects.transform.rotation = Quaternion.Euler(0, _temp, 0); catleObjects.SetActive(false); warpObjects.SetActive(true); cityObjects.SetActive(false); nowPlayerController.StopMove(); nowPlayerController.SettingWarp(warpScenePoint); warpEffectController.WarpSequence(teleportType); }
internal void BotBotPipeMove(Vector2 destination) { this.collidable = false; this.destination = destination; Start_First_Pipe_Movement(); teleportType = TeleportType.Bot_Bot; }
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); }
public RecallInf(int netid, TeleportStatus stat, TeleportType tpe, int dura, int star = 0) { NetworkID = netid; Status = stat; Type = tpe; Duration = dura; Start = star; }
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>(); }
private int CheckTrigger(bool isAuto, TeleportType type) { int len = teleports.Count; for (int i = 0; i < len; i++) { if (teleports[i].IsAuto == isAuto && (teleports[i].type & type) != TeleportType.None) { return(i); } } return(-1); }
private IEnumerator WarpRoutine(TeleportType teleportType) { StartWarpEffect(); yield return(StartCoroutine(AccelWarpEffect())); if (teleportType == TeleportType.City) { GameManager.Instance.SettingCity(); } else if (teleportType == TeleportType.Catle) { GameManager.Instance.SettingCatle(); } }
public static void AddTeleport(int from, int to, TeleportType type) { Pipe FromPipe = pipes[from]; Pipe ToPipe = pipes[to]; foreach (var item in pipes) { // Console.WriteLine(item.Key + " " + item.Value.number); } switch (type) { case TeleportType.Top_Top: FromPipe.TopActive = true; ToPipe.TopActive = true; FromPipe.TP_TOP_destination = new Vector2(ToPipe.rectangle.X, ToPipe.rectangle.Y); ToPipe.TP_TOP_destination = new Vector2(FromPipe.rectangle.X, FromPipe.rectangle.Y); FromPipe.top_tp_type = TeleportType.Top_Top; ToPipe.top_tp_type = TeleportType.Top_Top; break; case TeleportType.Top_Bot: FromPipe.TopActive = true; ToPipe.BotActive = true; FromPipe.TP_TOP_destination = new Vector2(ToPipe.rectangle.X, ToPipe.rectangle.Bot); ToPipe.TP_BOT_destination = new Vector2(FromPipe.rectangle.X, FromPipe.rectangle.Y); FromPipe.top_tp_type = TeleportType.Top_Bot; ToPipe.bot_tp_type = TeleportType.Bot_Top; break; case TeleportType.Bot_Bot: FromPipe.BotActive = true; ToPipe.BotActive = true; FromPipe.TP_BOT_destination = new Vector2(ToPipe.rectangle.X, ToPipe.rectangle.Bot); ToPipe.TP_BOT_destination = new Vector2(FromPipe.rectangle.X, FromPipe.rectangle.Bot); FromPipe.bot_tp_type = TeleportType.Bot_Bot; ToPipe.bot_tp_type = TeleportType.Bot_Bot; break; case TeleportType.Bot_Top: FromPipe.BotActive = true; ToPipe.TopActive = true; FromPipe.TP_BOT_destination = new Vector2(ToPipe.rectangle.X, ToPipe.rectangle.Y); ToPipe.TP_TOP_destination = new Vector2(FromPipe.rectangle.X, FromPipe.rectangle.Bot); FromPipe.bot_tp_type = TeleportType.Bot_Top; ToPipe.top_tp_type = TeleportType.Top_Bot; break; } }
public void TeleportToTarget(TeleportType teleportType) { if (CheckForErroredRagdoll("TeleportToTarget")) { return; } // if we're teleporting non physics bones, start looping after their indicies int startIndex = teleportType == TeleportType.SecondaryNonPhysicsBones || teleportType == TeleportType.PhysicsParents ? bonesCount : 0; // set the ending index for the loop int endIndex = teleportType == TeleportType.PhysicsBones ? bonesCount : allElements.Length; for (int i = startIndex; i < endIndex; i++) { bool teleportBone = false; switch (teleportType) { case TeleportType.All: teleportBone = true; break; case TeleportType.PhysicsBones: teleportBone = allElements[i].isPhysicsBone; break; case TeleportType.PhysicsParents: teleportBone = allElements[i].isPhysicsParent; break; case TeleportType.PhysicsBonesAndParents: teleportBone = allElements[i].isPhysicsBone || allElements[i].isPhysicsParent; break; case TeleportType.SecondaryNonPhysicsBones: teleportBone = !allElements[i].isPhysicsBone && !allElements[i].isPhysicsParent; break; } if (teleportBone) { allElements[i].TeleportToTarget(); } } }
public void WarpSequence(TeleportType teleportType) { StartCoroutine(WarpRoutine(teleportType)); }
public TeleportAct(CreatureAI creature) : base(creature) { Name = "Teleport"; Type = TeleportType.Jump; }
public TeleportFixup(TeleportType tp, int idx, TeleData to) { this.Type = tp; this.Index = idx; this.To = to; }
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; }
public TeleportEventArgs(int unitNetworkId, TeleportStatus status, TeleportType type) { _unitNetworkId = unitNetworkId; _status = status; _type = type; }
internal void Teleport(IRocketPlayer caller, TeleportType teleportType, ulong ulSteamID) { if (StructureManager.regions.LongLength == 0 && BarricadeManager.BarricadeRegions.LongLength == 0) { UnturnedChat.Say(caller, Translate("wreckingball_map_clear")); return; } UnturnedPlayer player = (UnturnedPlayer)caller; Vector3 tpVector; bool match = false; int tries = 0; int x = 0; int xCount = 0; int z = 0; int zCount = 0; int idx = 0; int idxCount = 0; Transform current = null; List <Destructible> items = new List <Destructible>(); // Steam id matching. if (ulSteamID != 0) { switch (teleportType) { case TeleportType.Structures: xCount = StructureManager.regions.GetLength(0); zCount = StructureManager.regions.GetLength(1); for (x = 0; x < xCount; x++) { for (z = 0; z < zCount; z++) { idxCount = StructureManager.regions[x, z].drops.Count; for (int k = 0; k < idxCount; k++) { if (StructureManager.regions[x, z].structures[k].owner == ulSteamID) { items.Add(new Destructible(StructureManager.regions[x, z].drops[k].model, ElementType.Structure, StructureManager.regions[x, z].structures[k].structure.id)); } } } } if (items.Count > 0) { idx = UnityEngine.Random.Range(0, items.Count - 1); try { current = items[idx].Transform; match = true; } catch { } } break; case TeleportType.Barricades: xCount = BarricadeManager.regions.GetLength(0); zCount = BarricadeManager.regions.GetLength(1); for (x = 0; x < xCount; x++) { for (z = 0; z < zCount; z++) { idxCount = BarricadeManager.regions[x, z].drops.Count; for (int k = 0; k < idxCount; k++) { if (BarricadeManager.regions[x, z].barricades[k].owner == ulSteamID) { items.Add(new Destructible(BarricadeManager.regions[x, z].drops[k].model, ElementType.Barricade, BarricadeManager.regions[x, z].barricades[k].barricade.id)); } } } } if (items.Count > 0) { idx = UnityEngine.Random.Range(0, items.Count - 1); try { current = items[idx].Transform; match = true; } catch { } } break; case TeleportType.Vehicles: int vCount = VehicleManager.vehicles.Count; for (x = 0; x < vCount; x++) { if (VehicleManager.vehicles[x].isLocked && (ulong)VehicleManager.vehicles[x].lockedOwner == ulSteamID) { Logger.Log(VehicleManager.vehicles[x].lockedOwner.ToString() + ":" + VehicleManager.vehicles[x].instanceID.ToString()); items.Add(new Destructible(VehicleManager.vehicles[x].transform, ElementType.Vehicle, VehicleManager.vehicles[x].id, VehicleManager.vehicles[x])); } } if (items.Count > 0) { idx = UnityEngine.Random.Range(0, items.Count - 1); Logger.Log(idx.ToString()); try { current = items[idx].Transform; match = true; } catch { } } break; } } // Standard random search. else { while (tries < 2000 && !match) { tries++; switch (teleportType) { case TeleportType.Structures: xCount = StructureManager.regions.GetLength(0); zCount = StructureManager.regions.GetLength(1); if (xCount == 0) { continue; } x = UnityEngine.Random.Range(0, xCount - 1); if (zCount == 0) { continue; } z = UnityEngine.Random.Range(0, zCount - 1); idxCount = StructureManager.regions[x, z].structures.Count; if (idxCount == 0) { continue; } idx = UnityEngine.Random.Range(0, idxCount - 1); try { current = StructureManager.regions[x, z].drops[idx].model; } catch { continue; } if (Vector3.Distance(current.position, player.Position) > 20) { match = true; } break; case TeleportType.Barricades: xCount = BarricadeManager.BarricadeRegions.GetLength(0); zCount = BarricadeManager.BarricadeRegions.GetLength(1); if (xCount == 0) { continue; } x = UnityEngine.Random.Range(0, xCount - 1); if (zCount == 0) { continue; } z = UnityEngine.Random.Range(0, zCount - 1); idxCount = BarricadeManager.BarricadeRegions[x, z].drops.Count; if (idxCount == 0) { continue; } idx = UnityEngine.Random.Range(0, idxCount - 1); try { current = BarricadeManager.BarricadeRegions[x, z].drops[idx].model; } catch { continue; } if (Vector3.Distance(current.position, player.Position) > 20) { match = true; } break; case TeleportType.Vehicles: int vCount = VehicleManager.vehicles.Count; int vRand = UnityEngine.Random.Range(0, vCount - 1); try { current = VehicleManager.vehicles[vRand].transform; } catch { continue; } if (Vector3.Distance(current.position, player.Position) > 20) { match = true; } break; default: return; } } } if (match) { tpVector = new Vector3(current.position.x, teleportType == TeleportType.Vehicles ? current.position.y + 4 : current.position.y + 2, current.position.z); player.Teleport(tpVector, player.Rotation); return; } UnturnedChat.Say(caller, Translate("wreckingball_teleport_not_found")); }
public TeleportAlias(string alias, string aetheryte, TeleportType type = TeleportType.Direct) { Alias = alias; Aetheryte = aetheryte; TeleportType = type; }
public TeleportEventArgs(TSPlayer player, Vector2 toLocation, TeleportType teleportType) : base(player) { this.ToLocation = toLocation; this.TeleportType = teleportType; }
private void NetHooks_GetData(GetDataEventArgs e) { if (e == null || this.isDisposed || e.Handled) { return; } TSPlayer player = TShock.Players[e.Msg.whoAmI]; if (player == null) { return; } try { switch (e.MsgID) { case PacketTypes.Tile: { if (this.TileEdit == null) { break; } int editType = e.Msg.readBuffer[e.Index]; int x = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 1); int y = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 3); if (!TerrariaUtils.Tiles.IsValidCoord(x, y) || editType > 14) { return; } int blockType = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 5); int objectStyle = e.Msg.readBuffer[e.Index + 7]; e.Handled = this.OnTileEdit( new TileEditEventArgs(player, (TileEditType)editType, new DPoint(x, y), (BlockType)blockType, objectStyle )); break; } case PacketTypes.PlaceObject: { if (this.ObjectPlacement == null && this.TileEdit == null) { break; } int x = BitConverter.ToInt16(e.Msg.readBuffer, e.Index); int y = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 2); if (!TerrariaUtils.Tiles.IsValidCoord(x, y)) { return; } int blockType = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 4); int objectStyle = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 6); int alternative = e.Msg.readBuffer[e.Index + 8]; int random = ((sbyte)e.Msg.readBuffer[e.Index + 9]); bool direction = BitConverter.ToBoolean(e.Msg.readBuffer, e.Index + 10); if (this.InvokeTileOnObjectPlacement) { e.Handled = this.OnTileEdit( new TileEditEventArgs(player, TileEditType.PlaceTile, new DPoint(x, y), (BlockType)blockType, objectStyle )); } if (!e.Handled) { e.Handled = this.OnObjectPlacement( new ObjectPlacementEventArgs(player, new DPoint(x, y), (BlockType)blockType, objectStyle, alternative, random, direction )); } break; } // Note: As for TileKill and TileKillNoItem, blockId will be of "1" if the player attempted to destroy // a tile but didn't succeed yet, and will be of "0" as the tile is actually destroyed. // However, there's one exception with Chests, they will never send their actual destroy packet, except a hack // tool is used, it seems. case PacketTypes.TileKill: { int type = e.Msg.readBuffer[e.Index]; int x = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 1); int y = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 3); if (!TerrariaUtils.Tiles.IsValidCoord(x, y)) { break; } int style = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 5); if (type == 0 || type == 2) // Chest placement / Dresser Placement { e.Handled = this.OnChestPlace(new ChestPlaceEventArgs(player, new DPoint(x, y), type, style)); } else // Chest kill { int tileType = TerrariaUtils.Tiles[x, y].type; if (tileType != TileID.Containers && tileType != TileID.Dressers) { break; } if (this.InvokeTileEditOnChestKill) { e.Handled = this.OnTileEdit(new TileEditEventArgs(player, TileEditType.TileKill, new DPoint(x, y), 0, 0)); } if (!e.Handled) { e.Handled = this.OnChestKill(new TileLocationEventArgs(player, new DPoint(x, y))); } } break; } case PacketTypes.ChestOpen: { if (this.ChestOpen == null && this.ChestRename == null) { break; } int chestIndex = BitConverter.ToInt16(e.Msg.readBuffer, e.Index); int x = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 2); int y = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 4); if (!TerrariaUtils.Tiles.IsValidCoord(x, y)) { break; } int nameLength = e.Msg.readBuffer[e.Index + 6]; string newName = string.Empty; if ((nameLength > 0 && nameLength <= 20) || nameLength == 255) // Name change requested? { if (nameLength != 255) { newName = Encoding.UTF8.GetString(e.Msg.readBuffer, e.Index + 8, nameLength); } e.Handled = this.OnChestRename(new ChestRenameEventArgs(player, chestIndex, newName)); } if (!e.Handled) { e.Handled = this.OnChestOpen(new ChestOpenEventArgs(player, chestIndex, new DPoint(x, y))); } break; } case PacketTypes.ChestGetContents: { if (this.ChestGetContents == null) { break; } int x = BitConverter.ToInt16(e.Msg.readBuffer, e.Index); int y = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 2); if (!TerrariaUtils.Tiles.IsValidCoord(x, y) || !Main.tile[x, y].active()) { return; } e.Handled = this.OnChestGetContents(new TileLocationEventArgs(player, new DPoint(x, y))); break; } case PacketTypes.ChestItem: { if (this.ChestModifySlot == null) { break; } int chestIndex = BitConverter.ToInt16(e.Msg.readBuffer, e.Index); int slotIndex = e.Msg.readBuffer[e.Index + 2]; int itemStackSize = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 3); ItemPrefix itemPrefix = (ItemPrefix)e.Msg.readBuffer[e.Index + 5]; ItemType itemType = (ItemType)BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 6); if (chestIndex >= Main.chest.Length || slotIndex > 39) { break; } e.Handled = this.OnChestModifySlot(new ChestModifySlotEventArgs( player, chestIndex, slotIndex, new ItemData(itemPrefix, itemType, itemStackSize) )); break; } case PacketTypes.SignNew: { if (this.SignEdit == null) { break; } int signIndex = BitConverter.ToInt16(e.Msg.readBuffer, e.Index); int x = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 2); int y = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 4); string newText; using (MemoryStream stream = new MemoryStream(e.Msg.readBuffer, e.Index + 6, e.Length - 7)) newText = new BinaryReader(stream).ReadString(); if (!TerrariaUtils.Tiles.IsValidCoord(x, y) || !Main.tile[x, y].active()) { return; } e.Handled = this.OnSignEdit(new SignEditEventArgs(player, signIndex, new DPoint(x, y), newText)); break; } case PacketTypes.SignRead: { if (this.SignRead == null) { break; } int x = BitConverter.ToInt16(e.Msg.readBuffer, e.Index); int y = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 2); if (!TerrariaUtils.Tiles.IsValidCoord(x, y)) { break; } e.Handled = this.OnSignRead(new TileLocationEventArgs(player, new DPoint(x, y))); break; } case PacketTypes.HitSwitch: { if (this.HitSwitch == null) { break; } int x = BitConverter.ToInt16(e.Msg.readBuffer, e.Index); int y = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 2); if (!TerrariaUtils.Tiles.IsValidCoord(x, y) || !Main.tile[x, y].active()) { return; } // For some reason, TShock doesn't handle this packet so we just do our own checks. if (TShock.CheckIgnores(player)) { return; } if (TShock.CheckRangePermission(player, x, y, 32)) { return; } e.Handled = this.OnHitSwitch(new TileLocationEventArgs(player, new DPoint(x, y))); break; } case PacketTypes.SpawnBossorInvasion: { if (this.BossSpawn == null) { break; } //int playerIndex = BitConverter.ToInt32(e.Msg.readBuffer, e.Index); int bossType = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 2); e.Handled = this.OnBossSpawn(new BossSpawnEventArgs(player, (BossType)bossType)); break; } case PacketTypes.ItemDrop: case PacketTypes.UpdateItemDrop: { // ItemDrop2 if (this.ItemUpdate == null) { break; } int itemIndex = BitConverter.ToInt16(e.Msg.readBuffer, e.Index); float x = BitConverter.ToSingle(e.Msg.readBuffer, e.Index + 2); float y = BitConverter.ToSingle(e.Msg.readBuffer, e.Index + 6); float velocityX = BitConverter.ToSingle(e.Msg.readBuffer, e.Index + 10); float velocityY = BitConverter.ToSingle(e.Msg.readBuffer, e.Index + 14); int itemStackSize = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 18); ItemPrefix itemPrefix = (ItemPrefix)e.Msg.readBuffer[e.Index + 20]; bool noDelay = (e.Msg.readBuffer[e.Index + 21] != 0); ItemType itemType = (ItemType)BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 22); // If it is actually an item pick up, then ensure a valid item index. if (itemType == 0 && (itemIndex < 0 || itemIndex >= Main.item.Length)) { break; } e.Handled = this.OnItemUpdate(new ItemUpdateEventArgs( player, itemIndex, new Vector2(x, y), new Vector2(velocityX, velocityY), noDelay, new ItemData(itemPrefix, itemType, itemStackSize) )); break; } case PacketTypes.ItemOwner: { if (this.ItemOwner == null) { break; } int itemIndex = BitConverter.ToInt16(e.Msg.readBuffer, e.Index); int newOwnerPlayerIndex = e.Msg.readBuffer[e.Index + 2]; TSPlayer newOwner; if (newOwnerPlayerIndex < 255) { newOwner = TShock.Players[newOwnerPlayerIndex]; } else { break; } e.Handled = this.OnItemOwner(new ItemOwnerEventArgs(player, itemIndex, newOwner)); break; } case PacketTypes.ForceItemIntoNearestChest: { // QuickStackNearby if (this.QuickStackNearby == null) { break; } int slotIndex = e.Msg.readBuffer[e.Index]; if (slotIndex >= TSPlayer.Server.TPlayer.inventory.Length) { break; } e.Handled = this.OnQuickStackNearby(new PlayerSlotEventArgs(player, slotIndex)); break; } case PacketTypes.PlayerSlot: { if (this.PlayerModifySlot == null) { break; } //byte playerIndex = e.Msg.readBuffer[e.Index]; int slotIndex = e.Msg.readBuffer[e.Index + 1]; int itemStackSize = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 2); ItemPrefix itemPrefix = (ItemPrefix)e.Msg.readBuffer[e.Index + 4]; ItemType itemType = (ItemType)BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 5); Player tServerPlayer = TSPlayer.Server.TPlayer; if (slotIndex >= tServerPlayer.inventory.Length + tServerPlayer.bank.item.Length + tServerPlayer.bank2.item.Length) { break; } e.Handled = this.OnPlayerModifySlot(new PlayerModifySlotEventArgs( player, slotIndex, new ItemData(itemPrefix, itemType, itemStackSize) )); break; } case PacketTypes.LiquidSet: { if (this.LiquidSet == null) { break; } int x = BitConverter.ToInt16(e.Msg.readBuffer, e.Index); int y = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 2); if (!TerrariaUtils.Tiles.IsValidCoord(x, y)) { break; } int liquidAmount = e.Msg.readBuffer[e.Index + 4]; LiquidKind liquidKind = (LiquidKind)e.Msg.readBuffer[e.Index + 5]; e.Handled = this.OnLiquidSet(new LiquidSetEventArgs(player, new DPoint(x, y), liquidAmount, liquidKind)); break; } case PacketTypes.DoorUse: { if (this.DoorUse == null) { break; } byte action = e.Msg.readBuffer[e.Index]; int x = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 1); int y = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 3); if (!TerrariaUtils.Tiles.IsValidCoord(x, y)) { break; } int direction = e.Msg.readBuffer[e.Index + 5]; Direction actualDirection = Direction.Right; if (direction == 0) { actualDirection = Direction.Left; } e.Handled = this.OnDoorUse(new DoorUseEventArgs(player, new DPoint(x, y), (DoorAction)action, actualDirection)); break; } case PacketTypes.PlayerSpawn: { if (this.PlayerSpawn == null) { break; } int playerIndex = e.Msg.readBuffer[e.Index]; int spawnX = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 1); int spawnY = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 3); if (!TerrariaUtils.Tiles.IsValidCoord(spawnX, spawnY)) { break; } e.Handled = this.OnPlayerSpawn(new PlayerSpawnEventArgs(player, new DPoint(spawnX, spawnY))); break; } // Note: Also door unlock case PacketTypes.ChestUnlock: { if (this.ChestUnlock == null) { break; } UnlockType unlockType = (UnlockType)e.Msg.readBuffer[e.Index]; int chestX = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 1); int chestY = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 3); if (!TerrariaUtils.Tiles.IsValidCoord(chestX, chestY)) { break; } e.Handled = this.OnChestUnlock(new UnlockEventArgs(player, new DPoint(chestX, chestY), unlockType)); break; } case PacketTypes.ChatText: { if (this.ChatText == null) { break; } short playerIndex = e.Msg.readBuffer[e.Index]; if (playerIndex != e.Msg.whoAmI) { break; } int colorR = e.Msg.readBuffer[e.Index + 1]; int colorG = e.Msg.readBuffer[e.Index + 2]; int colorB = e.Msg.readBuffer[e.Index + 3]; string text = Encoding.UTF8.GetString(e.Msg.readBuffer, e.Index + 4, e.Length - 5); e.Handled = this.OnChatText(new ChatTextEventArgs(player, new Color(colorR, colorG, colorB), text)); break; } case PacketTypes.TileSendSquare: { if (this.SendTileSquare == null) { break; } int size = BitConverter.ToInt16(e.Msg.readBuffer, e.Index); int tileX = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 2); int tileY = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 4); if (!TerrariaUtils.Tiles.IsValidCoord(tileX, tileY)) { break; } e.Handled = this.OnSendTileSquare(new SendTileSquareEventArgs(player, new DPoint(tileX, tileY), size)); break; } case PacketTypes.PaintTile: { if (this.TilePaint == null) { break; } int tileX = BitConverter.ToInt16(e.Msg.readBuffer, e.Index); int tileY = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 2); if (!TerrariaUtils.Tiles.IsValidCoord(tileX, tileY)) { break; } int color = e.Msg.readBuffer[e.Index + 8]; e.Handled = this.OnTilePaint(new TilePaintEventArgs(player, new DPoint(tileX, tileY), (PaintColor)color)); break; } case PacketTypes.PlayerKillMe: { if (this.PlayerDeath == null) { break; } int playerIndex = e.Msg.readBuffer[e.Index]; int direction = e.Msg.readBuffer[e.Index + 1]; int dmg = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 2); bool pvp = e.Msg.readBuffer[e.Index + 4] != 0; string deathText = Encoding.UTF8.GetString(e.Msg.readBuffer, e.Index + 6, e.Length - 7); e.Handled = this.OnPlayerDeath(new PlayerDeathEventArgs(player, direction, dmg, pvp, deathText)); break; } case PacketTypes.Teleport: { if (this.Teleport == null) { break; } BitsByte flags = e.Msg.readBuffer[e.Index]; int playerIndex = BitConverter.ToInt16(e.Msg.readBuffer, e.Index + 1); float x = BitConverter.ToSingle(e.Msg.readBuffer, e.Index + 3); float y = BitConverter.ToSingle(e.Msg.readBuffer, e.Index + 7); Vector2 destLocation = new Vector2(x, y); TeleportType tpType = TeleportType.PlayerToPos; if (flags[0]) { tpType = TeleportType.NpcToPos; } if (flags[1]) { if (flags[0]) { tpType = TeleportType.Unknown; } else { tpType = TeleportType.PlayerNearPlayerWormhole; } } e.Handled = this.OnTeleport(new TeleportEventArgs(player, destLocation, tpType)); break; } } } catch (Exception ex) { ServerApi.LogWriter.PluginWriteLine( this.Plugin, string.Format("Internal error on handling data packet {0}. Exception details: \n{1}", e.MsgID, ex), TraceLevel.Error ); } }
public TeleportEventArgs(TSPlayer player, Vector2 toLocation, TeleportType teleportType) : base(player) { this.ToLocation = toLocation; this.TeleportType = teleportType; }
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>(); }