* @brief Represents a 3-dimensional location in a dimension within a level. */
| 30 | * @brief Represents a 3-dimensional location in a dimension within a level. |
| 31 | */ |
| 32 | class Location { |
| 33 | public: |
| 34 | template <std::convertible_to<float> T> |
| 35 | Location(Dimension &dimension, T x, T y, T z, const float pitch = 0.0, const float yaw = 0.0) |
| 36 | : dimension_(&dimension), x_(static_cast<float>(x)), y_(static_cast<float>(y)), z_(static_cast<float>(z)), |
| 37 | pitch_(pitch), yaw_(yaw) |
| 38 | { |
| 39 | } |
| 40 | |
| 41 | /** |
| 42 | * @brief Sets the dimension that this position resides in |
| 43 | * |
| 44 | * @param dimension New dimension that this position resides in |
| 45 | */ |
| 46 | void setDimension(Dimension &dimension) { dimension_ = &dimension; } |
| 47 | |
| 48 | /** |
| 49 | * @brief Gets the dimension that this location resides in |
| 50 | * |
| 51 | * @return Dimension that contains this location |
| 52 | */ |
| 53 | [[nodiscard]] Dimension &getDimension() const { return *dimension_; } |
| 54 | |
| 55 | /** |
| 56 | * @brief Gets the block at the represented location |
| 57 | * |
| 58 | * @return Block at the represented location |
| 59 | */ |
| 60 | [[nodiscard]] std::unique_ptr<Block> getBlock() const; |
| 61 | |
| 62 | /** |
| 63 | * @brief Sets the x-coordinate of this location |
| 64 | * |
| 65 | * @param x X-coordinate |
| 66 | */ |
| 67 | template <std::convertible_to<float> T> |
| 68 | constexpr void setX(T x) |
| 69 | { |
| 70 | x_ = static_cast<float>(x); |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * @brief Gets the x-coordinate of this location |
| 75 | * |
| 76 | * @return x-coordinate |
| 77 | */ |
| 78 | [[nodiscard]] constexpr float getX() const { return x_; } |
| 79 | |
| 80 | /** |
| 81 | * @brief Gets the floored value of the X component, indicating the block that this location is contained with. |
| 82 | * |
| 83 | * @return block X |
| 84 | */ |
| 85 | [[nodiscard]] int getBlockX() const { return static_cast<int>(std::floorf(x_)); } |
| 86 | |
| 87 | /** |
| 88 | * @brief Sets the y-coordinate of this location |
| 89 | * |
no test coverage detected