2025-10-11 15:18:09 +08:00
|
|
|
|
using System;
|
|
|
|
|
|
using System.Runtime.CompilerServices;
|
2025-12-24 14:34:26 +08:00
|
|
|
|
using System.Runtime.InteropServices;
|
2025-10-11 15:18:09 +08:00
|
|
|
|
using Unity.IL2CPP.CompilerServices;
|
|
|
|
|
|
|
|
|
|
|
|
namespace AlicizaX
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
|
|
[AttributeUsage(AttributeTargets.Struct)]
|
|
|
|
|
|
public sealed class PrewarmAttribute : Attribute
|
|
|
|
|
|
{
|
|
|
|
|
|
public int Capacity { get; }
|
|
|
|
|
|
public PrewarmAttribute(int capacity) => Capacity = capacity;
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[Il2CppSetOption(Option.NullChecks, false)]
|
|
|
|
|
|
[Il2CppSetOption(Option.DivideByZeroChecks, false)]
|
|
|
|
|
|
[Il2CppSetOption(Option.ArrayBoundsChecks, false)]
|
2025-12-24 14:34:26 +08:00
|
|
|
|
[StructLayout(LayoutKind.Sequential)]
|
|
|
|
|
|
public readonly struct EventRuntimeHandle : IDisposable
|
2025-10-11 15:18:09 +08:00
|
|
|
|
{
|
2025-12-24 14:34:26 +08:00
|
|
|
|
private readonly long _data; // 高32位=index, 低32位=version
|
|
|
|
|
|
private readonly int _typeId; // 类型ID,避免泛型委托
|
2025-10-11 15:18:09 +08:00
|
|
|
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2025-12-24 14:34:26 +08:00
|
|
|
|
internal EventRuntimeHandle(int typeId, int index, int version)
|
2025-10-11 15:18:09 +08:00
|
|
|
|
{
|
2025-12-24 14:34:26 +08:00
|
|
|
|
_typeId = typeId;
|
|
|
|
|
|
_data = ((long)index << 32) | (uint)version;
|
2025-10-11 15:18:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
2025-12-24 14:34:26 +08:00
|
|
|
|
public void Dispose()
|
|
|
|
|
|
{
|
|
|
|
|
|
if (_typeId != 0)
|
|
|
|
|
|
{
|
|
|
|
|
|
int index = (int)(_data >> 32);
|
|
|
|
|
|
int version = (int)_data;
|
|
|
|
|
|
UnsubscribeRegistry.Invoke(_typeId, index, version);
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-10-11 15:18:09 +08:00
|
|
|
|
}
|
|
|
|
|
|
}
|