Location.java 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. /*
  2. * This program is free software: you can redistribute it and/or modify it under
  3. * the terms of the GNU General Public License as published by the Free Software
  4. * Foundation, either version 3 of the License, or (at your option) any later
  5. * version.
  6. *
  7. * This program is distributed in the hope that it will be useful, but WITHOUT
  8. * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  9. * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  10. * details.
  11. *
  12. * You should have received a copy of the GNU General Public License along with
  13. * this program. If not, see <http://www.gnu.org/licenses/>.
  14. */
  15. package com.l2jserver.gameserver.model;
  16. import com.l2jserver.gameserver.model.actor.L2Character;
  17. public final class Location
  18. {
  19. private final int _x;
  20. private final int _y;
  21. private final int _z;
  22. private int _heading;
  23. private int _instanceId;
  24. public Location(int x, int y, int z)
  25. {
  26. _x = x;
  27. _y = y;
  28. _z = z;
  29. _instanceId = -1;
  30. }
  31. public Location(int x, int y, int z, int heading)
  32. {
  33. _x = x;
  34. _y = y;
  35. _z = z;
  36. _heading = heading;
  37. _instanceId = -1;
  38. }
  39. public Location(int x, int y, int z, int heading, int instanceId)
  40. {
  41. _x = x;
  42. _y = y;
  43. _z = z;
  44. _heading = heading;
  45. _instanceId = instanceId;
  46. }
  47. public Location(L2Object obj)
  48. {
  49. _x = obj.getX();
  50. _y = obj.getY();
  51. _z = obj.getZ();
  52. _instanceId = obj.getInstanceId();
  53. }
  54. public Location(L2Character obj)
  55. {
  56. _x = obj.getX();
  57. _y = obj.getY();
  58. _z = obj.getZ();
  59. _heading = obj.getHeading();
  60. _instanceId = obj.getInstanceId();
  61. }
  62. public int getX()
  63. {
  64. return _x;
  65. }
  66. public int getY()
  67. {
  68. return _y;
  69. }
  70. public int getZ()
  71. {
  72. return _z;
  73. }
  74. public int getHeading()
  75. {
  76. return _heading;
  77. }
  78. public int getInstanceId()
  79. {
  80. return _instanceId;
  81. }
  82. @Override
  83. public String toString()
  84. {
  85. return "[" + getClass().getSimpleName() + "] X: " + _x + " Y: " + _y + " Z: " + _z + " Heading: " + _heading + " InstanceId: " + _instanceId;
  86. }
  87. /**
  88. * @param instanceId the instance Id to set
  89. */
  90. public void setInstanceId(int instanceId)
  91. {
  92. _instanceId = instanceId;
  93. }
  94. }