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.
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. 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 is drawn bared and its lamp as its shelter says.
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.
Index ¶
- Constants
- type Figure
- type Ground
- type Part
- 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) Queues() []command.CommandQueue
- func (p *Plugin) Restore()
- func (p *Plugin) RunPlan(ctx goke.RunCtx, d time.Duration)
- func (p *Plugin) Serializable() plugin.Serializable
- func (p *Plugin) String() string
- func (p *Plugin) Types() *Types
- func (p *Plugin) WithAir(sky Sky, ground Ground) *Plugin
- func (p *Plugin) WithRooms(rooms *interiors.Plugin) *Plugin
- func (p *Plugin) World() *world.Plugin
- func (p *Plugin) Write() *Write
- type Raise
- type Resources
- type Roof
- type Row
- type Ruled
- type Sky
- type Spec
- type Stood
- type Types
- type Write
Constants ¶
const BuildingRole = "buildings.building"
BuildingRole is the role every building plays, the plugin's own: a building goes as its sector folds.
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 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 ¶
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 ¶
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 (*Plugin) EventHandler ¶
func (p *Plugin) EventHandler() control.EventHandler
func (*Plugin) Figures ¶
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) Queues ¶
func (p *Plugin) Queues() []command.CommandQueue
Queues are the plugin's command queues: Raise.
func (*Plugin) Restore ¶
func (p *Plugin) Restore()
Restore takes the Resources loaded and has the buildings laid anew.
func (*Plugin) RunPlan ¶
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) WithAir ¶
WithAir has the buildings hazed by the air of sky where ground is hazed, and clear where it is not.
func (*Plugin) WithRooms ¶
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.
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.
type Resources ¶
Resources is the state of buildings, saved with the game whole: the buildings standing, by the sector their middles lie in.
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 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
// Floor colours its room's floor; zero, boards.
Floor 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 Types ¶
type Types struct {
// contains filtered or unexported fields
}
Types is the register of the kinds of buildings, defined on the Stage's kinds.
type Write ¶
type Write struct {
// contains filtered or unexported fields
}
Write changes the buildings standing, on the game's goroutine.