Location.java 2.3 KB

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