Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
SubsystemAmbientSounds.cs
浏览该文件的文档.
1using Engine;
2using Engine.Audio;
5
6namespace Game {
9
11
13
14 public Random m_random = new();
15
16 public SubsystemAudio SubsystemAudio { get; set; }
17
18 public float FireSoundVolume { get; set; }
19
20 public float WaterSoundVolume { get; set; }
21
22 public float MagmaSoundVolume { get; set; }
23
25
26 public virtual void Update(float dt) {
27 m_fireSound.Volume = MathUtils.Lerp(
28 m_fireSound.Volume,
31 );
32 if (m_fireSound.Volume > 0.5f * AudioManager.MinAudibleVolume) {
33 m_fireSound.Play();
34 }
35 else {
36 m_fireSound.Pause();
37 }
38 m_waterSound.Volume = MathUtils.Lerp(
39 m_waterSound.Volume,
42 );
43 if (m_waterSound.Volume > 0.5f * AudioManager.MinAudibleVolume) {
44 m_waterSound.Play();
45 }
46 else {
47 m_waterSound.Pause();
48 }
49 m_magmaSound.Volume = MathUtils.Lerp(
50 m_magmaSound.Volume,
53 );
54 if (m_magmaSound.Volume > 0.5f * AudioManager.MinAudibleVolume) {
55 m_magmaSound.Play();
56 }
57 else {
58 m_magmaSound.Pause();
59 }
60 if (m_magmaSound.State == SoundState.Playing
61 && m_random.Bool(0.2f * dt)) {
62 SubsystemAudio.PlayRandomSound("Audio/Sizzles", m_magmaSound.Volume, m_random.Float(-0.2f, 0.2f), 0f, 0f);
63 }
64 FireSoundVolume = 0f;
67 }
68
69 public override void Load(ValuesDictionary valuesDictionary) {
70 SubsystemAudio = Project.FindSubsystem<SubsystemAudio>(true);
71 m_fireSound = SubsystemAudio.CreateSound("Audio/Fire");
72 m_fireSound.IsLooped = true;
73 m_fireSound.Volume = 0f;
74 m_waterSound = SubsystemAudio.CreateSound("Audio/Water");
75 m_waterSound.IsLooped = true;
76 m_waterSound.Volume = 0f;
77 m_magmaSound = SubsystemAudio.CreateSound("Audio/Magma");
78 m_magmaSound.IsLooped = true;
79 m_magmaSound.Volume = 0f;
80 }
81 }
82}
static float Saturate(float x)
static float Lerp(float x1, float x2, float f)
static float FrameDuration
定义 Time.cs:46
static float MinAudibleVolume
override void Load(ValuesDictionary valuesDictionary)
ValuesDictionary ValuesDictionary