Pass target ID through the cutter's button handler
Use the machine entity ID in the button handler prototype. Now to see about getting the FuelGauge to show the value after a button press.
This commit is contained in:
@@ -37,19 +37,10 @@ impl SpawnUi for CuttingMachine {
|
|||||||
))
|
))
|
||||||
.with_children(|cmds| {
|
.with_children(|cmds| {
|
||||||
let mut button_cmds = cmds.spawn(BigRedButton::bundle("CUT"));
|
let mut button_cmds = cmds.spawn(BigRedButton::bundle("CUT"));
|
||||||
button_cmds.observe(
|
button_cmds.observe(move |trigger: Trigger<Pointer<Click>>, mut com: Commands| {
|
||||||
|trigger: Trigger<Pointer<Click>>,
|
dbg!("Cut button pressed. Triggering a FuelChanged event");
|
||||||
mut com: Commands,
|
com.trigger_targets(FuelChanged, machine_id);
|
||||||
q: Single<(Entity, &CuttingMachine)>| {
|
});
|
||||||
dbg!("Cut button pressed. Triggering a FuelChanged event");
|
|
||||||
|
|
||||||
// Feed through the target machine, once the SpawnUi trait is updated
|
|
||||||
// to require it gets here in the first place.
|
|
||||||
|
|
||||||
let cutting_machine = q.0;
|
|
||||||
com.trigger_targets(FuelChanged, cutting_machine);
|
|
||||||
},
|
|
||||||
);
|
|
||||||
// TODO: Attach on-press observer so this machine can do something
|
// TODO: Attach on-press observer so this machine can do something
|
||||||
// in response to that button being pressed
|
// in response to that button being pressed
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user