armark1ng

Untitled

May 28th, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.93 KB | None | 0 0
  1. package com.rs.game.route;
  2.  
  3. /**
  4. * Route finder, designed for single-threaded usage.
  5. * @author Mangis
  6. */
  7. public class RouteFinder {
  8.  
  9. /**
  10. * Standart walk route finder type.
  11. */
  12. public static final int WALK_ROUTEFINDER = 0;
  13.  
  14. /**
  15. * Last routefinder that was used.
  16. */
  17. private static int lastUsed;
  18.  
  19. /**
  20. * Find's route using given strategy.
  21. * Returns amount of steps found.
  22. * If steps > 0, route exists.
  23. * If steps = 0, route exists, but no need to move.
  24. * If steps < 0, route does not exist.
  25. */
  26. public static int findRoute(int type, int srcX, int srcY, int srcZ, int srcSizeXY, RouteStrategy strategy, boolean findAlternative) {
  27. switch (lastUsed = type) {
  28. case WALK_ROUTEFINDER:
  29. return WalkRouteFinder.findRoute(srcX, srcY, srcZ, srcSizeXY, strategy, findAlternative);
  30. default:
  31. throw new RuntimeException("Unknown routefinder type.");
  32. }
  33. }
  34.  
  35.  
  36. /**
  37. * Get's last path buffer x.
  38. * Modifying the buffer in any way is prohibited.
  39. */
  40. public static int[] getLastPathBufferX() {
  41. switch (lastUsed) {
  42. case WALK_ROUTEFINDER:
  43. return WalkRouteFinder.getLastPathBufferX();
  44. default:
  45. throw new RuntimeException("Unknown routefinder type.");
  46. }
  47. }
  48.  
  49. /**
  50. * Get's last path buffer y.
  51. * Modifying the buffer in any way is prohibited.
  52. */
  53. public static int[] getLastPathBufferY() {
  54. switch (lastUsed) {
  55. case WALK_ROUTEFINDER:
  56. return WalkRouteFinder.getLastPathBufferY();
  57. default:
  58. throw new RuntimeException("Unknown routefinder type.");
  59. }
  60. }
  61.  
  62. /**
  63. * Whether last path is only alternative path.
  64. */
  65. public static boolean lastIsAlternative() {
  66. switch (lastUsed) {
  67. case WALK_ROUTEFINDER:
  68. return WalkRouteFinder.lastIsAlternative();
  69. default:
  70. throw new RuntimeException("Unknown routefinder type.");
  71. }
  72. }
  73.  
  74. }
Advertisement
Add Comment
Please, Sign In to add comment