underground

package
v0.22.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 31 Imported by: 1 module, 1 package

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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 Aim

type Aim struct{ At geom.Vec }

Aim is where the cursor of a player holding the tunnel points: where the tunnel runs to.

func (Aim) Command

func (Aim) Command()

type Cancel

type Cancel struct{}

Cancel digs nothing of the tunnel its player was asked about, the first head still laid.

func (Cancel) Command

func (Cancel) Command()

type Config

type Config struct {
	Rules site.Rules
	Digs  string
}

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.

func (Courses) Command

func (Courses) Command()

type Dig

type Dig struct{}

Dig digs the tunnel its player was asked about.

func (Dig) Command

func (Dig) Command()

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

type Mark struct{ At geom.Vec }

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.

func (Mark) Command

func (Mark) Command()

type Order

type Order struct {
	Kind string
	Plan site.Tunnel
}

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

type Plugin struct {
	*world.Self
	Res Resources
	// contains filtered or unexported fields
}

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

func NewPlugin(w *world.Plugin, brd *board.Plugin, cfg Config) *Plugin

NewPlugin builds the plugin of what lies under the ground over w and brd, a world with heights.

func (*Plugin) DefaultBindings

func (p *Plugin) DefaultBindings() []control.Binding

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

func (p *Plugin) Figures(figures ...Figure)

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) Install

func (p *Plugin) Install(ctx plugin.Installer) error

func (*Plugin) Name

func (p *Plugin) Name() string

func (*Plugin) Populate

func (p *Plugin) Populate() error

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

func (p *Plugin) Reason() *ui.Element

Reason is a label saying why the tunnel in a player's hand may not lie where it points.

func (*Plugin) Restore

func (p *Plugin) Restore()

Restore takes the Resources loaded.

func (*Plugin) RunPlan

func (p *Plugin) RunPlan(ctx goke.RunCtx, d time.Duration)

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

func (p *Plugin) Settings() []control.Setting

Settings is whether what lies under the ground is marked over the world, under Game (plugin.Tunable).

func (*Plugin) String

func (p *Plugin) String() string

func (*Plugin) Types

func (p *Plugin) Types() *Types

Types is the plugin's register of the kinds of structures.

func (*Plugin) Window

func (p *Plugin) Window() *ui.Element

Window is the window asking a player whether to dig the tunnel it marked out, shown while it asks.

func (*Plugin) WithShaper

func (p *Plugin) WithShaper(s ground.Shaper) *Plugin

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.

func (*Plugin) World

func (p *Plugin) World() *world.Plugin

World is the world the structures lie under.

func (*Plugin) Write

func (p *Plugin) Write() *Write

Write changes what lies under the ground, on the game's goroutine.

type Resources

type Resources struct {
	Orders   []Order
	Settings Settings
}

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

type Row struct {
	From cell.ID   `yaml:"from"`
	To   cell.ID   `yaml:"to"`
	Via  []cell.ID `yaml:"via"`
}

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.

func (Type) Name

func (t Type) Name() string

Name is what the kind of structure is called.

func (Type) Spec

func (t Type) Spec() Spec

Spec is what the kind of structure is.

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

func (t *Types) Chamber(name string, spec Spec)

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".

func (*Types) Define

func (t *Types) Define(name string, spec Spec)

Define registers the kind of tunnel named name, as spec says, with the kinds of its parts, "<name>.bore", and of its handle, "<name>.whole".

func (*Types) Named

func (t *Types) Named(name string) Type

Named is the kind of structure defined as name; an unknown name panics.

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

func (w *Write) Spawn(level *board.Level) error

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.

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL