mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-19 15:51:48 +00:00
add a limit to multitarget buttons
This commit is contained in:
1 parent
8a71f13874
commit
b19a0178ad
1 file changed
+9
-1
@@ -19,6 +19,11 @@ public abstract class MultiTargetButton<T> : CustomActionButton where T : MonoBe
|
||||
/// <inheritdoc cref="CustomActionButton{T}.Distance"/>
|
||||
public virtual float Distance => PlayerControl.LocalPlayer.Data.Role.GetAbilityDistance();
|
||||
|
||||
/// <summary>
|
||||
/// Gets the maximum amount of targets the button can have.
|
||||
/// </summary>
|
||||
public virtual int MaxTargets { get; } = int.MaxValue;
|
||||
|
||||
/// <inheritdoc cref="CustomActionButton{T}.IsTargetValid"/>
|
||||
public virtual bool IsTargetValid(T target)
|
||||
{
|
||||
@@ -47,7 +52,10 @@ public abstract class MultiTargetButton<T> : CustomActionButton where T : MonoBe
|
||||
}
|
||||
}
|
||||
|
||||
Targets = newTargets.Where(IsTargetValid).ToArray();
|
||||
Targets = newTargets
|
||||
.Where(IsTargetValid)
|
||||
.Take(MaxTargets)
|
||||
.ToArray();
|
||||
Targets.Do(t => SetOutline(t, true));
|
||||
|
||||
return base.CanUse() && Targets.Length > 0;
|
||||
|
||||
Reference in new issue
Block a user