//
// Created by Dan Crosby on 4/14/21.
//

#ifndef EAGLE0_HEXCUBEUTILS_HPP
#define EAGLE0_HEXCUBEUTILS_HPP

#include "src/main/cpp/net/eagle0/shardok/library/map/Coordinates.hpp"

namespace shardok {

using std::vector;

struct Cube {
    int16_t x;
    int16_t y;
    int16_t z;

    Cube() : x(0), y(0), z(0){};
    Cube(const int16_t x, const int16_t y, const int16_t z) : x(x), y(y), z(z){};
};

auto OffsetToCube(const Coords &c) -> Cube;

auto CubeToOffset(const Cube &cube) -> Coords;

static inline auto CubeDistance(const Cube &c1, const Cube &c2) -> int {
    return (abs(c1.x - c2.x) + abs(c1.y - c2.y) + abs(c1.z - c2.z)) / 2;
}

auto CubesWithinDistance(const Cube &c1, int distance) -> vector<Cube>;
auto CubesWithExactDistance(const Cube &c1, int distance) -> vector<Cube>;

// Returns all the hexes that are on the line between c1 and c2, including the endpoints.
// In a case where the line passes exactly between two hexes, includes BOTH hexes.
auto CubeLineInclusive(const Cube &c1, const Cube &c2) -> vector<Cube>;

}  // namespace shardok

#endif  // EAGLE0_HEXCUBEUTILS_HPP
