Make map and radar targets legible with an honest hover (#132)

- mini radar: class-shaped blips that merge into one with a count
- map: larger track markers and trails, hover card with distance, type,
  status, target and interception
- explicit network vs sandbox truth: true drones, routes and aims drawn
  apart from the network tracks, with their own trails

Co-Authored-By: Kimi Code <noreply@kimi.com>
This commit is contained in:
2026-11-20 21:44:58 +03:00
parent 1e2d5dd0c0
commit d302204649
3 changed files with 593 additions and 71 deletions
+445 -61
View File
@@ -7,7 +7,7 @@
//! comes from the game as tiles (`render::TerrainShape`): the mod only says which, and the game scans the
//! loaded chunks within a budget; land it hasn't got is drawn as unknown.
use crate::panel::distance;
use crate::sim::{self, Class, LowSensor, Sam, SamKind, Sim, doctrine::Doctrine, Track, strike::SiteState};
use crate::sim::{self, Class, Drone, LowSensor, Sam, SamKind, Sim, doctrine::Doctrine, Track, strike::SiteState};
use crate::{AirDef, say};
use glam::DVec3;
use horizon_mod_sdk::render::{self, CanvasEvent, FillShape, Point, QuadShape, Rect, Shape, TerrainShape, TextShape};
@@ -36,6 +36,10 @@ const TGT_SPEED: [f64; 4] = [0.8, 1.8, 3.0, 6.5];
/// a low zoom, and the most labels at once.
const LH: f32 = 9.0;
const CLUSTER_R: f32 = 9.0;
/// Tracks merge within this many pixels: their markers are bigger than the systems' (#132).
const TRACK_CLUSTER_R: f32 = 11.0;
/// A track marker's half-size, and the room its label keeps clear of it.
const TRACK_R: f32 = 6.0;
const MAX_LABELS: usize = 70;
/// Ticks a radar's computed coverage edge lives, and how many are recomputed in a redraw.
const RIM_REFRESH: u64 = 100;
@@ -121,6 +125,15 @@ enum Act {
SaveScn,
LoadScn(usize),
ScnPage(i32),
/// Switches the map between the network's data and the sandbox's truth (#132).
Truth,
}
/// What the pointer hovers: a network track, or a true drone in the truth mode.
#[derive(Clone, Copy, PartialEq, Debug)]
enum Hover {
Track(u32),
Drone(u32),
}
/// A system in the draft layout: an existing one (by id) or one to be built.
@@ -222,7 +235,11 @@ pub struct MapUi {
blocked: Vec<[f32; 4]>,
widths: HashMap<String, f32>,
trails: HashMap<u32, Vec<(f32, f32)>>,
/// The true places sampled while the sandbox's truth mode is on (#132), apart from the network's.
truth_trails: HashMap<u32, Vec<(f32, f32)>>,
seen: HashMap<u32, u64>,
/// When a true drone was last seen, kept apart from the network's `seen` (#132).
truth_seen: HashMap<u32, u64>,
sampled: u64,
draft: Draft,
history: Vec<Draft>,
@@ -273,7 +290,9 @@ impl Default for MapUi {
blocked: Vec::new(),
widths: HashMap::new(),
trails: HashMap::new(),
truth_trails: HashMap::new(),
seen: HashMap::new(),
truth_seen: HashMap::new(),
sampled: 0,
draft: Draft::default(),
history: Vec::new(),
@@ -350,7 +369,9 @@ impl MapUi {
pub fn sample(&mut self, sim: &Sim) {
if sim.tick < self.sampled {
self.trails.clear();
self.truth_trails.clear();
self.seen.clear();
self.truth_seen.clear();
}
if sim.tick < self.sampled + SAMPLE {
return;
@@ -371,10 +392,27 @@ impl MapUi {
}
self.seen.insert(id, sim.tick);
}
// The truth mode keeps its own trail of the real places, never mixed into the network's (#132).
if sim.truth {
for d in sim.drones.iter().filter(|d| d.alive()) {
let trail = self.truth_trails.entry(d.id).or_default();
let p = (d.pos.x as f32, d.pos.z as f32);
if trail.last().is_none_or(|l| (l.0 - p.0).hypot(l.1 - p.1) > 4.0) {
trail.push(p);
if trail.len() > TRAIL_POINTS {
trail.remove(0);
}
}
self.truth_seen.insert(d.id, sim.tick);
}
}
let now = sim.tick;
self.seen.retain(|_, t| now.saturating_sub(*t) < 1200);
self.truth_seen.retain(|_, t| now.saturating_sub(*t) < 1200);
let seen = &self.seen;
self.trails.retain(|id, _| seen.contains_key(id));
let truth_seen = &self.truth_seen;
self.truth_trails.retain(|id, _| truth_seen.contains_key(id));
}
fn enter_editor(&mut self) {
@@ -456,7 +494,7 @@ fn tgt_class(t: &Track) -> usize {
}
/// Markers within `r` pixels of the first of a group go with it: the groups, as indices into `pos`.
fn group(pos: &[(f32, f32)], r: f32) -> Vec<Vec<usize>> {
pub(crate) fn group(pos: &[(f32, f32)], r: f32) -> Vec<Vec<usize>> {
let r2 = r * r;
let mut g: Vec<Vec<usize>> = Vec::new();
'next: for (i, p) in pos.iter().enumerate() {
@@ -567,6 +605,257 @@ fn class_name(c: sim::sites::SiteClass) -> &'static str {
}
}
/// What the pointer is over, in the view: a network track, or a true drone while the sandbox's truth mode is on.
/// The network's tracks come from `Sim::picture` only; a drone the network has not measured is not hoverable
/// outside the truth mode (#132). Panels and cards take the pointer first.
fn hover_at(sim: &Sim, ui: &MapUi) -> Option<Hover> {
let p = ui.cursor;
if ui.blocked.iter().any(|r| p.0 >= r[0] && p.1 >= r[1] && p.0 <= r[0] + r[2] && p.1 <= r[1] + r[3]) {
return None;
}
let near = PICK_R + 2.0;
let mut best: Option<(f32, Hover)> = None;
if ui.filters[F_TRACKS] {
let now = sim.tick;
for (id, t) in sim.picture() {
if !ui.tclass[tgt_class(&t)] {
continue;
}
let e = t.est(now);
let c = ui.to_screen(e.x, e.z);
if !ui.on_screen(c, 6.0) {
continue;
}
let d = (c.0 - p.0).hypot(c.1 - p.1);
if d <= near && best.is_none_or(|b| d < b.0) {
best = Some((d, Hover::Track(id)));
}
}
}
// The true place wins over its own track: the mode is explicit and the card says so.
if sim.truth {
for d in sim.drones.iter().filter(|d| d.alive()) {
let c = ui.to_screen(d.pos.x, d.pos.z);
if !ui.on_screen(c, 6.0) {
continue;
}
let dist = (c.0 - p.0).hypot(c.1 - p.1);
if dist <= near && best.is_none_or(|b| dist <= b.0 + 0.5) {
best = Some((dist, Hover::Drone(d.id)));
}
}
}
best.map(|b| b.1)
}
/// The network's knowledge of one track: type, status, source, distance, speed, whatever holds or intercepts it.
/// The target and the route are never known to the network unless the sandbox's truth mode adds them (#132).
fn track_lines(sim: &Sim, t: &Track, player: Option<DVec3>, lines: &mut Vec<(String, u32)>) {
let now = sim.tick;
let age = t.age(now);
let forecast = t.forecast(now);
let class = t.kind.spec().class;
lines.push((format!("Трек №{} · {} ({})", t.id, t.kind.spec().name, class.name()), RED));
lines.push((
format!("Статус: {}{}", t.ident().name(), if forecast { format!(" · прогноз {} с", age / 20) } else { format!(" · измерение {} с назад", age / 20) }),
if forecast { YELLOW } else { GREEN },
));
lines.push((format!("Источник: {}", if t.own_within(now, t.ttl as u64) { "своя РЛС" } else { "сеть (чужое измерение)" }), WHITE));
if t.locked {
lines.push(("Огневой захват: да".into(), YELLOW));
}
let e = t.est(now);
if let Some(p) = player {
lines.push((format!("Дистанция: {} · высота {:.0} м", distance(e.distance(p)), e.y), WHITE));
}
lines.push((
format!("Скорость: {:.0} км/ч · погрешность места {}", t.vel.length() * 20.0 * 3.6, distance(t.uncertainty(now))),
WHITE,
));
let missiles = sim.missiles.iter().filter(|m| m.target() == t.id).count();
lines.push((
if missiles > 0 { format!("Перехват: {missiles} ракет в полёте") } else { "Перехват: ракет нет".into() },
if missiles > 0 { GREEN } else { GREY },
));
let who = who_tracks(sim, t);
if !who.is_empty() {
lines.push((format!("Держат: {who}"), WHITE));
}
}
/// The systems whose tracks hold this one, by name (the network's own bookkeeping, not the drone's).
fn who_tracks(sim: &Sim, t: &Track) -> String {
let n = sim.sams.iter().filter(|s| s.tracks.iter().any(|x| x.id == t.id)).count();
if n == 0 { String::new() } else { format!("{n} комплексов") }
}
/// What a true drone is aimed at, in the sandbox's words: a unit, a marked object, or a bare point (#132).
fn aim_text(sim: &Sim, d: &Drone) -> String {
let unit = d.aim_unit();
if unit != 0 {
return match sim.sams.iter().position(|s| s.id == unit) {
Some(i) => format!("{} №{}", sim.sams[i].kind.name(), i + 1),
None => format!("комплекс №{unit}"),
};
}
let aim = d.aim_pos();
match sim.targets.iter().position(|p| p.distance(aim) < 8.0) {
Some(i) => format!("объект №{}", i + 1),
None => format!("точка {:.0} {:.0}", aim.x, aim.z),
}
}
/// The truth's lines for one drone: what it is, whether the network holds it, where it goes, what it is sent at,
/// and who is shooting at it. Only the sandbox's truth mode asks for these (#132).
fn truth_lines(sim: &Sim, d: &Drone, player: Option<DVec3>, lines: &mut Vec<(String, u32)>) {
let tracked = sim.picture().contains_key(&d.id);
lines.push((format!("ИСТИНА · {} ({}) №{}", d.kind.spec().name, d.kind.spec().class.name(), d.id), YELLOW));
lines.push((
format!("Статус: {}{}", if d.jammed { "в воздухе, навигация подавлена" } else { "в воздухе" }, if tracked { ", в картине сети" } else { ", вне картины сети" }),
if tracked { WHITE } else { ORANGE },
));
if d.kind.spec().decoy {
lines.push(("Ложная цель: без боевой части".into(), GREY));
}
if let Some(p) = player {
lines.push((format!("Дистанция: {} · высота {:.0} м", distance(d.pos.distance(p)), d.pos.y), WHITE));
}
lines.push((format!("Скорость: {:.0} км/ч", d.vel.length() * 20.0 * 3.6), WHITE));
lines.push((format!("Цель: {}", aim_text(sim, d)), YELLOW));
let route = d.route();
if route.is_empty() {
lines.push(("Маршрут: прямо на цель".into(), YELLOW));
} else {
lines.push((format!("Маршрут: {} точек, следующая через {}", route.len(), distance(d.pos.distance(route[0]))), YELLOW));
}
let aim = d.aim_pos();
let speed = d.vel.length().max(0.001);
lines.push((format!("До цели: {} (~{:.0} с)", distance(d.pos.distance(aim)), d.pos.distance(aim) / speed / 20.0), WHITE));
let missiles = sim.missiles.iter().filter(|m| m.target() == d.id).count();
lines.push((
if missiles > 0 || d.engaged > 0 {
format!("Перехват: {missiles} ракет в полёте, наведено {}", d.engaged)
} else {
"Перехват: никто не ведёт".into()
},
if missiles > 0 || d.engaged > 0 { GREEN } else { GREY },
));
}
/// The truth layer: the real drones as white frames, their sampled path, the route and aim ahead in yellow, marked
/// apart from the network's red tracks. Drawn only while the sandbox's truth mode is on (#132).
fn map_truth(sim: &Sim, ui: &mut MapUi, hover: Option<Hover>, s: &mut Vec<Shape>, labs: &mut Vec<Lab>, taken: &mut Vec<[f32; 4]>) {
for d in sim.drones.iter().filter(|d| d.alive()) {
let c = ui.to_screen(d.pos.x, d.pos.z);
if ui.filters[F_TRAILS]
&& let Some(trail) = ui.truth_trails.get(&d.id)
{
let mut prev: Option<(f32, f32)> = None;
for p in trail {
let q = ui.to_screen(p.0 as f64, p.1 as f64);
if let Some(a) = prev
&& (ui.on_screen(a, 0.0) || ui.on_screen(q, 0.0))
{
s.push(line(a, q, 1.4, alpha(WHITE, 0.45)));
}
prev = Some(q);
}
}
if !ui.on_screen(c, 20.0) {
continue;
}
// The way ahead: the route's points, then the aim. Dashes, because a plan is not a measurement.
let aim = ui.to_screen(d.aim_pos().x, d.aim_pos().z);
let mut prev = c;
for p in d.route().iter().map(|p| ui.to_screen(p.x, p.z)).chain(std::iter::once(aim)) {
if ui.on_screen(prev, 0.0) || ui.on_screen(p, 0.0) {
route_dashed(s, prev, p, alpha(0xFFE070, 0.55));
}
prev = p;
}
// The drone: a white frame, never the network's red diamond.
s.extend(frame(c.0 - 5.0, c.1 - 5.0, 10.0, 10.0, 1.2, alpha(WHITE, 0.95)));
s.push(fill(c.0 - 1.0, c.1 - 1.0, 2.0, 2.0, WHITE));
if ui.on_screen(aim, 6.0) {
s.push(diamond(aim.0, aim.1, 4.5, alpha(0xFFE070, 0.85)));
s.push(fill(aim.0 - 1.0, aim.1 - 1.0, 2.0, 2.0, alpha(0xFFE070, 0.9)));
}
taken.push([c.0 - 6.0, c.1 - 6.0, 12.0, 12.0]);
let chosen = hover == Some(Hover::Drone(d.id));
add_lab(ui, labs, format!("{} №{}", d.kind.spec().name, d.id), c, 7.0, alpha(YELLOW, 0.95), chosen);
if chosen {
s.extend(frame(c.0 - 8.0, c.1 - 8.0, 16.0, 16.0, 1.0, GREEN));
}
}
}
/// The hover card: beside the pointer, over the picture. A network track's card never claims its target or route;
/// in the truth mode the true drone's card adds the route, the aim and the interception (#132).
fn hover_card(sim: &Sim, ui: &mut MapUi, h: Hover, player: Option<DVec3>, out: &mut Vec<Shape>, taken: &mut Vec<[f32; 4]>) {
let mut lines: Vec<(String, u32)> = Vec::new();
let border;
match h {
Hover::Track(id) => {
let pic = sim.picture();
let Some(t) = pic.get(&id) else { return };
border = RED;
track_lines(sim, t, player, &mut lines);
lines.push(("Цель и маршрут сети неизвестны".into(), GREY));
if sim.truth && let Some(d) = sim.drones.iter().find(|d| d.id == id && d.alive()) {
lines.push(("Истина (песочница):".into(), YELLOW));
lines.push((format!("Тип: {} · {}", d.kind.spec().name, aim_text(sim, d)), YELLOW));
}
}
Hover::Drone(id) => {
let Some(d) = sim.drones.iter().find(|d| d.id == id && d.alive()) else { return };
border = YELLOW;
truth_lines(sim, d, player, &mut lines);
lines.push(("Жёлтый пунктир — маршрут и цель; белые рамки — истина.".into(), GREY));
}
}
if lines.is_empty() {
return;
}
let (w, h) = ui.size;
let card_w = 250.0f32.min(w - 16.0);
let lines = wrap_lines(ui, lines, card_w);
let lh = (11.0 * ui.u).round();
let total = lines.len() as f32 * lh + 8.0;
let mut x = ui.cursor.0 + 14.0;
if x + card_w + 4.0 > w {
x = ui.cursor.0 - card_w - 14.0;
}
let x = x.clamp(4.0, (w - card_w - 4.0).max(4.0));
let y = (ui.cursor.1 - 10.0).clamp(4.0, (h - total - 4.0).max(4.0));
out.push(fill(x - 3.0, y - 3.0, card_w + 6.0, total + 6.0, 0xE8101814));
out.extend(frame(x - 3.0, y - 3.0, card_w + 6.0, total + 6.0, 1.0, border));
let mut ty = y;
for (l, c) in &lines {
out.push(text(l.as_str(), x + 2.0, ty, *c));
ty += lh;
}
taken.push([x - 3.0, y - 3.0, card_w + 6.0, total + 6.0]);
}
/// Long lines broken at the card's width.
fn wrap_lines(ui: &mut MapUi, lines: Vec<(String, u32)>, width: f32) -> Vec<(String, u32)> {
let mut wrapped: Vec<(String, u32)> = Vec::new();
for (l, c) in lines {
let mut cur = String::new();
for word in l.split(' ') {
let try_ = if cur.is_empty() { word.to_string() } else { format!("{cur} {word}") };
if ui.tw(&try_) > width - 8.0 && !cur.is_empty() {
wrapped.push((std::mem::take(&mut cur), c));
cur = word.to_string();
} else {
cur = try_;
}
}
wrapped.push((cur, c));
}
wrapped
}
impl AirDef {
/// Opens the map (the key, or the menu).
pub(crate) fn map_toggle(&mut self) {
@@ -810,6 +1099,7 @@ impl AirDef {
"key.keyboard.r" if ui.mode == Mode::Editor => self.map_act(ui, Act::Rotate),
"key.keyboard.delete" | "key.keyboard.backspace" if ui.mode == Mode::Editor => self.map_act(ui, Act::Delete),
"key.keyboard.f" => self.map_act(ui, Act::Follow),
"key.keyboard.t" => self.map_act(ui, Act::Truth),
k if k.len() == 14 && k.starts_with("key.keyboard.") && k.as_bytes()[13].is_ascii_digit() && k.as_bytes()[13] != b'0' => {
let n = (k.as_bytes()[13] - b'1') as usize;
if n < FILTERS.len() {
@@ -915,6 +1205,8 @@ impl AirDef {
ui.pick = Pick::None;
ui.ed_sel = None;
ui.trails.clear();
ui.truth_trails.clear();
ui.truth_seen.clear();
ui.rims.clear();
ui.note(tick, m);
}
@@ -929,6 +1221,17 @@ impl AirDef {
}
}
Act::Filter(i) => ui.filters[i] = !ui.filters[i],
Act::Truth => {
self.sim.truth = !self.sim.truth;
// The two pictures are kept apart: a mode switch starts its trails afresh (#132).
ui.truth_trails.clear();
ui.truth_seen.clear();
ui.note(tick, if self.sim.truth {
"Режим ИСТИНА (песочница): настоящие дроны, их цели и маршруты. Треки сети остаются на карте."
} else {
"Режим данных сети РЛС: только то, что засекли радары."
});
}
Act::Close => {
ui.close = true;
}
@@ -1363,9 +1666,16 @@ impl AirDef {
// The panels first: the labels keep clear of them. They are drawn last, over the picture.
let mut panels: Vec<Shape> = Vec::with_capacity(400);
self.map_panels(ui, &mut panels, &draft);
// The hover card (#132): beside the pointer, over the picture; the labels keep clear of it too.
let hover = if !editing && ui.drag.is_none() { hover_at(&self.sim, ui) } else { None };
let mut hover_taken: Vec<[f32; 4]> = Vec::new();
if let Some(h) = hover {
hover_card(&self.sim, ui, h, crate::player().map(|p| DVec3::new(p.x, p.y, p.z)), &mut panels, &mut hover_taken);
}
let mut s: Vec<Shape> = Vec::with_capacity(2048);
let mut labs: Vec<Lab> = Vec::new();
let mut taken: Vec<[f32; 4]> = ui.blocked.clone();
taken.extend(hover_taken);
// Terrain.
if ui.filters[F_TERRAIN] {
self.map_terrain(ui, &mut s);
@@ -1458,14 +1768,9 @@ impl AirDef {
if ui.filters[F_TRACKS] || ui.filters[F_TRAILS] {
self.map_tracks(ui, &mut s, &mut labs, &mut taken);
}
// The truth, when the sandbox shows it, marked as such.
// The truth, when the sandbox shows it, marked as such: the real drones, their routes and aims.
if self.sim.truth {
for d in &self.sim.drones {
let c = ui.to_screen(d.pos.x, d.pos.z);
if ui.on_screen(c, 4.0) {
s.extend(frame(c.0 - 3.0, c.1 - 3.0, 6.0, 6.0, 1.0, alpha(0xFF4040, 0.9)));
}
}
map_truth(&self.sim, ui, hover, &mut s, &mut labs, &mut taken);
}
// The ghost under the pointer while placing.
if editing && let Some(y) = self.ground_y(cur_world.0, cur_world.1) {
@@ -1929,14 +2234,14 @@ impl AirDef {
if ui.filters[F_TRAILS]
&& let Some(trail) = ui.trails.get(*id)
{
let col = alpha(0xFF6060, if chosen { 0.95 } else { 0.5 });
let col = alpha(0xFF6060, if chosen { 1.0 } else { 0.7 });
let mut prev: Option<(f32, f32)> = None;
for p in trail {
let c = ui.to_screen(p.0 as f64, p.1 as f64);
if let Some(a) = prev
&& (ui.on_screen(a, 0.0) || ui.on_screen(c, 0.0))
{
s.push(line(a, c, 1.0, col));
s.push(line(a, c, if chosen { 2.2 } else { 1.6 }, col));
}
prev = Some(c);
}
@@ -1950,7 +2255,7 @@ impl AirDef {
let m = ui.to_screen(t.pos.x, t.pos.z);
// The last measurement and the forecast from it: dashes, never drawn as a certainty.
if forecast {
s.push(line(m, c, 1.0, alpha(0xFFB0B0, 0.4)));
s.push(line(m, c, 1.4, alpha(0xFFB0B0, 0.45)));
let r = (t.uncertainty(now) * ui.scale) as f32;
ring(ui, s, c, r.min(300.0), 1.0, alpha(0xFFB0B0, 0.5));
}
@@ -1958,7 +2263,7 @@ impl AirDef {
// Ahead along the course for 30 s, dashed.
let v = t.vel;
let ahead = ui.to_screen(e.x + v.x * 600.0, e.z + v.z * 600.0);
dashed(s, c, ahead, alpha(0xFF8080, 0.8));
dashed(s, c, ahead, 1.5, alpha(0xFF8080, 0.85));
}
}
if !ui.filters[F_TRACKS] {
@@ -1974,7 +2279,7 @@ impl AirDef {
.collect();
let pos: Vec<(f32, f32)> = vis.iter().map(|v| v.2).collect();
let solo: Vec<bool> = vis.iter().map(|v| ui.sel == Some(Sel::Track(v.0))).collect();
for grp in groups_of(&pos, &solo, CLUSTER_R * 0.8, true) {
for grp in groups_of(&pos, &solo, TRACK_CLUSTER_R, true) {
if grp.len() > 1 {
let members: Vec<(f32, f32)> = grp.iter().map(|&k| vis[k].2).collect();
draw_cluster(ui, s, taken, &members, RED);
@@ -1985,15 +2290,20 @@ impl AirDef {
let forecast = t.forecast(now);
let age = t.age(now);
let col = if forecast { alpha(0xFFB0B0, 0.65) } else { 0xFFFF5050 };
s.push(diamond(c.0, c.1, 4.0, col));
s.push(diamond(c.0, c.1, TRACK_R, col));
if !forecast {
s.push(diamond(c.0, c.1, 2.0, 0xFF200808));
s.push(diamond(c.0, c.1, 3.0, 0xFF200808));
}
taken.push([c.0 - 5.0, c.1 - 5.0, 10.0, 10.0]);
let txt = format!("{}{}", if forecast { "~" } else { "" }, if age < 20 { "сейчас".to_string() } else { format!("{} с", age / 20) });
add_lab(ui, labs, txt, c, 5.0, col, chosen);
// Its course, a tick out of the marker.
let v = t.vel.normalize_or_zero();
if v != DVec3::ZERO {
s.push(line(c, (c.0 + v.x as f32 * 10.0, c.1 + v.z as f32 * 10.0), 1.5, col));
}
taken.push([c.0 - TRACK_R - 1.0, c.1 - TRACK_R - 1.0, TRACK_R * 2.0 + 2.0, TRACK_R * 2.0 + 2.0]);
let txt = format!("{} {}{}", t.kind.spec().class.letter(), if forecast { "~" } else { "" }, if age < 20 { "сейчас".to_string() } else { format!("{} с", age / 20) });
add_lab(ui, labs, txt, c, TRACK_R + 1.0, col, chosen);
if chosen {
s.extend(frame(c.0 - 8.0, c.1 - 8.0, 16.0, 16.0, 1.0, GREEN));
s.extend(frame(c.0 - 10.0, c.1 - 10.0, 20.0, 20.0, 1.0, GREEN));
}
}
}
@@ -2018,7 +2328,7 @@ impl AirDef {
};
let tail_w = ui.tw(&tail);
let heads: [&str; 2] = if self.sim.truth {
["КАРТА · ИСТИНА (песочница): красные рамки — настоящие дроны", "КАРТА · ИСТИНА"]
["КАРТА · ИСТИНА (песочница): белые рамки — дроны, жёлтое — их цели и маршруты", "КАРТА · ИСТИНА (песочница)"]
} else {
["КАРТА · режим: данные сети РЛС", "КАРТА · сеть РЛС"]
};
@@ -2151,7 +2461,7 @@ impl AirDef {
y += 6.0;
// The mode buttons, in rows that wrap.
let mut bx = x0 - 2.0;
for (label, act, on) in [("Правка (E)", Act::Editor, editing), ("Игрок (C)", Act::Player, false), ("Выход (M)", Act::Close, false)] {
for (label, act, on) in [("Правка (E)", Act::Editor, editing), ("Истина (T)", Act::Truth, self.sim.truth), ("Игрок (C)", Act::Player, false), ("Выход (M)", Act::Close, false)] {
let bw = ui.tw(label) + 10.0;
if bx + bw > lw + 2.0 {
bx = x0 - 2.0;
@@ -2169,7 +2479,7 @@ impl AirDef {
let helps: [&str; 3] = if editing {
["ЛКМ: ставить/переносить · ПКМ: убрать · R · Z · Enter · Esc", "ЛКМ ставить · ПКМ убрать · Enter · Esc", "Enter · Esc"]
} else {
["ЛКМ: выбор, тянуть: сдвиг · колесо: масштаб · ПКМ: марш · Esc", "ЛКМ выбор · колесо масштаб · Esc", "Esc"]
["ЛКМ: выбор, тянуть: сдвиг · колесо: масштаб · T: данные · Esc", "ЛКМ выбор · колесо масштаб · T данные · Esc", "Esc"]
};
for help in helps {
let hw = ui.tw(help);
@@ -2204,21 +2514,7 @@ impl AirDef {
self.sel_card(ui, &mut lines, &mut btns);
}
// Long lines break at the card's width.
let mut wrapped: Vec<(String, u32)> = Vec::new();
for (l, c) in lines {
let mut cur = String::new();
for word in l.split(' ') {
let try_ = if cur.is_empty() { word.to_string() } else { format!("{cur} {word}") };
if ui.tw(&try_) > card_w - 8.0 && !cur.is_empty() {
wrapped.push((std::mem::take(&mut cur), c));
cur = word.to_string();
} else {
cur = try_;
}
}
wrapped.push((cur, c));
}
let lines = wrapped;
let lines = wrap_lines(ui, lines, card_w);
if !lines.is_empty() || !btns.is_empty() {
let mut y = top;
let ch = lines.len() as f32 * lh + 10.0;
@@ -2434,24 +2730,13 @@ impl AirDef {
lines.push((format!("Трек №{id}: потерян сетью"), GREY));
return;
};
lines.push((format!("Трек сети №{id}"), 0xFFFF8080));
lines.push((format!("Опознание: {}", t.ident().name()), WHITE));
let age = t.age(now);
lines.push((
if t.forecast(now) { format!("ПРОГНОЗ: последнее измерение {} с назад", age / 20) } else { format!("Измерение {} с назад", age / 20) },
if t.forecast(now) { YELLOW } else { GREEN },
));
lines.push((format!("Высота {:.0} м, скорость {:.0} км/ч", t.pos.y, t.vel.length() * 20.0 * 3.6), WHITE));
lines.push((format!("Погрешность места до {}", distance(t.uncertainty(now))), GREY));
lines.push(("Цель и маршрут неизвестны сети: тонкая линия —".into(), GREY));
lines.push(("пройденное по измерениям, пунктир — прогноз курса.".into(), GREY));
let player = crate::player().map(|p| DVec3::new(p.x, p.y, p.z));
track_lines(&self.sim, t, player, lines);
lines.push(("Тонкая линия — пройденное по измерениям,".into(), GREY));
lines.push(("пунктир — прогноз курса.".into(), GREY));
if let Some(trail) = ui.trails.get(&id) {
lines.push((format!("Точек измерений: {}", trail.len()), GREY));
}
let who = self.who_tracks(t);
if !who.is_empty() {
lines.push((format!("Держат: {who}"), WHITE));
}
btns.push(("В центр".into(), Act::Centre, false));
btns.push(("Следить (F)".into(), Act::Follow, ui.follow));
}
@@ -2460,18 +2745,16 @@ impl AirDef {
lines.push(("Ничего не выбрано".into(), GREY));
lines.push((format!("Комплексов: {} · объектов: {}", self.sim.sams.len(), self.sim.targets.len()), WHITE));
lines.push((format!("Целей у сети: {} · известных ПУ: {live}", self.sim.picture().len()), WHITE));
if self.sim.truth {
lines.push(("Режим ИСТИНА: настоящие дроны, их цели и маршруты.".into(), YELLOW));
lines.push(("Это песочница, не данные сети. T — обратно.".into(), YELLOW));
}
if self.battle() {
lines.push(("Идёт налёт: расстановка закрыта".into(), YELLOW));
}
}
}
}
/// The systems whose tracks hold this one, by name (the network's own bookkeeping, not the drone's).
fn who_tracks(&self, t: &Track) -> String {
let n = self.sim.sams.iter().filter(|s| s.tracks.iter().any(|x| x.id == t.id)).count();
if n == 0 { String::new() } else { format!("{n} комплексов") }
}
}
fn remove_dsam(d: &mut Draft, i: usize) {
@@ -2538,13 +2821,24 @@ fn ring(ui: &MapUi, s: &mut Vec<Shape>, c: (f32, f32), r: f32, w: f32, color: u3
}
}
fn dashed(s: &mut Vec<Shape>, a: (f32, f32), b: (f32, f32), color: u32) {
fn dashed(s: &mut Vec<Shape>, a: (f32, f32), b: (f32, f32), w: f32, color: u32) {
let (dx, dy) = (b.0 - a.0, b.1 - a.1);
let len = dx.hypot(dy);
let n = ((len / 8.0) as usize).min(200);
for i in (0..n).step_by(2) {
let (t0, t1) = (i as f32 / n as f32, (i + 1) as f32 / n as f32);
s.push(line((a.0 + dx * t0, a.1 + dy * t0), (a.0 + dx * t1, a.1 + dy * t1), 1.0, color));
s.push(line((a.0 + dx * t0, a.1 + dy * t0), (a.0 + dx * t1, a.1 + dy * t1), w, color));
}
}
/// A coarser dash for the truth mode's routes: many drones at once, so fewer, longer dashes.
fn route_dashed(s: &mut Vec<Shape>, a: (f32, f32), b: (f32, f32), color: u32) {
let (dx, dy) = (b.0 - a.0, b.1 - a.1);
let len = dx.hypot(dy);
let n = ((len / 24.0) as usize).clamp(2, 24);
for i in (0..n).step_by(2) {
let (t0, t1) = (i as f32 / n as f32, (i + 1) as f32 / n as f32);
s.push(line((a.0 + dx * t0, a.1 + dy * t0), (a.0 + dx * t1, a.1 + dy * t1), 1.2, color));
}
}
@@ -2602,4 +2896,94 @@ mod tests {
let far: Vec<(f32, f32)> = (0..128).map(|i| (i as f32 * 30.0, 0.0)).collect();
assert_eq!(groups_of(&far, &vec![false; 128], CLUSTER_R, true).len(), 128);
}
/// A drone over the map's middle and a system that has not measured anything yet.
fn hover_fixture() -> (Sim, u32, MapUi) {
let mut sim = Sim::new(1);
sim.launch(sim::DroneKind::Shahed, DVec3::new(0.0, 64.0, 0.0), DVec3::ZERO, DVec3::ZERO, &mut sim::Out::default());
let id = sim.drones[0].id;
let sid = sim.id();
sim.sams.push(Sam::new(sid, SamKind::Buk, DVec3::new(0.0, 64.0, 500.0), 0.0));
let mut ui = MapUi::default();
ui.size = (800.0, 600.0);
ui.centre = (0.0, 0.0);
ui.scale = 1.0;
ui.cursor = (400.0, 300.0);
(sim, id, ui)
}
#[test]
fn hover_reads_the_network_and_only_the_truth_mode_adds_drones() {
let (mut sim, id, ui) = hover_fixture();
// The system holds no track: the drone is not in the network's picture and is not hoverable.
assert_eq!(hover_at(&sim, &ui), None);
sim.truth = true;
assert_eq!(hover_at(&sim, &ui), Some(Hover::Drone(id)));
// A measured track is hoverable in the honest picture too.
sim.truth = false;
let t = Track { id, kind: sim::DroneKind::Shahed, pos: DVec3::new(0.0, 64.0, 0.0), vel: DVec3::ZERO, tick: 0, own_tick: 0, ttl: 200, hits: 3, locked: false };
sim.sams[0].tracks.push(t);
assert_eq!(hover_at(&sim, &ui), Some(Hover::Track(id)));
// Away from the marker there is nothing.
let mut away = ui;
away.cursor = (20.0, 20.0);
assert_eq!(hover_at(&sim, &away), None);
}
#[test]
fn the_network_card_never_claims_a_target_and_lists_its_status_and_interception() {
let (mut sim, id, _) = hover_fixture();
let t = Track { id, kind: sim::DroneKind::Shahed, pos: DVec3::new(0.0, 64.0, 0.0), vel: DVec3::new(0.0, 0.0, 0.5), tick: 0, own_tick: 0, ttl: 200, hits: 3, locked: true };
sim.sams[0].tracks.push(t);
let mut lines = Vec::new();
track_lines(&sim, &t, Some(DVec3::ZERO), &mut lines);
let all: String = lines.iter().map(|l| l.0.as_str()).collect::<Vec<_>>().join(" | ");
for must in ["Трек №", "Статус:", "Источник: сеть", "Скорость:", "Дистанция:", "Огневой захват", "Перехват: ракет нет", "Держат: 1 комплексов"] {
assert!(all.contains(must), "the track card lacks {must}: {all}");
}
assert!(!all.contains("Цель:"), "the network's card claims a target: {all}");
}
#[test]
fn the_truth_card_names_the_type_aim_route_and_interception() {
let (sim, _, ui) = hover_fixture();
let mut lines = Vec::new();
truth_lines(&sim, &sim.drones[0], Some(DVec3::ZERO), &mut lines);
let all: String = lines.iter().map(|l| l.0.as_str()).collect::<Vec<_>>().join(" | ");
for must in ["ИСТИНА", "Шахед", "вне картины сети", "Цель:", "Маршрут:", "До цели:", "Перехват:"] {
assert!(all.contains(must), "the truth card lacks {must}: {all}");
}
assert_eq!(hover_at(&sim, &ui), None, "the truth-off map revealed the drone");
}
#[test]
fn the_truth_layer_draws_white_frames_and_yellow_routes() {
let (mut sim, id, mut ui) = hover_fixture();
sim.truth = true;
// The label's width is cached so the test needs no GUI host call.
let label = format!("{} №{}", sim.drones[0].kind.spec().name, id);
ui.widths.insert(label.clone(), 60.0);
let mut shapes = Vec::new();
let mut labs = Vec::new();
let mut taken = Vec::new();
map_truth(&sim, &mut ui, Some(Hover::Drone(id)), &mut shapes, &mut labs, &mut taken);
assert!(shapes.iter().any(|s| matches!(s, Shape::Fill(f) if f.color == alpha(WHITE, 0.95))), "no white frame for the true drone");
assert!(shapes.iter().any(|s| matches!(s, Shape::Quad(q) if q.color & 0xFFFFFF == 0xFFE070)), "no yellow route or aim");
assert!(labs.iter().any(|l| l.text.contains("Шахед")), "the true drone has no label");
assert!(!taken.is_empty());
}
#[test]
fn the_truth_trail_never_mixes_into_the_network_trail() {
let (mut sim, id, mut ui) = hover_fixture();
sim.tick = SAMPLE;
ui.sample(&sim);
assert!(ui.trails.is_empty() && ui.seen.is_empty(), "the network got the truth's trail");
sim.truth = true;
sim.tick = SAMPLE * 2;
ui.sample(&sim);
assert_eq!(ui.truth_trails.get(&id).map(Vec::len), Some(1));
assert!(ui.trails.is_empty(), "the truth's trail was filed as the network's");
assert!(ui.truth_seen.contains_key(&id) && !ui.seen.contains_key(&id));
}
}
+132 -10
View File
@@ -1,7 +1,8 @@
//! The radar screen (top left): a round scope round the player, north up,
//! with a sweeping beam; blips fade after the beam passes them.
//! The radar screen (bottom right): a round scope round the player, north up,
//! with a sweeping beam; blips fade after the beam passes them. A track's blip is a shape by the
//! class the radar measured (#132), big enough to read at a glance; close ones merge with a count.
use crate::panel::distance;
use crate::sim::{SamKind, Sim};
use crate::sim::{Class, SamKind, Sim};
use glam::DVec3;
use horizon_mod_sdk::render::{FillShape, Point, QuadShape, Rect, Shape, TextShape};
@@ -10,6 +11,10 @@ pub const SIZE: f32 = 112.0;
/// Blocks from the centre to the edge.
const RANGE: f64 = 500.0;
const SEGMENTS: usize = 48;
/// A track blip's half-size: the icons span about six pixels, against the old dot's three and a half.
const BLIP: f32 = 3.0;
/// Tracks this close on the scope merge into one blip with their number.
const MERGE_R: f32 = 4.5;
fn pt(x: f32, y: f32) -> Point {
Point { x, y }
@@ -32,6 +37,32 @@ fn alpha(rgb: u32, a: f64) -> u32 {
((a.clamp(0.0, 1.0) * 255.0) as u32) << 24 | (rgb & 0xFFFFFF)
}
/// A track's blip: a shape by the class the radar measured, pointing along the course where there is one.
/// Дrones are triangles, jets darts, cruise squares, supersonic diamonds, ballistic octagons.
fn blip(class: Class, x: f32, y: f32, color: u32, vel: DVec3) -> Vec<Shape> {
let h = DVec3::new(vel.x, 0.0, vel.z).normalize_or_zero();
let (hx, hy) = if h == DVec3::ZERO { (0.0, -1.0) } else { (h.x as f32, h.z as f32) };
let (px, py) = (-hy, hx);
let r = BLIP;
let at = |along: f32, side: f32| pt(x + hx * along + px * side, y + hy * along + py * side);
match class {
Class::Drone => vec![quad(at(r * 1.2, 0.0), at(-r * 0.8, r * 0.9), at(-r * 0.8, -r * 0.9), at(-r * 0.8, -r * 0.9), color)],
Class::Jet => vec![quad(at(r * 1.3, 0.0), at(-r * 0.9, r * 0.9), at(-r * 0.3, 0.0), at(-r * 0.9, -r * 0.9), color)],
Class::Cruise => vec![square(x, y, 2.6, color)],
Class::Supersonic => vec![quad(pt(x, y - 3.2), pt(x + 3.2, y), pt(x, y + 3.2), pt(x - 3.2, y), color)],
Class::Ballistic => vec![square(x, y, 2.3, color), quad(pt(x, y - r), pt(x + r, y), pt(x, y + r), pt(x - r, y), color)],
}
}
/// Keeps a blip's centre far enough inside the disc that the whole icon stays on the scope: the longest point
/// of any class's icon is 1.3 × a half-size out.
fn inside(x: f32, y: f32, cx: f32, cy: f32, r: f32) -> (f32, f32) {
let (dx, dy) = (x - cx, y - cy);
let d = dx.hypot(dy);
let max = r - BLIP * 1.4 - 0.5;
if d > max && d > 0.0 { (cx + dx / d * max, cy + dy / d * max) } else { (x, y) }
}
pub fn draw(sim: &Sim, player: DVec3, yaw: f32) -> Vec<Shape> {
let mut s = Vec::new();
let r = SIZE / 2.0 - 2.0;
@@ -153,6 +184,8 @@ pub fn draw(sim: &Sim, player: DVec3, yaw: f32) -> Vec<Shape> {
// is a forecast, dimmer); with no system deployed, the sky as it is. Nothing else is read (#93).
let pic = sim.air_picture();
let now = pic.now;
// (x, y, class, colour, brightness, velocity) of every track on the scope, its icon kept inside the disc.
let mut marks: Vec<(f32, f32, Class, u32, f64, DVec3)> = Vec::new();
for t in &pic.tracks {
let (pos, vel) = (t.est(now), t.vel);
match scope(pos) {
@@ -165,24 +198,39 @@ pub fn draw(sim: &Sim, player: DVec3, yaw: f32) -> Vec<Shape> {
} else {
(1.0, 0xFF4040)
};
s.push(square(x, y, 1.8, alpha(color, a)));
// Its heading, a short tail.
let v = vel.normalize_or_zero();
s.push(quad(pt(x, y), pt(x + 0.6, y), pt(x - v.x as f32 * 6.0 + 0.6, y - v.z as f32 * 6.0), pt(x - v.x as f32 * 6.0, y - v.z as f32 * 6.0), alpha(color, a * 0.6)));
let (x, y) = inside(x, y, cx, cy, r);
marks.push((x, y, t.kind.spec().class, color, a, vel));
}
None => far += 1,
}
}
// A tight raid reads as one blip with its number, not a pile of icons.
let pos: Vec<(f32, f32)> = marks.iter().map(|m| (m.0, m.1)).collect();
for grp in crate::map::group(&pos, MERGE_R) {
let (x, y, class, color, a, vel) = marks[grp[0]];
s.extend(blip(class, x, y, alpha(color, a), vel));
// Its heading, a short tail, kept on the disc too.
let v = vel.normalize_or_zero();
let (ex, ey) = inside(x - v.x as f32 * 7.0, y - v.z as f32 * 7.0, cx, cy, r);
s.push(quad(pt(x, y), pt(x + 1.0, y), pt(ex + 1.0, ey), pt(ex, ey), alpha(color, a * 0.6)));
if grp.len() > 1 {
s.push(text(format!("×{}", grp.len()), x + 4.0, y - 9.0, alpha(color, a), false));
}
}
// The true places, when the sandbox asks for them: a white dot beside the track, to see how far the picture is off.
if sim.truth && !pic.unaided {
for d in sim.drones.iter().filter(|d| d.alive()) {
if let Some((x, y, _)) = scope(d.pos) {
s.push(square(x, y, 0.8, 0xFFFFFFFF));
let (x, y) = inside(x, y, cx, cy, r);
s.push(square(x, y, 1.3, 0xFFFFFFFF));
}
}
}
// Labels.
s.push(text(format!("РЛС · {}", distance(RANGE)), cx, SIZE + 2.0, 0xFF80FF90, true));
if sim.truth && !pic.unaided {
s.push(text("ИСТИНА · песочница".into(), cx, SIZE + 12.0, 0xFFFFE070, true));
}
s.push(text("С".into(), cx, 3.0, 0xFF80FF90, true));
if far > 0 {
s.push(text(format!("+{far} за пределом"), cx, SIZE - 14.0, 0xFFFF8080, true));
@@ -193,7 +241,7 @@ pub fn draw(sim: &Sim, player: DVec3, yaw: f32) -> Vec<Shape> {
#[cfg(test)]
mod tests {
use super::*;
use crate::sim::{DroneKind, Out};
use crate::sim::{DroneKind, Out, Sam};
#[test]
fn target_blips_are_drawn_over_the_player_arrow() {
@@ -201,7 +249,81 @@ mod tests {
sim.launch(DroneKind::Shahed, DVec3::new(0.0, 64.0, -10.0), DVec3::ZERO, DVec3::ZERO, &mut Out::default());
let shapes = draw(&sim, DVec3::ZERO, 0.0);
let arrow = shapes.iter().rposition(|s| matches!(s, Shape::Quad(q) if q.color == 0xFFFFFFFF)).unwrap();
let target = shapes.iter().rposition(|s| matches!(s, Shape::Fill(f) if f.color == 0xFFFF4040)).unwrap();
// The Shahed's blip is a red triangle (a quad with a repeated corner), drawn after the arrow.
let target = shapes.iter().rposition(|s| matches!(s, Shape::Quad(q) if q.color == 0xFFFF4040)).unwrap();
assert!(target > arrow, "the player arrow covers the target blip");
}
#[test]
fn every_class_has_its_own_blip_shape() {
let vel = DVec3::new(0.5, 0.0, 0.0);
let shapes: Vec<Vec<Shape>> = Class::ALL.iter().map(|c| blip(*c, 50.0, 50.0, 0xFFFF4040, vel)).collect();
for (i, a) in shapes.iter().enumerate() {
assert!(!a.is_empty());
for b in &shapes[i + 1..] {
assert_ne!(format!("{a:?}"), format!("{b:?}"), "two classes share one icon");
}
}
// A courseless track (a ballistic one straight overhead) still draws, pointing north.
assert!(!blip(Class::Ballistic, 50.0, 50.0, 0xFFFF4040, DVec3::Y).is_empty());
}
#[test]
fn blips_stay_inside_the_scope() {
let mut sim = Sim::new(1);
// One track near the rim on every bearing, one of each class among them, one just beyond it.
for k in 0..8 {
let a = k as f64 / 8.0 * std::f64::consts::TAU;
sim.launch(DroneKind::Shahed, DVec3::new(a.sin() * 495.0, 64.0, a.cos() * 495.0), DVec3::ZERO, DVec3::ZERO, &mut Out::default());
}
for (k, kind) in [DroneKind::Geran3, DroneKind::Kh101, DroneKind::Kh22, DroneKind::Kinzhal].into_iter().enumerate() {
let a = (k as f64 + 0.5) / 4.0 * std::f64::consts::TAU;
sim.launch(kind, DVec3::new(a.sin() * 490.0, 64.0, a.cos() * 490.0), DVec3::ZERO, DVec3::ZERO, &mut Out::default());
}
sim.launch(DroneKind::Shahed, DVec3::new(0.0, 64.0, -700.0), DVec3::ZERO, DVec3::ZERO, &mut Out::default());
let shapes = draw(&sim, DVec3::ZERO, 0.0);
let (cx, cy, r) = (SIZE / 2.0, SIZE / 2.0, SIZE / 2.0 - 2.0);
let mut blips = 0;
for s in &shapes {
let corners = match s {
Shape::Quad(q) if q.color & 0xFFFFFF == 0xFF4040 => vec![q.corners.0, q.corners.1, q.corners.2, q.corners.3],
Shape::Fill(f) if f.color & 0xFFFFFF == 0xFF4040 => vec![pt(f.rect.x, f.rect.y), pt(f.rect.x + f.rect.w, f.rect.y), pt(f.rect.x, f.rect.y + f.rect.h), pt(f.rect.x + f.rect.w, f.rect.y + f.rect.h)],
_ => continue,
};
blips += 1;
for p in corners {
assert!((p.x - cx).hypot(p.y - cy) <= r + 0.01, "a blip corner leaves the disc: {p:?}");
}
}
assert!(blips >= 8, "the rim tracks were not drawn");
assert!(shapes.iter().any(|s| matches!(s, Shape::Text(t) if t.text.contains("за пределом"))), "the track beyond the range is counted");
}
#[test]
fn a_tight_raid_merges_into_one_blip_with_a_count() {
let mut sim = Sim::new(1);
for k in 0..3 {
sim.launch(DroneKind::Shahed, DVec3::new(100.0 + k as f64, 64.0, -100.0), DVec3::ZERO, DVec3::ZERO, &mut Out::default());
}
let shapes = draw(&sim, DVec3::ZERO, 0.0);
assert!(shapes.iter().any(|s| matches!(s, Shape::Text(t) if t.text == "×3")), "the merged blip has no count");
let triangles = shapes
.iter()
.filter(|s| matches!(s, Shape::Quad(q) if q.color & 0xFFFFFF == 0xFF4040 && q.corners.2.x == q.corners.3.x && q.corners.2.y == q.corners.3.y))
.count();
assert_eq!(triangles, 1, "three close tracks drew three icons");
}
#[test]
fn the_truth_mode_is_labelled_on_the_scope() {
let mut sim = Sim::new(1);
let id = sim.id();
sim.sams.push(Sam::new(id, SamKind::Buk, DVec3::new(0.0, 64.0, 0.0), 0.0));
sim.launch(DroneKind::Shahed, DVec3::new(0.0, 64.0, -100.0), DVec3::ZERO, DVec3::ZERO, &mut Out::default());
let plain = draw(&sim, DVec3::ZERO, 0.0);
assert!(!plain.iter().any(|s| matches!(s, Shape::Text(t) if t.text.contains("ИСТИНА"))));
sim.truth = true;
let shapes = draw(&sim, DVec3::ZERO, 0.0);
assert!(shapes.iter().any(|s| matches!(s, Shape::Text(t) if t.text.contains("ИСТИНА") && t.text.contains("песочница"))), "the truth mode is not marked");
}
}
+16
View File
@@ -811,6 +811,18 @@ impl Drone {
pub fn smart(&self) -> bool {
self.smart
}
/// Where it is aimed, without this airframe's navigation error: only the sandbox's truth view reads it (#132).
pub fn aim_pos(&self) -> DVec3 {
self.target - self.err
}
/// The unit it is sent at (0: a marked object), as the aim bookkeeping holds it (#127).
pub fn aim_unit(&self) -> u32 {
self.aim.unit
}
/// The points it flies by on its way, the next first: the truth view draws the route ahead.
pub fn route(&self) -> &[DVec3] {
&self.route
}
/// How much a system wants to shoot it: fast and heavy first, decoys look real.
fn threat(&self, from: DVec3) -> f64 {
self.threat_at(from, self.pos)
@@ -956,6 +968,10 @@ impl MissileKind {
}
impl Missile {
/// The track it is intercepting: the map's hover says whether an interception is under way (#132).
pub fn target(&self) -> u32 {
self.target
}
/// Cold ejection and post-burn coast have no powered exhaust.
pub fn engine_lit(&self) -> bool {
let spec = self.kind.spec();