Location.java 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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. _heading = obj.getHeading();
  57. _instanceId = obj.getInstanceId();
  58. }
  59. public Location(L2Character obj)
  60. {
  61. _x = obj.getX();
  62. _y = obj.getY();
  63. _z = obj.getZ();
  64. _heading = obj.getHeading();
  65. _instanceId = obj.getInstanceId();
  66. }
  67. public int getX()
  68. {
  69. return _x;
  70. }
  71. public int getY()
  72. {
  73. return _y;
  74. }
  75. public int getZ()
  76. {
  77. return _z;
  78. }
  79. public int getHeading()
  80. {
  81. return _heading;
  82. }
  83. public int getInstanceId()
  84. {
  85. return _instanceId;
  86. }
  87. @Override
  88. public String toString()
  89. {
  90. return "[" + getClass().getSimpleName() + "] X: " + _x + " Y: " + _y + " Z: " + _z + " Heading: " + _heading + " InstanceId: " + _instanceId;
  91. }
  92. /**
  93. * @param instanceId the instance Id to set
  94. */
  95. public void setInstanceId(int instanceId)
  96. {
  97. _instanceId = instanceId;
  98. }
  99. }