diff --git a/crates/render/src/ui/manager.rs b/crates/render/src/ui/manager.rs index 233af29..462d091 100644 --- a/crates/render/src/ui/manager.rs +++ b/crates/render/src/ui/manager.rs @@ -25,10 +25,11 @@ impl UiManager { /// Draw all ui elements pub fn draw(&mut self, input: &RenderInput, state: &mut RenderState) { let ship_handle = input.player.ship.unwrap(); - let ship = input - .systemsim + let ship = &input + .phys_img .get_ship(&PhysSimShipHandle(ship_handle)) - .unwrap(); + .unwrap() + .ship; self.fps.update(input, state); diff --git a/crates/render/src/ui/planet.rs b/crates/render/src/ui/planet.rs index 72330ba..8f9916f 100644 --- a/crates/render/src/ui/planet.rs +++ b/crates/render/src/ui/planet.rs @@ -114,10 +114,11 @@ impl Planet { pub fn draw(&mut self, input: &RenderInput, state: &mut RenderState) { // Get required data let ship_handle = input.player.ship.unwrap(); - let ship_data = input - .systemsim + let ship_data = &input + .phys_img .get_ship(&PhysSimShipHandle(ship_handle)) - .unwrap(); + .unwrap() + .ship; let planet_handle = match ship_data.get_data().get_state() { ShipState::Landed { target } => *target, _ => unreachable!("tried to draw planet interface while not landed!"), diff --git a/crates/render/src/ui/radar.rs b/crates/render/src/ui/radar.rs index 3899ca1..faa227e 100644 --- a/crates/render/src/ui/radar.rs +++ b/crates/render/src/ui/radar.rs @@ -28,13 +28,13 @@ impl Radar { // TODO: maybe a cleaner solution for last posititon? // This is necessary because the player may be dead or landed let player_ship = input - .systemsim + .phys_img .get_ship(&galactica_system::phys::PhysSimShipHandle( input.player.ship.unwrap(), )) .unwrap(); - match player_ship.get_data().get_state() { + match player_ship.ship.get_data().get_state() { ShipState::Dead => {} ShipState::Landed { target } => { @@ -46,12 +46,7 @@ impl Radar { | ShipState::Landing { .. } | ShipState::Flying { .. } | ShipState::Collapsing { .. } => { - let player_body = input - .systemsim - .get_rigid_body(player_ship.rigid_body) - .unwrap(); - - self.last_player_position = (*player_body.translation()).into(); + self.last_player_position = (*player_ship.rigidbody.translation()).into(); } }; @@ -111,9 +106,9 @@ impl Radar { } // Draw ships - for (s, r) in input.systemsim.iter_ship_body() { - let ship = input.ct.get_ship(s.get_data().get_content()); - let (color, z_scale) = match s.get_data().get_state() { + for s in input.phys_img.iter_ships() { + let ship = input.ct.get_ship(s.ship.get_data().get_content()); + let (color, z_scale) = match s.ship.get_data().get_state() { ShipState::Dead | ShipState::Landed { .. } => { continue; } @@ -129,16 +124,16 @@ impl Radar { ([0.2, 0.2, 0.2, 1.0], 1.0) } ShipState::Flying { .. } => { - let c = input.ct.get_faction(s.get_data().get_faction()).color; + let c = input.ct.get_faction(s.ship.get_data().get_faction()).color; ([c[0], c[1], c[2], 1.0], 1.0) } }; let size = (ship.size * input.ct.get_sprite(ship.sprite).aspect) * ship_scale * z_scale; let p: Point2 = { - if s.collider == input.player.ship.unwrap() { + if s.ship.collider == input.player.ship.unwrap() { self.last_player_position } else { - (*r.translation()).into() + (*s.rigidbody.translation()).into() } }; let d = (p - self.last_player_position) / radar_range; @@ -158,7 +153,7 @@ impl Radar { state.push_ui_buffer(UiInstance { anchor: PositionAnchor::NwC.to_int(), position: position.into(), - angle: r.rotation().angle(), + angle: player_ship.rigidbody.rotation().angle(), size, color, texture_index: [texture_a, texture_a], diff --git a/crates/render/src/ui/status.rs b/crates/render/src/ui/status.rs index 163b2f3..9845445 100644 --- a/crates/render/src/ui/status.rs +++ b/crates/render/src/ui/status.rs @@ -20,28 +20,42 @@ impl Status { let current_hull; let max_hull; let player_ship = input - .systemsim + .phys_img .get_ship(&galactica_system::phys::PhysSimShipHandle( input.player.ship.unwrap(), )) .unwrap(); - match player_ship.get_data().get_state() { + match player_ship.ship.get_data().get_state() { ShipState::Dead => { current_shields = 0.0; current_hull = 0.0; - max_shields = player_ship.get_data().get_outfits().get_shield_strength(); - max_hull = input.ct.get_ship(player_ship.get_data().get_content()).hull; + max_shields = player_ship + .ship + .get_data() + .get_outfits() + .get_shield_strength(); + max_hull = input + .ct + .get_ship(player_ship.ship.get_data().get_content()) + .hull; } ShipState::UnLanding { .. } | ShipState::Landing { .. } | ShipState::Landed { .. } | ShipState::Collapsing { .. } | ShipState::Flying { .. } => { - current_shields = player_ship.get_data().get_shields(); - current_hull = player_ship.get_data().get_hull(); - max_shields = player_ship.get_data().get_outfits().get_shield_strength(); - max_hull = input.ct.get_ship(player_ship.get_data().get_content()).hull; + current_shields = player_ship.ship.get_data().get_shields(); + current_hull = player_ship.ship.get_data().get_hull(); + max_shields = player_ship + .ship + .get_data() + .get_outfits() + .get_shield_strength(); + max_hull = input + .ct + .get_ship(player_ship.ship.get_data().get_content()) + .hull; } }