File tree Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Expand file tree Collapse file tree 1 file changed +12
-9
lines changed Original file line number Diff line number Diff line change @@ -14,24 +14,27 @@ pub fn input_action_active<A: InputAction>(action: InputActionState<A>) -> bool
14
14
15
15
/// Returns `true` if the input action [`A`] has just started.
16
16
pub fn input_action_started < A : InputAction > ( mut action : InputActionReader < A > ) -> bool {
17
- action
17
+ let has_started = action
18
18
. 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
21
22
}
22
23
23
24
/// Returns `true` if the input action [`A`] has just updated.
24
25
pub fn input_action_updated < A : InputAction > ( mut action : InputActionReader < A > ) -> bool {
25
- action
26
+ let has_updated = action
26
27
. 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
29
31
}
30
32
31
33
/// Returns `true` if the input action [`A`] has just stopped.
32
34
pub fn input_action_stopped < A : InputAction > ( mut action : InputActionReader < A > ) -> bool {
33
- action
35
+ let has_stopped = action
34
36
. 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
37
40
}
You can’t perform that action at this time.
0 commit comments