Tile.java 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157
  1. package me.hammerle.supersnuvi.tiles;
  2. import me.hammerle.supersnuvi.entity.Entity;
  3. import me.hammerle.supersnuvi.util.CollisionBox;
  4. import me.hammerle.supersnuvi.util.Face;
  5. public abstract class Tile
  6. {
  7. public final static int SIZE = 32;
  8. private CollisionBox movementCollision;
  9. private CollisionBox collisionBox;
  10. public Tile()
  11. {
  12. movementCollision = null;
  13. collisionBox = null;
  14. }
  15. /** Sets the collision box for movement
  16. *
  17. * @param cb a collision box
  18. * @return the tile which the change was applied to
  19. */
  20. public Tile setMovementBox(CollisionBox cb)
  21. {
  22. if(cb == CollisionBox.NULL_BOX)
  23. {
  24. this.movementCollision = null;
  25. }
  26. else
  27. {
  28. this.movementCollision = cb.copy();
  29. }
  30. return this;
  31. }
  32. /** Sets the collision box for normal collision
  33. *
  34. * @param cb a collision box
  35. * @return the tile which the change was applied to
  36. */
  37. public Tile setCollisionBox(CollisionBox cb)
  38. {
  39. if(cb == CollisionBox.NULL_BOX)
  40. {
  41. this.collisionBox = null;
  42. }
  43. else
  44. {
  45. this.collisionBox = cb.copy();
  46. }
  47. return this;
  48. }
  49. /** Sets the default collision box for movement and for collision
  50. *
  51. * @return the tile which the change was applied to
  52. */
  53. public Tile setDefaultCollisionBox()
  54. {
  55. this.movementCollision = CollisionBox.DEFAULT_TILE_BOX.copy();
  56. this.collisionBox = CollisionBox.DEFAULT_TILE_BOX.copy();
  57. return this;
  58. }
  59. public CollisionBox getCollisionBox(int x, int y)
  60. {
  61. if(collisionBox != null)
  62. {
  63. return collisionBox;
  64. }
  65. return CollisionBox.NULL_BOX.reset();
  66. }
  67. public boolean shouldAiUseCollisionBox(int x, int y)
  68. {
  69. return true;
  70. }
  71. public CollisionBox getMovementBox(int x, int y)
  72. {
  73. if(movementCollision != null)
  74. {
  75. return movementCollision;
  76. }
  77. return CollisionBox.NULL_BOX.reset();
  78. }
  79. public void onEntityCollide(Entity ent, int x, int y, Face face)
  80. {
  81. }
  82. public void tick()
  83. {
  84. }
  85. public long getKey(int x, int y)
  86. {
  87. return x | (((long) y) << 32);
  88. }
  89. public void reset()
  90. {
  91. }
  92. public int getBottleScore()
  93. {
  94. return 0;
  95. }
  96. public float getTextureMinX()
  97. {
  98. return 0.0f;
  99. }
  100. public float getTextureMaxX()
  101. {
  102. return 0.0625f;
  103. }
  104. public float getTextureMinY()
  105. {
  106. return 0.0f;
  107. }
  108. public float getTextureMaxY()
  109. {
  110. return 0.0625f;
  111. }
  112. public float getOffsetX()
  113. {
  114. return 0.0f;
  115. }
  116. public float getOffsetY()
  117. {
  118. return 0.0f;
  119. }
  120. public float getWidth()
  121. {
  122. return Tile.SIZE;
  123. }
  124. public float getHeight()
  125. {
  126. return Tile.SIZE;
  127. }
  128. public boolean shouldRender(int x, int y)
  129. {
  130. return true;
  131. }
  132. }