-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4c2174c
commit e90b576
Showing
9 changed files
with
386 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
|
||
Microsoft Visual Studio Solution File, Format Version 12.00 | ||
# Visual Studio Version 17 | ||
VisualStudioVersion = 17.12.35527.113 d17.12 | ||
MinimumVisualStudioVersion = 10.0.40219.1 | ||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "MVPMusicBox", "MVPMusicBox\MVPMusicBox.csproj", "{120E5B85-75F0-4D97-91A6-203AF884BAAC}" | ||
EndProject | ||
Global | ||
GlobalSection(SolutionConfigurationPlatforms) = preSolution | ||
Debug|Any CPU = Debug|Any CPU | ||
Release|Any CPU = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(ProjectConfigurationPlatforms) = postSolution | ||
{120E5B85-75F0-4D97-91A6-203AF884BAAC}.Debug|Any CPU.ActiveCfg = Debug|Any CPU | ||
{120E5B85-75F0-4D97-91A6-203AF884BAAC}.Debug|Any CPU.Build.0 = Debug|Any CPU | ||
{120E5B85-75F0-4D97-91A6-203AF884BAAC}.Release|Any CPU.ActiveCfg = Release|Any CPU | ||
{120E5B85-75F0-4D97-91A6-203AF884BAAC}.Release|Any CPU.Build.0 = Release|Any CPU | ||
EndGlobalSection | ||
GlobalSection(SolutionProperties) = preSolution | ||
HideSolutionNode = FALSE | ||
EndGlobalSection | ||
EndGlobal |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Exiled.API.Interfaces; | ||
using System.ComponentModel; | ||
|
||
namespace MVPMusicBox | ||
{ | ||
public class Config : IConfig | ||
{ | ||
[Description("启动MVP音乐盒")] | ||
public bool IsEnabled { get; set ; } = true; | ||
[Description("启动MVP音乐盒-Debug")] | ||
public bool Debug { get; set; } = false; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
using Exiled.API.Features; | ||
using Exiled.Events.EventArgs.Player; | ||
using Exiled.Events.EventArgs.Server; | ||
using Newtonsoft.Json; | ||
using System.Collections.Generic; | ||
using System.IO; | ||
using System.Linq; | ||
|
||
namespace MVPMusicBox | ||
{ | ||
public class EventHandlers | ||
{ | ||
public class MVPList | ||
{ | ||
public string UserId { get; set; } | ||
public string MusicName { get; set; } | ||
public string BroadcastName { get; set; } | ||
} | ||
public class MVPMusic | ||
{ | ||
public static bool MusicBox = true; | ||
public static List<MVPList> MVPInfos = new List<MVPList>(); | ||
public static Dictionary<Player, int> Kills = new Dictionary<Player, int>(); | ||
public static void RegMusic() | ||
{ | ||
ReadJson(); | ||
Exiled.Events.Handlers.Server.RoundStarted += RoundStart; | ||
Exiled.Events.Handlers.Server.RoundEnded += RoundEnded; | ||
Exiled.Events.Handlers.Player.Dying += PlayerDying; | ||
Exiled.Events.Handlers.Player.Spawned += PlayerSpawn; | ||
} | ||
public static void UnRegMusic() | ||
{ | ||
Exiled.Events.Handlers.Server.RoundStarted -= RoundStart; | ||
Exiled.Events.Handlers.Server.RoundEnded -= RoundEnded; | ||
Exiled.Events.Handlers.Player.Dying -= PlayerDying; | ||
Exiled.Events.Handlers.Player.Spawned -= PlayerSpawn; | ||
} | ||
public static void RoundStart() | ||
{ | ||
foreach (Player player in Player.List) | ||
{ | ||
Kills[player] = 0; | ||
} | ||
Kills.Clear(); | ||
ReadJson(); | ||
} | ||
public static void PlayerSpawn(SpawnedEventArgs Args) | ||
{ | ||
if (!Kills.ContainsKey(Args.Player) && Args.Player.IsVerified && !Args.Player.IsNPC) | ||
{ | ||
Kills.Add(Args.Player, 0); | ||
} | ||
} | ||
public static void PlayerDying(DyingEventArgs Args) | ||
{ | ||
if (Args.Player != null && Args.Attacker != null) | ||
{ | ||
if (Args.Player != Args.Attacker) | ||
{ | ||
if (Kills.ContainsKey(Args.Attacker)) | ||
{ | ||
Kills[Args.Attacker]++; | ||
} | ||
else | ||
{ | ||
Kills[Args.Attacker] = 1; | ||
} | ||
} | ||
} | ||
} | ||
public static void MusicBoxPlayer(Player player) | ||
{ | ||
MVPList mvpList = MVPInfos.FirstOrDefault(x => x.UserId == player.UserId); | ||
if (mvpList != null) | ||
{ | ||
Log.Info($"[MVP][玩家 {player.Nickname}][击杀 {Kills[player]} 人][播放音乐 {mvpList.MusicName} ][播报名 {mvpList.BroadcastName}]"); | ||
Map.Broadcast(10, $"<size=55%>=----------------= <color=#FFF000>MVP 时刻</color> =----------------=</size>\n<size=45%>本回合MVP: {player.Nickname} </size>\n<size=50%>总共击杀了 {Kills[player]} 人 </size>\n<size=55%>正在播放MVP音乐: 「 {mvpList.BroadcastName} 」 </size>"); | ||
MusicAPI.PlayMusic.GlobalPlayMusic(Paths.Exiled + "\\音乐盒\\音乐文件", mvpList.MusicName, $"{player.Nickname}的音乐盒"); | ||
return; | ||
} | ||
else | ||
{ | ||
Log.Info($"[MVP][玩家 {player.Nickname}][击杀 {Kills[player]} 人]"); | ||
Map.Broadcast(10, $"<size=55%>=----------------= <color=#FFF000>MVP 时刻</color> =----------------=</size>\n<size=45%>本回合MVP: {player.Nickname} </size>\n<size=50%>总共击杀了 {Kills[player]} 人 </size>"); | ||
return; | ||
} | ||
} | ||
public static void RoundEnded(RoundEndedEventArgs ev) | ||
{ | ||
if (MusicBox == false) | ||
return; | ||
MusicBox = false; | ||
ReadJson(); | ||
foreach (Player player in Player.List) | ||
if (!Kills.ContainsKey(player)) | ||
Kills.Add(player, 0); | ||
MusicBoxPlayer(Kills.OrderByDescending(x => x.Value).First().Key); | ||
} | ||
public static void ReadJson() | ||
{ | ||
string JsonPath = Paths.Exiled + "\\音乐盒\\Config.json"; | ||
if (!Directory.Exists(Paths.Exiled + "\\音乐盒")) | ||
{ | ||
Directory.CreateDirectory(Paths.Exiled + "\\音乐盒"); | ||
} | ||
if (!Directory.Exists(Paths.Exiled + "\\音乐盒\\音乐文件")) | ||
{ | ||
Directory.CreateDirectory(Paths.Exiled + "\\音乐盒\\音乐文件"); | ||
} | ||
if (!File.Exists(JsonPath)) | ||
{ | ||
MVPInfos.Add(new MVPList() | ||
{ | ||
UserId = "76561199208302036@steam", | ||
MusicName = "76561199208302036", | ||
BroadcastName = "[DEBUG]", | ||
}); | ||
File.WriteAllText(JsonPath, JsonConvert.SerializeObject((object)MVPInfos)); | ||
Log.Info($"生成音乐盒模板至 => [{JsonPath}]"); | ||
} | ||
else | ||
{ | ||
MVPInfos = JsonConvert.DeserializeObject<List<MVPList>>(File.ReadAllText(JsonPath)); | ||
Log.Info($"读取音乐盒数量:{MVPInfos.Count}"); | ||
} | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
<?xml version="1.0" encoding="utf-8"?> | ||
<Project ToolsVersion="15.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> | ||
<Import Project="$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" /> | ||
<PropertyGroup> | ||
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration> | ||
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform> | ||
<ProjectGuid>{120E5B85-75F0-4D97-91A6-203AF884BAAC}</ProjectGuid> | ||
<OutputType>Library</OutputType> | ||
<AppDesignerFolder>Properties</AppDesignerFolder> | ||
<RootNamespace>MVPMusicBox</RootNamespace> | ||
<AssemblyName>MVPMusicBox</AssemblyName> | ||
<TargetFrameworkVersion>v4.8</TargetFrameworkVersion> | ||
<FileAlignment>512</FileAlignment> | ||
<Deterministic>true</Deterministic> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' "> | ||
<DebugSymbols>true</DebugSymbols> | ||
<DebugType>full</DebugType> | ||
<Optimize>false</Optimize> | ||
<OutputPath>bin\Debug\</OutputPath> | ||
<DefineConstants>DEBUG;TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
<PlatformTarget>x64</PlatformTarget> | ||
</PropertyGroup> | ||
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' "> | ||
<DebugType>pdbonly</DebugType> | ||
<Optimize>true</Optimize> | ||
<OutputPath>bin\Release\</OutputPath> | ||
<DefineConstants>TRACE</DefineConstants> | ||
<ErrorReport>prompt</ErrorReport> | ||
<WarningLevel>4</WarningLevel> | ||
</PropertyGroup> | ||
<ItemGroup> | ||
<Reference Include="Assembly-CSharp"> | ||
<HintPath>..\..\..\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Assembly-CSharp.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Assembly-CSharp-firstpass"> | ||
<HintPath>..\..\..\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Assembly-CSharp-firstpass.dll</HintPath> | ||
</Reference> | ||
<Reference Include="CommandSystem.Core"> | ||
<HintPath>..\..\..\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\CommandSystem.Core.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Exiled.API"> | ||
<HintPath>C:\Users\Administrator\AppData\Roaming\SCP Secret Laboratory\PluginAPI\plugins\7777\dependencies\Exiled.API.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Exiled.Events"> | ||
<HintPath>C:\Users\Administrator\AppData\Roaming\EXILED\Plugins\Exiled.Events.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Mirror"> | ||
<HintPath>..\..\..\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Mirror.dll</HintPath> | ||
</Reference> | ||
<Reference Include="Newtonsoft.Json, Version=13.0.1.0, Culture=neutral, PublicKeyToken=30ad4fe6b2a6aeed, processorArchitecture=MSIL"> | ||
<SpecificVersion>False</SpecificVersion> | ||
<HintPath>..\..\..\Game\sister30days_Data\Managed\Newtonsoft.Json.dll</HintPath> | ||
</Reference> | ||
<Reference Include="PluginAPI"> | ||
<HintPath>..\..\..\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\PluginAPI.dll</HintPath> | ||
</Reference> | ||
<Reference Include="SCPSLAudioApi"> | ||
<HintPath>C:\Users\Administrator\Desktop\SCPSLAudioApi.dll</HintPath> | ||
</Reference> | ||
<Reference Include="System" /> | ||
<Reference Include="System.Core" /> | ||
<Reference Include="System.Xml.Linq" /> | ||
<Reference Include="System.Data.DataSetExtensions" /> | ||
<Reference Include="Microsoft.CSharp" /> | ||
<Reference Include="System.Data" /> | ||
<Reference Include="System.Net.Http" /> | ||
<Reference Include="System.Xml" /> | ||
<Reference Include="UnityEngine"> | ||
<HintPath>..\..\..\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.dll</HintPath> | ||
</Reference> | ||
<Reference Include="UnityEngine.CoreModule"> | ||
<HintPath>..\..\..\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.CoreModule.dll</HintPath> | ||
</Reference> | ||
<Reference Include="UnityEngine.PhysicsModule"> | ||
<HintPath>..\..\..\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.PhysicsModule.dll</HintPath> | ||
</Reference> | ||
</ItemGroup> | ||
<ItemGroup> | ||
<Compile Include="MusicAPI\FakeConnection.cs" /> | ||
<Compile Include="MusicAPI\PlayMusic.cs" /> | ||
<Compile Include="MusicAPI\WarppedAudio.cs" /> | ||
<Compile Include="Config.cs" /> | ||
<Compile Include="EventHandlers.cs" /> | ||
<Compile Include="Plugin.cs" /> | ||
<Compile Include="Properties\AssemblyInfo.cs" /> | ||
</ItemGroup> | ||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" /> | ||
</Project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
using Mirror; | ||
using System; | ||
|
||
namespace MVPMusicBox.MusicAPI | ||
{ | ||
internal class FakeConnection : NetworkConnectionToClient | ||
{ | ||
public FakeConnection(int networkConnectionId) : base(networkConnectionId) | ||
{ | ||
|
||
} | ||
|
||
public override string address => "localhost"; | ||
|
||
public override void Send(ArraySegment<byte> segment, int channelId = 0) | ||
{ | ||
|
||
} | ||
|
||
public override void Disconnect() | ||
{ | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using Exiled.API.Features; | ||
using Mirror; | ||
using PlayerRoles; | ||
using SCPSLAudioApi.AudioCore; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using VoiceChat; | ||
|
||
namespace MVPMusicBox.MusicAPI | ||
{ | ||
public static class PlayMusic | ||
{ | ||
public static List<WarppedAudio> audios = new List<WarppedAudio>(); | ||
public static AudioPlayerBase GlobalPlayMusic(string Path,string musicname,string Name = "Unknown") | ||
{ | ||
GameObject player1 = Object.Instantiate(NetworkManager.singleton.playerPrefab); | ||
int networkConnectionId = new System.Random().Next(250, 301); | ||
NetworkServer.AddPlayerForConnection(new FakeConnection(networkConnectionId), player1); | ||
ReferenceHub component = player1.GetComponent<ReferenceHub>(); | ||
Player player = Player.Get(component); | ||
player.DisplayNickname = Name; | ||
AudioPlayerBase audioPlayerBase = AudioPlayerBase.Get(component); | ||
string str = Path + "\\" + musicname + ".ogg"; | ||
audioPlayerBase.Enqueue(str, -1); | ||
audioPlayerBase.LogDebug = false; | ||
audioPlayerBase.Volume = 50; | ||
audioPlayerBase.BroadcastChannel = VoiceChatChannel.Intercom; | ||
audioPlayerBase.Loop = false; | ||
audioPlayerBase.Play(-1); | ||
component.roleManager.InitializeNewRole(RoleTypeId.Overwatch, RoleChangeReason.RemoteAdmin); | ||
audios.Add(new WarppedAudio() | ||
{ | ||
Player = audioPlayerBase, | ||
Music = musicname, | ||
Verfiy = $"{musicname}-{networkConnectionId}@server" | ||
}); | ||
return audioPlayerBase; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using SCPSLAudioApi.AudioCore; | ||
|
||
namespace MVPMusicBox.MusicAPI | ||
{ | ||
public class WarppedAudio | ||
{ | ||
public AudioPlayerBase Player { get; set; } | ||
public string Music { get; set; } | ||
public string Verfiy { get; set; } | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
using Exiled.API.Features; | ||
|
||
namespace MVPMusicBox | ||
{ | ||
public class Plugin : Plugin<Config> | ||
{ | ||
public override string Author { get; } = "萌新社区服务器"; | ||
public override string Name { get; } = "MVPMusicBox"; | ||
public override void OnEnabled() | ||
{ | ||
Log.Info("加载MVP音乐盒插件! By 萌新社区服务器"); | ||
EventHandlers.MVPMusic.RegMusic(); | ||
base.OnEnabled(); | ||
} | ||
public override void OnDisabled() | ||
{ | ||
EventHandlers.MVPMusic.UnRegMusic(); | ||
base.OnDisabled(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
using System.Reflection; | ||
using System.Runtime.CompilerServices; | ||
using System.Runtime.InteropServices; | ||
|
||
// 有关程序集的一般信息由以下 | ||
// 控制。更改这些特性值可修改 | ||
// 与程序集关联的信息。 | ||
[assembly: AssemblyTitle("MVPMusicBox")] | ||
[assembly: AssemblyDescription("")] | ||
[assembly: AssemblyConfiguration("")] | ||
[assembly: AssemblyCompany("萌新社区服务器")] | ||
[assembly: AssemblyProduct("MVPMusicBox")] | ||
[assembly: AssemblyCopyright("©萌新社区服务器 2025")] | ||
[assembly: AssemblyTrademark("")] | ||
[assembly: AssemblyCulture("")] | ||
|
||
// 将 ComVisible 设置为 false 会使此程序集中的类型 | ||
//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 | ||
//请将此类型的 ComVisible 特性设置为 true。 | ||
[assembly: ComVisible(false)] | ||
|
||
// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID | ||
[assembly: Guid("120e5b85-75f0-4d97-91a6-203af884baac")] | ||
|
||
// 程序集的版本信息由下列四个值组成: | ||
// | ||
// 主版本 | ||
// 次版本 | ||
// 生成号 | ||
// 修订号 | ||
// | ||
[assembly: AssemblyVersion("1.0.0.0")] | ||
[assembly: AssemblyFileVersion("1.0.0.0")] |