diff options
Diffstat (limited to 'crates/fparkan-runtime/src/satellite_contacts.rs')
| -rw-r--r-- | crates/fparkan-runtime/src/satellite_contacts.rs | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/crates/fparkan-runtime/src/satellite_contacts.rs b/crates/fparkan-runtime/src/satellite_contacts.rs index 31181bc1..13c918a4 100644 --- a/crates/fparkan-runtime/src/satellite_contacts.rs +++ b/crates/fparkan-runtime/src/satellite_contacts.rs @@ -73,12 +73,26 @@ pub fn visible_buildings( engine: &Engine, cockpit: StartingCockpit, extent: f32, + selected: Option<ObjectHandle>, ) -> impl Iterator<Item = BuildingContact> + '_ { + let selected = selected.filter(|&target| { + identity_metadata(&engine.world, target) + .ok() + .and_then(|identity| identity.owner_id) + .is_some_and(|owner| { + identity_metadata(&engine.world, cockpit.handle) + .is_ok_and(|identity| identity.owner_id == Some(owner)) + }) + }); visible_contacts(engine, cockpit, extent, |_, class| icon_x(class)).map( - |(pixel, _, _, tint, icon_x)| BuildingContact { + move |(pixel, handle, _, tint, icon_x)| BuildingContact { pixel, icon_x, - tint, + tint: if Some(handle) == selected { + [255; 3] + } else { + tint + }, }, ) } @@ -460,14 +474,14 @@ mod tests { icon_x: 72, tint: super::OWN_TINT, }; - assert!(!visible_buildings(&engine, cockpit, extent).any(|contact| contact == marker)); + assert!(!visible_buildings(&engine, cockpit, extent, None).any(|contact| contact == marker)); let owner = identity_metadata(&engine.world, cockpit.handle) .unwrap() .owner_id; assert!(owner.is_some()); set_owner(&mut engine.world, handle, owner).unwrap(); - assert!(visible_buildings(&engine, cockpit, extent).any(|contact| contact == marker)); + assert!(visible_buildings(&engine, cockpit, extent, None).any(|contact| contact == marker)); let table = loaded_mission_control_device_tables(&engine) .unwrap() @@ -488,6 +502,6 @@ mod tests { assert!(registration_sequence(&engine.world, handle) .unwrap() .is_some()); - assert!(!visible_buildings(&engine, cockpit, extent).any(|contact| contact == marker)); + assert!(!visible_buildings(&engine, cockpit, extent, None).any(|contact| contact == marker)); } } |
