TileInfo.cpp 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * TileInfo.cpp, part of VCMI engine
  3. *
  4. * Authors: listed in file AUTHORS in main folder
  5. *
  6. * License: GNU General Public License v2.0 or later
  7. * Full text of license available in license.txt file, in main folder
  8. *
  9. */
  10. #include "StdInc.h"
  11. #include "TileInfo.h"
  12. VCMI_LIB_NAMESPACE_BEGIN
  13. TileInfo::TileInfo()
  14. : nearestObjectDistance(static_cast<float>(std::numeric_limits<int>::max()))
  15. , occupied(ETileType::POSSIBLE) //all tiles are initially possible to place objects or passages
  16. {
  17. }
  18. float TileInfo::getNearestObjectDistance() const
  19. {
  20. return nearestObjectDistance;
  21. }
  22. void TileInfo::setNearestObjectDistance(float value)
  23. {
  24. nearestObjectDistance = std::max<float>(0, value); //never negative (or uninitialized)
  25. }
  26. bool TileInfo::shouldBeBlocked() const
  27. {
  28. return occupied == ETileType::BLOCKED;
  29. }
  30. bool TileInfo::isBlocked() const
  31. {
  32. return occupied == ETileType::BLOCKED || occupied == ETileType::USED;
  33. }
  34. bool TileInfo::isPossible() const
  35. {
  36. return occupied == ETileType::POSSIBLE;
  37. }
  38. bool TileInfo::isFree() const
  39. {
  40. return occupied == ETileType::FREE;
  41. }
  42. bool TileInfo::isRoad() const
  43. {
  44. return roadType != Road::NO_ROAD;
  45. }
  46. bool TileInfo::isUsed() const
  47. {
  48. return occupied == ETileType::USED;
  49. }
  50. void TileInfo::setOccupied(ETileType value)
  51. {
  52. occupied = value;
  53. }
  54. ETileType TileInfo::getTileType() const
  55. {
  56. return occupied;
  57. }
  58. TerrainId TileInfo::getTerrainType() const
  59. {
  60. return terrain;
  61. }
  62. void TileInfo::setTerrainType(TerrainId type)
  63. {
  64. terrain = type;
  65. }
  66. void TileInfo::setRoadType(RoadId type)
  67. {
  68. roadType = type;
  69. // setOccupied(ETileType::FREE);
  70. }
  71. VCMI_LIB_NAMESPACE_END