Documentation
¶
Overview ¶
Package driving drives units by hand: a player's keys, or an entity's own commands, walk, turn, strafe, brake and back a unit away, leap, and fly one that flies.
Commands and the hand ¶
Ahead walks the units on the way each faces (Sprint urging them on), Back brakes them and backs them away, Turn turns them, Strafe walks them across the way they face, facing on, Toward walks them the way of the screen, Jump has them leap (JumpKey binds it). Each is given every tick its key is held, and a tick's commands add up into a hand. A player's hand, through the camera its commands name, is on the unit that camera is fastened to, else on the units the player has selected and owns; an entity's command for itself (act.Self.Do) is its own hand. The hand is written into the unit's steering.Driven and the unit marked Driving; asked to go more than 45 degrees off its way, a walking unit brakes first and turns, then walks; a tick with no hand on it brakes it, and it is let go once it stands. With Plugin.WithTap a key held no longer than that on a standing unit only turns it the way of the key; held longer, it walks.
Keys ¶
Tank are four keys driving the unit as one sits in it (Left and Right turn), Shooter four driving it as a shooter does (Left and Right strafe, the mouse turns) and Compass four walking it the way of the screen; each holds in the fastenings of the camera it says (In), so the same keys may pan a free camera and drive a ridden unit. DefaultKeys, the plugin's DefaultBindings, are a Shooter of W, S, A and D inside the unit, a Compass of them behind it (the way the screen lies, as the camera turns it: camera.Headed), a Tank of the arrows behind it, and Space to jump inside and behind; a split screen gives each player its own Compass.
Ground and navigation ¶
Given a board (Plugin.WithGround) a driven unit never walks onto ground its domain may not stand on nor takes a step the board's mobility refuses (a slope too steep for it), and its cell and its hold on the occupancy follow it; beyond that one under gravity is held back by physics alone. A plugin that keeps units apart hands the driving its Keeping (Plugin.WithKeeping, as navigation does): whether a unit may walk on into the cell ahead, and whether something else steers it, which the driving leaves be with no hand on it.
Vocabulary ¶
Commands, a player's through its camera or an entity's own: Ahead, Back, Turn, Strafe, Toward, Jump. It writes the knob steering.Driven and the marker Driving.
Index ¶
- Constants
- func JumpKey(key control.Key) control.Binding
- type Ahead
- type Back
- type Compass
- type Jump
- type Keeping
- type Keys
- type Plugin
- func (p *Plugin) DefaultBindings() []control.Binding
- func (p *Plugin) EventHandler() control.EventHandler
- func (p *Plugin) Install(ctx plugin.Installer) error
- func (p *Plugin) KindTemplates(r *kind.Roster)
- func (p *Plugin) Name() string
- func (p *Plugin) Queues() []command.CommandQueue
- func (p *Plugin) RunPlan(ctx goke.RunCtx, d time.Duration)
- func (p *Plugin) Serializable() plugin.Serializable
- func (p *Plugin) WithGround(b *board.Plugin) *Plugin
- func (p *Plugin) WithKeeping(k Keeping) *Plugin
- func (p *Plugin) WithTap(d time.Duration) *Plugin
- type Shooter
- type States
- type Strafe
- type Tank
- type Toward
- type Turn
Constants ¶
const Driving tag.Tag[States] = 0
Driving is on while a hand drives the unit; once no hand is on it and it stands, or something else steers it, the driving lets it go.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Ahead ¶
Ahead walks the units the hand is on the way each faces, Sprint urging them on; given every tick its key is held. Camera, the one it was given through, says which units the hand is on: the one it is fastened to, else those the player has selected.
type Back ¶
Back brakes the units the hand is on to a stop and then backs them away facing as they do.
type Compass ¶
Compass are four keys held walking the units the way of the screen: up, down, left, right, as the camera lays it (up the way it looks ahead, camera.Headed), the units turning to face it; with Shift, sprinting. In says in which fastenings of the camera they hold (zero, every one); KeyUnknown leaves one unbound.
type Jump ¶
Jump has each unit the hand is on leap (gravity.Leap), as high as its gravity.Body says.
type Keeping ¶
type Keeping interface {
// MayStep reports whether the unit id, standing at pos in its cell at, moving in domain, may
// walk on into the cell ahead along heading on level.
MayStep(id uid.UID64, pos world.Position, at, ahead cell.ID, level cell.Level,
domain cell.Domain,
heading geom.Vec) bool
// Ordered reports whether id is steered along a route of its own: with no hand on it, the
// driving leaves it be.
Ordered(id uid.UID64) bool
}
Keeping is who else may stand in a driven unit's way, and whom something else steers: the navigation's spacing, which navigation hands over as it is made (WithKeeping).
type Keys ¶
Keys are a set of keys driving a player's units, bound as one and in chords, sprinting with Shift: Tank, Shooter or Compass.
func DefaultKeys ¶
func DefaultKeys() []Keys
DefaultKeys drive the unit the camera is fastened to: W, S, A and D riding inside it as a shooter's, behind it as a compass's (the way the screen lies, the mouse turning the camera); the arrows a tank's behind it.
type Plugin ¶
Plugin drives units by hand: the commands Ahead, Back, Turn and Toward, summed a tick into each hand and carried out on the units the hand is on.
func NewPlugin ¶
func NewPlugin( worldPlugin *world.Plugin, m *motion.Plugin, selectionPlugin *selection.Plugin, ) *Plugin
NewPlugin builds the driving over worldPlugin's units, moved by m, a player's hand on those it has selected in selectionPlugin while its camera is fastened to none.
func (*Plugin) DefaultBindings ¶
DefaultBindings are DefaultKeys, the keys driving the unit the camera is fastened to, and Space to jump riding inside it or behind it.
func (*Plugin) EventHandler ¶
func (p *Plugin) EventHandler() control.EventHandler
EventHandler is nil: a player's bindings issue the commands.
func (*Plugin) KindTemplates ¶
KindTemplates is what driving asks of the kinds a game defines: of a unit, the profile it is driven by and its driving's markers.
func (*Plugin) Queues ¶
func (p *Plugin) Queues() []command.CommandQueue
Queues are where the hand's commands land.
func (*Plugin) RunPlan ¶
RunPlan puts this tick's hands on the units at once and carries them out in the simulation; call it after navigation's, whose orders a hand ends.
func (*Plugin) Serializable ¶
func (p *Plugin) Serializable() plugin.Serializable
Serializable is nil: the driving keeps nothing but the units' own components.
func (*Plugin) WithGround ¶
WithGround has the driven units walk the board: never onto ground their domain may not stand on, their cell and their hold on the occupancy following them. Call it before Use.
func (*Plugin) WithKeeping ¶
WithKeeping has k say who else is in a driven unit's way and whom it steers itself (navigation calls it as it is made). Call it before Use.
type Shooter ¶
Shooter are four keys held driving the units as a shooter does: Ahead walks on (with Shift, sprints), Back brakes and backs away, Left and Right strafe, facing on — the mouse turns. In says in which fastenings of the camera they hold (zero, every one); KeyUnknown leaves one unbound.
type States ¶
type States struct{}
States is the family of a unit's driving markers. The plugin gives it to every unit the world's roster makes; a unit without it gets it the first time it is needed.
type Strafe ¶
Strafe walks the units the hand is on across the way each faces, facing on: Way 1 to the right, -1 to the left.
type Tank ¶
Tank are four keys held driving the units as one sits in them: Ahead walks on (with Shift, sprints), Back brakes and backs away, Left and Right turn. In says in which fastenings of the camera they hold (camera.Inside riding in the unit, camera.Behind following it, camera.Outside looking from anywhere; zero, every one); KeyUnknown leaves one unbound.