TileInfo.cpp 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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. TileInfo::TileInfo():nearestObjectDistance(float(INT_MAX)), terrain()
  13. {
  14. occupied = ETileType::POSSIBLE; //all tiles are initially possible to place objects or passages
  15. }
  16. float TileInfo::getNearestObjectDistance() const
  17. {
  18. return nearestObjectDistance;
  19. }
  20. void TileInfo::setNearestObjectDistance(float value)
  21. {
  22. nearestObjectDistance = std::max<float>(0, value); //never negative (or unitialized)
  23. }
  24. bool TileInfo::shouldBeBlocked() const
  25. {
  26. return occupied == ETileType::BLOCKED;
  27. }
  28. bool TileInfo::isBlocked() const
  29. {
  30. return occupied == ETileType::BLOCKED || occupied == ETileType::USED;
  31. }
  32. bool TileInfo::isPossible() const
  33. {
  34. return occupied == ETileType::POSSIBLE;
  35. }
  36. bool TileInfo::isFree() const
  37. {
  38. return occupied == ETileType::FREE;
  39. }
  40. bool TileInfo::isRoad() const
  41. {
  42. return roadType != Road::NO_ROAD;
  43. }
  44. bool TileInfo::isUsed() const
  45. {
  46. return occupied == ETileType::USED;
  47. }
  48. void TileInfo::setOccupied(ETileType::ETileType value)
  49. {
  50. occupied = value;
  51. }
  52. ETileType::ETileType TileInfo::getTileType() const
  53. {
  54. return occupied;
  55. }
  56. TTerrainId TileInfo::getTerrainType() const
  57. {
  58. return terrain;
  59. }
  60. void TileInfo::setTerrainType(TTerrainId type)
  61. {
  62. terrain = type;
  63. }
  64. void TileInfo::setRoadType(TRoadId type)
  65. {
  66. roadType = type;
  67. // setOccupied(ETileType::FREE);
  68. }