unit

package
v0.22.1 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: MIT Imports: 8 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 unit is an entity on a board: the cell it is At, how it moves over the cells and what it weighs (a Mover) and where it stands at a step as a rule gets it (Standing, with its Heading, so a rule's board.Ahead(n) turns to the cells in front of it; its words Fallen where its domain may not be, StandingOn a cell under an effect, OnKind a cell of a kind). Entered and Airborne are markers of the board's States every unit carries: on for the step a unit came into another cell, and while it is in the air.

Footprint is how many cells a side a unit's box takes, past a cell holding it with room to spare (an even side rounded up to an odd one on a hex grid); Place is where the unit stands on the footprint laid from a cell, LaidFrom that cell's point from where it stands.

Vocabulary

Moments, for a role's rules: Standing (every unit a step; places board.Around and board.Ahead; its words Fallen, StandingOn, OnKind).

Index

Constants

View Source
const Airborne tag.Tag[States] = 1

Airborne is on while a unit is in the air, put on and off by whoever carries it there (plugins/gravity). A unit in the air has not fallen in where it is over.

View Source
const AirborneName = "unit.airborne"

AirborneName is the name Airborne is defined under, as the saves know it.

View Source
const Entered tag.Tag[States] = 0

Entered is on for the step a unit's At changed: put on by whoever moves it into another cell, taken off by the board as its next pass begins.

View Source
const EnteredName = "unit.entered"

EnteredName is the name Entered is defined under, as the saves know it.

Variables

This section is empty.

Functions

func DomainAt

func DomainAt(movers []Mover, i int) cell.Domain

DomainAt is the domain of the i-th entity of a chunk whose Mover column may be absent.

func Fallen

func Fallen() cond.Word[Standing]

Fallen is the word of a unit that has fallen in where its domain may not be: a hole, water on foot — with its feet down at the cell's ground, never in the air over it nor on a deck over it.

func Footprint added in v0.14.0

func Footprint(g grid.Grid, size geom.Vec) int

Footprint is how many cells a side the box of size of a unit on g takes: one for a box no bigger than a cell; past it the fewest, two at least, whose side holds its longer side with room to spare, slack for collision. On a grid no direction of which leaves through a corner, a hex one, an even side has no window and is rounded up to an odd one.

func LaidFrom added in v0.14.0

func LaidFrom(g grid.Grid, size, p geom.Vec) geom.Vec

LaidFrom is a point of the cell the footprint of a unit is laid from, its box of size and its middle at p: p back by its Offset.

func Offset added in v0.14.0

func Offset(g grid.Grid, cells int) geom.Vec

Offset is how far off the middle of the cell its footprint is laid from a unit of a footprint cells a side stands: half a cell right and down for an even side, on the corner its middle cells share; none for an odd one, whose footprint is laid round its cell.

func OnKind

func OnKind(k cell.Kind) cond.Word[Standing]

OnKind is the word of a unit standing on a cell of the kind k.

func Place added in v0.14.0

func Place(g grid.Grid, size geom.Vec, c cell.ID) geom.Vec

Place is where the middle of a unit of a box of size stands with its footprint laid from c: off c's middle by its Offset, a place to spawn it at.

func StandingOn

func StandingOn(e effect.Effect) cond.Word[Standing]

StandingOn is the word of a unit standing on a cell under the effect e: the ground's state, whatever its kind.

Types

type At

type At struct{ Cell, Next cell.ID }

At is the cell an entity on the board stands in, kept by whoever moves it, and Next the cell it steps into next, set by whoever leads it: its own cell for a step within it, 0 while nobody leads it.

type Mover

type Mover struct {
	Domain    cell.Domain
	Lift      float32
	Clearance float32
	Ceiling   float32
	// Weight is how heavy it is in kg, for the floors it stands on (cell.Floor.Load); 0 any bears.
	Weight float32
}

Mover says which domains an entity moves in and how far above the ground it keeps (Lift), the least it keeps over it (Clearance) and the highest over sea level it climbs to (Ceiling; 0 none). An entity on the board without one moves on Land.

type Standing

type Standing struct {
	ID       uid.UID64
	Cell     cell.ID
	Kind     cell.Kind
	States   tag.Tags[effect.States] // the effects on the cell now: frozen over, snowed under
	Box      geom.AABB
	Heading  geom.Vec // the way the unit faces (Vel.Dir), standing or not; zero facing nowhere
	Domain   cell.Domain
	Airborne bool    // in the air over the cell, not on it
	Feet     float32 // where its feet stand; -Inf for one carrying no Z
	Level    float32 // the cell's ground, under its decks
	Reach    float32 // how high it steps
}

Standing is where an entity on the board stands this tick: the cell under its centre, its kind and the effects on it, the entity's box and the domains it moves in (Land without a Mover).

func (Standing) Who

func (s Standing) Who() uid.UID64

Who is the entity standing: whose moment it is, for a rule.

type States

type States struct{}

States is the family of a unit's markers on the board: states switched by a bit, never by a component put on or taken off. The board gives it to every unit the world's roster makes.

Jump to

Keyboard shortcuts

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