Skip to content

pair

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 relation is a component with a value, then the pair takes the same value type;
  • Else if target is 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.

R

ComponentHandle<R>

ComponentHandle<undefined>

Pair<R>

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))

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 relation is a component with a value, then the pair takes the same value type;
  • Else if target is 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.

T

ComponentHandle<undefined>

ComponentHandle<T>

Pair<T>

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))

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 relation is a component with a value, then the pair takes the same value type;
  • Else if target is 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.

R

T

ComponentHandle<R>

ComponentHandle<T>

Pair<R>

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))

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 relation is a component with a value, then the pair takes the same value type;
  • Else if target is 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.

R

ComponentHandle<R>

EntityHandle

Pair<R>

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))

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 relation is a component with a value, then the pair takes the same value type;
  • Else if target is 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.

T

EntityHandle

ComponentHandle<T>

Pair<T>

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))

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 relation is a component with a value, then the pair takes the same value type;
  • Else if target is 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.

EntityHandle

EntityHandle

Pair<undefined>

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))