Skip to content

Commit

Permalink
Plugin Code
Browse files Browse the repository at this point in the history
  • Loading branch information
Supper-Steve authored Dec 18, 2024
1 parent a4f75b9 commit ce2edcc
Show file tree
Hide file tree
Showing 7 changed files with 409 additions and 0 deletions.
25 changes: 25 additions & 0 deletions UNGOC.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@

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
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
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {50BDD41C-D6A4-47F1-94E1-BA1AFC0D9C3A}
EndGlobalSection
EndGlobal
69 changes: 69 additions & 0 deletions UNGOC/Config.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
using Exiled.API.Features;
using Exiled.API.Interfaces;
using PlayerRoles;
using System.Collections.Generic;
using System.ComponentModel;

namespace UNGOC
{
public sealed 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,则播报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; } = "所有设施基金会人员注意<split>UNGOC人员已进入设施B大门,GOC人员将协助九尾狐收容所有SCP项目。";

[Description("如果刷新UNGOC,启动全图播报Broadcase? /If Respawn UNGOC , Enable Map Broadcast")]
public bool EnableBroadcast { get; set; } = true;
[Description("如果刷新UNGOC,则全图播报文本 / If Respawn UNGOC , Send Map Broadcast text")]
public string Broadcast { get; set; } = "<size=65%>[<color=#00FFF6>C.A.S.S.I.E.</color>] 全球超自然联盟已进入设施协助基金会收容异常,请所有非战斗人员请撤离设施!</size>";
[Description("UNGOC指挥官物品 / UNGOC Captain Item List")]
public List<ItemType> RespawnItems_Captain { get; set; } = new List<ItemType>()
{
ItemType.GunFRMG0,
ItemType.ArmorHeavy,
ItemType.Adrenaline,
ItemType.Medkit,
ItemType.GrenadeHE,
ItemType.KeycardMTFCaptain,
ItemType.Radio
};
[Description("UNGOC指挥官启用SCP1853效果 / Enable UNGOC Captain SCP1853 Effect")]
public bool UNGOCCaptain_SCP1853Effect { get; set; } = true;
[Description("UNGOC列兵物品 / UNGOC Private Personnel Item List")]
public List<ItemType> RespawnItems_Private { get; set; } = new List<ItemType>()
{
ItemType.GunE11SR,
ItemType.ArmorCombat,
ItemType.Adrenaline,
ItemType.Medkit,
ItemType.KeycardMTFOperative,
ItemType.Radio
};
[Description("UNGOC指挥官信息介绍 / UNGOC Captain Role Info")]
public string UNGOCCaptain_Info { get; set; } = "<size=65%>你是 </size><size=100%><color=#00FFF6>\nUNGOC - 指挥官</color></size>\n<size=45%>与基金会合作\n------清除设施威胁------</size>";
[Description("UNGOC列兵信息介绍 / UNGOC Private Role Info")]
public string UNGOCPrivate_Info { get; set; } = "<size=65%>你是 </size><size=100%><color=#00FFF6>\nUNGOC - 作战专家</color></size>\n<size=45%>与基金会合作\n------清除设施威胁------</size>";
[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";
}
}
88 changes: 88 additions & 0 deletions UNGOC/EventHandlers.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
using CustomPlayerEffects;
using Exiled.API.Features;
using Exiled.Events.EventArgs.Server;
using Respawning;
using System.Collections.Generic;
using UNGOC.SteveAPI;

namespace UNGOC
{
internal class EventHandlers
{
private static List<Player> UNGOC_C = new List<Player>();
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.Clear();
SpawnTimes = 0;
UNGOC_C.Clear();
}
private static ushort SpawnTimes = 0;
private static void OnRespawningTeam(RespawningTeamEventArgs ev)
{
if (ev.NextKnownTeam != SpawnableTeamType.NineTailedFox)
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.Config.Broadcast);
if (Plugin.UNGOCPlugin.Config.EnableMusic)
Dummy.PlaySound(Plugin.UNGOCPlugin.Config.MusicPath);
if (Plugin.UNGOCPlugin.Config.EnableAnnouncement)
Cassie.MessageTranslated(Plugin.UNGOCPlugin.Config.Announcement, Plugin.UNGOCPlugin.Config.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;
ev.NextKnownTeam = SpawnableTeamType.None;
}
}
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.Broadcast(5, Plugin.UNGOCPlugin.Config.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<Scp1853>();
foreach(ItemType item in Plugin.UNGOCPlugin.Config.RespawnItems_Captain)
{
player.AddItem(item);
}
player.Broadcast(5, Plugin.UNGOCPlugin.Config.UNGOCCaptain_Info);
}
}
}
}
29 changes: 29 additions & 0 deletions UNGOC/Plugin.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
using Exiled.API.Features;
using System;

namespace UNGOC
{
public class Plugin : Plugin<Config>
{
/*
倒卖不会让你有什么好处,只会让你失去爹妈
*/
internal static Plugin UNGOCPlugin { get; } = new Plugin();
public override string Author { get; } = "萌新社区服务器 & 史蒂夫";
public override string Name { get; } = "UNGOC插件 / UNGOC Plugin";
public override Version Version { get; } = new Version(1,0,3,3);
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();
}
}
}
33 changes: 33 additions & 0 deletions UNGOC/Properties/AssemblyInfo.cs
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("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.1.3")]
[assembly: AssemblyFileVersion("1.0.4.4")]
79 changes: 79 additions & 0 deletions UNGOC/SteveAPI/Dummy.cs
Original file line number Diff line number Diff line change
@@ -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 Clear()
{
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<ReferenceHub>();
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<byte> segment, int channelId = 0)
{

}
public override void Disconnect()
{

}
}
}
}
Loading

0 comments on commit ce2edcc

Please sign in to comment.