Documentation
¶
Overview ¶
Package plugin is the extension contract: what a Plugin is, what it is handed at install time, and how a game's rules are hosted inside a plugin's own pass. Built-in plugins and third-party ones implement the same interface.
Plugin ¶
A Plugin has a Name (saves match its state by it), an Install that queues its ECS wiring, a RunPlan the Stage calls once a tick, and optional faces: EventHandler for the input it reads, Serializable for the state it saves. A Builtin plugin is one the engine installs itself. A plugin tells the Stage of itself as it is made (Made); the Stage uses the plugins in the order made.
Installer ¶
Installer is ECS wiring and Hosts, which tells the engine the hosts of the rules of the moments the plugin catches. Install only queues; the engine flushes every plugin's wiring in one ecs.Setup after the Stage's Init. What a plugin needs of another it takes in its constructor. What a plugin draws it gives Draws, render.Sources of the Stage's one picture (world.Read.Picture), ordered there by height; Looks has its looks declared and its atlases closed once the Stage is set up, before its scenes are made. Pool is the goroutines the whole game shares (plugin/parallel): a plugin that splits a pass among them keeps the pool and begins a batch a pass.
Rules ¶
A plugin hosts the rules of the moments it catches in its own pass: in Install it tells the engine its hosts (a [Host] is a [Rules], a [PairRules] or a [StepRules]), and once the Stage's Init returns the engine hands the rules of every role somebody plays to the first host that does not refuse them with [ErrUnhosted]; [ErrHostBuilt] is a rule handed over after ecs.Setup. Rules run over the entities the plugin walks (Bind to the columns of its query, made by ceremony/goke's NewColumns, which Own shares a column the plugin reads itself with; Run and RunWhere over each block, cols.Row(cursor)), PairRules over pairs (Bind, [Marks] read with Read, then Dispatch, DispatchEitherWay or DispatchGrouped), StepRules once a step, walking no entities. Each hands its rules a [Tick], made by the world's [TickSource]. A moment is [About] one entity, [Met] others too, a [Subject] names another, an [Aimed] command is told whom it is about, a [Placed] moment stands on places of their own.
Commands ¶
What a player wants goes the other way, as a command of package control. A CommandHandler defines command types and carries them out: it keeps a command.Queue of each, lists them in Queues, drains them in its own pass, and suggests the control.Bindings that issue them. A command type has one handler.
Optional interfaces ¶
Serializable gives Persistence what to encode and decode, Populator seeds initial state in a Stage entered afresh, Restorer is called right after its state was decoded, PostLoader supplies a one-time system run after the entities were restored. A KindTemplater writes, in its KindTemplates alone, what it asks of the kinds a game defines (kind.Roster). A Tunable lists its settings, the control.Settings the players adjust on the settings screen; Keep has them saved with the game, whole.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Bound ¶ added in v0.5.0
Bound is what reads the world and so is readied with it, once, as a system is: a source the Stage's plugins draw, a scene's drawer, a reporter.
type Builtin ¶
type Builtin interface{ Builtin() }
Builtin marks a Plugin the engine installs itself; Use refuses it.
type CommandHandler ¶ added in v0.3.0
type CommandHandler interface {
Queues() []command.CommandQueue
DefaultBindings() []control.Binding
}
CommandHandler is a plugin, or a game, that defines commands and carries them out: the queues they land in and the bindings it suggests for them. A command type has one handler.
type FrameTimes ¶ added in v0.5.0
FrameTimes is how long a frame took from the last one's start, and its steps: the wait for the GPU's next image, the simulation (the ticks and the publishing), the barrier, the drawing on the CPU and the presenting.
type Installer ¶
type Installer interface {
UseModule(m goke.Module)
Setup(providers ...goke.SetupProvider)
RegSys(factory func() goke.System) goke.Runnable
ECS() *goke.ECS
Hosts(hosts ...host.Host)
// Draws adds what the plugin draws to its Stage's picture, ordered there by height.
Draws(sources ...render.Source)
// Looks has declare run once the Stage is set up, before its scenes are made: the plugin's
// looks declared and its atlases closed.
Looks(declare func())
// Pool is the goroutines the game shares the work a plugin splits among; nil, one.
Pool() *parallel.Pool
}
Installer is what a Plugin gets during Install: ECS wiring, Hosts, which tells the engine the hosts of the rules of the moments the plugin catches, and what the plugin draws.
type Kept ¶ added in v0.3.0
type Kept[T any] struct { // contains filtered or unexported fields }
Kept is a plugin's settings saved with the game, made by Keep: Persisted encodes them whole, so a setting saved at its zero value comes back so, not as the start it was given.
func Keep ¶ added in v0.3.0
Keep has of, a struct of exported fields, saved and restored whole: a plugin's Serializable is Keep(&p.Res), or Keep(&p.Res.Settings) where the rest of its Res is not saved; its Restore calls Kept.Restore before it applies what came back.
type KindTemplater ¶ added in v0.3.0
KindTemplater is a plugin asking something of the kinds a game defines: in KindTemplates, and nowhere else, it writes what it requires of a template's kinds and what it brings them.
type Made ¶ added in v0.3.0
type Made struct {
// contains filtered or unexported fields
}
Made are the plugins made for a Stage, in the order made, which is the order the Stage uses them in.
type Paced ¶ added in v0.5.0
type Paced interface {
Pace(t FrameTimes)
}
Paced is a tracked value paced on the frame's barrier, where nothing ticks or draws: told the last frame's times, it may draw what follows the frame budget coarser or finer.
type Plugin ¶
type Plugin interface {
// Name is unique among a Stage's plugins; Use refuses a duplicate.
Name() string
// Install queues the plugin's ECS wiring.
Install(ctx Installer) error
// RunPlan is the plugin's work of a tick, called from Stage.Update in the order the game needs.
RunPlan(ctx goke.RunCtx, d time.Duration)
// EventHandler is the plugin's own, or nil for none.
EventHandler() control.EventHandler
// Serializable is the plugin's saved state, or nil for none.
Serializable() Serializable
}
Plugin is the one extension point: what a Stage uses, named for the saves.
type Populator ¶
type Populator interface {
Populate() error
}
Populator is a Plugin that seeds its own initial state, run only when a Stage starts afresh.
type PostLoader ¶
PostLoader is a tracked value needing a one-time system run right after Persistence.Load restored the entities.
type Publisher ¶ added in v0.5.0
type Publisher interface {
Publish()
Swap()
}
Publisher hands the renderer what it draws, once a frame after the frame's ticks: Publish reads the world into what is drawn next, and Swap, called while nothing draws, has it drawn. A tracked value, a source the Stage's plugins draw or a scene's drawer may be one; a scene's drawer publishes only while the scene is shown.
type Restorer ¶
type Restorer interface {
Restore()
}
Restorer is a tracked value called back right after Persistence.Load decoded its state.
type Serializable ¶
type Serializable interface {
Persisted() []any
}
Serializable is a tracked value giving Persistence the pointers it gob-encodes and decodes.
func KeepOf ¶ added in v0.17.0
func KeepOf(of any) Serializable
KeepOf is Keep of a value whose type the caller does not name: of is a pointer to a struct of exported fields, saved and restored whole; anything else panics.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package parallel shares a job of many tasks among the goroutines of a pool kept for the whole game: the caller's own and the pool's, each known by its number.
|
Package parallel shares a job of many tasks among the goroutines of a pool kept for the whole game: the caller's own and the pool's, each known by its number. |
|
Package section names the parts a Stage is defined in, in their order, and lets a plugin refuse what is defined in the wrong one.
|
Package section names the parts a Stage is defined in, in their order, and lets a plugin refuse what is defined in the wrong one. |