aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/control_resources.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/fparkan-runtime/src/control_resources.rs')
-rw-r--r--crates/fparkan-runtime/src/control_resources.rs33
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 {