/// <summary> /// Serverside: Play sound at given position for particular player. /// ("Doctor, there are voices in my head!") /// Accepts "#" wildcards for sound variations. (Example: "Punch#") /// </summary> public static void PlayNetworkedForPlayerAtPos(GameObject recipient, Vector3 worldPos, string sndName, float pitch = -1, bool polyphonic = false, bool shakeGround = false, byte shakeIntensity = 64, int shakeRange = 30, GameObject sourceObj = null) { ShakeParameters shakeParameters = null; if (shakeGround) { shakeParameters = new ShakeParameters { ShakeGround = shakeGround, ShakeIntensity = shakeIntensity, ShakeRange = shakeRange }; } AudioSourceParameters audioSourceParameters = null; if (pitch > 0) { audioSourceParameters = new AudioSourceParameters { Pitch = pitch }; } sndName = Instance.ResolveSoundPattern(sndName); PlaySoundMessage.Send(recipient, sndName, worldPos, polyphonic, sourceObj, shakeParameters, audioSourceParameters); }
/// <summary> /// Serverside: Play sound at given position for particular player. /// ("Doctor, there are voices in my head!") /// Accepts "#" wildcards for sound variations. (Example: "Punch#") /// </summary> public static void PlayNetworkedForPlayerAtPos(GameObject recipient, Vector3 pos, string sndName, float pitch = -1, bool polyphonic = false, bool shakeGround = false, byte shakeIntensity = 64, int shakeRange = 30) { sndName = Instance.ResolveSoundPattern(sndName); PlaySoundMessage.Send(recipient, sndName, pos, pitch, polyphonic, shakeGround, shakeIntensity, shakeRange); }
/// <summary> /// Serverside: Play sound at given position for particular player. /// ("Doctor, there are voices in my head!") /// If more than one is specified, one will be picked at random. /// </summary> /// <param name="addressableAudioSources">The sound to be played. If more than one is specified, one will be picked at random.</param> public static async Task PlayNetworkedForPlayerAtPos(GameObject recipient, Vector3 worldPos, List <AddressableAudioSource> addressableAudioSources, float pitch = -1, bool polyphonic = false, bool shakeGround = false, byte shakeIntensity = 64, int shakeRange = 30, GameObject sourceObj = null) { ShakeParameters shakeParameters = null; if (shakeGround) { shakeParameters = new ShakeParameters { ShakeGround = shakeGround, ShakeIntensity = shakeIntensity, ShakeRange = shakeRange }; } AudioSourceParameters audioSourceParameters = null; if (pitch > 0) { audioSourceParameters = new AudioSourceParameters { Pitch = pitch }; } AddressableAudioSource addressableAudioSource = await GetAddressableAudioSourceFromCache(addressableAudioSources); PlaySoundMessage.Send(recipient, addressableAudioSource, worldPos, polyphonic, sourceObj, shakeParameters, audioSourceParameters); }
/// <summary> /// Serverside: Play sound for particular player. /// ("Doctor, there are voices in my head!") /// Accepts "#" wildcards for sound variations. (Example: "Punch#") /// </summary> public static void PlayNetworkedForPlayer(GameObject recipient, string sndName, float pitch = -1, bool polyphonic = false, bool shakeGround = false, byte shakeIntensity = 64, int shakeRange = 30, GameObject sourceObj = null) { sndName = Instance.ResolveSoundPattern(sndName); PlaySoundMessage.Send(recipient, sndName, TransformState.HiddenPos, pitch, polyphonic, shakeGround, shakeIntensity, shakeRange, sourceObj); }
/// <summary> /// Play sound for particular player. /// ("Doctor, there are voices in my head!") /// </summary> /// <param name="recipient">The player that will receive the sound</param> /// <param name="addressableAudioSource">The sound to be played.</param> /// <param name="audioSourceParameters">Extra parameters of the audio source.</param> /// <param name="polyphonic">Is the sound to be played polyphonic</param> /// <param name="shakeParameters">Camera shake effect associated with this sound</param> /// <param name="sourceObj">The object that is the source of the sound</param> public static async Task PlayNetworkedForPlayer(GameObject recipient, AddressableAudioSource addressableAudioSource, AudioSourceParameters audioSourceParameters = new AudioSourceParameters(), bool polyphonic = false, ShakeParameters shakeParameters = new ShakeParameters(), GameObject sourceObj = null) { if (addressableAudioSource == null || string.IsNullOrEmpty(addressableAudioSource.AssetAddress) || addressableAudioSource.AssetAddress == "null") { Logger.LogWarning($"SoundManager received a null AudioSource to be played for: {recipient.name}", Category.Audio); return; } PlaySoundMessage.Send(recipient, addressableAudioSource, TransformState.HiddenPos, polyphonic, sourceObj, shakeParameters, audioSourceParameters); }
/// <summary> /// Serverside: Play sound at given position for particular player. /// ("Doctor, there are voices in my head!") /// </summary> /// <param name="recipient">The player that will receive the sound</param> /// <param name="addressableAudioSource">The sound to be played.</param> /// <param name="audioSourceParameters">Extra parameters of the audio source.</param> /// <param name="polyphonic">Is the sound to be played polyphonic</param> /// <param name="shakeParameters">Camera shake effect associated with this sound</param> /// <param name="sourceObj">The object that is the source of the sound</param> public static async Task PlayNetworkedForPlayerAtPos(GameObject recipient, Vector3 worldPos, AddressableAudioSource addressableAudioSource, AudioSourceParameters audioSourceParameters = new AudioSourceParameters(), bool polyphonic = false, ShakeParameters shakeParameters = new ShakeParameters(), GameObject sourceObj = null) { if (addressableAudioSource == null || string.IsNullOrEmpty(addressableAudioSource.AssetAddress) || addressableAudioSource.AssetAddress == "null") { Logger.LogWarning($"SoundManager received a null AudioSource to be played for: {recipient.name} at position: {worldPos}", Category.Audio); return; } addressableAudioSource = await AudioManager.GetAddressableAudioSourceFromCache(addressableAudioSource); PlaySoundMessage.Send(recipient, addressableAudioSource, worldPos, polyphonic, sourceObj, shakeParameters, audioSourceParameters); }
/// <summary> /// Play sound for particular player. /// ("Doctor, there are voices in my head!") /// If more than one is specified, one will be picked at random. /// </summary> /// <param name="recipient">The player that will receive the sound</param> /// <param name="addressableAudioSources">The sound to be played. If more than one is specified, one will be picked at random.</param> /// <param name="pitch">The pitch variation of the sound. -1 for default pitch.</param> public static async Task PlayNetworkedForPlayer(GameObject recipient, List <AddressableAudioSource> addressableAudioSources, float pitch = 0, bool polyphonic = false, bool shakeGround = false, byte shakeIntensity = 64, int shakeRange = 30, GameObject sourceObj = null) { ShakeParameters shakeParameters = new ShakeParameters(shakeGround, shakeIntensity, shakeRange); AudioSourceParameters audioSourceParameters = new AudioSourceParameters(); audioSourceParameters.Pitch = pitch; AddressableAudioSource addressableAudioSource = await GetAddressableAudioSourceFromCache(addressableAudioSources); PlaySoundMessage.Send(recipient, addressableAudioSource, TransformState.HiddenPos, polyphonic, sourceObj, shakeParameters, audioSourceParameters); }
/// <summary> /// Serverside: Play sound for particular player /// ("Doctor, there are voices in my head!") /// </summary> public static void PlayNetworkedForPlayer(GameObject recipient, string sndName, float pitch = -1, bool shakeGround = false, byte shakeIntensity = 64, int shakeRange = 30) { PlaySoundMessage.Send(recipient, sndName, TransformState.HiddenPos, pitch, shakeGround, shakeIntensity, shakeRange); }