#pragma once #include #include struct Vector2Options { int32_t x; int32_t y; }; /** * A 2D Vector. */ class Vector2 { public: using Value = int32_t; explicit Vector2(const Vector2Options &options); [[nodiscard]] Value get_x() const noexcept; void set_x(Value x) noexcept; [[nodiscard]] Value get_y() const noexcept; void set_y(Value y) noexcept; [[nodiscard]] Vector2 to_direction(const Vector2 &direction, Vector2::Value amount) const noexcept; const Vector2 &operator+=(const Vector2 &vector2) noexcept; const Vector2 &operator-=(const Vector2 &vector2) noexcept; Vector2 operator+(const Vector2 &vector2) const noexcept; Vector2 operator*(const Vector2 &vector2) const noexcept; bool operator==(const Vector2 &vector2) const noexcept; /** * Returns Vector2({.x = 0, .y = -1}) */ static Vector2 up() noexcept; /** * Returns Vector2({.x = 0, .y = 1}) */ static Vector2 down() noexcept; /** * Returns Vector2({.x = -1, .y = 0}) */ static Vector2 left() noexcept; /** * Returns Vector2({.x = 1, .y = 0}) */ static Vector2 right() noexcept; private: Value _x; Value _y; }; class Vector2Hasher { public: std::size_t operator()(const Vector2 &vector2) const noexcept; };