Terraria
v1.4.4.9
Terraria source code documentation
Toggle main menu visibility
Main Page
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Functions
a
b
c
d
e
f
g
h
i
j
l
m
n
o
p
r
s
t
u
v
w
x
Enumerations
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
z
Classes
Class List
Class Index
Class Hierarchy
Class Members
All
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Functions
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
~
Variables
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Enumerations
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
Properties
_
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
y
z
Events
_
a
c
d
e
f
i
l
m
o
p
r
s
t
u
w
Files
File List
File Members
All
Enumerations
Macros
•
All
Classes
Namespaces
Files
Functions
Variables
Enumerations
Enumerator
Properties
Events
Macros
Loading...
Searching...
No Matches
MusicCueHolder.cs
Go to the documentation of this file.
1
using
System
;
2
using
Microsoft.Xna.Framework.Audio;
3
4
namespace
Terraria.Audio
;
5
6
public
class
MusicCueHolder
7
{
8
private
SoundBank
_soundBank
;
9
10
private
string
_cueName
;
11
12
private
Cue
_loadedCue
;
13
14
private
float
_lastSetVolume
;
15
16
public
bool
IsPlaying
17
{
18
get
19
{
20
if
(
_loadedCue
!=
null
)
21
{
22
return
_loadedCue
.IsPlaying;
23
}
24
return
false
;
25
}
26
}
16
public
bool
IsPlaying
{
…
};
27
28
public
bool
IsOngoing
29
{
30
get
31
{
32
if
(
_loadedCue
!=
null
)
33
{
34
if
(!
_loadedCue
.IsPlaying)
35
{
36
return
!
_loadedCue
.IsStopped;
37
}
38
return
true
;
39
}
40
return
false
;
41
}
42
}
28
public
bool
IsOngoing
{
…
};
43
44
public
MusicCueHolder
(SoundBank soundBank,
string
cueName)
45
{
46
_soundBank
= soundBank;
47
_cueName
= cueName;
48
_loadedCue
=
null
;
49
}
44
public
MusicCueHolder
(SoundBank soundBank,
string
cueName) {
…
}
50
51
public
void
Pause
()
52
{
53
if
(
_loadedCue
==
null
||
_loadedCue
.IsPaused || !
_loadedCue
.IsPlaying)
54
{
55
return
;
56
}
57
try
58
{
59
_loadedCue
.Pause();
60
}
61
catch
(
Exception
)
62
{
63
}
64
}
51
public
void
Pause
() {
…
}
65
66
public
void
Resume
()
67
{
68
if
(
_loadedCue
==
null
|| !
_loadedCue
.IsPaused)
69
{
70
return
;
71
}
72
try
73
{
74
_loadedCue
.Resume();
75
}
76
catch
(
Exception
)
77
{
78
}
79
}
66
public
void
Resume
() {
…
}
80
81
public
void
Stop
()
82
{
83
if
(
_loadedCue
!=
null
)
84
{
85
SetVolume
(0f);
86
_loadedCue
.Stop(AudioStopOptions.Immediate);
87
}
88
}
81
public
void
Stop
() {
…
}
89
90
public
void
RestartAndTryPlaying
(
float
volume)
91
{
92
PurgeCue
();
93
TryPlaying
(volume);
94
}
90
public
void
RestartAndTryPlaying
(
float
volume) {
…
}
95
96
private
void
PurgeCue
()
97
{
98
if
(
_loadedCue
!=
null
)
99
{
100
_loadedCue
.Stop(AudioStopOptions.Immediate);
101
_loadedCue
.Dispose();
102
_loadedCue
=
null
;
103
}
104
}
96
private
void
PurgeCue
() {
…
}
105
106
public
void
Play
(
float
volume)
107
{
108
LoadTrack
(forceReload:
false
);
109
SetVolume
(volume);
110
_loadedCue
.Play();
111
}
106
public
void
Play
(
float
volume) {
…
}
112
113
public
void
TryPlaying
(
float
volume)
114
{
115
LoadTrack
(forceReload:
false
);
116
if
(
_loadedCue
.IsPrepared)
117
{
118
SetVolume
(volume);
119
if
(!
_loadedCue
.IsPlaying)
120
{
121
_loadedCue
.Play();
122
}
123
}
124
}
113
public
void
TryPlaying
(
float
volume) {
…
}
125
126
public
void
SetVolume
(
float
volume)
127
{
128
_lastSetVolume
= volume;
129
if
(
_loadedCue
!=
null
)
130
{
131
_loadedCue
.SetVariable(
"Volume"
,
_lastSetVolume
);
132
}
133
}
126
public
void
SetVolume
(
float
volume) {
…
}
134
135
private
void
LoadTrack
(
bool
forceReload)
136
{
137
if
(forceReload ||
_loadedCue
==
null
)
138
{
139
_loadedCue
=
_soundBank
.GetCue(
_cueName
);
140
}
141
}
135
private
void
LoadTrack
(
bool
forceReload) {
…
}
142
}
6
public
class
MusicCueHolder
{
…
};
System.Exception
Definition
Exception.cs:15
Terraria.Audio.MusicCueHolder.RestartAndTryPlaying
void RestartAndTryPlaying(float volume)
Definition
MusicCueHolder.cs:90
Terraria.Audio.MusicCueHolder._loadedCue
Cue _loadedCue
Definition
MusicCueHolder.cs:12
Terraria.Audio.MusicCueHolder._cueName
string _cueName
Definition
MusicCueHolder.cs:10
Terraria.Audio.MusicCueHolder.MusicCueHolder
MusicCueHolder(SoundBank soundBank, string cueName)
Definition
MusicCueHolder.cs:44
Terraria.Audio.MusicCueHolder.PurgeCue
void PurgeCue()
Definition
MusicCueHolder.cs:96
Terraria.Audio.MusicCueHolder.IsOngoing
bool IsOngoing
Definition
MusicCueHolder.cs:29
Terraria.Audio.MusicCueHolder.Pause
void Pause()
Definition
MusicCueHolder.cs:51
Terraria.Audio.MusicCueHolder.Stop
void Stop()
Definition
MusicCueHolder.cs:81
Terraria.Audio.MusicCueHolder._soundBank
SoundBank _soundBank
Definition
MusicCueHolder.cs:8
Terraria.Audio.MusicCueHolder.LoadTrack
void LoadTrack(bool forceReload)
Definition
MusicCueHolder.cs:135
Terraria.Audio.MusicCueHolder.Play
void Play(float volume)
Definition
MusicCueHolder.cs:106
Terraria.Audio.MusicCueHolder.SetVolume
void SetVolume(float volume)
Definition
MusicCueHolder.cs:126
Terraria.Audio.MusicCueHolder._lastSetVolume
float _lastSetVolume
Definition
MusicCueHolder.cs:14
Terraria.Audio.MusicCueHolder.TryPlaying
void TryPlaying(float volume)
Definition
MusicCueHolder.cs:113
Terraria.Audio.MusicCueHolder.IsPlaying
bool IsPlaying
Definition
MusicCueHolder.cs:17
Terraria.Audio.MusicCueHolder.Resume
void Resume()
Definition
MusicCueHolder.cs:66
Terraria.Audio.MusicCueHolder
Definition
MusicCueHolder.cs:7
System
Definition
BlockingCollection.cs:8
Terraria.Audio
Definition
ActiveSound.cs:4
source
Terraria.Audio
MusicCueHolder.cs
Generated by
1.10.0