aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime
diff options
context:
space:
mode:
Diffstat (limited to 'crates/fparkan-runtime')
-rw-r--r--crates/fparkan-runtime/src/lib.rs7
-rw-r--r--crates/fparkan-runtime/src/unit_combat.rs9
2 files changed, 14 insertions, 2 deletions
diff --git a/crates/fparkan-runtime/src/lib.rs b/crates/fparkan-runtime/src/lib.rs
index 1a9eb405..cdd8d35a 100644
--- a/crates/fparkan-runtime/src/lib.rs
+++ b/crates/fparkan-runtime/src/lib.rs
@@ -3459,6 +3459,13 @@ pub fn autonomous_weapon_effects(engine: &Engine) -> &[(String, String)] {
pub fn autodemo_projectiles(
engine: &Engine,
) -> impl Iterator<Item = (usize, PlayerProjectile)> + '_ {
+ autonomous_projectile_flights(engine).map(|(_, projectile, pose)| (projectile, pose))
+}
+
+/// Active autonomous flights with IDs stable across combat steps and pool reuse.
+pub fn autonomous_projectile_flights(
+ engine: &Engine,
+) -> impl Iterator<Item = (u64, usize, PlayerProjectile)> + '_ {
engine
.autodemo_combat
.iter()
diff --git a/crates/fparkan-runtime/src/unit_combat.rs b/crates/fparkan-runtime/src/unit_combat.rs
index 2d6a3715..1ebbac2a 100644
--- a/crates/fparkan-runtime/src/unit_combat.rs
+++ b/crates/fparkan-runtime/src/unit_combat.rs
@@ -95,6 +95,7 @@ pub(super) struct AutoDemoCombat {
projectiles: Vec<AutoDemoProjectileType>,
weapon_effects: Vec<(String, String)>,
flights: Vec<Flight>,
+ next_flight_id: u64,
finished_segments: Vec<(usize, [[f32; 3]; 2])>,
pose_failures: super::WeaponPoseReport,
pub(super) report: CombatReport,
@@ -130,6 +131,7 @@ impl Unit {
}
struct Flight {
+ id: u64,
shooter: ObjectHandle,
shooter_identity: CombatObject,
projectile: usize,
@@ -171,6 +173,7 @@ impl AutoDemoCombat {
projectiles: Vec::new(),
weapon_effects: Vec::new(),
flights: Vec::new(),
+ next_flight_id: 0,
finished_segments: Vec::new(),
pose_failures: super::WeaponPoseReport::default(),
report: CombatReport::default(),
@@ -320,10 +323,10 @@ impl AutoDemoCombat {
.aim(component)
}
- pub(super) fn flights(&self) -> impl Iterator<Item = (usize, PlayerProjectile)> + '_ {
+ pub(super) fn flights(&self) -> impl Iterator<Item = (u64, usize, PlayerProjectile)> + '_ {
self.flights
.iter()
- .map(|flight| (flight.projectile, flight.pose))
+ .map(|flight| (flight.id, flight.projectile, flight.pose))
}
pub(super) fn segments(&self) -> impl Iterator<Item = (usize, [[f32; 3]; 2])> + '_ {
@@ -701,12 +704,14 @@ impl AutoDemoCombat {
PlayerProjectile::new(from, direction, data.speed, data.lifetime_ms, now)
{
self.flights.push(Flight {
+ id: self.next_flight_id,
shooter: unit.handle,
shooter_identity: shooter,
projectile,
pose,
segment: None,
});
+ self.next_flight_id += 1;
self.report
.shot(shooter, CombatObject::read(&engine.world, target), now);
events.push(AutoDemoCombatEvent::Shot {