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:
2026-11-20 22:26:16 +03:00
parent 53fbeced22
commit e5ee15a2ca
23 changed files with 1139 additions and 27 deletions
+21 -2
View File
@@ -25,6 +25,7 @@ pub mod record;
mod sight;
mod terrain;
mod ew;
mod optical;
mod durable;
pub use ew::{AimReport, Confidence, ContactReport, EnemyPictureReport, Intent, PendingReport};
pub mod lights;
@@ -45,6 +46,9 @@ mod sensor_tests;
pub use ew::EW_RADIUS;
pub use damage::{Comps, Part, PartState};
pub use sight::{AirPicture, Ident, LowSensor, Track, RIM_RAYS};
pub use optical::{Optical, OpticalClassEstimate, OpticalObservation, OpticalObservable, OpticalReport, OpticalState, SightBlock};
/// The passive optical post's clear-day reach (the monitor's scale reads it).
pub const OPTICAL_RANGE: f64 = optical::RANGE;
use damage::dice;
use outcome::{Impact, Outcome};
pub use units::{Family, SamKind};
@@ -1240,6 +1244,8 @@ pub struct Sam {
pub(super) terrain: HashMap<u32, (u64, u8)>,
/// Targets whose land hasn't been answered yet, and since when it has been waited for.
waits: HashMap<u32, u64>,
/// A passive optical post's own state (#136): no radar, no track, one class observation at a time.
pub optical: Optical,
}
impl Sam {
@@ -1313,6 +1319,7 @@ impl Sam {
beam_cast: 0,
terrain: HashMap::new(),
waits: HashMap::new(),
optical: Optical::default(),
}
}
pub fn alive(&self) -> bool {
@@ -1552,6 +1559,12 @@ impl Sim {
{
return self.drones.iter().find(|d| d.id == id);
}
// An optical post has no track: its camera looks where it last saw the contact in clear
// sight, and nowhere at all while it has not seen it (#136).
if sam.kind == SamKind::Optical {
let (id, _) = sam.optical.seen(self.tick)?;
return self.drones.iter().find(|d| d.id == id);
}
let id = sam
.gun_target
.or(sam.target)
@@ -1567,6 +1580,9 @@ impl Sim {
{
return Some(self.watched(sam).map_or(at, |d| d.pos));
}
if sam.kind == SamKind::Optical {
return sam.optical.seen(self.tick).map(|(_, p)| p);
}
self.watched(sam).map(|d| d.pos)
}
@@ -2306,7 +2322,7 @@ impl Sim {
if self.hold {
for i in 0..self.sams.len() {
if self.sams[i].alive() && !self.sams[i].moving() {
if self.sams[i].alive() && !self.sams[i].moving() && self.sams[i].kind != SamKind::Optical {
self.sams[i].state = SamState::Hold;
}
self.draw_sam(i, out);
@@ -2362,7 +2378,10 @@ impl Sim {
}
if !self.sams[i].kind.armed() {
let sam = &mut self.sams[i];
sam.state = SamState::Search;
// An optical post's state is its optics' (#136), not the armed systems' search line.
if sam.kind != SamKind::Optical {
sam.state = SamState::Search;
}
// A searchlight's target is its beam's (step_lights): kept for its spot of light.
if sam.kind != SamKind::Light {
retarget(&mut missile_on, sam.target.take(), None);