#include "vector2.hpp" #include "util/hash.hpp" Vector2::Vector2(const Vector2Options &options) : _x(options.x), _y(options.y) {} int32_t Vector2::get_x() const noexcept { return _x; } void Vector2::set_x(int32_t x) noexcept { _x = x; } int32_t Vector2::get_y() const noexcept { return _y; } void Vector2::set_y(int32_t y) noexcept { _y = y; } const Vector2 &Vector2::operator+=(const Vector2 &vector2) noexcept { _x += vector2._x; _y += vector2._y; return *this; } const Vector2 &Vector2::operator-=(const Vector2 &vector2) noexcept { _x -= vector2._x; _y -= vector2._y; return *this; } bool Vector2::operator==(const Vector2 &vector2) const noexcept { return _x == vector2._x && _y == vector2._y; } Vector2 Vector2::up() { return Vector2({.x = 0, .y = 1}); } Vector2 Vector2::down() { return Vector2({.x = 0, .y = -1}); } Vector2 Vector2::left() { return Vector2({.x = -1, .y = 0}); } Vector2 Vector2::right() { return Vector2({.x = 1, .y = 0}); } std::size_t Vector2Hasher::operator()(const Vector2 &vector2) const { std::size_t result_hash = 0; hash_combine(result_hash, vector2.get_x()); hash_combine(result_hash, vector2.get_y()); return result_hash; }