/// <summary> /// Move to the specified cell (Fight). /// </summary> private bool MoveToCell(int cellId) { if (cellId != m_Data.Fighter.CellId) { if (!(m_Data.IsCellWalkable(cellId))) { int num = -1; int num2 = 5000; MapPoint point = new MapPoint(m_Data.Fighter.CellId); MapPoint point2 = new MapPoint(cellId); int direction = 1; while (true) { MapPoint nearestCellInDirection = point2.GetNearestCellInDirection(direction, 1); if (m_Data.IsCellWalkable(nearestCellInDirection.CellId)) { int num4 = point.DistanceToCell(nearestCellInDirection); if (num4 < num2) { num2 = num4; num = nearestCellInDirection.CellId; } } direction = (direction + 2); if (direction > 7) { if (num == -1) { return(false); } cellId = num; break; } } } SimplePathfinder pathfinder = new SimplePathfinder(m_Account.MapData); pathfinder.SetFight(m_Data.Fighters, m_Data.Fighter.MovementPoints); MovementPath path = pathfinder.FindPath(m_Data.Fighter.CellId, cellId); if (path != null) { List <UInt32> serverMovement = MapMovementAdapter.GetServerMovement(path); using (BigEndianWriter writer = new BigEndianWriter()) { GameMapMovementRequestMessage msg = new GameMapMovementRequestMessage(serverMovement.ToList().Select <uint, short>(ui => (short)ui).ToArray(), m_Account.MapData.Id); msg.Serialize(writer); writer.Content = m_Account.HumanCheck.hash_function(writer.Content); MessagePackaging pack = new MessagePackaging(writer); pack.Pack((int)msg.ProtocolID); flag = 0; m_Account.SocketManager.Send(pack.Writer.Content); if (m_Account.DebugMode.Checked) { m_Account.Log(new DebugTextInformation("[SND] 950 (GameMapMovementRequestMessage)"), 0); } } return(true); } } return(false); }
public ICellMovement MoveToCell(int cellId) { if (cellId == Fighter.CellId) { return(null); } if (!IsCellWalkable(cellId)) { var num = -1; var num2 = 5000; var point = new MapPoint(Fighter.CellId); var point2 = new MapPoint(cellId); var direction = 1; while (true) { var nearestCellInDirection = point2.GetNearestCellInDirection(direction, 1); if (IsCellWalkable(nearestCellInDirection.CellId)) { var num4 = point.DistanceToCell(nearestCellInDirection); if (num4 < num2) { num2 = num4; num = nearestCellInDirection.CellId; } } direction += 2; if (direction <= 7) { continue; } if (num == -1) { return(null); } cellId = num; break; } } var pathfinder = new SimplePathfinder((API.Gamedata.D2p.Map)Account.Character.Map.Data); pathfinder.SetFight(Fighters, Fighter.MovementPoints); var path = pathfinder.FindPath(Fighter.CellId, cellId); return(path == null ? null : new CellMovement(Account, path)); }