Prototype finite interceptor motor and coast

Co-authored-by: Codex <codex@openai.com>
This commit is contained in:
2026-11-02 23:50:33 +03:00
parent b377a5d8d2
commit 143d9b2858
4 changed files with 71 additions and 11 deletions
+13 -2
View File
@@ -253,6 +253,7 @@ pub struct Event {
pub enum SceneKind {
MissileLaunch { missile: u32, sam: u32, target: u32, kind: MissileKind, sound: &'static str, pitch: f32 },
MotorIgnition { missile: u32, kind: MissileKind, sound: Option<&'static str> },
MotorBurnout { missile: u32, kind: MissileKind },
TrackAcquired { sam: u32, target: u32, ever_own: bool },
TrackLost { sam: u32, target: u32 },
TrackSource { sam: u32, target: u32, ever_own: bool },
@@ -281,6 +282,7 @@ pub struct SceneJournal {
fire_events: Vec<usize>,
launches: HashMap<u32, usize>,
ignitions: HashMap<u32, usize>,
burnouts: HashMap<u32, usize>,
}
impl SceneJournal {
@@ -296,6 +298,7 @@ impl SceneJournal {
match event.kind {
SceneKind::MissileLaunch { missile, .. } => { self.launches.insert(missile, index); }
SceneKind::MotorIgnition { missile, .. } => { self.ignitions.insert(missile, index); }
SceneKind::MotorBurnout { missile, .. } => { self.burnouts.insert(missile, index); }
SceneKind::FireStarted { .. } | SceneKind::FireChanged { .. } | SceneKind::FireEnded { .. } => self.fire_events.push(index),
_ => {}
}
@@ -623,9 +626,17 @@ impl Recording {
/// Recorded ignition takes precedence; older/incomplete tracks retain their original fallback.
pub fn missile_is_lit(&self, tr: &Track, t: f64, cold: u32) -> bool {
if let Some(event) = self.missile_ignition(tr.id) { return t >= event.at as f64; }
if let Some(scene) = &self.scene
&& let Some(index) = scene.burnouts.get(&tr.id)
&& t >= scene.events[*index].at as f64 { return false; }
if let Some(event) = self.missile_ignition(tr.id) {
let burn = match tr.what { What::Missile(kind, _) => kind.burn_ticks(), _ => return false };
return t >= event.at as f64 && t < event.at as f64 + burn as f64;
}
if self.missile_launch(tr.id).is_some() && self.scene.as_ref().is_some_and(|s| !s.truncated) { return false; }
t - tr.first as f64 > cold as f64
let age = t - tr.first as f64;
let burn = match tr.what { What::Missile(kind, _) => kind.burn_ticks(), _ => return false };
age > cold as f64 && age <= (cold + burn) as f64
}
fn note_tracks(&mut self, sams: &[Sam]) {