com.alicizax.unity.framework/Runtime/ABase/Event/EventPublisher.cs

55 lines
1.8 KiB
C#
Raw Normal View History

2025-11-14 11:38:28 +08:00
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
{
2025-12-24 14:34:26 +08:00
EventContainer<T>.Publish(in evt);
2025-11-14 11:38:28 +08:00
}
[Il2CppSetOption(Option.NullChecks, false)]
[Il2CppSetOption(Option.DivideByZeroChecks, false)]
[Il2CppSetOption(Option.ArrayBoundsChecks, false)]
2025-12-24 14:34:26 +08:00
[MethodImpl(MethodImplOptions.AggressiveInlining)]
2025-11-14 11:38:28 +08:00
public static void Publish<T>(Action<T> init) where T : struct, IEventArgs
{
var evt = default(T);
init(evt);
Publish(in evt);
}
2025-12-24 14:34:26 +08:00
[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static int GetSubscriberCount<T>() where T : struct, IEventArgs
{
return EventContainer<T>.SubscriberCount;
}
public static void EnsureCapacity<T>(int capacity) where T : struct, IEventArgs
{
EventContainer<T>.EnsureCapacity(capacity);
}
public static void Clear<T>() where T : struct, IEventArgs
{
EventContainer<T>.Clear();
}
2025-11-14 11:38:28 +08:00
}
2025-12-24 14:34:26 +08:00
}