See Discord for context.
It's worth reading the original Discord conversation thread and understanding some background. There's too much to repeat in here at the moment but I wanted to track this issue.
But I can add an event that indicates the mocking is over. What do you think?
I currently have an observer that restores my action mock once it is complete:
app.add_observer(restore_action_mock_after_complete::<CancelOrderAction>);
fn restore_action_mock_after_complete<A: InputAction>(
complete: On<Complete<A>>,
mut commands: Commands,
unit_query: Query<(), Without<UnitSelected>>,
) {
// If the unit is not selected (i.e., AI-controlled), restore the action
// mock. If we don't do this, the action mock remains disabled and the AI
// ends up responding to bindings meant for player-controlled units.
if unit_query.get(complete.context).is_ok() {
commands.entity(complete.action).insert(ActionMock::new(
ActionState::None,
false,
MockSpan::Manual,
));
trace!("Restored AI mock for action");
}
}
But this is possibly technically wrong because it's listening to this particular event. I'd need to think about it more but maybe this would fire under the wrong conditions for what the observer handler is trying to do.
If we had an event like On<ActionMockExpired then at least it would be explicit what we are handling here.
Maybe it would go in here after setting the action mock enabled to false: https://github.com/mgi388/bevy_enhanced_input/blob/e1c1d7aea3e6d66a16f720e1daff90cb1356e192/src/context.rs#L526. Maybe it would also pass in the computed new_state and new_value.
See Discord for context.
It's worth reading the original Discord conversation thread and understanding some background. There's too much to repeat in here at the moment but I wanted to track this issue.
I currently have an observer that restores my action mock once it is complete:
But this is possibly technically wrong because it's listening to this particular event. I'd need to think about it more but maybe this would fire under the wrong conditions for what the observer handler is trying to do.
If we had an event like
On<ActionMockExpiredthen at least it would be explicit what we are handling here.Maybe it would go in here after setting the action mock
enabledtofalse: https://github.com/mgi388/bevy_enhanced_input/blob/e1c1d7aea3e6d66a16f720e1daff90cb1356e192/src/context.rs#L526. Maybe it would also pass in the computednew_stateandnew_value.