mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-19 15:51:48 +00:00
Add toggles to disable abilities upon use / vote
This commit is contained in:
1 parent
027d4763f3
commit
6c7b362f95
2 files changed
+38
-1
No files matched your search
@@ -71,6 +71,26 @@ public abstract class MeetingActionButton
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public bool TimerPaused { get; set; }
|
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>
|
/// <summary>
|
||||||
/// Gets or sets the amount of uses left.
|
/// Gets or sets the amount of uses left.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -107,6 +127,7 @@ public abstract class MeetingActionButton
|
|||||||
Button.graphic.sprite = Sprite.LoadAsset();
|
Button.graphic.sprite = Sprite.LoadAsset();
|
||||||
|
|
||||||
Button.SetUsesRemaining(UsesLeft);
|
Button.SetUsesRemaining(UsesLeft);
|
||||||
|
UsesSoFar = 0;
|
||||||
if (MaxUses <= 0)
|
if (MaxUses <= 0)
|
||||||
{
|
{
|
||||||
Button.SetInfiniteUses();
|
Button.SetInfiniteUses();
|
||||||
@@ -264,7 +285,9 @@ public abstract class MeetingActionButton
|
|||||||
/// <returns>A value that represents whether the button should light up or not.</returns>
|
/// <returns>A value that represents whether the button should light up or not.</returns>
|
||||||
public virtual bool CanUse()
|
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>
|
/// <summary>
|
||||||
@@ -287,6 +310,11 @@ public abstract class MeetingActionButton
|
|||||||
|
|
||||||
Timer = Cooldown;
|
Timer = Cooldown;
|
||||||
OnClick();
|
OnClick();
|
||||||
|
UsesSoFar++;
|
||||||
|
if (DisableUponUse && Button)
|
||||||
|
{
|
||||||
|
Button!.SetDisabled();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@@ -111,6 +111,15 @@ internal static class MeetingHudPatches
|
|||||||
[HarmonyPatch(nameof(MeetingHud.VotingComplete))]
|
[HarmonyPatch(nameof(MeetingHud.VotingComplete))]
|
||||||
public static void VotingCompletePatch(MeetingHud __instance)
|
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));
|
MiraEventManager.InvokeEvent(new VotingCompleteEvent(__instance));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user