Skip to main content

Class: BitFlags

Defined in: src/sdk/math/BitFlags.ts:4

Utility class for manipulating bit flags.

Constructors

Constructor

new BitFlags(): BitFlags

Returns

BitFlags

Methods

createFlag()

static createFlag(index): number

Defined in: src/sdk/math/BitFlags.ts:11

Generates a bit flag with a boolean value of true at a specified index.

Parameters

ParameterTypeDescription
indexnumberThe index of the flag. Must be between 0 and 32, inclusive.

Returns

number

a bit flag.

Throws

Error if index is out of bounds.


forEach()

static forEach(flags, callback, valueFilter?, startIndex?, endIndex?): void

Defined in: src/sdk/math/BitFlags.ts:104

Iterates through a bit flag group and executes a callback function once for each flag.

Parameters

ParameterTypeDescription
flagsnumberA bit flag group.
callback(value, index, flags) => voidA function which will be called once for each flag.
valueFilter?booleanThe 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?numberThe index of the flag at which to start (inclusive). Defaults to 0.
endIndex?numberThe index of the flag at which to end (exclusive). Defaults to 32.

Returns

void


intersection()

static intersection(...flags): number

Defined in: src/sdk/math/BitFlags.ts:50

Gets the intersection of zero or more bit flags.

Parameters

ParameterTypeDescription
...flagsnumber[]A list of bit flags.

Returns

number

the intersection of the bit flags.


isAll()

static isAll(flags, conditions): boolean

Defined in: src/sdk/math/BitFlags.ts:91

Checks if a bit flag group meets all the conditions from a list of conditions.

Parameters

ParameterTypeDescription
flagsnumberA bit flag group.
conditionsnumberThe conditions to meet, as a bit flag group.

Returns

boolean

whether the bit flag group meets all the conditions.


isAny()

static isAny(flags, conditions): boolean

Defined in: src/sdk/math/BitFlags.ts:81

Checks if a bit flag group meets at least one condition from a list of conditions.

Parameters

ParameterTypeDescription
flagsnumberA bit flag group.
conditionsnumberThe conditions to meet, as a bit flag group.

Returns

boolean

whether the bit flag group meets at least one condition.


not()

static not(flags, mask): number

Defined in: src/sdk/math/BitFlags.ts:27

Gets the inverse of some bit flags.

Parameters

ParameterTypeDefault valueDescription
flagsnumberundefinedThe bit flag group containing the flags to invert.
masknumber~0An 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


set()

static set(flags, valuesToSet, mask): number

Defined in: src/sdk/math/BitFlags.ts:71

Changes a bit flag group by setting values at specific indexes.

Parameters

ParameterTypeDescription
flagsnumberThe bit flag group to change.
valuesToSetnumberA bit flag group containing the values to set.
masknumberA 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.


union()

static union(...flags): number

Defined in: src/sdk/math/BitFlags.ts:36

Gets the union of zero or more bit flags.

Parameters

ParameterTypeDescription
...flagsnumber[]A list of bit flags.

Returns

number

the union of the bit flags.