From fcf99cfb02dd6481f8c981f8c62a01543d4f3808 Mon Sep 17 00:00:00 2001 From: Atony <75191600+AtonyGit@users.noreply.github.com> Date: Sun, 15 Nov 2026 20:22:20 -0600 Subject: [PATCH] Fix roles breaking from VanillaButtonClickEvent --- .../Gameplay/VanillaButtonCancelledEvent.cs | 14 ------------- .../Gameplay/VanillaButtonClickEvent.cs | 20 ------------------- .../Patches/Events/VanillaButtonPatches.cs | 13 +----------- 3 files changed, 1 insertion(+), 46 deletions(-) diff --git a/MiraAPI/Events/Vanilla/Gameplay/VanillaButtonCancelledEvent.cs b/MiraAPI/Events/Vanilla/Gameplay/VanillaButtonCancelledEvent.cs index e4826a01..92bd1f14 100644 --- a/MiraAPI/Events/Vanilla/Gameplay/VanillaButtonCancelledEvent.cs +++ b/MiraAPI/Events/Vanilla/Gameplay/VanillaButtonCancelledEvent.cs @@ -2,20 +2,6 @@ namespace MiraAPI.Events.Vanilla.Gameplay; -/// -/// Invoked when a Vanilla click is cancelled. Do not use for . -/// -/// The vanilla type. -/// The vanilla whose click was cancelled. -public sealed class VanillaButtonCancelledEvent(T button) : MiraEvent - where T : AbilityButton -{ - /// - /// Gets the Vanilla whose click was cancelled. - /// - public T Button => button; -} - /// /// Invoked when a Vanilla click is cancelled. Do not use for s. /// diff --git a/MiraAPI/Events/Vanilla/Gameplay/VanillaButtonClickEvent.cs b/MiraAPI/Events/Vanilla/Gameplay/VanillaButtonClickEvent.cs index 4e87c87b..192db6fd 100644 --- a/MiraAPI/Events/Vanilla/Gameplay/VanillaButtonClickEvent.cs +++ b/MiraAPI/Events/Vanilla/Gameplay/VanillaButtonClickEvent.cs @@ -2,26 +2,6 @@ namespace MiraAPI.Events.Vanilla.Gameplay; -/// -/// Button click event for Vanilla s only. Do not use for s. -/// -/// The vanilla type. -/// The vanilla that was clicked. -/// The generic invoked before button-specific events. -public sealed class VanillaButtonClickEvent(T button, VanillaButtonClickEvent genericClickEvent) : MiraCancelableEvent - where T : AbilityButton -{ - /// - /// Gets the vanilla that was clicked. - /// - public T Button => button; - - /// - /// Gets the generic that is invoked before this button-specific event. - /// - public VanillaButtonClickEvent GenericClickEvent => genericClickEvent; -} - /// /// Button click event for Vanilla only. Do not use for s. /// diff --git a/MiraAPI/Patches/Events/VanillaButtonPatches.cs b/MiraAPI/Patches/Events/VanillaButtonPatches.cs index 92946439..77c91125 100644 --- a/MiraAPI/Patches/Events/VanillaButtonPatches.cs +++ b/MiraAPI/Patches/Events/VanillaButtonPatches.cs @@ -72,17 +72,6 @@ public static class VanillaButtonPatches new VanillaButtonCancelledEvent(__instance).InvokeEvent(); } - var eventType = typeof(VanillaButtonClickEvent<>).MakeGenericType(__instance.GetType()); - var @event = (MiraCancelableEvent)Activator.CreateInstance(eventType, [__instance])!; - var specificInvoked = @event.InvokeEvent(eventType); - if (@event.IsCancelled) - { - var cancelEventType = typeof(VanillaButtonCancelledEvent<>).MakeGenericType(__instance.GetType()); - var cancelEvent = (MiraEvent)Activator.CreateInstance(cancelEventType, [__instance])!; - cancelEvent.InvokeEvent(cancelEventType); - } - - MiraCancelableEvent eventCheck = specificInvoked ? @event : genericEvent; - return !eventCheck.IsCancelled; + return !genericEvent.IsCancelled; } }