37 lines
1.3 KiB
C#
37 lines
1.3 KiB
C#
using System;
|
|
using System.Runtime.CompilerServices;
|
|
using Unity.IL2CPP.CompilerServices;
|
|
|
|
namespace AlicizaX
|
|
{
|
|
public static class EventPublisher
|
|
{
|
|
[Il2CppSetOption(Option.NullChecks, false)]
|
|
[Il2CppSetOption(Option.DivideByZeroChecks, false)]
|
|
[Il2CppSetOption(Option.ArrayBoundsChecks, false)]
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static EventRuntimeHandle Subscribe<T>(Action<T> handler) where T : struct, IEventArgs
|
|
{
|
|
return EventContainer<T>.Subscribe(handler);
|
|
}
|
|
|
|
[Il2CppSetOption(Option.NullChecks, false)]
|
|
[Il2CppSetOption(Option.DivideByZeroChecks, false)]
|
|
[Il2CppSetOption(Option.ArrayBoundsChecks, false)]
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
|
public static void Publish<T>(in T evt) where T : struct, IEventArgs
|
|
{
|
|
EventContainer<T>.Publish(evt);
|
|
}
|
|
|
|
[Il2CppSetOption(Option.NullChecks, false)]
|
|
[Il2CppSetOption(Option.DivideByZeroChecks, false)]
|
|
[Il2CppSetOption(Option.ArrayBoundsChecks, false)]
|
|
public static void Publish<T>(Action<T> init) where T : struct, IEventArgs
|
|
{
|
|
var evt = default(T);
|
|
init(evt);
|
|
Publish(in evt);
|
|
}
|
|
}
|
|
} |