Class: BitFlags
Utility class for manipulating bit flags.
Constructors
constructor
• new BitFlags(): BitFlags
Returns
Methods
createFlag
▸ createFlag(index
): number
Generates a bit flag with a boolean value of true at a specified index.
Parameters
Name | Type | Description |
---|---|---|
index | number | The index of the flag. Must be between 0 and 32, inclusive. |
Returns
number
a bit flag.
Throws
Error if index is out of bounds.
Defined in
src/sdk/math/BitFlags.ts:11
forEach
▸ forEach(flags
, callback
, valueFilter?
, startIndex?
, endIndex?
): void
Iterates through a bit flag group and executes a callback function once for each flag.
Parameters
Name | Type | Description |
---|---|---|
flags | number | A bit flag group. |
callback | (value : boolean , index : number , flags : number ) => void | A function which will be called once for each flag. |
valueFilter? | boolean | The value on which to filter. If defined, only flags with values equal to the filter will be iterated, otherwise all flags will be iterated regardless of their values. |
startIndex? | number | The index of the flag at which to start (inclusive). Defaults to 0. |
endIndex? | number | The index of the flag at which to end (exclusive). Defaults to 32. |
Returns
void
Defined in
src/sdk/math/BitFlags.ts:104
intersection
▸ intersection(...flags
): number
Gets the intersection of zero or more bit flags.
Parameters
Name | Type | Description |
---|---|---|
...flags | number [] | A list of bit flags. |
Returns
number
the intersection of the bit flags.
Defined in
src/sdk/math/BitFlags.ts:50
isAll
▸ isAll(flags
, conditions
): boolean
Checks if a bit flag group meets all the conditions from a list of conditions.
Parameters
Name | Type | Description |
---|---|---|
flags | number | A bit flag group. |
conditions | number | The conditions to meet, as a bit flag group. |
Returns
boolean
whether the bit flag group meets all the conditions.
Defined in
src/sdk/math/BitFlags.ts:91
isAny
▸ isAny(flags
, conditions
): boolean
Checks if a bit flag group meets at least one condition from a list of conditions.
Parameters
Name | Type | Description |
---|---|---|
flags | number | A bit flag group. |
conditions | number | The conditions to meet, as a bit flag group. |
Returns
boolean
whether the bit flag group meets at least one condition.
Defined in
src/sdk/math/BitFlags.ts:81
not
▸ not(flags
, mask?
): number
Gets the inverse of some bit flags.
Parameters
Name | Type | Default value | Description |
---|---|---|---|
flags | number | undefined | The bit flag group containing the flags to invert. |
mask | number | ~0 | An optional bit mask to use when applying the inverse operation. The operation will only be performed at the indexes where the mask has a value of 1 (true). If a mask is not specified, the operation will be performed at all indexes. |
Returns
number
the inverse
Defined in
src/sdk/math/BitFlags.ts:27
set
▸ set(flags
, valuesToSet
, mask
): number
Changes a bit flag group by setting values at specific indexes.
Parameters
Name | Type | Description |
---|---|---|
flags | number | The bit flag group to change. |
valuesToSet | number | A bit flag group containing the values to set. |
mask | number | A mask defining the indexes to set. Only indexes at which the mask has a value of 1 (true ) will be set. |
Returns
number
The result of changing flags
using the specified values and indexes.
Defined in
src/sdk/math/BitFlags.ts:71
union
▸ union(...flags
): number
Gets the union of zero or more bit flags.
Parameters
Name | Type | Description |
---|---|---|
...flags | number [] | A list of bit flags. |
Returns
number
the union of the bit flags.
Defined in
src/sdk/math/BitFlags.ts:36