# @latticexyz/std-client

# Enumerations

# ActionState

ActionState: Enum ActionState

# Defined in

std-client/src/systems/ActionSystem/constants.ts:1

# Type Aliases

# ActionSystem

Ƭ ActionSystem: ReturnType<typeof createActionSystem>

# Defined in

std-client/src/systems/ActionSystem/createActionSystem.ts:23


# ContractComponent

Ƭ ContractComponent: Component<Schema, Object>

# Defined in

std-client/src/setup/types.ts:25


# ContractComponents

Ƭ ContractComponents: Object

# Index signature

▪ [key: string]: ContractComponent

# Defined in

std-client/src/setup/types.ts:27


# DecodedNetworkComponentUpdate

Ƭ DecodedNetworkComponentUpdate: Omit<Omit<NetworkComponentUpdate, "entity">, "component"> & Object

# Defined in

std-client/src/setup/types.ts:11


# DecodedSystemCall

Ƭ DecodedSystemCall: Omit<SystemCall<C>, "updates"> & Object

# Type parameters

Name Type
T extends Object = Object
C extends Components = Components

# Defined in

std-client/src/setup/types.ts:16


# NetworkComponents

Ƭ NetworkComponents: C & Object

# Type parameters

Name Type
C extends ContractComponents

# Defined in

std-client/src/setup/types.ts:31


# SetupContractConfig

Ƭ SetupContractConfig: NetworkConfig & Omit<SyncWorkerConfig, "worldContract" | "mappings"> & Object

# Defined in

std-client/src/setup/types.ts:5

# Variables

# ActionStateString

Const ActionStateString: Object

# Type declaration

Name Type
0 string
1 string
2 string
3 string
4 string
5 string
6 string

# Defined in

std-client/src/systems/ActionSystem/constants.ts:11

# Functions

# applyNetworkUpdates

applyNetworkUpdates<C>(world, components, ecsEvents$, mappings, ack$, decodeAndEmitSystemCall?): Object

Sets up synchronization between contract components and client components

# Type parameters

Name Type
C extends Components

# Parameters

Name Type
world World
components C
ecsEvents$ Observable<NetworkEvent<C>[]>
mappings Mappings<C>
ack$ Subject<Ack>
decodeAndEmitSystemCall? Function

# Returns

Object

Name Type
txReduced$ Observable<string>

# Defined in

std-client/src/setup/utils.ts:134


# createActionSystem

createActionSystem<M>(world, txReduced$): Object

# Type parameters

Name Type
M undefined

# Parameters

Name Type
world World
txReduced$ Observable<string>

# Returns

Object

Name Type
Action Component<Object, Metadata, M>
add Function
cancel Function
withOptimisticUpdates Function

# Defined in

std-client/src/systems/ActionSystem/createActionSystem.ts:25


# createDecodeNetworkComponentUpdate

createDecodeNetworkComponentUpdate<C>(world, components, mappings): Function

# Type parameters

Name Type
C extends Components

# Parameters

Name Type
world World
components C
mappings Mappings<C>

# Returns

Function

▸ (update): DecodedNetworkComponentUpdate | undefined

# Parameters
Name Type
update NetworkComponentUpdate
# Returns

DecodedNetworkComponentUpdate | undefined

# Defined in

std-client/src/setup/utils.ts:36


# createEncoders

createEncoders(world, components, signerOrProvider): Promise<Record<string, Function>>

# Parameters

Name Type
world World
components Component<Object, Metadata, undefined>
signerOrProvider IComputedValue<JsonRpcProvider | Signer>

# Returns

Promise<Record<string, Function>>

# Defined in

std-client/src/setup/utils.ts:101


# createSystemCallStreams

createSystemCallStreams<C, SystemTypes>(world, systemNames, systemsRegistry, getSystemContract, decodeNetworkComponentUpdate): Object

# Type parameters

Name Type
C extends Components
SystemTypes extends Object

# Parameters

Name Type
world World
systemNames string[]
systemsRegistry Component<Object, Metadata, undefined>
getSystemContract Function
decodeNetworkComponentUpdate Function

# Returns

Object

Name Type
decodeAndEmitSystemCall Function
systemCallStreams Record<string, Subject<DecodedSystemCall<SystemTypes, C>>>

# Defined in

std-client/src/setup/utils.ts:59


# defineActionComponent

defineActionComponent<T>(world): Component<Object, Metadata, T>

# Type parameters

