diff --git a/MiraAPI/Patches/DetectiveNotesMinigamePatch.cs b/MiraAPI/Patches/DetectiveNotesMinigamePatch.cs new file mode 100644 index 0000000..1324dde --- /dev/null +++ b/MiraAPI/Patches/DetectiveNotesMinigamePatch.cs @@ -0,0 +1,44 @@ +using System.Linq; +using AmongUs.GameOptions; +using HarmonyLib; +using Il2CppSystem.Collections.Generic; +using MiraAPI.Roles; +using UnityEngine; + +namespace MiraAPI.Patches; + +[HarmonyPatch(typeof(DetectiveNotesMinigame), nameof(DetectiveNotesMinigame.OpenBodyPopup))] +public static class DetectiveNotesMinigamePatch +{ + public static void Prefix(DetectiveNotesMinigame __instance, bool active) + { + __instance.impostorTypePopup.SetActive(active); + if (!active) + { + ControllerManager.Instance.CloseOverlayMenu(__instance.ImpostorOverlay); + ControllerManager.Instance.SetUpSelectables(ControllerManager.Instance.CurrentUiState, __instance.ControllerSelectable[0], __instance.ControllerSelectable); + ControllerManager.Instance.SetCurrentSelected(__instance.ControllerSelectable[2]); + return; + } + if (__instance.impostorButton != null) + { + ControllerManager.Instance.OpenOverlayMenu(__instance.ImpostorOverlay, null, __instance.ImpostorIconControllerSelectables[0], __instance.ImpostorIconControllerSelectables, false); + return; + } + __instance.impostorButton = new List(); + int num = 0; + var allRoles = DestroyableSingleton.Instance.AllRoles; + var customRoles = CustomRoleManager.CustomRoleBehaviours; + foreach (var role in allRoles) + { + if (role.TeamType != RoleTeamTypes.Impostor || role.Role == RoleTypes.ImpostorGhost || customRoles.Contains(role) ) + continue; + GameObject gameObject = Object.Instantiate(__instance.impostorTypePrefab, __instance.impostorTypeParent); + __instance.impostorButton.Add(gameObject); + gameObject.GetComponent().Initialize(__instance, role); + num++; + __instance.ImpostorIconControllerSelectables.Add(gameObject.GetComponent()); + } + ControllerManager.Instance.OpenOverlayMenu(__instance.ImpostorOverlay, null, __instance.ImpostorIconControllerSelectables[0], __instance.ImpostorIconControllerSelectables, false); + } +} \ No newline at end of file