Skip to content
Work in progress. These docs describe Spawnite at launch, and some parts are still being built.

setTrait

setTrait<S>(writer, target, trait, value): void

Sets target’s trait to value: an entity’s, or the world’s for a world trait. A trait of fields takes the fields to change; a factory trait’s value is copied into the record it keeps, so a writer that keeps and changes its own object changes nothing. The first argument is what may write it: a trait the room streams takes an authority, the room’s step or requireAuthority(world); a Reach.Local or Reach.Authority trait takes any step; a predicted trait takes a predicted step, on the PredictedEntity it hands out. The target holds the trait already: addTrait adds one. It tells the trait’s watchers, as koota’s set does. As Unity’s EntityManager.SetComponentData.

Type Parameter
S extends Schema
Parameter Type
writer EntityAuthority | PredictedStep
target PredictedEntity
trait PredictedTrait<S>
value TraitValue<S>

void

setTrait<T>(writer, target, trait, value): void

Sets target’s trait to value: an entity’s, or the world’s for a world trait. A trait of fields takes the fields to change; a factory trait’s value is copied into the record it keeps, so a writer that keeps and changes its own object changes nothing. The first argument is what may write it: a trait the room streams takes an authority, the room’s step or requireAuthority(world); a Reach.Local or Reach.Authority trait takes any step; a predicted trait takes a predicted step, on the PredictedEntity it hands out. The target holds the trait already: addTrait adds one. It tells the trait’s watchers, as koota’s set does. As Unity’s EntityManager.SetComponentData.

Type Parameter
T extends UnstreamedTrait
Parameter Type
writer EntityAuthority | SystemStep
target Target
trait T
value TraitValue<ExtractSchema<T>>

void

setTrait<T>(writer, target, trait, value): void

Sets target’s trait to value: an entity’s, or the world’s for a world trait. A trait of fields takes the fields to change; a factory trait’s value is copied into the record it keeps, so a writer that keeps and changes its own object changes nothing. The first argument is what may write it: a trait the room streams takes an authority, the room’s step or requireAuthority(world); a Reach.Local or Reach.Authority trait takes any step; a predicted trait takes a predicted step, on the PredictedEntity it hands out. The target holds the trait already: addTrait adds one. It tells the trait’s watchers, as koota’s set does. As Unity’s EntityManager.SetComponentData.

Type Parameter
T extends AnyEntityPredictedTrait
Parameter Type
writer PredictedStep
target PredictedEntity
trait T
value TraitValue<ExtractSchema<T>>

void

setTrait<T>(writer, target, trait, value): void

Sets target’s trait to value: an entity’s, or the world’s for a world trait. A trait of fields takes the fields to change; a factory trait’s value is copied into the record it keeps, so a writer that keeps and changes its own object changes nothing. The first argument is what may write it: a trait the room streams takes an authority, the room’s step or requireAuthority(world); a Reach.Local or Reach.Authority trait takes any step; a predicted trait takes a predicted step, on the PredictedEntity it hands out. The target holds the trait already: addTrait adds one. It tells the trait’s watchers, as koota’s set does. As Unity’s EntityManager.SetComponentData.

Type Parameter
T extends Trait
Parameter Type
writer EntityAuthority
target Entity
trait T
value TraitValue<ExtractSchema<T>>

void

setTrait<T>(writer, target, trait, value): void

Sets target’s trait to value: an entity’s, or the world’s for a world trait. A trait of fields takes the fields to change; a factory trait’s value is copied into the record it keeps, so a writer that keeps and changes its own object changes nothing. The first argument is what may write it: a trait the room streams takes an authority, the room’s step or requireAuthority(world); a Reach.Local or Reach.Authority trait takes any step; a predicted trait takes a predicted step, on the PredictedEntity it hands out. The target holds the trait already: addTrait adds one. It tells the trait’s watchers, as koota’s set does. As Unity’s EntityManager.SetComponentData.

Type Parameter
T extends Trait
Parameter Type
writer Authority
target World
trait T
value TraitValue<ExtractSchema<T>>

void

setTrait<T>(writer, target, trait, value): void

Sets target’s trait to value: an entity’s, or the world’s for a world trait. A trait of fields takes the fields to change; a factory trait’s value is copied into the record it keeps, so a writer that keeps and changes its own object changes nothing. The first argument is what may write it: a trait the room streams takes an authority, the room’s step or requireAuthority(world); a Reach.Local or Reach.Authority trait takes any step; a predicted trait takes a predicted step, on the PredictedEntity it hands out. The target holds the trait already: addTrait adds one. It tells the trait’s watchers, as koota’s set does. As Unity’s EntityManager.SetComponentData.

Type Parameter
T extends Trait
Parameter Type
writer SetupWriter
target Target
trait T
value TraitValue<ExtractSchema<T>>

void

setTrait<T>(writer, target, trait, value): void

Sets target’s trait to value: an entity’s, or the world’s for a world trait. A trait of fields takes the fields to change; a factory trait’s value is copied into the record it keeps, so a writer that keeps and changes its own object changes nothing. The first argument is what may write it: a trait the room streams takes an authority, the room’s step or requireAuthority(world); a Reach.Local or Reach.Authority trait takes any step; a predicted trait takes a predicted step, on the PredictedEntity it hands out. The target holds the trait already: addTrait adds one. It tells the trait’s watchers, as koota’s set does. As Unity’s EntityManager.SetComponentData.

Type Parameter
T extends LocalTrait
Parameter Type
writer ViewWriter | EntityAuthority | SystemStep
target Target
trait T
value TraitValue<ExtractSchema<T>>

void