world

package
v0.22.0 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 56 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 world is the foundation for a Stage with drawable entities: a Position and Velocity each and a shared spatial index other plugins query; the motion plugin moves them. What an entity carries is set by its kind (entity/kind).

The world runs gram's core: entity and entity/kind, clock, and ceremony through its goke binding (the effects, the plans, the commands about effects, the roles' tags). Its sub-package is view (what one camera sees); its machinery is in plugins/world/internal.

Plugin

Plugin is the world a Stage makes from a Config: the SpaceCfg sizes it and sets the edge rule per axis (closed, wrapping or open), the EntitiesCfg bounds how many entities it holds and their sizes; what becomes of one past an open edge is motion's. Config.Heights gives the world heights: entities carry a Z, and the board, the topography and the atmosphere stand in no other; a flat world refuses a Z. The world knows its entities and nothing else: the ground is the board's, the sky the atmosphere's.

Read and Write

The world's state is read through Plugin.Read and changed through Plugin.Write: Read(w) is worker w's of the game's pool, 0 the game's own goroutine, each with queries of its own, so the workers read the world at once; Write is the game's goroutine's. Read(w).Space() queries the spatial index, Read(w).Clock() reads the clock and Read(w).Effects() which effects the entities are under; Write() spawns, writes the space, drives the clock and casts the effects. Read(w).GroundAt is the ground's height under a point as the plugin laying the ground in relief gives it (Write.SetGround, the topography's), 0 in a world without one.

Base, Position and Velocity

Base is the one component every entity carries: its Position, its Velocity (a unit heading and a speed in world units a second), the kind it was spawned from and the capability bits the space indexes it under. Z, Layers, Eye and Lie are the types of package entity under the world's own names. No entity moves further in a step than StepReach of its own shorter side.

Scale

Scale says how many metres a world unit spans; with one the ground sinks under an eye's level far off (Scale.Drop, Scale.Horizon). A game gives metres through Scale.Units, and the sizes of its figures, drawn bigger than life, through Scale.Figure.

Kinds, Seed and Populate

Plugin.Kinds is the register kind.Define registers with; Kinds.DefineTag hands out the bits of a tag family by name and Kinds.NewSprite atlas slots no kind owns. A Stage's Spawn puts entities on the roster with Write.Seed; the engine calls Plugin.Populate only for a Stage entered afresh. Plugin.Roster is what the plugins ask of the kinds of each template (EntityTemplate and those a plugin brings: motion.UnitTemplate, the board's), the world and every plugin made writing theirs in their KindTemplates as it is first read.

Roles and Commands

What a game defines is its Stage's, by name: Roles (Plugin.Roles) and Commands (Plugin.Commands), beside the effects (Write.Effects) and the kinds. Define registers and hands nothing back; Named is the thing; a name defined twice or asked for unknown panics. A role is a tag of the family cond.Roles, saved by name. The world plays roles itself ([Plugin.Plays]): the rules of a clock.Moment they obey fire every step.

A plugin's own entity

Self is the one entity a plugin has in the world, called by the plugin's name, carrying its knobs, the roles it plays and the effects it is under. A plugin makes it with NewSelf as it is made and embeds it, so it is whom a command may be for and learns from Self.Changed that its knobs were turned. The world's own is the clock's entity, which ceremony.World names.

Spawn and Despawn

The command Spawn adds an entity of a kind to the running world at the next step of the simulation (Write.Spawn gives it as the game's own); one refused is logged, never a panic. An entity gives itself Despawn to go. The world carries out the commands about effects (ceremony.Put, Take, Toggle) for the entities named or grouped by their ceremony.Label and for the world itself, netting a step's commands of one effect on one entity.

Clock and the tick

The world keeps the tactical clock (Write.Clock) and the commands Pause (P, Shift+P), Faster and Slower on it. Plugin.RunPlan runs the tick: the clock's commands, the sectors and the views at once; in every step of the simulation the plans, the spawns and the despawns, the commands about effects, the clock's moments, the aggregates' and the effects, the space told of every entity after a spawn or a despawn. Write.Carrier is the Stage's one carrier of commands.

Drawing and Look

How entities are drawn is declared on the world's Atlas by the figures' Looks, gathered once the Stage is set up, before its scenes: a kind's look, its look Under an effect, Turning, Facing, Animated, Lying, Upright, Uncovered, GivesWay, Cutout, Swaying, Edges, and Styled: how another plugin draws about the kind (an outline, a cone, a route), a render.Style of that plugin's, read off Read.Styles. Closing the atlas hands it to the world (Write.SetAtlas), which gives it the entity renderer and applies what was declared; a game declaring looks by hand closes its own (Plugin.NewAtlas) before. Each entity is laid on the screen by the world's Look (Read.Look, Write.SetLook), flat from above unless a view plugin sets its own; a DirectLook draws the sprites itself on the GPU, a LyingLook lays some flat, an UprightLook stands some true, a FoggyLook fades one into the fog before a camera's sight, an UncoveringLook has some uncovered and some give way to them, and a CutoutLook draws what is whole in the cutout pass. A kind's look declared Slot.Uncovered shows through whatever is declared Slot.GivesWay and stands before it or over it, which is left out in part round it (render.Target.Uncovered): before a camera loose over the world or centred on a unit, the tactical view, unless the settings say not (GiveWay), and before one riding a unit, behind it or inside it, only where they say (GiveWayRiding; Read.GivesWay, both under the settings' section Game). A plugin's source giving way to the uncovered too, as the buildings' do, says so (Write.GivesWay) and asks the frame drawn before which cameras (Read.GivesWayDrawn); Read.Uncovered says whether a sprite is drawn uncovered. One declared Slot.Cutout is drawn whole in render's cutout pass, cut at half its alpha and writing the depth, so what stands under it is hidden and the cutouts need no order. Each is marked by the Lighting, the light plugin's (Write.SetLighting), and lit as the frame says (render.Frame.Lit) by the lights the picture is given (Write.SetLights, Read.Lights), in white light without them. A kind may be a Body in place of a drawn sprite (Atlas.AddBody): parts, spheroids and cones, in paints. A view in relief with a BodyLook stands it whole out to the level the bodies reach and as a card of it beyond, down to L3, the side of it the camera sees or, looking down steeply, its top (Bodied.Card), lit by the frame's light as the body whole is; a view from above draws it photographed from above, turned as it stands, and its sprite, from the side, is a photograph too, taken on the GPU as its cards are (Slot.Above has the sheets take it from above). How far the bodies stand whole is a setting, the close scale, L2 or L3 (Bodies, Read.BodiesReach), which follows the cameras' frame budget where they are given the world's Plugin.Bodies for a lever (AdaptBodies, BodiesLever). An entity is drawn in its kind's look at the level its camera sees it at: its own at L2 (lod.Standard) and the close levels, plainly at L3 (no edges, flat where it would stand), a blob of its own look at L4 (render.Blob), its blob's colour in the ground at L5, or as Slot.At and Slot.Nothing declare from a level on, a close one to Standard at most. At L4 the renderer draws it itself as a point, its box as large as it shows and a pixel at least, as opaque as it covers, with no Look, lamp or shadow, and a camera publishes the ladder's Keep share of a level's entities by their identity, the same each frame, sparing the sector.Keen, a kind Slot.Always and one drawn in a look declared there. As Config.Far and the settings say (ShowFar, Read.FarLook), a kind's loose units in a sector drawn from L4 on are a point each or, where the kind declares a look there, one Banner at their centroid (Read.Banners), never thinned, drawn as a badge over their top (BannerStyle: a disc or a diamond in the kind's far colour, a kind's own by Slot.Styled, and a style alone has a kind bannered there); with the counts drawn (ShowCounts, Read.Counts) the number of a banner's units from two on stands inside its badge, and of a kind's points two or more in a sector over their centroid, in the picture as deep as they stand. What stands for good where a sheet is drawn from L4 is left to the sheet from above, and drawn as a point of its look there or its blob through a camera with an eye, which sees no sheet (a photograph from above). A camera riding inside an entity (camera.Inside) draws none of its figure, its shadow still. Plugin.WithFog is the fog's colour in a world without an atmosphere. The entities are published once a frame, after its ticks: the looks' rules settle every one some camera sees, the Lighting marks it, each camera's view is copied, and the frame is drawn of that alone. In a world cut into sectors whose ground a renderer draws (Plugin.Sheets) what stands (Fixed) in a sector some camera sees at L4 or L5 is photographed on the GPU from its L3 looks, with the parts of the fields folded there, into Read.Sheet, an albedo and a relief over the whole world (SheetImage, SheetReliefImage, at L5 in half), a few sectors a frame as their content changes; once a sector's sheet is painted its standing entities are no record, the renderer drawing the sheet as the ground's relief, and a unit there is its blob. What stands is signed into its sector as its chunk comes, goes or has its table moved, or as Write.Restill says of a change in place, never walked frame by frame. A standing entity cut by a sector's edge, or beside a sector seen finer than L4, is drawn alive at the finer level, never thinned, and photographed nowhere.

Config.Sheets (SheetsCfg) keeps the sheets between runs: they are read from the tiles in its Dir as they are made, so a sector photographed in an earlier run is photographed again only once what stands in it changes, and with Keep the tiles a sector was photographed in are written back there as they settle, a tile a second; without Keep the folder is only read. Tiles of another Version, texel or world are not read. What a field's folded parts look like is not in what a sector is signed by, so a game changing how it plants its fields changes Version.

Read.Picture is everything the Stage's plugins draw (plugin.Installer.Draws), one picture for every scene; a scene shows it through a camera, ui.Image(render.NewFeed(camera, it)).

Sectors

