Terraria v1.4.4.9
Terraria source code documentation
Loading...
Searching...
No Matches
SoundPlayer.cs
Go to the documentation of this file.
4
5namespace Terraria.Audio;
6
7public class SoundPlayer
8{
10
11 public SlotId Play(SoundStyle style, Vector2 position)
12 {
13 //IL_0012: Unknown result type (might be due to invalid IL or missing references)
14 //IL_0059: Unknown result type (might be due to invalid IL or missing references)
15 //IL_0044: Unknown result type (might be due to invalid IL or missing references)
16 if (Main.dedServ || style == null || !style.IsTrackable)
17 {
18 return SlotId.Invalid;
19 }
20 if (Vector2.DistanceSquared(Main.screenPosition + new Vector2(Main.screenWidth / 2, Main.screenHeight / 2), position) > 100000000f)
21 {
22 return SlotId.Invalid;
23 }
24 ActiveSound activeSound = new ActiveSound(style, position);
26 }
27
29 {
30 //IL_0012: Unknown result type (might be due to invalid IL or missing references)
31 //IL_005a: Unknown result type (might be due to invalid IL or missing references)
32 //IL_0044: Unknown result type (might be due to invalid IL or missing references)
33 if (Main.dedServ || style == null || !style.IsTrackable)
34 {
35 return SlotId.Invalid;
36 }
37 if (Vector2.DistanceSquared(Main.screenPosition + new Vector2(Main.screenWidth / 2, Main.screenHeight / 2), position) > 100000000f)
38 {
39 return SlotId.Invalid;
40 }
43 }
44
45 public void Reload()
46 {
47 StopAll();
48 }
49
50 public SlotId Play(SoundStyle style)
51 {
52 //IL_0012: Unknown result type (might be due to invalid IL or missing references)
53 //IL_0026: Unknown result type (might be due to invalid IL or missing references)
54 if (Main.dedServ || style == null || !style.IsTrackable)
55 {
56 return SlotId.Invalid;
57 }
60 }
61
63 {
64 //IL_0006: Unknown result type (might be due to invalid IL or missing references)
65 //IL_0016: Unknown result type (might be due to invalid IL or missing references)
66 if (!_trackedSounds.Has(id))
67 {
68 return null;
69 }
70 return _trackedSounds[id];
71 }
72
73 public void PauseAll()
74 {
75 //IL_000f: Unknown result type (might be due to invalid IL or missing references)
77 {
78 item.Value.Pause();
79 }
80 }
81
82 public void ResumeAll()
83 {
84 //IL_000f: Unknown result type (might be due to invalid IL or missing references)
86 {
87 item.Value.Resume();
88 }
89 }
90
91 public void StopAll()
92 {
93 //IL_000f: Unknown result type (might be due to invalid IL or missing references)
95 {
96 item.Value.Stop();
97 }
99 }
100
101 public void Update()
102 {
103 //IL_0048: Unknown result type (might be due to invalid IL or missing references)
104 //IL_0049: Unknown result type (might be due to invalid IL or missing references)
105 //IL_000f: Unknown result type (might be due to invalid IL or missing references)
106 //IL_0014: Unknown result type (might be due to invalid IL or missing references)
107 //IL_0015: Unknown result type (might be due to invalid IL or missing references)
108 //IL_0020: Unknown result type (might be due to invalid IL or missing references)
109 //IL_0033: Unknown result type (might be due to invalid IL or missing references)
110 //IL_0034: Unknown result type (might be due to invalid IL or missing references)
112 {
113 try
114 {
115 item.Value.Update();
116 if (!item.Value.IsPlaying)
117 {
118 _trackedSounds.Remove(item.Id);
119 }
120 }
121 catch
122 {
123 _trackedSounds.Remove(item.Id);
124 }
125 }
126 }
127
129 {
130 //IL_000f: Unknown result type (might be due to invalid IL or missing references)
131 //IL_0014: Unknown result type (might be due to invalid IL or missing references)
132 //IL_0015: Unknown result type (might be due to invalid IL or missing references)
133 //IL_0023: Unknown result type (might be due to invalid IL or missing references)
135 {
136 if (item.Value.Style == style)
137 {
138 return item.Value;
139 }
140 }
141 return null;
142 }
143}
bool ICollection< KeyValuePair< TKey, TValue > >. Remove(KeyValuePair< TKey, TValue > keyValuePair)
void Add(TKey key, TValue value)
delegate bool LoopedPlayCondition()
ActiveSound FindActiveSound(SoundStyle style)
SlotId Play(SoundStyle style, Vector2 position)
SlotId Play(SoundStyle style)
SlotId PlayLooped(SoundStyle style, Vector2 position, ActiveSound.LoopedPlayCondition loopingCondition)
readonly SlotVector< ActiveSound > _trackedSounds
Definition SoundPlayer.cs:9
ActiveSound GetActiveSound(SlotId id)
static bool dedServ
Definition Main.cs:1226
static int screenHeight
Definition Main.cs:1721
static Vector2 screenPosition
Definition Main.cs:1715
static int screenWidth
Definition Main.cs:1719
static float DistanceSquared(Vector2 value1, Vector2 value2)
Definition Vector2.cs:107
static readonly SlotId Invalid
Definition SlotId.cs:5