Skip to content

Data Interfaces

A comprehensive list of data structures used in the engine.

game

game.options

GAME_OPTIONS

ts
interface GAME_OPTIONS {
    stage: string;
    servers: Record<string, SERVER_DATA>;
    userGroup: number;
}

SERVER_DATA

ts
interface SERVER_DATA = {
    id: string;
    region: string;
    name: string;
    hostname: string;
    ipAddress: string;
    port: number;
    fallbackPort: number;
    selected: boolean;
};

network

Packet Interfaces

ENTER_WORLD_DATA

ts
interface ENTER_WORLD_DATA {
    allowed: boolean,
    uid: string,
    startingTick: number,
    tickRate: number,
    effectiveTickRate: number,
    players: number,
    maxPlayers: number,
    chatChannel: number,
    effectiveDisplayName: string,
    x1: number,
    y1: number,
    x2: number,
    y2: number,
    opcode: number
}

INFO

ENTER_WORLD_DATA also populates BinCodec's internal attributeMaps, entityTypeNames, sortedUidsByType, and rpcMaps / rpcMapsByName tables. These are not returned directly but are used by subsequent decodeEntityUpdate and decodeRpc calls.

ENTITY_UPDATE_DATA

ts
interface ENTITY_UPDATE_DATA {
    opcode: number,
    tick: number,
    entities: Record<string, ENTITY_DATA | true>,
    byteSize: number
}

TIP

When an entity is present in the update but has no changed attributes, it is stored as true instead of a full ENTITY_DATA object. This signals that the entity still exists but can reuse its previous tick data.

ENTITY_DATA

The shape of this object is dynamic as its keys are determined by the entity's attributeMap received during ENTER_WORLD_DATA. All entities include a uid field; the remaining fields depend on the entity type.

ts
interface ENTITY_DATA {
    uid: number,
    [attributeName: string]: number | string | Vector2 | Vector2[] | number[]
}

PING_DATA

ts
interface PING_DATA {
    opcode: number
}

INFO

The ping response carries no payload as it is an empty object. The opcode field is added by the top-level decode() method.

RPC_DATA

ts
interface SERVER_RPC_DATA {
    opcode: number,
    name: string,
    response: Record<string, any> | Record<string, any>[]
}

INFO

If the RPC is defined as an array type (isArray), response will be an array of objects. Otherwise it will be a single object.

ts
interface CLIENT_RPC_DATA {
    name: string,
    [parameter: string]: string | number
}

TIP

The shape of each RPC is determined by the RPC's parameters from rpcMaps. If the RPC is client-side, parameters will be injected directly into the RPC object. If it is a server-side RPC, parameters will be inside of response.

ATTRIBUTE_MAP_ENTRY

Internal structure populated during decodeEnterWorldResponse. One entry per attribute on an entity type.

ts
interface ATTRIBUTE_MAP_ENTRY {
    name: string,
    type: e_AttributeType
}

RPC_MAP_ENTRY

Internal structure populated during decodeEnterWorldResponse. One entry per registered RPC.

ts
interface RPC_MAP_ENTRY {
    name: string,
    parameters: RPC_PARAMETER_ENTRY[],
    isArray: boolean,
    index: number
}

RPC_PARAMETER_ENTRY

ts
interface RPC_PARAMETER_ENTRY {
    name: string,
    type: e_ParameterType
}

Attribute Interfaces

Vector2

ts
interface Vector2 {
    x: number,
    y: number
}

renderer

renderer.viewport

VIEWPORT

ts
interface VIEWPORT {
    x: number
    y: number
    width: number
    height: number
}