Net
Back to the reference

Net

Online games: the same scenes in a room of a server, which decides, and in each player's page, which shows it and asks; the server, its rooms, and the lines between them.

29 symbols

nacatamalon/net

connectLoopbackfunctionexperimentalnacatamalon/net

connectLoopback(server: TServer, options: TLoopbackOptions) => TNetConnection

Connects a player's game to a server in the same page or process, with no network at all: a line in memory, given to server.accept at once, whose other end goes to useNet().connect. For trying an online game in one page (the server's room and two players side by side), and for tests.

Messages still go as text, so what JSON cannot carry fails here as it would over the internet, and still arrive later, in order, never in the middle of a frame. delay makes the line as slow as a real one, to see how the game feels from far away.

Parameters

serverTServer

Example

import { createScene, type TSceneFn } from 'nacatamalon';
import { connectLoopback, createServer, useNet } from 'nacatamalon/net';

// The same scene runs in the server's room and in the player's page.
const Lobby: TSceneFn = () => {
    const net = useNet();
    if (net.role === 'client') {
        // Into the server below, 50 ms away each way.
        net.connect(connectLoopback(server, { delay: 0.05 }), { room: 'lobby' });
    }
    return createScene();
};

const server = createServer({ width: 320, height: 180, scenes: { Lobby }, step: 20 });
View source · net/connect_loopback.ts:68

createRoomfunctionexperimentalnacatamalon/net

createRoom(options: TRoomOptions) => TRoom

Makes a room: the game's own scenes running with no screen and no sound, deciding what happens, with players coming in over their connections. The scenes are the same a player's page runs, and useNet().role is 'server' in them, so the code that decides (who won, how many coins) runs here and nowhere else.

createServer makes these on its own, one for each room asked for. This is for a server of someone else's (socket.io, or a framework with rooms of its own) that holds the rooms itself: it lets each player in with join, over their connection wrapped as a TNetConnection, and, with clock: false, moves the room with step() from its own loop.

It runs in a page, in Bun and in Node. In a page it is never heard, and its files come from the page's address; elsewhere they are read from assets.

Parameters

Example

import { createScene, type TSceneFn } from 'nacatamalon';
import { createRoom } from 'nacatamalon/net';

// The game's own scene, as its players' pages run it.
const Lobby: TSceneFn = () => createScene();

// What of socket.io's server this uses (`import { Server } from 'socket.io'`).
type Socket = {
    emit(event: string, text: string): void;
    on(event: string, listener: (value: string) => void): void;
    disconnect(): void;
};
declare const io: { on(event: 'connection', listener: (socket: Socket) => void): void };

const room = createRoom({ width: 320, height: 180, scenes: { Lobby }, step: 20, name: 'lobby' });

io.on('connection', (socket) => {
    let hear: (text: string) => void = () => {};
    socket.on('naca', (text) => hear(text));
    room.join({
        send: (text) => socket.emit('naca', text),
        onMessage: (listener) => { hear = listener; },
        onClose: (listener) => socket.on('disconnect', (reason) => listener(reason)),
        close: () => socket.disconnect(),
    });
});
View source · net/create_room.ts:174

createRoomStorefunctionexperimentalnacatamalon/net

createRoomStore(options: TRoomStoreOptions<S>) => TRoomStoreDecl<S>

Declares a room store: data of one room (its score, its round, whose turn it is) that the room changes and every player in it sees, a moment later, read only.

A store of the game (createGameStore) is one object for everything that imports it: in a server with many rooms, one for all of them, so a goal in one room would score in every room. This one is a plan, holding nothing: each game has its own, asked for with useRoomStore while something is being built (a scene, an object, a game system), room.store from the server's own code, or roomStoreOf from a page's HUD. The room's is the one that is changed; in a player's page it is a copy the room keeps up to date, changed before anything the room says after the change. A game tried on its own, never connected, has one of its own to change, as the room would.

Parameters

Example

import { createScene, createText } from 'nacatamalon';
import { createRoomStore, useNet, useRoomStore } from 'nacatamalon/net';

// stores/score.ts
export const score = createRoomStore({ key: 'score', state: { red: 0, blue: 0 } });

// scenes/match.ts
const Match = () => {
    const net = useNet();
    const board = useRoomStore(score);
    const label = createText({ text: '0 - 0' });
    board.watch((s) => `${s.red} - ${s.blue}`, (text) => { label.text = text; });
    if (board.writable) {
        net.onMessage<'red' | 'blue'>('goal', (team) => board.set((s) => { s[team] += 1; }));
    }
    return createScene();
};
View source · net/create_room_store.ts:46

