buildings

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: MIT Imports: 32 Imported by: 1 module, 0 packages

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 buildings stands the buildings of a level's file as solids: walls on a rectangle turned any way and a roof over them, each as long, as wide and as high as its line says.

NewPlugin takes a world with heights and the board. A game defines its kinds in the Kinds section (Plugin.Types, in a Figure): a Spec says how high a storey is, how many a building has where the file says none, its colours, how wide a window's bay is and its [Part]s, the first its body on the building's own rectangle, the rest (a tower, a turret, a room on the roof) standing where the spec puts them, each under a Roof: Flat, Gable, Hip or Pyramid. Sizes are world units: a game gives them in metres through its world.Scale.

The walls are rendered in lime. A kind's buildings are washed in its [Wash]es by their shares, each picked by where it stands, and a kind of Spec.Stone has its plinths under the storeys, its corners and the frames of its doors and windows dressed in that stone.

A level's buildings

A line of a level's file `{kind: house, mid: [x, y], size: [length, width], turn: degrees, floors: n, door: [x, y]}` is a building (Row); Write.Spawn takes every one in the Spawn section and Write.Stand stands one from the game's code.

A door and a room

A building whose line gives a door, of a kind whose Spec gives one its width and height, stands square to the board's square grid on whole cells, a room over them on RoomStorey, entered by the door in the middle of the wall its line points at, its walls as thick as the Spec says, stopping a body at their faces, and a window of its storey too near the door left out. The room's floor lies as high as the ground in the middle of the door, level across its cells: dug into the ground uphill, the ground cut where it rises into it, on a plinth downhill; the storeys are counted from it. Its handle is a room of the interiors plugin (interiors.Room) under a light.Shelter: the sun gets in by the windows of its storey where the ground outside lies under their sills and by its door, its lamp burning from dusk; Plugin.WithRooms takes the keeper of the rooms, so a room an uncovered entity stands in opens before the cameras the Settings say and its lamp burns as its shelter says.

Holding the cameras

Plugin.Read is what stands for the cameras (cameras.Config.Walls): a building's parts hold a camera's eye and stop its cursor, a house's room letting them in within its walls, under its ceiling and by its door, its windows glass. A house an uncovered entity stands in opens round its room before a camera of the tactical view (OpenRooms) and one behind a unit (OpenRoomsBehind) where the settings say, never before one inside a unit: cut away there, the walls it shows the camera low where they stood, the others as high as the room, no roof, it lets the cursor and the eye in; shut, it stands whole. An eye in a room sees it from inside, its walls and its ceiling, the world outside by its windows and its door.

Drawn at every level, an entity where its sector unfolds

The plugin draws the buildings itself, from the file's lines, in the frame's light, the relief's shade and the air's haze (Plugin.WithAir): whole where the camera sees their sector at the close and standard scales, among the figures, giving way to what is uncovered as the world's settings say (world.Write.GivesWay), a room's door and the windows of its storey open and its inside drawn, lit by the sun where it falls in; their bodies alone, without windows, under a level lid with the ground at the strategic one. No sheet holds them.

A building is an entity only where its settlement's sector has come near: the game's settlement, a field aggregate, gives itself Raise under its world.Unfold, and the plugin spawns the buildings standing in that stretch as its parts, each of its kind, standing for good (world.Fixed), turned (world.Stand), casting its shadow on the ground (light.Baked) and playing BuildingRole, by which it goes as the sector folds. What a unit may not walk through is the board's: a map gives the cells under a building a kind no walker is allowed on, and a room's walls stand on its cells' edges but for its door.

Vocabulary

  • Raise: the command a settlement gives itself under a world.Unfold to have the buildings of the stretch unfolding spawned as its parts.
  • OpenRooms, OpenRoomsBehind: a player's settings, whether a house a unit stands in opens round its room before a camera of the tactical view and before one behind a unit.

Index

Constants

View Source
const BuildingRole = "buildings.building"

BuildingRole is the role every building plays, the plugin's own: a building goes as its sector folds.

View Source
const RoomStorey = cell.Storeys - 1

RoomStorey is the storey of the board's cells a building's room is laid on: the last, the first left to bridges and those between to what is dug under the ground.

Variables

This section is empty.

Functions

This section is empty.

Types

type Figure

type Figure interface{ Define(p *Plugin) }

Figure is a game's buildings in one piece: their kinds defined on the plugin's Types in the Kinds section. One with roles and rules of its own is Ruled.

type Ground

type Ground interface{ Hazes() bool }

Ground says whether the air hazes what stands on it, the topography's Read.

type OpenRooms added in v0.24.0

type OpenRooms struct{ On bool }

OpenRooms has a house a unit stands in open round its room before a camera of the tactical view, loose or centred on a unit, letting the cursor and the eye in, or stand whole there (Settings.Shut). The settings screen alone, under Game.

