using System.Diagnostics.CodeAnalysis;
namespace Content.Client.UserInterface;
///
/// A simple utility class to "coalesce" multiple input events into a single one, fired later.
///
///
public struct InputCoalescer
{
public bool IsModified;
public T LastValue;
///
/// Replace the value in the . This sets to true.
///
public void Set(T value)
{
LastValue = value;
IsModified = true;
}
///
/// Check if the has been modified.
/// If it was, return the value and clear .
///
/// True if the value was modified since the last check.
public bool CheckIsModified([MaybeNullWhen(false)] out T value)
{
if (IsModified)
{
value = LastValue;
IsModified = false;
return true;
}
value = default;
return IsModified;
}
}