@@ -3,7 +3,6 @@ use leafwing_input_manager::prelude::*;
3
3
4
4
use crate :: core:: UpdateSet ;
5
5
use crate :: game:: actor:: attack:: AttackController ;
6
- use crate :: game:: actor:: facing:: Facing ;
7
6
use crate :: util:: prelude:: * ;
8
7
9
8
pub ( super ) fn plugin ( app : & mut App ) {
@@ -24,20 +23,13 @@ impl Configure for AttackAction {
24
23
}
25
24
26
25
fn record_attack_action (
27
- mut action_query : Query < (
28
- & ActionState < AttackAction > ,
29
- Option < & Facing > ,
30
- & mut AttackController ,
31
- ) > ,
26
+ mut action_query : Query < ( & ActionState < AttackAction > , & mut AttackController ) > ,
32
27
) {
33
- for ( action, facing, mut controller) in & mut action_query {
34
- controller. aim += action
35
- . axis_pair ( & AttackAction :: Aim )
36
- . filter ( |x| x. xy ( ) != Vec2 :: ZERO )
37
- . map ( |x| x. xy ( ) . clamp_length_max ( 1.0 ) )
38
- . or_else ( || facing. map ( |x| x. 0 . as_vec2 ( ) ) )
39
- . unwrap_or_default ( ) ;
40
- controller. fire = action. just_pressed ( & AttackAction :: Fire ) ;
28
+ for ( action, mut controller) in & mut action_query {
29
+ controller. aim += cq ! ( action. axis_pair( & AttackAction :: Aim ) )
30
+ . xy ( )
31
+ . clamp_length_max ( 1.0 ) ;
32
+ controller. fire |= action. just_pressed ( & AttackAction :: Fire ) ;
41
33
}
42
34
}
43
35
@@ -46,8 +38,8 @@ pub fn attack_action(mut entity: EntityWorldMut) {
46
38
InputMap :: default ( )
47
39
. insert ( AttackAction :: Aim , DualAxis :: right_stick ( ) )
48
40
. insert ( AttackAction :: Aim , VirtualDPad :: arrow_keys ( ) )
49
- . insert ( AttackAction :: Fire , MouseButton :: Left )
50
- . insert ( AttackAction :: Fire , KeyCode :: Space )
41
+ . insert ( AttackAction :: Fire , GamepadButtonType :: East )
42
+ . insert ( AttackAction :: Fire , VirtualDPad :: arrow_keys ( ) )
51
43
. build ( ) ,
52
44
) ) ;
53
45
}
0 commit comments