Add passive optical observation post (#136)
- new Optical unit kind with its own catalog row and deploy item - bounded one-contact line-of-sight checks against land and blocks - day/night reach and hold timing; obstacle and unknown geometry block sight - independent class observation with source, time and uncertainty, never DroneKind - map/monitor/panel statuses and a line to the selected contact - tests: day/night, wall/unknown, ageing, no kind leak, bounded work, passivity Cherry-picked from 3ae21123964a9d3234bb2b3efc9ff926d64fc77d onto the #132/#133/#134 base: the cue test's track literal now carries the shared class/source/product/quality contract instead of a DroneKind. Co-Authored-By: Kimi Code <noreply@moonshot.ai>
This commit is contained in:
+64
-15
@@ -3,7 +3,7 @@
|
||||
//! renders it) locked on its target. K shows one system at a time, J all of
|
||||
//! them in a grid.
|
||||
use crate::panel::distance;
|
||||
use crate::sim::{ClassEst, Sam, SamState, Sim, heading_of, roles_text};
|
||||
use crate::sim::{ClassEst, OpticalState, Sam, SamKind, SamState, Sim, heading_of, roles_text};
|
||||
use glam::DVec3;
|
||||
use horizon_mod_sdk::render::{self, CameraView, FillShape, Point, QuadShape, Rect, Shape, TextShape, ViewShape};
|
||||
|
||||
@@ -91,12 +91,23 @@ fn cell(sim: &Sim, index: usize, x: f32, y: f32, w: f32, h: f32, s: &mut Vec<Sha
|
||||
s.push(fill(x, y, w, h, 0xC0080C0A));
|
||||
s.push(fill(x, y, w, 12.0, 0xE0142018));
|
||||
let state = sam.state;
|
||||
let optical = sam.kind == SamKind::Optical;
|
||||
let lock = matches!(state, SamState::Lock | SamState::Launch | SamState::Fire);
|
||||
let blink = lock && (tick / 4) % 2 == 0;
|
||||
let label = state.name();
|
||||
let label = if optical { sam.optical.state().name() } else { state.name() };
|
||||
let color = if optical {
|
||||
match sam.optical.state() {
|
||||
OpticalState::Observing => 0xFF60FF80,
|
||||
OpticalState::Holding => 0xFF9FE0FF,
|
||||
OpticalState::NoSight => 0xFFFFA040,
|
||||
OpticalState::Searching => 0xFFE0E0E0,
|
||||
}
|
||||
} else {
|
||||
state.color()
|
||||
};
|
||||
let lw = render::text_width(label);
|
||||
s.push(text(fit(format!("№{} {}", index + 1, spec.name), w - lw - 12.0), x + 3.0, y + 2.0, 0xFF9FE0FF));
|
||||
s.push(text(label, x + w - 3.0 - lw, y + 2.0, argb(state.color(), if blink { 0x80 } else { 0xFF })));
|
||||
s.push(text(label, x + w - 3.0 - lw, y + 2.0, argb(color, if blink { 0x80 } else { 0xFF })));
|
||||
|
||||
// The radar, at the left: round the system, north up.
|
||||
let rr = ((h - 28.0) / 2.0).min(w * 0.2).max(10.0);
|
||||
@@ -114,9 +125,13 @@ fn cell(sim: &Sim, index: usize, x: f32, y: f32, w: f32, h: f32, s: &mut Vec<Sha
|
||||
}
|
||||
// A system that only fires (no radar) has no reach: a radar's sensor
|
||||
// range stands in, and nothing is divided by zero.
|
||||
let reach = match sam.kind.range() {
|
||||
r if r > 0.0 => r,
|
||||
_ => spec.sensor,
|
||||
let reach = if optical {
|
||||
crate::sim::OPTICAL_RANGE
|
||||
} else {
|
||||
match sam.kind.range() {
|
||||
r if r > 0.0 => r,
|
||||
_ => spec.sensor,
|
||||
}
|
||||
};
|
||||
let scale = if reach > 0.0 { rr as f64 / (reach * 1.25) } else { 0.0 };
|
||||
// The beam is the radar's real one: targets are measured as it passes them.
|
||||
@@ -168,7 +183,9 @@ fn cell(sim: &Sim, index: usize, x: f32, y: f32, w: f32, h: f32, s: &mut Vec<Sha
|
||||
}
|
||||
}
|
||||
s.push(fill(rx - 1.5, ry - 1.5, 3.0, 3.0, 0xFF40A0FF));
|
||||
let radar_text = if spec.sensor <= 0.0 {
|
||||
let radar_text = if optical {
|
||||
format!("ОПТИКА · {}", sam.optical.state().name())
|
||||
} else if spec.sensor <= 0.0 {
|
||||
format!("сеть · {seen}")
|
||||
} else if radar_up {
|
||||
let profile = sam.radar_profile();
|
||||
@@ -177,7 +194,19 @@ fn cell(sim: &Sim, index: usize, x: f32, y: f32, w: f32, h: f32, s: &mut Vec<Sha
|
||||
} else {
|
||||
"РЛС ОТКАЗ".to_string()
|
||||
};
|
||||
s.push(text(fit(radar_text, rr * 2.0 + 4.0), x + 4.0, y + h - 10.0, if spec.sensor > 0.0 && !radar_up { 0xFFFF5040 } else { 0xFF80FF90 }));
|
||||
let radar_color = if optical {
|
||||
match sam.optical.state() {
|
||||
OpticalState::Observing => 0xFF60FF80,
|
||||
OpticalState::Holding => 0xFF9FE0FF,
|
||||
OpticalState::NoSight => 0xFFFFA040,
|
||||
OpticalState::Searching => 0xFFB0B0B0,
|
||||
}
|
||||
} else if spec.sensor > 0.0 && !radar_up {
|
||||
0xFFFF5040
|
||||
} else {
|
||||
0xFF80FF90
|
||||
};
|
||||
s.push(text(fit(radar_text, rr * 2.0 + 4.0), x + 4.0, y + h - 10.0, radar_color));
|
||||
|
||||
// Its health under the radar: a bar, red when it is low.
|
||||
if sam.alive() && sam.health < 1.0 {
|
||||
@@ -223,6 +252,21 @@ fn cell(sim: &Sim, index: usize, x: f32, y: f32, w: f32, h: f32, s: &mut Vec<Sha
|
||||
s.push(fill(cx + 3.0, cy + ch / 2.0 - 0.5, cw * 0.18, 1.0, 0x90FFFFFF));
|
||||
s.push(fill(cx + cw * 0.82 - 3.0, cy + ch / 2.0 - 0.5, cw * 0.18, 1.0, 0x90FFFFFF));
|
||||
match target {
|
||||
Some(_) if optical => {
|
||||
// The optical post's picture: its own class observation, never the true model name.
|
||||
let (color, info) = match sam.optical.state() {
|
||||
OpticalState::Observing => (0xFF60FF80, sam.optical.status_text()),
|
||||
OpticalState::Holding => (0xFF9FE0FF, sam.optical.status_text()),
|
||||
OpticalState::NoSight => (0xFFFFA040, sam.optical.status_text()),
|
||||
OpticalState::Searching => (0xFFB0B0B0, sam.optical.status_text()),
|
||||
};
|
||||
let (bw, bh) = (cw * 0.3, ch * 0.34);
|
||||
brackets(s, cx + cw / 2.0 - bw / 2.0, cy + ch / 2.0 - bh / 2.0, bw, bh, 6.0, color);
|
||||
if ch > 50.0 {
|
||||
s.push(text(fit(info.clone(), cw - 6.0), cx + 3.0, cy + ch - 20.0, color));
|
||||
}
|
||||
s.push(text(fit(info, cw - 6.0), cx + 3.0, cy + ch - 10.0, 0xFFC0FFC0));
|
||||
}
|
||||
Some(t) => {
|
||||
let color = if lock { if blink { 0xFFFF3030 } else { 0xFFFF8080 } } else { 0xFFFFE060 };
|
||||
let (bw, bh) = (cw * 0.3, ch * 0.34);
|
||||
@@ -257,19 +301,24 @@ fn cell(sim: &Sim, index: usize, x: f32, y: f32, w: f32, h: f32, s: &mut Vec<Sha
|
||||
}
|
||||
s.push(text(fit(info, cw - 6.0), cx + 3.0, cy + ch - 10.0, 0xFFC0FFC0));
|
||||
}
|
||||
None if optical => s.push(text(fit(sam.optical.status_text(), cw - 6.0), cx + 3.0, cy + ch - 10.0, 0xFFB0B0B0)),
|
||||
None => s.push(text("ПОИСК", cx + 3.0, cy + ch - 10.0, 0xFF80FF90)),
|
||||
}
|
||||
|
||||
// What it carries and does.
|
||||
let mut line = String::new();
|
||||
if !matches!(sam.kind, crate::sim::SamKind::Gepard) {
|
||||
line += &format!("Р{} ", sam.missiles);
|
||||
if sam.kind == crate::sim::SamKind::S400 { line += &format!("У{} ", sam.ground_rounds); }
|
||||
if optical {
|
||||
line = sam.optical.status_text();
|
||||
} else {
|
||||
if !matches!(sam.kind, SamKind::Gepard) {
|
||||
line += &format!("Р{} ", sam.missiles);
|
||||
if sam.kind == SamKind::S400 { line += &format!("У{} ", sam.ground_rounds); }
|
||||
}
|
||||
if crate::sim::catalog::unit(sam.kind).has_gun() {
|
||||
line += &format!("Оч{} ", sam.bursts);
|
||||
}
|
||||
line += &format!("сб.{} [{}]", sam.kills, roles_text(sam.roles));
|
||||
}
|
||||
if crate::sim::catalog::unit(sam.kind).has_gun() {
|
||||
line += &format!("Оч{} ", sam.bursts);
|
||||
}
|
||||
line += &format!("сб.{} [{}]", sam.kills, roles_text(sam.roles));
|
||||
s.push(text(fit(line, cw), cx, y + h - 10.0, 0xFF9FE0FF));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user