Unstable v0.15.17.0 (Hex is out of town edition)
This commit is contained in:
@@ -9,6 +9,7 @@ using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
namespace Barotrauma
|
||||
{
|
||||
@@ -534,6 +535,16 @@ namespace Barotrauma
|
||||
}
|
||||
}
|
||||
|
||||
// Enum.HasFlag() sucks
|
||||
public static bool IsBitSet<T>(this T self, T bit) where T : struct, Enum
|
||||
{
|
||||
// This uses Unsafe.As for performance reasons, as
|
||||
// C# will otherwise not allow a T -> int cast
|
||||
// without first casting to object, which would make
|
||||
// this not any better than Enum.HasFlag
|
||||
return (Unsafe.As<T, int>(ref self) & Unsafe.As<T, int>(ref bit)) != 0;
|
||||
}
|
||||
|
||||
public static string ByteArrayToString(byte[] ba)
|
||||
{
|
||||
StringBuilder hex = new StringBuilder(ba.Length * 2);
|
||||
|
||||
Reference in New Issue
Block a user