From f470687494741964efb9a4bd66f5abbdbd7e33c4 Mon Sep 17 00:00:00 2001 From: Robert Garrett Date: Thu, 28 Aug 2025 15:35:46 -0500 Subject: [PATCH] Fix Fuel's field visibility, add it to the cutter *Now* the fuel change events will work (and compile). --- src/game/mod.rs | 2 +- src/main.rs | 6 +++++- src/widgets/machines.rs | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/game/mod.rs b/src/game/mod.rs index 74791e3..b311c44 100644 --- a/src/game/mod.rs +++ b/src/game/mod.rs @@ -33,7 +33,7 @@ pub mod consumables { use bevy::prelude::*; #[derive(Component)] - pub struct Fuel(u32); + pub struct Fuel(pub u32); #[derive(Event)] pub struct FuelChanged; diff --git a/src/main.rs b/src/main.rs index fd3e124..9c07eaa 100644 --- a/src/main.rs +++ b/src/main.rs @@ -2,7 +2,10 @@ use bevy::{color::palettes::css::*, prelude::*, window::WindowResolution}; use bevy_inspector_egui::{bevy_egui::EguiPlugin, quick::WorldInspectorPlugin}; use crate::{ - game::machines::{CuttingMachine, FlippingMachine, RotatingMachine, TransposingMachine}, + game::{ + consumables::Fuel, + machines::{CuttingMachine, FlippingMachine, RotatingMachine, TransposingMachine}, + }, resources::UiTheme, widgets::SpawnUi, }; @@ -47,6 +50,7 @@ fn dummy_machines(mut commands: Commands) { commands .spawn(( CuttingMachine, + Fuel(10), Sprite::from_color(RED, Vec2::splat(40.0)), Transform::from_translation(Vec3::new(-40.0, 40.0, 0.0)), Pickable::default(), diff --git a/src/widgets/machines.rs b/src/widgets/machines.rs index 3cfc6c3..43a429c 100644 --- a/src/widgets/machines.rs +++ b/src/widgets/machines.rs @@ -12,7 +12,7 @@ impl SpawnUi for CuttingMachine { commands.entity(base_entity).with_children(|commands| { // Left panel. For fuel or machine stats or whatever. // TODO: Pass along target machine, not the UI's root entity. - commands.spawn(FuelGauge::bundle(Entity::PLACEHOLDER)); + commands.spawn(FuelGauge::bundle(machine_id)); // Center panel (placeholder for the Card view) commands.spawn((