pair
Call Signature
Section titled “Call Signature”pair<
R>(relation,target):Pair<R>
Defined in: src/pair.ts:81
Creates a relationship pair relation → target (e.g.: Likes → Bob),
where both relation and target can be either entities or components.
Pairs can be assigned to any id, forming something like Alice → Likes → Bob.
Like components, pairs can be associated to values. The value type of a
pair is determined by its relation and target arguments:
- If
relationis a component with a value, then the pair takes the same value type; - Else if
targetis a component with a value, then the pair takes the same value type; - Otherwise, the pair is a tag pair and does not hold a value.
Type Parameters
Section titled “Type Parameters”R
Parameters
Section titled “Parameters”relation
Section titled “relation”target
Section titled “target”ComponentHandle<undefined>
Returns
Section titled “Returns”Pair<R>
Examples
Section titled “Examples”const Likes = component()const Owns = component<number>()
const car = entity()const bob = entity() // Because neither `Likes` nor `car` hold values, we have no value to assign. .set(pair(Likes, car)) // Because `Owns` holds a number value, the pair takes a number value. .set(pair(Owns, car), 2)const Begin = component()const End = component()const Position = component<Vector3>()
const line = entity() // Because `Begin` and `End` hold no values, those pairs take the value from `Position`. .set(pair(Begin, Position), new Vector3(0, 0, 0)) .set(pair(End, Position), new Vector3(10, 0, 0))Call Signature
Section titled “Call Signature”pair<
T>(relation,target):Pair<T>
Defined in: src/pair.ts:82
Creates a relationship pair relation → target (e.g.: Likes → Bob),
where both relation and target can be either entities or components.
Pairs can be assigned to any id, forming something like Alice → Likes → Bob.
Like components, pairs can be associated to values. The value type of a
pair is determined by its relation and target arguments:
- If
relationis a component with a value, then the pair takes the same value type; - Else if
targetis a component with a value, then the pair takes the same value type; - Otherwise, the pair is a tag pair and does not hold a value.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”relation
Section titled “relation”ComponentHandle<undefined>
target
Section titled “target”Returns
Section titled “Returns”Pair<T>
Examples
Section titled “Examples”const Likes = component()const Owns = component<number>()
const car = entity()const bob = entity() // Because neither `Likes` nor `car` hold values, we have no value to assign. .set(pair(Likes, car)) // Because `Owns` holds a number value, the pair takes a number value. .set(pair(Owns, car), 2)const Begin = component()const End = component()const Position = component<Vector3>()
const line = entity() // Because `Begin` and `End` hold no values, those pairs take the value from `Position`. .set(pair(Begin, Position), new Vector3(0, 0, 0)) .set(pair(End, Position), new Vector3(10, 0, 0))Call Signature
Section titled “Call Signature”pair<
R,T>(relation,target):Pair<R>
Defined in: src/pair.ts:83
Creates a relationship pair relation → target (e.g.: Likes → Bob),
where both relation and target can be either entities or components.
Pairs can be assigned to any id, forming something like Alice → Likes → Bob.
Like components, pairs can be associated to values. The value type of a
pair is determined by its relation and target arguments:
- If
relationis a component with a value, then the pair takes the same value type; - Else if
targetis a component with a value, then the pair takes the same value type; - Otherwise, the pair is a tag pair and does not hold a value.
Type Parameters
Section titled “Type Parameters”R
T
Parameters
Section titled “Parameters”relation
Section titled “relation”target
Section titled “target”Returns
Section titled “Returns”Pair<R>
Examples
Section titled “Examples”const Likes = component()const Owns = component<number>()
const car = entity()const bob = entity() // Because neither `Likes` nor `car` hold values, we have no value to assign. .set(pair(Likes, car)) // Because `Owns` holds a number value, the pair takes a number value. .set(pair(Owns, car), 2)const Begin = component()const End = component()const Position = component<Vector3>()
const line = entity() // Because `Begin` and `End` hold no values, those pairs take the value from `Position`. .set(pair(Begin, Position), new Vector3(0, 0, 0)) .set(pair(End, Position), new Vector3(10, 0, 0))Call Signature
Section titled “Call Signature”pair<
R>(relation,target):Pair<R>
Defined in: src/pair.ts:84
Creates a relationship pair relation → target (e.g.: Likes → Bob),
where both relation and target can be either entities or components.
Pairs can be assigned to any id, forming something like Alice → Likes → Bob.
Like components, pairs can be associated to values. The value type of a
pair is determined by its relation and target arguments:
- If
relationis a component with a value, then the pair takes the same value type; - Else if
targetis a component with a value, then the pair takes the same value type; - Otherwise, the pair is a tag pair and does not hold a value.
Type Parameters
Section titled “Type Parameters”R
Parameters
Section titled “Parameters”relation
Section titled “relation”target
Section titled “target”Returns
Section titled “Returns”Pair<R>
Examples
Section titled “Examples”const Likes = component()const Owns = component<number>()
const car = entity()const bob = entity() // Because neither `Likes` nor `car` hold values, we have no value to assign. .set(pair(Likes, car)) // Because `Owns` holds a number value, the pair takes a number value. .set(pair(Owns, car), 2)const Begin = component()const End = component()const Position = component<Vector3>()
const line = entity() // Because `Begin` and `End` hold no values, those pairs take the value from `Position`. .set(pair(Begin, Position), new Vector3(0, 0, 0)) .set(pair(End, Position), new Vector3(10, 0, 0))Call Signature
Section titled “Call Signature”pair<
T>(relation,target):Pair<T>
Defined in: src/pair.ts:85
Creates a relationship pair relation → target (e.g.: Likes → Bob),
where both relation and target can be either entities or components.
Pairs can be assigned to any id, forming something like Alice → Likes → Bob.
Like components, pairs can be associated to values. The value type of a
pair is determined by its relation and target arguments:
- If
relationis a component with a value, then the pair takes the same value type; - Else if
targetis a component with a value, then the pair takes the same value type; - Otherwise, the pair is a tag pair and does not hold a value.
Type Parameters
Section titled “Type Parameters”T
Parameters
Section titled “Parameters”relation
Section titled “relation”target
Section titled “target”Returns
Section titled “Returns”Pair<T>
Examples
Section titled “Examples”const Likes = component()const Owns = component<number>()
const car = entity()const bob = entity() // Because neither `Likes` nor `car` hold values, we have no value to assign. .set(pair(Likes, car)) // Because `Owns` holds a number value, the pair takes a number value. .set(pair(Owns, car), 2)const Begin = component()const End = component()const Position = component<Vector3>()
const line = entity() // Because `Begin` and `End` hold no values, those pairs take the value from `Position`. .set(pair(Begin, Position), new Vector3(0, 0, 0)) .set(pair(End, Position), new Vector3(10, 0, 0))Call Signature
Section titled “Call Signature”pair(
relation,target):Pair<undefined>
Defined in: src/pair.ts:86
Creates a relationship pair relation → target (e.g.: Likes → Bob),
where both relation and target can be either entities or components.
Pairs can be assigned to any id, forming something like Alice → Likes → Bob.
Like components, pairs can be associated to values. The value type of a
pair is determined by its relation and target arguments:
- If
relationis a component with a value, then the pair takes the same value type; - Else if
targetis a component with a value, then the pair takes the same value type; - Otherwise, the pair is a tag pair and does not hold a value.
Parameters
Section titled “Parameters”relation
Section titled “relation”target
Section titled “target”Returns
Section titled “Returns”Pair<undefined>
Examples
Section titled “Examples”const Likes = component()const Owns = component<number>()
const car = entity()const bob = entity() // Because neither `Likes` nor `car` hold values, we have no value to assign. .set(pair(Likes, car)) // Because `Owns` holds a number value, the pair takes a number value. .set(pair(Owns, car), 2)const Begin = component()const End = component()const Position = component<Vector3>()
const line = entity() // Because `Begin` and `End` hold no values, those pairs take the value from `Position`. .set(pair(Begin, Position), new Vector3(0, 0, 0)) .set(pair(End, Position), new Vector3(10, 0, 0))