Files
AetherBags/KamiToolKit/Classes/FlagHelper.cs
T
KnackAtNite 8db4ce6094
Debug Build and Test / Build against Latest Dalamud (push) Has been cancelled
Debug Build and Test / Build against Staging Dalamud (push) Has been cancelled
Initial commit: AetherBags + KamiToolKit for FC Gitea
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-02-08 14:46:31 -05:00

24 lines
873 B
C#

using System.Numerics;
namespace KamiToolKit.Classes;
public static class FlagHelper {
public static bool ReadFlag<T>(ref T flagsField, int flag) where T : struct, IBinaryInteger<T>
=> (flagsField & T.One << BitOperations.Log2((uint)flag)) != T.Zero;
public static void SetFlag<T>(ref T flagsField, int flag) where T : struct, IBinaryInteger<T>
=> flagsField |= T.One << BitOperations.Log2((uint)flag);
public static void ClearFlag<T>(ref T flagsField, int flag) where T : struct, IBinaryInteger<T>
=> flagsField &= ~(T.One << BitOperations.Log2((uint)flag));
public static void UpdateFlag<T>(ref T flagsField, int flag, bool enable) where T : struct, IBinaryInteger<T> {
if (enable) {
SetFlag(ref flagsField, flag);
}
else {
ClearFlag(ref flagsField, flag);
}
}
}