From d4bb277bc02ce9bfe1c7bdfe9d5541cadfeb4df4 Mon Sep 17 00:00:00 2001 From: D1GQ Date: Sat, 27 Jul 2024 18:20:45 -0500 Subject: [PATCH] GetRoleHexColor --- Modules/BetterHostManager.cs | 3 +-- Modules/EventLogManager.cs | 9 +++++++++ Modules/ExtendedPlayerControl.cs | 14 ++++++++++++++ Patches/ChatPatch.cs | 3 +-- Patches/PlayerControlPatch.cs | 3 +-- 5 files changed, 26 insertions(+), 6 deletions(-) diff --git a/Modules/BetterHostManager.cs b/Modules/BetterHostManager.cs index 6d20326..23d29e1 100644 --- a/Modules/BetterHostManager.cs +++ b/Modules/BetterHostManager.cs @@ -62,8 +62,7 @@ class BetterHostManager } else if (GameStates.IsInGame && !GameStates.IsLobby) { - string RoleHexColor = player.IsImpostorTeam() ? "#ff1919" : "#8cffff"; - string Role = $"{player.GetRoleName()}"; + string Role = $"{player.GetRoleName()}"; if (!player.IsImpostorTeam() && !target.IsImpostorTeam()) { if (target.IsAlive() && player != target) diff --git a/Modules/EventLogManager.cs b/Modules/EventLogManager.cs index 3e86be0..48e8dc3 100644 --- a/Modules/EventLogManager.cs +++ b/Modules/EventLogManager.cs @@ -20,6 +20,15 @@ class EventLogManager else Logger.LogPrivate($"{__instance.Data.PlayerName} Has Un-Shapeshifted, did animate: {animate}", "EventLog"); } + [HarmonyPatch(nameof(PlayerControl.SetRoleInvisibility))] + [HarmonyPostfix] + public static void SetRoleInvisibility_Postfix(PlayerControl __instance, [HarmonyArgument(0)] bool isActive, [HarmonyArgument(1)] bool animate) + { + if (isActive) + Logger.LogPrivate($"{__instance.Data.PlayerName} Has Vanished as Phantom, did animate: {animate}", "EventLog"); + else + Logger.LogPrivate($"{__instance.Data.PlayerName} Has Appeared as Phantom, did animate: {animate}", "EventLog"); + } } [HarmonyPatch(typeof(PlayerPhysics))] diff --git a/Modules/ExtendedPlayerControl.cs b/Modules/ExtendedPlayerControl.cs index fe71a7e..25a224e 100644 --- a/Modules/ExtendedPlayerControl.cs +++ b/Modules/ExtendedPlayerControl.cs @@ -136,6 +136,20 @@ static class ExtendedPlayerControl } return false; } + // Get hex color for team + public static string GetTeamHexColor(this PlayerControl player) + { + if (player == null) return "#ffffff"; + + if (player.IsImpostorTeam()) + { + return "#f00202"; + } + else + { + return "#8cffff"; + } + } // Check if player is on imposter team public static bool IsImpostorTeam(this PlayerControl player) => player?.Data != null && (player.Data.RoleType is RoleTypes.Impostor or RoleTypes.ImpostorGhost or RoleTypes.Shapeshifter or RoleTypes.Phantom); // Check if player is a imposter teammate diff --git a/Patches/ChatPatch.cs b/Patches/ChatPatch.cs index b1d3447..258a723 100644 --- a/Patches/ChatPatch.cs +++ b/Patches/ChatPatch.cs @@ -114,8 +114,7 @@ class ChatPatch string hashPuid = Utils.GetHashPuid(sourcePlayer); string friendCode = sourcePlayer.Data.FriendCode; string playerName = sourcePlayer.Data.PlayerName; - string RoleHexColor = sourcePlayer.IsImpostorTeam() ? "#ff1919" : "#8cffff"; - string Role = $"{sourcePlayer.GetRoleName()}+++"; + string Role = $"{sourcePlayer.GetRoleName()}+++"; if (GameStates.IsLobby && !GameStates.IsFreePlay) { diff --git a/Patches/PlayerControlPatch.cs b/Patches/PlayerControlPatch.cs index 9a46efc..aee3680 100644 --- a/Patches/PlayerControlPatch.cs +++ b/Patches/PlayerControlPatch.cs @@ -199,8 +199,7 @@ class PlayerControlPatch } else { - string RoleHexColor = player.IsImpostorTeam() ? "#ff1919" : "#8cffff"; - string Role = $"{player.GetRoleName()}"; + string Role = $"{player.GetRoleName()}"; if (!player.IsImpostorTeammate()) { if (PlayerControl.LocalPlayer.IsAlive() && player != PlayerControl.LocalPlayer)