Name Type
T undefined

# Parameters

Name Type
world World

# Returns

Component<Object, Metadata, T>

# Defined in

std-client/src/components/ActionComponent.ts:3


# defineBoolComponent

defineBoolComponent<M>(world, options?): Component<Object, M, undefined>

# Type parameters

Name Type
M extends Metadata

# Parameters

Name Type
world World
options? Object
options.id? string
options.indexed? boolean
options.metadata? M

# Returns

Component<Object, M, undefined>

# Defined in

std-client/src/components/BoolComponent.ts:3


# defineCoordComponent

defineCoordComponent<M>(world, options?): Component<Object, M, undefined>

# Type parameters

Name Type
M extends Metadata

# Parameters

Name Type
world World
options? Object
options.id? string
options.indexed? boolean
options.metadata? M

# Returns

Component<Object, M, undefined>

# Defined in

std-client/src/components/CoordComponent.ts:3


# defineDevHighlightComponent

defineDevHighlightComponent(world): Component<Object, Metadata, undefined>

DevHighlight is for use during development to highlight the positions of entities that you are interacting with. Example: Highlight the Entities that you are currently editing in the ComponentBrowser.

# Parameters

Name Type
world World

# Returns

Component<Object, Metadata, undefined>

# Defined in

std-client/src/components/DevHighlight.ts:8


# defineNumberComponent

defineNumberComponent<M>(world, options?): Component<Object, M, undefined>

# Type parameters

Name Type
M extends Metadata

# Parameters

Name Type
world World
options? Object
options.id? string
options.indexed? boolean
options.metadata? M

# Returns

Component<Object, M, undefined>

# Defined in

std-client/src/components/NumberComponent.ts:3


# defineStringComponent

defineStringComponent<M>(world, options?): Component<Object, M, undefined>

# Type parameters

Name Type
M extends Metadata

# Parameters

Name Type
world World
options? Object
options.id? string
options.indexed? boolean
options.metadata? M

# Returns

Component<Object, M, undefined>

# Defined in

std-client/src/components/StringComponent.ts:3


# defineVoxelCoordComponent

defineVoxelCoordComponent<M>(world, options?): Component<Object, M, undefined>

# Type parameters

Name Type
M extends Metadata

# Parameters

Name Type
world World
options? Object
options.id? string
options.indexed? boolean
options.metadata? M

# Returns

Component<Object, M, undefined>

# Defined in

std-client/src/components/VoxelCoordComponent.ts:3


# findEntityWithComponentInRelationshipChain

findEntityWithComponentInRelationshipChain(relationshipComponent, entity, searchComponent): EntityIndex | undefined

Starting with the given entity, traverse the relationship chain until you find an entity that has the given component.

# Parameters

Name Type Description
relationshipComponent Component<Object, Metadata, undefined> The component that will be used to traverse the relationship chain.
entity EntityIndex Starting entity
searchComponent Component<Schema, Metadata, undefined> The component to search for.

# Returns

EntityIndex | undefined

The first entity in the relationship chain that has the given component or undefined if the relationship chain is broken.

# Defined in

std-client/src/utils.ts:116


# findInRelationshipChain

findInRelationshipChain(relationshipComponent, entity, searchEntity): boolean

Find a specific entity in a relationship chain.

# Parameters

Name Type Description
relationshipComponent Component<Object, Metadata, undefined> The component that will be used to traverse the relationship chain.
entity EntityIndex Starting entity
searchEntity EntityIndex Entity to search for

# Returns

boolean

True if the entity is found in the relationship chain, false otherwise.

# Defined in

std-client/src/utils.ts:143


# getCurrentTurn

getCurrentTurn(world, gameConfigComponent, clock): number

# Parameters

Name Type
world World
gameConfigComponent Component<Object, Metadata, undefined>
clock Clock

# Returns

number

# Defined in

std-client/src/utils.ts:24


# getGameConfig

getGameConfig(world, gameConfigComponent): undefined | ComponentValue<Object, undefined>

# Parameters

Name Type
world World
gameConfigComponent Component<Object, Metadata, undefined>

# Returns

undefined | ComponentValue<Object, undefined>

# Defined in

std-client/src/utils.ts:54


# getPlayerEntity

getPlayerEntity(address, world, Player): EntityIndex | undefined

# Parameters

Name Type
address undefined | string
world World
Player Component<Object, Metadata, undefined>

# Returns

EntityIndex | undefined

# Defined in

