diff --git a/.idea/.idea.EHR/.idea/indexLayout.xml b/.idea/.idea.EHR/.idea/indexLayout.xml index 7b08163ce..d2f7c74df 100644 --- a/.idea/.idea.EHR/.idea/indexLayout.xml +++ b/.idea/.idea.EHR/.idea/indexLayout.xml @@ -2,7 +2,9 @@ - + + Main.cs + \ No newline at end of file diff --git a/Modules/ExtendedPlayerControl.cs b/Modules/ExtendedPlayerControl.cs index d6287be76..3557b262f 100644 --- a/Modules/ExtendedPlayerControl.cs +++ b/Modules/ExtendedPlayerControl.cs @@ -943,7 +943,7 @@ internal static class ExtendedPlayerControl if (player.GetCustomRole() is not CustomRoles.Necromancer and not CustomRoles.Deathknight and not CustomRoles.Refugee and not CustomRoles.Sidekick) return; } - if (!player.CanUseKillButton() && !AntiBlackout.SkipTasks) return; + if (!player.CanUseKillButton() && !AntiBlackout.SkipTasks && !IntroCutsceneDestroyPatch.PreventKill) return; player.AddKillTimerToDict(cd: time); if (target == null) target = player; @@ -1356,7 +1356,7 @@ internal static class ExtendedPlayerControl public static bool CanUseKillButton(this PlayerControl pc) { - if (AntiBlackout.SkipTasks || TimeMaster.Rewinding || !Main.IntroDestroyed || !pc.IsAlive()) return false; + if (AntiBlackout.SkipTasks || TimeMaster.Rewinding || !Main.IntroDestroyed || IntroCutsceneDestroyPatch.PreventKill || !pc.IsAlive()) return false; switch (Options.CurrentGameMode) { diff --git a/Modules/GameState.cs b/Modules/GameState.cs index af179ce12..82477807f 100644 --- a/Modules/GameState.cs +++ b/Modules/GameState.cs @@ -193,8 +193,6 @@ public class PlayerState(byte playerId) Utils.NotifyRoles(SpecifySeer: Player); Utils.NotifyRoles(SpecifyTarget: Player); - - HudSpritePatch.ResetButtonIcons = true; } CheckMurderPatch.TimeSinceLastKill.Remove(PlayerId); @@ -228,9 +226,6 @@ public class PlayerState(byte playerId) SetAddonCountTypes(role); - if (Main.IntroDestroyed && GameStates.InGame) - HudSpritePatch.ResetButtonIcons = true; - Logger.Info($" ID {PlayerId} ({Player?.GetRealName()}) => {role}, CountTypes => {countTypes}", "SetSubRole"); } diff --git a/Patches/GameOptionsMenuPatch.cs b/Patches/GameOptionsMenuPatch.cs index d72f67614..573f7ea73 100644 --- a/Patches/GameOptionsMenuPatch.cs +++ b/Patches/GameOptionsMenuPatch.cs @@ -473,14 +473,14 @@ public static class ToggleOptionPatch OptionItem item = OptionItem.AllOptions[index]; CustomGameMode gm = Options.CurrentGameMode; - Color32 color = gm == CustomGameMode.Standard ? item.Tab switch + Color32 color = gm == CustomGameMode.Standard ? (TabGroup)(ModGameOptionsMenu.TabIndex - 3) switch { - TabGroup.ImpostorRoles => new(255, 25, 25, 255), - TabGroup.CrewmateRoles => new(140, 255, 255, 255), - TabGroup.NeutralRoles => new(255, 171, 27, 255), - TabGroup.CovenRoles => new(123, 63, 187, 255), - _ => new(0, 165, 255, 255) - } : Main.GameModeColors.TryGetValue(gm, out var c) ? c : new(0, 165, 255, 255); + TabGroup.ImpostorRoles => new Color32(255, 25, 25, 255), + TabGroup.CrewmateRoles => new Color32(140, 255, 255, 255), + TabGroup.NeutralRoles => new Color32(255, 171, 27, 255), + TabGroup.CovenRoles => new Color32(123, 63, 187, 255), + _ => new Color32(0, 165, 255, 255) + } : Main.GameModeColors.TryGetValue(gm, out var c) ? c : new Color32(0, 165, 255, 255); __instance.CheckMark.sprite = Utils.LoadSprite("EHR.Resources.Images.Checkmark.png", 100f); __instance.CheckMark.color = color; var renderer = __instance.CheckMark.transform.parent.FindChild("ActiveSprite").GetComponent(); diff --git a/Patches/HudPatch.cs b/Patches/HudPatch.cs index a00b19a74..b38d1e29c 100644 --- a/Patches/HudPatch.cs +++ b/Patches/HudPatch.cs @@ -380,10 +380,10 @@ internal static class HudManagerPatch else button = null; - if (button != null) + if (button == __instance.AbilityButton) { - button.SetUsesRemaining((int)abilityUseLimit); button.usesRemainingSprite.color = Utils.GetRoleColor(role); + button.SetUsesRemaining((int)abilityUseLimit); } } } @@ -1152,7 +1152,10 @@ internal static class TaskPanelBehaviourPatch if (Options.CurrentGameMode is CustomGameMode.Standard or CustomGameMode.MoveAndStop or CustomGameMode.HideAndSeek or CustomGameMode.Speedrun) { var tabText = __instance.tab.transform.FindChild("TabText_TMP").GetComponent(); - tabText.SetText($"{TranslationController.Instance.GetString(StringNames.Tasks)}{Utils.GetTaskCount(PlayerControl.LocalPlayer.PlayerId, Utils.IsActive(SystemTypes.Comms))}"); + bool fakeTasks = Options.CurrentGameMode == CustomGameMode.Standard && !Utils.HasTasks(PlayerControl.LocalPlayer.Data, forRecompute: false); + string sideText = TranslationController.Instance.GetString(fakeTasks ? StringNames.FakeTasks : StringNames.Tasks); + if (fakeTasks) sideText = Utils.ColorString(Utils.GetRoleColor(CustomRoles.ImpostorEHR), sideText.TrimEnd(':')); + tabText.SetText($"{sideText}{Utils.GetTaskCount(PlayerControl.LocalPlayer.PlayerId, Utils.IsActive(SystemTypes.Comms))}"); } else { diff --git a/Patches/HudSpritePatch.cs b/Patches/HudSpritePatch.cs index 284686b55..93090858e 100644 --- a/Patches/HudSpritePatch.cs +++ b/Patches/HudSpritePatch.cs @@ -19,19 +19,9 @@ public static class CustomButton //[HarmonyPatch(typeof(HudManager), nameof(HudManager.Update))] public static class HudSpritePatch { - private static Sprite Kill; - private static Sprite Ability; - private static Sprite Vent; - private static Sprite Sabotage; - private static Sprite Pet; - private static Sprite Report; - public static Sprite[] DefaultIcons = []; - private static long LastErrorTime; - public static bool ResetButtonIcons; - public static void Postfix(HudManager __instance) { try @@ -41,39 +31,19 @@ public static class HudSpritePatch if (!Main.EnableCustomButton.Value || !Main.ProcessShapeshifts || Mastermind.ManipulatedPlayers.ContainsKey(player.PlayerId) || ExileController.Instance || GameStates.IsMeeting) return; if ((!SetHudActivePatch.IsActive && !MeetingStates.FirstMeeting) || !player.IsAlive()) return; - - if (ResetButtonIcons || !AmongUsClient.Instance.IsGameStarted || !Main.IntroDestroyed || GameStates.IsLobby || GameStates.IsNotJoined || !GameStates.InGame) - { - Kill = null; - Ability = null; - Vent = null; - Sabotage = null; - Pet = null; - Report = null; - - ResetButtonIcons = false; - return; - } - - bool shapeshifting = player.IsShifted(); + if (!AmongUsClient.Instance.IsGameStarted || !Main.IntroDestroyed || GameStates.IsLobby || GameStates.IsNotJoined || !GameStates.InGame || IntroCutsceneDestroyPatch.PreventKill) return; if (DefaultIcons.Length == 0) return; - if (!Kill) Kill = DefaultIcons[0]; - if (!Ability) Ability = DefaultIcons[1]; - if (!Vent) Vent = DefaultIcons[2]; - if (!Sabotage) Sabotage = DefaultIcons[3]; - if (!Pet) Pet = DefaultIcons[4]; - if (!Report) Report = DefaultIcons[5]; - - Sprite newKillButton = Kill; - Sprite newAbilityButton = Ability; - Sprite newVentButton = Vent; - Sprite newSabotageButton = Sabotage; - Sprite newPetButton = Pet; - Sprite newReportButton = Report; + Sprite newKillButton = DefaultIcons[0]; + Sprite newAbilityButton = DefaultIcons[1]; + Sprite newVentButton = DefaultIcons[2]; + Sprite newSabotageButton = DefaultIcons[3]; + Sprite newPetButton = DefaultIcons[4]; + Sprite newReportButton = DefaultIcons[5]; bool usesPetInsteadOfKill = player.UsesPetInsteadOfKill(); + bool shapeshifting = player.IsShifted(); switch (player.GetCustomRole()) { @@ -112,7 +82,7 @@ public static class HudSpritePatch } case CustomRoles.Echo: { - newAbilityButton = player.IsShifted() ? Kill : CustomButton.Get("Puttpuer"); + newAbilityButton = player.IsShifted() ? newKillButton : CustomButton.Get("Puttpuer"); break; } case CustomRoles.Shifter: @@ -488,7 +458,7 @@ public static class HudSpritePatch foreach (var button in new ActionButton[] { __instance.KillButton, __instance.AbilityButton, __instance.ImpostorVentButton, __instance.SabotageButton, __instance.PetButton, __instance.ReportButton }) { button.OverrideColor(roleColor); - button.buttonLabelText.color = roleColor; + button.buttonLabelText.SetOutlineColor(roleColor); } return; diff --git a/Patches/IntroPatch.cs b/Patches/IntroPatch.cs index 433cc90bc..ec66d1fc0 100644 --- a/Patches/IntroPatch.cs +++ b/Patches/IntroPatch.cs @@ -20,7 +20,7 @@ static class ShowRoleMoveNextPatchAndroid { public static void Postfix(IntroCutscene._ShowRole_d__40 __instance, ref bool __result) { - if (AmongUsClient.Instance.AmHost || __instance.__1__state != 1 || !__result) return; + if (__instance.__1__state != 1 || !__result) return; GameStates.InGame = true; SetUpRoleTextPatch.Postfix(__instance.__4__this); @@ -32,7 +32,7 @@ static class ShowRoleMoveNextPatch { public static void Postfix(IntroCutscene._ShowRole_d__41 __instance, ref bool __result) { - if (AmongUsClient.Instance.AmHost || __instance.__1__state != 1 || !__result) return; + if (__instance.__1__state != 1 || !__result) return; GameStates.InGame = true; SetUpRoleTextPatch.Postfix(__instance.__4__this); @@ -45,14 +45,10 @@ static class ShowRoleMoveNextPatch [HarmonyPatch(typeof(HudManager), nameof(HudManager.CoShowIntro))] static class CoShowIntroPatch { - public static bool IntroStarted; - public static bool Prefix(HudManager __instance) { if (!AmongUsClient.Instance.AmHost || !GameStates.IsModHost) return true; - IntroStarted = true; - Utils.SetupLongRoleDescriptions(); LateTask.New(() => @@ -151,7 +147,7 @@ static class CoShowIntroPatch } } -[HarmonyPatch(typeof(IntroCutscene), nameof(IntroCutscene.ShowRole))] +//[HarmonyPatch(typeof(IntroCutscene), nameof(IntroCutscene.ShowRole))] internal static class SetUpRoleTextPatch { public static bool IsInIntro; @@ -1050,11 +1046,14 @@ internal static class BeginImpostorPatch [HarmonyPatch(typeof(HudManager), nameof(HudManager.OnGameStart))] internal static class IntroCutsceneDestroyPatch { + public static bool PreventKill; public static void Postfix( /*IntroCutscene __instance*/) { if (!GameStates.IsInGame) return; Main.IntroDestroyed = true; + PreventKill = true; + LateTask.New(() => PreventKill = false, 5f, "PreventKillReset"); // Set roleAssigned as false for overriding roles for modded players // for vanilla clients we use "Data.Disconnected" @@ -1088,15 +1087,15 @@ internal static class IntroCutsceneDestroyPatch { x.ResetKillCooldown(false); - if (Main.AllPlayerKillCooldown.TryGetValue(x.PlayerId, out float kcd) && kcd - 2f > 0f) - x.SetKillCooldown(kcd - 2f); + if (Main.AllPlayerKillCooldown.TryGetValue(x.PlayerId, out float kcd)) + x.SetKillCooldown(kcd); }); }, 2f, "FixKillCooldownTask"); } else { int kcd = Options.StartingKillCooldown.GetInt(); - LateTask.New(() => aapc.Do(x => x.SetKillCooldown(kcd - 2)), 2f, "FixKillCooldownTask"); + LateTask.New(() => aapc.Do(x => x.SetKillCooldown(kcd)), 2f, "FixKillCooldownTask"); } } } @@ -1121,7 +1120,7 @@ internal static class IntroCutsceneDestroyPatch { lp.RpcResetAbilityCooldown(); lp.SetKillCooldown(10f); - }, 0.2f, log: false); + }, 0.8f, log: false); StartGameHostPatch.RpcSetRoleReplacer.SetActualSelfRolesAfterOverride(); }, 0.1f, log: false); @@ -1277,9 +1276,7 @@ internal static class IntroCutsceneDestroyPatch pc.TP(new Vector2(3.32f, -26.57f)); } } - - if (HudSpritePatch.DefaultIcons.Length > 0) return; - + HudManager hud = FastDestroyableSingleton.Instance; HudSpritePatch.DefaultIcons = @@ -1299,7 +1296,4 @@ internal static class IntroCutsceneDestroyPatch PlayerControl.LocalPlayer.NetTransform.SnapTo(new(15.5f, 0.0f), (ushort)(PlayerControl.LocalPlayer.NetTransform.lastSequenceId + 8)); }, 4f, "Airship Spawn FailSafe"); } - -} - - +} \ No newline at end of file diff --git a/Patches/OnGameStartedPatch.cs b/Patches/OnGameStartedPatch.cs index 81edf5462..28df9707f 100644 --- a/Patches/OnGameStartedPatch.cs +++ b/Patches/OnGameStartedPatch.cs @@ -286,8 +286,6 @@ internal static class ChangeRoleSettings GameEndChecker.Ended = false; ReportDeadBodyPatch.MeetingStarted = false; - HudSpritePatch.ResetButtonIcons = true; - ShipStatusFixedUpdatePatch.ClosestVent = []; ShipStatusFixedUpdatePatch.CanUseClosestVent = []; @@ -306,7 +304,6 @@ internal static class ChangeRoleSettings Main.LastNotifyNames = []; CheckForEndVotingPatch.EjectionText = string.Empty; - CoShowIntroPatch.IntroStarted = false; Arsonist.CurrentDousingTarget = byte.MaxValue; Revolutionist.CurrentDrawTarget = byte.MaxValue; @@ -474,8 +471,6 @@ internal static class StartGameHostPatch public static readonly Dictionary> BasisChangingAddons = []; private static Dictionary RoleTypeNums = []; - public static readonly Dictionary DataDisconnected = []; - private static RoleOptionsCollectionV10 RoleOpt => Main.NormalOptions.roleOptions; private static void UpdateRoleTypeNums() diff --git a/Patches/PlayerControlPatch.cs b/Patches/PlayerControlPatch.cs index fdddbaee0..181b4c1a9 100644 --- a/Patches/PlayerControlPatch.cs +++ b/Patches/PlayerControlPatch.cs @@ -1174,8 +1174,6 @@ internal static class ReportDeadBodyPatch Damocles.CountRepairSabotage = false; Stressed.CountRepairSabotage = false; - HudSpritePatch.ResetButtonIcons = true; - if (Options.CurrentGameMode == CustomGameMode.Standard) { foreach (byte id in Main.DiedThisRound)