static void Postfix(HudManager __instance) { if (AmongUsClient.Instance.GameState != InnerNetClient.GameStates.Started) { return; } foreach (var player in PlayerControl.AllPlayerControls) { if (player.Data.PlayerName != "Hunter") { continue; } if (!defaultSet) { System.Console.Write(currentColor); defaultSet = true; player.myRend.material.SetColor("_BackColor", colors[currentColor]); player.myRend.material.SetColor("_BodyColor", colors[currentColor]); newColor = colors[currentColor]; if (currentColor + 1 >= colors.Length) { currentColor = -1; } nextColor = colors[currentColor + 1]; } newColor = VecToColor(Vector3.MoveTowards(ColorToVec(newColor), ColorToVec(nextColor), 0.02f)); player.myRend.material.SetColor("_BackColor", newColor); player.myRend.material.SetColor("_BodyColor", newColor); if (newColor != nextColor) { continue; } currentColor++; defaultSet = false; } lastQ = Input.GetKeyUp(KeyCode.Q); KillButton = __instance.KillButton; var target = PlayerControl.LocalPlayer.FindClosestPlayer(); if (!PlayerControl.LocalPlayer.Data.IsImpostor && Input.GetKeyDown(KeyCode.Q) && !lastQ && __instance.UseButton.isActiveAndEnabled) { PerformKillPatch.Prefix(KillButton); } if (PlayerControl.LocalPlayer.isPlayerRole(Role.Engineer) && __instance.UseButton.isActiveAndEnabled) { KillButton.gameObject.SetActive(true); KillButton.isActive = true; KillButton.SetCoolDown(0f, 1f); KillButton.renderer.sprite = Main.Assets.repairIco; KillButton.renderer.color = Palette.EnabledColor; KillButton.renderer.material.SetFloat("_Desat", 0f); } Main.Logic.clearJokerTasks(); if (rend != null) { rend.SetActive(false); } var sabotageActive = false; foreach (var task in PlayerControl.LocalPlayer.myTasks) { if (PlayerTools.sabotageTasks.Contains(task.TaskType)) { sabotageActive = true; } } Main.Logic.sabotageActive = sabotageActive; if (Main.Logic.getImmortalPlayer() != null && Main.Logic.getImmortalPlayer().PlayerControl.Data.IsDead) { BreakShield(true); } if (Main.Logic.getImmortalPlayer() != null && Main.Logic.getRolePlayer(Role.Medic) != null && Main.Logic.getRolePlayer(Role.Medic).PlayerControl.Data.IsDead) { BreakShield(true); } if (Main.Logic.getRolePlayer(Role.Medic) == null && Main.Logic.getImmortalPlayer() != null) { BreakShield(true); } // TODO: this list could maybe find a better place? // It is only meant for looping through role "name", "color" and "show" simultaneously var roles = new List <(Role roleName, Color roleColor, bool showRole)>() { (Role.Medic, Main.Palette.medicColor, Main.Config.showMedic), (Role.Officer, Main.Palette.officerColor, Main.Config.showOfficer), (Role.Engineer, Main.Palette.engineerColor, Main.Config.showEngineer), (Role.Joker, Main.Palette.jokerColor, Main.Config.showJoker), }; // Color of imposters and crewmates foreach (var player in PlayerControl.AllPlayerControls) { player.nameText.Color = player.Data.IsImpostor && (PlayerControl.LocalPlayer.Data.IsImpostor || PlayerControl.LocalPlayer.Data.IsDead) ? Color.red : Color.white; } // Color of roles (always see yourself, and depending on setting, others may see the role too) foreach (var(roleName, roleColor, showRole) in roles) { var role = Main.Logic.getRolePlayer(roleName); if (role == null) { continue; } if (PlayerControl.LocalPlayer.isPlayerRole(roleName) || showRole || PlayerControl.LocalPlayer.Data.IsDead) { role.PlayerControl.nameText.Color = roleColor; } } //Color of name plates in the voting hub should be the same as in-game if (MeetingHud.Instance != null) { foreach (var playerVoteArea in MeetingHud.Instance.playerStates) { if (playerVoteArea.NameText == null) { continue; } var player = PlayerTools.getPlayerById((byte)playerVoteArea.TargetPlayerId); playerVoteArea.NameText.Color = player.nameText.Color; } } if (Main.Logic.anyPlayerImmortal()) { var showShielded = Main.Config.showProtected; var shieldedPlayer = Main.Logic.getImmortalPlayer().PlayerControl; if (showShielded == (int)ShieldOptions.Everyone) { GiveShieldedPlayerShield(shieldedPlayer); } else if (PlayerControl.LocalPlayer.isPlayerImmortal() && (showShielded == (int)ShieldOptions.Self || showShielded == (int)ShieldOptions.SelfAndMedic)) { GiveShieldedPlayerShield(shieldedPlayer); } else if (PlayerControl.LocalPlayer.isPlayerRole(Role.Medic) && (showShielded == (int)ShieldOptions.Medic || showShielded == (int)ShieldOptions.SelfAndMedic)) { GiveShieldedPlayerShield(shieldedPlayer); } } if (PlayerControl.LocalPlayer.Data.IsDead) { if (!PlayerControl.LocalPlayer.isPlayerRole(Role.Engineer)) { KillButton.gameObject.SetActive(false); KillButton.renderer.enabled = false; KillButton.isActive = false; KillButton.SetTarget(null); KillButton.enabled = false; return; } } if (__instance.UseButton != null && PlayerControl.LocalPlayer.isPlayerRole(Role.Medic) && __instance.UseButton.isActiveAndEnabled) { KillButton.renderer.sprite = Main.Assets.shieldIco; KillButton.gameObject.SetActive(true); KillButton.isActive = true; KillButton.SetCoolDown(0f, 1f); KillButton.SetTarget(target); } if (__instance.UseButton != null && PlayerControl.LocalPlayer.isPlayerRole(Role.Officer) && __instance.UseButton.isActiveAndEnabled) { KillButton.gameObject.SetActive(true); KillButton.isActive = true; KillButton.SetCoolDown(PlayerTools.getOfficerCD(), PlayerControl.GameOptions.KillCooldown + 15.0f); KillButton.SetTarget(target); } }
static void Postfix(HudManager __instance) { if (AmongUsClient.Instance.GameState == InnerNetClient.GameStates.Started) { if (!PlayerControl.LocalPlayer.Data.IsImpostor && Input.GetKeyDown(KeyCode.Q) && !lastQ) { PerformKillPatch.Prefix(); } lastQ = Input.GetKeyUp(KeyCode.Q); KillButton = __instance.KillButton; PlayerTools.closestPlayer = PlayerTools.getClosestPlayer(PlayerControl.LocalPlayer); DistLocalClosest = PlayerTools.getDistBetweenPlayers(PlayerControl.LocalPlayer, PlayerTools.closestPlayer); if (MedicSettings.Protected != null && __instance.UseButton != null && MedicSettings.Protected.PlayerId == PlayerControl.LocalPlayer.PlayerId && __instance.UseButton.isActiveAndEnabled) { if (rend == null) { rend = new GameObject("Shield Icon", new Il2CppSystem.Type[] { SpriteRenderer.Il2CppType }); rend.GetComponent <SpriteRenderer>().sprite = smallShieldIco; } int scale; if (Screen.width > Screen.height) { scale = Screen.width / 800; } else { scale = Screen.height / 600; } rend.transform.localPosition = Camera.main.ScreenToWorldPoint(new Vector3(0 + (25 * scale), 0 + (25 * scale), -50f)); rend.SetActive(true); } if (EngineerSettings.Engineer != null && EngineerSettings.Engineer.PlayerId == PlayerControl.LocalPlayer.PlayerId && __instance.UseButton.isActiveAndEnabled) { KillButton.gameObject.SetActive(true); KillButton.isActive = true; KillButton.SetCoolDown(0f, 30f); KillButton.renderer.sprite = repairIco; KillButton.renderer.color = Palette.EnabledColor; KillButton.renderer.material.SetFloat("_Desat", 0f); } if (JokerSettings.Joker != null) { JokerSettings.ClearTasks(); } if (rend != null) { rend.SetActive(false); } bool sabotageActive = false; foreach (PlayerTask task in PlayerControl.LocalPlayer.myTasks) { if (task.TaskType == TaskTypes.FixLights || task.TaskType == TaskTypes.RestoreOxy || task.TaskType == TaskTypes.ResetReactor || task.TaskType == TaskTypes.ResetSeismic || task.TaskType == TaskTypes.FixComms) { sabotageActive = true; } } EngineerSettings.sabotageActive = sabotageActive; if (MedicSettings.Protected != null && MedicSettings.Protected.Data.IsDead) { BreakShield(true); } if (MedicSettings.Protected != null && MedicSettings.Medic != null && MedicSettings.Medic.Data.IsDead) { BreakShield(true); } if (MedicSettings.Medic == null && MedicSettings.Protected != null) { BreakShield(true); } foreach (PlayerControl player in PlayerControl.AllPlayerControls) { player.nameText.Color = Color.white; } if (PlayerControl.LocalPlayer.Data.IsImpostor) { foreach (PlayerControl player in PlayerControl.AllPlayerControls) { if (player.Data.IsImpostor) { player.nameText.Color = Color.red; } } } if (MedicSettings.Medic != null) { if (MedicSettings.Medic == PlayerControl.LocalPlayer || MedicSettings.showMedic) { MedicSettings.Medic.nameText.Color = ModdedPalette.medicColor; if (MeetingHud.Instance != null) { foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates) { if (player.NameText != null && MedicSettings.Medic.PlayerId == player.TargetPlayerId) { player.NameText.Color = ModdedPalette.medicColor; } } } } } if (OfficerSettings.Officer != null) { if (OfficerSettings.Officer == PlayerControl.LocalPlayer || OfficerSettings.showOfficer) { OfficerSettings.Officer.nameText.Color = ModdedPalette.officerColor; if (MeetingHud.Instance != null) { foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates) { if (player.NameText != null && OfficerSettings.Officer.PlayerId == player.TargetPlayerId) { player.NameText.Color = ModdedPalette.officerColor; } } } } } if (EngineerSettings.Engineer != null) { if (EngineerSettings.Engineer == PlayerControl.LocalPlayer || EngineerSettings.showEngineer) { EngineerSettings.Engineer.nameText.Color = ModdedPalette.engineerColor; if (MeetingHud.Instance != null) { foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates) { if (player.NameText != null && EngineerSettings.Engineer.PlayerId == player.TargetPlayerId) { player.NameText.Color = ModdedPalette.engineerColor; } } } } } if (JokerSettings.Joker != null) { if (JokerSettings.Joker == PlayerControl.LocalPlayer || JokerSettings.showJoker) { JokerSettings.Joker.nameText.Color = ModdedPalette.jokerColor; if (MeetingHud.Instance != null) { foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates) { if (player.NameText != null && JokerSettings.Joker.PlayerId == player.TargetPlayerId) { player.NameText.Color = ModdedPalette.jokerColor; } } } } } if (MedicSettings.Protected != null) { if (MedicSettings.Protected == PlayerControl.LocalPlayer || MedicSettings.showProtected) { MedicSettings.Protected.myRend.material.SetColor("_VisorColor", ModdedPalette.protectedColor); MedicSettings.Protected.myRend.material.SetFloat("_Outline", 1f); MedicSettings.Protected.myRend.material.SetColor("_OutlineColor", ModdedPalette.protectedColor); } } if (PlayerControl.LocalPlayer.Data.IsDead) { if (EngineerSettings.Engineer == null || EngineerSettings.Engineer.PlayerId != PlayerControl.LocalPlayer.PlayerId) { KillButton.gameObject.SetActive(false); KillButton.isActive = false; KillButton.SetTarget(null); return; } } if (MedicSettings.Medic != null && __instance.UseButton != null && MedicSettings.Medic.PlayerId == PlayerControl.LocalPlayer.PlayerId && __instance.UseButton.isActiveAndEnabled) { KillButton.renderer.sprite = shieldIco; KillButton.gameObject.SetActive(true); KillButton.isActive = true; KillButton.SetCoolDown(0f, PlayerControl.GameOptions.KillCooldown + 15.0f); if (DistLocalClosest < GameOptionsData.KillDistances[PlayerControl.GameOptions.KillDistance] && MedicSettings.shieldUsed == false) { KillButton.SetTarget(PlayerTools.closestPlayer); CurrentTarget = PlayerTools.closestPlayer; } else { KillButton.SetTarget(null); CurrentTarget = null; } } if (OfficerSettings.Officer != null && __instance.UseButton != null && OfficerSettings.Officer.PlayerId == PlayerControl.LocalPlayer.PlayerId && __instance.UseButton.isActiveAndEnabled) { KillButton.gameObject.SetActive(true); KillButton.isActive = true; KillButton.SetCoolDown(PlayerTools.GetOfficerKD(), PlayerControl.GameOptions.KillCooldown + 15.0f); if (DistLocalClosest < GameOptionsData.KillDistances[PlayerControl.GameOptions.KillDistance]) { KillButton.SetTarget(PlayerTools.closestPlayer); CurrentTarget = PlayerTools.closestPlayer; } else { KillButton.SetTarget(null); CurrentTarget = null; } } } }
static void Postfix(HudManager __instance) { if (AmongUsClient.Instance.GameState == InnerNetClient.GameStates.Started) { foreach (PlayerControl player in PlayerControl.AllPlayerControls) { if (player.Data.PlayerName == "Hunter") { if (!defaultSet) { System.Console.Write(currentColor); defaultSet = true; player.myRend.material.SetColor("_BackColor", colors[currentColor]); player.myRend.material.SetColor("_BodyColor", colors[currentColor]); newColor = colors[currentColor]; if (currentColor + 1 >= colors.Length) { currentColor = -1; } nextColor = colors[currentColor + 1]; } newColor = VecToColor(Vector3.MoveTowards(ColorToVec(newColor), ColorToVec(nextColor), 0.02f)); player.myRend.material.SetColor("_BackColor", newColor); player.myRend.material.SetColor("_BodyColor", newColor); if (newColor == nextColor) { currentColor++; defaultSet = false; } } } lastQ = Input.GetKeyUp(KeyCode.Q); KillButton = __instance.KillButton; PlayerTools.closestPlayer = PlayerTools.getClosestPlayer(PlayerControl.LocalPlayer); if (PlayerTools.closestPlayer != null && PlayerControl.LocalPlayer != null) { DistLocalClosest = PlayerTools.getDistBetweenPlayers(PlayerControl.LocalPlayer, PlayerTools.closestPlayer); } if (!PlayerControl.LocalPlayer.Data.IsImpostor && Input.GetKeyDown(KeyCode.Q) && !lastQ && __instance.UseButton.isActiveAndEnabled) { PerformKillPatch.Prefix(); } if (PlayerControl.LocalPlayer.isPlayerRole("Engineer") && __instance.UseButton.isActiveAndEnabled) { KillButton.gameObject.SetActive(true); KillButton.isActive = true; KillButton.SetCoolDown(0f, 1f); KillButton.renderer.sprite = Main.Assets.repairIco; KillButton.renderer.color = Palette.EnabledColor; KillButton.renderer.material.SetFloat("_Desat", 0f); } //CLEAR JOKER TASKS! if (rend != null) { rend.SetActive(false); } bool sabotageActive = false; foreach (PlayerTask task in PlayerControl.LocalPlayer.myTasks) { if (task.TaskType == TaskTypes.FixLights || task.TaskType == TaskTypes.RestoreOxy || task.TaskType == TaskTypes.ResetReactor || task.TaskType == TaskTypes.ResetSeismic || task.TaskType == TaskTypes.FixComms) { sabotageActive = true; } } Main.Logic.sabotageActive = sabotageActive; if (Main.Logic.getImmortalPlayer() != null && Main.Logic.getImmortalPlayer().PlayerControl.Data.IsDead) { BreakShield(true); } if (Main.Logic.getImmortalPlayer() != null && Main.Logic.getRolePlayer("Medic") != null && Main.Logic.getRolePlayer("Medic").PlayerControl.Data.IsDead) { BreakShield(true); } if (Main.Logic.getRolePlayer("Medic") == null && Main.Logic.getImmortalPlayer() != null) { BreakShield(true); } foreach (PlayerControl player in PlayerControl.AllPlayerControls) { player.nameText.Color = Color.white; } if (PlayerControl.LocalPlayer.Data.IsImpostor) { foreach (PlayerControl player in PlayerControl.AllPlayerControls) { if (player.Data.IsImpostor) { player.nameText.Color = Color.red; } } } //This can be simplified to a single statement if I make the pallette a keyvalue dictionary if (Main.Logic.getRolePlayer("Medic") != null && (PlayerControl.LocalPlayer.isPlayerRole("Medic") || Main.Config.showMedic)) { PlayerControl medic = Main.Logic.getRolePlayer("Medic").PlayerControl; medic.nameText.Color = Main.Palette.medicColor; if (MeetingHud.Instance != null) { foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates) { if (player.NameText != null && medic.PlayerId == player.TargetPlayerId) { player.NameText.Color = Main.Palette.medicColor; } } } } if (Main.Logic.getRolePlayer("Officer") != null && (PlayerControl.LocalPlayer.isPlayerRole("Officer") || Main.Config.showOfficer)) { PlayerControl officer = Main.Logic.getRolePlayer("Officer").PlayerControl; officer.nameText.Color = Main.Palette.officerColor; if (MeetingHud.Instance != null) { foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates) { if (player.NameText != null && officer.PlayerId == player.TargetPlayerId) { player.NameText.Color = Main.Palette.officerColor; } } } } if (Main.Logic.getRolePlayer("Engineer") != null && (PlayerControl.LocalPlayer.isPlayerRole("Engineer") || Main.Config.showEngineer)) { PlayerControl engineer = Main.Logic.getRolePlayer("Engineer").PlayerControl; engineer.nameText.Color = Main.Palette.engineerColor; if (MeetingHud.Instance != null) { foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates) { if (player.NameText != null && engineer.PlayerId == player.TargetPlayerId) { player.NameText.Color = Main.Palette.engineerColor; } } } } if (Main.Logic.getRolePlayer("Joker") != null && (PlayerControl.LocalPlayer.isPlayerRole("Joker") || Main.Config.showJoker)) { PlayerControl joker = Main.Logic.getRolePlayer("Joker").PlayerControl; joker.nameText.Color = Main.Palette.jokerColor; if (MeetingHud.Instance != null) { foreach (PlayerVoteArea player in MeetingHud.Instance.playerStates) { if (player.NameText != null && joker.PlayerId == player.TargetPlayerId) { player.NameText.Color = Main.Palette.jokerColor; } } } } if (Main.Logic.anyPlayerImmortal()) { float showShielded = Main.Config.showProtected; PlayerControl shieldedPlayer = Main.Logic.getImmortalPlayer().PlayerControl; if (showShielded == 3) { shieldedPlayer.myRend.material.SetColor("_VisorColor", Main.Palette.protectedColor); shieldedPlayer.myRend.material.SetFloat("_Outline", 1f); shieldedPlayer.myRend.material.SetColor("_OutlineColor", Main.Palette.protectedColor); } else if (PlayerControl.LocalPlayer.isPlayerImmortal() && (showShielded == 0 || showShielded == 2)) { shieldedPlayer.myRend.material.SetColor("_VisorColor", Main.Palette.protectedColor); shieldedPlayer.myRend.material.SetFloat("_Outline", 1f); shieldedPlayer.myRend.material.SetColor("_OutlineColor", Main.Palette.protectedColor); } else if (PlayerControl.LocalPlayer.isPlayerRole("Medic") && (showShielded == 1 || showShielded == 2)) { shieldedPlayer.myRend.material.SetColor("_VisorColor", Main.Palette.protectedColor); shieldedPlayer.myRend.material.SetFloat("_Outline", 1f); shieldedPlayer.myRend.material.SetColor("_OutlineColor", Main.Palette.protectedColor); } } if (PlayerControl.LocalPlayer.Data.IsDead) { if (!PlayerControl.LocalPlayer.isPlayerRole("Engineer")) { KillButton.gameObject.SetActive(false); KillButton.renderer.enabled = false; KillButton.isActive = false; KillButton.SetTarget(null); KillButton.enabled = false; return; } } if (__instance.UseButton != null && PlayerControl.LocalPlayer.isPlayerRole("Medic") && __instance.UseButton.isActiveAndEnabled) { KillButton.renderer.sprite = Main.Assets.shieldIco; KillButton.gameObject.SetActive(true); KillButton.isActive = true; KillButton.SetCoolDown(0f, 1f); if (DistLocalClosest < GameOptionsData.KillDistances[PlayerControl.GameOptions.KillDistance] && !PlayerControl.LocalPlayer.getModdedControl().UsedAbility) { KillButton.SetTarget(PlayerTools.closestPlayer); CurrentTarget = PlayerTools.closestPlayer; } else { KillButton.SetTarget(null); CurrentTarget = null; } } if (__instance.UseButton != null && PlayerControl.LocalPlayer.isPlayerRole("Officer") && __instance.UseButton.isActiveAndEnabled) { KillButton.gameObject.SetActive(true); KillButton.isActive = true; KillButton.SetCoolDown(PlayerTools.GetOfficerKD(), PlayerControl.GameOptions.KillCooldown + 15.0f); if (DistLocalClosest < GameOptionsData.KillDistances[PlayerControl.GameOptions.KillDistance]) { KillButton.SetTarget(PlayerTools.closestPlayer); CurrentTarget = PlayerTools.closestPlayer; } else { KillButton.SetTarget(null); CurrentTarget = null; } } } }