2024-01-11 22:28:02 -08:00
|
|
|
use galactica_system::data::ShipState;
|
2024-01-12 14:34:31 -08:00
|
|
|
use std::f32::consts::TAU;
|
2024-01-10 18:53:19 -08:00
|
|
|
|
2024-01-10 17:53:27 -08:00
|
|
|
use crate::{
|
2024-01-17 10:25:03 -08:00
|
|
|
vertexbuffer::types::{RadialBarInstance, UiInstance},
|
|
|
|
PositionAnchor, RenderInput, RenderState,
|
2024-01-10 17:53:27 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
pub(super) struct Status {}
|
|
|
|
impl Status {
|
|
|
|
pub fn new() -> Self {
|
|
|
|
Self {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-01-10 18:53:19 -08:00
|
|
|
impl Status {
|
|
|
|
pub fn draw(&mut self, input: &RenderInput, state: &mut RenderState) {
|
2024-01-11 20:21:07 -08:00
|
|
|
let max_shields;
|
|
|
|
let current_shields;
|
|
|
|
let current_hull;
|
|
|
|
let max_hull;
|
2024-01-12 14:34:31 -08:00
|
|
|
let player_ship = input
|
|
|
|
.systemsim
|
|
|
|
.get_ship(&galactica_system::phys::PhysSimShipHandle(
|
|
|
|
input.player.ship.unwrap(),
|
|
|
|
))
|
|
|
|
.unwrap();
|
2024-01-11 22:10:36 -08:00
|
|
|
|
2024-01-20 10:04:09 -08:00
|
|
|
match player_ship.get_data().get_state() {
|
2024-01-12 17:38:33 -08:00
|
|
|
ShipState::Dead => {
|
|
|
|
current_shields = 0.0;
|
|
|
|
current_hull = 0.0;
|
2024-01-20 10:04:09 -08:00
|
|
|
max_shields = player_ship.get_data().get_outfits().get_shield_strength();
|
|
|
|
max_hull = input.ct.get_ship(player_ship.get_data().get_content()).hull;
|
2024-01-12 17:38:33 -08:00
|
|
|
}
|
2024-01-12 18:16:20 -08:00
|
|
|
ShipState::UnLanding { .. }
|
|
|
|
| ShipState::Landing { .. }
|
2024-01-12 17:38:33 -08:00
|
|
|
| ShipState::Landed { .. }
|
|
|
|
| ShipState::Collapsing { .. }
|
2024-01-13 18:57:21 -08:00
|
|
|
| ShipState::Flying { .. } => {
|
2024-01-20 10:04:09 -08:00
|
|
|
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;
|
2024-01-11 22:10:36 -08:00
|
|
|
}
|
|
|
|
}
|
2024-01-10 17:53:27 -08:00
|
|
|
|
2024-01-20 10:04:09 -08:00
|
|
|
let sprite = input
|
|
|
|
.ct
|
|
|
|
.get_sprite(input.ct.get_sprite_handle("ui::status"));
|
|
|
|
let texture_a = sprite.get_section(sprite.default_section).frames[0]; // ANIMATE
|
|
|
|
|
2024-01-17 10:25:03 -08:00
|
|
|
state.push_ui_buffer(UiInstance {
|
|
|
|
anchor: PositionAnchor::NeNe.to_int(),
|
|
|
|
position: [-10.0, -10.0],
|
|
|
|
angle: 0.0,
|
|
|
|
size: 200.0,
|
|
|
|
color: [1.0, 1.0, 1.0, 1.0],
|
2024-01-20 10:04:09 -08:00
|
|
|
texture_index: [texture_a, texture_a],
|
|
|
|
texture_fade: 1.0,
|
2024-01-17 13:27:32 -08:00
|
|
|
mask_index: [0, 0],
|
2024-01-17 10:25:03 -08:00
|
|
|
});
|
2024-01-10 17:53:27 -08:00
|
|
|
|
2024-01-17 10:25:03 -08:00
|
|
|
state.push_radialbar_buffer(RadialBarInstance {
|
|
|
|
position: [-19.0, -19.0],
|
|
|
|
anchor: PositionAnchor::NeNe.to_int(),
|
|
|
|
diameter: 182.0,
|
|
|
|
stroke: 5.0,
|
|
|
|
color: [0.3, 0.6, 0.8, 1.0],
|
|
|
|
angle: (current_shields / max_shields) * TAU,
|
|
|
|
});
|
2024-01-10 17:53:27 -08:00
|
|
|
|
2024-01-17 10:25:03 -08:00
|
|
|
state.push_radialbar_buffer(RadialBarInstance {
|
|
|
|
position: [-27.0, -27.0],
|
|
|
|
anchor: PositionAnchor::NeNe.to_int(),
|
|
|
|
diameter: 166.0,
|
|
|
|
stroke: 5.0,
|
|
|
|
color: [0.8, 0.7, 0.5, 1.0],
|
|
|
|
angle: (current_hull / max_hull) * TAU,
|
|
|
|
});
|
2024-01-10 17:53:27 -08:00
|
|
|
}
|
|
|
|
}
|