Skip to content

Commit c8e8c3d

Browse files
committed
update run conditions
1 parent 5b05cca commit c8e8c3d

File tree

1 file changed

+12
-9
lines changed

1 file changed

+12
-9
lines changed

src/conditions.rs

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,24 +14,27 @@ pub fn input_action_active<A: InputAction>(action: InputActionState<A>) -> bool
1414

1515
/// Returns `true` if the input action [`A`] has just started.
1616
pub fn input_action_started<A: InputAction>(mut action: InputActionReader<A>) -> bool {
17-
action
17+
let has_started = action
1818
.read()
19-
.last()
20-
.map_or(false, |a| matches!(a, InputActionStatus::Started(_)))
19+
.any(|status| matches!(status, InputActionStatus::Started(_)));
20+
action.clear();
21+
has_started
2122
}
2223

2324
/// Returns `true` if the input action [`A`] has just updated.
2425
pub fn input_action_updated<A: InputAction>(mut action: InputActionReader<A>) -> bool {
25-
action
26+
let has_updated = action
2627
.read()
27-
.last()
28-
.map_or(false, |a| matches!(a, InputActionStatus::Updated(_)))
28+
.any(|status| matches!(status, InputActionStatus::Updated(_)));
29+
action.clear();
30+
has_updated
2931
}
3032

3133
/// Returns `true` if the input action [`A`] has just stopped.
3234
pub fn input_action_stopped<A: InputAction>(mut action: InputActionReader<A>) -> bool {
33-
action
35+
let has_stopped = action
3436
.read()
35-
.last()
36-
.map_or(false, |a| matches!(a, InputActionStatus::Stopped))
37+
.any(|status| matches!(status, InputActionStatus::Stopped));
38+
action.clear();
39+
has_stopped
3740
}

0 commit comments

Comments
 (0)