Config.Sectors cuts the world into sectors, each ticked at the fullest level Config.LOD (a lod.Ladder) says one of the observers sees it at (Write.Observe; the cameras plugin gives its cameras; a sector off a camera's picture at lod.Strategic or coarser, but for the sector its viewpoint lies in and the eight round it, whole whichever way the camera looks) or a sector.Keen entity in it or beside it keeps it at, and marks each entity with its sector's level and how many levels coarser that is than the finest any observer sees (package sector); what lies at L6 (lod.Omitted) is out of the space. An entity gives itself Keen to keep its sector so, Calm to keep it so no more. With no observer every sector is ticked at the ladder's Unobserved level, L4 unless set. An entity travelling the abstract graph far from every camera carries sector.Abstract, saved with the game. A system adds the pace of its lod.Paces (Plugin.Pace) to its query and walks it with goke.Query.Paced, in full on the finest level seen, so a world with no observer goes in full everywhere; the world's plans and effects go lod.Slowing(2, 4, 8). Plugin.Within keeps a query to the sectors of one scale: a system of the close scale's detail goes Within(lod.Close) at lod.Exact, nowhere while nobody looks so close. Read.Sectors lays them on the telemetry panel. A camera's View in such a world is of the sectors it sees, each at the level it sees it at (view.NewSeen), within Read.Sight; Read.Seen lays the first camera's on the panel. SwitchSectors shows the sectors over the ground by the level they are ticked at or by how the camera sees them (Write.ShowSectors); SwitchBands switches the levels off, every sector ticked at Standard, to weigh what they spare (Write.SetBanded); both are the settings screen's alone.

Aggregates

An Aggregate is a kind of entity standing for parts, an army's soldiers: they are the truth while its sector is ticked finer than L4 (lod.Strategic), it alone from L4 on. It is told Unfold once as its sector comes down finer than L4 (the world unfolding at most lod.Ladder.Unfolds stretches a step, those nearest an observer first, the others waiting folded as they are), when its rules spawn the parts (SpawnPart), each carrying PartOf it, and Fold once its sector has lain at L4 or coarser for the ladder's Fold seconds, with the Parts it has, each part told a Folding to sum itself into it and go; the wait is the stretch's, an entity the world keeps while it is unfolded, saved with the game. From its first Unfold till the step after its last Fold, its parts gone, it carries Unfolded, saved too: its parts are drawn for it and what moves it stands it, at any level, and a point aggregate stands each step at the middle of its parts, its own size kept, so its sector, its banner and whatever follows it go with them. Folded, it counts in its banner for its Strength where its kind declares one, which the world sets to the parts folded in at each Fold; without, for one. Before a point aggregate's Fold is told the world moves it to the centroid of its parts' centres, so what sums them finds it where they stood; with no part left it stays. What the parts are and what has changed of them is the game's: lod.Seed is the number a place of the aggregate draws from, the same at every unfold, its losses its effects. Two aggregates travelling the abstract graph (sector.Abstract) are told Met once as their boxes come to overlap, again only after they have parted; one standing unfolded is on no such graph. A unit's route is a plain value of its order, one an aggregate and the part leading it may hand each other as they fold and unfold (navigation.Inherit).

A Field aggregate stands over a box round its centre wider than an entity may be and goes by sector: each sector of it unfolds and folds apart, told with the Sector and the Box of the field within it, its parts there those whose centre lies in it, and it is found asleep too, its own sector at L6 stopping none of the others. A point aggregate's moments tell the sector of its centre and its own box. A SpawnPart given under an Unfold is laid At off the middle of that Box, so the plots a rule plants, picked by words over lod.Seed and the aggregate's effects, lie in the sector. A field is drawn by sector, asleep too, wherever a camera sees its part there: its look at the level of that sector stretched over the part, from L4 in the sector's sheet where it declares none; a sector it is unfolded in has its parts drawn alone, till they have gone the step after its Fold. Drawn so, it lies on the ground, under the figures standing over it.

A field's stretch a sheet draws, of a kind declaring no look of its own at L4, with none of its parts kept (never unfolded, or not since the game was loaded), is previewed before its sector is photographed: told its Unfold as though it unfolded, it has the parts its rules give there photographed where they would stand, on the ground the world is given (Write.SetGround), and kept as a Fold keeps them; none is spawned, no stretch is made, nothing is saved. Its rules cannot tell a preview from an unfolding, so whatever else they do under Unfold is done then too.

Views

Write.NewView makes the view.View of a camera, as the cameras plugin makes the camera, refreshed once a tick after movement. What publishes for a frame culls by every camera's (Read.Views, Read.InView); what draws reads a camera's as the frame was published (Read.ViewFor), one copy a frame for all of it, and draws only what it contains.

Telemetry

Telemetry counts the population; Resources publishes it with the Config.

Figures

A Figure is a kind of entity in one piece: Define says what it is (kind.Define with the roster, the roles it plays, its plan), Look how it looks on the world's Atlas; one with states of its own is Stateful (Effects), one with roles and rules of its own Ruled (Rules). Plugin.Figures notes them in the Stage's Figures link, and the Stage runs each part in its section after the game's own functions (Plugin.FiguresIn); Atlas.Looks declares every look in a scene. What several kinds share — a role many play, a rule of the whole — stays the game's, in its sections. A figure standing on a board is the board's (board.Plugin.Figures), defined over it and looked here.

Vocabulary

Moments, for a role's rules: Unfold (a stretch of an aggregate come down finer than L4, its subject the stretch), Fold (one folding; its word Parts), Folding (each part of it, its subject the aggregate), Met (a pair of aggregates on the abstract graph, host.Met). Marks: Aggregate and Field (on a kind), PartOf (on a part), Unfolded (on an aggregate, for the plugins: a rule reads no component), Fixed (on a kind standing for good, what the sheets of the strategic scale are photographed of), Whole (on the kind of the handle of a thing standing in pieces, its joint box and no sprite, despawning its pieces as it goes), PieceOf (on a piece, its handle's), Unseen (on a kind none of the world's looks draw, its plugin drawing it by a source of its own). A thing standing for good lives in a tier of sectors (sector.Grid.Fit): one no longer than SectorsCfg Small by its centre, a longer one in the lowest holding it whole. Knobs, for an effect's Alter: render.Appearance, the look's. Commands: Spawn (a player's or an entity's own); SpawnPart (an aggregate's own, aimed at the stretch of an Unfold); SpawnWhole (a handle and its pieces in one step, as Spawn); Despawn, Keen, Calm (an entity's own); Pause, Faster, Slower, Tempo, SwitchSectors, SwitchBands, ShowFar, ShowCounts, Bodies, AdaptBodies, GiveWay, GiveWayRiding (a player's). Settings (Settings, saved with the game, in Resources): the sectors drawn, their levels on, how the loose units are drawn far off and whether they are counted, how far the bodies stand whole and whether that follows the frame budget, before which cameras what gives way does. The clock's moment and the commands about effects (ceremony.Put, Take, Toggle, Trigger) are carried here too.

Index

Examples

Constants

View Source
const (
	MaxParts  = 12
	MaxPaints = 4
	BodyViews = 8
)

The most Parts and Paints a Body holds, and how many sides it is seen from as a card.

View Source
const (
	EarthRadius = 6371000.0
	Refraction  = 0.13
)

EarthRadius is in metres; Refraction is the standard refraction, how much the air bends a line of sight back towards the ground.

View Source
const AsConfig = 0

AsConfig is a setting left as the Config says (Settings.Far, Settings.Counts): the zero an older save loads such a setting as.

View Source
const FigureLift = ilook.FigureLift

FigureLift is how far over its height a figure lies among what is drawn back to front: over whatever a plugin lays on the ground beneath it, at a lift of its own below this one.

View Source
const SheetImage = "Sheet"

SheetImage is the name the shaders read a sheet's albedo by (Read.Sheet), a frame image (render.RegisterImage) a renderer binds, at L4 or at L5, where it draws a sector so.

View Source
const SheetReliefImage = "SheetRelief"

SheetReliefImage is the name the shaders read a sheet's relief by (Read.Sheet), bound as SheetImage is.

View Source
const StepReach = entity.StepReach

StepReach is how far an entity may travel in one tick, as a share of its own shorter side.

Variables

View Source
var EntityTemplate = kind.NewTemplate("entity", nil)

EntityTemplate is the template of every kind the world spawns, the parent of a plugin's own.

Functions

func Own added in v0.5.0

func Own[T any](r *Rules, col interface{ Slice(*goke.Cursor) []T })

Own has the rules over T read the column col of the renderer's own query. Call it before Bind.

func Parts added in v0.20.0

func Parts(n int) cond.Word[Fold]

Parts is the word of a stretch of an aggregate folding with n parts or more.

func RunOf added in v0.4.0

func RunOf(ids []uid.UID64, bases []Base) aabbworld.Run

RunOf is the space's run over bases, a chunk's Base column named by ids: the space reads the boxes and their Caps where they lie and pushes the boxes in place.

Types

type AdaptBodies added in v0.22.0

type AdaptBodies struct{ On bool }

AdaptBodies has the bodies' reach follow the cameras' frame budget, or not (Settings.StillBodies): the world's Bodies is a cameras.Lever (cameras.Config.Levers), the reach drawn in a level as the rate falls under the budget, out again as it stays over. The settings screen alone, under Graphics.

func (AdaptBodies) Command added in v0.22.0

func (AdaptBodies) Command()

type Aggregate added in v0.20.0

type Aggregate struct{ Strength int }

Aggregate marks the kind of an entity standing for parts, an army's soldiers: they are the truth finer than Strategic, spawned by its rules at its Unfold, and it alone from Strategic on, as they are summed into it at its Fold. Strength is how many units it stands for folded, counted so in its banner (zero, one); the world sets a Strength declared to the parts folded in at each Fold.

type Atlas added in v0.3.0

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

Atlas is the world's sprite sheet under construction, where every kind's look is declared; Close bakes it and the world takes it as its looks.

func (*Atlas) Add added in v0.3.0

func (a *Atlas) Add[L render.Look](of render.Sprited, size int, look L) Slot

Add takes look on as of's own and hands back a Slot to chain the rest of its look on. A SpriteDrawer is drawn once into the sheet, size x size; a MaterialID is worked out per pixel in the entity's box every frame.

func (*Atlas) AddBody added in v0.22.0

func (a *Atlas) AddBody(of render.Sprited, size int, body Body) Slot

AddBody takes body on as of's own and hands back a Slot to chain the rest of its look on: a view in relief stands it whole near the camera and as a card of it beyond (BodyLook), a view from above draws it photographed from above, turned as it stands. Its sprite, size x size, is the body photographed from the side, and it is whole, a cutout (Slot.Cutout).

func (*Atlas) Atlas added in v0.3.0

