diff options
-rw-r--r-- | kurator/src/Battle.cpp | 18 |
1 files changed, 12 insertions, 6 deletions
diff --git a/kurator/src/Battle.cpp b/kurator/src/Battle.cpp index 9bb5dec..ce14365 100644 --- a/kurator/src/Battle.cpp +++ b/kurator/src/Battle.cpp @@ -10,10 +10,12 @@ #include <raylib.h> #include <imgui.h> +#include <kurator/engine/Point.h> #include <kurator/campaign/scenarios.h> #include <kurator/sim/Battle.h> #include <kurator/sim/components.h> #include <kurator/sim/events.h> +#include <kurator/sim/FloatingMovement.h> #include <kurator/stats/events.h> #include <kurator/universe/ShipType.h> #include <kurator/universe/UniqueIdentifier.h> @@ -162,13 +164,17 @@ Battle::draw() const auto view = registry.view<const Marker, const sim::Transform>(); for (auto [entity, marker, transform] : view.each()) { const auto pos = camera.to_screen(transform.position); + if (registry.all_of<sim::FloatingMovement>(entity)) { + const auto& movement = registry.get<sim::FloatingMovement>(entity); + const auto& velocity = movement.speed; + const auto edge = pos + velocity.normalized().scale(marker.radius); + const auto tip = edge + velocity.scale(2.0 * camera.scale); + DrawLine(edge.x, edge.y, tip.x, tip.y, DARKGRAY); + } + const engine::Point direction {std::cos(transform.angle), std::sin(transform.angle)}; + const auto edge = pos + direction.scale(marker.radius); DrawCircle(pos.x, pos.y, marker.radius, marker.color); - DrawLine( - pos.x, - pos.y, - pos.x + marker.radius*std::cos(transform.angle), - pos.y + marker.radius*std::sin(transform.angle), - WHITE); + DrawLine(pos.x, pos.y, edge.x, edge.y, WHITE); DrawText(marker.name.c_str(), pos.x+10, pos.y-5, 10.0f, GRAY); } auto pops = registry.view<CenteredText, sim::Transform, UIOffset>(); |