31 lines
580 B
C#
31 lines
580 B
C#
using Godot;
|
|
|
|
|
|
namespace Rokojori
|
|
{
|
|
public class BitMath
|
|
{
|
|
public static int GetInt32BitMask( int bit )
|
|
{
|
|
return ( 1 << bit );
|
|
}
|
|
|
|
public static int SetBit( int value, int bitPosition )
|
|
{
|
|
return value | GetInt32BitMask( bitPosition );
|
|
}
|
|
|
|
public static int UnsetBit( int value, int bitPosition )
|
|
{
|
|
return value & ~GetInt32BitMask( bitPosition );
|
|
}
|
|
|
|
public static bool IsBitSet( int value, int bitPosition )
|
|
{
|
|
var mask = GetInt32BitMask( bitPosition );
|
|
return ( value & mask ) == mask;
|
|
}
|
|
|
|
|
|
}
|
|
} |