Documentation
¶
Overview ¶
Package bullet fires shots and flies them: entities of the world a Shoot spawns at a unit's muzzle, flown every step past the world's step cap and swept by collision, so what lies on the path is struck. A weapon — which ammo, how often, who carries it — is the game's rules and effects.
Body, Shots and Ammo ¶
Body is what a kind of shot is: its Size, Speed, Range, its Gravity if thrown and whether it Lands. Shots (Plugin.Shots) defines the kinds: Define(name, body, extra...) registers an ammo, Named is the Ammo a Shoot names. A shot is a kind of the world like any other, drawn from its sprite, carrying a Collider without Physics (a sensor), a Sweep ignoring its shooter, its Body, its Flight and its shooter's owners. The game must use collision: without it nothing is struck.
Shoot ¶
Shoot is the command: by a player, from the unit its Camera is fastened to, else from every Selected unit it owns; by an entity, through act.Self.Do in a rule or a plan, from itself. The shot goes towards At when Targeted, towards the moment's Subject when aimed, else the way the shooter faces. A thrown shot comes down where it goes to, on the ground Plugin.WithGround gives, untargeted as far as its Power says.
Landing, Resting and Blast ¶
Landing is told once as a flight ends: whom it Struck (its Subject), which Wall, whether it came down or Left. Resting is told every step for a landed shot that Lands; Burst is the command such a shot gives itself, and Blast what every entity within the Burst's Radius is to the pair rules, Within its word of the other. A Flight is a plan's fact, Lying its word of a shot come to rest: a fuse. The Meeting of a shot and what it struck is collision's.
Dressing a shot ¶
A shot is dressed on the world's atlas as any entity: a look Under an effect, and Turning for one drawn the way it flies, the sprite authored facing east.
Limits ¶
A wrapping world is refused. Shots do not penetrate: the nearest contact ends the flight. A landed shot touches nothing. A shot flies every step at every level of the world's sectors but L6, keeping its sector and those round it at L4 at most (sector.Keen) till it rests, at L3 when aimed at an aggregate (world.Aggregate), so a fight unfolds it as the shot comes.
Figures ¶
A Figure is a kind of ammo in one piece: Define its Body on the plugin's Shots, Look its look on the world's atlas, and, Stateful or Ruled, its own effects and rules. Plugin.Figures, called in the Stage's Figures link, hands them on to the world's figures, which the Stage leads through its sections; Plugin.World is the world the shots fly in.
Vocabulary ¶
Moments, for a role's rules: Landing (a shot landing, its subject what it struck), Resting (a landed shot, every step), Blast (a pair, host.Met, its subject the shot; its word Within of the other). Facts, for plans: Flight (every shot's, its word Lying). Knobs, for an effect's Alter: Body (its Speed and Gravity felt every step, its Range at the shot). Commands: Shoot (a player's or an entity's own, aimed at the moment's subject, host.Aimed); Burst (an entity's own).
Index ¶
- func Lying() cond.Word[Flight]
- func Within(d float32) cond.Word[Blast]
- type Ammo
- type Blast
- type Body
- type Burst
- type End
- type Figure
- type Flight
- type Landing
- type Plugin
- func (p *Plugin) DefaultBindings() []control.Binding
- func (p *Plugin) EventHandler() control.EventHandler
- func (p *Plugin) Figures(figures ...Figure)
- func (p *Plugin) Install(ctx plugin.Installer) error
- 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) Shots() *Shots
- func (p *Plugin) WithGround(heights func() ground.Heights) *Plugin
- func (p *Plugin) World() *world.Plugin
- type Resting
- type Ruled
- type Shoot
- type Shot
- type Shots
- type Stateful
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Ammo ¶
type Ammo struct {
// contains filtered or unexported fields
}
Ammo is a kind of shot, as Shoot names it.
type Blast ¶
Blast is the moment told for each entity within the Radius of a Burst: the shot bursting (Self), the one reached (Other) and how far off its centre is.
type Body ¶
Body is what a kind of shot is, a knob on every shot: its Size (a square box), how fast and far it flies, whether it is thrown (Gravity > 0) and whether it Lands where its flight ends. A shot that is to Burst must Land.
type Burst ¶
type Burst struct{ Radius float32 }
Burst is the command a landed shot gives itself to burst: every entity within Radius of its centre is told a Blast, and the shot is gone.
type End ¶
type End uint8
End is how a flight ends: not yet (Flying), its Range flown (Spent), a thrown shot come down (Grounded), stopped at a closed edge (Edge), flown out by an open one (Left), on an entity (Struck), on the solid ground (Wall).
type Figure ¶
Figure is a kind of ammo in one piece: its Body defined on the plugin's Shots in the Kinds section, its look 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.
type Flight ¶
type Flight struct {
At, Dir geom.Vec
Range, Flown, Climb float32
Shooter uid.UID64
Ending End
Other uid.UID64
Cell uint64
Landed bool
}
Flight is a shot in the air: where it is, which way and how far it goes, who shot it, how its flight ends and whether it lies Landed.
type Landing ¶
type Landing struct {
ID uid.UID64
At geom.Vec
Struck bool
Other uid.UID64
Wall bool
Cell uint64
Grounded bool
Left bool
}
Landing is the moment a shot's flight ends: where, and why — Struck an entity (Other), hit a Wall of the ground (Cell), Grounded (come down, or its Range flown) or Left by an open edge.
type Plugin ¶
Plugin fires shots and flies them, hosting the rules of their Landing, Resting and Blast.
func NewPlugin ¶
NewPlugin builds the bullet plugin over w, firing a player's Shoot from the units sel marks Selected, a shot gone past an open edge m's leaver.
func (*Plugin) DefaultBindings ¶
DefaultBindings are none: a Shoot names its Ammo, which is the game's to bind.
func (*Plugin) EventHandler ¶
func (p *Plugin) EventHandler() control.EventHandler
EventHandler is nil: bullet handles no input of its own.
func (*Plugin) Figures ¶
Figures notes the kinds of ammo among the world's figures, which the Stage leads through its sections. Called in the Stage's Figures link.
func (*Plugin) Queues ¶
func (p *Plugin) Queues() []command.CommandQueue
Queues are the plugin's command queues, Shoot and Burst.
func (*Plugin) RunPlan ¶
RunPlan fires the Shoots given and hands the flights to the simulation. Call it before the world's RunPlan, so a step's flights are tested by collision in the same step.
func (*Plugin) Serializable ¶
func (p *Plugin) Serializable() plugin.Serializable
Serializable is nil: a shot's state is on its entity.
func (*Plugin) WithGround ¶
WithGround gives the plugin the ground a thrown shot comes down on, read as needed; without it the ground lies at 0.
type Ruled ¶
type Ruled interface{ Rules(p *Plugin) }
Ruled is a Figure with roles and rules of its own, defined in the Rules section.
type Shoot ¶
type Shoot struct {
Ammo Ammo
At geom.Vec
Targeted bool
Camera camera.Camera
Power float32
// contains filtered or unexported fields
}
Shoot is the command to fire a shot of Ammo: by a player from the unit Camera is fastened to, else from every selected unit it owns; by an entity from itself. It goes towards At when Targeted, at the moment's Subject when aimed, else the way the shooter faces, a thrown shot as far as Power says, a share of its Range (0 the whole).
type Shot ¶
type Shot struct {
From, Dir geom.Vec
Altitude float32
Climb float32
Range float32
Shooter uid.UID64
Owners tag.Tags[owner.Family]
// contains filtered or unexported fields
}
Shot is the row a kind of shot spawns from; the plugin builds it as it fires.
type Shots ¶
type Shots struct {
// contains filtered or unexported fields
}
Shots is the register of the kinds of shots, defined on a world's kinds.