Skip to content

GameSource beta ​

Interface of @v12-engine/client

ts
export interface GameSource

Where a game to play comes from. One of, in this order: a save to go on from (from), the map being edited (editing), one the game's generator makes (generated), a world made in code (world), a map (map), or a seat at a game run elsewhere (session). All but the last are played in the page

Members ​

beforePlay ​

ts
beforePlay?: (world: World, context: {
        player: PlayerId;
        map?: GameMap;
        fresh: boolean;
    }) => void | Promise<void>;

What the game does with every world played in the page before it is played, new (after start) or loaded from a save (fresh false): what it listens to (a mission won kept), what it seats again

debug ​

ts
debug?: boolean;

Whether the player may use the debug tools: the debug panel, cheats. No when left out

editing ​

ts
editing?: MapBeingEdited;

The map the editor's Play hands over, as it is being edited (SceneArgs.editing): played as it is, with what its Data panel changed over the game's code, from its seat, seen whole or not, the view where the editor looked, the map's own files

environment ​

ts
environment?: Partial<MapEnvironment>;

A look laid over the map's (withEnvironment): not over a map being edited, which is played as it is

from ​

ts
from?: WorldSave;

A save to go on from, in the place of a new game: the world as it was, and start is not called

game ​

ts
game?: LoadedGame;

The game: needed for every source but a seat at a game run elsewhere

generated ​

ts
generated?: GeneratorOptions;

A map for the game's generator to make (SceneArgs.generated, a random map's scene)

log ​

ts
log?: Logger;

The logger the game's world is made under (world.log), when it is made here from a map or a save

lookAt ​

ts
lookAt?: Vec2;

Where the player's view starts, over what the map says (the player's start)

map ​

ts
map?: GameMap;

A map of the game: the world is made from it with the game's rules

ts
navigation?: NavigationBuilds;

Who builds the navigation of the world made here, and where what was built is kept: the app's worker (LaunchOptions.navigationWorker, SceneContext.navigation). This thread when left out

onStart ​

ts
onStart?: (world: World, context: {
        player: PlayerId;
        map?: GameMap;
    }) => void | Promise<void>;

What the game does once a new world is made, before anyone plays: computer players, a mission given, the first wave sent

pack ​

ts
pack?: MapPack;

The files a map brings with it (MapPack), over those of the map being edited

player ​

ts
player?: PlayerId | ((world: World, map?: GameMap) => PlayerId | undefined);

Who the player at the screen is, after the editor's seat and the one a save was played from. When left out (or a function gives none): the first player of the map with a start, else its first player; in a world made in code or loaded, the first that is neither neutral nor the creeps

progress ​

ts
progress?: (done: number, total: number) => void;

Told as the game's packs of content are fetched (Game.packs): for the loading screen

reveal ​

ts
reveal?: boolean;

Whether the player sees everything from the start, without fog of war

seed ​

ts
seed?: number;

The seed of the world's numbers: the same seed, the same game. One of the moment when left out

session ​

ts
session?: () => GameSession | Promise<GameSession>;

A seat at a game run elsewhere: () => connect(await openSocket(url), { rules: game.rules })

startView ​

ts
startView?: string;

The view of the map the player starts with, by name, over what the map says

worker ​

ts
worker?: WorldWorkerLike;

A worker to run the simulation in, off the page's thread (S54): a long tick is then not a late frame. A worker of the page's own, whose file calls serveWorld(rules, { onStart }) with the same game: the game's code that runs on the world (start, world, a player decided in code) is given there, not here, since only data crosses. The page's thread when left out. With a map or a save, or neither for a world the worker makes in code

workerArgs ​

ts
workerArgs?: unknown;

Anything the worker's own code is to know (its start and world are handed it as args): plain data

world ​

ts
world?: (context: {
        rules: Rules;
        seed: number;
        navigation?: NavigationBuilds;
    }) => World | Promise<World>;

A world made in code, for what a map does not say: generated ground, players of its own. navigation is who builds its navigation, for it to pass on (CreateWorldOptions.navigation.builds)