aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/autodemo.rs
diff options
context:
space:
mode:
authorValentin Popov <valentin@popov.link>2026-12-02 08:12:48 +0300
committerValentin Popov <valentin@popov.link>2026-12-02 08:12:48 +0300
commitea9051e68a9de762a3d6f79c2e8d26bd1ce4310c (patch)
treef97e7492be703434471a16440300bf94d5214f9f /crates/fparkan-runtime/src/autodemo.rs
parent9bb041a090dab428469647a203a57147a5d09c0b (diff)
downloadfparkan-ea9051e68a9de762a3d6f79c2e8d26bd1ce4310c.tar.xz
fparkan-ea9051e68a9de762a3d6f79c2e8d26bd1ce4310c.zip
feat(ui): show the original framed map in AutoDemo
Diffstat (limited to 'crates/fparkan-runtime/src/autodemo.rs')
-rw-r--r--crates/fparkan-runtime/src/autodemo.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/crates/fparkan-runtime/src/autodemo.rs b/crates/fparkan-runtime/src/autodemo.rs
index fe0bfd19..ab793fb2 100644
--- a/crates/fparkan-runtime/src/autodemo.rs
+++ b/crates/fparkan-runtime/src/autodemo.rs
@@ -431,6 +431,22 @@ fn read_setting(bytes: &[u8], key: &str) -> Option<u32> {
}
impl AutoDemoCamera {
+ /// Unit selected while the automatic camera shows the strategic map.
+ pub fn strategy_map_target(&self, snapshot: &WorldSnapshot) -> Option<StartingCockpit> {
+ if self.phase != 0 || self.last_clock_ms.is_none() {
+ return None;
+ }
+ self.targets
+ .get(self.target_index)
+ .copied()
+ .filter(|target| {
+ snapshot
+ .transforms
+ .iter()
+ .any(|(handle, _)| *handle == target.handle)
+ })
+ }
+
/// Replaces the camera target for a reused model slot, or adds a new target.
pub fn register_target(&mut self, cockpit: StartingCockpit) {
if let Some(target) = self
@@ -595,6 +611,11 @@ mod tests {
demo.sample_with_height(0, &snapshot, terrain).unwrap(),
AutoDemoView::Exterior { bird: false, .. }
));
+ assert_eq!(
+ demo.strategy_map_target(&snapshot)
+ .map(|target| target.handle),
+ Some(cockpit(0).handle)
+ );
assert!(matches!(
demo.sample_with_height(5_000, &snapshot, terrain).unwrap(),
AutoDemoView::Exterior { bird: false, .. }
@@ -603,6 +624,7 @@ mod tests {
demo.sample_with_height(5_001, &snapshot, terrain).unwrap(),
AutoDemoView::Exterior { bird: true, .. }
));
+ assert!(demo.strategy_map_target(&snapshot).is_none());
assert!(matches!(
demo.sample_with_height(15_001, &snapshot, terrain).unwrap(),
AutoDemoView::Exterior { bird: true, .. }