Documentation
¶
Overview ¶
Package underground digs what lies under the ground by one set of rules, package site's, whoever digs it: a level's file, a player with a tunnel in hand, a map maker.
NewPlugin takes a world with heights, the board and the Config: where a structure may lie (site.Rules) and the kind of tunnel a player digs. A game defines its kinds in the Kinds section (Plugin.Types): a tunnel (Types.Define a Spec: whom its floor carries and how much it bears, how wide it runs, how much room lies over its floor and how it is drawn, its Look) and a chamber (Types.Chamber).
A structure is its parts ¶
A structure is entities lying under the board's cells, saved as any: a piece under every cell it runs under, its floor a cell.Floor sunk under the ground (a negative Height) with the room over it (Clear), on a storey of its own, so the ground over it stays ground and a bridge may stand over it; a tunnel's pieces are bands running from one to the next, a chamber's whole cells. A tunnel comes out square to its head's edge and runs straight through its first cell, its mouth framed, the way in open. Over them stands the handle, "<name>.whole", which takes its pieces with it as it goes (world.Whole). A unit walks in at a mouth and through on the floor, no taller than the room, and a body in the room is kept in by its walls, as collision reads them of the board; a camera riding it stays under the roof; the ground over a mouth is cut away, and inside the structure is drawn with its own lamps, lit by none of the sun, in its kind's Look: a road's tunnel, concrete and asphalt, unless the kind gives colours of its own, rough rock and timber sets for a mine. Each structure is a room of the interiors plugin (interiors.Room) under a light.Shelter letting none of the sun in, its lamps burning by day and night, so whoever walks in it is lit as it is drawn.
A level's structures ¶
A line of a level's file `{kind: tunnel, from: [x, y], to: [x, y], via: [[x, y]]}` is a tunnel from head to head turning at the cells via, `{kind: cave, from: [x, y], to: [x, y], depth: d}` a chamber under a rectangle of cells: Write.Spawn digs every one in the Spawn section and fails with the line of one that may not lie.
A tunnel in a player's hand ¶
Plugin.DefaultBindings have Shift+T take a tunnel in hand (Tool); while the player holds it, the cursor lays it out (Aim), a left click marks a head (Mark) and a right click or Esc puts it down. The tunnel in hand is drawn yellow where it may not lie (Plugin.Reason says why), green where it may. Plugin.Window asks "Dig the tunnel?": Dig has it dug at the next step of the simulation, its heads levelled on the ground Plugin.WithShaper gives, Cancel digs nothing. A tunnel confirmed waits for its step in Resources.Orders, saved with the game.
Seen from above ¶
From over the ground the courses of the tunnels and the units in them are marks over the world where the setting says (Courses, under the settings' section Game; Settings.HideCourses).
Figures ¶
A Figure is a kind of structure in one piece: Define its Spec, its Look among it, on the plugin's Types, and, Stateful or Ruled, its own effects and rules. Plugin.Figures, called in the Stage's Figures link, hands them on to the world's figures; Plugin.World is the world they lie under.
Vocabulary ¶
Marks: world.Whole on a structure's handle, world.PieceOf on its pieces, world.Unseen on those under the ground. Commands, a player's with the tunnel in hand: Aim, Mark, Dig, Cancel; a setting's: Courses.
Index ¶
- Constants
- type Aim
- type Cancel
- type Config
- type Courses
- type Dig
- type Figure
- type Look
- type Mark
- type Order
- type Plugin
- func (p *Plugin) DefaultBindings() []control.Binding
- func (p *Plugin) EventHandler() control.EventHandler
- func (p *Plugin) Figures(figures ...Figure)
- func (p *Plugin) Install(ctx plugin.Installer) error
- func (p *Plugin) Name() string
- func (p *Plugin) Populate() error
- func (p *Plugin) Queues() []command.CommandQueue
- func (p *Plugin) Reason() *ui.Element
- func (p *Plugin) Restore()
- func (p *Plugin) RunPlan(ctx goke.RunCtx, d time.Duration)
- func (p *Plugin) Serializable() plugin.Serializable
- func (p *Plugin) Settings() []control.Setting
- func (p *Plugin) String() string
- func (p *Plugin) Types() *Types
- func (p *Plugin) Window() *ui.Element
- func (p *Plugin) WithShaper(s ground.Shaper) *Plugin
- func (p *Plugin) World() *world.Plugin
- func (p *Plugin) Write() *Write
- type Resources
- type RoomRow
- type Row
- type Ruled
- type Settings
- type Spec
- type Stateful
- type Type
- type Types
- type Write
Constants ¶
const Tool control.Tool = "tunnel"
Tool is a tunnel in a player's hand, for control.Take.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Cancel ¶
type Cancel struct{}
Cancel digs nothing of the tunnel its player was asked about, the first head still laid.
type Config ¶
Config is where structures may lie under the ground and the kind of tunnel a player's Tool digs, the first defined for none.
type Courses ¶
type Courses struct{ Shown bool }
Courses has the courses of what lies under the ground and the units in it marked over the world, or not (Settings.HideCourses). The settings screen alone, under Game.
type Figure ¶
type Figure interface {
Define(p *Plugin)
}
Figure is a kind of structure under the ground in one piece: its Spec defined on the plugin's Types in the Kinds section; the plugin draws it. One with states of its own is Stateful, one with roles and rules of its own Ruled.
type Look ¶
type Look struct {
Walls, Floor, Roof, Frame color.RGBA
// a road's lines down the floor: a broken one in its middle, one by each wall
Lines color.RGBA
// Rough hews the walls, the roof and the floor out of rock; Sets stands a set of the frame's
// colour round the stretch every height of its room, as a mine's timbers
Rough, Sets bool
}
Look is how a kind of structure is drawn from inside, its colours straight: the zero Look a road's tunnel, concrete walls, roof and frame round its mouths, an asphalt floor and a road's lines; any other its own colours, each zero as the road's, lines only of a colour it gives.
type Mark ¶
Mark lays a tunnel's head at the world point At: the first where the tunnel begins, the next its other end, asking whether to dig it; the first again lifts it.
type Order ¶
Order is a tunnel its player confirmed (Dig), dug at the next step of the simulation: the name of its kind (Types.Named) and its plan.
type Plugin ¶
Plugin digs tunnels and chambers by one set of rules, a level's and a player's, as entities lying under the board's cells.
func NewPlugin ¶
NewPlugin builds the plugin of what lies under the ground over w and brd, a world with heights.
func (*Plugin) DefaultBindings ¶
DefaultBindings are Shift+T taking the tunnel in hand and, while it is held, the cursor aiming it, a left click marking a head and a right click or Esc putting it down.
func (*Plugin) EventHandler ¶
func (p *Plugin) EventHandler() control.EventHandler
func (*Plugin) Figures ¶
Figures notes the kinds of structures among the world's figures, which the Stage leads through its sections. Called in the Stage's Figures link.
func (*Plugin) Populate ¶
Populate holds the structures a level's file laid to the Rules; one that may not lie fails with its line.
func (*Plugin) Queues ¶
func (p *Plugin) Queues() []command.CommandQueue
Queues are the plugin's command queues: Aim, Mark, Dig, Cancel and Courses.
func (*Plugin) Reason ¶
Reason is a label saying why the tunnel in a player's hand may not lie where it points.
func (*Plugin) RunPlan ¶
RunPlan carries out the players' commands at once and digs the tunnels confirmed in the simulation.
func (*Plugin) Serializable ¶
func (p *Plugin) Serializable() plugin.Serializable
Serializable is the plugin's Resources, kept whole; a structure dug is its parts, saved as entities.
func (*Plugin) Settings ¶
Settings is whether what lies under the ground is marked over the world, under Game (plugin.Tunable).
func (*Plugin) Window ¶
Window is the window asking a player whether to dig the tunnel it marked out, shown while it asks.
func (*Plugin) WithShaper ¶
WithShaper gives the plugin the ground a player's tunnel levels its heads on; without it a tunnel opens only where its heads' ground lies flat already.
type Resources ¶
Resources is the state of the plugin, saved with the game whole: the tunnels ordered and not yet dug, and the players' settings.
type RoomRow ¶
type RoomRow struct {
From cell.ID `yaml:"from"`
To cell.ID `yaml:"to"`
Depth float32 `yaml:"depth"`
}
RoomRow is a chamber as a level's file writes it: under the rectangle of cells from From to To, its floor Depth under the lowest ground over it.
type Row ¶
Row is a tunnel as a level's file writes it: from the head From to the head To, turning at the cells Via.
type Ruled ¶
type Ruled interface{ Rules(p *Plugin) }
Ruled is a Figure with roles and rules of its own, defined in the Rules section.
type Settings ¶
type Settings struct{ HideCourses bool }
Settings is what the plugin lets the players adjust, saved with the game: whether the courses of what lies under the ground and the units in it are marked over the world, as they are unless hidden.
type Spec ¶
type Spec struct {
Allows cell.Domain
Load float32
Width float32
Clear float32
Pace float64
Look Look
}
Spec is what a kind of structure under the ground is: whom its floor carries (Allows, at Pace; 0 the ground's) and how heavy they may be (Load, kg; 0 any), how wide a tunnel of it runs and how much room lies over its floor, up to its roof.
type Stateful ¶
type Stateful interface{ Effects(p *Plugin) }
Stateful is a Figure with effects of its own, defined in the Effects section.
type Type ¶
type Type struct {
// contains filtered or unexported fields
}
Type is a kind of structure under the ground defined.
type Types ¶
type Types struct {
// contains filtered or unexported fields
}
Types is the register of the kinds of structures under the ground, defined on the Stage's kinds.
func (*Types) Chamber ¶
Chamber registers the kind of chamber named name, as spec says, its Width left out, with the kinds of its parts, "<name>.bore", and of its handle, "<name>.whole".
type Write ¶
type Write struct {
// contains filtered or unexported fields
}
Write changes what lies under the ground, on the game's goroutine.
func (*Write) Spawn ¶
Spawn digs every structure a level's file has: a tunnel, a line `{kind: <a kind of tunnel>, from: [x, y], to: [x, y], via: [[x, y], ...]}`, and a chamber, a line `{kind: <a kind of chamber>, from: [x, y], to: [x, y], depth: <units>}`. One the Rules refuse fails with its line, here or in Populate; the chambers are dug first, so a tunnel opens into one wherever the file has it.
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
Package site is where a structure under the ground may lie, the one set of rules whoever digs it keeps to: a level's file, a player with the tool in hand, a map maker.
|
Package site is where a structure under the ground may lie, the one set of rules whoever digs it keeps to: a level's file, a player with the tool in hand, a map maker. |