mirror of
https://github.com/All-Of-Us-Mods/MiraAPI.git
synced 2026-10-20 01:46:15 +00:00
Made EventHandler InvokeEvent extension methods
This commit is contained in:
1 parent
caca3d92ad
commit
6540f8b7bb
1 file changed
+2
-2
@@ -17,7 +17,7 @@ public static class MiraEventManager
|
|||||||
/// <param name="eventInstance">The <typeparamref name="T"/> instance.</param>
|
/// <param name="eventInstance">The <typeparamref name="T"/> instance.</param>
|
||||||
/// <typeparam name="T">Type of Event.</typeparam>
|
/// <typeparam name="T">Type of Event.</typeparam>
|
||||||
/// <returns>If there was an event handler invoked for this event, return <see langword="true"/>. Otherwise, return <see langword="false"/>.</returns>
|
/// <returns>If there was an event handler invoked for this event, return <see langword="true"/>. Otherwise, return <see langword="false"/>.</returns>
|
||||||
public static bool InvokeEvent<T>(T eventInstance) where T : MiraEvent
|
public static bool InvokeEvent<T>(this T eventInstance) where T : MiraEvent
|
||||||
{
|
{
|
||||||
EventWrappers.TryGetValue(typeof(T), out var handlers);
|
EventWrappers.TryGetValue(typeof(T), out var handlers);
|
||||||
if (handlers == null || handlers.Count == 0)
|
if (handlers == null || handlers.Count == 0)
|
||||||
@@ -46,7 +46,7 @@ public static class MiraEventManager
|
|||||||
/// <param name="eventInstance">The <see cref="MiraEvent"/> instance.</param>
|
/// <param name="eventInstance">The <see cref="MiraEvent"/> instance.</param>
|
||||||
/// <param name="type">The type to use for handler lookup.</param>
|
/// <param name="type">The type to use for handler lookup.</param>
|
||||||
/// <returns>If there was an event handler invoked for this event, return <see langword="true"/>. Otherwise, return <see langword="false"/>.</returns>
|
/// <returns>If there was an event handler invoked for this event, return <see langword="true"/>. Otherwise, return <see langword="false"/>.</returns>
|
||||||
public static bool InvokeEvent(MiraEvent eventInstance, Type type)
|
public static bool InvokeEvent(this MiraEvent eventInstance, Type type)
|
||||||
{
|
{
|
||||||
EventWrappers.TryGetValue(type, out var handlers);
|
EventWrappers.TryGetValue(type, out var handlers);
|
||||||
if (handlers == null || handlers.Count == 0)
|
if (handlers == null || handlers.Count == 0)
|
||||||
|
|||||||
Reference in new issue
Block a user