Adjust UI for new system
parent
51d9aa3911
commit
46049467a8
|
@ -25,10 +25,11 @@ impl UiManager {
|
||||||
/// Draw all ui elements
|
/// Draw all ui elements
|
||||||
pub fn draw(&mut self, input: &RenderInput, state: &mut RenderState) {
|
pub fn draw(&mut self, input: &RenderInput, state: &mut RenderState) {
|
||||||
let ship_handle = input.player.ship.unwrap();
|
let ship_handle = input.player.ship.unwrap();
|
||||||
let ship = input
|
let ship = &input
|
||||||
.systemsim
|
.phys_img
|
||||||
.get_ship(&PhysSimShipHandle(ship_handle))
|
.get_ship(&PhysSimShipHandle(ship_handle))
|
||||||
.unwrap();
|
.unwrap()
|
||||||
|
.ship;
|
||||||
|
|
||||||
self.fps.update(input, state);
|
self.fps.update(input, state);
|
||||||
|
|
||||||
|
|
|
@ -114,10 +114,11 @@ impl Planet {
|
||||||
pub fn draw(&mut self, input: &RenderInput, state: &mut RenderState) {
|
pub fn draw(&mut self, input: &RenderInput, state: &mut RenderState) {
|
||||||
// Get required data
|
// Get required data
|
||||||
let ship_handle = input.player.ship.unwrap();
|
let ship_handle = input.player.ship.unwrap();
|
||||||
let ship_data = input
|
let ship_data = &input
|
||||||
.systemsim
|
.phys_img
|
||||||
.get_ship(&PhysSimShipHandle(ship_handle))
|
.get_ship(&PhysSimShipHandle(ship_handle))
|
||||||
.unwrap();
|
.unwrap()
|
||||||
|
.ship;
|
||||||
let planet_handle = match ship_data.get_data().get_state() {
|
let planet_handle = match ship_data.get_data().get_state() {
|
||||||
ShipState::Landed { target } => *target,
|
ShipState::Landed { target } => *target,
|
||||||
_ => unreachable!("tried to draw planet interface while not landed!"),
|
_ => unreachable!("tried to draw planet interface while not landed!"),
|
||||||
|
|
|
@ -28,13 +28,13 @@ impl Radar {
|
||||||
// TODO: maybe a cleaner solution for last posititon?
|
// TODO: maybe a cleaner solution for last posititon?
|
||||||
// This is necessary because the player may be dead or landed
|
// This is necessary because the player may be dead or landed
|
||||||
let player_ship = input
|
let player_ship = input
|
||||||
.systemsim
|
.phys_img
|
||||||
.get_ship(&galactica_system::phys::PhysSimShipHandle(
|
.get_ship(&galactica_system::phys::PhysSimShipHandle(
|
||||||
input.player.ship.unwrap(),
|
input.player.ship.unwrap(),
|
||||||
))
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
match player_ship.get_data().get_state() {
|
match player_ship.ship.get_data().get_state() {
|
||||||
ShipState::Dead => {}
|
ShipState::Dead => {}
|
||||||
|
|
||||||
ShipState::Landed { target } => {
|
ShipState::Landed { target } => {
|
||||||
|
@ -46,12 +46,7 @@ impl Radar {
|
||||||
| ShipState::Landing { .. }
|
| ShipState::Landing { .. }
|
||||||
| ShipState::Flying { .. }
|
| ShipState::Flying { .. }
|
||||||
| ShipState::Collapsing { .. } => {
|
| ShipState::Collapsing { .. } => {
|
||||||
let player_body = input
|
self.last_player_position = (*player_ship.rigidbody.translation()).into();
|
||||||
.systemsim
|
|
||||||
.get_rigid_body(player_ship.rigid_body)
|
|
||||||
.unwrap();
|
|
||||||
|
|
||||||
self.last_player_position = (*player_body.translation()).into();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -111,9 +106,9 @@ impl Radar {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Draw ships
|
// Draw ships
|
||||||
for (s, r) in input.systemsim.iter_ship_body() {
|
for s in input.phys_img.iter_ships() {
|
||||||
let ship = input.ct.get_ship(s.get_data().get_content());
|
let ship = input.ct.get_ship(s.ship.get_data().get_content());
|
||||||
let (color, z_scale) = match s.get_data().get_state() {
|
let (color, z_scale) = match s.ship.get_data().get_state() {
|
||||||
ShipState::Dead | ShipState::Landed { .. } => {
|
ShipState::Dead | ShipState::Landed { .. } => {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -129,16 +124,16 @@ impl Radar {
|
||||||
([0.2, 0.2, 0.2, 1.0], 1.0)
|
([0.2, 0.2, 0.2, 1.0], 1.0)
|
||||||
}
|
}
|
||||||
ShipState::Flying { .. } => {
|
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)
|
([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 size = (ship.size * input.ct.get_sprite(ship.sprite).aspect) * ship_scale * z_scale;
|
||||||
let p: Point2<f32> = {
|
let p: Point2<f32> = {
|
||||||
if s.collider == input.player.ship.unwrap() {
|
if s.ship.collider == input.player.ship.unwrap() {
|
||||||
self.last_player_position
|
self.last_player_position
|
||||||
} else {
|
} else {
|
||||||
(*r.translation()).into()
|
(*s.rigidbody.translation()).into()
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let d = (p - self.last_player_position) / radar_range;
|
let d = (p - self.last_player_position) / radar_range;
|
||||||
|
@ -158,7 +153,7 @@ impl Radar {
|
||||||
state.push_ui_buffer(UiInstance {
|
state.push_ui_buffer(UiInstance {
|
||||||
anchor: PositionAnchor::NwC.to_int(),
|
anchor: PositionAnchor::NwC.to_int(),
|
||||||
position: position.into(),
|
position: position.into(),
|
||||||
angle: r.rotation().angle(),
|
angle: player_ship.rigidbody.rotation().angle(),
|
||||||
size,
|
size,
|
||||||
color,
|
color,
|
||||||
texture_index: [texture_a, texture_a],
|
texture_index: [texture_a, texture_a],
|
||||||
|
|
|
@ -20,28 +20,42 @@ impl Status {
|
||||||
let current_hull;
|
let current_hull;
|
||||||
let max_hull;
|
let max_hull;
|
||||||
let player_ship = input
|
let player_ship = input
|
||||||
.systemsim
|
.phys_img
|
||||||
.get_ship(&galactica_system::phys::PhysSimShipHandle(
|
.get_ship(&galactica_system::phys::PhysSimShipHandle(
|
||||||
input.player.ship.unwrap(),
|
input.player.ship.unwrap(),
|
||||||
))
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
match player_ship.get_data().get_state() {
|
match player_ship.ship.get_data().get_state() {
|
||||||
ShipState::Dead => {
|
ShipState::Dead => {
|
||||||
current_shields = 0.0;
|
current_shields = 0.0;
|
||||||
current_hull = 0.0;
|
current_hull = 0.0;
|
||||||
max_shields = player_ship.get_data().get_outfits().get_shield_strength();
|
max_shields = player_ship
|
||||||
max_hull = input.ct.get_ship(player_ship.get_data().get_content()).hull;
|
.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::UnLanding { .. }
|
||||||
| ShipState::Landing { .. }
|
| ShipState::Landing { .. }
|
||||||
| ShipState::Landed { .. }
|
| ShipState::Landed { .. }
|
||||||
| ShipState::Collapsing { .. }
|
| ShipState::Collapsing { .. }
|
||||||
| ShipState::Flying { .. } => {
|
| ShipState::Flying { .. } => {
|
||||||
current_shields = player_ship.get_data().get_shields();
|
current_shields = player_ship.ship.get_data().get_shields();
|
||||||
current_hull = player_ship.get_data().get_hull();
|
current_hull = player_ship.ship.get_data().get_hull();
|
||||||
max_shields = player_ship.get_data().get_outfits().get_shield_strength();
|
max_shields = player_ship
|
||||||
max_hull = input.ct.get_ship(player_ship.get_data().get_content()).hull;
|
.ship
|
||||||
|
.get_data()
|
||||||
|
.get_outfits()
|
||||||
|
.get_shield_strength();
|
||||||
|
max_hull = input
|
||||||
|
.ct
|
||||||
|
.get_ship(player_ship.ship.get_data().get_content())
|
||||||
|
.hull;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue