Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SoundStyle.cs
Go to the documentation of this file.
1using Microsoft.Xna.Framework.Audio;
3
4namespace Terraria.Audio;
5
6public abstract class SoundStyle
7{
8 private static UnifiedRandom _random = new UnifiedRandom();
9
10 private float _volume;
11
12 private float _pitchVariance;
13
15
16 public float Volume => _volume;
17
19
20 public SoundType Type => _type;
21
22 public abstract bool IsTrackable { get; }
23
24 public SoundStyle(float volume, float pitchVariance, SoundType type = SoundType.Sound)
25 {
26 _volume = volume;
27 _pitchVariance = pitchVariance;
28 _type = type;
29 }
30
31 public SoundStyle(SoundType type = SoundType.Sound)
32 {
33 _volume = 1f;
34 _pitchVariance = 0f;
35 _type = type;
36 }
37
38 public float GetRandomPitch()
39 {
40 return _random.NextFloat() * PitchVariance - PitchVariance * 0.5f;
41 }
42
43 public abstract SoundEffect GetRandomSound();
44}
SoundStyle(SoundType type=SoundType.Sound)
Definition SoundStyle.cs:31
static UnifiedRandom _random
Definition SoundStyle.cs:8
SoundStyle(float volume, float pitchVariance, SoundType type=SoundType.Sound)
Definition SoundStyle.cs:24
SoundEffect GetRandomSound()