@@ -11,6 +11,7 @@ use bevy::{
11
11
} ,
12
12
} ,
13
13
} ;
14
+ use de_audio:: spatial:: { PlaySpatialAudioEvent , Sound } ;
14
15
use de_core:: {
15
16
cleanup:: DespawnOnGameExit , gamestate:: GameState , gconfig:: GameConfig , state:: AppState ,
16
17
} ;
@@ -35,16 +36,22 @@ impl Plugin for TrailPlugin {
35
36
(
36
37
local_laser_trail
37
38
. before ( MessagesSet :: SendMessages )
38
- . before ( laser_trail) ,
39
- remote_laser_trail. before ( laser_trail) ,
40
- laser_trail,
39
+ . before ( TrailSet :: Trail ) ,
40
+ remote_laser_trail. before ( TrailSet :: Trail ) ,
41
+ laser_trail. in_set ( TrailSet :: Trail ) ,
42
+ laser_sound. in_set ( TrailSet :: Trail ) ,
41
43
update,
42
44
)
43
45
. run_if ( in_state ( GameState :: Playing ) ) ,
44
46
) ;
45
47
}
46
48
}
47
49
50
+ #[ derive( Copy , Clone , Hash , Debug , PartialEq , Eq , SystemSet ) ]
51
+ enum TrailSet {
52
+ Trail ,
53
+ }
54
+
48
55
#[ derive( Event ) ]
49
56
pub ( crate ) struct LocalLaserTrailEvent ( Ray ) ;
50
57
@@ -178,6 +185,18 @@ fn laser_trail(
178
185
}
179
186
}
180
187
188
+ fn laser_sound (
189
+ mut events : EventReader < LaserTrailEvent > ,
190
+ mut sound_events : EventWriter < PlaySpatialAudioEvent > ,
191
+ ) {
192
+ for event in events. iter ( ) {
193
+ sound_events. send ( PlaySpatialAudioEvent :: new (
194
+ Sound :: LaserFire ,
195
+ event. 0 . origin . into ( ) ,
196
+ ) ) ;
197
+ }
198
+ }
199
+
181
200
fn update ( mut commands : Commands , time : Res < Time > , mut query : Query < ( Entity , & mut Trail ) > ) {
182
201
for ( entity, mut trail) in query. iter_mut ( ) {
183
202
trail. tick ( time. delta ( ) ) ;
0 commit comments