summaryrefslogtreecommitdiff
path: root/kurator
diff options
context:
space:
mode:
authorAki <please@ignore.pl>2023-04-23 12:54:14 +0200
committerAki <please@ignore.pl>2024-04-05 19:41:19 +0200
commit975339d07aeb193564221adff31b55a913d92a1e (patch)
tree957b37e922e494780874bbc8e495a1a5e412fb76 /kurator
parentbdfb27ba04528f213dcadc00afdcf1f35a61f6fc (diff)
downloadkurator-975339d07aeb193564221adff31b55a913d92a1e.zip
kurator-975339d07aeb193564221adff31b55a913d92a1e.tar.gz
kurator-975339d07aeb193564221adff31b55a913d92a1e.tar.bz2
Separated Turret from AI, shuffled their units
Diffstat (limited to 'kurator')
-rw-r--r--kurator/src/inspect.cpp57
1 files changed, 31 insertions, 26 deletions
diff --git a/kurator/src/inspect.cpp b/kurator/src/inspect.cpp
index ea70baf..38f5394 100644
--- a/kurator/src/inspect.cpp
+++ b/kurator/src/inspect.cpp
@@ -6,12 +6,12 @@
#include <imgui.h>
#include <raylib.h>
+#include <kurator/sim/ai.h>
#include <kurator/sim/components.h>
#include <kurator/sim/FloatingMovement.h>
#include <kurator/sim/HitPoints.h>
-#include <kurator/sim/TurretControl.h>
+#include <kurator/sim/weapons.h>
#include <kurator/universe/ShipType.h>
-#include <kurator/universe/TurretType.h>
#include <kurator/universe/UniqueIdentifier.h>
#include "Controller.h"
@@ -51,10 +51,10 @@ InspectionWindow::show()
ImGui::PushID(it - selected.begin());
inspect<universe::UniqueIdentifier>(*it);
inspect<universe::ShipType>(*it);
- inspect<universe::TurretType>(*it);
inspect<sim::FloatingMovement>(*it);
inspect<sim::HitPoints>(*it);
- inspect<sim::AIState>(*it);
+ inspect<sim::AIShip>(*it);
+ inspect<sim::Turret>(*it);
inspect<TurretVisuals>(*it);
inspect<AIVisuals>(*it);
it = std::next(it);
@@ -76,7 +76,7 @@ InspectionWindow::select(entt::handle entity)
return;
entity.get<Selectable>().active = true;
auto* registry = entity.registry();
- auto turrets = registry->view<sim::TurretControl>();
+ auto turrets = registry->view<sim::Turret>();
entity.emplace<AIVisuals>();
selected.push_back(std::move(entity));
for (auto&& [entity_, turret] : turrets.each()) {
@@ -131,21 +131,26 @@ slider_double(const char* label, double* value, double minimum, double maximum,
template <>
void
-inspect(entt::handle&, universe::TurretType& type)
-{
- ImGui::Text("Turret: %s", type.name.c_str());
- ImGui::Text("DPS: %.1f", type.damage_per_second());
- ImGui::Text("Eff. Range: %.1f", type.effective_range());
- ImGui::SliderInt("Rounds", &type.rounds, 0, 50);
- slider_double("Base Damage", &type.base_damage, 0, 1000.0, "%.1f");
- slider_double("Rate of Fire", &type.rate_of_fire, 0, 60.0, "%.3f");
- slider_double("Reload", &type.reload, 0, 60.0, "%.3f");
- slider_double("Optimal Range", &type.optimal_range, 0, 30000.0, "%.1f");
- slider_double("Falloff Modifier", &type.falloff_modifier, 0, 5.0, "%.3f");
- slider_double("Falloff Intensity", &type.falloff_intensity, 0, 1.0, "%.3f");
- slider_double("Tracking", &type.tracking, 0, 1000.0, "%.1f");
- slider_double("Tracking Factor", &type.tracking_factor, 0, 10.0, "%.3f");
- slider_double("Tracking Exponent", &type.tracking_exponent, 0, 2.0, "%.3f");
+inspect(entt::handle&, sim::Turret& turret)
+{
+ ImGui::Text("Turret: %s", turret.type.name.c_str());
+ ImGui::Text("DPS: %.1f", turret.type.damage_per_second());
+ ImGui::Text("Eff. Range: %.1f", turret.type.effective_range());
+ ImGui::Text("Current");
+ ImGui::SliderInt("Rounds##current", &turret.rounds, 0, turret.type.rounds);
+ slider_double("Delay", &turret.delay, 0, turret.type.rate_of_fire, "%.3f");
+ slider_double("Reload##current", &turret.reload, 0, turret.type.reload, "%.3f");
+ ImGui::Text("Base");
+ ImGui::SliderInt("Rounds##base", &turret.type.rounds, 0, 50);
+ slider_double("Base Damage", &turret.type.base_damage, 0, 1000.0, "%.1f");
+ slider_double("Rate of Fire", &turret.type.rate_of_fire, 0, 60.0, "%.3f");
+ slider_double("Reload##base", &turret.type.reload, 0, 60.0, "%.3f");
+ slider_double("Optimal Range", &turret.type.optimal_range, 0, 30000.0, "%.1f");
+ slider_double("Falloff Modifier", &turret.type.falloff_modifier, 0, 5.0, "%.3f");
+ slider_double("Falloff Intensity", &turret.type.falloff_intensity, 0, 1.0, "%.3f");
+ slider_double("Tracking", &turret.type.tracking, 0, 1000.0, "%.1f");
+ slider_double("Tracking Factor", &turret.type.tracking_factor, 0, 10.0, "%.3f");
+ slider_double("Tracking Exponent", &turret.type.tracking_exponent, 0, 2.0, "%.3f");
}
@@ -171,7 +176,7 @@ inspect(entt::handle&, sim::HitPoints& points)
template <>
void
-inspect(entt::handle&, sim::AIState& ai)
+inspect(entt::handle&, sim::AIShip& ai)
{
ImGui::InputDouble("Keep At Range", &ai.keep_at_range, 0, 0, "%.1f");
}
@@ -201,14 +206,14 @@ static constexpr Color EFFECTIVE {0x77, 0x50, 0x22, 0xff};
void
draw_turret_visuals(const sim::State& ctx)
{
- const auto helpers = ctx.registry.view<TurretVisuals, universe::TurretType, sim::TurretControl>();
- for (const auto& [entity, visuals, type, turret] : helpers.each()) {
+ const auto helpers = ctx.registry.view<TurretVisuals, sim::Turret>();
+ for (const auto& [entity, visuals, turret] : helpers.each()) {
if (!visuals.visible || !ctx.registry.valid(turret.owner))
continue;
const auto& transform = ctx.registry.get<sim::Transform>(turret.owner);
const auto center = ctx.camera.to_screen(transform.position);
- const auto optimal = type.optimal_range * ctx.camera.scale;
- const auto effective = type.effective_range() * ctx.camera.scale;
+ const auto optimal = turret.type.optimal_range * ctx.camera.scale;
+ const auto effective = turret.type.effective_range() * ctx.camera.scale;
DrawCircleLines(center.x, center.y, optimal, OPTIMAL);
DrawCircleLines(center.x, center.y, effective, EFFECTIVE);
}
@@ -222,7 +227,7 @@ static constexpr Color TARGET {0x44, 0x22, 0x66, 0xff};
void
draw_ai_visuals(const sim::State& ctx)
{
- const auto visuals = ctx.registry.view<AIVisuals, sim::AIState, sim::Transform>();
+ const auto visuals = ctx.registry.view<AIVisuals, sim::AIShip, sim::Transform>();
for (const auto& [entity, visuals, ai, transform] : visuals.each()) {
const auto start = ctx.camera.to_screen(transform.position);
if (visuals.show_target && ctx.registry.valid(ai.target)) {