mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 01:46:15 +00:00
Merge pull request #13 from CallOfCreator/dev
This commit is contained in:
4 files changed
+70
-1
No files matched your search
@@ -1,5 +1,6 @@
|
|||||||
using HarmonyLib;
|
using HarmonyLib;
|
||||||
using MiraAPI.Hud;
|
using MiraAPI.Hud;
|
||||||
|
using MiraAPI.Roles;
|
||||||
using Reactor.Utilities.Extensions;
|
using Reactor.Utilities.Extensions;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Object = UnityEngine.Object;
|
using Object = UnityEngine.Object;
|
||||||
|
|||||||
@@ -27,10 +27,11 @@ public static class HudManagerPatches
|
|||||||
{
|
{
|
||||||
var flag = localPlayer.Data != null && localPlayer.Data.IsDead;
|
var flag = localPlayer.Data != null && localPlayer.Data.IsDead;
|
||||||
|
|
||||||
if (role is ICustomRole)
|
if (role is ICustomRole customRole)
|
||||||
{
|
{
|
||||||
__instance.KillButton.ToggleVisible(isActive && role.CanUseKillButton && !flag);
|
__instance.KillButton.ToggleVisible(isActive && role.CanUseKillButton && !flag);
|
||||||
__instance.ImpostorVentButton.ToggleVisible(isActive && role.CanVent && !flag);
|
__instance.ImpostorVentButton.ToggleVisible(isActive && role.CanVent && !flag);
|
||||||
|
__instance.SabotageButton.gameObject.SetActive(isActive && customRole.CanUseSabotage);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_roleTab)
|
if (_roleTab)
|
||||||
|
|||||||
@@ -0,0 +1,62 @@
|
|||||||
|
using HarmonyLib;
|
||||||
|
using MiraAPI.Roles;
|
||||||
|
|
||||||
|
namespace MiraAPI.Patches.Roles;
|
||||||
|
|
||||||
|
[HarmonyPatch(typeof(SabotageButton))]
|
||||||
|
public class SabotageButtonPatch
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Patches the Sabotage button to check if the player's custom role can use sabotage.
|
||||||
|
/// </summary>
|
||||||
|
[HarmonyPatch(nameof(SabotageButton.DoClick))]
|
||||||
|
[HarmonyPrefix]
|
||||||
|
public static bool DoClickPrefix(SabotageButton __instance)
|
||||||
|
{
|
||||||
|
var player = PlayerControl.LocalPlayer;
|
||||||
|
|
||||||
|
if (player.Data.Role is not ICustomRole customRole)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!customRole.CanUseSabotage || PlayerControl.LocalPlayer.inVent || !GameManager.Instance.SabotagesEnabled())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
DestroyableSingleton<HudManager>.Instance.ToggleMapVisible(
|
||||||
|
new MapOptions
|
||||||
|
{
|
||||||
|
Mode = MapOptions.Modes.Sabotage,
|
||||||
|
});
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
[HarmonyPrefix]
|
||||||
|
[HarmonyPatch(nameof(SabotageButton.Refresh))]
|
||||||
|
public static bool RefreshPrefix(SabotageButton __instance)
|
||||||
|
{
|
||||||
|
var player = PlayerControl.LocalPlayer;
|
||||||
|
if (GameManager.Instance == null || player == null)
|
||||||
|
{
|
||||||
|
__instance.ToggleVisible(false);
|
||||||
|
__instance.SetDisabled();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player.Data.Role is not ICustomRole customRole)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player.inVent || !GameManager.Instance.SabotagesEnabled() || player.petting)
|
||||||
|
{
|
||||||
|
__instance.ToggleVisible(customRole.CanUseSabotage && GameManager.Instance.SabotagesEnabled());
|
||||||
|
__instance.SetDisabled();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
__instance.SetEnabled();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -77,6 +77,11 @@ public interface ICustomRole
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
bool CanUseVent => Team == ModdedRoleTeams.Impostor;
|
bool CanUseVent => Team == ModdedRoleTeams.Impostor;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets a value indicating whether the role can use the sabotage button.
|
||||||
|
/// </summary>
|
||||||
|
bool CanUseSabotage => Team == ModdedRoleTeams.Impostor;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets a value indicating whether the role's tasks count towards task progress.
|
/// Gets a value indicating whether the role's tasks count towards task progress.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in new issue
Block a user