createServerfunctionexperimentalnacatamalon/net

createServer(options: TServerOptions) => TServer

Makes a server: it takes players' connections, asks admit who gets in, and gives each room asked for a game of its own (createRoom) running the game's scenes, which ends when its last player leaves. What the rooms decide is the truth every player's game is told.

Connections come from listen(port), in Bun or Node, from connectLoopback, in the same page or process, or from any server of someone else's through accept. The players' games connect with useNet().connect.

Accounts are the game's: the engine carries the token a player's game sends and asks admit, which checks it however the game keeps its players.

Parameters

Example

// server.ts, run with `bun server.ts` (or Node: `node server.js`)
import { createScene, type TSceneFn } from 'nacatamalon';
import { createServer } from 'nacatamalon/net';

// The game's own scenes, as its players' pages run them.
const Lobby: TSceneFn = () => createScene();
const Pool: TSceneFn = () => createScene();

const server = createServer({
    width: 320, height: 180,
    scenes: { Lobby, Pool },
    step: 20,
    roomScene: (room) => (room === 'pool' ? 'Pool' : 'Lobby'),
    admit: async ({ token }) => (await accountOf(token))?.name ?? false,
});
server.listen(8080);

declare function accountOf(token: string | null): Promise<{ name: string } | null>;
View source · net/create_server.ts:96

roomStoreOffunctionexperimentalnacatamalon/net

roomStoreOf(instance: TGameInstance, decl: TRoomStoreDecl<S>) => Promise<TRoomStore<S>>

A game's store of a declaration, from outside the game: for a HUD of the page (React, the DOM) over a game made with createGame. It waits for the game to start. What it watches stays until the function watch returns is called.

Parameters

Example

import { createGame } from 'nacatamalon';
import { createRoomStore, roomStoreOf } from 'nacatamalon/net';

declare const container: HTMLElement;
declare const label: HTMLElement;
const score = createRoomStore({ key: 'score', state: { red: 0, blue: 0 } });

const game = createGame(container, { width: 320, height: 180 })({});
const board = await roomStoreOf(game, score);
board.watch((s) => `${s.red} - ${s.blue}`, (text) => { label.textContent = text; });
View source · net/use_room_store.ts:77

useNetfunctionhookexperimentalnacatamalon/net

useNet() => TNetHandle

The network, for a scene of an online game. The same scenes run in two places: in a room of the server, where what happens is decided, and in each player's page, which shows it and asks. The handle is the same in both, and role says which this is.

The rule that keeps a game fair: a player's game says what the player did, and the server decides what comes of it. It sends "I cast the line" and "I pulled", never "I caught a fish" or "I have 110 coins": the server, running the same scene, works out whether a fish bit, adds the coins and tells everyone. A player who changes their own game only changes their own screen.

Everything that arrives is handed over at the start of a step, before any update, in order. What a scene listens to stops when the scene leaves.

Example

import { createScene, createText, useUpdate, useKeyboard, type TSceneFn } from 'nacatamalon';
import { useRandom } from 'nacatamalon/math';
import { useNet } from 'nacatamalon/net';

export const Pond: TSceneFn = () => {
    const net = useNet();
    const random = useRandom();
    const coins = new Map<string, number>();

    if (net.role === 'server') {
        // Decided here and nowhere else, with the server's own luck.
        net.onJoin((player) => coins.set(player, 100));
        net.onMessage('pull', (_data, from) => {
            if (from === null || !random.chance(0.5)) return; // nothing bit
            const now = (coins.get(from) ?? 0) + 10;
            coins.set(from, now);
            net.sendTo(from, 'coins', now);
        });
    } else {
        const label = createText({ text: 'COINS 100' });
        const keys = useKeyboard();
        net.connect('wss://example.com', { room: 'pond' });
        net.onMessage<number>('coins', (amount) => { label.text = `COINS ${amount}`; });
        useUpdate(() => {
            if (net.status === 'online' && keys.justPressed(' ')) net.send('pull');
        });
    }
    return createScene();
};
View source · net/use_net.ts:59

useNetSpawnfunctionhookexperimentalnacatamalon/net

useNetSpawn(kind: string, component: (args: TArgs) => TApi, options: Omit<TSpawnOptions, 'name'>) => (args: TArgs) => TGameObject<TApi>

