diff --git a/Roles/MusicManager.cs b/Roles/MusicManager.cs
index a7ce26a..51ebb9d 100644
--- a/Roles/MusicManager.cs
+++ b/Roles/MusicManager.cs
@@ -87,6 +87,17 @@ public AudioPlayerBase Play(string musicFile, string npcName, FramePlayer source
return Play(musicFile, npcName, new TrackEvent(), source, distance, [], false, 80, false);
}
///
+ /// 单独给一个人播放音频
+ ///
+ /// 音频文件
+ /// NPC名称
+ /// 指定玩家
+ ///
+ public AudioPlayerBase Play(string musicFile, string npcName, Player source)
+ {
+ return Play(musicFile, npcName, new TrackEvent(), source, [], false, 80, false);
+ }
+ ///
/// 播放音频
///
/// 音频文件
@@ -154,7 +165,59 @@ public AudioPlayerBase Play(string musicFile, string npcName, TrackEvent? trackE
}
return audioPlayerBase;
}
+ ///
+ /// 播放音频
+ ///
+ /// 音频文件
+ /// NPC名称
+ /// 播放事件
+ /// 传播距离检测源头玩家
+ /// 额外可接收音频的玩家
+ /// 是否覆盖播放
+ /// 音量大小
+ /// 是否循环
+ ///
+ public AudioPlayerBase Play(string musicFile, string npcName, TrackEvent trackEvent, FramePlayer source, FramePlayer[] extraPlay, bool isSole = false, float volume = 80, bool isLoop = false)
+ {
+ AudioPlayerBase audioPlayerBase = null;
+ try
+ {
+ OnTrackLoaded += trackEvent.TrackLoaded;
+ if (!MusicNpc.TryGetValue(npcName, out ReferenceHub npc))
+ {
+ npc = CreateMusicNpc(npcName);
+ audioPlayerBase = Get(npc);
+ }
+ else
+ {
+ if (!isSole)
+ {
+ npc = CreateMusicNpc(npcName);
+ audioPlayerBase = Get(npc);
+ MusicNpc.Add(num + npcName, npc);
+ num++;
+ }
+ }
+
+ if (extraPlay != null)
+ {
+ audioPlayerBase.AudioToPlay = extraPlay.Select((s) => { return s.ExPlayer.UserId; }).ToList();
+ }
+
+ audioPlayerBase.AudioToPlay.Add(source.UserId);
+ audioPlayerBase.Enqueue($"{Paths.Plugins}/{Server.Port}/YongAnPluginData/{musicFile}.ogg", 0);
+ audioPlayerBase.Volume = volume;
+ audioPlayerBase.Loop = isLoop;
+ audioPlayerBase.Play(0);
+ }
+ catch (Exception)
+ {
+ Stop(audioPlayerBase);
+ }
+ return audioPlayerBase;
+ }
+
public readonly struct TrackEvent(TrackLoaded trackLoaded)
{
public TrackLoaded TrackLoaded { get; } = trackLoaded;