#pragma once #include "basics.h" #include "adaptions.h" #include "../simulation/Simulation.h" #include "../simulation/Beat.h" using Vec2 = math::Vec2; using LineKind = simulation::LineKind; using ball_info = int; using line_info = int; using ball_type = simulation::Ball; using line_type = simulation::Line; using simu_type = simulation::Simulation; using note_info = Vec2; using note_type = Note; using beat_type = Beat; // Pretty unuseful in server struct AbstractLine { math::Vec2 starting_point; math::Vec2 end_point; int ID; int line_kind; static constexpr float hsize = 5.0f; AbstractLine() = default; AbstractLine(AbstractLine const&) = default; AbstractLine& operator=(AbstractLine const&) = default; AbstractLine(math::Vec2 starting_point, math::Vec2 end_point, int line_kind, int ID) : starting_point(starting_point) , end_point(end_point) , ID(ID) , line_kind(line_kind) {} // create 6 lines, to emulate width, and rounded edges std::vector calculate_lines() const { auto dir = normalize(end_point - starting_point); auto normal = rotate_ccw(dir); LineKind lk = static_cast(line_kind); if(line_kind == simulation::kOneWay){ std::vector ret; ret.emplace_back(starting_point + hsize*normal, end_point + hsize*normal, lk, ID); ret.emplace_back(end_point + hsize*normal, end_point + hsize*dir, lk, ID); ret.emplace_back(end_point + hsize*dir, end_point - hsize*normal, lk, ID); ret.emplace_back(end_point - hsize*normal, starting_point - hsize*normal, lk, ID); ret.emplace_back(starting_point - hsize*normal, starting_point - hsize*dir, lk, ID); ret.emplace_back(starting_point - hsize*dir, starting_point + hsize*normal, lk, ID); return ret; } else { std::vector ret; ret.emplace_back(starting_point, end_point, lk, ID); return ret; } } }; BOOST_FUSION_ADAPT_STRUCT( AbstractLine, (::math::Vec2, starting_point) (::math::Vec2, end_point) (int, ID) (int, line_kind) ) BOOST_FUSION_DEFINE_STRUCT( , IntVec2, (int, x) (int, y) ) inline math::Vec2 to_FloatVec2(IntVec2 v){ return {static_cast(v.x), static_cast(v.y)}; } struct cheap_ball_type { IntVec2 position; ball_info information; cheap_ball_type() = default; cheap_ball_type(ball_type const & b) : position(b.position) , information(b.information) {} }; BOOST_FUSION_ADAPT_STRUCT( cheap_ball_type, (IntVec2, position) (ball_info, information) ) struct cheap_line_type { IntVec2 starting_point; IntVec2 end_point; int ID; int line_kind; cheap_line_type() = default; cheap_line_type(AbstractLine const & l) : starting_point(l.starting_point) , end_point(l.end_point) , ID(l.ID) , line_kind(l.line_kind) {} }; BOOST_FUSION_ADAPT_STRUCT( cheap_line_type, (IntVec2, starting_point) (IntVec2, end_point) (int, ID) (int, line_kind) )