TileInfo.cpp 1.5 KB

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