mirror of
https://github.com/seemueller-io/yachtpit.git
synced 2025-09-08 22:46:45 +00:00
abstract vessel/systems
This commit is contained in:
@@ -14,7 +14,7 @@ pub mod depth_gauge;
|
||||
pub mod compass_gauge;
|
||||
pub mod engine_status;
|
||||
pub mod navigation_display;
|
||||
pub mod yacht_data;
|
||||
pub mod vessel_data;
|
||||
pub mod instrument_cluster;
|
||||
pub mod gps_indicator;
|
||||
pub mod radar_indicator;
|
||||
@@ -31,7 +31,7 @@ pub use depth_gauge::*;
|
||||
pub use compass_gauge::*;
|
||||
pub use engine_status::*;
|
||||
pub use navigation_display::*;
|
||||
pub use yacht_data::*;
|
||||
pub use vessel_data::*;
|
||||
pub use instrument_cluster::*;
|
||||
pub use gps_indicator::*;
|
||||
pub use radar_indicator::*;
|
||||
|
@@ -2,8 +2,6 @@
|
||||
|
||||
use bevy::prelude::*;
|
||||
|
||||
// Placeholder for UI components
|
||||
// This module will contain reusable UI components for the yacht pit application
|
||||
|
||||
pub struct ComponentsPlugin;
|
||||
|
||||
|
@@ -5,7 +5,7 @@ use super::compass_gauge::CompassGauge;
|
||||
|
||||
/// Yacht data resource containing all sensor readings
|
||||
#[derive(Resource)]
|
||||
pub struct YachtData {
|
||||
pub struct VesselData {
|
||||
pub speed: f32, // knots
|
||||
pub depth: f32, // meters
|
||||
pub heading: f32, // degrees
|
||||
@@ -16,7 +16,7 @@ pub struct YachtData {
|
||||
pub wind_direction: f32, // degrees
|
||||
}
|
||||
|
||||
impl Default for YachtData {
|
||||
impl Default for VesselData {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
speed: 12.5,
|
||||
@@ -32,25 +32,25 @@ impl Default for YachtData {
|
||||
}
|
||||
|
||||
/// Updates yacht data with simulated sensor readings
|
||||
pub fn update_yacht_data(mut yacht_data: ResMut<YachtData>, time: Res<Time>) {
|
||||
pub fn update_vessel_data(mut vessel_data: ResMut<VesselData>, time: Res<Time>) {
|
||||
let t = time.elapsed_secs();
|
||||
|
||||
// Simulate realistic yacht data with some variation
|
||||
yacht_data.speed = 12.5 + (t * 0.3).sin() * 2.0;
|
||||
yacht_data.depth = 15.2 + (t * 0.1).sin() * 3.0;
|
||||
yacht_data.heading = (yacht_data.heading + time.delta_secs() * 5.0) % 360.0;
|
||||
yacht_data.engine_temp = 82.0 + (t * 0.2).sin() * 3.0;
|
||||
yacht_data.wind_speed = 8.3 + (t * 0.4).sin() * 1.5;
|
||||
yacht_data.wind_direction = (yacht_data.wind_direction + time.delta_secs() * 10.0) % 360.0;
|
||||
vessel_data.speed = 12.5 + (t * 0.3).sin() * 2.0;
|
||||
vessel_data.depth = 15.2 + (t * 0.1).sin() * 3.0;
|
||||
vessel_data.heading = (vessel_data.heading + time.delta_secs() * 5.0) % 360.0;
|
||||
vessel_data.engine_temp = 82.0 + (t * 0.2).sin() * 3.0;
|
||||
vessel_data.wind_speed = 8.3 + (t * 0.4).sin() * 1.5;
|
||||
vessel_data.wind_direction = (vessel_data.wind_direction + time.delta_secs() * 10.0) % 360.0;
|
||||
|
||||
// Slowly drain fuel and battery (very slowly for demo purposes)
|
||||
yacht_data.fuel_level = (yacht_data.fuel_level - time.delta_secs() * 0.01).max(0.0);
|
||||
yacht_data.battery_level = (yacht_data.battery_level - time.delta_secs() * 0.005).max(0.0);
|
||||
vessel_data.fuel_level = (vessel_data.fuel_level - time.delta_secs() * 0.01).max(0.0);
|
||||
vessel_data.battery_level = (vessel_data.battery_level - time.delta_secs() * 0.005).max(0.0);
|
||||
}
|
||||
|
||||
/// Updates the display values for all instrument gauges
|
||||
pub fn update_instrument_displays(
|
||||
yacht_data: Res<YachtData>,
|
||||
vessel_data: Res<VesselData>,
|
||||
mut speed_query: Query<&mut Text, (With<SpeedGauge>, Without<DepthGauge>, Without<CompassGauge>)>,
|
||||
mut depth_query: Query<&mut Text, (With<DepthGauge>, Without<SpeedGauge>, Without<CompassGauge>)>,
|
||||
mut compass_query: Query<&mut Text, (With<CompassGauge>, Without<SpeedGauge>, Without<DepthGauge>)>,
|
||||
@@ -58,20 +58,20 @@ pub fn update_instrument_displays(
|
||||
// Update speed display
|
||||
for mut text in speed_query.iter_mut() {
|
||||
if text.0.contains('.') {
|
||||
text.0 = format!("{:.1}", yacht_data.speed);
|
||||
text.0 = format!("{:.1}", vessel_data.speed);
|
||||
}
|
||||
}
|
||||
|
||||
// Update depth display
|
||||
for mut text in depth_query.iter_mut() {
|
||||
if text.0.contains('.') {
|
||||
text.0 = format!("{:.1}", yacht_data.depth);
|
||||
text.0 = format!("{:.1}", vessel_data.depth);
|
||||
}
|
||||
}
|
||||
|
||||
// Update compass display
|
||||
for mut text in compass_query.iter_mut() {
|
||||
text.0 = format!("{:03.0}", yacht_data.heading);
|
||||
text.0 = format!("{:03.0}", vessel_data.heading);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -80,12 +80,12 @@ mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn test_yacht_data_default() {
|
||||
let yacht_data = YachtData::default();
|
||||
assert_eq!(yacht_data.speed, 12.5);
|
||||
assert_eq!(yacht_data.depth, 15.2);
|
||||
assert_eq!(yacht_data.heading, 45.0);
|
||||
assert_eq!(yacht_data.fuel_level, 75.0);
|
||||
assert_eq!(yacht_data.battery_level, 88.0);
|
||||
fn test_vessel_data_default() {
|
||||
let vessel_data = VesselData::default();
|
||||
assert_eq!(vessel_data.speed, 12.5);
|
||||
assert_eq!(vessel_data.depth, 15.2);
|
||||
assert_eq!(vessel_data.heading, 45.0);
|
||||
assert_eq!(vessel_data.fuel_level, 75.0);
|
||||
assert_eq!(vessel_data.battery_level, 88.0);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user