diff --git a/MiraAPI/Hud/CustomActionButton.cs b/MiraAPI/Hud/CustomActionButton.cs
index 6b1c21ec..7049a8e9 100644
--- a/MiraAPI/Hud/CustomActionButton.cs
+++ b/MiraAPI/Hud/CustomActionButton.cs
@@ -65,6 +65,11 @@ public abstract class CustomActionButton
///
public bool EffectActive { get; protected set; }
+ ///
+ /// Gets or sets a value indicating whether the timer is currently active.
+ ///
+ public bool TimerPaused { get; protected set; }
+
///
/// Gets or sets the amount of uses left.
///
@@ -94,6 +99,7 @@ public abstract class CustomActionButton
UsesLeft = MaxUses;
Timer = AmongUsClient.Instance?.NetworkMode == NetworkModes.FreePlay ? 0 : InitialCooldown;
EffectActive = false;
+ TimerPaused = false;
Button = Object.Instantiate(HudManager.Instance.AbilityButton, parent);
Button.name = Name + "Button";
@@ -248,6 +254,15 @@ public abstract class CustomActionButton
SetTimer(Timer - amount);
}
+ ///
+ /// Sets whether the timer is paused or not.
+ ///
+ /// Whether you want to pause/resume the timer.
+ public virtual void SetTimerPaused(bool val)
+ {
+ TimerPaused = val;
+ }
+
///
/// Set the amount of uses this button has left.
///
@@ -256,6 +271,11 @@ public abstract class CustomActionButton
{
UsesLeft = Mathf.Clamp(amount, 0, int.MaxValue);
Button?.SetUsesRemaining(UsesLeft);
+
+ if (Button != null)
+ {
+ Button.usesRemainingSprite.color = UsesLeft == 0 ? Color.red : Color.white;
+ }
}
///
@@ -306,14 +326,24 @@ public abstract class CustomActionButton
}
///
- /// When the button is enabled, this method is called to determine if the button can be used.
+ /// When the button is usable, this method is called to determine if the button can be clicked.
/// By default, it takes into account the timer, effect, and uses.
/// You can override it to change the behavior.
///
- /// A value that represents whether the button can be used or not.
+ /// A value that represents whether the button can be clicked or not.
+ public virtual bool CanClick()
+ {
+ return Timer <= 0 && !EffectActive && CanUse();
+ }
+
+ ///
+ /// Whether the button should light up or not. This is also the base for CanClick.
+ /// You can override it to change the behaviour. Do not include timer in here, that is for CanClick.
+ ///
+ /// A value that represents whether the button should light up or not.
public virtual bool CanUse()
{
- return Timer <= 0 && !EffectActive && (!LimitedUses || UsesLeft > 0);
+ return !LimitedUses || UsesLeft > 0;
}
///
@@ -335,7 +365,7 @@ public abstract class CustomActionButton
///
public virtual void ClickHandler()
{
- if (!CanUse())
+ if (!CanClick())
{
return;
}
@@ -344,15 +374,10 @@ public abstract class CustomActionButton
{
UsesLeft--;
Button?.SetUsesRemaining(UsesLeft);
-
- if (Button != null)
- {
- Button.usesRemainingSprite.color = UsesLeft == 0 ? Color.red : Color.white;
- }
}
OnClick();
- Button?.SetDisabled();
+
if (HasEffect)
{
EffectActive = true;
@@ -372,7 +397,7 @@ public abstract class CustomActionButton
/// The local PlayerControl.
public virtual void FixedUpdateHandler(PlayerControl playerControl)
{
- if (Timer >= 0)
+ if (Timer >= 0 && !TimerPaused)
{
Timer -= Time.deltaTime;
}
@@ -392,7 +417,17 @@ public abstract class CustomActionButton
Button?.SetDisabled();
}
- Button?.SetCoolDown(Timer, EffectActive ? EffectDuration : Cooldown);
+ if (EffectActive)
+ {
+ Button?.SetFillUp(Timer, EffectDuration);
+
+ Button!.cooldownTimerText.text = Mathf.CeilToInt(Timer).ToString();
+ Button!.cooldownTimerText.gameObject.SetActive(true);
+ }
+ else
+ {
+ Button?.SetCoolDown(Timer, Cooldown);
+ }
FixedUpdate(playerControl);
}
@@ -451,6 +486,12 @@ public abstract class CustomActionButton : CustomActionButton where T : MonoB
return base.CanUse() && Target != null;
}
+ ///
+ public override bool CanClick()
+ {
+ return base.CanClick() && Target != null;
+ }
+
///
/// Use this to reset the button's target after used.
///
diff --git a/MiraAPI/Hud/CustomPlayerMenu.cs b/MiraAPI/Hud/CustomPlayerMenu.cs
index 7c861ecd..a1885961 100644
--- a/MiraAPI/Hud/CustomPlayerMenu.cs
+++ b/MiraAPI/Hud/CustomPlayerMenu.cs
@@ -1,11 +1,11 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using AmongUs.GameOptions;
+using AmongUs.GameOptions;
using Il2CppInterop.Runtime.Attributes;
using MiraAPI.Patches.Stubs;
using Reactor.Utilities.Attributes;
using Reactor.Utilities.Extensions;
+using System;
+using System.Collections.Generic;
+using System.Linq;
using UnityEngine;
using UnityEngine.Events;
@@ -86,10 +86,16 @@ public class CustomPlayerMenu(IntPtr il2CppPtr) : Minigame(il2CppPtr)
/// Function to determine if player should show in the custom menu.
/// Onclick action for player.
[HideFromIl2Cpp]
- public void Begin(Func playerMatch, Action onClick)
+ public void Begin(Func playerMatch, Action onClick)
{
MinigameStubs.Begin(this, null);
+ var back = BackButton.GetComponent();
+ back.OnClick.AddListener((UnityAction)(() =>
+ {
+ onClick(null);
+ }));
+
DestroyableSingleton.Instance.Analytics.MinigameOpened(PlayerControl.LocalPlayer.Data, TaskType);
var list = PlayerControl.AllPlayerControls.ToArray().Where(playerMatch).ToList();
potentialVictims = [];