diff --git a/HelpSense/HelpSense.csproj b/HelpSense/HelpSense.csproj index a80c15a..f9bad19 100644 --- a/HelpSense/HelpSense.csproj +++ b/HelpSense/HelpSense.csproj @@ -71,7 +71,7 @@ - + diff --git a/HelpSense/Helper/Chat/ChatHelper.cs b/HelpSense/Helper/Chat/ChatHelper.cs index 43c97db..7fe62e9 100644 --- a/HelpSense/Helper/Chat/ChatHelper.cs +++ b/HelpSense/Helper/Chat/ChatHelper.cs @@ -52,7 +52,7 @@ public static class ChatHelper { private static CoroutineHandle _coroutine; - private static readonly LinkedList MessageList= new(); + private static readonly LinkedList MessageList = new(); private static readonly Dictionary MessageSlot = new(); diff --git a/HelpSense/Helper/SCP/SCPHPChangeSystem.cs b/HelpSense/Helper/SCP/SCPHealthSystem.cs similarity index 79% rename from HelpSense/Helper/SCP/SCPHPChangeSystem.cs rename to HelpSense/Helper/SCP/SCPHealthSystem.cs index 8f9effd..3e557d8 100644 --- a/HelpSense/Helper/SCP/SCPHPChangeSystem.cs +++ b/HelpSense/Helper/SCP/SCPHealthSystem.cs @@ -3,9 +3,9 @@ namespace HelpSense.Helper.SCP { - public class SCPHPChangeSystem + public class SCPHealthSystem { - public static Dictionary healthDict = new Dictionary() + public static Dictionary HealthDict = new() { [RoleTypeId.Scp173] = Plugin.Instance.Config.SCPsHP[0], [RoleTypeId.Scp939] = Plugin.Instance.Config.SCPsHP[1], diff --git a/HelpSense/Helper/SCP/SCPHelper.cs b/HelpSense/Helper/SCP/SCPHelper.cs index 4f4f4fb..754db11 100644 --- a/HelpSense/Helper/SCP/SCPHelper.cs +++ b/HelpSense/Helper/SCP/SCPHelper.cs @@ -14,200 +14,19 @@ public class SCPHelper public Player Player; public string OldRoleName; public string OldRoleColor; - public SCPHelper(Player Player, string NewRoleName, string NewRoleColor, List Items) - { - this.Player = Player; - OldRoleName = Player.RoleName; - OldRoleColor = Player.RoleColor; - Player.RoleName = NewRoleName; - Player.RoleColor = NewRoleColor; - AddItems(Player, Items); - } - public SCPHelper(Player Player, string NewRoleName, string NewRoleColor) - { - this.Player = Player; - OldRoleName = Player.RoleName; - OldRoleColor = Player.RoleColor; - Player.RoleName = NewRoleName; - Player.RoleColor = NewRoleColor; - } - public SCPHelper(Player Player, string NewRoleName, string NewRoleColor, Vector3 Vector3) - { - this.Player = Player; - OldRoleName = Player.RoleName; - OldRoleColor = Player.RoleColor; - Player.RoleName = NewRoleName; - Player.RoleColor = NewRoleColor; - Player.Position = Vector3; - } - public SCPHelper(Player Player, RoleTypeId NewRole, string NewRoleName, string NewRoleColor, Vector3 Vector3) - { - this.Player = Player; - Player.SetRole(NewRole); - OldRoleName = Player.RoleName; - OldRoleColor = Player.RoleColor; - Player.RoleName = NewRoleName; - Player.RoleColor = NewRoleColor; - Player.Position = Vector3; - } - public SCPHelper(Player Player, RoleTypeId NewRole, float Health, string NewRoleName, string NewRoleColor) - { - this.Player = Player; - Player.SetRole(NewRole); - Player.Health = Health; - OldRoleName = Player.RoleName; - OldRoleColor = Player.RoleColor; - Player.RoleName = NewRoleName; - Player.RoleColor = NewRoleColor; - } - public SCPHelper(Player Player, RoleTypeId NewRole, float Health, string NewRoleName, string NewRoleColor, Vector3 Vector3) - { - this.Player = Player; - Player.SetRole(NewRole); - Player.Health = Health; - OldRoleName = Player.RoleName; - OldRoleColor = Player.RoleColor; - Player.RoleName = NewRoleName; - Player.RoleColor = NewRoleColor; - Player.Position = Vector3; - } - public SCPHelper(Player Player, RoleTypeId NewRole, string NewRoleName, string NewRoleColor) - { - this.Player = Player; - Player.SetRole(NewRole); - OldRoleName = Player.RoleName; - OldRoleColor = Player.RoleColor; - Player.RoleName = NewRoleName; - Player.RoleColor = NewRoleColor; - } - public SCPHelper(Player Player, RoleTypeId NewRole, string NewRoleName, string NewRoleColor, List Items) - { - this.Player = Player; - Player.SetRole(NewRole); - OldRoleName = Player.RoleName; - OldRoleColor = Player.RoleColor; - Player.RoleName = NewRoleName; - Player.RoleColor = NewRoleColor; - AddItems(Player, Items); - } - public SCPHelper(Player Player, string NewRoleName, string NewRoleColor, string Broadcast, ushort Time) - { - this.Player = Player; - OldRoleName = Player.RoleName; - OldRoleColor = Player.RoleColor; - Player.RoleName = NewRoleName; - Player.RoleColor = NewRoleColor; - Player.SendBroadcast(Broadcast, Time); - } - public SCPHelper(Player Player, string NewRoleName, string NewRoleColor, List Items, string Broadcast, ushort Time) - { - this.Player = Player; - OldRoleName = Player.RoleName; - OldRoleColor = Player.RoleColor; - Player.RoleName = NewRoleName; - Player.RoleColor = NewRoleColor; - AddItems(Player, Items); - Player.SendBroadcast(Broadcast, Time); - } - public SCPHelper(Player Player, RoleTypeId NewRole, string NewRoleName, string NewRoleColor, List Items, string Broadcast, ushort Time) - { - this.Player = Player; - Player.SetRole(NewRole); - OldRoleName = Player.RoleName; - OldRoleColor = Player.RoleColor; - Player.RoleName = NewRoleName; - Player.RoleColor = NewRoleColor; - AddItems(Player, Items); - Player.SendBroadcast(Broadcast, Time); - } - public SCPHelper(Player Player, float Health, string NewRoleName, string NewRoleColor, List Items) - { - this.Player = Player; - OldRoleName = Player.RoleName; - OldRoleColor = Player.RoleColor; - Player.RoleName = NewRoleName; - Player.RoleColor = NewRoleColor; - AddItems(Player, Items); - Player.Health = Health; - } - public SCPHelper(Player Player, float Health, string NewRoleName, string NewRoleColor) - { - this.Player = Player; - OldRoleName = Player.RoleName; - OldRoleColor = Player.RoleColor; - Player.RoleName = NewRoleName; - Player.RoleColor = NewRoleColor; - Player.Health = Health; - } - public SCPHelper(Player Player, float Health, RoleTypeId NewRole, string NewRoleName, string NewRoleColor, List Items) - { - this.Player = Player; - Player.SetRole(NewRole); - OldRoleName = Player.RoleName; - OldRoleColor = Player.RoleColor; - Player.RoleName = NewRoleName; - Player.RoleColor = NewRoleColor; - AddItems(Player, Items); - Player.Health = Health; - } - public SCPHelper(Player Player, float Health, string NewRoleName, string NewRoleColor, string Broadcast, ushort Time) - { - this.Player = Player; - OldRoleName = Player.RoleName; - OldRoleColor = Player.RoleColor; - Player.RoleName = NewRoleName; - Player.RoleColor = NewRoleColor; - Player.SendBroadcast(Broadcast, Time); - Player.Health = Health; - } - public SCPHelper(Player Player, float Health, string NewRoleName, string NewRoleColor, List Items, string Broadcast, ushort Time) - { - this.Player = Player; - OldRoleName = Player.RoleName; - OldRoleColor = Player.RoleColor; - Player.RoleName = NewRoleName; - Player.RoleColor = NewRoleColor; - AddItems(Player, Items); - Player.SendBroadcast(Broadcast, Time); - Player.Health = Health; - } - public SCPHelper(Player Player, float Health, RoleTypeId NewRole, string NewRoleName, string NewRoleColor, List Items, string Broadcast, ushort Time) - { - this.Player = Player; - Player.SetRole(NewRole); - OldRoleName = Player.RoleName; - OldRoleColor = Player.RoleColor; - Player.RoleName = NewRoleName; - Player.RoleColor = NewRoleColor; - AddItems(Player, Items); - Player.SendBroadcast(Broadcast, Time); - Player.Health = Health; - } - public SCPHelper(Player Player, float Health, RoleTypeId NewRole, string NewRoleName, string NewRoleColor, string Broadcast, ushort Time) + + public SCPHelper(Player player) { - this.Player = Player; - Player.SetRole(NewRole); + this.Player = player; OldRoleName = Player.RoleName; OldRoleColor = Player.RoleColor; - Player.RoleName = NewRoleName; - Player.RoleColor = NewRoleColor; - Player.SendBroadcast(Broadcast, Time); - Player.Health = Health; - } - - public void OnPlayerDead(Player Player, string cassie, string tcassie) - { - Player.RoleName = OldRoleName; - Player.RoleColor = OldRoleColor; - XHelper.MessageTranslated(cassie, tcassie); } - public void AddItems(Player Player, List Items) + public void OnPlayerDead(Player player, string cassieMessage, string translatedCassieMessage) { - foreach (ItemType Item in Items) - { - Player.AddItem(Item); - } + player.RoleName = OldRoleName; + player.RoleColor = OldRoleColor; + XHelper.MessageTranslated(cassieMessage, translatedCassieMessage); } } } diff --git a/HelpSense/Helper/SpecialRole/SpecialRoleHelper.cs b/HelpSense/Helper/SpecialRole/SpecialRoleHelper.cs index bccb234..44f2e96 100644 --- a/HelpSense/Helper/SpecialRole/SpecialRoleHelper.cs +++ b/HelpSense/Helper/SpecialRole/SpecialRoleHelper.cs @@ -1,39 +1,22 @@ using CustomPlayerEffects; -using HintServiceMeow.Core.Enum; -using HintServiceMeow.Core.Extension; -using HintServiceMeow.Core.Models.Hints; using HintServiceMeow.UI.Extension; using InventorySystem.Items.Firearms; using InventorySystem.Items.Firearms.Attachments; -using InventorySystem.Items.Test; using MEC; using PlayerRoles; using PluginAPI.Core; -using System; + using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; namespace HelpSense.Helper.SpecialRole { public static class SpecialRoleHelper { - public static IEnumerator SpecialRoleInfoHandle() + public static IEnumerator SCP703CoroutineMethod() { - int SCP703ItemTime = 0; - string SCP029SpecialIntroduction = Plugin.Instance.TranslateConfig.SCP029SpecialIntroduction; - string SCP703SpecialIntroduction = Plugin.Instance.TranslateConfig.SCP703SpecialIntroduction; - string SCP347SpecialIntroduction = Plugin.Instance.TranslateConfig.SCP347SpecialIntroduction; - string SCP1093SpecialIntroduction = Plugin.Instance.TranslateConfig.SCP1093SpecialIntroduction; - string SCP191SpecialIntroduction = Plugin.Instance.TranslateConfig.SCP191SpecialIntroduction; - string SCP2936SpecialIntroduction = Plugin.Instance.TranslateConfig.SCP2936SpecialIntroduction; - string SCP073AbelSpecialIntroduction = Plugin.Instance.TranslateConfig.SCP073AbelSpecialIntroduction; - string SCP073CainSpecialIntroduction = Plugin.Instance.TranslateConfig.SCP073CainSpecialIntroduction; - string SkynetSpecialIntroduction = Plugin.Instance.TranslateConfig.SkynetSpecialIntroduction; - string SeeNoEvilSpecialIntroduction = Plugin.Instance.TranslateConfig.SeeNoEvilSpecialIntroduction; - - List SCP703StringList = Plugin.Instance.TranslateConfig.SCP703SkillIntroduction; + int scp703ItemTime = 0; + string scp703SpecialIntroduction = Plugin.Instance.TranslateConfig.SCP703SpecialIntroduction; + List scp703StringList = Plugin.Instance.TranslateConfig.SCP703SkillIntroduction; while (true) { @@ -44,14 +27,9 @@ public static IEnumerator SpecialRoleInfoHandle() yield break; } - if (Plugin.Instance.SCP029 != null && Plugin.Instance.SCP029.Player != null) - { - Plugin.Instance.SCP029.Player.GetPlayerUi().CommonHint.ShowRoleHint(SCP029SpecialIntroduction, Plugin.Instance.TranslateConfig.SCP029SkillIntroduction , 1.25f); - } - if (Plugin.Instance.SCP703 != null && Plugin.Instance.SCP703.Player != null) { - if (SCP703ItemTime == 0) + if (scp703ItemTime == 0) { if (!Plugin.Instance.SCP703.Player.IsInventoryFull) { @@ -67,41 +45,122 @@ public static IEnumerator SpecialRoleInfoHandle() } Plugin.Instance.SCP703.Player.GetPlayerUi().CommonHint.ShowOtherHint(Plugin.Instance.TranslateConfig.SCP703ReceivedItemHint, 5); - SCP703ItemTime = Plugin.Instance.Config.SCP703ItemTime * 60; + scp703ItemTime = Plugin.Instance.Config.SCP703ItemTime * 60; } } else { - SCP703ItemTime--; + scp703ItemTime--; } - SCP703StringList.ForEach(i => + scp703StringList.ForEach(i => { - int index = SCP703StringList.IndexOf(i); + int index = scp703StringList.IndexOf(i); if (index >= 0) { - SCP703StringList[index] = i.Replace("%Time%", SCP703ItemTime.ToString()); + scp703StringList[index] = i.Replace("%Time%", scp703ItemTime.ToString()); } }); - Plugin.Instance.SCP703.Player.GetPlayerUi().CommonHint.ShowRoleHint(SCP703SpecialIntroduction, SCP703StringList.ToArray(), 1.25f); + Plugin.Instance.SCP703.Player.GetPlayerUi().CommonHint.ShowRoleHint(scp703SpecialIntroduction, scp703StringList.ToArray(), 1.25f); + } + } + } + + public static IEnumerator SCP029CoroutineMethod() + { + string scp029SpecialIntroduction = Plugin.Instance.TranslateConfig.SCP029SpecialIntroduction; + + while (true) + { + yield return Timing.WaitForSeconds(1f); + + if (Round.IsRoundEnded || !Round.IsRoundStarted) + { + yield break; + } + + if (Plugin.Instance.SCP029 != null && Plugin.Instance.SCP029.Player != null) + { + Plugin.Instance.SCP029.Player.GetPlayerUi().CommonHint.ShowRoleHint(scp029SpecialIntroduction, Plugin.Instance.TranslateConfig.SCP029SkillIntroduction, 1.25f); + } + } + } + + public static IEnumerator SCP347CoroutineMethod() + { + string scp347SpecialIntroduction = Plugin.Instance.TranslateConfig.SCP347SpecialIntroduction; + + while (true) + { + yield return Timing.WaitForSeconds(1f); + + if (Round.IsRoundEnded || !Round.IsRoundStarted) + { + yield break; } if (Plugin.Instance.SCP347 != null && Plugin.Instance.SCP347.Player != null) { Plugin.Instance.SCP347.Player.EffectsManager.EnableEffect(); - Plugin.Instance.SCP347.Player.GetPlayerUi().CommonHint.ShowRoleHint(SCP347SpecialIntroduction, Plugin.Instance.TranslateConfig.SCP347SkillIntroduction, 1.25f); + Plugin.Instance.SCP347.Player.GetPlayerUi().CommonHint.ShowRoleHint(scp347SpecialIntroduction, Plugin.Instance.TranslateConfig.SCP347SkillIntroduction, 1.25f); + } + } + } + + public static IEnumerator SCP1093CoroutineMethod() + { + string scp1093SpecialIntroduction = Plugin.Instance.TranslateConfig.SCP1093SpecialIntroduction; + + while (true) + { + yield return Timing.WaitForSeconds(1f); + + if (Round.IsRoundEnded || !Round.IsRoundStarted) + { + yield break; } if (Plugin.Instance.SCP1093 != null && Plugin.Instance.SCP1093.Player != null) { - Plugin.Instance.SCP1093.Player.GetPlayerUi().CommonHint.ShowRoleHint(SCP1093SpecialIntroduction, Plugin.Instance.TranslateConfig.SCP1093SkillIntroduction.ToArray(), 1.25f); + Plugin.Instance.SCP1093.Player.GetPlayerUi().CommonHint.ShowRoleHint(scp1093SpecialIntroduction, Plugin.Instance.TranslateConfig.SCP1093SkillIntroduction.ToArray(), 1.25f); + } + } + } + + public static IEnumerator SCP2936CoroutineMethod() + { + string scp2936SpecialIntroduction = Plugin.Instance.TranslateConfig.SCP2936SpecialIntroduction; + + while (true) + { + yield return Timing.WaitForSeconds(1f); + + if (Round.IsRoundEnded || !Round.IsRoundStarted) + { + yield break; } if (Plugin.Instance.SCP2936 != null && Plugin.Instance.SCP2936.Player != null) { - Plugin.Instance.SCP2936.Player.GetPlayerUi().CommonHint.ShowRoleHint(SCP2936SpecialIntroduction, Plugin.Instance.TranslateConfig.SCP29361SkillIntroduction, 1.25f); + Plugin.Instance.SCP2936.Player.GetPlayerUi().CommonHint.ShowRoleHint(scp2936SpecialIntroduction, Plugin.Instance.TranslateConfig.SCP29361SkillIntroduction, 1.25f); + } + } + } + + public static IEnumerator SCP073CoroutineMethod() + { + string scp073AbelSpecialIntroduction = Plugin.Instance.TranslateConfig.SCP073AbelSpecialIntroduction; + string scp073CainSpecialIntroduction = Plugin.Instance.TranslateConfig.SCP073CainSpecialIntroduction; + + while (true) + { + yield return Timing.WaitForSeconds(1f); + + if (Round.IsRoundEnded || !Round.IsRoundStarted) + { + yield break; } if (Plugin.Instance.SCP073 != null && Plugin.Instance.SCP073.Player != null) @@ -109,32 +168,72 @@ public static IEnumerator SpecialRoleInfoHandle() switch (Plugin.Instance.SCP073.Player.Team) { case Team.FoundationForces: - Plugin.Instance.SCP073.Player.GetPlayerUi().CommonHint.ShowRoleHint(SCP073AbelSpecialIntroduction, Plugin.Instance.TranslateConfig.SCP073AbelSkillIntroduction, 1.25f); + Plugin.Instance.SCP073.Player.GetPlayerUi().CommonHint.ShowRoleHint(scp073AbelSpecialIntroduction, Plugin.Instance.TranslateConfig.SCP073AbelSkillIntroduction, 1.25f); break; case Team.ChaosInsurgency: - Plugin.Instance.SCP073.Player.GetPlayerUi().CommonHint.ShowRoleHint(SCP073CainSpecialIntroduction, Plugin.Instance.TranslateConfig.SCP073CainSkillIntroduction, 1.25f); + Plugin.Instance.SCP073.Player.GetPlayerUi().CommonHint.ShowRoleHint(scp073CainSpecialIntroduction, Plugin.Instance.TranslateConfig.SCP073CainSkillIntroduction, 1.25f); break; } } + } + } + + public static IEnumerator SCP191CoroutineMethod() + { + string scp191SpecialIntroduction = Plugin.Instance.TranslateConfig.SCP191SpecialIntroduction; + + while (true) + { + yield return Timing.WaitForSeconds(1f); + + if (Round.IsRoundEnded || !Round.IsRoundStarted) + { + yield break; + } if (Plugin.Instance.SCP191 != null && Plugin.Instance.SCP191.Player != null) { - Plugin.Instance.SCP191.Player.GetPlayerUi().CommonHint.ShowRoleHint(SCP191SpecialIntroduction, Plugin.Instance.TranslateConfig.SCP191SkillIntroduction.ToArray(), 1.25f); + Plugin.Instance.SCP191.Player.GetPlayerUi().CommonHint.ShowRoleHint(scp191SpecialIntroduction, Plugin.Instance.TranslateConfig.SCP191SkillIntroduction.ToArray(), 1.25f); } + } + } - if (!Plugin.Instance.SkynetPlayers.IsEmpty()) + public static IEnumerator SkynetCoroutineMethod() + { + string skynetSpecialIntroduction = Plugin.Instance.TranslateConfig.SkynetSpecialIntroduction; + + while (true) + { + yield return Timing.WaitForSeconds(1f); + + if (Round.IsRoundEnded || !Round.IsRoundStarted) { - foreach (var Player in Plugin.Instance.SkynetPlayers) - { - Player.GetPlayerUi().CommonHint.ShowRoleHint(SkynetSpecialIntroduction, Plugin.Instance.TranslateConfig.SkynetSkillIntroduction.ToArray(), 1.25f); - } + yield break; } - if (!Plugin.Instance.SeePlayers.IsEmpty()) + + foreach (var player in Plugin.Instance.SkynetPlayers) { - foreach (var Player in Plugin.Instance.SeePlayers) - { - Player.GetPlayerUi().CommonHint.ShowRoleHint(SeeNoEvilSpecialIntroduction, Plugin.Instance.TranslateConfig.SeeNoEvilSkillIntroduction.ToArray(), 1.25f); - } + player.GetPlayerUi().CommonHint.ShowRoleHint(skynetSpecialIntroduction, Plugin.Instance.TranslateConfig.SkynetSkillIntroduction.ToArray(), 1.25f); + } + } + } + + public static IEnumerator SeeNoEvilCoroutineMethod() + { + string seeNoEvilSpecialIntroduction = Plugin.Instance.TranslateConfig.SeeNoEvilSpecialIntroduction; + + while (true) + { + yield return Timing.WaitForSeconds(1f); + + if (Round.IsRoundEnded || !Round.IsRoundStarted) + { + yield break; + } + + foreach (var player in Plugin.Instance.SeePlayers) + { + player.GetPlayerUi().CommonHint.ShowRoleHint(seeNoEvilSpecialIntroduction, Plugin.Instance.TranslateConfig.SeeNoEvilSkillIntroduction.ToArray(), 1.25f); } } } diff --git a/HelpSense/Helper/XHelper.cs b/HelpSense/Helper/XHelper.cs index 9320791..a775e6e 100644 --- a/HelpSense/Helper/XHelper.cs +++ b/HelpSense/Helper/XHelper.cs @@ -1,5 +1,4 @@ using InventorySystem.Items.Firearms; -using InventorySystem.Items.Firearms.Attachments; using InventorySystem.Items.Firearms.BasicMessages; using PlayerRoles; @@ -17,14 +16,10 @@ using MEC; using Respawning; using UnityEngine; -using CustomPlayerEffects; using Interactables.Interobjects.DoorUtils; using Mirror; using HelpSense.API.Features.Pool; -using HelpSense.ConfigSystem; - -using HintServiceMeow.UI.Extension; namespace HelpSense.Helper { @@ -140,8 +135,8 @@ public static void SetPlayerScale(this Player target, Vector3 scale) } } public static void SetPlayerScale(this Player target, float scale) => SetPlayerScale(target, Vector3.one * scale); - public static bool PlayerScaleIs(this Player target, Vector3 scale) => target.GameObject.transform.localScale == scale; public static bool PlayerScaleIs(this Player target, float scale) => PlayerScaleIs(target, Vector3.one * scale); + public static bool PlayerScaleIs(this Player target, Vector3 scale) => target.GameObject.transform.localScale == scale; public static void MessageTranslated(string message, string translation, bool isHeld = false, bool isNoisy = true, bool isSubtitles = true) { @@ -158,9 +153,11 @@ public static void MessageTranslated(string message, string translation, bool is //防倒卖 public static IEnumerator AutoXBroadcast() { + yield return Timing.WaitForSeconds(30f); + while (true) { - yield return Timing.WaitForSeconds(6 * 60f); + yield return Timing.WaitForSeconds(360f); if (Round.IsRoundEnded || !Round.IsRoundStarted) { yield break; @@ -168,8 +165,11 @@ public static IEnumerator AutoXBroadcast() Broadcast("此服务器在运行X小左的插件,享受你的游戏时间~", 6, global::Broadcast.BroadcastFlags.Normal); } } + public static IEnumerator AutoServerBroadcast() { + yield return Timing.WaitForSeconds(10f); + while (true) { if (Round.IsRoundEnded || !Round.IsRoundStarted) @@ -247,7 +247,7 @@ public static bool IsAmmo(this ItemType item) return true; } - public static bool IsWeapon(this ItemType type, bool checkMicro = true) + public static bool IsWeapon(this ItemType type, bool checkHID = true) { switch (type) { @@ -266,7 +266,7 @@ public static bool IsWeapon(this ItemType type, bool checkMicro = true) case ItemType.Jailbird: return true; case ItemType.MicroHID: - if (checkMicro) + if (checkHID) { return true; } @@ -304,25 +304,26 @@ public static bool IsArmor(this ItemType type) public static bool IsKeycard(this ItemType type) { - var keycardTypes = new HashSet + switch (type) { - ItemType.KeycardScientist, - ItemType.KeycardResearchCoordinator, - ItemType.KeycardZoneManager, - ItemType.KeycardGuard, - ItemType.KeycardMTFPrivate, - ItemType.KeycardContainmentEngineer, - ItemType.KeycardMTFOperative, - ItemType.KeycardMTFCaptain, - ItemType.KeycardFacilityManager, - ItemType.KeycardChaosInsurgency, - ItemType.KeycardO5 - }; - - return keycardTypes.Contains(type); + case ItemType.KeycardScientist: + case ItemType.KeycardResearchCoordinator: + case ItemType.KeycardZoneManager: + case ItemType.KeycardGuard: + case ItemType.KeycardMTFPrivate: + case ItemType.KeycardContainmentEngineer: + case ItemType.KeycardMTFOperative: + case ItemType.KeycardMTFCaptain: + case ItemType.KeycardFacilityManager: + case ItemType.KeycardChaosInsurgency: + case ItemType.KeycardO5: + return true; + } + + return false; } - public static Team GetTeam2(this RoleTypeId typeId) + public static Team GetTeam(this RoleTypeId typeId) { switch (typeId) { @@ -368,10 +369,10 @@ public static void ShowBroadcast(this Player player, string text, ushort time, B public static Vector3 GetRandomSpawnLocation(this RoleTypeId roleType) { - if (!PlayerRoleLoader.TryGetRoleTemplate(roleType, out PlayerRoleBase @base)) + if (!PlayerRoleLoader.TryGetRoleTemplate(roleType, out PlayerRoleBase roleBase)) return Vector3.zero; - if (@base is not IFpcRole fpc) + if (roleBase is not IFpcRole fpc) return Vector3.zero; ISpawnpointHandler spawn = fpc.SpawnpointHandler; @@ -431,7 +432,7 @@ public static IEnumerator PositionCheckerCoroutine(Player player) } } - public static bool IsSameTeam(this Player player1, Player player2) + public static bool IsSameLeadingTeam(this Player player1, Player player2) { if (player1.Team is Team.FoundationForces && player2.Team is Team.Scientists) { @@ -443,7 +444,7 @@ public static bool IsSameTeam(this Player player1, Player player2) return true; } - return false; + return player1.Team == player2.Team; } } } diff --git a/HelpSense/Patches/MaxHealthGetPatch.cs b/HelpSense/Patches/MaxHealthGetPatch.cs index a824763..2bc77c2 100644 --- a/HelpSense/Patches/MaxHealthGetPatch.cs +++ b/HelpSense/Patches/MaxHealthGetPatch.cs @@ -13,7 +13,7 @@ public static bool Prefix(ref float __result, HealthStat __instance) { Player player = Player.Get(__instance.Hub); - if (player.IsSCP && SCPHPChangeSystem.healthDict.TryGetValue(player.Role, out var health)) + if (player.IsSCP && SCPHealthSystem.HealthDict.TryGetValue(player.Role, out var health)) { __result = health; return false; diff --git a/HelpSense/Plugin.cs b/HelpSense/Plugin.cs index a669f24..f2aab15 100644 --- a/HelpSense/Plugin.cs +++ b/HelpSense/Plugin.cs @@ -357,7 +357,7 @@ void OnPlayerEscape(PlayerEscapeEvent ev) { if (newRole == RoleTypeId.NtfSpecialist) { - var firearm = player.ReferenceHub.inventory.ServerAddItem(ItemType.ParticleDisruptor) as ParticleDisruptor; + var firearm = (ParticleDisruptor)player.ReferenceHub.inventory.ServerAddItem(ItemType.ParticleDisruptor); firearm.Status = new FirearmStatus(5, FirearmStatusFlags.MagazineInserted, firearm.GetCurrentAttachmentsCode()); player.GetPlayerUi().CommonHint.ShowOtherHint(TranslateConfig.SCP703EscapeHint); } @@ -413,6 +413,7 @@ void OnSpecialTeamRespawn(TeamRespawnEvent ev) return; }//我搞了半天搞出来的最像的语音 } + if (Config.EnableSeeNoEvil) { Timing.CallDelayed(1.2f, () => @@ -467,8 +468,8 @@ void OnTeamRespawn(TeamRespawnEvent ev) { if (Player.Role is RoleTypeId.NtfCaptain) { - var firaerm = Player.AddItem(ItemType.ParticleDisruptor) as ParticleDisruptor; - firaerm.Status = new FirearmStatus(5, FirearmStatusFlags.MagazineInserted, firaerm.GetCurrentAttachmentsCode()); + var firearm = Player.AddItem(ItemType.ParticleDisruptor) as ParticleDisruptor; + firearm.Status = new FirearmStatus(5, FirearmStatusFlags.MagazineInserted, firearm.GetCurrentAttachmentsCode()); } } }); @@ -484,7 +485,11 @@ void OnTeamRespawn(TeamRespawnEvent ev) SpawnLeader = true; - ChaosLeader = new SCPHelper(player, 150, TranslateConfig.ChaosLeaderRoleName, "green"); + ChaosLeader = new SCPHelper(player); + + player.RoleName = TranslateConfig.ChaosLeaderRoleName; + player.RoleColor = "green"; + player.Health = 150; player.ClearBroadcasts(); @@ -519,7 +524,11 @@ void OnTeamRespawn(TeamRespawnEvent ev) specialPlayers.Remove(player); - SCP2936 = new SCPHelper(player, 300, "SCP-2936-1", "red"); + SCP2936 = new SCPHelper(player); + + player.RoleName = "SCP-2936-1"; + player.RoleColor = "red"; + player.Health = 300; player.SendBroadcast(TranslateConfig.SCP29361SpawnBroadcast, 6); @@ -537,7 +546,11 @@ void OnTeamRespawn(TeamRespawnEvent ev) { specialPlayers.Remove(player); - SCP073 = new SCPHelper(player, 120, "SCP-073", "green"); + SCP073 = new SCPHelper(player); + + player.RoleName = "SCP-073"; + player.RoleColor = "green"; + player.Health = 120; if (player.Team is Team.ChaosInsurgency) { @@ -567,24 +580,22 @@ void OnTeamRespawn(TeamRespawnEvent ev) [PluginEvent] public void OnRoundStarted(RoundStartEvent ev) { - if (Config.SavePlayersInfo) - { - Timing.RunCoroutine(InfoExtension.CollectInfo()); - Log.Debug("开始记录玩家信息"); - } - + //Special roles if (Config.EnableSCP703) { Timing.CallDelayed(0.5f, () => { - var Player = XHelper.GetRandomSpecialPlayer(RoleTypeId.Scientist); - if (Player != null) + var player = XHelper.GetRandomSpecialPlayer(RoleTypeId.Scientist); + if (player != null) { - SCP703 = new SCPHelper(Player, 120, "SCP-703", "cyan"); + SCP703 = new SCPHelper(player); + player.RoleName = "SCP-703"; + player.RoleColor = "cyan"; + player.Health = 120; - Player.ClearBroadcasts(); + player.ClearBroadcasts(); - Player.ShowBroadcast(TranslateConfig.SCP703SpawnBroadcast, 10, BroadcastFlags.Normal); + player.ShowBroadcast(TranslateConfig.SCP703SpawnBroadcast, 10, BroadcastFlags.Normal); }; }); } @@ -596,7 +607,11 @@ public void OnRoundStarted(RoundStartEvent ev) var player = XHelper.GetRandomSpecialPlayer(RoleTypeId.ClassD); if (player != null) { - SCP029 = new SCPHelper(player, 120, "SCP-029", "red"); + SCP029 = new SCPHelper(player); + + player.RoleName = "SCP-029"; + player.RoleColor = "red"; + player.Health = 120; player.ClearBroadcasts(); @@ -630,7 +645,13 @@ public void OnRoundStarted(RoundStartEvent ev) if (player != null) { - SCP347 = new SCPHelper(player, RoleTypeId.Tutorial, "SCP-347", "red", XHelper.GetRandomSpawnLocation(RoleTypeId.FacilityGuard)); + player.SetRole(RoleTypeId.Tutorial); + + SCP347 = new SCPHelper(player); + + player.RoleName = "SCP-347"; + player.RoleColor = "red"; + player.Position = XHelper.GetRandomSpawnLocation(RoleTypeId.FacilityGuard); player.AddItem(ItemType.KeycardGuard); @@ -651,7 +672,10 @@ public void OnRoundStarted(RoundStartEvent ev) if (player != null) { - SCP1093 = new SCPHelper(player , "SCP-1093" , "yellow"); + SCP1093 = new SCPHelper(player); + + player.RoleName = "SCP-1093"; + player.RoleColor = "yellow"; player.GameObject.AddComponent(); @@ -740,6 +764,14 @@ public void OnRoundStarted(RoundStartEvent ev) } }); } + + //Functions + if (Config.SavePlayersInfo) + { + Timing.RunCoroutine(InfoExtension.CollectInfo()); + Log.Debug("开始记录玩家信息"); + } + if (Config.EnableRoundWaitingLobby) { try @@ -766,26 +798,19 @@ public void OnRoundStarted(RoundStartEvent ev) Log.Error("[HelpSense] [Event: OnRoundStarted] " + e); } } + if (Config.EnableFriendlyFire) { Server.FriendlyFire = false; Traverse.Create().Method("RefreshConfigs").GetValue(); } + if (Config.EnableRespawnTimer) { Timing.RunCoroutine(RespawnHelper.TimerCoroutine()); } - Timing.CallDelayed(30f, () => - { - Timing.RunCoroutine(XHelper.AutoXBroadcast()); - }); - Timing.CallDelayed(10f, () => - { - if (Config.EnableAutoServerMessage) - { - Timing.RunCoroutine(XHelper.AutoServerBroadcast()); - } - }); + + //Spawn special items if (Config.SCP1068) { Timing.CallDelayed(2f, () => @@ -800,16 +825,32 @@ public void OnRoundStarted(RoundStartEvent ev) } }); } + if (Config.SCP1056) { Timing.CallDelayed(1f, () => { - RoomIdentifier room173 = RoomIdentifier.AllRoomIdentifiers.Where(x => x.Name == RoomName.Lcz173).First(); + RoomIdentifier room173 = RoomIdentifier.AllRoomIdentifiers.First(x => x.Name == RoomName.Lcz173); var item = XHelper.SpawnItem(ItemType.Medkit, room173.transform.TransformPoint(new Vector3(-2.62f, 13.29f, -4.93f))); SCP1056Id = item.Serial; }); } - Timing.RunCoroutine(SpecialRoleHelper.SpecialRoleInfoHandle()); + + //Broadcast coroutine + Timing.RunCoroutine(XHelper.AutoXBroadcast()); + if (Config.EnableAutoServerMessage) + Timing.RunCoroutine(XHelper.AutoServerBroadcast()); + + //Special role coroutine + Timing.RunCoroutine(SpecialRoleHelper.SCP029CoroutineMethod()); + Timing.RunCoroutine(SpecialRoleHelper.SCP073CoroutineMethod()); + Timing.RunCoroutine(SpecialRoleHelper.SCP1093CoroutineMethod()); + Timing.RunCoroutine(SpecialRoleHelper.SCP191CoroutineMethod()); + Timing.RunCoroutine(SpecialRoleHelper.SCP2936CoroutineMethod()); + Timing.RunCoroutine(SpecialRoleHelper.SCP347CoroutineMethod()); + Timing.RunCoroutine(SpecialRoleHelper.SCP703CoroutineMethod()); + Timing.RunCoroutine(SpecialRoleHelper.SeeNoEvilCoroutineMethod()); + Timing.RunCoroutine(SpecialRoleHelper.SkynetCoroutineMethod()); } [PluginEvent] @@ -954,7 +995,7 @@ void OnPlayerThrowProjectile(PlayerThrowProjectileEvent ev) { XHelper.Broadcast(TranslateConfig.SCP1068UsedBroadcast, 5, BroadcastFlags.Normal); Server.Instance.GetComponent(globalSearch: true).RpcShake(true); - }//沙比NW写空壳核弹抖动我直接自己写一个 + } } [PluginEvent] @@ -1038,8 +1079,8 @@ void OnPlayerSpawn(PlayerSpawnEvent ev) { Timing.CallDelayed(0.5f, () => { - if (SCPHPChangeSystem.healthDict.TryGetValue(role, out var health)) - player.Health = SCPHPChangeSystem.healthDict[role]; + if (SCPHealthSystem.HealthDict.TryGetValue(role, out var health)) + player.Health = health; }); } @@ -1109,7 +1150,8 @@ void OnPlayerDying(PlayerDyingEvent ev) { var player = ev.Player; - if (player == null) return; + if (player == null) + return; Timing.CallDelayed(1f, () => { @@ -1415,7 +1457,13 @@ void OnChangeRole(PlayerChangeRoleEvent ev) if (!(oldRole is RoleTypeId.Scp079 && newRole is RoleTypeId.Spectator && Config.SCP191)) return; - SCP191 = new SCPHelper(player, RoleTypeId.Tutorial, 120, "SCP-191", "red"); + player.SetRole(RoleTypeId.Tutorial); + player.Health = 120; + + SCP191 = new SCPHelper(player); + + player.RoleName = "SCP-191"; + player.RoleColor = "red"; player.SetPlayerScale(0.8f);