1
0
Fork 0
Univerxel/src/core/world/actions.hpp

66 lines
1.3 KiB
C++

#pragma once
#include "forward.h"
#include "Voxel.hpp"
#include <variant>
#include "../flags.hpp"
#include "../geometry/Shapes.hpp"
/// Client action on world
namespace world::action {
namespace part {
struct Ping { };
}
struct Fill: part::Ping {
Fill(const area_<voxel_pos> &pos, const Voxel &val): pos(pos), val(val) {}
const area_<voxel_pos> pos;
const Voxel val;
};
enum class Shape: uint8_t {
Cube,
Sphere,
/*SmoothSphere,
CylinderX,
CylinderY,
CylinderZ,
ConePX,
ConeNX,
ConePY,
ConeNY,
ConePZ,
ConeNZ,
*/
};
static _FORCE_INLINE_ geometry::Shape ToGeometry(Shape shape) {
switch (shape) {
case Shape::Sphere:
return geometry::Shape::Sphere;
default:
return geometry::Shape::Cube;
}
}
constexpr auto SHAPES = "Cube\0Sphere\0";
struct FillShape: Fill {
FillShape(const area_<voxel_pos> &pos, const Voxel &val, Shape shape, uint8_t radius):
Fill(pos, val), shape(shape), radius(radius) {}
const Shape shape;
const uint8_t radius;
};
struct Move: part::Ping {
Move(const voxel_pos& pos): pos(pos) { }
const voxel_pos pos;
};
struct Message: part::Ping {
Message(const std::string& text): text(text) { }
const std::string text;
};
using packet = std::variant<Move, Message, Fill, FillShape>;
}