From 35a0d51dfbbf5700a9f0f1aaae288df806147a22 Mon Sep 17 00:00:00 2001 From: hut Date: Wed, 8 May 2024 02:35:36 +0200 Subject: [PATCH] battery drain on flashlight --- src/actor.rs | 48 ++++++++++++++++++++++++++++++++++++++++++++---- src/commands.rs | 1 + src/hud.rs | 6 +++--- 3 files changed, 48 insertions(+), 7 deletions(-) diff --git a/src/actor.rs b/src/actor.rs index 0f6903c..eae69ac 100644 --- a/src/actor.rs +++ b/src/actor.rs @@ -33,6 +33,7 @@ impl Plugin for ActorPlugin { )); app.add_systems(FixedUpdate, ( update_physics_lifeforms, + update_power, handle_wants_maxrotation, handle_wants_maxvelocity, )); @@ -198,21 +199,58 @@ impl Default for Engine { #[derive(Component)] pub struct Suit { pub oxygen: f32, - pub power: f32, pub oxygen_max: f32, - pub power_max: f32, pub integrity: f32, // [0.0 - 1.0] } impl Default for Suit { fn default() -> Self { SUIT_SIMPLE } } const SUIT_SIMPLE: Suit = Suit { - power: 1e5, - power_max: 1e5, oxygen: nature::OXY_D, oxygen_max: nature::OXY_D, integrity: 1.0, }; +#[derive(Component)] +pub struct Battery { + pub power: f32, // Watt-seconds + pub capacity: f32, // Watt-seconds + pub reactor: f32, // Watt (production) +} + +impl Default for Battery { + fn default() -> Self { + Self { + power: 10e3 * 3600.0, + capacity: 10e3 * 3600.0, // 10kWh + reactor: 2000e3, // 2MW + } + } +} + +pub fn update_power( + time: Res