Survivalcraft API 1.8.2.3 v1.8.2.3
Survivalcraft 2.4
载入中...
搜索中...
未找到
ComponentCreatureSounds.cs
浏览该文件的文档.
3
4namespace Game {
7
9
11
13
14 public Random m_random = new();
15
16 public string m_idleSound;
17
18 public string m_painSound;
19
20 public string m_moanSound;
21
22 public string m_sneezeSound;
23
24 public string m_coughSound;
25
26 public string m_pukeSound;
27
28 public string m_attackSound;
29
31
33
35
37
39
41
43
44 public double m_lastSoundTime = -1000.0;
45
46 public double m_lastCoughingSoundTime = -1000.0;
47
48 public double m_lastPukeSoundTime = -1000.0;
49
50 public virtual void PlayIdleSound(bool skipIfRecentlyPlayed) {
51 if (!string.IsNullOrEmpty(m_idleSound)
52 && m_subsystemTime.GameTime > m_lastSoundTime + (skipIfRecentlyPlayed ? 12f : 1f)) {
54 m_subsystemAudio.PlayRandomSound(
56 1f,
57 m_random.Float(-0.1f, 0.1f),
58 m_componentCreature.ComponentBody.Position,
60 false
61 );
62 }
63 }
64
65 public virtual void PlayPainSound() {
66 if (!string.IsNullOrEmpty(m_painSound)
67 && m_subsystemTime.GameTime > m_lastSoundTime + 1.0) {
69 m_subsystemAudio.PlayRandomSound(
71 1f,
72 m_random.Float(-0.1f, 0.1f),
73 m_componentCreature.ComponentBody.Position,
75 false
76 );
77 }
78 }
79
80 public virtual void PlayMoanSound() {
81 if (!string.IsNullOrEmpty(m_moanSound)
82 && m_subsystemTime.GameTime > m_lastSoundTime + 1.0) {
84 m_subsystemAudio.PlayRandomSound(
86 1f,
87 m_random.Float(-0.1f, 0.1f),
88 m_componentCreature.ComponentBody.Position,
90 false
91 );
92 }
93 }
94
95 public virtual void PlaySneezeSound() {
96 if (!string.IsNullOrEmpty(m_sneezeSound)
97 && m_subsystemTime.GameTime > m_lastSoundTime + 1.0) {
99 m_subsystemAudio.PlayRandomSound(
101 1f,
102 m_random.Float(-0.1f, 0.1f),
103 m_componentCreature.ComponentBody.Position,
105 false
106 );
107 }
108 }
109
110 public void PlayCoughSound() {
111 if (!string.IsNullOrEmpty(m_coughSound)
112 && m_subsystemTime.GameTime > m_lastCoughingSoundTime + 1.0) {
114 m_subsystemAudio.PlayRandomSound(
116 1f,
117 m_random.Float(-0.1f, 0.1f),
118 m_componentCreature.ComponentBody.Position,
120 false
121 );
122 }
123 }
124
125 public virtual void PlayPukeSound() {
126 if (!string.IsNullOrEmpty(m_pukeSound)
127 && m_subsystemTime.GameTime > m_lastPukeSoundTime + 1.0) {
129 m_subsystemAudio.PlayRandomSound(
131 1f,
132 m_random.Float(-0.1f, 0.1f),
133 m_componentCreature.ComponentBody.Position,
135 false
136 );
137 }
138 }
139
140 public virtual void PlayAttackSound() {
141 if (!string.IsNullOrEmpty(m_attackSound)
142 && m_subsystemTime.GameTime > m_lastSoundTime + 1.0) {
144 m_subsystemAudio.PlayRandomSound(
146 1f,
147 m_random.Float(-0.1f, 0.1f),
148 m_componentCreature.ComponentBody.Position,
150 false
151 );
152 }
153 }
154
155 public virtual bool PlayFootstepSound(float loudnessMultiplier) =>
156 m_subsystemSoundMaterials.PlayFootstepSound(m_componentCreature, loudnessMultiplier);
157
158 public override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap) {
159 m_subsystemTime = Project.FindSubsystem<SubsystemTime>(true);
160 m_subsystemAudio = Project.FindSubsystem<SubsystemAudio>(true);
162 m_componentCreature = Entity.FindComponent<ComponentCreature>(true);
163 m_idleSound = valuesDictionary.GetValue<string>("IdleSound");
164 m_painSound = valuesDictionary.GetValue<string>("PainSound");
165 m_moanSound = valuesDictionary.GetValue<string>("MoanSound");
166 m_sneezeSound = valuesDictionary.GetValue<string>("SneezeSound");
167 m_coughSound = valuesDictionary.GetValue<string>("CoughSound");
168 m_pukeSound = valuesDictionary.GetValue<string>("PukeSound");
169 m_attackSound = valuesDictionary.GetValue<string>("AttackSound");
170 m_idleSoundMinDistance = valuesDictionary.GetValue<float>("IdleSoundMinDistance");
171 m_painSoundMinDistance = valuesDictionary.GetValue<float>("PainSoundMinDistance");
172 m_moanSoundMinDistance = valuesDictionary.GetValue<float>("MoanSoundMinDistance");
173 m_sneezeSoundMinDistance = valuesDictionary.GetValue<float>("SneezeSoundMinDistance");
174 m_coughSoundMinDistance = valuesDictionary.GetValue<float>("CoughSoundMinDistance");
175 m_pukeSoundMinDistance = valuesDictionary.GetValue<float>("PukeSoundMinDistance");
176 m_attackSoundMinDistance = valuesDictionary.GetValue<float>("AttackSoundMinDistance");
177 }
178 }
179}
virtual void PlayIdleSound(bool skipIfRecentlyPlayed)
SubsystemSoundMaterials m_subsystemSoundMaterials
virtual bool PlayFootstepSound(float loudnessMultiplier)
override void Load(ValuesDictionary valuesDictionary, IdToEntityMap idToEntityMap)
ValuesDictionary ValuesDictionary