Skip to content

Vector

SerializedVector = Readonly<LuaMap<string, unknown>> & object

Defined in: packages/isaacscript-common/src/functions/vector.ts:18

readonly __serializedVectorBrand: symbol

readonly __kind: CopyableIsaacAPIClassType.VECTOR

copyVector(vector): Vector

Defined in: packages/isaacscript-common/src/functions/vector.ts:27

Helper function to copy a Vector Isaac API class.

Vector

Vector


deserializeVector(vector): Vector

Defined in: packages/isaacscript-common/src/functions/vector.ts:41

Helper function to convert a SerializedVector object to a normal RNG object. (This is used by the save data manager when reading data from the “save#.dat” file.)

SerializedVector

Vector


doesVectorHaveLength(vector, threshold?): boolean

Defined in: packages/isaacscript-common/src/functions/vector.ts:73

Helper function to measure a vector to see if it has a non-zero length using a threshold to ignore extremely small values.

Use this function instead of explicitly checking if the length is 0 because vectors in the game are unlikely to ever be exactly set to 0. Instead, they will always have some miniscule length.

Vector

The vector to measure.

number = 0.01

Optional. The threshold from 0 to consider to be a non-zero vector. Default is 0.01.

boolean


getClosestVectorTo(referenceVector, vectors): Vector | undefined

Defined in: packages/isaacscript-common/src/functions/vector.ts:87

Given an array of vectors, this helper function returns the closest one to a provided reference vector.

Vector

The vector to compare against.

readonly Vector[]

The array of vectors to look through.

Vector | undefined


getRandomVector(seedOrRNG): Readonly<Vector>

Defined in: packages/isaacscript-common/src/functions/vector.ts:119

Helper function to get a random vector between (-1, -1) and (1, 1).

To get random vectors with a bigger length, multiply this with a number.

Use this over the RandomVector function when you need the vector to be seeded.

If you want to generate an unseeded vector, you must explicitly pass undefined to the seedOrRNG parameter.

RNG | Seed | undefined

The Seed or RNG object to use. If an RNG object is provided, the RNG.Next method will be called. If undefined is provided, it will default to a random seed.

Readonly<Vector>


isSerializedVector(object): object is SerializedVector

Defined in: packages/isaacscript-common/src/functions/vector.ts:134

Used to determine is the given table is a serialized Vector object created by the deepCopy function.

unknown

object is SerializedVector


isVector(object): object is Vector

Defined in: packages/isaacscript-common/src/functions/vector.ts:145

Helper function to check if something is an instantiated Vector object.

unknown

object is Vector


serializeVector(vector): SerializedVector

Defined in: packages/isaacscript-common/src/functions/vector.ts:153

Helper function to convert a Vector object to a SerializedVector object. (This is used by the save data manager when writing data from the “save#.dat” file.)

Vector

SerializedVector


vectorEquals(vector1, vector2): boolean

Defined in: packages/isaacscript-common/src/functions/vector.ts:172

Helper function to compare two vectors for equality.

This function is useful because vectors are not directly comparable. In other words, Vector(1.2) === Vector(1.2) will be equal to false.

Vector

Vector

boolean


vectorToDirection(vector): Direction

Defined in: packages/isaacscript-common/src/functions/vector.ts:177

Helper function for finding out which way a vector is pointing.

Vector

Direction


vectorToString(vector, round?): string

Defined in: packages/isaacscript-common/src/functions/vector.ts:189

Helper function to convert a vector to a string.

Vector

The vector to convert.

boolean = false

Optional. If true, will round the vector values to the nearest integer. Default is false.

string