A spawner for objects every game in the room sees: the server calls it, and the object is made there and, with the same arguments, in every player's game, now and for whoever comes later; when the server destroys it, it goes everywhere. One whose body gave it no placement gets one, at the origin of its parent. Where it is and its fields travel on their own (see useShared, which its body may call to say more: its fields, its owner, what moves it).

The scenes are the same on both sides, so both call this, with the same name: the name is how a player's game knows which spawner the server used. Only the server makes anything with it; a player's game that wants one asks the server with a message, and the server decides.

The arguments travel, so they are plain data: a player's name, a colour, a number.

Parameters

kindstring
component(args: TArgs) => TApi
optionsOmit<TSpawnOptions, 'name'>

Example

import { createScene, createShapes, destroy, useTransform, type TGameObject, type TSceneFn } from 'nacatamalon';
import { useNet, useNetSpawn } from 'nacatamalon/net';

const Coin = (x: number, y: number) => {
    useTransform({ x, y });
    createShapes({ shapes: [{ type: 'circle', x: 0, y: 0, radius: 4, fill: '#ffd040' }] });
};

export const Field: TSceneFn = () => {
    const net = useNet();
    const spawnCoin = useNetSpawn('coin', Coin);
    if (net.role === 'server') {
        const coin: TGameObject = spawnCoin(40, 30);
        net.onMessage('take', () => destroy(coin));
    }
    return createScene();
};
View source · net/use_net_spawn.ts:54

useRoomStorefunctionhookexperimentalnacatamalon/net

useRoomStore(decl: TRoomStoreDecl<S>) => TRoomStore<S>

This game's store of a declaration made with createRoomStore: the room's own in the room, a copy the room keeps up to date in a player's game.

Asked for while something is being built (a scene body, an object made with useSpawn, a game system, useReady), where the engine knows which game it is; keep what it gives and use it whenever, after an await too. What it watches goes with the object that asked.

Parameters

Example

import { createScene } from 'nacatamalon';
import { createRoomStore, useRoomStore } from 'nacatamalon/net';

const round = createRoomStore({ key: 'round', state: { number: 1, left: 90 } });

const Arena = () => {
    const clock = useRoomStore(round);
    clock.watch((s) => s.left, (left) => { console.log(`${left} s left`); });
    return createScene();
};
View source · net/use_room_store.ts:38

useSharedfunctionhookexperimentalnacatamalon/net

useShared(options: TSharedOptions<F>) => TShared<F>

Makes the object being built one every game in the room sees: the server decides where it is and what its fields hold, and each player's game shows it there a moment later, gliding between what it was told. Nothing in the scene's code sends anything: the room sends what changed, a few dozen times a second, to everyone in it, and to whoever comes later.