func (a *Atlas) Atlas() *render.Image

Atlas is the baked sheet.

func (*Atlas) BodyOf added in v0.22.0

func (a *Atlas) BodyOf(of render.Sprited) *Bodied

BodyOf is the body of's kind was added with, as a Look stands it; nil without one.

func (*Atlas) Close added in v0.3.0

func (a *Atlas) Close()

Close lays the sheet out, bakes it and hands it to the world (Plugin.SetAtlas); call once, after the last look.

func (*Atlas) Looks added in v0.3.0

func (a *Atlas) Looks() *Atlas

Looks declares every figure's look on the atlas, in the order the figures were noted, and hands the atlas back to Close.

func (*Atlas) UV added in v0.3.0

func (a *Atlas) UV(id render.SpriteID) (sx0, sy0, sx1, sy1 float32)

UV is a sprite's rectangle on the sheet.

func (*Atlas) White added in v0.3.0

func (a *Atlas) White() (u, v float32)

White is the white texel plain colours sample.

type Banner struct {
	Kind   kind.ID
	Sector int
	Center geom.Vec
	IDs    []uid.UID64
	Count  int
	Box    geom.AABB
	Z      Z
	Reach  float32
}

Banner is a kind's loose units in a sector drawn as one at the strategic scale: the entities IDs, standing for Count units (an aggregate folded for its Strength), drawn over Box round their centroid, Center, at their mean Z, under a badge reaching Reach shown pixels round its middle (BadgeAt).

func (Banner) BadgeAt added in v0.20.0

func (b Banner) BadgeAt(cam camera.Camera) (x, y, reach float32)

BadgeAt is where cam shows b's badge, in its pixels: its middle and how far it reaches round it.

type BannerStyle added in v0.20.0

type BannerStyle struct {
	Shape render.BadgeShape
	Size  float32
	Fill  color.RGBA
	Rim   color.RGBA
}

BannerStyle is how a kind's banner is drawn: a badge of Shape at least Size shown pixels across, in Fill within a rim in Rim, each zero its default (a disc 14 across in the kind's far colour, its rim darker). Declared on the world's atlas (Slot.Styled), it has the kind drawn in banners at the strategic scale even without a look declared there.

func (BannerStyle) Style added in v0.20.0

func (BannerStyle) Style()

Style: a figure declares it on the world's atlas (render.Style).

type Base

type Base = entity.Base

What an entity carries, as package entity has it, under the world's own names.

type Bodied added in v0.22.0

type Bodied struct {
	Table     *render.Image
	Row       int
	Parts     int
	Wide      float32
	Tall      float32
	Views     [BodyViews]render.SpriteID
	Ways      [BodyViews]render.SpriteID
	Top       render.SpriteID
	TopWays   render.SpriteID
	Above     render.SpriteID
	Elevation float32
	Margin    float32
	TopAt     float32
	// contains filtered or unexported fields
}

Bodied is a kind's body as a Look stands it: its Row of the bodies' Table and how many Parts it has, how Wide and Tall it is, its cards and Above, it seen from straight above in the photograph's own light. A card (Card) is its paint with the ways out of it (body_shot.wgsl): Views and Ways from BodyViews sides round it, the first looking along its x and each next an eighth of a turn on towards its y, from Elevation over the level and reaching Margin under its foot and over its top, leaning back about TopAt over its foot for an eye looking steeper (body.wgsl's shapeRow); Top and TopWays from straight above, held to the eye there.

func (*Bodied) Card added in v0.22.0

func (b *Bodied) Card(way [3]float32, turn float32) (view, ways render.SpriteID, lies bool)

Card is the card of the body, turned by turn about its foot, for an eye looking at it along way: the view of its side nearest and the ways out of it there. Looking down so steeply that the one from above shows the body's parts truer, or no card stands, it is that one, which lies.

type Bodies added in v0.22.0

type Bodies struct{ Reach lod.Level }

Bodies has the kinds with a body (Atlas.AddBody) stand whole in relief out to the level Reach, the close scale's L1 to L3, cards of them beyond (Settings.BodiesShort). The settings screen alone, under Graphics.

func (Bodies) Command added in v0.22.0

func (Bodies) Command()

type BodiesLever added in v0.22.0

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

BodiesLever is the bodies' reach as the cameras' frame budget turns it (cameras.Lever, given in cameras.Config.Levers). A reach let out and drawn in again at once cost the budget: it waits a minute to be let out again, twice as long after each such try, sixteen at the most.

func (BodiesLever) Coarser added in v0.22.0

func (l BodiesLever) Coarser() bool

Coarser draws the bodies' reach in a level, the close scale the nearest, true where it could.

func (BodiesLever) Finer added in v0.22.0

func (l BodiesLever) Finer() bool

Finer lets the bodies' reach out a level, as far as the Settings say, true where it could: not while a try that cost the budget is waited out.

func (BodiesLever) Following added in v0.22.0

func (l BodiesLever) Following() bool

Following is whether the bodies' reach follows the frame budget.

type Body added in v0.22.0

type Body struct {
	Wide   float32
	Tall   float32
	Parts  []Part
	Paints []Paint
}

Body is a kind's shape: its Parts in world units off the middle of its foot, X across, Y deep and Z up, within a box Wide a side and Tall high, each in one of its Paints. A view in relief stands it whole near the camera and as a card of it further off (Atlas.AddBody).

func (Body) Check added in v0.22.0

func (b Body) Check(of string)

Check panics where the body, of's, does not hold together: no part, too many, a part of no shape or width, in no paint, or reaching past the body's box, which its cards are as wide as.

type BodyLook added in v0.22.0

type BodyLook interface {
	Look
	Body(f *render.Frame, cam camera.Camera, box plane.AABB, z Z, atlas render.AtlasSource,
		b *Bodied, turn float32, whole bool, a render.Appearance, lit render.Illumination)
}

BodyLook is a Look that stands the kinds with a body (Atlas.AddBody) in relief: whole, its parts turned about its foot by turn, radians, or as the card of the body for the way the camera looks at it (Bodied.Card).

type Calm added in v0.20.0

type Calm struct{}

Calm is the command an entity gives itself to take off the sector.Keen it carries.

func (Calm) Command added in v0.20.0

func (Calm) Command()

type Commands added in v0.3.0

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

Commands is a Stage's register of commands about effects, by name. As the first step begins a name a command says that nobody bears, or one two bear, panics.

func (*Commands) Define added in v0.3.0

func (c *Commands) Define(name string, cmd ceremony.Command)

Define registers cmd as name. A name defined twice, or a command that names nobody, panics.

func (*Commands) Lookup added in v0.3.0

func (c *Commands) Lookup(name string) (ceremony.Command, bool)

Lookup is the command defined as name, false for an unknown one.

func (*Commands) Named added in v0.3.0

func (c *Commands) Named(name string) ceremony.Command

Named is the command defined as name; an unknown name panics.

type Config

type Config struct {
	Space    SpaceCfg
	Entities EntitiesCfg
	// Heights gives the world heights: entities carry a Z, and a board stands in it. A flat world
	// (the default) is a set of planes and refuses heights where it meets them.
	Heights bool
	// Clock is how the tactical clock goes; the zero Config is tempos ½, 1, 2 and 4 in steps.
	Clock clock.Config
	// Scale is how many metres a world unit spans; zero, a board.
	Scale Scale
	// Seed is what the rules' and the plans' Chance draws from, the same after a load.
	Seed uint64
	// Sectors cuts the world into sectors ticked by level round the observers; zero, the whole
	// world at the world's pace.
	Sectors SectorsCfg
	// LOD is the world's ladder of levels, its sectors' by the scale they are seen at and how far
	// they lie; zero, Standard everywhere without end round an observer, Strategic with none. It
	// needs Sectors.
	LOD lod.Ladder
	// Far is how the loose units are drawn at the strategic scale; zero, Points.
	Far FarLook
	// Counts has the number of a kind's units in a sector drawn by them at the strategic scale.
	Counts bool
	// Sheets is where the sheets of what stands are kept between runs; zero, they are made anew
	// each run and live in memory alone.
	Sheets SheetsCfg
}

Config is the world's shape, its bounds on entities, whether it has heights and how its clock goes.

type CutoutLook added in v0.21.0

type CutoutLook interface {
	Look
	Cutout(on bool)
}

CutoutLook is a Look drawing the figures it lays next in the cutout pass while on: whole, cut at half their alpha, writing the depth, in no order (Slot.Cutout).

type Despawn added in v0.3.0

type Despawn struct{}

Despawn is the command an entity gives itself to leave the world.

func (Despawn) Command added in v0.3.0

func (Despawn) Command()

type DirectLook added in v0.3.0

type DirectLook interface {
	Look
	Begin(f *render.Frame, cam camera.Camera)
	DrawSprites(t render.Target, cam camera.Camera, u render.Uniforms)
}

DirectLook is a Look that draws the sprites itself on the GPU: readied every frame with Begin (which may ask the frame for what it reads), handed the sprites in sight through Sprite, it draws them at DrawSprites.

type EntitiesCfg

type EntitiesCfg struct {
	MaxCount int
	MinSize  uint32
	MaxSize  uint32
}

EntitiesCfg bounds how many entities the world holds and the sizes they may spawn with.

type Eye added in v0.3.0

type Eye = entity.Eye

What an entity carries, as package entity has it, under the world's own names.

type FarLook added in v0.20.0

type FarLook uint8

FarLook is how the loose units of a kind are drawn at the strategic scale: a point each, or one banner a sector where the kind declares a look of its own there.

const (
	// Points draws every unit a point of its own.
	Points FarLook = iota + 1
	// Banners draws a kind's units in a sector as one, in its look at L4, where it declares one.
	Banners
)

The FarLooks but AsConfig.

type Faster added in v0.3.0

type Faster struct{}

Faster raises the tempo of the simulation a notch. ] by default.

func (Faster) Command added in v0.3.0

func (Faster) Command()

type Field added in v0.20.0

type Field struct{ Size geom.Vec }

Field marks an aggregate standing over a field: the box of Size round its centre, each sector of it unfolding and folding apart. Its own box, within the world's sizes, is where it stands.

type Figure added in v0.3.0

