Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
CustomSoundStyle.cs
Go to the documentation of this file.
1using Microsoft.Xna.Framework.Audio;
3
4namespace Terraria.Audio;
5
7{
8 private static readonly UnifiedRandom Random = new UnifiedRandom();
9
10 private readonly SoundEffect[] _soundEffects;
11
12 public override bool IsTrackable => true;
13
14 public CustomSoundStyle(SoundEffect soundEffect, SoundType type = SoundType.Sound, float volume = 1f, float pitchVariance = 0f)
15 : base(volume, pitchVariance, type)
16 {
17 _soundEffects = new SoundEffect[1] { soundEffect };
18 }
19
20 public CustomSoundStyle(SoundEffect[] soundEffects, SoundType type = SoundType.Sound, float volume = 1f, float pitchVariance = 0f)
21 : base(volume, pitchVariance, type)
22 {
23 _soundEffects = soundEffects;
24 }
25
26 public override SoundEffect GetRandomSound()
27 {
28 return _soundEffects[Random.Next(_soundEffects.Length)];
29 }
30}
override SoundEffect GetRandomSound()
CustomSoundStyle(SoundEffect soundEffect, SoundType type=SoundType.Sound, float volume=1f, float pitchVariance=0f)
CustomSoundStyle(SoundEffect[] soundEffects, SoundType type=SoundType.Sound, float volume=1f, float pitchVariance=0f)
readonly SoundEffect[] _soundEffects
static readonly UnifiedRandom Random