Co-Authored-By: Kimi <noreply@moonshot.ai>
This commit is contained in:
@@ -153,6 +153,8 @@ pub enum What {
|
||||
Drone(DroneKind),
|
||||
/// An interceptor and the system that fired it.
|
||||
Missile(MissileKind, u32),
|
||||
/// A counter-strike missile on its way to a launch site (#109).
|
||||
Strike,
|
||||
}
|
||||
|
||||
pub struct Track {
|
||||
@@ -195,6 +197,8 @@ pub enum StrikeResult {
|
||||
Intercepted,
|
||||
/// Off the map: its launches ended, nothing to see.
|
||||
Halted,
|
||||
/// It met the land or a building short of its aim (#106): it went off there.
|
||||
Blocked,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug)]
|
||||
@@ -357,7 +361,7 @@ pub fn strike_power(result: StrikeResult) -> u32 {
|
||||
match result {
|
||||
StrikeResult::Destroyed => 3,
|
||||
StrikeResult::Stunned => 2,
|
||||
StrikeResult::Missed => 1,
|
||||
StrikeResult::Missed | StrikeResult::Blocked => 1,
|
||||
StrikeResult::Intercepted | StrikeResult::Halted => 0,
|
||||
}
|
||||
}
|
||||
@@ -379,7 +383,7 @@ pub fn blast_spec(kind: EventKind) -> (f32, u32) {
|
||||
EventKind::Split { .. } => (2.0, 7 * 9),
|
||||
EventKind::Strike { result, .. } => match result {
|
||||
StrikeResult::Destroyed => (SIZE[4], LIFE[4] * 9),
|
||||
StrikeResult::Stunned | StrikeResult::Missed => (SIZE[3], LIFE[3] * 9),
|
||||
StrikeResult::Stunned | StrikeResult::Missed | StrikeResult::Blocked => (SIZE[3], LIFE[3] * 9),
|
||||
StrikeResult::Intercepted => (SIZE[0], LIFE[0] * 9),
|
||||
StrikeResult::Halted => (0.0, 0),
|
||||
},
|
||||
@@ -570,14 +574,15 @@ impl Sim {
|
||||
}
|
||||
}
|
||||
|
||||
/// Once a tick: starts a recording with the first drone, adds the tracks' points, ends it
|
||||
/// when the sky has been clear 5 s.
|
||||
/// Once a tick: starts a recording with the first drone or counter-strike in the air, adds the tracks' points,
|
||||
/// ends it when the sky has been clear 5 s.
|
||||
pub(super) fn record(&mut self) {
|
||||
// Wrecks still falling (far off they fall a long while) don't keep it going.
|
||||
let busy = self.drones.iter().any(|d| d.alive()) || !self.missiles.is_empty() || !self.queue.is_empty();
|
||||
// Wrecks still falling (far off they fall a long while) don't keep it going. A counter-strike is a recorded
|
||||
// object in its own right (#109): it holds the recording open until it lands, whatever the sky is doing.
|
||||
let busy = self.drones.iter().any(|d| d.alive()) || !self.missiles.is_empty() || !self.queue.is_empty() || !self.strikes.flights.is_empty();
|
||||
if self.rec.is_none() {
|
||||
// It starts with the first drone in the sky (not with a raid's drones still waiting).
|
||||
if !self.drones.iter().any(|d| d.alive()) {
|
||||
// It starts with the first drone or strike missile in the air (not with a raid's drones still waiting).
|
||||
if !self.drones.iter().any(|d| d.alive()) && self.strikes.flights.is_empty() {
|
||||
return;
|
||||
}
|
||||
self.recordings += 1;
|
||||
@@ -599,6 +604,9 @@ impl Sim {
|
||||
for m in &self.missiles {
|
||||
r.point(m.id, What::Missile(m.kind, m.sam), m.pos);
|
||||
}
|
||||
for f in &self.strikes.flights {
|
||||
r.point(f.track(), What::Strike, f.pos);
|
||||
}
|
||||
}
|
||||
r.len += 1;
|
||||
r.quiet = if busy { 0 } else { r.quiet + 1 };
|
||||
@@ -665,6 +673,16 @@ impl Sim {
|
||||
out.model(id + 1, "airdef:flame", pos + rot * DVec3::new(0.0, 0.0, back), rot, spec.flame, true);
|
||||
}
|
||||
}
|
||||
What::Strike => {
|
||||
// The same model, flame and turn the live flight drew (#106, #109).
|
||||
let spec = DroneKind::Kalibr.spec();
|
||||
let rot = look(dir, 0.0);
|
||||
out.model(id, spec.model, pos, rot, spec.scale, false);
|
||||
if let Engine::Jet(up, back, size) = spec.engine {
|
||||
let flicker = 0.7 + 0.3 * (t * 1.7).sin().abs();
|
||||
out.model(id + 1, "airdef:geran3_flame", pos + rot * DVec3::new(0.0, up * spec.scale, back * spec.scale), rot, spec.scale * size * flicker, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
// The air-defence systems as they stood: where, which way, the launcher or turret where it
|
||||
|
||||
Reference in New Issue
Block a user