Advertisement
Guest User

RouteFinder.Java

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