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| {
|
||||
let mut button_cmds = cmds.spawn(BigRedButton::bundle("CUT"));
|
||||
button_cmds.observe(
|
||||
|trigger: Trigger<Pointer<Click>>,
|
||||
mut com: Commands,
|
||||
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);
|
||||
},
|
||||
);
|
||||
button_cmds.observe(move |trigger: Trigger<Pointer<Click>>, mut com: Commands| {
|
||||
dbg!("Cut button pressed. Triggering a FuelChanged event");
|
||||
com.trigger_targets(FuelChanged, machine_id);
|
||||
});
|
||||
// TODO: Attach on-press observer so this machine can do something
|
||||
// in response to that button being pressed
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user