type Figure interface {
	Define(w *Plugin)
	Look(a *Atlas, w *Plugin)
}

Figure is a kind of entity in one piece: what it is, defined in the Kinds section, and how it looks, declared on the world's atlas in a scene. One with states of its own is Stateful, one with roles and rules of its own Ruled; the Stage runs each part in its section.

type Fixed added in v0.20.0

type Fixed struct{}

Fixed marks a kind of entity standing for good where it was put, a bridge's deck or pier, a lantern, a ford: what the sheets of the strategic scale are photographed of.

type FoggyLook added in v0.3.0

type FoggyLook interface {
	Look
	Fog(amount float32)
}

FoggyLook is a Look turning what it lays next into the fog by amount, 0 clear to 1 all fog: how far an entity lies into the fog before a camera's sight (view.View.Fog).

type Fold added in v0.20.0

type Fold struct {
	ID    uid.UID64
	Parts int
	// Sector and Box are the stretch's, as its Unfold told them.
	Sector int
	Box    geom.AABB
}

Fold is the moment a stretch of an aggregate has lain at Strategic or coarser for the ladder's Fold seconds, once after its Unfold: the time its rules sum its Parts into it, each told a Folding.

func (Fold) Who added in v0.20.0

func (f Fold) Who() uid.UID64

Who is the aggregate folding.

type Folding added in v0.20.0

type Folding struct {
	ID, Whole uid.UID64
	// Sector and Box are the stretch's, a field's part folding with the sector holding its centre.
	Sector int
	Box    geom.AABB
}

Folding is the moment told each part of a stretch of an aggregate as it folds, the step of its Fold: the time the part's rules sum it into its Whole, the moment's subject, and despawn it.

func (Folding) Subject added in v0.20.0

func (f Folding) Subject() (uid.UID64, bool)

Subject is the aggregate folding, whom the part's steps of Other and an Aimed command are of.

func (Folding) Who added in v0.20.0

func (f Folding) Who() uid.UID64

Who is the part folded in.

type GiveWay added in v0.22.0

type GiveWay struct{ On bool }

GiveWay has what gives way (Slot.GivesWay) do so before a camera loose over the world or centred on a unit, the tactical view, or stand whole there (Settings.Covers). The settings screen alone, under Game.

func (GiveWay) Command added in v0.22.0

func (GiveWay) Command()

type GiveWayRiding added in v0.22.0

type GiveWayRiding struct{ On bool }

GiveWayRiding has what gives way do so before a camera riding a unit too, behind it or inside it, or stand whole there (Settings.GivesWayRiding). The settings screen alone, under Game.

func (GiveWayRiding) Command added in v0.22.0

func (GiveWayRiding) Command()

type GridPlacement

type GridPlacement struct {
	Width, Height uint32
	EntitySize    uint32
}

GridPlacement arranges entities on a regular grid spanning [0,Width)×[0,Height).

func NewGridPlacement

func NewGridPlacement(width, height, entitySize uint32) *GridPlacement

func (*GridPlacement) Place

func (p *GridPlacement) Place(index, count int) Position

type Keen added in v0.20.0

type Keen struct{ Level lod.Level }

Keen is the command an entity gives itself to keep its sector and the eight round it ticked at Level at most (sector.Keen) till it gives Calm: a battle its rules would see fought out unseen.

func (Keen) Command added in v0.20.0

func (Keen) Command()

type Kinds

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

Kinds is the world's register of entity kinds and tags, handed to kind.Define. Saves keep their names, so a build that defines them in another order still loads.

func (*Kinds) DefineTag added in v0.3.0

func (k *Kinds) DefineTag[F any](name string) tag.Tag[F]

DefineTag registers name in family F and returns its tag, assigned by call order within the family.

func (*Kinds) LoadComps

func (k *Kinds) LoadComps() []goke.CompToken

LoadComps lists every component type the defined kinds give their entities, each once.

func (*Kinds) Lookup added in v0.3.0

func (k *Kinds) Lookup(name string) (kind.ID, render.SpriteID, reflect.Type, bool)

Lookup is the kind registered as name.

func (*Kinds) NewSprite

func (k *Kinds) NewSprite() render.SpriteID

NewSprite reserves an atlas slot that belongs to no kind.

func (*Kinds) Persisted

func (k *Kinds) Persisted() []any

Persisted is the kinds' and the tags' names by order, for the saves.

func (*Kinds) Play added in v0.3.0

func (k *Kinds) Play(roles ...*ceremony.Part)

Play notes roles played by what is no kind of the world's, a cell's kind or a plugin.

func (*Kinds) Played added in v0.3.0

func (k *Kinds) Played() []act.Rule

Played are the roles played so far, each once.

func (*Kinds) Register

func (k *Kinds) Register(name string, row reflect.Type, spec kind.Spec) (kind.ID, render.SpriteID)

Register takes spec on as name and assigns its ID and SpriteID by call order.

func (*Kinds) SetupSystems

func (k *Kinds) SetupSystems() []goke.System

SetupSystems returns no systems.

type Layers added in v0.3.0

type Layers = entity.Layers

What an entity carries, as package entity has it, under the world's own names.

func LayersOf added in v0.3.0

func LayersOf(p *Layers) Layers

LayersOf is the Layers an entity carries, every plane for one carrying none.

type Lie added in v0.3.0

type Lie = entity.Lie

What an entity carries, as package entity has it, under the world's own names.

type Lighting added in v0.3.0

type Lighting interface {
	Join(qb *goke.QueryBuilder)
	Mark(cur *goke.Cursor, i int) render.Shadowing
}

Lighting is what the world asks of the light as it publishes its entities, a plugin's (Write.SetLighting): it joins its columns to the renderer's query and says how the row i of the chunk at cur casts its shadow and which shade it takes. The frame lights them as drawn (render.Frame.Lit, Cast).

type Look added in v0.3.0

type Look interface {
	// Sprite hands f the entity's settled Appearance for a box standing as z says, lit as lit
	// says. A billboard in relief ignores the Angle.
	Sprite(f *render.Frame, cam camera.Camera, box plane.AABB, z Z, atlas render.AtlasSource,
		a render.Appearance, lit render.Illumination)
	// Drawn is the screen quad that sprite covers, for picking.
	Drawn(cam camera.Camera, box geom.AABB, z Z) render.Corners
	// Footprint appends to dst the ground under box on screen, in pieces where it crosses a wrap
	// seam.
	Footprint(cam camera.Camera, box geom.AABB, alt float32, dst []render.Corners) []render.Corners
}

Look is how an entity lies on the screen through a camera, asked by the renderer, picking and outlines. The world's own is flat, seen from above; a view plugin puts its own in with Plugin.SetLook.

type LyingLook added in v0.3.0

type LyingLook interface {
	Look
	Lie(f *render.Frame, cam camera.Camera, box plane.AABB, z Z, atlas render.AtlasSource,
		a render.Appearance, lit render.Illumination)
	// Lay lays the sprite level at z's Altitude over the rectangle lie says, on the middle of box
	// and headed dir, and, lie being Edged, the sprite edge along both its long sides.
	Lay(f *render.Frame, cam camera.Camera, box plane.AABB, dir geom.Vec, lie Lie, z Z,
		atlas render.AtlasSource, a render.Appearance, edge render.SpriteID,
		lit render.Illumination)
}

LyingLook is a Look that lays the sprites declared Lying flat on the ground at the entity's Altitude (Lie), and those of an entity with a Lie over its rectangle (Lay).

type Met added in v0.20.0

type Met struct {
	A, B uid.UID64
}

Met is the moment two aggregates travelling the abstract graph (sector.Abstract) come to overlap, as seen from A: once a pair till they have come apart.

func (Met) Who added in v0.20.0

func (m Met) Who() uid.UID64

Who is the aggregate meeting the other.

func (Met) Whom added in v0.20.0

func (m Met) Whom(each func(uid.UID64))

Whom tells each the other one.

type Paint added in v0.22.0

type Paint struct {
	Colour color.RGBA
	Lit    color.RGBA
	Dots   color.RGBA
}

Paint is what a Part is painted in: its Colour, dotted with Lit and with Dots where it has them, specks of it catching the light and specks of what else it carries.

type Part added in v0.22.0

type Part struct {
	Shape Shape
	From  [3]float32
	To    [3]float32
	Wide  float32
	Tip   float32
	Paint int
}

Part is a piece of a Body from From to To, as its Shape says, in the Paint of that number of its Body's.

type PartOf added in v0.20.0

type PartOf struct{ Whole uid.UID64 }

PartOf is a part's aggregate, the Whole it is summed into as that folds; SpawnPart puts it on the part it spawns.

type Pause added in v0.3.0

type Pause struct{}

Pause switches the tactical pause: game time stands, the cameras and the picture go on. P and Shift+P by default.

func (Pause) Command added in v0.3.0

func (Pause) Command()

type PieceOf added in v0.20.0

type PieceOf struct{ Whole uid.UID64 }

PieceOf is a piece's handle, the Whole it stands as a piece of; SpawnWhole and SeedWhole put it on every piece they spawn.

type Plugin

type Plugin struct {
	Res Resources

	*Self
	// contains filtered or unexported fields
}

Plugin is the world a Stage makes with its World link (ctx.UseWorld); never Use your own.

func NewPlugin

func NewPlugin(cfg Config) *Plugin

NewPlugin makes the world from cfg, usable before Install.

func (*Plugin) Bodies added in v0.22.0

func (p *Plugin) Bodies() BodiesLever

Bodies is the lever of how far the kinds with a body stand whole.

func (*Plugin) Builtin

func (*Plugin) Builtin()

Builtin marks Plugin as installed by the engine itself.

func (*Plugin) Carry added in v0.3.0

func (p *Plugin) Carry(handlers ...plugin.CommandHandler) error

Carry has the world's carrier take commands to the queues of handlers.

func (*Plugin) Commands added in v0.3.0

func (p *Plugin) Commands() *Commands

Commands is this Stage's register of commands about effects, by name.

func (*Plugin) DefaultBindings added in v0.3.0

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

DefaultBindings are the clock's keys: P and Shift+P pause, ] goes faster, [ slower. The sectors drawn and their levels are the settings screen's.

func (*Plugin) EventHandler

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

