aboutsummaryrefslogtreecommitdiff
path: root/crates/fparkan-runtime/src/autodemo.rs
diff options
context:
space:
mode:
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, .. }