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:
@@ -16,16 +16,22 @@ pub mod machines {
|
||||
|
||||
use bevy::prelude::*;
|
||||
|
||||
use crate::game::consumables::Fuel;
|
||||
|
||||
#[derive(Component)]
|
||||
#[require(Fuel)]
|
||||
pub struct CuttingMachine;
|
||||
|
||||
#[derive(Component)]
|
||||
#[require(Fuel)]
|
||||
pub struct RotatingMachine;
|
||||
|
||||
#[derive(Component)]
|
||||
#[require(Fuel)]
|
||||
pub struct FlippingMachine;
|
||||
|
||||
#[derive(Component)]
|
||||
#[require(Fuel)]
|
||||
pub struct TransposingMachine;
|
||||
}
|
||||
|
||||
@@ -35,6 +41,11 @@ pub mod consumables {
|
||||
#[derive(Component)]
|
||||
pub struct Fuel(pub u32);
|
||||
|
||||
impl Default for Fuel {
|
||||
fn default() -> Self {
|
||||
Self(5)
|
||||
}
|
||||
}
|
||||
#[derive(Event)]
|
||||
pub struct FuelChanged;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ use bevy_inspector_egui::{bevy_egui::EguiPlugin, quick::WorldInspectorPlugin};
|
||||
|
||||
use crate::{
|
||||
game::{
|
||||
consumables::Fuel,
|
||||
machines::{CuttingMachine, FlippingMachine, RotatingMachine, TransposingMachine},
|
||||
},
|
||||
resources::UiTheme,
|
||||
@@ -50,7 +49,6 @@ 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(),
|
||||
|
||||
Reference in New Issue
Block a user