func (OpenRooms) Command added in v0.24.0

func (OpenRooms) Command()

type OpenRoomsBehind added in v0.24.0

type OpenRoomsBehind struct{ On bool }

OpenRoomsBehind has a house a unit stands in open round its room before a camera behind a unit, letting the cursor and the arm in, or stand whole there (Settings.ShutBehind). The settings screen alone, under Game.

func (OpenRoomsBehind) Command added in v0.24.0

func (OpenRoomsBehind) Command()

type Part

type Part struct {
	Roof Roof
	// Pitch is how high the roof rises, a share of half the part's width.
	Pitch float32
	// Size is the part's length and width, world units; zero, the building's own.
	Size geom.Vec
	// Off is where the part's middle lies off the building's, along it and across, shares of
	// half its length and half its width.
	Off geom.Vec
	// Height is how high the part's walls stand, world units; zero, the building's storeys and
	// Above over them.
	Height float32
	Above  float32
	// Walls and Tiles colour the part; zero, the Spec's.
	Walls color.RGBA
	Tiles color.RGBA
	// Blind leaves the part's walls without windows.
	Blind bool
	// Fine has the part drawn at the close and standard scales alone.
	Fine bool
}

Part is a solid of a building: walls on a rectangle and a roof over them. Zero, it is the building's own: its rectangle, its walls as high as its storeys, a flat roof.

type Plugin

type Plugin struct {
	*world.Self

	Res Resources
	// contains filtered or unexported fields
}

Plugin stands the buildings of a level's file: the kinds a game defines on its Types, drawn as solids at every level, entities where their settlement's sectors come near.

func NewPlugin

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

NewPlugin builds the plugin of buildings over w, a world with heights, and the board brd, which their ground is read off.

func (*Plugin) DefaultBindings

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

func (*Plugin) EventHandler

func (p *Plugin) EventHandler() control.EventHandler

func (*Plugin) Figures

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

Figures notes the game's buildings 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) Queues

func (p *Plugin) Queues() []command.CommandQueue

Queues are the plugin's command queues: Raise, OpenRooms and OpenRoomsBehind.

func (*Plugin) Read added in v0.24.0

func (p *Plugin) Read(int) *Read

Read reads the buildings standing.

func (*Plugin) Restore

func (p *Plugin) Restore()

Restore takes the Resources loaded and has the buildings laid anew.

func (*Plugin) RunPlan

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

RunPlan stands the buildings of the stretches told to Raise in the simulation.

func (*Plugin) Serializable

func (p *Plugin) Serializable() plugin.Serializable

Serializable is the plugin's Resources, kept whole; a building raised is an entity, saved as any.

func (*Plugin) Settings added in v0.24.0

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

Settings are whether a house a unit stands in opens round its room in the tactical view and behind a unit, where a kind of building has a room (plugin.Tunable, under Game).

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

func (*Plugin) WithAir

func (p *Plugin) WithAir(sky Sky, ground Ground) *Plugin

WithAir has the buildings hazed by the air of sky where ground is hazed, and clear where it is not.

func (*Plugin) WithRooms

func (p *Plugin) WithRooms(rooms *interiors.Plugin) *Plugin

WithRooms has the buildings' rooms lit and bared as rooms says who stands in them: whatever lies over a room an uncovered entity stands in gives way to it whole.

func (*Plugin) World

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

World is the world the buildings stand in.

func (*Plugin) Write

func (p *Plugin) Write() *Write

Write changes the buildings standing, on the game's goroutine.

type Raise

type Raise struct {
	// contains filtered or unexported fields
}

Raise is the command a settlement gives itself under a world.Unfold to have the buildings the level's file stands in the stretch unfolding spawned as its parts.

func (*Raise) Aim

func (r *Raise) Aim(who uid.UID64)

Aim tells the command the stretch of the settlement unfolding.

func (Raise) Command

func (Raise) Command()

type Read added in v0.24.0

type Read struct {
	// contains filtered or unexported fields
}

Read reads the buildings standing: where they hold the cameras.

func (*Read) Free added in v0.24.0

func (r *Read) Free(x, y, z float32) bool

Free reports whether no building's solid fills the point (x, y, z), every house shut: a part's walls on its rectangle from its foot and its roof over them, but for a house's room within its walls, from its floor to its ceiling, and its door.

func (*Read) FreeTo added in v0.24.0

func (r *Read) FreeTo(how camera.How, x, y, z float32) bool

FreeTo is Free as a camera fastened how sees it: a house open before it, a unit standing in its room as the settings say, is free whole.

func (*Read) Grain added in v0.24.0

func (r *Read) Grain(x, y float32) (step, thin float32)

