mirror of
https://github.com/gwdevhub/Daybreak.git
synced 2026-07-15 15:19:57 +00:00
27 lines
544 B
C#
27 lines
544 B
C#
using System.Core.Extensions;
|
|
|
|
namespace Daybreak.API.Interop;
|
|
|
|
public sealed class GWAddressCache(Func<nuint> provider)
|
|
{
|
|
private readonly Func<nuint> provider = provider.ThrowIfNull();
|
|
private nuint? cachedAddress;
|
|
|
|
public nuint? GetAddress()
|
|
{
|
|
if (this.cachedAddress.HasValue)
|
|
{
|
|
return this.cachedAddress.Value;
|
|
}
|
|
|
|
var addr = this.provider();
|
|
if (addr is 0x0)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
this.cachedAddress = addr;
|
|
return addr;
|
|
}
|
|
}
|