@@ -21,7 +21,6 @@ public static AerodynamicsFX AeroFX
2121 }
2222 }
2323
24- public Dictionary < PhysicsControl , List < SoundLayer > > SoundLayerGroups = new Dictionary < PhysicsControl , List < SoundLayer > > ( ) ;
2524 public Dictionary < string , AudioSource > Sources = new Dictionary < string , AudioSource > ( ) ;
2625 public Dictionary < string , AirSimulationFilter > AirSimFilters = new Dictionary < string , AirSimulationFilter > ( ) ;
2726
@@ -66,37 +65,15 @@ public bool Initialize()
6665 return true ;
6766 }
6867
69- if ( ShipEffectsConfig . ShipEffectsConfigNode . Count > 0 )
70- {
71- foreach ( var node in ShipEffectsConfig . ShipEffectsConfigNode )
72- {
73- if ( ! Enum . TryParse ( node . name , true , out PhysicsControl controlGroup ) ) continue ;
74- if ( ignoreVessel && controlGroup != PhysicsControl . SONICBOOM ) continue ;
75-
76- if ( node . HasNode ( "SOUNDLAYER" ) )
77- {
78- var soundLayers = AudioUtility . CreateSoundLayerGroup ( node . GetNodes ( "SOUNDLAYER" ) ) ;
79- if ( soundLayers . Count == 0 ) continue ;
80-
81- if ( SoundLayerGroups . ContainsKey ( controlGroup ) ) { SoundLayerGroups [ controlGroup ] . AddRange ( soundLayers ) ; continue ; }
82-
83- SoundLayerGroups . Add ( controlGroup , soundLayers ) ;
84- }
85- }
86- }
87-
8868 audioParent = new GameObject ( $ "ShipEffects_{ vessel . vesselName } ") ;
8969 audioParent . transform . rotation = vessel . transform . rotation ;
9070 audioParent . transform . position = vessel . transform . position ;
9171 audioParent . transform . parent = vessel . transform ;
9272
93- if ( SoundLayerGroups . Count > 0 )
73+ foreach ( var soundLayerGroup in ShipEffectsConfig . SoundLayerGroups )
9474 {
95- foreach ( var soundLayerGroup in SoundLayerGroups )
96- {
97- var hasAirSimFilter = soundLayerGroup . Key != PhysicsControl . SONICBOOM ;
98- StartCoroutine ( SetupAudioSources ( soundLayerGroup . Value , hasAirSimFilter ) ) ;
99- }
75+ var hasAirSimFilter = soundLayerGroup . Key != PhysicsControl . SONICBOOM ;
76+ StartCoroutine ( SetupAudioSources ( soundLayerGroup . Value , hasAirSimFilter ) ) ;
10077 }
10178
10279 CacheVesselData ( ) ;
@@ -280,40 +257,43 @@ private void LateUpdate()
280257 if ( ! HighLogic . LoadedSceneIsFlight || ! initialized || gamePaused || noPhysics || ignoreVessel )
281258 return ;
282259
283- if ( SoundLayerGroups . ContainsKey ( PhysicsControl . SONICBOOM ) && Settings . MachEffectsAmount > 0 && ! MapView . MapCamera . isActiveAndEnabled )
260+ foreach ( var soundLayerGroup in ShipEffectsConfig . SoundLayerGroups )
284261 {
285- if ( MachPass > Settings . MachEffectLowerLimit && ! SonicBoomed )
262+ if ( soundLayerGroup . Key == PhysicsControl . SONICBOOM )
286263 {
287- SonicBoomed = true ;
288- if ( vessel . mach > 1 )
264+ if ( Settings . MachEffectsAmount > 0 && ! MapView . MapCamera . isActiveAndEnabled )
289265 {
290- foreach ( var soundLayer in SoundLayerGroups [ PhysicsControl . SONICBOOM ] )
266+ if ( MachPass > Settings . MachEffectLowerLimit && ! SonicBoomed )
291267 {
292- if ( vessel . crewableParts == 0 && soundLayer . channel == FXChannel . Interior )
293- continue ;
268+ SonicBoomed = true ;
269+ if ( vessel . mach > 1 )
270+ {
271+ foreach ( var soundLayer in soundLayerGroup . Value )
272+ {
273+ if ( vessel . crewableParts == 0 && soundLayer . channel == FXChannel . Interior )
274+ continue ;
275+
276+ PlaySonicBoom ( soundLayer ) ;
277+ }
278+ }
279+ }
294280
295- PlaySonicBoom ( soundLayer ) ;
281+ if ( MachPass == Settings . MachEffectLowerLimit )
282+ {
283+ SonicBoomed = false ;
296284 }
297285 }
298286 }
299-
300- if ( MachPass == Settings . MachEffectLowerLimit )
301- {
302- SonicBoomed = false ;
303- }
304- }
305-
306- foreach ( var soundLayerGroup in SoundLayerGroups )
307- {
308- if ( soundLayerGroup . Key == PhysicsControl . SONICBOOM ) continue ;
309-
310- float rawControl = GetPhysicsController ( soundLayerGroup . Key ) ;
311- foreach ( var soundLayer in soundLayerGroup . Value )
287+ else
312288 {
313- if ( vessel . crewableParts == 0 && soundLayer . channel == FXChannel . Interior )
314- continue ;
289+ float rawControl = GetPhysicsController ( soundLayerGroup . Key ) ;
290+ foreach ( var soundLayer in soundLayerGroup . Value )
291+ {
292+ if ( vessel . crewableParts == 0 && soundLayer . channel == FXChannel . Interior )
293+ continue ;
315294
316- PlaySoundLayer ( soundLayer , rawControl ) ;
295+ PlaySoundLayer ( soundLayer , rawControl ) ;
296+ }
317297 }
318298 }
319299
0 commit comments