Adjust UI for new system

master
Mark 2024-01-23 15:52:51 -08:00
parent 51d9aa3911
commit 46049467a8
Signed by: Mark
GPG Key ID: C6D63995FE72FD80
4 changed files with 40 additions and 29 deletions

View File

@ -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);

View File

@ -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!"),

View File

@ -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<f32> = {
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],

View File

@ -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;
}
}