std-client/src/utils.ts:76


# getStringColor

getStringColor(address): number

# Parameters

Name Type
address string

# Returns

number

# Defined in

std-client/src/utils.ts:239


# getTurnAtTime

getTurnAtTime(world, gameConfigComponent, time): number

# Parameters

Name Type
world World
gameConfigComponent Component<Object, Metadata, undefined>
time number

# Returns

number

# Defined in

std-client/src/utils.ts:36


# isUntraversable

isUntraversable(untraversableComponent, positionComponent, targetPosition): boolean

# Parameters

Name Type
untraversableComponent Component<Object, Metadata, undefined>
positionComponent Component<Object, Metadata, undefined>
targetPosition Coord

# Returns

boolean

# Defined in

std-client/src/utils.ts:64


# randomColor

randomColor(id): number

Generate a random color based on the given id.

# Parameters

Name Type Description
id string Any string

# Returns

number

A color in the range 0x000000 - 0xFFFFFF

# Defined in

std-client/src/utils.ts:168


# resolveRelationshipChain

resolveRelationshipChain(relationshipComponent, entity): EntityIndex | undefined

Starting with the given entity, traverse the relationship chain until the end is reached.

# Parameters

Name Type Description
relationshipComponent Component<Object, Metadata, undefined> The component that will be used to traverse the relationship chain.
entity EntityIndex Starting entity

# Returns

EntityIndex | undefined

The last entity in the relationship chain or undefined if the relationship chain is broken.

# Defined in

std-client/src/utils.ts:95


# setupMUDNetwork

setupMUDNetwork<C, SystemTypes>(networkConfig, world, contractComponents, SystemAbis, options?): Promise<Object>

# Type parameters

Name Type
C extends ContractComponents
SystemTypes extends Object

# Parameters

Name Type
networkConfig SetupContractConfig
world World
contractComponents C
SystemAbis { [key in string | number | symbol]: ContractInterface }
options? Object
options.fetchSystemCalls? boolean
options.initialGasPrice? number

# Returns

Promise<Object>

# Defined in

std-client/src/setup/setupMUDNetwork.ts:28


# useComponentValueStream

useComponentValueStream<T>(component, entity?): undefined | null | ComponentValue<T, undefined>

Deprecated

Use hooks exported from @latticexyz/react package instead.

# Type parameters

Name Type
T extends Schema

# Parameters

Name Type
component Component<T, Metadata, undefined>
entity? EntityIndex

# Returns

undefined | null | ComponentValue<T, undefined>

# Defined in

std-client/src/hooks.ts:19


# useQuery

useQuery(queryFragments): undefined | ObservableSet<EntityIndex>

Handles subscribing and unsubscribing to a queries update stream to keep the matching set up to date

Deprecated

Use hooks exported from @latticexyz/react package instead.

# Parameters

Name Type Description
queryFragments EntityQueryFragment<Schema>[] Query fragments

# Returns

undefined | ObservableSet<EntityIndex>

Mobx ObservablesSet with entities currently matching the query

# Defined in

std-client/src/hooks.ts:36


# useStream

useStream<T>(stream, defaultValue?): undefined | T

Deprecated

Use hooks exported from @latticexyz/react package instead.

# Type parameters

Name
T

# Parameters

Name Type
stream Observable<T>
defaultValue? T

# Returns

undefined | T

# Defined in

std-client/src/hooks.ts:7


# waitForActionCompletion

waitForActionCompletion(Action, entity): Promise<void>

# Parameters

Name Type
Action Component<Object, Metadata, unknown>
entity EntityIndex

# Returns

Promise<void>

# Defined in

std-client/src/systems/ActionSystem/utils/waitForActionCompletion.ts:6


# waitForComponentValue

waitForComponentValue<S>(component, entity, value): Promise<void>

# Type parameters

Name Type
S extends Schema

# Parameters

Name Type
component Component<S, Metadata, undefined>
entity EntityIndex
value Partial<ComponentValue<S, undefined>>

# Returns

Promise<void>

# Defined in

std-client/src/utils.ts:265


# waitForComponentValueIn

waitForComponentValueIn<S, T>(component, entity, values): Promise<void>

# Type parameters

Name Type
S extends Schema
T T

# Parameters

Name Type
component Component<S, Metadata, T>
entity EntityIndex
values Partial<ComponentValue<S, undefined>>[]

# Returns

Promise<void>

# Defined in

std-client/src/utils.ts:243