protected KMAudio.KMAudioRef PlayGameSoundHandlerWithRef(KMSoundOverride.SoundEffect sound, Transform t) { KMAudio.KMAudioRef kmaudioRef = new KMAudio.KMAudioRef(); if (audioSource == null) { return(kmaudioRef); } var clip = SoundEffects.GetAudioClip(sound); if (clip == null) { return(kmaudioRef); } try { audioSource.transform.position = t.position; } catch { } audioSource.loop = false; audioSource.PlayOneShot(clip); KMAudio.KMAudioRef kmaudioRef2 = kmaudioRef; kmaudioRef2.StopSound = (Action)Delegate.Combine(kmaudioRef2.StopSound, new Action(delegate { if (audioSource.isPlaying) { audioSource.Stop(); } })); return(kmaudioRef); }
public static void PlaySound(KMSoundOverride.SoundEffect effectOverride, Transform transform) { if (ModSoundMap.GroupNameMap.TryGetValue(effectOverride, out string effect)) { MasterAudio.PlaySound3DAtTransformAndForget(effect, transform, 1f, null, 0f, null); } }
/// <summary> /// Play an existing game sound (or its override) at the given transform. /// </summary> /// <param name="sound"></param> /// <param name="transform"></param> public void PlayGameSoundAtTransform(KMSoundOverride.SoundEffect sound, Transform transform) { if (HandlePlayGameSoundAtTransform != null) { HandlePlayGameSoundAtTransform(sound, transform); } }
/// <summary> /// Play an existing game sound (or its override) at the given transform. /// </summary> /// <param name="sound"></param> /// <param name="transform"></param> /// <returns>A KMAudioRef that can be used to stop sounds early</returns> public KMAudioRef PlayGameSoundAtTransformWithRef(KMSoundOverride.SoundEffect sound, Transform transform) { if (HandlePlayGameSoundAtTransformWithRef != null) { return(HandlePlayGameSoundAtTransformWithRef(sound, transform)); } return(null); }
public AudioClip GetAudioClip(KMSoundOverride.SoundEffect effect) { List <AudioClip> clips; if (!_soundEffects.TryGetValue(effect, out clips)) { return(null); } if (clips == null || clips.Count == 0) { return(null); } return(clips[UnityEngine.Random.Range(0, clips.Count)]); }
public void TurnLightsOn() { RenderSettings.ambientIntensity = 1f; DynamicGI.UpdateEnvironment(); foreach (Light l in FindObjectsOfType <Light>()) { if (l.transform.parent == null) { l.enabled = true; } } PlayGameSoundHandler(_lightsOnEffect, transform); _lightsOnEffect = KMSoundOverride.SoundEffect.LightBuzzShort; }
protected void PlayGameSoundHandler(KMSoundOverride.SoundEffect sound, Transform t) { PlayGameSoundHandlerWithRef(sound, t); }