public AudioSource PlayEnviroSE(int clipID, int idx, float fadeTime = 0.0f) { List <SoundPack.Data2D> source; if (!this._env3DSEData.TryGetValue(clipID, out source) || source.IsNullOrEmpty <SoundPack.Data2D>() || (idx < 0 || source.Count <= idx)) { return((AudioSource)null); } SoundPack.Data2D data2D = source[idx]; AudioClip clip = this.Load((SoundPack.IData)data2D); if (Object.op_Equality((Object)clip, (Object)null)) { return((AudioSource)null); } AudioSource audioSource = Illusion.Game.Utils.Sound.Play(Manager.Sound.Type.ENV, clip, fadeTime); if (Object.op_Equality((Object)audioSource, (Object)null)) { return((AudioSource)null); } string bundle = data2D.AssetBundleName; string asset = data2D.AssetName; SoundPack.AddCountUsedEnviroSEInfo(bundle, asset, clip); ObservableExtensions.Subscribe <Unit>((IObservable <M0>)ObservableTriggerExtensions.OnDestroyAsObservable((Component)audioSource), (System.Action <M0>)(_ => SoundPack.RemoveUsedEnviroSEInfo(bundle, asset))); return(audioSource); }
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 Start() { this.cgrp.set_alpha(0.0f); this.cgrp.set_blocksRaycasts(false); this.active = false; ObservableExtensions.Subscribe <Unit>((IObservable <M0>)ObservableTriggerExtensions.OnDestroyAsObservable((Component)this), (Action <M0>)(_ => { this.disposables.Clear(); this.cgrp.set_alpha(0.0f); this.cgrp.set_blocksRaycasts(false); this.active = false; })); }
public AudioSource Play(SoundPack.IData data, Manager.Sound.Type type, float fadeTime = 0.0f) { AudioClip clip = this.Load(data); if (Object.op_Equality((Object)clip, (Object)null)) { return((AudioSource)null); } AudioSource audio = Illusion.Game.Utils.Sound.Play(type, clip, fadeTime); if (type == Manager.Sound.Type.GameSE3D && Object.op_Inequality((Object)audio, (Object)null)) { this.PlayingAudioList.RemoveAll((Predicate <AudioSource>)(x => Object.op_Equality((Object)x, (Object)null) || Object.op_Equality((Object)((Component)x).get_gameObject(), (Object)null))); if (this._soundSystemInfo.Game3DMaxCount <= this.PlayingAudioList.Count) { int num = this.PlayingAudioList.Count - this._soundSystemInfo.Game3DMaxCount + 1; Transform cameraT = ((Component)Singleton <Manager.Map> .Instance.Player.CameraControl.CameraComponent).get_transform(); List <AudioSource> audioSourceList = ListPool <AudioSource> .Get(); audioSourceList.AddRange((IEnumerable <AudioSource>) this.PlayingAudioList); audioSourceList.Sort((Comparison <AudioSource>)((a1, a2) => this.GetSqrDistanceSort(cameraT, ((Component)a2).get_transform(), ((Component)a1).get_transform()))); for (int index = 0; index < num; ++index) { AudioSource element = audioSourceList.GetElement <AudioSource>(index); this.PlayingAudioList.Remove(element); Object.Destroy((Object)((Component)element).get_gameObject()); } ListPool <AudioSource> .Release(audioSourceList); } ObservableExtensions.Subscribe <Unit>((IObservable <M0>)ObservableTriggerExtensions.OnDestroyAsObservable((Component)audio), (System.Action <M0>)(_ => { if (!Object.op_Inequality((Object)audio, (Object)null)) { return; } this.PlayingAudioList.Remove(audio); })); this.PlayingAudioList.Add(audio); } if (data is SoundPack.Data3D data3D) { audio.set_minDistance(data3D.MinDistance); audio.set_maxDistance(data3D.MaxDistance); } return(audio); }
protected override void PlayEventOnceVoice(int voiceID) { AssetBundleInfo info; if (!Singleton <Resources> .Instance.Sound.TryGetMapActionVoiceInfo(-90, voiceID, out info)) { return; } Transform transform1 = ((Component)this.Actor.Locomotor).get_transform(); Manager.Voice instance = Singleton <Manager.Voice> .Instance; int num = -90; string assetbundle = (string)info.assetbundle; string asset = (string)info.asset; Transform transform2 = transform1; int no = num; string assetBundleName = assetbundle; string assetName = asset; Transform voiceTrans = transform2; Transform trfVoice = instance.OnecePlayChara(no, assetBundleName, assetName, 1f, 0.0f, 0.0f, true, voiceTrans, Manager.Voice.Type.PCM, -1, true, true, false); this.Actor.ChaControl.SetVoiceTransform(trfVoice); this.OnceActionVoice = (AudioSource)((Component)trfVoice).GetComponent <AudioSource>(); if (!Object.op_Inequality((Object)this.OnceActionVoice, (Object)null)) { return; } ObservableExtensions.Subscribe <Unit>(Observable.TakeUntilDestroy <Unit>((IObservable <M0>)ObservableTriggerExtensions.OnDestroyAsObservable((Component)this.OnceActionVoice), ((Component)this).get_gameObject()), (Action <M0>)(_ => { if (this.PlayEventLoopVoice()) { return; } this.StopLoopActionVoice(); })); }
private void Initialize() { if (Object.op_Equality((Object)this._prefab, (Object)null)) { return; } if (Object.op_Equality((Object)this._center, (Object)null)) { this._center = ((Component)this).get_transform(); } this._userMaxCount = this._createNumRange.RandomRange(); for (int index = 0; index < this._userMaxCount; ++index) { GameObject gameObject = new GameObject(string.Format("alone_butterfly_{0}", (object)index.ToString("00"))); gameObject.get_transform().SetParent(((Component)this).get_transform(), false); AloneButterfly butterfly = gameObject.GetOrAddComponent <AloneButterfly>(); butterfly.Initialize(this, this._prefab); ObservableExtensions.Subscribe <Unit>(Observable.TakeUntilDestroy <Unit>((IObservable <M0>)ObservableTriggerExtensions.OnDestroyAsObservable((Component)butterfly), (Component)this), (Action <M0>)(_ => this._use.Remove(butterfly))); this._use.Add(butterfly); } }
public void AttachSafe(Component component) { ObservableExtensions.Subscribe <Unit>((IObservable <M0>)ObservableTriggerExtensions.OnDestroyAsObservable(component), (Action <M0>)(_ => this.Stop())); }
public void AttachSafe(GameObject gameObject) { ObservableExtensions.Subscribe <Unit>((IObservable <M0>)ObservableTriggerExtensions.OnDestroyAsObservable(gameObject), (Action <M0>)(_ => this.Stop())); }
private void Awake() { if (this.Obj == null) { this.Obj = (this._animal ?? (AnimalBase)((Component)this).GetComponent <AnimalBase>()) as INicknameObject; } if (this.Obj == null) { return; } this._outputter = !Singleton <MapUIContainer> .IsInstance() ? (AnimalNicknameOutput)null : MapUIContainer.NicknameUI; if (Object.op_Equality((Object)this._outputter, (Object)null)) { Object.DestroyImmediate((Object)this); } else { this.Obj.NicknameEnabled = true; this._outputter.AddElement(this.Obj); ObservableExtensions.Subscribe <Unit>(Observable.Where <Unit>((IObservable <M0>)ObservableTriggerExtensions.OnEnableAsObservable((Component)this), (Func <M0, bool>)(_ => this.Obj != null)), (Action <M0>)(_ => this.Obj.NicknameEnabled = true)); ObservableExtensions.Subscribe <Unit>(Observable.Where <Unit>((IObservable <M0>)ObservableTriggerExtensions.OnDisableAsObservable((Component)this), (Func <M0, bool>)(_ => this.Obj != null)), (Action <M0>)(_ => this.Obj.NicknameEnabled = false)); ObservableExtensions.Subscribe <Unit>(Observable.Where <Unit>((IObservable <M0>)ObservableTriggerExtensions.OnDestroyAsObservable((Component)this), (Func <M0, bool>)(_ => this.Obj != null)), (Action <M0>)(_ => { if (!Object.op_Inequality((Object)this._outputter, (Object)null)) { return; } this._outputter.RemoveElement(this.Obj); })); } }