diff --git a/Modules/Extensions/ObjectHelper.cs b/Modules/Extensions/ObjectHelper.cs index 668ecbeef..5ccede0da 100644 --- a/Modules/Extensions/ObjectHelper.cs +++ b/Modules/Extensions/ObjectHelper.cs @@ -1,13 +1,9 @@ -using HarmonyLib; using UnityEngine; namespace EHR; public static class ObjectHelper { - /// - /// オブジェクトのコンポーネントを破棄します - /// public static void DestroyTranslator(this GameObject obj) { if (obj == null) return; @@ -15,8 +11,6 @@ public static class ObjectHelper TextTranslatorTMP[] translator = obj.GetComponentsInChildren(true); translator?.Do(Object.Destroy); } - /// - /// オブジェクトのコンポーネントを破棄します - /// - public static void DestroyTranslator(this MonoBehaviour obj) => obj?.gameObject?.DestroyTranslator(); + + public static void DestroyTranslator(this MonoBehaviour obj) => obj?.gameObject.DestroyTranslator(); } diff --git a/Modules/GuessManager.cs b/Modules/GuessManager.cs index fca69a439..06d449715 100644 --- a/Modules/GuessManager.cs +++ b/Modules/GuessManager.cs @@ -327,6 +327,7 @@ public static class GuessManager if (!isUI) Utils.SendMessage(GetString("GuessSuperStar"), pc.PlayerId); else pc.ShowPopUp(GetString("GuessSuperStar")); return true; + case CustomRoles.Shifter: case CustomRoles.Goose when !Goose.CanBeGuessed.GetBool(): case CustomRoles.Disco: case CustomRoles.Glow: diff --git a/Modules/Utils.cs b/Modules/Utils.cs index ab0a4c168..f530238ed 100644 --- a/Modules/Utils.cs +++ b/Modules/Utils.cs @@ -431,6 +431,7 @@ public static class Utils var self = seerId == targetId || Main.PlayerStates[seerId].IsDead; bool isHnsAgentOverride = Options.CurrentGameMode == CustomGameMode.HideAndSeek && targetMainRole == CustomRoles.Agent && HnSManager.PlayerRoles[seerId].Interface.Team != Team.Impostor; + bool loversShowDifferentRole = false; if (!GameStates.IsEnded && targetMainRole == CustomRoles.LovingImpostor && !self && seerMainRole != CustomRoles.LovingCrewmate && !seerSubRoles.Contains(CustomRoles.Lovers)) { targetMainRole = Lovers.LovingImpostorRoleForOtherImps.GetValue() switch @@ -439,10 +440,11 @@ public static class Utils 1 => Lovers.LovingImpostorRole, _ => CustomRoles.LovingImpostor }; + loversShowDifferentRole = true; } string RoleText = GetRoleName(isHnsAgentOverride ? CustomRoles.Hider : targetMainRole); - Color RoleColor = GetRoleColor(targetMainRole); + Color RoleColor = GetRoleColor(loversShowDifferentRole ? CustomRoles.Impostor : targetMainRole); if (LastImpostor.currentId == targetId) RoleText = GetRoleString("Last-") + RoleText; @@ -829,11 +831,11 @@ public static class Utils return __instance.Is(CustomRoles.Madmate) && PlayerControl.LocalPlayer.Is(CustomRoles.Madmate) && Options.MadmateKnowWhosMadmate.GetBool() || __instance.Is(CustomRoles.Mimic) && Main.VisibleTasksCount && __instance.Data.IsDead || - __instance.Is(CustomRoles.Lovers) && PlayerControl.LocalPlayer.Is(CustomRoles.Lovers) && Lovers.LoverKnowRoles.GetBool() || __instance.Is(CustomRoles.Madmate) && PlayerControl.LocalPlayer.Is(CustomRoleTypes.Impostor) && Options.ImpKnowWhosMadmate.GetBool() || __instance.Is(CustomRoleTypes.Impostor) && PlayerControl.LocalPlayer.Is(CustomRoles.Crewpostor) && Options.AlliesKnowCrewpostor.GetBool() || __instance.Is(CustomRoleTypes.Impostor) && PlayerControl.LocalPlayer.Is(CustomRoleTypes.Impostor) && Options.ImpKnowAlliesRole.GetBool() || __instance.Is(CustomRoleTypes.Impostor) && PlayerControl.LocalPlayer.Is(CustomRoles.Madmate) && Options.MadmateKnowWhosImp.GetBool() || + Main.LoversPlayers.TrueForAll(x => x.PlayerId == __instance.PlayerId || x.PlayerId == PlayerControl.LocalPlayer.PlayerId) && Lovers.LoverKnowRoles.GetBool() || CustomTeamManager.AreInSameCustomTeam(__instance.PlayerId, PlayerControl.LocalPlayer.PlayerId) && CustomTeamManager.IsSettingEnabledForPlayerTeam(__instance.PlayerId, CTAOption.KnowRoles) || Main.PlayerStates.Values.Any(x => x.Role.KnowRole(PlayerControl.LocalPlayer, __instance)) || PlayerControl.LocalPlayer.IsRevealedPlayer(__instance) || @@ -1351,7 +1353,7 @@ public static class Utils var sb = new StringBuilder(); if (intro) { - bool isLovers = SubRoles.Contains(CustomRoles.Lovers); + bool isLovers = SubRoles.Contains(CustomRoles.Lovers) && Main.PlayerStates[id].MainRole is not CustomRoles.LovingCrewmate and not CustomRoles.LovingImpostor; SubRoles.RemoveAll(x => x is CustomRoles.NotAssigned or CustomRoles.LastImpostor or CustomRoles.Lovers); if (isLovers) @@ -1963,7 +1965,7 @@ public static class Utils if (Options.CurrentGameMode != CustomGameMode.Standard) goto GameMode0; SelfMark.Append(Snitch.GetWarningArrow(seer)); - if (seer.Is(CustomRoles.Lovers)) SelfMark.Append(ColorString(GetRoleColor(CustomRoles.Lovers), " ♥")); + if (Main.LoversPlayers.Contains(seer)) SelfMark.Append(ColorString(GetRoleColor(CustomRoles.Lovers), " ♥")); if (BallLightning.IsGhost(seer)) SelfMark.Append(ColorString(GetRoleColor(CustomRoles.BallLightning), "■")); SelfMark.Append(Medic.GetMark(seer, seer)); SelfMark.Append(Gamer.TargetMark(seer, seer)); @@ -2152,8 +2154,7 @@ public static class Utils TargetMark.Append(Snitch.GetWarningMark(seer, target)); - if ((seer.Is(CustomRoles.Lovers) && target.Is(CustomRoles.Lovers)) - || (seer.Data.IsDead && target.Is(CustomRoles.Lovers))) + if (Main.LoversPlayers.TrueForAll(x => x.PlayerId == seer.PlayerId || x.PlayerId == target.PlayerId) || (seer.Data.IsDead && Main.LoversPlayers.Contains(target))) { TargetMark.Append($" ♥"); } @@ -2226,7 +2227,7 @@ public static class Utils (seer.Data.IsDead && Options.GhostCanSeeOtherRoles.GetBool()) || (seer.Is(CustomRoles.Mimic) && target.Data.IsDead && Options.MimicCanSeeDeadRoles.GetBool()) || (target.Is(CustomRoles.Gravestone) && target.Data.IsDead) || - (seer.Is(CustomRoles.Lovers) && target.Is(CustomRoles.Lovers) && Lovers.LoverKnowRoles.GetBool()) || + (Main.LoversPlayers.TrueForAll(x => x.PlayerId == seer.PlayerId || x.PlayerId == target.PlayerId) && Lovers.LoverKnowRoles.GetBool()) || (seer.Is(CustomRoleTypes.Impostor) && target.Is(CustomRoleTypes.Impostor) && Options.ImpKnowAlliesRole.GetBool()) || (seer.Is(CustomRoles.Madmate) && target.Is(CustomRoleTypes.Impostor) && Options.MadmateKnowWhosImp.GetBool()) || (seer.Is(CustomRoleTypes.Impostor) && target.Is(CustomRoles.Madmate) && Options.ImpKnowWhosMadmate.GetBool()) || @@ -2513,7 +2514,7 @@ public static class Utils { if (!Lovers.IsChatActivated && Lovers.PrivateChat.GetBool() && !GameStates.IsEnded) { - SetChatVisible(); + LateTask.New(SetChatVisible, 0.5f, log: false); Lovers.IsChatActivated = true; return; } diff --git a/Patches/ChatCommandPatch.cs b/Patches/ChatCommandPatch.cs index ace2b15ab..638e321f1 100644 --- a/Patches/ChatCommandPatch.cs +++ b/Patches/ChatCommandPatch.cs @@ -73,14 +73,12 @@ internal class ChatCommands switch (args[0]) { case "/dump": - //canceled = true; Utils.DumpLog(); break; case "/v": case "/version": canceled = true; string version_text = Main.PlayerVersion.OrderBy(pair => pair.Key).Aggregate(string.Empty, (current, kvp) => current + $"{kvp.Key}:{Main.AllPlayerNames[kvp.Key]}:{kvp.Value.forkId}/{kvp.Value.version}({kvp.Value.tag})\n"); - if (version_text != string.Empty) HudManager.Instance.Chat.AddChat(PlayerControl.LocalPlayer, (PlayerControl.LocalPlayer.FriendCode.GetDevUser().HasTag() ? "\n" : string.Empty) + version_text); break; default: @@ -764,7 +762,7 @@ internal class ChatCommands ChatUpdatePatch.LoversMessage = true; Utils.SendMessage(text, otherLover.PlayerId, title); Utils.SendMessage(text, PlayerControl.LocalPlayer.PlayerId, title); - LateTask.New(() => ChatUpdatePatch.LoversMessage = false, 1f, log: false); + LateTask.New(() => ChatUpdatePatch.LoversMessage = false, Main.MessageWait.Value, log: false); } goto Canceled; @@ -1408,8 +1406,8 @@ internal class ChatCommands ChatUpdatePatch.LoversMessage = true; Utils.SendMessage(text, otherLover.PlayerId, title); Utils.SendMessage(text, player.PlayerId, title); - LateTask.New(() => ChatUpdatePatch.LoversMessage = false, 1f, log: false); - }, 0.5f, log: false); + LateTask.New(() => ChatUpdatePatch.LoversMessage = false, Main.MessageWait.Value, log: false); + }, 0.2f, log: false); } } diff --git a/Patches/CheckGameEndPatch.cs b/Patches/CheckGameEndPatch.cs index ac4840441..5c20ef05f 100644 --- a/Patches/CheckGameEndPatch.cs +++ b/Patches/CheckGameEndPatch.cs @@ -240,12 +240,10 @@ class GameEndChecker .DoIf(x => !CustomTeamManager.IsSettingEnabledForTeam(x.Key, CTAOption.WinWithOriginalTeam), x => WinnerIds.ExceptWith(x.Value), fast: true); } - if ((WinnerTeam == CustomWinner.Lovers || WinnerIds.Any(x => Main.PlayerStates[x].SubRoles.Contains(CustomRoles.Lovers))) && Main.LoversPlayers.All(x => x.IsAlive())) + if ((WinnerTeam == CustomWinner.Lovers || WinnerIds.Any(x => Main.PlayerStates[x].SubRoles.Contains(CustomRoles.Lovers))) && Main.LoversPlayers.All(x => x.IsAlive()) && reason != GameOverReason.HumansByTask) { if (WinnerTeam != CustomWinner.Lovers) AdditionalWinnerTeams.Add(AdditionalWinners.Lovers); - Main.AllPlayerControls - .Where(p => p.Is(CustomRoles.Lovers)) - .Do(p => WinnerIds.Add(p.PlayerId)); + WinnerIds.UnionWith(Main.LoversPlayers.Select(x => x.PlayerId)); } if (Options.NeutralWinTogether.GetBool() && WinnerIds.Any(x => GetPlayerById(x) != null && GetPlayerById(x).GetCustomRole().IsNeutral())) @@ -378,7 +376,7 @@ class GameEndChecker if (CustomTeamManager.CheckCustomTeamGameEnd()) return true; - if (Main.AllAlivePlayerControls.All(p => p.Is(CustomRoles.Lovers)) && !Main.LoversPlayers.All(x => x.Is(CustomRoles.LovingCrewmate))) + if (Main.AllAlivePlayerControls.All(Main.LoversPlayers.Contains) && !Main.LoversPlayers.All(x => x.Is(Team.Crewmate))) { ResetAndSetWinner(CustomWinner.Lovers); return true; diff --git a/Patches/MeetingHudPatch.cs b/Patches/MeetingHudPatch.cs index 74bdd4bab..a540cd13c 100644 --- a/Patches/MeetingHudPatch.cs +++ b/Patches/MeetingHudPatch.cs @@ -354,8 +354,18 @@ class CheckForEndVotingPatch var crole = exiledPlayer.GetCustomRole(); var coloredRole = Utils.GetDisplayRoleName(exileId, true); + if (crole == CustomRoles.LovingImpostor && !Options.ConfirmLoversOnEject.GetBool()) + { + coloredRole = (Lovers.LovingImpostorRoleForOtherImps.GetValue() switch + { + 0 => CustomRoles.ImpostorEHR, + 1 => Lovers.LovingImpostorRole, + _ => CustomRoles.LovingImpostor + }).ToColoredString(); + } + if (Options.ConfirmEgoistOnEject.GetBool() && player.Is(CustomRoles.Egoist)) coloredRole = Utils.ColorString(Utils.GetRoleColor(CustomRoles.Egoist), GetRoleString("Temp.Blank") + coloredRole.RemoveHtmlTags()); - if (Options.ConfirmLoversOnEject.GetBool() && player.Is(CustomRoles.Lovers)) coloredRole = Utils.ColorString(Utils.GetRoleColor(CustomRoles.Lovers), GetRoleString("Temp.Blank") + coloredRole.RemoveHtmlTags()); + if (Options.ConfirmLoversOnEject.GetBool() && Main.LoversPlayers.Contains(player)) coloredRole = Utils.ColorString(Utils.GetRoleColor(CustomRoles.Lovers), GetRoleString("Temp.Blank") + coloredRole.RemoveHtmlTags()); if (Options.RascalAppearAsMadmate.GetBool() && player.Is(CustomRoles.Rascal)) coloredRole = Utils.ColorString(Utils.GetRoleColor(CustomRoles.Madmate), GetRoleString("Mad-") + coloredRole.RemoveHtmlTags()); var name = string.Empty; @@ -373,9 +383,7 @@ class CheckForEndVotingPatch foreach (PlayerControl pc in Main.AllAlivePlayerControls) { if (pc == exiledPlayer.Object) continue; - var pc_role = pc.GetCustomRole(); - - if (pc_role.IsImpostor()) impnum++; + if (pc.GetCustomRole().IsImpostor()) impnum++; else if (pc.IsNeutralKiller()) neutralnum++; } @@ -797,7 +805,7 @@ class MeetingHudStartPatch (Main.VisibleTasksCount && PlayerControl.LocalPlayer.Data.IsDead && Options.GhostCanSeeOtherRoles.GetBool()) || (PlayerControl.LocalPlayer.Is(CustomRoles.Mimic) && Main.VisibleTasksCount && pc.Data.IsDead && Options.MimicCanSeeDeadRoles.GetBool()) || (pc.Is(CustomRoles.Gravestone) && Main.VisibleTasksCount && pc.Data.IsDead) || - (pc.Is(CustomRoles.Lovers) && PlayerControl.LocalPlayer.Is(CustomRoles.Lovers) && Lovers.LoverKnowRoles.GetBool()) || + (Main.LoversPlayers.TrueForAll(x => x.PlayerId == pc.PlayerId || x.PlayerId == PlayerControl.LocalPlayer.PlayerId) && Lovers.LoverKnowRoles.GetBool()) || (pc.Is(CustomRoleTypes.Impostor) && PlayerControl.LocalPlayer.Is(CustomRoleTypes.Impostor) && Options.ImpKnowAlliesRole.GetBool()) || (pc.Is(CustomRoleTypes.Impostor) && PlayerControl.LocalPlayer.Is(CustomRoles.Madmate) && Options.MadmateKnowWhosImp.GetBool()) || (pc.Is(CustomRoles.Madmate) && PlayerControl.LocalPlayer.Is(CustomRoleTypes.Impostor) && Options.ImpKnowWhosMadmate.GetBool()) || @@ -964,7 +972,7 @@ class MeetingHudStartPatch if (Silencer.ForSilencer.Contains(target.PlayerId)) sb.Append(Utils.ColorString(Utils.GetRoleColor(CustomRoles.Silencer), "╳")); - if (target.GetCustomSubRoles().Contains(CustomRoles.Lovers) && (seer.Is(CustomRoles.Lovers) || seer.Data.IsDead)) + if (Main.LoversPlayers.Contains(target) && (Main.LoversPlayers.Contains(seer) || seer.Data.IsDead)) { sb.Append(Utils.ColorString(Utils.GetRoleColor(CustomRoles.Lovers), "♥")); } diff --git a/Roles/Crewmate/Mayor.cs b/Roles/Crewmate/Mayor.cs index 04d3ab1ab..05026bd63 100644 --- a/Roles/Crewmate/Mayor.cs +++ b/Roles/Crewmate/Mayor.cs @@ -41,10 +41,10 @@ namespace EHR.Roles.Crewmate public override void SetButtonTexts(HudManager hud, byte id) { - if (UsePets.GetBool()) - hud.PetButton.buttonLabelText.text = Translator.GetString("MayorVentButtonText"); - else - hud.AbilityButton.buttonLabelText.text = Translator.GetString("MayorVentButtonText"); + if (!MayorHasPortableButton.GetBool()) return; + + if (UsePets.GetBool()) hud.PetButton.buttonLabelText.text = Translator.GetString("MayorVentButtonText"); + else hud.AbilityButton.buttonLabelText.text = Translator.GetString("MayorVentButtonText"); } public override void OnPet(PlayerControl pc) diff --git a/Roles/Crewmate/SabotageMaster.cs b/Roles/Crewmate/SabotageMaster.cs index 9e1f69eac..4a7a12242 100644 --- a/Roles/Crewmate/SabotageMaster.cs +++ b/Roles/Crewmate/SabotageMaster.cs @@ -72,6 +72,12 @@ public class SabotageMaster : RoleBase AURoleOptions.EngineerInVentMaxTime = 0f; } + public override string GetProgressText(byte playerId, bool comms) + { + var limit = SkillLimit.GetInt() - UsedSkillCount; + return limit + base.GetProgressText(playerId, comms); + } + public void SendRPC() { if (!IsEnable || !Utils.DoRPC) return; diff --git a/Roles/Crewmate/Sentry.cs b/Roles/Crewmate/Sentry.cs index 43821558d..8dad0f8e2 100644 --- a/Roles/Crewmate/Sentry.cs +++ b/Roles/Crewmate/Sentry.cs @@ -125,14 +125,14 @@ namespace EHR.Roles.Impostor MonitoredRoom = room; Utils.SendRPC(CustomRPC.SyncSentry, pc.PlayerId); } - else DisplayRoomInfo(pc); + else DisplayRoomInfo(pc, false); } - void DisplayRoomInfo(PlayerControl pc) + void DisplayRoomInfo(PlayerControl pc, bool fromDevice) { if (CannotSeeInfoDuringComms.GetBool() && Utils.IsActive(SystemTypes.Comms)) return; - if (pc.Is(CustomRoles.Sentry)) + if (!fromDevice) { if (pc.GetAbilityUseLimit() < 1) return; pc.RpcRemoveAbilityUse(); @@ -278,7 +278,7 @@ namespace EHR.Roles.Impostor return; } - DisplayRoomInfo(pc); + DisplayRoomInfo(pc, true); UsingDevice.Add(pc.PlayerId); } diff --git a/Roles/Neutral/Executioner.cs b/Roles/Neutral/Executioner.cs index 83b724573..1570b6f8e 100644 --- a/Roles/Neutral/Executioner.cs +++ b/Roles/Neutral/Executioner.cs @@ -63,7 +63,7 @@ public class Executioner : RoleBase try { List targetList = []; - targetList.AddRange(from target in Main.AllPlayerControls where playerId != target.PlayerId where CanTargetImpostor.GetBool() || !target.Is(CustomRoleTypes.Impostor) where CanTargetNeutralKiller.GetBool() || !target.IsNeutralKiller() where CanTargetNeutralBenign.GetBool() || !target.IsNeutralBenign() where CanTargetNeutralEvil.GetBool() || !target.IsNeutralEvil() where CanTargetNeutralChaos.GetBool() || !target.IsNeutralChaos() where target.GetCustomRole() is not (CustomRoles.GM or CustomRoles.SuperStar) where !Utils.GetPlayerById(playerId).Is(CustomRoles.Lovers) || !target.Is(CustomRoles.Lovers) select target); + targetList.AddRange(from target in Main.AllPlayerControls where playerId != target.PlayerId where CanTargetImpostor.GetBool() || !target.Is(CustomRoleTypes.Impostor) where CanTargetNeutralKiller.GetBool() || !target.IsNeutralKiller() where CanTargetNeutralBenign.GetBool() || !target.IsNeutralBenign() where CanTargetNeutralEvil.GetBool() || !target.IsNeutralEvil() where CanTargetNeutralChaos.GetBool() || !target.IsNeutralChaos() where target.GetCustomRole() is not (CustomRoles.GM or CustomRoles.SuperStar) where Main.LoversPlayers.TrueForAll(x => x.PlayerId != playerId) select target); if (targetList.Count == 0) { diff --git a/Roles/Neutral/FFF.cs b/Roles/Neutral/FFF.cs index 008c09329..8a16a8f27 100644 --- a/Roles/Neutral/FFF.cs +++ b/Roles/Neutral/FFF.cs @@ -92,7 +92,7 @@ namespace EHR.Roles.Neutral ((target.Is(CustomRoles.Madmate) || target.Is(CustomRoles.Gangster)) && CanKillMadmate.GetBool()) || ((target.Is(CustomRoles.Charmed) || target.Is(CustomRoles.Succubus)) && CanKillCharmed.GetBool()) || ((target.Is(CustomRoles.Undead) || target.Is(CustomRoles.Necromancer) || target.Is(CustomRoles.Deathknight)) && CanKillUndead.GetBool()) - || ((target.Is(CustomRoles.Lovers) || target.Is(CustomRoles.Ntr)) && CanKillLovers.GetBool()) + || ((Main.LoversPlayers.Contains(target) || target.Is(CustomRoles.Ntr)) && CanKillLovers.GetBool()) || ((target.Is(CustomRoles.Romantic) || target.Is(CustomRoles.RuthlessRomantic) || target.Is(CustomRoles.VengefulRomantic) || Romantic.PartnerId == target.PlayerId) && CanKillLovers.GetBool()) || ((target.Is(CustomRoles.Sidekick) || target.Is(CustomRoles.Jackal) || target.Is(CustomRoles.Recruit)) && CanKillSidekicks.GetBool()) diff --git a/Roles/Neutral/Lawyer.cs b/Roles/Neutral/Lawyer.cs index a1ac8a37b..fd6b6d774 100644 --- a/Roles/Neutral/Lawyer.cs +++ b/Roles/Neutral/Lawyer.cs @@ -77,7 +77,7 @@ public class Lawyer : RoleBase if (AmongUsClient.Instance.AmHost) { List targetList = []; - targetList.AddRange(from target in Main.AllPlayerControls where playerId != target.PlayerId where CanTargetImpostor.GetBool() || !target.Is(CustomRoleTypes.Impostor) where CanTargetNeutralKiller.GetBool() || !target.IsNeutralKiller() where CanTargetCrewmate.GetBool() || !target.Is(CustomRoleTypes.Crewmate) where CanTargetJester.GetBool() || !target.Is(CustomRoles.Jester) where !target.Is(CustomRoleTypes.Neutral) || target.IsNeutralKiller() || target.Is(CustomRoles.Jester) where target.GetCustomRole() is not (CustomRoles.GM or CustomRoles.SuperStar) where !Utils.GetPlayerById(playerId).Is(CustomRoles.Lovers) || !target.Is(CustomRoles.Lovers) select target); + targetList.AddRange(from target in Main.AllPlayerControls where playerId != target.PlayerId where CanTargetImpostor.GetBool() || !target.Is(CustomRoleTypes.Impostor) where CanTargetNeutralKiller.GetBool() || !target.IsNeutralKiller() where CanTargetCrewmate.GetBool() || !target.Is(CustomRoleTypes.Crewmate) where CanTargetJester.GetBool() || !target.Is(CustomRoles.Jester) where !target.Is(CustomRoleTypes.Neutral) || target.IsNeutralKiller() || target.Is(CustomRoles.Jester) where target.GetCustomRole() is not (CustomRoles.GM or CustomRoles.SuperStar) where Main.LoversPlayers.TrueForAll(x => x.PlayerId != playerId) select target); if (targetList.Count == 0) {