Skip to content

Commit e2353e8

Browse files
committed
1.0.8 part 2 💀
Creating my own audioplayer to avoid the problem with grenades
1 parent 1daa7f8 commit e2353e8

File tree

4 files changed

+29
-9
lines changed

4 files changed

+29
-9
lines changed

SCP575/Resources/Components/Scp575Component.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ private IEnumerator<float> Checks()
166166
/// </summary>
167167
private void OnDestroy()
168168
{
169-
var audioPlayer = AudioPlayerBase.Get(ReferenceHub);
169+
var audioPlayer = Scp575AudioPlayer.Get(ReferenceHub);
170170
audioPlayer.Stoptrack(true);
171171

172172
Timing.KillCoroutines(_checksCoroutine);

SCP575/Resources/FakeConnection.cs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,13 @@ namespace SCP575.Resources
55
{
66
public class FakeConnection : NetworkConnectionToClient
77
{
8-
public FakeConnection(int connectionId) : base(connectionId, false, 0f)
9-
{
10-
}
11-
12-
public override string address => "localhost";
13-
148
public override void Send(ArraySegment<byte> segment, int channelId = 0)
159
{
1610
}
1711

18-
public override void Disconnect()
12+
public override string address => "localhost";
13+
14+
public FakeConnection(int networkConnectionId) : base(networkConnectionId, false, 0)
1915
{
2016
}
2117
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
using SCPSLAudioApi.AudioCore;
2+
using VoiceChat;
3+
4+
namespace SCP575.Resources
5+
{
6+
public class Scp575AudioPlayer : AudioPlayerBase
7+
{
8+
public static Scp575AudioPlayer Get(ReferenceHub hub)
9+
{
10+
if (AudioPlayers.TryGetValue(hub, out AudioPlayerBase player))
11+
{
12+
if (player is Scp575AudioPlayer scp575Player1)
13+
return scp575Player1;
14+
}
15+
16+
var scp575Player = hub.gameObject.AddComponent<Scp575AudioPlayer>();
17+
scp575Player.Owner = hub;
18+
scp575Player.BroadcastChannel = VoiceChatChannel.Proximity;
19+
20+
AudioPlayers.Add(hub, scp575Player);
21+
return scp575Player;
22+
}
23+
}
24+
}

SCP575/Scp575.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -250,7 +250,7 @@ private void Spawn575(float duration)
250250

251251
if (!Config.Scp575.PlaySounds) return;
252252
if (!Extensions.AudioFileExist()) Log.Error($"There is no .ogg file in the folder {AudioPath}");
253-
var audioPlayer = AudioPlayerBase.Get(hubPlayer);
253+
var audioPlayer = Scp575AudioPlayer.Get(hubPlayer);
254254
var audioFile = Extensions.GetAudioFilePath();
255255
audioPlayer.Enqueue(audioFile, -1);
256256
audioPlayer.LogDebug = Config.AudioDebug;

0 commit comments

Comments
 (0)