/// Pauses the playback of active sound sources. /// /// @param %channels An optional word list of channel indices or an empty /// string to pause sources on all channels. /// @param %pauseSet An optional SimSet which is filled with the paused /// sources. If not specified the global SFXPausedSet /// is used. /// /// @deprecated public static void sfxPause(List <int> channels = null, SimSet pauseSet = null) { // Did we get a set to populate? if (pauseSet == null) { pauseSet = SFXPausedSet; } SimSet SFXSourceSet = Sim.FindObjectByName <SimSet>("SFXSourceSet"); int count = SFXSourceSet.getCount(); for (uint i = 0; i < count; i++) { SFXSource source = SFXSourceSet.getObject(i).As <SFXSource>(); int channel = sfxGroupToOldChannel(source.getGroup()); if (channels != null && !channels.Contains(channel)) { continue; } source.pause(); pauseSet.add(source); } }
public static void PlaySound(AudioClip clip) { if (!SFXSource.isPlaying) { SFXSource.PlayOneShot(clip); } }
public static void PlayOneShot(AudioBundle bundle, string audioName, Action onAudioEnd, float volumeScale = 1.0f) { AudioClip clip = GetClip(bundle, audioName); SFXSource.PlayOneShot(clip, volumeScale); Framework.Extensions.DelayAction(clip.length, onAudioEnd); }
public static void PlayOneShot(MonoBehaviour mono, TPAudioBundle bundle, string audioName, Action onAudioEnd, float volumeScale = 1.0f) { AudioClip clip = GetClip(bundle, audioName); SFXSource.PlayOneShot(clip, volumeScale); mono.StartCoroutine(DelayAction(clip.length, onAudioEnd)); }
public static void sfxSetChannelVolume(SimSet channel, float volume) { SFXSource obj = sfxOldChannelToGroup(channel); if (obj.isObject()) { obj.setVolume(volume); } }
private static void sfxStopAll(int channel) { // Don't stop channel itself since that isn't quite what the function // here intends. SFXSource source = sfxOldChannelToGroup(channel); for (uint i = 0; i < source.getCount(); i++) { source.getObject(i).As <SFXSource>().stop(); } }
private static int sfxGroupToOldChannel(SimGroup group) { int id = group.getId(); for (int index = 0; index < AudioChannels.Count; index++) { SFXSource audioChannel = AudioChannels[index]; if (audioChannel.getId() == id) { return(index); } } return(-1); }
public void PlaySoundEffect(GameObject SourceObject, string FileName) { if (mSources.ContainsKey(SourceObject)) { mSources[SourceObject].PlaySFX(FileName); } else { SFXSource Source = SourceObject.GetComponent <SFXSource>(); if (Source == null) { Debug.LogWarning(SourceObject.name + " does not possess component SFXSource."); return; } mSources.Add(SourceObject, Source); Source.PlaySFX(FileName); } }
/// Resumes the playback of paused sound sources. /// /// @param %pauseSet An optional SimSet which contains the paused sound /// sources to be resumed. If not specified the global /// SFXPausedSet is used. /// @deprecated public static void sfxResume(SimSet pauseSet = null) { if (pauseSet == null) { pauseSet = SFXPausedSet; } int count = pauseSet.getCount(); for (uint i = 0; i < count; i++) { SFXSource source = pauseSet.getObject(i).As <SFXSource>(); source.play(); } // Clear our pause set... the caller is left // to clear his own if he passed one. pauseSet.clear(); }
public static void Init() { //----------------------------------------------------------------------------- // Source groups. //----------------------------------------------------------------------------- SFXDescription AudioMaster = new SFXDescription("AudioMaster"); AudioMaster.registerSingleton(); System.Console.WriteLine(AudioMaster.ConeInsideAngle); AudioChannelMaster = new SFXSource("AudioChannelMaster") { Description = AudioMaster }; AudioChannelMaster.registerSingleton(); System.Console.WriteLine(AudioChannelMaster.Description.getName()); SFXDescription AudioChannel = new SFXDescription("AudioChannel") { SourceGroup = AudioChannelMaster }; AudioChannel.registerSingleton(); SFXSource AudioChannelDefault = new SFXSource("AudioChannelDefault") { Description = AudioChannel }; AudioChannelDefault.registerSingleton(); SFXSource AudioChannelGui = new SFXSource("AudioChannelGui") { Description = AudioChannel }; AudioChannelGui.registerSingleton(); AudioChannelEffects = new SFXSource("AudioChannelEffects") { Description = AudioChannel }; AudioChannelEffects.registerSingleton(); SFXSource AudioChannelMessages = new SFXSource("AudioChannelMessages") { Description = AudioChannel }; AudioChannelMessages.registerSingleton(); SFXSource AudioChannelMusic = new SFXSource("AudioChannelMusic") { Description = AudioChannel }; AudioChannelMusic.registerSingleton(); // Set default playback states of the channels. AudioChannelMaster.play(); AudioChannelDefault.play(); AudioChannelGui.play(); AudioChannelMusic.play(); AudioChannelMessages.play(); // Stop in-game effects channels. AudioChannelEffects.stop(); AudioChannels.Add(AudioChannelDefault); AudioChannels.Add(AudioChannelGui); AudioChannels.Add(AudioChannelEffects); AudioChannels.Add(AudioChannelMessages); AudioChannels.Add(AudioChannelMusic); //----------------------------------------------------------------------------- // Master SFXDescriptions. //----------------------------------------------------------------------------- // Master description for interface audio. SFXDescription AudioGui = new SFXDescription("AudioGui") { Volume = 1.0f, SourceGroup = AudioChannelGui }; AudioGui.registerSingleton(); // Master description for game effects audio. SFXDescription AudioEffect = new SFXDescription("AudioEffect") { Volume = 1.0f, SourceGroup = AudioChannelEffects }; AudioEffect.registerSingleton(); // Master description for audio in notifications. SFXDescription AudioMessage = new SFXDescription("AudioMessage") { Volume = 1.0f, SourceGroup = AudioChannelMessages }; AudioMessage.registerSingleton(); // Master description for music. SFXDescription AudioMusic = new SFXDescription("AudioMusic") { Volume = 1.0f, SourceGroup = AudioChannelMusic }; AudioMusic.registerSingleton(); SFXPausedSet = new SimSet("SFXPausedSet"); SFXPausedSet.registerSingleton(); InitBackwardsCompatibility(); }
public static string sfxGetChannelVolume(SimSet channel) { SFXSource obj = sfxOldChannelToGroup(channel); return(obj.isObject() ? obj.getVolume().AsString() : "0"); }
public static void PlayOneShot(AudioBundle bundle, string audioName, float volumeScale = 1.0f) { SFXSource.PlayOneShot(GetClip(bundle, audioName), volumeScale); }
// @formatter:on public void PlaySource(SFXSource source) => PlaySource((byte)source);