r2mods/ilspy_dump/ror2_csproj/ResourceAvailability.cs

32 lines
454 B
C#
Raw Normal View History

2024-10-04 07:26:37 +00:00
using System;
using JetBrains.Annotations;
public struct ResourceAvailability
{
public bool available { get; private set; }
private event Action onAvailable;
public void MakeAvailable()
{
if (!available)
{
available = true;
this.onAvailable?.Invoke();
this.onAvailable = null;
}
}
public void CallWhenAvailable([NotNull] Action callback)
{
if (available)
{
callback();
}
else
{
onAvailable += callback;
}
}
}