Documentation
¶
Overview ¶
Package entity is what every entity of a world carries: its Base (where it is, Position; how it moves, Velocity; its kind and what the space may do with it), its planes (Layers), in a world with heights its place in height (Z), where it looks from (Eye), the Drift it is carried at under gravity, how it lies flat (Lie) and how it casts its shadow ([Shadow]). No entity moves further in a tick than StepReach of its own shorter side.
Names and groups ¶
An entity may be called something: its [Label] holds a name, its alone, and a group it is in with others. A command says whom it is for with a [Whom]: [Named], the entities bearing those names, [Group], all those in the groups, [ID], the entities of those identifiers, or [World], the world's own entity.
The package is gram's core, imported by no plugin it needs; the world re-exports its components, so a game and the plugins say world.Base, world.Position and kin.
Index ¶
Constants ¶
const StepReach = 0.5
StepReach is how far an entity may travel in one tick, as a share of its own shorter side. Half a body keeps two entities from ever crossing centres unseen.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Base ¶
Base is what every entity in the world is made of: where it is, how it moves, which kind it was spawned from and what the space may do with it.
type Drift ¶
type Drift struct{ X, Y, Z float32 }
Drift is the velocity an entity is carried at beyond its walk (falling, thrown), in world units a second: X and Y along the ground, Z its rise. Gravity writes it.
type Eye ¶
type Eye struct{ Height, Angle, Vertical, Tilt float32 }
Eye is where an entity looks from and how wide: Height above its bottom (Z.Altitude), zero its top; Angle the whole field of view across, radians; Vertical the field up and down, radians, zero every height; Tilt how far the eye is turned up, radians, down negative, which Vertical alone limits (a rider's camera writes it).
type Layers ¶
type Layers uint8
Layers is the planes an entity is on, one bit each: two entities meet only where they share a bit, and one without Layers, or with none set, is on every plane. Collision and sight read it.
type Lie ¶
Lie is how an entity lying flat lies: a rectangle Length along its heading (Velocity.Dir) and Width across, its middle Ahead of its box's, with edges Edge high along its long sides while Edged. Zero, it lies over its box.
type Position ¶
Position is an entity's world-space rectangle.
type Stand ¶ added in v0.22.0
type Stand struct{ Length, Width float32 }
Stand is the rectangle a thing standing turned covers on the ground: Length along its heading (Velocity.Dir) and Width across, round the middle of its box. Zero, it stands over its box.
type Velocity ¶
Velocity is an entity's heading (Dir, a unit vector, zero when stationary), speed (Value, world units a second; under zero it backs away, still facing Dir) and Side, its speed across Dir, to its right (the screen's y down) over zero: a strafe, still facing Dir.
func (Velocity) Delta ¶
Delta returns Velocity's current per-axis rate: Dir scaled by Value, and Side across it.
type Z ¶
type Z struct{ Altitude, Height, Step float32 }
Z is an entity's place in height: Altitude its bottom, Height its rise above that, Step how high it steps up without a leap (0: a quarter of its Height). Only a world with heights carries it; one with no Height spans every height.