EventHandler is nil: a player's bindings issue the world's commands.

func (*Plugin) Figures added in v0.3.0

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

Figures notes the figures the Stage leads through its sections, in this order: their Effects after the game's, their Rules after the game's, their Define in Kinds, and their Look as the atlas's Looks asks. Called in the Stage's Figures link.

func (*Plugin) FiguresIn added in v0.3.0

func (p *Plugin) FiguresIn(part section.Part)

FiguresIn runs the figures' part of the section: Effects, Rules or Kinds; nothing elsewhere. The Stage calls it after the game's own functions of the section.

func (*Plugin) InSection added in v0.3.0

func (p *Plugin) InSection(what string, want ...section.Part) error

InSection is an error for what defined while the Stage is in another section than those want names; nil for a Stage written by hand.

func (*Plugin) Install

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

func (*Plugin) KindTemplates added in v0.3.0

func (p *Plugin) KindTemplates(r *kind.Roster)

KindTemplates is what the world asks of the kinds a game defines: of every one it spawns, where it stands, its velocity and its effects' markers.

func (*Plugin) Kinds

func (p *Plugin) Kinds() *Kinds

Kinds is this Stage's register of entity kinds, which kind.Define registers with.

func (*Plugin) Made added in v0.3.0

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

Made are the plugins made over the world, in the order made, which the Stage uses in that order.

func (*Plugin) Name

func (p *Plugin) Name() string

func (*Plugin) NewAtlas added in v0.3.0

func (p *Plugin) NewAtlas() *Atlas

NewAtlas starts the world's atlas, for looks declared by hand; Dress is the figures' way.

func (*Plugin) Pace added in v0.3.0

func (p *Plugin) Pace(paces lod.Paces) goke.Opt

Pace is the pace of a system going as paces says in the world's sectors, an option of its query walked with goke.Query.Paced: the steps numbered by the clock, a sector k levels coarser than the finest any observer sees going paces[k] steps at once in the last of every paces[k], none at Omitted.

func (*Plugin) Populate

func (p *Plugin) Populate() error

Populate spawns every seeded entity, or none with an error on an unknown kind or a wrong row.

func (*Plugin) Queues added in v0.3.0

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

Queues are the queues of every command the world carries out.

func (*Plugin) Read added in v0.4.0

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

Read reads the world's state on worker w of the game's pool, 0 the game's own goroutine; the other workers' reads come with Install.

func (*Plugin) Restore

func (p *Plugin) Restore()

Restore takes the Settings loaded and draws as they say.

func (*Plugin) Roles added in v0.3.0

func (p *Plugin) Roles() *Roles

Roles is this Stage's register of roles, by name.

func (*Plugin) Roster added in v0.3.0

func (p *Plugin) Roster() *kind.Roster

Roster is what this world's plugins ask of the kinds a game defines.

func (*Plugin) RunPlan

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

RunPlan runs the world's tick. Call it from Stage.Update before whatever reads the world's space, after only what moves entities itself.

func (*Plugin) Serializable

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

Serializable is the world's Settings, kept whole; its entities are saved with the ECS.

func (*Plugin) Settings added in v0.3.0

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

Settings are the tempo, with more than one to choose from, where a look gives way to one uncovered whether it does in the tactical view and riding a unit (under Game), with kinds that have bodies how far those stand whole and whether that follows the frame budget and, in a world cut into sectors, what is drawn of them, whether their levels are ticked and how the loose units are drawn far off (plugin.Tunable).

func (*Plugin) Sheets added in v0.20.0

func (p *Plugin) Sheets()

Sheets has the world photograph what stands into the sheets Read.Sheet gives, for a renderer drawing them over the ground it draws; a world none asks it of spends nothing on them.

func (*Plugin) WithFog added in v0.3.0

func (p *Plugin) WithFog(c color.RGBA) *Plugin

WithFog has what lies far off fade into c where nothing else, the atmosphere, gives the fog's colour; a scene sets it as it begins.

func (*Plugin) Within added in v0.20.0

func (p *Plugin) Within(first lod.Level) goke.Opt

Within keeps a system's query to the entities in sectors of the scale beginning at first (lod.Close, Standard or Strategic), its two levels; a world of no sectors lies at Standard. A system of a scale's detail joins it with Pace(lod.Exact), going where someone looks so close.

func (*Plugin) Write added in v0.4.0

func (p *Plugin) Write() *Write

Write changes the world's state, on the game's goroutine.

type Position

type Position = entity.Position

What an entity carries, as package entity has it, under the world's own names.

type Read added in v0.4.0

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

Read reads the world's state on one goroutine at a time: Plugin.Read(w), worker w's.

func (*Read) Atlas added in v0.4.0

func (r *Read) Atlas() render.AtlasSource

Atlas is the world's looks as Write.SetAtlas took them, nil before.

func (*Read) Banded added in v0.4.0

func (r *Read) Banded() bool

Banded reports whether the sectors' levels are ticked; true in a world of no sectors.

func (*Read) Banners added in v0.20.0

func (r *Read) Banners(cam camera.Camera, dst []Banner) []Banner

Banners appends to dst the banners cam drew in the frame drawn, where the far units are drawn as Banners; their IDs are the frame's, good till the next frame is drawn.

func (*Read) Bodied added in v0.22.0

func (r *Read) Bodied() bool

Bodied reports whether any kind of the world's looks has a body (Atlas.AddBody).

func (*Read) BodiesReach added in v0.22.0

func (r *Read) BodiesReach() lod.Level

BodiesReach is the furthest level the kinds with a body stand whole at in relief, L1 to L3: as the Settings say, drawn in by the frame budget.

func (*Read) Clock added in v0.4.0

func (r *Read) Clock() *clock.Read

Clock is the world's tactical clock, which everything that simulates goes by.

func (*Read) Counts added in v0.20.0

func (r *Read) Counts() bool

Counts reports whether the number of a kind's units in a sector is drawn by them at the strategic scale: as the Settings say, else as the Config does.

func (*Read) Effects added in v0.4.0

func (r *Read) Effects() *cgoke.EffectsRead

Effects is which effects the entities are under.

func (*Read) FarLook added in v0.20.0

func (r *Read) FarLook() FarLook

FarLook is how the loose units are drawn at the strategic scale: as the Settings say, else as the Config does, else Points.

func (*Read) FlatLook added in v0.4.0

func (r *Read) FlatLook() Look

FlatLook is the world's own Look, seen from above.

func (*Read) Fork added in v0.4.0

func (r *Read) Fork() *Read

Fork reads the same state through queries of its own, for another goroutine.

func (*Read) GivesWay added in v0.22.0

func (r *Read) GivesWay(cam camera.Camera) bool

GivesWay reports whether what gives way does so before cam: loose over the world or centred on a unit unless the Settings say it covers, riding a unit only where they say.

func (*Read) GivesWayDrawn added in v0.22.0

func (r *Read) GivesWayDrawn(cam camera.Camera) bool

GivesWayDrawn is GivesWay as the frame drawn has it, for a source composing it.

func (*Read) GivingWay added in v0.22.0

func (r *Read) GivingWay() bool

GivingWay reports whether the world's looks have one kind uncovered and something gives way to it: a kind of theirs or a plugin's source (Slot.Uncovered, Slot.GivesWay, Write.GivesWay).

func (*Read) GroundAt added in v0.20.0

func (r *Read) GroundAt(at geom.Vec) float32

GroundAt is the ground's height under the world point at, as the plugin giving the ground has it (Write.SetGround); 0 in a world without one.

func (*Read) HasHeights added in v0.4.0

func (r *Read) HasHeights() bool

HasHeights reports whether this world has heights.

func (*Read) InView added in v0.5.0

func (r *Read) InView(id uid.UID64) bool

InView reports whether some camera's View holds id, as the last tick left them; with no camera, everything is.

func (*Read) LevelAt added in v0.20.0

func (r *Read) LevelAt(x, y float32) lod.Level

LevelAt is the level the sector holding the world point (x, y) is ticked at, as the last tick left it; Standard in a world of no sectors and with the levels switched off.

func (*Read) Lights added in v0.5.0

func (r *Read) Lights() *render.Lights

Lights are the lights the frame drawn is lit by, the light plugin's; nil without one, or before a frame was published.

func (*Read) Look added in v0.4.0

func (r *Read) Look() Look

Look is how the world's entities lie on the screen.

func (*Read) Painted added in v0.20.0

func (r *Read) Painted(i int) uint32

Painted is the version of the photograph of what stands in sector i now its sheet holds, something standing there, 0 for none, new as the photograph changes: for what draws, as the frame drawn holds it.

func (*Read) Picture added in v0.4.0

func (r *Read) Picture() render.Picture

Picture is everything the Stage's plugins draw, one picture for every scene showing the world; nil before the plugins have declared their looks.

func (*Read) Restills added in v0.21.0

func (r *Read) Restills() uint64

Restills is how many times what stands for good was taken anew in place (Write.Restill): whoever keeps something of the standing things between frames takes them anew as it moves.

func (*Read) Scale added in v0.4.0

func (r *Read) Scale() Scale

Scale is how many metres a world unit spans.

func (*Read) SectorOf added in v0.20.0

func (r *Read) SectorOf(x, y float32) int

SectorOf is the sector holding the world point (x, y), held to the world's edges; 0 in a world of no sectors.

func (*Read) SectorSide added in v0.20.0

func (r *Read) SectorSide() float32

SectorSide is the side of the world's square sectors, in world units; 0 in a world of no sectors.

func (*Read) Sectors added in v0.4.0

func (r *Read) Sectors() render.Reporter

Sectors is the world's part of the telemetry panel: how many sectors and entities lie at each level.

func (*Read) SectorsLen added in v0.20.0

func (r *Read) SectorsLen() int

SectorsLen is how many sectors the world is cut into; 0 in a world of no sectors.

func (*Read) SectorsShown added in v0.4.0

func (r *Read) SectorsShown() SectorsShown

SectorsShown is what is drawn of the sectors.

func (*Read) Seen added in v0.4.0

func (r *Read) Seen() render.Reporter

Seen is the world's part of the telemetry panel about the first camera made: how many sectors it sees at each level.

func (*Read) Sheet added in v0.20.0

