#include "vector2.hpp" #include "util/hash.hpp" Vector2::Value Vector2::get_x() const noexcept { return _x; } void Vector2::set_x(Vector2::Value x) noexcept { _x = x; } Vector2::Value Vector2::get_y() const noexcept { return _y; } void Vector2::set_y(Vector2::Value y) noexcept { _y = y; } Vector2 Vector2::to_direction(const Vector2 &direction, Vector2::Value amount) const noexcept { return *this + (direction * Vector2({.x = amount, .y = amount})); } 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; } Vector2 Vector2::operator+(const Vector2 &vector2) const noexcept { auto new_vector2 = Vector2(*this); new_vector2._x += vector2._x; new_vector2._y += vector2._y; return new_vector2; } Vector2 Vector2::operator*(const Vector2 &vector2) const noexcept { auto new_vector2 = Vector2(*this); new_vector2._x *= vector2._x; new_vector2._y *= vector2._y; return new_vector2; } bool Vector2::operator==(const Vector2 &vector2) const noexcept { return _x == vector2._x && _y == vector2._y; } std::size_t Vector2Hasher::operator()(const Vector2 &vector2) const noexcept { std::size_t result_hash = 0; hash_combine(result_hash, vector2.get_x()); hash_combine(result_hash, vector2.get_y()); return result_hash; }