Grain is how far a line of sight may step near a house with a room, and how thin its walls are; zero elsewhere.

func (*Read) Span added in v0.24.0

func (r *Read) Span() (low, high float32)

Span is the lowest foot and the highest roof of the buildings.

type Resources

type Resources struct {
	Stood    map[int][]Stood
	Settings Settings
}

Resources is the state of buildings, saved with the game whole: the buildings standing, by the sector their middles lie in, and the settings.

type Roof

type Roof uint8

Roof is the shape of the roof over a part's walls.

const (
	// Flat is a level roof.
	Flat Roof = iota
	// Gable is two slopes meeting at a ridge along the part, a wall's gable at each end.
	Gable
	// Hip is four slopes, the ridge shorter than the part by its width.
	Hip
	// Pyramid is four slopes meeting at a point.
	Pyramid
)

type Row

type Row struct {
	Mid    [2]float32 `yaml:"mid"`
	Size   [2]float32 `yaml:"size"`
	Turn   float32    `yaml:"turn"`
	Floors int        `yaml:"floors"`
	// Door is where on its wall the building's door opens, world units: it stands square on whole
	// cells, a room over them, entered there; zero, it has none.
	Door [2]float32 `yaml:"door"`
}

Row is a building of a level's file: where its middle stands and its length and width, world units, how it is turned, degrees from the east towards the south, and its storeys.

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 added in v0.24.0

type Settings struct {
	Shut, ShutBehind bool
}

Settings are the buildings' settings: whether a house a unit stands in stays whole before a camera of the tactical view (Shut) and before one behind a unit (ShutBehind), rather than open round its room, letting the cursor and the eye in; before one inside a unit it always does.

type Sky

type Sky interface{ Air() air.Weather }

Sky is the air between the eye and a building far off, the atmosphere's.

type Spec

type Spec struct {
	// Storey is how high a storey is, world units.
	Storey float32
	// Floors and Size are a building's storeys and its length and width, world units, where its
	// line of the map gives none.
	Floors int
	Size   geom.Vec
	Walls  color.RGBA
	Tiles  color.RGBA
	// Bay is how wide a window's bay is along a wall, world units; zero, no windows.
	Bay   float32
	Parts []Part
	// Roles are the roles a building of the kind plays beside BuildingRole.
	Roles []string
	// Door is how wide and tall a building's door is where its line of the map gives it one;
	// zero, none does.
	Door cell.Gap
	// Wall is how thick the walls of a house with a room are, world units; zero, a twelfth of a
	// storey.
	Wall float32
	// Floor colours its room's floor; zero, boards.
	Floor color.RGBA
	// Washes are the colours the kind's buildings are washed in, each for its share of them,
	// picked by where a building stands; none, Walls.
	Washes []Wash
	// Stone dresses the kind's plinths under their storeys, their corners and the frames of
	// their doors and windows; zero, none is.
	Stone color.RGBA
}

Spec is a kind of building: its parts, the first its body, and what a building of it is where the map says nothing.

type Stood

type Stood struct {
	Kind string
	Row  Row
}

Stood is a building standing: its kind and its line.

type Types

type Types struct {
	// contains filtered or unexported fields
}

Types is the register of the kinds of buildings, defined on the Stage's kinds.

func (*Types) Define

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

Define registers the kind of building named name, as spec says: a part of its settlement standing for good, drawn by the plugin, playing BuildingRole and spec's Roles.

func (*Types) Named

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

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

type Wash added in v0.24.0

type Wash struct {
	Colour color.RGBA
	Share  float32
}

Wash is a colour a kind's buildings are washed in and the share of them washed in it.

type Write

type Write struct {
	// contains filtered or unexported fields
}

Write changes the buildings standing, on the game's goroutine.

func (*Write) OpenRooms added in v0.24.0

func (w *Write) OpenRooms(on bool)

OpenRooms has a house a unit stands in open round its room before a camera of the tactical view, loose or centred on a unit, or stand whole there (Settings.Shut).

func (*Write) OpenRoomsBehind added in v0.24.0

func (w *Write) OpenRoomsBehind(on bool)

OpenRoomsBehind has a house a unit stands in open round its room before a camera behind a unit, or stand whole there (Settings.ShutBehind).

func (*Write) Spawn

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

Spawn stands every building a level's file has, a line `{kind: <a kind of building>, mid: [x, y], size: [length, width], turn: degrees, floors: n, door: [x, y]}`: drawn from then on, an entity where its settlement's sector unfolds; one with a door stands its room too.

func (*Write) Stand

func (w *Write) Stand(name string, row Row)

Stand stands a building of the kind named name as row says, as a line of a level's file does; one with a door, in the Spawn section, on the ground its level's file seeds (Spawn) or the board's heights.

Jump to

Keyboard shortcuts

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