Make Fuel a required component on machines

It will be pulled in automatically by Bevy, now. I've also set a default
fuel level of 5 units.
This commit is contained in:
2025-08-29 09:54:27 -05:00
parent f470687494
commit 4a80b4f4ad
2 changed files with 11 additions and 2 deletions

View File

@@ -16,16 +16,22 @@ pub mod machines {
use bevy::prelude::*; use bevy::prelude::*;
use crate::game::consumables::Fuel;
#[derive(Component)] #[derive(Component)]
#[require(Fuel)]
pub struct CuttingMachine; pub struct CuttingMachine;
#[derive(Component)] #[derive(Component)]
#[require(Fuel)]
pub struct RotatingMachine; pub struct RotatingMachine;
#[derive(Component)] #[derive(Component)]
#[require(Fuel)]
pub struct FlippingMachine; pub struct FlippingMachine;
#[derive(Component)] #[derive(Component)]
#[require(Fuel)]
pub struct TransposingMachine; pub struct TransposingMachine;
} }
@@ -35,6 +41,11 @@ pub mod consumables {
#[derive(Component)] #[derive(Component)]
pub struct Fuel(pub u32); pub struct Fuel(pub u32);
impl Default for Fuel {
fn default() -> Self {
Self(5)
}
}
#[derive(Event)] #[derive(Event)]
pub struct FuelChanged; pub struct FuelChanged;
} }

View File

@@ -3,7 +3,6 @@ use bevy_inspector_egui::{bevy_egui::EguiPlugin, quick::WorldInspectorPlugin};
use crate::{ use crate::{
game::{ game::{
consumables::Fuel,
machines::{CuttingMachine, FlippingMachine, RotatingMachine, TransposingMachine}, machines::{CuttingMachine, FlippingMachine, RotatingMachine, TransposingMachine},
}, },
resources::UiTheme, resources::UiTheme,
@@ -50,7 +49,6 @@ fn dummy_machines(mut commands: Commands) {
commands commands
.spawn(( .spawn((
CuttingMachine, CuttingMachine,
Fuel(10),
Sprite::from_color(RED, Vec2::splat(40.0)), Sprite::from_color(RED, Vec2::splat(40.0)),
Transform::from_translation(Vec3::new(-40.0, 40.0, 0.0)), Transform::from_translation(Vec3::new(-40.0, 40.0, 0.0)),
Pickable::default(), Pickable::default(),