From 11cdf8fd8d96bdcf10022a037e07562569a5d297 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B2=E8=92=82=E5=A4=AB?= Date: Tue, 7 Jan 2025 21:36:29 +0800 Subject: [PATCH] version 1.0.4 Add NWAPI-Version[NoMusic] --- UNGOC-nw/Config.cs | 66 +++++++++++++ UNGOC-nw/EventHandlers.cs | 97 ++++++++++++++++++++ UNGOC-nw/Plugin.cs | 21 +++++ UNGOC-nw/Properties/AssemblyInfo.cs | 33 +++++++ UNGOC-nw/SteveAPI/Cassie.cs | 23 +++++ UNGOC-nw/SteveAPI/Interfaces/IPool.cs | 8 ++ UNGOC-nw/SteveAPI/Pools/StringBuilderPool.cs | 18 ++++ UNGOC-nw/UNGOC_NW.csproj | 84 +++++++++++++++++ UNGOC.sln | 31 +++++++ UNGOC/Config.cs | 65 +++++++++++++ UNGOC/EventHandlers.cs | 91 ++++++++++++++++++ UNGOC/Plugin.cs | 26 ++++++ UNGOC/Properties/AssemblyInfo.cs | 33 +++++++ UNGOC/SteveAPI/Dummy.cs | 79 ++++++++++++++++ UNGOC/Translation.cs | 20 ++++ UNGOC/UNGOC.csproj | 89 ++++++++++++++++++ 16 files changed, 784 insertions(+) create mode 100644 UNGOC-nw/Config.cs create mode 100644 UNGOC-nw/EventHandlers.cs create mode 100644 UNGOC-nw/Plugin.cs create mode 100644 UNGOC-nw/Properties/AssemblyInfo.cs create mode 100644 UNGOC-nw/SteveAPI/Cassie.cs create mode 100644 UNGOC-nw/SteveAPI/Interfaces/IPool.cs create mode 100644 UNGOC-nw/SteveAPI/Pools/StringBuilderPool.cs create mode 100644 UNGOC-nw/UNGOC_NW.csproj create mode 100644 UNGOC.sln create mode 100644 UNGOC/Config.cs create mode 100644 UNGOC/EventHandlers.cs create mode 100644 UNGOC/Plugin.cs create mode 100644 UNGOC/Properties/AssemblyInfo.cs create mode 100644 UNGOC/SteveAPI/Dummy.cs create mode 100644 UNGOC/Translation.cs create mode 100644 UNGOC/UNGOC.csproj diff --git a/UNGOC-nw/Config.cs b/UNGOC-nw/Config.cs new file mode 100644 index 0000000..422506d --- /dev/null +++ b/UNGOC-nw/Config.cs @@ -0,0 +1,66 @@ +using PlayerRoles; +using System.Collections.Generic; +using System.ComponentModel; + +namespace UNGOC_NW +{ + public class Config + { + [Description("启动Debug / Enable Debug")] + public bool Debug { get; set; } = false; + [Description("如果刷新九尾狐,第几次将刷新UNGOC(如果为0则跳过) / If Respawn Ntf , What times will spawn UNGOC? (If 0 , Skip)")] + public ushort SpawnTimes { get; set; } = 1; + + [Description("如果刷新UNGOC,启动广播/If Respawn UNGOC , Enable Announcement")] + public bool EnableAnnouncement { get; set; } = true; + [Description("如果刷新UNGOC,启动全图播报Broadcase? /If Respawn UNGOC , Enable Map Broadcast")] + public bool EnableBroadcast { get; set; } = true; + [Description("UNGOC指挥官物品 / UNGOC Captain Item List")] + public List RespawnItems_Captain { get; set; } = new List() + { + ItemType.GunFRMG0, + ItemType.ArmorHeavy, + ItemType.Adrenaline, + ItemType.Medkit, + ItemType.GrenadeHE, + ItemType.KeycardMTFCaptain, + ItemType.Radio + }; + [Description("UNGOC列兵物品 / UNGOC Private Personnel Item List")] + public List RespawnItems_Private { get; set; } = new List() + { + ItemType.GunE11SR, + ItemType.ArmorCombat, + ItemType.Adrenaline, + ItemType.Medkit, + ItemType.KeycardMTFOperative, + ItemType.Radio + }; + [Description("UNGOC列兵弹药类型 / UNGOC Private Personnel Ammo Type")] + public ItemType RespawnAmmo_Private { get; set; } = ItemType.Ammo556x45; + [Description("UNGOC列兵弹药数量 / UNGOC Private Personnel Ammos")] + public ushort RespawnAmmos_Private { get; set; } = 60; + [Description("UNGOC指挥官弹药类型 / UNGOC Captain Personnel Ammo Type")] + public ItemType RespawnAmmo_Captain { get; set; } = ItemType.Ammo556x45; + [Description("UNGOC指挥官弹药数量 / UNGOC Private Personnel Ammos")] + public ushort RespawnAmmos_Captain { get; set; } = 100; + [Description("UNGOC指挥官启用SCP1853效果 / Enable UNGOC Captain SCP1853 Effect")] + public bool UNGOCCaptain_SCP1853Effect { get; set; } = true; + + [Description("UNGOC指挥官角色类型 / UNGOC Captain Role")] + public RoleTypeId UNGOCCaptain_Role { get; set; } = RoleTypeId.NtfSergeant; + [Description("UNGOC列兵角色类型 / UNGOC Private Role")] + public RoleTypeId UNGOCPrivate_Role { get; set; } = RoleTypeId.NtfSpecialist; + [Description("如果刷新UNGOC,则播报CASSIE广播文本 / If Respawn UNGOC , Send CASSIE Announcement text")] + public string Announcement { get; set; } = "Attention all site Foundation personnel . U N G O C personnel into the facility gate B . G O C personnel will help NINETAILEDFOX containment all SCPSubjects"; + + [Description("如果刷新UNGOC,则播报CASSIE广播本地化文本(语言文本) / If Respawn UNGOC , Send CASSIE Announcement Translation")] + public string Announcement_Translation { get; set; } = "所有设施基金会人员注意UNGOC人员已进入设施B大门,GOC人员将协助九尾狐收容所有SCP项目。"; + [Description("如果刷新UNGOC,则全图播报文本 / If Respawn UNGOC , Send Map Broadcast text")] + public string Broadcast { get; set; } = "[C.A.S.S.I.E.] 全球超自然联盟已进入设施协助基金会收容异常,请所有非战斗人员请撤离设施!"; + [Description("UNGOC指挥官信息介绍 / UNGOC Captain Role Info")] + public string UNGOCCaptain_Info { get; set; } = "你是 \nUNGOC - 指挥官\n与基金会合作\n------清除设施威胁------"; + [Description("UNGOC列兵信息介绍 / UNGOC Private Role Info")] + public string UNGOCPrivate_Info { get; set; } = "你是 \nUNGOC - 作战专家\n与基金会合作\n------清除设施威胁------"; + } +} diff --git a/UNGOC-nw/EventHandlers.cs b/UNGOC-nw/EventHandlers.cs new file mode 100644 index 0000000..9b0f295 --- /dev/null +++ b/UNGOC-nw/EventHandlers.cs @@ -0,0 +1,97 @@ +using CustomPlayerEffects; +using InventorySystem; +using MEC; +using PluginAPI.Core; +using PluginAPI.Core.Attributes; +using PluginAPI.Events; +using System.Collections.Generic; + +namespace UNGOC_NW +{ + internal class EventHandlers + { + public static List UNGOC_C = new List(); + [PluginEvent(PluginAPI.Enums.ServerEventType.RoundStart)] + public void OnRoundStart() + { + Respawning.WaveManager.OnWaveSpawned += OnTeamRespawning; + if (Plugin.Config.Debug) + Log.Debug("Round Start!"); + SpawnTimes = 0; + UNGOC_C.Clear(); + } + public ushort SpawnTimes = 0; + public IEnumerator RespawnTeam(List Players) + { + if (Plugin.Config.Debug) + Log.Debug(" 刷新UNGOC! / Respawn UNGOC!"); + if (Plugin.Config.EnableBroadcast) + Map.Broadcast(7, Plugin.Config.Broadcast); + if (Plugin.Config.EnableAnnouncement) + { + Cassie.Clear(); + SteveAPI.Cassie.MessageTranslated(Plugin.Config.Announcement, Plugin.Config.Announcement_Translation); + } + yield return Timing.WaitForSeconds(0.5f); + foreach (Player player in Players) + { + if (UNGOC_C.Count < 1) + { + UNGOC_TeamRespawn.PlayerSpawn_GOCC(player); + } + if (!UNGOC_C.Contains(player)) + { + UNGOC_TeamRespawn.PlayerSpawn_GOCP(player); + } + } + UNGOC_C.Clear(); + } + + private void OnTeamRespawning(Respawning.Waves.SpawnableWaveBase arg1, List arg2) + { + if (Plugin.Config.Debug) + Log.Debug("Respawn Team!"); + if (arg1.TargetFaction != PlayerRoles.Faction.FoundationStaff) + return; + SpawnTimes++; + if (SpawnTimes == Plugin.Config.SpawnTimes) + { + var PlayerList = new List(); + foreach(ReferenceHub hub in arg2) + { + PlayerList.Add(Player.Get(hub)); + } + Timing.RunCoroutine(RespawnTeam(PlayerList)); + } + } + + private class UNGOC_TeamRespawn + { + public static void PlayerSpawn_GOCP(Player player) + { + player.SetRole(Plugin.Config.UNGOCPrivate_Role); + player.ClearInventory(); + foreach (ItemType item in Plugin.Config.RespawnItems_Private) + { + player.ReferenceHub.inventory.ServerAddItem(item, InventorySystem.Items.ItemAddReason.AdminCommand); + } + player.AddAmmo(Plugin.Config.RespawnAmmo_Private, Plugin.Config.RespawnAmmos_Private); + player.SendBroadcast(Plugin.Config.UNGOCPrivate_Info,5); + } + public static void PlayerSpawn_GOCC(Player player) + { + UNGOC_C.Add(player); + player.SetRole(Plugin.Config.UNGOCCaptain_Role); + player.ClearInventory(); + if(Plugin.Config.UNGOCCaptain_SCP1853Effect) + player.EffectsManager.EnableEffect(); + foreach(ItemType item in Plugin.Config.RespawnItems_Captain) + { + player.ReferenceHub.inventory.ServerAddItem(item,InventorySystem.Items.ItemAddReason.AdminCommand); + } + player.AddAmmo(Plugin.Config.RespawnAmmo_Captain, Plugin.Config.RespawnAmmos_Captain); + player.SendBroadcast(Plugin.Config.UNGOCCaptain_Info, 5); + } + } + } +} diff --git a/UNGOC-nw/Plugin.cs b/UNGOC-nw/Plugin.cs new file mode 100644 index 0000000..8314675 --- /dev/null +++ b/UNGOC-nw/Plugin.cs @@ -0,0 +1,21 @@ +using PluginAPI.Core; +using PluginAPI.Core.Attributes; +using PluginAPI.Events; + +namespace UNGOC_NW +{ + public class Plugin + { + [PluginConfig] + public static Config Config; + private static EventHandlers Handlers { get; set; } = new EventHandlers(); + [PluginEntryPoint("UNGOC-NWAPI","1.0.4","SCP:SL UNGOC Plugin","史蒂夫")] + internal void OnEnabled() + { + Log.Info("成功加载UNGOC插件 / Enable Plugin \"UNGOC\" By 史蒂夫"); + Log.Info("如果你在某些购物平台购买到这个插件,请立刻退款并投诉!"); + Log.Info("插件作者: 萌新社区服务器 & 史蒂夫 ,GitHub仓库:https://github.com/MengXinSheQu/UNGOC"); + EventManager.RegisterEvents(Handlers); + } + } +} diff --git a/UNGOC-nw/Properties/AssemblyInfo.cs b/UNGOC-nw/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..fb7be29 --- /dev/null +++ b/UNGOC-nw/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("UNGOC-NWAPI")] +[assembly: AssemblyDescription("全球超自然联盟[UNGOC]")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("微软中国")] +[assembly: AssemblyProduct("UNGOC-NWAPI")] +[assembly: AssemblyCopyright("萌新社区服务器 & 史蒂夫 ©2024")] +[assembly: AssemblyTrademark("萌新社区服务器")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("19d00bfa-ffb8-46f2-9e04-099e55599c92")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +[assembly: AssemblyVersion("1.0.1.3")] +[assembly: AssemblyFileVersion("1.0.4.4")] diff --git a/UNGOC-nw/SteveAPI/Cassie.cs b/UNGOC-nw/SteveAPI/Cassie.cs new file mode 100644 index 0000000..79a18bc --- /dev/null +++ b/UNGOC-nw/SteveAPI/Cassie.cs @@ -0,0 +1,23 @@ +using Respawning; +using SteveAPI.Pools; +using System.Text; + +namespace SteveAPI +{ + public static class Cassie + { + public static void MessageTranslated(string message, string translation, bool isHeld = false, bool isNoisy = true, bool isSubtitles = true) + { + StringBuilder stringBuilder = StringBuilderPool.Pool.Get(); + string[] array = message.Split('\n'); + string[] array2 = translation.Split('\n'); + for (int i = 0; i < array.Length; i++) + { + stringBuilder.Append(array2[i].Replace(' ', '\u2005') + " " + array[i] + " "); + } + RespawnEffectsController.PlayCassieAnnouncement(stringBuilder.ToString(), isHeld, isNoisy, isSubtitles); + StringBuilderPool.Pool.Return(stringBuilder); + } + public static void Clear() => RespawnEffectsController.ClearQueue(); + } +} diff --git a/UNGOC-nw/SteveAPI/Interfaces/IPool.cs b/UNGOC-nw/SteveAPI/Interfaces/IPool.cs new file mode 100644 index 0000000..d2efc9f --- /dev/null +++ b/UNGOC-nw/SteveAPI/Interfaces/IPool.cs @@ -0,0 +1,8 @@ +namespace SteveAPI.Interfaces +{ + internal interface IPool + { + T Get(); + void Return(T obj); + } +} diff --git a/UNGOC-nw/SteveAPI/Pools/StringBuilderPool.cs b/UNGOC-nw/SteveAPI/Pools/StringBuilderPool.cs new file mode 100644 index 0000000..06e5cbe --- /dev/null +++ b/UNGOC-nw/SteveAPI/Pools/StringBuilderPool.cs @@ -0,0 +1,18 @@ +using System.Text; +using SteveAPI.Interfaces; + +namespace SteveAPI.Pools +{ + internal class StringBuilderPool : IPool + { + public static StringBuilderPool Pool { get; } = new StringBuilderPool(); + public StringBuilder Get() + { + return NorthwoodLib.Pools.StringBuilderPool.Shared.Rent(); + } + public void Return(StringBuilder obj) + { + NorthwoodLib.Pools.StringBuilderPool.Shared.Return(obj); + } + } +} diff --git a/UNGOC-nw/UNGOC_NW.csproj b/UNGOC-nw/UNGOC_NW.csproj new file mode 100644 index 0000000..fb7b36c --- /dev/null +++ b/UNGOC-nw/UNGOC_NW.csproj @@ -0,0 +1,84 @@ + + + + + Debug + AnyCPU + {A7ADA447-7248-43C6-810F-4CD1C8033D52} + Library + Properties + UNGOC_NW + UNGOC-NW + v4.8 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + x64 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Assembly-CSharp.dll + + + ..\..\..\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Assembly-CSharp-firstpass.dll + + + ..\..\..\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\CommandSystem.Core.dll + + + ..\..\..\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Mirror.dll + + + ..\..\..\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\NorthwoodLib.dll + + + ..\..\..\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\PluginAPI.dll + + + ..\..\..\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Pooling.dll + + + + + + + + + + + ..\..\..\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.dll + + + ..\..\..\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.CoreModule.dll + + + ..\..\..\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.PhysicsModule.dll + + + + + + + + + + + + + \ No newline at end of file diff --git a/UNGOC.sln b/UNGOC.sln new file mode 100644 index 0000000..d871471 --- /dev/null +++ b/UNGOC.sln @@ -0,0 +1,31 @@ + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio Version 17 +VisualStudioVersion = 17.11.35222.181 +MinimumVisualStudioVersion = 10.0.40219.1 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UNGOC", "UNGOC\UNGOC.csproj", "{19D00BFA-FFB8-46F2-9E04-099E55599C92}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "UNGOC_NW", "UNGOC-nw\UNGOC_NW.csproj", "{A7ADA447-7248-43C6-810F-4CD1C8033D52}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {19D00BFA-FFB8-46F2-9E04-099E55599C92}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {19D00BFA-FFB8-46F2-9E04-099E55599C92}.Debug|Any CPU.Build.0 = Debug|Any CPU + {19D00BFA-FFB8-46F2-9E04-099E55599C92}.Release|Any CPU.ActiveCfg = Release|Any CPU + {19D00BFA-FFB8-46F2-9E04-099E55599C92}.Release|Any CPU.Build.0 = Release|Any CPU + {A7ADA447-7248-43C6-810F-4CD1C8033D52}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {A7ADA447-7248-43C6-810F-4CD1C8033D52}.Debug|Any CPU.Build.0 = Debug|Any CPU + {A7ADA447-7248-43C6-810F-4CD1C8033D52}.Release|Any CPU.ActiveCfg = Release|Any CPU + {A7ADA447-7248-43C6-810F-4CD1C8033D52}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection + GlobalSection(ExtensibilityGlobals) = postSolution + SolutionGuid = {50BDD41C-D6A4-47F1-94E1-BA1AFC0D9C3A} + EndGlobalSection +EndGlobal diff --git a/UNGOC/Config.cs b/UNGOC/Config.cs new file mode 100644 index 0000000..b1c496c --- /dev/null +++ b/UNGOC/Config.cs @@ -0,0 +1,65 @@ +using Exiled.API.Enums; +using Exiled.API.Features; +using Exiled.API.Interfaces; +using PlayerRoles; +using System.Collections.Generic; +using System.ComponentModel; + +namespace UNGOC +{ + public class Config : IConfig + { + [Description("启动UNGOC插件 / Enable UNGOC Plugin")] + public bool IsEnabled { get; set; } = true; + + [Description("启动Debug / Enable Debug")] + public bool Debug { get; set; } = false; + + [Description("如果刷新九尾狐,第几次将刷新UNGOC(如果为0则跳过) / If Respawn Ntf , What times will spawn UNGOC? (If 0 , Skip)")] + public ushort SpawnTimes { get; set; } = 1; + + [Description("如果刷新UNGOC,启动广播/If Respawn UNGOC , Enable Announcement")] + public bool EnableAnnouncement { get; set; } = true; + [Description("如果刷新UNGOC,启动全图播报Broadcase? /If Respawn UNGOC , Enable Map Broadcast")] + public bool EnableBroadcast { get; set; } = true; + [Description("UNGOC列兵物品 / UNGOC Private Personnel Item List")] + public List RespawnItems_Private { get; set; } = new List() + { + ItemType.GunE11SR, + ItemType.ArmorCombat, + ItemType.Adrenaline, + ItemType.Medkit, + ItemType.KeycardMTFOperative, + ItemType.Radio + }; + [Description("UNGOC指挥官物品 / UNGOC Captain Item List")] + public List RespawnItems_Captain { get; set; } = new List() + { + ItemType.GunFRMG0, + ItemType.ArmorHeavy, + ItemType.Adrenaline, + ItemType.Medkit, + ItemType.GrenadeHE, + ItemType.KeycardMTFCaptain, + ItemType.Radio + }; + [Description("UNGOC列兵弹药类型 / UNGOC Private Personnel Ammo Type")] + public AmmoType RespawnAmmo_Private { get; set; } = AmmoType.Nato556; + [Description("UNGOC列兵弹药数量 / UNGOC Private Personnel Ammos")] + public ushort RespawnAmmos_Private { get; set; } = 60; + [Description("UNGOC指挥官弹药类型 / UNGOC Captain Personnel Ammo Type")] + public AmmoType RespawnAmmo_Captain { get; set; } = AmmoType.Nato556; + [Description("UNGOC指挥官弹药数量 / UNGOC Private Personnel Ammos")] + public ushort RespawnAmmos_Captain { get; set; } = 100; + [Description("UNGOC指挥官启用SCP1853效果 / Enable UNGOC Captain SCP1853 Effect")] + public bool UNGOCCaptain_SCP1853Effect { get; set; } = true; + [Description("UNGOC指挥官角色类型 / UNGOC Captain Role")] + public RoleTypeId UNGOCCaptain_Role { get; set; } = RoleTypeId.NtfCaptain; + [Description("UNGOC列兵角色类型 / UNGOC Private Role")] + public RoleTypeId UNGOCPrivate_Role { get; set; } = RoleTypeId.NtfSpecialist; + [Description("启动UNGOC刷新音乐 / Enable UNGOC Respawn Music")] + public bool EnableMusic { get; set; } = true; + [Description("UNGOC刷新音乐路径 / UNGOC Respawn Music Path")] + public string MusicPath { get; set; } = Paths.Exiled + "\\UNGOC.ogg"; + } +} diff --git a/UNGOC/EventHandlers.cs b/UNGOC/EventHandlers.cs new file mode 100644 index 0000000..0d285a8 --- /dev/null +++ b/UNGOC/EventHandlers.cs @@ -0,0 +1,91 @@ +using CustomPlayerEffects; +using Exiled.API.Features; +using Exiled.Events.EventArgs.Server; +using System.Collections.Generic; +using UNGOC.SteveAPI; + +namespace UNGOC +{ + internal class EventHandlers + { + internal static List UNGOC_C = new List(); + public static void RegEvent() + { + Exiled.Events.Handlers.Server.RoundStarted += OnRoundStart; + Exiled.Events.Handlers.Server.RespawningTeam += OnRespawningTeam; + } + public static void UnRegEvent() + { + Exiled.Events.Handlers.Server.RoundStarted -= OnRoundStart; + Exiled.Events.Handlers.Server.RespawningTeam -= OnRespawningTeam; + } + private static void OnRoundStart() + { + Dummy.Destory(); + SpawnTimes = 0; + UNGOC_C.Clear(); + } + private static ushort SpawnTimes = 0; + private static void OnRespawningTeam(RespawningTeamEventArgs ev) + { + if (ev.NextKnownTeam != PlayerRoles.Faction.FoundationStaff) + return; + SpawnTimes++; + if(SpawnTimes == Plugin.UNGOCPlugin.Config.SpawnTimes) + { + if (Plugin.UNGOCPlugin.Config.Debug) + Log.Debug(" 刷新UNGOC! / Respawn UNGOC!"); + if (Plugin.UNGOCPlugin.Config.EnableBroadcast) + Map.Broadcast(7, Plugin.UNGOCPlugin.Translation.Broadcast); + if (Plugin.UNGOCPlugin.Config.EnableMusic) + Dummy.PlaySound(Plugin.UNGOCPlugin.Config.MusicPath); + if (Plugin.UNGOCPlugin.Config.EnableAnnouncement) + { + Cassie.Clear(); + Cassie.MessageTranslated(Plugin.UNGOCPlugin.Translation.Announcement, Plugin.UNGOCPlugin.Translation.Announcement_Translation); + } + foreach (Player player in ev.Players) + { + if(UNGOC_C.Count < 1) + { + UNGOC_TeamRespawn.PlayerSpawn_GOCC(player); + } + if(!UNGOC_C.Contains(player)) + { + UNGOC_TeamRespawn.PlayerSpawn_GOCP(player); + } + } + UNGOC_C.Clear(); + ev.IsAllowed = false; + } + } + public class UNGOC_TeamRespawn + { + public static void PlayerSpawn_GOCP(Player player) + { + player.Role.Set(Plugin.UNGOCPlugin.Config.UNGOCPrivate_Role); + player.ClearInventory(); + foreach (ItemType item in Plugin.UNGOCPlugin.Config.RespawnItems_Private) + { + player.AddItem(item); + } + player.AddAmmo(Plugin.UNGOCPlugin.Config.RespawnAmmo_Private, Plugin.UNGOCPlugin.Config.RespawnAmmos_Private); + player.Broadcast(5, Plugin.UNGOCPlugin.Translation.UNGOCPrivate_Info); + } + public static void PlayerSpawn_GOCC(Player player) + { + UNGOC_C.Add(player); + player.Role.Set(Plugin.UNGOCPlugin.Config.UNGOCCaptain_Role); + player.ClearInventory(); + if(Plugin.UNGOCPlugin.Config.UNGOCCaptain_SCP1853Effect) + player.EnableEffect(); + foreach(ItemType item in Plugin.UNGOCPlugin.Config.RespawnItems_Captain) + { + player.AddItem(item); + } + player.AddAmmo(Plugin.UNGOCPlugin.Config.RespawnAmmo_Captain, Plugin.UNGOCPlugin.Config.RespawnAmmos_Captain); + player.Broadcast(5, Plugin.UNGOCPlugin.Translation.UNGOCCaptain_Info); + } + } + } +} diff --git a/UNGOC/Plugin.cs b/UNGOC/Plugin.cs new file mode 100644 index 0000000..ed26230 --- /dev/null +++ b/UNGOC/Plugin.cs @@ -0,0 +1,26 @@ +using Exiled.API.Features; +using System; + +namespace UNGOC +{ + public class Plugin : Plugin + { + internal static Plugin UNGOCPlugin; + public override string Author { get; } = "萌新社区服务器 & 史蒂夫"; + public override string Name { get; } = "UNGOC插件 / UNGOC Plugin"; + public override Version Version { get; } = new Version(1,0,0,4); + public override void OnEnabled() + { + Log.Info("成功加载UNGOC插件 / Enable Plugin \"UNGOC\" By 史蒂夫"); + Log.Info("如果你在某些购物平台购买到这个插件,请立刻退款并投诉!"); + Log.Info("插件作者: 萌新社区服务器 & 史蒂夫 ,GitHub仓库:https://github.com/MengXinSheQu/UNGOC"); + EventHandlers.RegEvent(); + base.OnEnabled(); + } + public override void OnDisabled() + { + EventHandlers.UnRegEvent(); + base.OnDisabled(); + } + } +} diff --git a/UNGOC/Properties/AssemblyInfo.cs b/UNGOC/Properties/AssemblyInfo.cs new file mode 100644 index 0000000..62483b1 --- /dev/null +++ b/UNGOC/Properties/AssemblyInfo.cs @@ -0,0 +1,33 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// 有关程序集的一般信息由以下 +// 控制。更改这些特性值可修改 +// 与程序集关联的信息。 +[assembly: AssemblyTitle("UNGOC")] +[assembly: AssemblyDescription("全球超自然联盟[UNGOC]")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("微软中国")] +[assembly: AssemblyProduct("UNGOC")] +[assembly: AssemblyCopyright("萌新社区服务器 & 史蒂夫 ©2024")] +[assembly: AssemblyTrademark("萌新社区服务器")] +[assembly: AssemblyCulture("")] + +// 将 ComVisible 设置为 false 会使此程序集中的类型 +//对 COM 组件不可见。如果需要从 COM 访问此程序集中的类型 +//请将此类型的 ComVisible 特性设置为 true。 +[assembly: ComVisible(false)] + +// 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID +[assembly: Guid("19d00bfa-ffb8-46f2-9e04-099e55599c92")] + +// 程序集的版本信息由下列四个值组成: +// +// 主版本 +// 次版本 +// 生成号 +// 修订号 +// +[assembly: AssemblyVersion("1.0.0.4")] +[assembly: AssemblyFileVersion("1.0.4.4")] diff --git a/UNGOC/SteveAPI/Dummy.cs b/UNGOC/SteveAPI/Dummy.cs new file mode 100644 index 0000000..fb29234 --- /dev/null +++ b/UNGOC/SteveAPI/Dummy.cs @@ -0,0 +1,79 @@ +using Exiled.API.Features; +using SCPSLAudioApi.AudioCore; +using System; +using VoiceChat; +using UnityEngine; +using Mirror; +using Object = UnityEngine.Object; + +namespace UNGOC.SteveAPI +{ + internal class Dummy + { + private static ReferenceHub Bot; + public static void Destory() + { + if (Bot == null) + return; + AudioPlayerBase audioPlayerBase = AudioPlayerBase.Get(Bot); + if (audioPlayerBase.CurrentPlay != null) + { + + audioPlayerBase.Stoptrack(true); + audioPlayerBase.OnDestroy(); + } + try + { + NetworkServer.RemovePlayerForConnection(Player.Get(Bot).Connection, true); + } + catch + { + + } + } + public static AudioPlayerBase PlaySound(string Path) + { + if (Bot == null) + { + Add("C.A.S.S.I.E."); + } + ReferenceHub component = Bot; + AudioPlayerBase audioPlayerBase = AudioPlayerBase.Get(component); + audioPlayerBase.Enqueue(Path, -1); + audioPlayerBase.LogDebug = false; + audioPlayerBase.BroadcastChannel = VoiceChatChannel.Intercom; + audioPlayerBase.Volume = 50f; + audioPlayerBase.Loop = false; + audioPlayerBase.Play(0); + return audioPlayerBase; + } + public static void Add(string Name) + { + if (Bot != null) + return; + GameObject player1 = Object.Instantiate(NetworkManager.singleton.playerPrefab); + int networkConnectionId = 13422; + NetworkServer.AddPlayerForConnection(new FakeConnection(networkConnectionId), player1); + ReferenceHub component = player1.GetComponent(); + Player player = Player.Get(component); + player.DisplayNickname = Name; + Bot = component; + } + private class FakeConnection : NetworkConnectionToClient + { + public FakeConnection(int networkConnectionId) : base(networkConnectionId) + { + + } + public override string address => "localhost"; + public override void Send(ArraySegment segment, int channelId = 0) + { + + } + public override void Disconnect() + { + + } + } + } +} diff --git a/UNGOC/Translation.cs b/UNGOC/Translation.cs new file mode 100644 index 0000000..5392e7b --- /dev/null +++ b/UNGOC/Translation.cs @@ -0,0 +1,20 @@ +using Exiled.API.Interfaces; +using System.ComponentModel; + +namespace UNGOC +{ + public class Translation : ITranslation + { + [Description("如果刷新UNGOC,则播报CASSIE广播文本 / If Respawn UNGOC , Send CASSIE Announcement text")] + public string Announcement { get; set; } = "Attention all site Foundation personnel . U N G O C personnel into the facility gate B . G O C personnel will help NINETAILEDFOX containment all SCPSubjects"; + + [Description("如果刷新UNGOC,则播报CASSIE广播本地化文本(语言文本) / If Respawn UNGOC , Send CASSIE Announcement Translation")] + public string Announcement_Translation { get; set; } = "所有设施基金会人员注意UNGOC人员已进入设施B大门,GOC人员将协助九尾狐收容所有SCP项目。"; + [Description("如果刷新UNGOC,则全图播报文本 / If Respawn UNGOC , Send Map Broadcast text")] + public string Broadcast { get; set; } = "[C.A.S.S.I.E.] 全球超自然联盟已进入设施协助基金会收容异常,请所有非战斗人员请撤离设施!"; + [Description("UNGOC指挥官信息介绍 / UNGOC Captain Role Info")] + public string UNGOCCaptain_Info { get; set; } = "你是 \nUNGOC - 指挥官\n与基金会合作\n------清除设施威胁------"; + [Description("UNGOC列兵信息介绍 / UNGOC Private Role Info")] + public string UNGOCPrivate_Info { get; set; } = "你是 \nUNGOC - 作战专家\n与基金会合作\n------清除设施威胁------"; + } +} diff --git a/UNGOC/UNGOC.csproj b/UNGOC/UNGOC.csproj new file mode 100644 index 0000000..480905b --- /dev/null +++ b/UNGOC/UNGOC.csproj @@ -0,0 +1,89 @@ + + + + + Debug + AnyCPU + {19D00BFA-FFB8-46F2-9E04-099E55599C92} + Library + Properties + UNGOC + UNGOC + v4.8 + 512 + true + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + x64 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + + + + ..\..\..\..\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Assembly-CSharp.dll + + + ..\..\..\..\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Assembly-CSharp-firstpass.dll + + + ..\..\..\..\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\CommandSystem.Core.dll + + + False + C:\Users\Administrator\AppData\Roaming\SCP Secret Laboratory\PluginAPI\plugins\7777\dependencies\Exiled.API.dll + + + False + C:\Users\Administrator\AppData\Roaming\EXILED\Plugins\Exiled.Events.dll + + + ..\..\..\..\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\Mirror.dll + + + ..\..\..\..\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\PluginAPI.dll + + + C:\Users\Administrator\Desktop\SCPSLAudioApi.dll + + + + + + + + + + + ..\..\..\..\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.dll + + + ..\..\..\..\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.CoreModule.dll + + + ..\..\..\..\SteamLibrary\steamapps\common\SCP Secret Laboratory Dedicated Server\SCPSL_Data\Managed\UnityEngine.PhysicsModule.dll + + + + + + + + + + + + + \ No newline at end of file