motion

package
v0.24.1 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 21 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 motion moves the world's entities: every step it steers them, runs the rules of a Moving over them, moves each by its velocity, never further than Position.MaxStep, and deals with those gone past an open edge. A world without it keeps its entities where they stand.

Plugin

Plugin is made over the world (NewPlugin) before what steers or pushes the entities, which takes it as it is made (collision, bullet, driving, navigation, gravity; a board's units, board.Plugin.WithMotion); its Plugin.RunPlan is called right after the world's. Its sub-package steering is how an entity is steered: a heading and a speed reached gradually. Steering and movement go slowing with a sector's distance in levels from the finest any observer sees (lod.Slowing): full pace where the viewer looks most closely.

Units and Drift

UnitTemplate is the template of the kinds that move, under the world's entity template: the plugins ask of it what every unit carries, motion a steering.Course. Drift is a velocity an entity is carried at beside its own, which gravity writes.

Leaving

An entity wholly past an open edge carries Outside; the rules of a Leaving hear of it every tick, and with none it is despawned. A plugin moving entities itself marks one it put out with Write.Leave.

Vocabulary

Moments, for a role's rules: Moving (every entity before it moves; its words Still, Braking), Leaving (every tick an entity is past an open edge). Knobs, for an effect's Alter: steering.Steering. Commands, an entity's own: steering.Away, steering.Toward, steering.Turn.

Index

Constants

This section is empty.

Variables

View Source
var UnitTemplate = kind.NewTemplate("unit", world.EntityTemplate)

UnitTemplate is the template of the kinds that move, steered, a world's entity besides.

Functions

func Braking

func Braking() cond.Word[Moving]

Braking is the word of an entity slowing down: still going, its course asking for less speed than it has.

func Still

func Still() cond.Word[Moving]

Still is the word of an entity that neither walks nor strafes this step.

Types

type Drift

type Drift = entity.Drift

Drift is the velocity an entity is carried at beyond its walk (falling, thrown), as package entity has it.

type Leaving

type Leaving struct {
	ID   uid.UID64
	Base *world.Base
}

Leaving is the moment of an entity carrying Outside, every tick it does. With no rule of it motion despawns the leaver.

func (Leaving) Who

func (l Leaving) Who() uid.UID64

Who is the entity leaving.

type Moving

type Moving struct {
	ID     uid.UID64
	Base   *world.Base
	Course *steering.Course
}

Moving is the moment of every entity in the velocity pass, every step: a rule of it scales Base.Vel.Value to slow or stop the entity. Course is the steering's, nil for an entity with none.

func (Moving) Who

func (m Moving) Who() uid.UID64

Who is the entity moving.

type Outside

type Outside struct{}

Outside marks an entity wholly past an open edge, taken off once it is back inside.

type Plugin

type Plugin struct {
	*world.Self
	// contains filtered or unexported fields
}

Plugin moves the world's entities: it steers them, moves each by its velocity and deals with those gone past an open edge.

func NewPlugin

func NewPlugin(w *world.Plugin) *Plugin

NewPlugin builds motion over the entities of the world w.

func (*Plugin) DefaultBindings

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

DefaultBindings is nil: an entity steers itself in its rules.

func (*Plugin) EventHandler

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

EventHandler is nil: motion reads no input.

func (*Plugin) Install

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

func (*Plugin) KindTemplates

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

KindTemplates is what motion asks of the kinds a game defines: every unit a course its steering keeps.

func (*Plugin) Name

func (p *Plugin) Name() string

func (*Plugin) Queues

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

Queues are the queues of the steering's commands, an entity's own (steering.Away, Toward, Turn).

func (*Plugin) RunPlan

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

RunPlan steers and moves the entities and deals with the leavers; call it right after the world's RunPlan.

func (*Plugin) Serializable

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

Serializable is nil: motion keeps no state beside its components.

func (*Plugin) Write added in v0.4.0

func (p *Plugin) Write() *Write

Write changes what motion moves, on the game's goroutine.

type Write added in v0.4.0

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

Write changes what motion moves, on the game's goroutine.

func (*Write) Leave added in v0.4.0

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

Leave marks the entity id as gone past an open edge, a leaver from the next step on; a plugin moving entities itself calls it.

Directories

Path Synopsis
internal
motiontest
Package motiontest is what motion's tests share: an installer and a world with motion, stepped as a game steps it.
Package motiontest is what motion's tests share: an installer and a world with motion, stepped as a game steps it.
Package steering turns what an entity wants into motion, gradually.
Package steering turns what an entity wants into motion, gradually.

Jump to

Keyboard shortcuts

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