func (r *Read) Sheet() (albedo, relief, albedoL5, reliefL5 *render.Image, perUnit float32)

Sheet is the sheets of what stands, images over the whole world from its top-left corner: at L4 the albedo, premultiplied, and the relief (the top's height a float16, its low byte in red and its high in green, its normal's x and y in blue and alpha as (n+1)/2), perUnit texels a world unit, and their halves at L5. They are nil until a renderer asks for them (Plugin.Sheets) and in a world without sectors, perUnit 0 while no sector holds a photograph of something; for what draws, as the frame drawn holds them.

func (*Read) Sight added in v0.18.0

func (r *Read) Sight(cam camera.Camera) float32

Sight is how far from its viewpoint cam sees the world, ticked and drawn: the ladder's Sight times the camera's (camera.SightOf); 0 without end.

func (*Read) Small added in v0.20.0

func (r *Read) Small() float32

Small is the longer side a thing standing for good may have and still live by its centre (Config.Sectors.Small, a quarter of a sector's side unless set); 0 in a world of no sectors.

func (*Read) Space added in v0.4.0

func (r *Read) Space() *aabbworld.SpaceRead

Space is the world's spatial index of its entities, to query.

func (*Read) Styles added in v0.4.0

func (r *Read) Styles() *render.Styles

Styles are the styles the figures declared on the world's atlas (Slot.Styled), for the plugins drawing about a kind; none before the atlas is closed.

func (*Read) Tick added in v0.4.0

func (r *Read) Tick(d time.Duration) host.Tick

Tick is the Tick a plugin hands the rules it hosts for a pass over d of the simulation.

func (*Read) Uncovered added in v0.22.0

func (r *Read) Uncovered(id render.SpriteID) bool

Uncovered reports whether the sprite id is drawn uncovered: its kind's look declares it so (Slot.Uncovered).

func (*Read) Unfolding added in v0.22.0

func (r *Read) Unfolding(stretch uid.UID64) (Unfolding, bool)

Unfolding is the stretch an Unfold of this step told of, by the id a command aimed under it was given (host.Aimed); false for any other.

func (*Read) ViewFor added in v0.4.0

func (r *Read) ViewFor(cam camera.Camera) *view.View

ViewFor is the View of what cam saw as the frame drawn was published, for what draws: nil for a camera the frame holds none of; before the first frame published, as the last tick left it. A camera's copy has its View.

func (*Read) Views added in v0.5.0

func (r *Read) Views() []*view.View

Views are the Views of every camera Write.NewView made, as the last tick left them: what publishes for a frame culls by them.

type Resources

type Resources struct {
	Config    Config
	Telemetry *Telemetry
	Settings  Settings
}

Resources is what the world publishes: its Config, its Telemetry and its Settings.

type Roles added in v0.3.0

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

Roles is a Stage's register of roles, by name. A Stage names 64 roles at most.

func (*Roles) Define added in v0.3.0

func (r *Roles) Define(name string, rules ...act.Rule)

Define registers the role called name and the rules those playing it obey. A name defined twice panics; a rule no host takes fails Init whether anybody plays the role or not.

func (*Roles) Lookup added in v0.3.0

func (r *Roles) Lookup(name string) (*ceremony.Part, bool)

Lookup is the role defined as name; false for none.

func (*Roles) Named added in v0.3.0

func (r *Roles) Named(name string) *ceremony.Part

Named is the role defined as name; an unknown name panics.

type Rule added in v0.5.0

type Rule interface {
	// contains filtered or unexported methods
}

Rule is how a renderer draws the entities it draws, settled for each of them every frame, in the order given. A rule reads one component of the entity, T, and holds only for one carrying it.

func As added in v0.5.0

func As[T any](with render.Appearance, when ...func(T) bool) Rule

As draws every entity carrying T as with, in place of its own sprite, where each of when holds.

func Over added in v0.5.0

func Over[T any](with render.Appearance, when ...func(T) bool) Rule

Over draws with on top of every entity carrying T, where each of when holds.

func Show added in v0.5.0

func Show[T any](when ...func(T) bool) Rule

Show draws every entity carrying T where each of when holds. Once a Show rule is given, a renderer draws only those some Show rule holds for.

func Swap added in v0.5.0

func Swap[T any](twins map[render.SpriteID]render.SpriteID, when ...func(T) bool) Rule

Swap draws every entity carrying T, where each of when holds, as the twin of the sprite it would be drawn with; one with no twin as it is.

func With added in v0.5.0

func With[T any](fn func(render.Appearance, T) render.Appearance, when ...func(T) bool) Rule

With reworks the sprite of every entity carrying T through fn, which sees the T it carries, where each of when holds.

type Ruled added in v0.3.0

type Ruled interface{ Rules(w *Plugin) }

Ruled is a Figure with roles and rules of its own, defined in the Rules section.

type Rules added in v0.5.0

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

Rules are the rules a renderer runs over the chunks of entities it draws.

func (*Rules) Add added in v0.5.0

func (r *Rules) Add(rules ...Rule) error

Add takes rules, run after those taken before. It is an error once the renderer is built.

func (*Rules) Bind added in v0.5.0

func (r *Rules) Bind(qb *goke.QueryBuilder)

Bind adds the components the rules read to the renderer's query. Call it once, before it is built.

func (*Rules) Run added in v0.5.0

func (r *Rules) Run(cur *goke.Cursor, layers [][]render.Appearance, shown []bool)

Run settles the chunk under cur: layers[i] begins as its i-th entity's render.Appearance and ends as what it is drawn with, shown[i] whether it is drawn; either may be nil.

type Scale added in v0.3.0

type Scale struct {
	Metres  float32
	Figures float32
}

Scale is how many Metres a world unit spans, across and up alike, and how many times bigger than life the Figures standing on it are drawn. The zero Scale leaves the world a board, flat as far as the eye goes.

func (Scale) Bend added in v0.3.0

func (s Scale) Bend() float32

Bend is how far below the level of an eye the ground d world units off lies, per d²; 0 for a flat world.

func (Scale) Drop added in v0.3.0

func (s Scale) Drop(d float32) float32

Drop is how far below the level of an eye the ground d world units off lies: Bend·d².

func (Scale) Figure added in v0.3.0

func (s Scale) Figure(m float32) float32

Figure is the size in world units of a figure m metres big in life, Units(m) times Figures.

func (Scale) Horizon added in v0.3.0

func (s Scale) Horizon(h float32) float32

Horizon is how far over level ground an eye h world units up sees it before it sinks away; +Inf for a flat world.

func (Scale) Units added in v0.3.0

func (s Scale) Units(m float32) float32

Units is m metres in world units; m itself without a scale.

type SectorsCfg added in v0.3.0

type SectorsCfg struct {
	Buckets int
	// Small is the longer side a thing standing for good may have and still live by its centre,
	// in the sector holding it; zero, a quarter of a sector's side. A longer one lives in the
	// lowest tier of sectors holding it whole (sector.Grid.Fit).
	Small float32
}

SectorsCfg is the world's sectors: Buckets of the space's buckets a side, the world cut into sectors where it is over zero.

type SectorsShown added in v0.3.0

type SectorsShown uint8

SectorsShown is what is drawn of the world's sectors over the ground.

const (
	NoSectors SectorsShown = iota
	// SectorBands colours each sector by the level it is ticked at.
	SectorBands
	// SectorsSeen colours each sector by the level the camera drawing sees it at (View.Level).
	SectorsSeen
)

type Self added in v0.3.0

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

Self is a plugin's own entity in the world, called by the plugin's name, carrying its knobs, the roles it plays and the effects it is under. A plugin embeds it, and so is whom a command may be for.

func NewSelf added in v0.3.0

func NewSelf(w *Plugin, p plugin.Plugin, knobs ...comp.Comp) *Self

NewSelf is the entity of the plugin p in w, carrying knobs, and notes p as made over w. Call it in the plugin's constructor; a second entity of one name panics.

func (*Self) Changed added in v0.3.0

func (s *Self) Changed() bool

Changed reports whether an effect changed the plugin's knobs in the step gone, the time to work anew what is costly to.

func (*Self) Entity added in v0.3.0

func (s *Self) Entity() uid.UID64

Entity is the plugin's own entity; 0 before the Stage's ECS is set up.

func (*Self) Plays added in v0.3.0

func (s *Self) Plays(roles ...*ceremony.Part)

Plays has the plugin play roles. Call it where the Stage defines its rules.

func (*Self) Route added in v0.3.0

func (s *Self) Route(c ceremony.Command) command.Command

Route is c for the plugin's entity, which the world carries out.

func (*Self) Target added in v0.3.0

func (*Self) Target()

Target marks the plugin as whom a command may be for.

type Settings added in v0.3.0

type Settings struct {
	Sectors  SectorsShown
	Unbanded bool
	Far      FarLook
	Counts   Shown
	// BodiesShort is how many levels short of L3 the bodies stand whole to at most, 2 the close
	// scale alone, and BodiesPulled how many more the frame budget has drawn them in by.
	BodiesShort  uint8
	BodiesPulled uint8
	// StillBodies has the bodies' reach stay as set, not follow the frame budget.
	StillBodies bool
	// Covers has what gives way (Slot.GivesWay) stand whole before a camera loose over the world
	// or centred on a unit, where it gives way unless this says; GivesWayRiding has it give way
	// before a camera riding a unit too, behind it or inside it.
	Covers         bool
	GivesWayRiding bool
}

Settings is what the world lets the players adjust, saved with the game: the looks of the sectors, whether their levels are ticked, how the loose units are drawn far off, how far the bodies stand whole and before which cameras what gives way does. The tempo and the pause are the clock's (clock.State).

type Shape added in v0.22.0

type Shape uint8

Shape is what a Part of a Body is.

const (
	// Spheroid is a ball squashed or drawn out along the line from a Part's From to its To, Wide
	// across in its middle: a head, a globe, a mound.
	Spheroid Shape = iota + 1
	// Cone is one cut short, Wide across at a Part's From and Tip across at its To: a post,
	// an arm, a skirt.
	Cone
)

type SheetsCfg added in v0.20.0

type SheetsCfg struct {
	// Dir is the folder of the tiles and their manifest; empty, no files.
	Dir string
	// Keep has the tiles of the sectors photographed written back to Dir; false, Dir only read.
	Keep bool
	// Version is the game's word for how it plants its fields: tiles written under another are
	// ignored, so a game changes it as it changes its rules of planting.
	Version string
}

SheetsCfg is the files of the sheets of what stands: tiles of them read as the game starts, so a sector photographed in an earlier run is not photographed again unless what stands in it has changed.

type ShowCounts added in v0.20.0

type ShowCounts struct{ On bool }

ShowCounts has the number of a kind's units in a sector drawn by them at the strategic scale, or not (Settings.Counts). The settings screen alone, in a world cut into sectors.

func (ShowCounts) Command added in v0.20.0

func (ShowCounts) Command()

type ShowFar added in v0.20.0

type ShowFar struct{ Look FarLook }

ShowFar has the loose units drawn at the strategic scale as Look says (Settings.Far), AsConfig as the Config does. The settings screen alone, in a world cut into sectors.

func (ShowFar) Command added in v0.20.0

func (ShowFar) Command()

type Shown added in v0.20.0

type Shown uint8

Shown is whether a setting has something drawn, or AsConfig.

const (
	On Shown = iota + 1
	Off
)

The Showns but AsConfig.

type Slot added in v0.3.0

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

Slot is one sprite added to the world's Atlas, which the rest of its look chains on.

func (Slot) Above added in v0.22.0

func (s Slot) Above(level lod.Level) Slot

Above has the kind's look from level on to the next level declared be its body photographed from straight above, as the sheets take it, in place of every look it has under its effects, ways and frames; a kind without a body panics.

func (Slot) Always added in v0.19.0

func (s Slot) Always() Slot

Always has the kind never thinned by the world's lod.Ladder.Keep: a camera publishes every one of its entities at every level it draws them at.

func (Slot) Animated added in v0.3.0

func (s Slot) Animated[D frameDrawer](n int, period time.Duration, draw D) Slot

Animated adds the sprite's n frames, each shown period of game time in turn, drawn by draw for its frame: after Facing, for each way the sprite looks, a draw taking the angle drawing each way its own. Facing comes first.

func (Slot) At added in v0.18.0

func (s Slot) At[L render.Look](level lod.Level, look L) Slot

At has the kind drawn in look from level on to the next level declared, a close one to Standard at most, in place of every look it has under its effects, ways and frames: a SpriteDrawer drawn into the sheet at its size or a MaterialID worked out per pixel.

func (Slot) Cutout added in v0.21.0

func (s Slot) Cutout() Slot

Cutout has the sprite drawn in the cutout pass where its look is whole: cut at half its alpha, writing the depth, in no order, so what stands behind it or under it is hidden by the depth (render.Cutout). Its looks under effects, its frames and its twins too.

func (Slot) Edges added in v0.3.0

func (s Slot) Edges(draw render.SpriteDrawer) Slot

Edges adds the sprite standing along the long sides of a lying one while its entity's Lie is Edged. Author it seen from the side, its length along x and its height along y, filling its square.

func (Slot) Facing added in v0.3.0

func (s Slot) Facing(n int, draw func(angleDeg float64) render.SpriteDrawer) Slot

Facing adds the sprite's n directional twins, east first against the clock, each drawn by draw at its angle in degrees. Animated frames and looks under effects drawn with the angle follow it; the rest keep their own look whichever way it goes.

func (Slot) GivesWay added in v0.22.0

func (s Slot) GivesWay() Slot

GivesWay has the sprite give way to the entities uncovered (Uncovered), before the cameras the world's settings say (Read.GivesWay), laid by a look that draws it so (UncoveringLook). Its looks under effects, its frames and its twins too.

func (Slot) Lying added in v0.3.0

func (s Slot) Lying() Slot

Lying has the sprite laid flat on the ground at its entity's Altitude where a view in relief stands the rest up. Its looks under effects, its frames and its twins lie too.

func (Slot) Nothing added in v0.18.0

func (s Slot) Nothing(level lod.Level) Slot

Nothing has the kind drawn at no level from level on to the next level declared, a close one to Standard at most.

func (Slot) Styled added in v0.3.0

func (s Slot) Styled(st render.Style) Slot

Styled declares how a plugin draws about the kind: its outline, its cone, its route (selection.Highlight, vision.Cone, navigation.RouteStyle), read off the world's Styles.

func (Slot) Swaying added in v0.22.0

func (s Slot) Swaying(amount float32) Slot

Swaying has the sprite's entity sway by amount, 0 to 1, where no effect has turned its render.Appearance's Sway: as far as the look laying it leans what sways. Its looks under effects, its frames and its twins too.

func (Slot) Turning added in v0.3.0

func (s Slot) Turning() Slot

Turning has the sprite drawn turned the way its entity is headed. Author it facing east, its content within the circle inscribed in its square box.

func (Slot) Uncovered added in v0.22.0

func (s Slot) Uncovered() Slot

Uncovered has the sprite's entity uncovered: a sprite giving way (GivesWay) is left out in part where it lies over it, so it shows through (render.Sprites.Uncover). Its looks under effects, its frames and its twins too.

func (Slot) Under added in v0.3.0

func (s Slot) Under[L render.Look](e effect.Effect, look L) Slot

Under adds the sprite's look under the effect e, the same size, drawn in its place while the effect's marker is on. A render.Phases spreads its frames along the effect's course, which must Last, a render.Loops shows them round and round by the clock; one drawing each frame at an angle (PhasedFacing, LoopedFacing) draws it every way the sprite faces. A material under an effect reads how far it has run as its fraction. Under two effects at once the entity is drawn by the look of the effect looked under later, in any kind.

func (Slot) Upright added in v0.3.0

func (s Slot) Upright() Slot

Upright has the sprite stand true on the four sides and the top of its entity's box where a view in relief stands the rest up as billboards. Its looks under effects, its frames and its twins stand so too.

func (Slot) WhileMoving added in v0.3.0

func (s Slot) WhileMoving() Slot

WhileMoving has the sprite's Animated frames go only while its entity moves; standing it is drawn as it faces. Animated comes first.

type Slower added in v0.3.0

type Slower struct{}

Slower lowers the tempo of the simulation a notch. [ by default.

func (Slower) Command added in v0.3.0

func (Slower) Command()

type SpaceCfg

type SpaceCfg struct {
	Width, Height uint32
	Edges         aabbworld.Edges
}

type Spawn added in v0.3.0

type Spawn struct{ Entry kind.Entry }

Spawn is the command to add an entity of a kind to the running world, carried out at the next step of the simulation. One refused (an unknown kind, a wrong row, a full world, a bad size, a box wholly past an open edge) is logged, never a panic.

func (Spawn) Command added in v0.3.0

func (Spawn) Command()

type SpawnPart added in v0.20.0

type SpawnPart struct {
	Entry kind.Entry
	// At is where the part's row's box is laid from, off that centre: zero at it.
	At geom.Vec
	// contains filtered or unexported fields
}

SpawnPart is the command an aggregate gives itself to spawn, at the next step, a part of it carrying PartOf it, the Entry's entity laid At off the centre of the stretch its Unfold tells of, or of the aggregate given under none. One refused, given by no aggregate or as a Spawn is, is logged.

func SpawnPartIn added in v0.22.0

func SpawnPartIn(stretch uid.UID64, e kind.Entry, at geom.Vec) SpawnPart

SpawnPartIn is a SpawnPart aimed at the stretch an Unfold told of (Read.Unfolding), for a plugin to give in the aggregate's name the parts a rule cannot count: the Entry's entity laid At off the stretch's centre.

func (*SpawnPart) Aim added in v0.20.0

func (s *SpawnPart) Aim(who uid.UID64)

Aim tells the command the stretch of the aggregate it lies in.

func (SpawnPart) Command added in v0.20.0

func (SpawnPart) Command()

type SpawnWhole added in v0.20.0

type SpawnWhole struct {
	Whole  kind.Entry
	Pieces []kind.Entry
}

SpawnWhole is the command to add a thing standing in pieces to the running world at the next step: the Whole's handle and every piece, each carrying PieceOf it. One refused (a handle whose kind carries no Whole, an entry refused as a Spawn is, or no room for them all) spawns none of them and is logged; a handle's box joins its pieces', bounded by no Entities.MaxSize.

func (SpawnWhole) Command added in v0.20.0

func (SpawnWhole) Command()

type Stand added in v0.22.0

type Stand = entity.Stand

What an entity carries, as package entity has it, under the world's own names.

type Stateful added in v0.3.0

type Stateful interface{ Effects(w *Plugin) }

Stateful is a Figure with effects of its own, defined in the Effects section.

type SwitchBands added in v0.3.0

type SwitchBands struct{ On bool }

SwitchBands switches the sectors' levels on, or off with every sector ticked at Standard (Settings.Unbanded): a way of weighing what the levels spare. The settings screen alone, in a world cut into sectors.

func (SwitchBands) Command added in v0.3.0

func (SwitchBands) Command()

type SwitchSectors added in v0.3.0

type SwitchSectors struct{ Shown SectorsShown }

SwitchSectors has Shown drawn of the sectors (Settings.Sectors): the levels they are ticked at, the levels the camera sees them at, nothing. The settings screen alone, in a world cut into sectors.

func (SwitchSectors) Command added in v0.3.0

func (SwitchSectors) Command()

type Telemetry

type Telemetry struct {
	Count int
}

type Tempo added in v0.3.0

type Tempo struct{ X float32 }

Tempo sets the tempo of the simulation to the clock's nearest X (clock.Config.Tempos).

func (Tempo) Command added in v0.3.0

func (Tempo) Command()

type UncoveringLook added in v0.22.0

type UncoveringLook interface {
	Look
	Uncover(on bool)
	GiveWay(on bool)
	Uncovers() bool
	GivesWay() bool
}

UncoveringLook is a Look that has the figures it lays next uncovered, and give way to those uncovered, while on (Slot.Uncovered, Slot.GivesWay; render.Target.Uncovered). Uncovers and GivesWay report whether it has laid either since it began: where something gives way to what is uncovered, its frame draws that first.

type Unfold added in v0.20.0

type Unfold struct {
	ID uid.UID64
	At geom.Vec
	// Sector is the stretch's sector, a point aggregate's the one holding its centre.
	Sector int
	// Box is the aggregate within that sector: a field's part there, a point aggregate's own box.
	Box geom.AABB
	// contains filtered or unexported fields
}

Unfold is the moment a stretch of an aggregate comes down finer than Strategic, once as it comes: the time its rules spawn the parts lying there (SpawnPart), a point aggregate's round At, its centre. It is told also as a preview, of a field's stretch a sheet draws holding none of its parts: the parts its rules give there are photographed into the sheet, none spawned.

func (Unfold) Subject added in v0.20.0

func (u Unfold) Subject() (uid.UID64, bool)

Subject is the stretch unfolding, which a SpawnPart given under it is aimed at to lie there.

func (Unfold) Who added in v0.20.0

func (u Unfold) Who() uid.UID64

Who is the aggregate unfolding.

type Unfolded added in v0.20.0

type Unfolded struct{}

Unfolded marks an aggregate some stretch of which is unfolded, from its first Unfold to its last Fold: its parts stand for it there, and it is neither drawn nor moved for itself, a point aggregate kept by the world at the middle of its parts.

type Unfolding added in v0.22.0

type Unfolding struct {
	Whole   uid.UID64
	Sector  int
	Box     geom.AABB
	Preview bool
}

Unfolding is the stretch of an aggregate the step's Unfold told of as its subject: whose it is, its sector and its box there, and whether it is a preview for the sheets, spawning nothing.

type Unseen added in v0.22.0

type Unseen struct{}

Unseen marks a kind none of the world's looks draw, its sprite left undeclared: what its plugin draws by a source of its own, a tunnel's piece under the ground.

type UprightLook added in v0.3.0

type UprightLook interface {
	Look
	Upright(f *render.Frame, cam camera.Camera, box plane.AABB, z Z, atlas render.AtlasSource,
		a render.Appearance, lit render.Illumination)
}

UprightLook is a Look that stands the sprites declared Upright true on the four sides and the top of their box, where a view in relief stands the rest up as billboards.

type Velocity

type Velocity = entity.Velocity

What an entity carries, as package entity has it, under the world's own names.

type Whole added in v0.20.0

type Whole struct{}

Whole marks the kind of the handle of a thing standing in pieces, a bridge or a wall: the handle carries what is the whole's (its joint box as its Position, its Z, a Lie where it lies along, its Shadow) and no sprite, and its pieces go as it goes.

type Write added in v0.4.0

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

Write changes the world's state, on the game's goroutine.

func (*Write) AdaptBodies added in v0.22.0

func (w *Write) AdaptBodies(on bool)

AdaptBodies has the bodies' reach follow the cameras' frame budget, or stay as set (AdaptBodies, Settings.StillBodies).

func (*Write) Carrier added in v0.4.0

func (w *Write) Carrier() *command.Carrier

Carrier is the Stage's one carrier of commands, taking each to its handler's queue.

func (*Write) Clock added in v0.4.0

func (w *Write) Clock() *clock.Clock

Clock is the world's tactical clock, to hand what simulates and to drive.

func (*Write) Despawn added in v0.4.0

func (w *Write) Despawn(cb *goke.CmdBuf, id uid.UID64)

Despawn takes an entity out of the ECS at the end of the tick, a Whole's handle with its pieces.

func (*Write) Effects added in v0.4.0

func (w *Write) Effects() *cgoke.Effects

Effects is this Stage's register of effects, which last in the clock's time, to cast and dispel.

func (*Write) GiveWay added in v0.22.0

func (w *Write) GiveWay(on bool)

GiveWay has what gives way do so before a camera loose over the world or centred on a unit, or stand whole there (GiveWay, Settings.Covers).

func (*Write) GiveWayRiding added in v0.22.0

func (w *Write) GiveWayRiding(on bool)

GiveWayRiding has what gives way do so before a camera riding a unit too, or stand whole there (GiveWayRiding, Settings.GivesWayRiding).

func (*Write) GivesWay added in v0.22.0

func (w *Write) GivesWay()

GivesWay has the world lay what its looks declare uncovered for a plugin's source giving way to it (render.Target.Uncovered), as for a kind of its own that does (Slot.GivesWay), and before the cameras its settings say (Read.GivesWay).

func (*Write) NewView added in v0.4.0

func (w *Write) NewView(cam camera.Camera) *view.View

NewView makes the View of what cam sees, kept current from the next tick on; the one made before for cam.

func (*Write) Observe added in v0.18.0

func (w *Write) Observe(o sector.Observers)

Observe has the world live round the cameras o gives: each sector is ticked at the fullest level one of them sees it at (Config.LOD).

func (*Write) Restill added in v0.20.0

func (w *Write) Restill()

Restill has what stands for good taken anew once something of it changed in place, a Caps, an Altitude or a look: the space's still layer, the sheets' signatures of the sectors and the shadows baked hold what stands as they found it when it came or went, and the frames between pay nothing for it.

func (*Write) Seed added in v0.4.0

func (w *Write) Seed(entries ...kind.Entry)

Seed adds entries to the entities spawned when this Stage starts fresh.

Example
package main

import (
	"github.com/kjkrol/ceremony/comp"
	"github.com/kjkrol/gram/entity/kind"
	"github.com/kjkrol/gram/plugins/world"
)

func main() {
	plugin := world.NewPlugin(world.Config{
		Space:    world.SpaceCfg{Width: 800, Height: 600},
		Entities: world.EntitiesCfg{MaxCount: 10, MinSize: 8, MaxSize: 8},
	})
	placement := world.NewGridPlacement(800, 600, 8)

	kind.Define[world.Position](plugin.Kinds(), "dot", kind.Spec{
		comp.Load(func(p world.Position) world.Position { return p }),
		comp.Const(world.Velocity{}),
	})
	dot := kind.Named[world.Position](plugin.Kinds(), "dot")

	for i := range 10 {
		plugin.Write().Seed(dot.Entry(placement.Place(i, 10)))
	}

	if err := plugin.Populate(); err != nil {
		panic(err)
	}
}

func (*Write) SeedWhole added in v0.20.0

func (w *Write) SeedWhole(whole kind.Entry, pieces ...kind.Entry)

SeedWhole adds a thing standing in pieces to the entities spawned when this Stage starts fresh: whole's handle and every piece, each carrying PieceOf it (SpawnWhole).

func (*Write) SetAtlas added in v0.4.0

func (w *Write) SetAtlas(atlas render.AtlasSource)

SetAtlas takes atlas as the world's looks for the entity renderer, applying what a *Atlas declared; its Close calls it. A foreign render.AtlasSource is given by hand.

func (*Write) SetBanded added in v0.4.0

func (w *Write) SetBanded(on bool)

SetBanded switches the sectors' levels on, or off with every sector ticked at Standard (SwitchBands, Settings.Unbanded); the cameras draw by their levels either way.

func (*Write) SetBodies added in v0.22.0

func (w *Write) SetBodies(reach lod.Level)

SetBodies has the bodies stand whole out to the level reach, L1 to L3, whatever the frame budget had drawn them in by (Bodies, Settings.BodiesShort).

func (*Write) SetGround added in v0.20.0

func (w *Write) SetGround(ground func(at geom.Vec) float32)

SetGround has the ground's height under a world point read off ground (Read.GroundAt), the plugin's laying the ground in relief.

func (*Write) SetLighting added in v0.4.0

func (w *Write) SetLighting(l Lighting)

SetLighting has the world's entities marked by l as they are published, the light plugin's. Before Install.

func (*Write) SetLights added in v0.5.0

func (w *Write) SetLights(lights func() *render.Lights)

SetLights has the world's picture lit by the lights lights gives (render.Composer.Light), the light plugin's; without them it is drawn in white light. Before Install.

func (*Write) SetLook added in v0.4.0

func (w *Write) SetLook(look Look)

SetLook has the world's entities drawn, picked and outlined by look, a view plugin's.

func (*Write) ShowCounts added in v0.20.0

func (w *Write) ShowCounts(on bool)

ShowCounts has the number of a kind's units in a sector drawn by them at the strategic scale, or not (ShowCounts, Settings.Counts).

func (*Write) ShowFar added in v0.20.0

func (w *Write) ShowFar(look FarLook)

ShowFar has the loose units drawn at the strategic scale as look says (ShowFar, Settings.Far), AsConfig as the Config does.

func (*Write) ShowSectors added in v0.4.0

func (w *Write) ShowSectors(shown SectorsShown)

ShowSectors has the sectors drawn as shown says (Settings.Sectors): a look for finding out what lives and what is seen where.

func (*Write) Space added in v0.4.0

func (w *Write) Space() *aabbworld.Space

Space is the world's spatial index of its entities, indexed again as they spawn, go and move.

func (*Write) Spawn added in v0.4.0

func (w *Write) Spawn(entries ...kind.Entry)

Spawn gives the command Spawn for each entry as command.Nobody.

func (*Write) SpawnWhole added in v0.20.0

func (w *Write) SpawnWhole(whole kind.Entry, pieces ...kind.Entry)

SpawnWhole gives the command SpawnWhole for whole's handle and its pieces as command.Nobody.

type Z added in v0.3.0

type Z = entity.Z

What an entity carries, as package entity has it, under the world's own names.

Directories

Path Synopsis
internal
kinds
Package kinds is the world's register of kinds and tags, the names a save keeps and the remapping of a load to this build's order.
Package kinds is the world's register of kinds and tags, the names a save keeps and the remapping of a load to this build's order.
look
Package look is the world's own look: seen from above, each entity's sprite over its box.
Package look is the world's own look: seen from above, each entity's sprite over its box.
sectorview
Package sectorview lays the world's sectors over the ground a frame drew, on the GPU, each in its colour (Ground), lying at the ground's depth, under what stands on it.
Package sectorview lays the world's sectors over the ground a frame drew, on the GPU, each in its colour (Ground), lying at the ground's depth, under what stands on it.
Package sector is the world cut into sectors and the levels they are ticked at round the observers, the cameras the players look through.
Package sector is the world cut into sectors and the levels they are ticked at round the observers, the cameras the players look through.
Package view is what one pair of eyes sees of a world.
Package view is what one pair of eyes sees of a world.

Jump to

Keyboard shortcuts

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