diff options
| author | Valentin Popov <valentin@popov.link> | 2026-12-01 17:52:41 +0300 |
|---|---|---|
| committer | Valentin Popov <valentin@popov.link> | 2026-12-01 17:52:41 +0300 |
| commit | f7c5c3bffd565bb6b0995a220ecb7788471b7848 (patch) | |
| tree | 09c33ae6a42b491035c3f0cf53bdefb604da72ff /crates/fparkan-runtime/src/control_resources.rs | |
| parent | 5f4850555ac2fd62009cffd5e98ea04c081bbaf7 (diff) | |
| download | fparkan-f7c5c3bffd565bb6b0995a220ecb7788471b7848.tar.xz fparkan-f7c5c3bffd565bb6b0995a220ecb7788471b7848.zip | |
fix(control): select authored drive states for mobile power demand
Diffstat (limited to 'crates/fparkan-runtime/src/control_resources.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/control_resources.rs | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/crates/fparkan-runtime/src/control_resources.rs b/crates/fparkan-runtime/src/control_resources.rs index 0b1f853b..095ac3ab 100644 --- a/crates/fparkan-runtime/src/control_resources.rs +++ b/crates/fparkan-runtime/src/control_resources.rs @@ -1,5 +1,6 @@ use crate::{ - control_profile, control_resource_budget_pass_with_motion, mobile_budget::DriveMotion, + control_profile, control_resource_budget_pass_with_motion, + mobile_budget::{DriveMotion, DriveStateSelection}, repair_zone, ControlProfileReport, Engine, MissionControlDeviceTableStatus, MobileBudgetReport, }; use fparkan_world::{transform_state, ObjectHandle, TransformState}; @@ -111,6 +112,22 @@ pub(super) fn tick(engine: &mut Engine, now_ms: u32) { }; let frame_seconds = (now_ms as f32 - clock.frame_ms) * 0.001; let previous_pose = clock.previous_pose.replace(pose); + let motion = previous_pose + .filter(|_| mobile_owner && frame_seconds > 0.0) + .and_then(|previous| { + let can_fly = table + .original_id + .and_then(|id| mission.unit_chassis_flags.get(&id.0)) + .and_then(|flags| flags.can_fly)?; + DriveMotion::sample( + table, + &mission.mission_assets, + [previous, pose], + frame_seconds, + can_fly, + &mut clock.drive_state, + ) + }); // Control.dll+0x42480: default resource period; this is a separate RNG from Behavior. let Some(seconds) = clock.step(now_ms as f32, true, 250.0, &mut state.rng) else { continue; @@ -162,19 +179,6 @@ pub(super) fn tick(engine: &mut Engine, now_ms: u32) { } } } - let motion = previous_pose.filter(|_| mobile_owner).and_then(|previous| { - let can_fly = table - .original_id - .and_then(|id| mission.unit_chassis_flags.get(&id.0)) - .and_then(|flags| flags.can_fly)?; - DriveMotion::sample( - table, - &mission.mission_assets, - [previous, pose], - frame_seconds, - can_fly, - ) - }); match control_resource_budget_pass_with_motion(table, seconds, motion) { Ok(()) => { state @@ -240,6 +244,7 @@ struct ResourceClock { resource_ms: f32, forced: u32, alarm: control_profile::DamageAlarm, + drive_state: DriveStateSelection, } impl ResourceClock { |
