private void SoundPlay(Transform root) { this._isPlay = true; List <EnvArea3DSE.IPlayInfo> playList = EnvArea3DSE.PlayAudioSourceList; playList.RemoveAll((Predicate <EnvArea3DSE.IPlayInfo>)(ax => ax == null || Object.op_Equality((Object)ax.Audio, (Object)null) || Object.op_Equality((Object)((Component)ax.Audio).get_gameObject(), (Object)null))); SoundPack.SoundSystemInfoGroup soundSystemInfo = Singleton <Resources> .Instance.SoundPack.SoundSystemInfo; if (soundSystemInfo.EnviroSEMaxCount <= playList.Count) { bool flag = true; int num = playList.Count - soundSystemInfo.EnviroSEMaxCount + 1; List <EnvArea3DSE.IPlayInfo> playInfoList = ListPool <EnvArea3DSE.IPlayInfo> .Get(); playInfoList.AddRange((IEnumerable <EnvArea3DSE.IPlayInfo>)playList); Transform cameraT = ((Component)Singleton <Manager.Map> .Instance.Player.CameraControl.CameraComponent).get_transform(); playInfoList.Sort((Comparison <EnvArea3DSE.IPlayInfo>)((a1, a2) => this.GetSqrDistanceSort(cameraT, ((Component)a2.Audio).get_transform(), ((Component)a1.Audio).get_transform()))); float distanceFromCamera = this.GetSqrDistanceFromCamera(cameraT, root); for (int index = 0; index < num; ++index) { EnvArea3DSE.IPlayInfo element = playInfoList.GetElement <EnvArea3DSE.IPlayInfo>(index); if ((double)distanceFromCamera < (double)element.GetSqrDistanceFromCamera(cameraT, ((Component)element.Audio).get_transform().get_position())) { element.Stop(); flag = false; } } ListPool <EnvArea3DSE.IPlayInfo> .Release(playInfoList); if (flag) { return; } } float fadeTime = 0.0f; if (this._firstPlaying) { fadeTime = !this._setFirstFadeTime ? Singleton <Resources> .Instance.SoundPack.EnviroInfo.FadeTime : this._firstFadeTime; this._firstPlaying = false; } this._audio = Singleton <Resources> .Instance.SoundPack.PlayEnviroSE(this._clipID, fadeTime); if (Object.op_Equality((Object)this._audio, (Object)null)) { Object.Destroy((Object)this); } else { this._fadePlayer = (FadePlayer)((Component)this._audio).GetComponentInChildren <FadePlayer>(true); this._audio.set_loop(this._isLoop); this._audio.set_minDistance((float)this._decay.x); this._audio.set_maxDistance((float)this._decay.y); if (!playList.Contains((EnvArea3DSE.IPlayInfo) this)) { playList.Add((EnvArea3DSE.IPlayInfo) this); } ObservableExtensions.Subscribe <Unit>((IObservable <M0>)ObservableTriggerExtensions.OnDestroyAsObservable((Component)this._audio), (Action <M0>)(_ => playList.Remove((EnvArea3DSE.IPlayInfo) this))); } }
private void Play(Transform root) { this.IsPlay = true; EnvArea3DSE._playAudioSourceList.RemoveAll((Predicate <EnvArea3DSE.IPlayInfo>)(ax => ax == null || Object.op_Equality((Object)ax.Audio, (Object)null) || Object.op_Equality((Object)((Component)ax.Audio).get_gameObject(), (Object)null))); SoundPack.SoundSystemInfoGroup soundSystemInfo = Singleton <Resources> .Instance.SoundPack.SoundSystemInfo; if (soundSystemInfo.EnviroSEMaxCount <= EnvArea3DSE._playAudioSourceList.Count) { bool flag = true; int num = EnvArea3DSE._playAudioSourceList.Count - soundSystemInfo.EnviroSEMaxCount + 1; List <EnvArea3DSE.IPlayInfo> playInfoList = ListPool <EnvArea3DSE.IPlayInfo> .Get(); playInfoList.AddRange((IEnumerable <EnvArea3DSE.IPlayInfo>)EnvArea3DSE._playAudioSourceList); Transform cameraT = ((Component)Singleton <Manager.Map> .Instance.Player.CameraControl.CameraComponent).get_transform(); playInfoList.Sort((Comparison <EnvArea3DSE.IPlayInfo>)((a1, a2) => this.GetSqrDistanceSort(cameraT, ((Component)a2.Audio).get_transform(), ((Component)a1.Audio).get_transform()))); float distanceFromCamera = this.GetSqrDistanceFromCamera(cameraT, root); for (int index = 0; index < num; ++index) { EnvArea3DSE.IPlayInfo element = playInfoList.GetElement <EnvArea3DSE.IPlayInfo>(index); if ((double)distanceFromCamera < (double)element.GetSqrDistanceFromCamera(cameraT, ((Component)element.Audio).get_transform().get_position())) { element.Stop(); flag = false; } } ListPool <EnvArea3DSE.IPlayInfo> .Release(playInfoList); if (flag) { return; } } float fadeTime = 0.0f; if (this.FirstPlaying) { fadeTime = Singleton <Resources> .Instance.SoundPack.EnviroInfo.FadeTime; this.FirstPlaying = false; } this.Audio = Singleton <Resources> .Instance.SoundPack.PlayEnviroSE(this.ClipID, fadeTime); if (Object.op_Equality((Object)this.Audio, (Object)null)) { return; } this.FadePlayer = (FadePlayer)((Component)this.Audio).GetComponentInChildren <FadePlayer>(true); this.Audio.set_loop(this.IsLoop); this.Audio.set_minDistance(this.Decay.min); this.Audio.set_maxDistance(this.Decay.max); this.LoadSuccess = true; if (EnvArea3DSE._playAudioSourceList.Contains((EnvArea3DSE.IPlayInfo) this)) { return; } EnvArea3DSE._playAudioSourceList.Add((EnvArea3DSE.IPlayInfo) this); }