diff --git a/MiraAPI/Patches/HudManagerPatches.cs b/MiraAPI/Patches/HudManagerPatches.cs
index cdef7cc..ddd31f8 100644
--- a/MiraAPI/Patches/HudManagerPatches.cs
+++ b/MiraAPI/Patches/HudManagerPatches.cs
@@ -1,5 +1,6 @@
using HarmonyLib;
using MiraAPI.Hud;
+using MiraAPI.Roles;
using Reactor.Utilities.Extensions;
using UnityEngine;
using Object = UnityEngine.Object;
@@ -92,10 +93,44 @@ public static class HudManagerPatches
{
return;
}
+ if (CustomRoleManager.GetCustomRoleBehaviour(role.Role, out var customRole))
+ {
+ if (customRole.CanUseSabotage)
+ {
+ __instance.SabotageButton.gameObject.SetActive(true);
+ }
+ else
+ {
+ __instance.SabotageButton.gameObject.SetActive(role.IsImpostor && isActive);
+ }
+ }
foreach (var button in CustomButtonManager.CustomButtons)
{
button.SetActive(isActive, role);
}
}
+
+ ///
+ /// Patches the Sabotage button to check if the player's custom role can use sabotage.
+ ///
+ [HarmonyPatch(typeof(SabotageButton), nameof(SabotageButton.DoClick))]
+ [HarmonyPrefix]
+ public static bool StartPrefix(SabotageButton __instance)
+ {
+
+ var player = PlayerControl.LocalPlayer;
+
+ if (CustomRoleManager.GetCustomRoleBehaviour(player.Data.Role.Role, out var customRole))
+ {
+ if (!customRole.CanUseSabotage) return false;
+
+ DestroyableSingleton.Instance.ToggleMapVisible(new MapOptions()
+ {
+ Mode = MapOptions.Modes.Sabotage
+ });
+ return false;
+ }
+ return true;
+ }
}
diff --git a/MiraAPI/Roles/ICustomRole.cs b/MiraAPI/Roles/ICustomRole.cs
index 3087dbe..9fc2b61 100644
--- a/MiraAPI/Roles/ICustomRole.cs
+++ b/MiraAPI/Roles/ICustomRole.cs
@@ -77,6 +77,11 @@ public interface ICustomRole
///
bool CanUseVent => Team == ModdedRoleTeams.Impostor;
+ ///
+ /// Gets a value indicating whether the role can use the sabotage button.
+ ///
+ bool CanUseSabotage => Team == ModdedRoleTeams.Impostor;
+
///
/// Gets a value indicating whether the role's tasks count towards task progress.
///