Add toggles to disable abilities upon use / vote

This commit is contained in:
Atony committed 2026-08-30 18:24:35 -05:00
1 parent 027d4763f3
commit 6c7b362f95
2 files changed
+38 -1

No files matched your search

@@ -71,6 +71,26 @@ public abstract class MeetingActionButton
/// </summary>
public bool TimerPaused { get; set; }
/// <summary>
/// Gets or sets a value indicating how many times the ability was used in the current meeting.
/// </summary>
public int UsesSoFar { get; set; }
/// <summary>
/// Gets a value determining if the abiity is disabled upon being used.
/// </summary>
public virtual bool DisableUponUse => false;
/// <summary>
/// Gets a value determining if the abiity is disabled upon voting.
/// </summary>
public virtual bool DisableUponVoting => false;
/// <summary>
/// Gets a value determining if the abiity is hidden when votes wrapping up.
/// </summary>
public virtual bool HideUponWrapUp => false;
/// <summary>
/// Gets or sets the amount of uses left.
/// </summary>
@@ -107,6 +127,7 @@ public abstract class MeetingActionButton
Button.graphic.sprite = Sprite.LoadAsset();
Button.SetUsesRemaining(UsesLeft);
UsesSoFar = 0;
if (MaxUses <= 0)
{
Button.SetInfiniteUses();
@@ -264,7 +285,9 @@ public abstract class MeetingActionButton
/// <returns>A value that represents whether the button should light up or not.</returns>
public virtual bool CanUse()
{
return !LimitedUses || UsesLeft > 0;
return (!DisableUponUse || UsesSoFar < 1) &&
(!DisableUponVoting || MeetingHud.Instance.CurrentState is not MeetingHud.MeetingStates.Voted) &&
(!LimitedUses || UsesLeft > 0);
}
/// <summary>
@@ -287,6 +310,11 @@ public abstract class MeetingActionButton
Timer = Cooldown;
OnClick();
UsesSoFar++;
if (DisableUponUse && Button)
{
Button!.SetDisabled();
}
}
/// <summary>
@@ -111,6 +111,15 @@ internal static class MeetingHudPatches
[HarmonyPatch(nameof(MeetingHud.VotingComplete))]
public static void VotingCompletePatch(MeetingHud __instance)
{
foreach (var meetingAbility in MeetingButtonManager.UntargetedButtons.Where(x => x.Enabled(PlayerControl.LocalPlayer.Data.Role) &&
(x.DisableUponVoting || x.HideUponWrapUp)))
{
meetingAbility.UpdateHandler(__instance);
if (meetingAbility.Button)
{
meetingAbility.Button!.SetDisabled();
}
}
MiraEventManager.InvokeEvent(new VotingCompleteEvent(__instance));
}