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

addOrSetTrait

addOrSetTrait<S>(writer, target, trait, …record): boolean

Adds trait to target where it lacks it, and sets it to record where it holds it: an entity’s, or the world’s for a world trait, such as a poison a second hit starts again. Answers true where this call added the trait, and false where it set one the target held, or where a deployed world refused the write and logged it, writing nothing. The writer is as setTrait’s. record is the whole record, every field of a trait of fields, so the result never depends on what the target held; a write of some fields that keeps the rest asks entity.has(Trait) first. A tag, or a trait of an empty schema, takes none, and a factory trait’s record is never null or undefined. An add tells the add’s watchers with the record in place, as addTrait, and is refused "world-full" where addTrait is; a set tells the change watchers, as setTrait. In a predicted system the answer may differ between the page’s run, a re-run and the room’s, so a one-shot reaction to the add, such as a sound, goes through an event. As Unity’s EntityManager.AddComponentData.

Type Parameter
S extends Schema
Parameter Type
writer EntityAuthority | PredictedStep
target PredictedEntity
trait PredictedTrait<S>
…record WholeSchemaArgument<S>

boolean

addOrSetTrait<T>(writer, target, trait, …record): boolean

Adds trait to target where it lacks it, and sets it to record where it holds it: an entity’s, or the world’s for a world trait, such as a poison a second hit starts again. Answers true where this call added the trait, and false where it set one the target held, or where a deployed world refused the write and logged it, writing nothing. The writer is as setTrait’s. record is the whole record, every field of a trait of fields, so the result never depends on what the target held; a write of some fields that keeps the rest asks entity.has(Trait) first. A tag, or a trait of an empty schema, takes none, and a factory trait’s record is never null or undefined. An add tells the add’s watchers with the record in place, as addTrait, and is refused "world-full" where addTrait is; a set tells the change watchers, as setTrait. In a predicted system the answer may differ between the page’s run, a re-run and the room’s, so a one-shot reaction to the add, such as a sound, goes through an event. As Unity’s EntityManager.AddComponentData.

Type Parameter
T extends UnstreamedTrait
Parameter Type
writer EntityAuthority | SystemStep
target Target
trait T
…record WholeRecordArgument<T>

boolean

addOrSetTrait<T>(writer, target, trait, …record): boolean

Adds trait to target where it lacks it, and sets it to record where it holds it: an entity’s, or the world’s for a world trait, such as a poison a second hit starts again. Answers true where this call added the trait, and false where it set one the target held, or where a deployed world refused the write and logged it, writing nothing. The writer is as setTrait’s. record is the whole record, every field of a trait of fields, so the result never depends on what the target held; a write of some fields that keeps the rest asks entity.has(Trait) first. A tag, or a trait of an empty schema, takes none, and a factory trait’s record is never null or undefined. An add tells the add’s watchers with the record in place, as addTrait, and is refused "world-full" where addTrait is; a set tells the change watchers, as setTrait. In a predicted system the answer may differ between the page’s run, a re-run and the room’s, so a one-shot reaction to the add, such as a sound, goes through an event. As Unity’s EntityManager.AddComponentData.

Type Parameter
T extends AnyEntityPredictedTrait
Parameter Type
writer PredictedStep
target PredictedEntity
trait T
…record WholeRecordArgument<T>

boolean

addOrSetTrait<T>(writer, target, trait, …record): boolean

Adds trait to target where it lacks it, and sets it to record where it holds it: an entity’s, or the world’s for a world trait, such as a poison a second hit starts again. Answers true where this call added the trait, and false where it set one the target held, or where a deployed world refused the write and logged it, writing nothing. The writer is as setTrait’s. record is the whole record, every field of a trait of fields, so the result never depends on what the target held; a write of some fields that keeps the rest asks entity.has(Trait) first. A tag, or a trait of an empty schema, takes none, and a factory trait’s record is never null or undefined. An add tells the add’s watchers with the record in place, as addTrait, and is refused "world-full" where addTrait is; a set tells the change watchers, as setTrait. In a predicted system the answer may differ between the page’s run, a re-run and the room’s, so a one-shot reaction to the add, such as a sound, goes through an event. As Unity’s EntityManager.AddComponentData.

Type Parameter
T extends Trait
Parameter Type
writer EntityAuthority
target Entity
trait T
…record WholeRecordArgument<T>

boolean

addOrSetTrait<T>(writer, target, trait, …record): boolean

Adds trait to target where it lacks it, and sets it to record where it holds it: an entity’s, or the world’s for a world trait, such as a poison a second hit starts again. Answers true where this call added the trait, and false where it set one the target held, or where a deployed world refused the write and logged it, writing nothing. The writer is as setTrait’s. record is the whole record, every field of a trait of fields, so the result never depends on what the target held; a write of some fields that keeps the rest asks entity.has(Trait) first. A tag, or a trait of an empty schema, takes none, and a factory trait’s record is never null or undefined. An add tells the add’s watchers with the record in place, as addTrait, and is refused "world-full" where addTrait is; a set tells the change watchers, as setTrait. In a predicted system the answer may differ between the page’s run, a re-run and the room’s, so a one-shot reaction to the add, such as a sound, goes through an event. As Unity’s EntityManager.AddComponentData.

Type Parameter
T extends Trait
Parameter Type
writer Authority
target World
trait T
…record WholeRecordArgument<T>

boolean

addOrSetTrait<T>(writer, target, trait, …record): boolean

Adds trait to target where it lacks it, and sets it to record where it holds it: an entity’s, or the world’s for a world trait, such as a poison a second hit starts again. Answers true where this call added the trait, and false where it set one the target held, or where a deployed world refused the write and logged it, writing nothing. The writer is as setTrait’s. record is the whole record, every field of a trait of fields, so the result never depends on what the target held; a write of some fields that keeps the rest asks entity.has(Trait) first. A tag, or a trait of an empty schema, takes none, and a factory trait’s record is never null or undefined. An add tells the add’s watchers with the record in place, as addTrait, and is refused "world-full" where addTrait is; a set tells the change watchers, as setTrait. In a predicted system the answer may differ between the page’s run, a re-run and the room’s, so a one-shot reaction to the add, such as a sound, goes through an event. As Unity’s EntityManager.AddComponentData.

Type Parameter
T extends Trait
Parameter Type
writer SetupWriter
target Target
trait T
…record WholeRecordArgument<T>

boolean

addOrSetTrait<T>(writer, target, trait, …record): boolean

Adds trait to target where it lacks it, and sets it to record where it holds it: an entity’s, or the world’s for a world trait, such as a poison a second hit starts again. Answers true where this call added the trait, and false where it set one the target held, or where a deployed world refused the write and logged it, writing nothing. The writer is as setTrait’s. record is the whole record, every field of a trait of fields, so the result never depends on what the target held; a write of some fields that keeps the rest asks entity.has(Trait) first. A tag, or a trait of an empty schema, takes none, and a factory trait’s record is never null or undefined. An add tells the add’s watchers with the record in place, as addTrait, and is refused "world-full" where addTrait is; a set tells the change watchers, as setTrait. In a predicted system the answer may differ between the page’s run, a re-run and the room’s, so a one-shot reaction to the add, such as a sound, goes through an event. As Unity’s EntityManager.AddComponentData.

Type Parameter
T extends LocalTrait
Parameter Type
writer ViewWriter | EntityAuthority | SystemStep
target Target
trait T
…record WholeRecordArgument<T>

boolean