Skip to main content

Class: BitFlags

Utility class for manipulating bit flags.

Constructors

constructor

new BitFlags(): BitFlags

Returns

BitFlags

Methods

createFlag

createFlag(index): number

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

Parameters

NameTypeDescription
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.

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

NameTypeDescription
flagsnumberA bit flag group.
callback(value: boolean, index: number, flags: number) => 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

Defined in

src/sdk/math/BitFlags.ts:104


intersection

intersection(...flags): number

Gets the intersection of zero or more bit flags.

Parameters

NameTypeDescription
...flagsnumber[]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

NameTypeDescription
flagsnumberA bit flag group.
conditionsnumberThe 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

NameTypeDescription
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.

Defined in

src/sdk/math/BitFlags.ts:81


not

not(flags, mask?): number

Gets the inverse of some bit flags.

Parameters

NameTypeDefault 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

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

NameTypeDescription
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.

Defined in

src/sdk/math/BitFlags.ts:71


union

union(...flags): number

Gets the union of zero or more bit flags.

Parameters

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

Returns

number

the union of the bit flags.

Defined in

src/sdk/math/BitFlags.ts:36