Two kinds of object, and only the first needs a key:

  • One every game builds itself, from the scene or its document (a door, a scoreboard): the same key on both sides is how they match.
  • One the server makes while the game runs (a player's avatar, a bullet): made with a spawner of useNetSpawn, which makes it in every player's game too and names it for them.

With an owner and a move, it is that player's own: the server moves it with what they press (useNet().actions), and their own page moves it at once with the same code, ahead of the server, and quietly takes the server's word when it comes. A player feels no wait for their own character; the server still decides where it really is.

Call it in the object's own body, once.

Parameters

optionsTSharedOptions<F>

Example

import { createScene, createSprite, destroy, useSelf, type TGameObject, type TSceneFn } from 'nacatamalon';
import { useNet, useNetSpawn, useShared } from 'nacatamalon/net';

const SPEED = 80;

// A player's avatar: theirs to move, everyone's to see.
const Avatar = (player: string) => {
    const self = useSelf();
    createSprite({ texture: 'avatar' });
    const shared = useShared({
        owner: player,
        fields: { score: 0 },
        move: (input, dt) => {
            const { x, y } = input.direction('left', 'right', 'up', 'down');
            self.transform!.x += x * SPEED * dt;
            self.transform!.y += y * SPEED * dt;
        },
    });
    return shared;
};

export const Arena: TSceneFn = () => {
    const net = useNet();
    const spawnAvatar = useNetSpawn('avatar', Avatar);
    if (net.role === 'server') {
        const avatars = new Map<string, TGameObject>();
        net.onJoin((player) => avatars.set(player, spawnAvatar(player)));
        net.onLeave((player) => {
            const avatar = avatars.get(player);
            if (avatar !== undefined) destroy(avatar);
        });
    }
    return createScene();
};
View source · net/use_shared.ts:73

webSocketConnectionfunctionexperimentalnacatamalon/net

webSocketConnection(socket: TSocketLike) => TNetConnection

A WebSocket as a connection the engine can use: the browser's, Bun's or Node's, made by the game itself (to pass headers of its own, or a protocol). useNet().connect('wss://…') makes one of these on its own; this is for a socket made elsewhere.

What is sent before the socket opens waits and goes as soon as it does, in order.

Parameters

socketTSocketLike

Example

import { useNet, webSocketConnection } from 'nacatamalon/net';

const net = useNet();
net.connect(webSocketConnection(new WebSocket('wss://example.com', 'nacatamalon')), { room: 'lobby' });
View source · net/web_socket_connection.ts:66

TLoopbackOptionstypeexperimentalnacatamalon/net

How the pretend line behaves.

Properties

delayoptionalnumber

Seconds each message takes to reach the other end, each way: 0.05 is a player 100 ms away from the server, there and back. Default 0, which still arrives later and never at once, as over a real line.

View source · net/connect_loopback.ts:12

TNetAdmitRequesttypeexperimentalnacatamalon/net

What a player asks for when they connect: a room, and what proves who they are.

Properties

roomstring

The room they want to enter.

tokenstring | null

What their game sent to prove who they are, or null when it sent nothing.

fromoptional{ room, player }

Where they come from when they move from another room of this server (useNet().joinRoom): that room and their name in it. Left out when they connect.

View source · net/types/t_server.ts:12

TNetConnectiontypeexperimentalnacatamalon/net

One line between a player's game and the server: what the engine asks of whatever carries the messages. A WebSocket, socket.io, a WebRTC channel or the loopback in memory are all one of these once wrapped, and the game above never knows which.

Messages are text: the engine writes them as JSON and reads them back, so what a game sends has to be something JSON can hold. The engine calls onMessage and onClose once each, when it takes the connection, and send and close whenever it needs to.

Properties

send
onMessage
onClose
close

Example

import type { TNetConnection } from 'nacatamalon/net';

// What of socket.io's client this uses (`import type { Socket } from 'socket.io-client'`).
type Socket = {
    emit(event: string, text: string): void;
    on(event: string, listener: (value: string) => void): void;
    disconnect(): void;
};

// A connection carried by socket.io, on an event of its own.
const overSocketIo = (socket: Socket): TNetConnection => ({
    send: (text) => socket.emit('naca', text),
    onMessage: (listener) => socket.on('naca', listener),
    onClose: (listener) => socket.on('disconnect', (reason) => listener(reason)),
    close: () => socket.disconnect(),
});
View source · net/types/t_net_connection.ts:35

TNetConnectOptionstypeexperimentalnacatamalon/net

What a player's game says when it connects: which room it wants and what proves who it is. The server's admit reads both.

Properties

roomoptionalstring

The room to enter. Default 'main'.

tokenoptionalstring

What the server checks before letting the player in: a session's token from the game's own accounts, a name. The engine only carries it.

interpolationoptionalnumber

How far behind the server this game shows what the others do, in seconds: what the server said is held back this long and shown gliding from one word to the next, so a late message does not make anything jump. Left out, it follows the line: it starts at 0.1 and settles on one of the server's sends and the lateness the line shows (about 0.04 on a good one, never over 0.3). Given, it stays as given: less is fresher and shakier.

sceneTransitionoptionalTTransition

How this game follows its room when the room changes its scene (a useScene().change in the server's room): a transition, as fade(0.3) gives. Left out, a cut. Transitions are the game's own, and do not travel from the server.

View source · net/types/t_net_handle.ts:37

TNetHandletypeexperimentalnacatamalon/net

The network as a scene sees it, from useNet(). The same scenes run in the server's rooms and in the players' pages, so the handle is the same in both, and role says which this is: what the server decides (who won, how many coins) is done where role is 'server', and what only a player has (the screen, the sound, the keys) where it is 'client'.

Everything that arrives (a message, a player coming or going) is handed over at the start of a step, before any update, in the order it came: a scene never hears the network in the middle of a frame. What a scene listens to stops when the scene leaves; each on… also returns what stops it sooner.

Properties

roleTNetRole

Where this game runs: in a room of the server, or in a player's page.

statusTNetStatus

How this game is with the server. A room of the server is always 'online'.

roomstring | null

The room this game is in, or null before a player's game has been let into one.

scenestring | null

The scene the room runs, which a player's game in it follows when the room changes it: in the room, and in a player's game once let in (null before, and in a room with no scenes). A game that connected from a menu goes to it with useScene().change(net.scene) in its onConnect.

mestring | null

This player's own name in the room, once let in. null on the server and before.

playerstypeOperator

The players in the room now, in the order they came, this one among them.

pingnumber | null

How long a word takes to go to the server and back, in seconds, measured every second while online: null before the first answer, and always on the server.

onMessage
onJoin
onLeave
connect
disconnect
joinRoom
send
onConnect
onDisconnect
sendTo
broadcast
kick
actions
rewind
View source · net/types/t_net_handle.ts:95

TNetJoinRoomOptionstypeexperimentalnacatamalon/net

How a player moves to another room with joinRoom.

Properties

tokenoptionalstring | null

What proves who the player is, when it is not what it connected with: the server's admit reads it, and keeps it only if the move goes through. Left out, the one it connected with.

transitionoptionalTTransition

How the scene of the room it leaves gives way to the scene of the one it moves to.

View source · net/types/t_net_handle.ts:69

TNetRoletypeexperimentalnacatamalon/net

TNetRole: 'server' | 'client'

Where a game runs in an online game: in a room of the server, where what happens is decided, or in a player's page, which shows it and asks.

View source · net/types/t_net_handle.ts:14

TNetStatustypeexperimentalnacatamalon/net

TNetStatus: 'offline' | 'connecting' | 'online' | 'closed'

How a player's game is with its server: not connected, on its way (connected, waiting to be let into the room and to be sent the whole of it), in the room and seeing it, or with the line gone. A room of the server is always 'online'.

View source · net/types/t_net_handle.ts:26

TRoomtypeexperimentalnacatamalon/net

One room: the game's own scenes running with no screen and no sound, deciding what happens, with the players in it. What createServer makes for each room asked for, and what a server of someone else's (socket.io, or a framework with rooms of its own) holds itself through createRoom.

Properties

namestring

What the room is called.

playerstypeOperator

The players in it now, in the order they came.

framenumber

Steps run so far.

join
leave
step
store
find
findAll
loaded
destroy
View source · net/types/t_room.ts:56

TRoomOptionstypeexperimentalnacatamalon/net

TRoomOptions: Omit<THeadlessGameOptions, 'step'> & { name, step, clock, sendRate, rewindLimit }

How a room is made: the game's own options and scenes, as a player's page has them, and how it keeps time. assets is where the files are read from when the room runs in Bun or Node (default 'public'); in a page they come from the page's own address, as the players' do.

Properties

nameoptionalstring

What the room is called: what a player asks for, and what useNet().room says. Default 'main'.

stepoptionalnumber

Steps a second: the room always moves in steps of exactly 1 / step seconds, whatever the machine, so what it decides is the same every time. 20 is plenty for walking around a room and chatting; a game of quick reactions wants 60. Default 60.

clockoptionalboolean

Whether the room keeps its own time, running its steps as the seconds go by. Default true. false when something else keeps it (another server's loop, a test): it moves only when step() is called.

sendRateoptionalnumber

How many times a second the room tells its players where the shared objects are (useShared) and what their fields hold: at most step, and then only what changed. More is smoother and costs more of the line. Default step up to 30.

rewindLimitoptionalnumber

How far back useNet().rewind may look, in seconds: a player's shot is judged where they saw the others, but never further back than this, whatever their game says it saw. Covers a player's ping and their interpolation; past it, a slow player hits a little behind. Default 0.25 (about 200 ms of ping), at most 1.

View source · net/types/t_room.ts:16

TRoomStoretypeexperimentalnacatamalon/net

One game's room store: the room's own in the room, a copy that the room keeps up to date in each player's game.

Properties

keystring

Its name.

stateTRoomStoreValue<S>

What it holds now, frozen. A getter: it is a new object after every change, so read it when it is needed rather than keeping it.

writableboolean

Whether this game may change it: in the room, and in a player's game that has never connected (a game tried on its own, with no server). In a player's game that connected, the server decides and this is false.

readyboolean

Whether it holds what the room has: always in the room and in a game that never connected; in a player's game, from the moment the stores of the room it is in arrive whole (just before onConnect, so a watcher told of them already reads true) until it leaves that room, by the line going or by joinRoom.

set
watch
View source · net/types/t_room_store.ts:66

TRoomStoreDecltypeexperimentalnacatamalon/net

A room store as createRoomStore declares it: a plan, holding nothing of its own. Each game asks for its own with useRoomStore, room.store or roomStoreOf.

Properties

keystring

Its name.

serverOnlyboolean

Whether it lives only in the room.

initialTRoomStoreValue<S>

What each game's store starts with, frozen.

View source · net/types/t_room_store.ts:48

TRoomStoreOptionstypeexperimentalnacatamalon/net

How a room store is declared.

Properties

keystring

Its name, one per game: two declarations with the same key in one game are a mistake.

stateS

What each game's store starts with. Plain data only: numbers, strings, booleans, null, arrays and objects of them, as it travels to the players as text.

serverOnlyoptionalboolean

Whether it lives only in the room and never reaches the players: the rules, a count of cheats, what is kept when the room ends. false by default.

View source · net/types/t_room_store.ts:24

TRoomStoreValuetypeexperimentalnacatamalon/net

TRoomStoreValue: conditional

What a room store holds, as everyone reads it: frozen all the way down, so a change made by hand fails out loud instead of never reaching anyone.

View source · net/types/t_room_store.ts:10

TServertypeexperimentalnacatamalon/net

A server: it takes connections, lets players in, and gives each room asked for a game of its own, which ends when its last player leaves.

Properties

accept
listen
roomstypeOperator

The rooms with players in them now, by name.

room
close
View source · net/types/t_server.ts:57

TServerOptionstypeexperimentalnacatamalon/net

TServerOptions: Omit<TRoomOptions, 'name'> & { admit, roomScene }

How a server is made: the game's options and scenes, which every room runs, and who gets in.

Properties

admitoptional(request: TNetAdmitRequest) => boolean | string | Promise<boolean | string>

Decides whether a player gets in: true lets them in with a name the room gives, a string lets them in under that name (their account's, so they are the same player each time they come), false refuses them. It may take its time (async, asking the game's own accounts). Left out, everyone gets in. A player moving from another room (useNet().joinRoom) is asked about too, with from, and stays where it was while this decides.

roomSceneoptional(room: string) => string | null

Which scene a room runs, by the room's name: 'pool' runs 'Pool', and a name with no scene is refused (null). Left out, every room runs the first scene, or initialScene.

View source · net/types/t_server.ts:32

TSharedtypeexperimentalnacatamalon/net

An object shared with every game in the room, as its own code sees it.

Properties

idstring

What the room calls it: its key, or the name the server gave one a spawner made.

ownerstring | null

The player it belongs to, or null.

mineboolean

Whether it belongs to the player of this page. Always false on the server.

fieldsF

What travels besides its placement: the server writes them, the players' games read them.

View source · net/types/t_shared.ts:61

TSharedMovetypeexperimentalnacatamalon/net

TSharedMove: (input: TActionsHandle, dt: number) => void

What a player's actions do to an object of their own in one step: the same code on the server, with the actions that came over the line, and in the player's page, with the player's own, ahead of the server so the player feels no wait.

It only moves the object, from where it is, by input and dt: when the server corrects the player's page, the page goes back to where the server had it and runs this again for the steps the server had not seen yet, several in one frame. So nothing else belongs here (no spawning, no sound, no score, no room store): what comes of a shot is the server's, in an update, from useNet().actions.

View source · net/types/t_shared.ts:19

TSharedOptionstypeexperimentalnacatamalon/net

How an object is shared with every game in the room.

Properties

keyoptionalstring

The name both sides know it by, for an object every game builds itself: one of the scene's, or of its document (self.id there). Not needed, and not used, for one a spawner of useNetSpawn makes: the server names those.

fieldsoptionalF

What travels besides its placement, with the values it starts with: the server changes them (shared.fields.hp -= 1) and every player's game has the new ones a moment later. Plain data only: numbers, strings, booleans, arrays and objects of them.

owneroptionalstring | null

The player it belongs to: the one whose actions move takes, and for whom mine is true.

moveoptionalTSharedMove

What its owner's actions do to it each step. See TSharedMove.

smoothoptionalboolean

Whether a player's game shows it gliding between what the server said, a moment behind (true, the default), or jumps to each as it arrives, with no wait (false).

View source · net/types/t_shared.ts:29