Interface: PredictorOptions<View, Command>
Defined in: client/predict.ts:5
How a Predictor works out what the room will do with this player's commands.
Type Parameters
| Type Parameter |
|---|
View |
Command |
Methods
apply()
apply(
state,
command,
you
): void;Defined in: client/predict.ts:13
What one of this player's commands does to the state, written the way the room's onCommand is: change state in place. It is given a draft of the room's state, so the room's state itself is never touched, and you is this player's id. If the room would refuse the command, change nothing.
Parameters
| Parameter | Type |
|---|---|
state | View |
command | Command |
you | string |
Returns
void
tick()?
tick?(state, you): void;Defined in: client/predict.ts:23
What one tick does to what this player controls, written the way the room's onTick is. Give it for a game in which a command sets something in motion that the simulation then carries on with, such as a unit that walks to where it was sent: the prediction then runs as far ahead of the room's state as a command takes to come back, and the player's own unit moves the moment they act. Leave the other players' units alone: where they will be is not this player's to know.
Parameters
| Parameter | Type |
|---|---|
state | View |
you | string |
Returns
void
onState()?
onState?(state): void;Defined in: client/predict.ts:29
The room's state changed, or a command was sent, applied or refused. With tick the prediction also moves on with time: read state when you draw, rather than wait for this.
Parameters
| Parameter | Type |
|---|---|
state | View |
Returns
void
now()?
now?(): number;Defined in: client/predict.ts:31
The clock, in milliseconds. Defaults to Date.now.
Returns
number