Documentation
¶
Overview ¶
Package host is the pass's side of the rules: a pass that perceives a moment of its entities keeps a host of that moment, binds it to the columns of its query (store.Columns) and runs it over every block of entities (store.Row), and the host runs the rules given to it. A rule of a moment no host in use catches is an error, never a silent no-op.
Moments ¶
A moment is what a pass perceives of an entity, handed to rules and forgotten: a value that is About (Who, the entity it is of), Met for one entity with others. Aimed is a command told the subject of the moment it is given on.
Places ¶
A library names the kinds of places its hosts tell for their moments (NewPlacing: those round where an entity stands, those in front of it), each saying which moments have them; Places are some of a kind, whom a rule's cond.At and act.At turn to, told by Tick.Places.
Hosts ¶
Rules runs the rules of a moment over the entities of a pass; PairRules matches pairs by the tag families the rules name (Side, Marks); StepRules runs rules of a moment of the whole once a step. Each is a Host: Add takes a rule or refuses it with ErrUnhosted, and after Bind with ErrHostBuilt. Tick is what a host tells its rules of the pass: the commands' carrier, the effects' runtime, the time, the seed, the places and the roles played.
Index ¶
- Variables
- type About
- type Aimed
- type Host
- type Hosted
- type Marks
- type Met
- type PairRules
- func (r *PairRules[P]) Add(rule any) error
- func (r *PairRules[P]) Bind(queries ...store.Columns)
- func (r *PairRules[P]) Dispatch(t Tick, self, other Marks, pair P)
- func (r *PairRules[P]) DispatchEitherWay(t Tick, a, b Marks, forward, backward P)
- func (r *PairRules[P]) DispatchGrouped(t Tick, self Marks, others []Marks, build func(matched []int) P)
- func (r *PairRules[P]) Empty() bool
- func (r *PairRules[P]) For(self Marks) bool
- func (r *PairRules[P]) Read(query int, row store.Row, i int) Marks
- type Places
- type Placing
- type Rules
- type Side
- type StepRules
- type Tick
- type TickSource
Constants ¶
This section is empty.
Variables ¶
var ErrHostBuilt = errors.New("plugin: rule handed over after its system was built")
ErrHostBuilt is what a Host reports for a rule handed over once the system running it is built.
var ErrUnhosted = errors.New("plugin: rule cannot be hosted here")
ErrUnhosted is what a Host reports for a rule of a moment it does not catch.
Functions ¶
This section is empty.
Types ¶
type Aimed ¶
Aimed is a command told the Subject of the moment or the fact it is given on as it is issued.
type Hosted ¶
type Hosted interface{ Hosted() any }
Hosted is a rule that builds itself for its host, as an act.Branch does.
type Marks ¶
type Marks struct {
// contains filtered or unexported fields
}
Marks is which tags of a host's families one entity carries, as PairRules reads them.
type PairRules ¶
type PairRules[P any] struct { // contains filtered or unexported fields }
PairRules are the rules of a moment P of two entities a pass runs: it reads the tag families the rules name, eight at most, off the entities (Read) and dispatches each pair to the rules whose sides it carries.
func (*PairRules[P]) Add ¶
Add takes a pair rule of P; ErrUnhosted for another, ErrHostBuilt after Bind.
func (*PairRules[P]) Bind ¶
Bind binds every family the rules name to the columns of each of the pass's queries, one Columns a query, in the order Read takes them. Call it once, as they are built.
func (*PairRules[P]) Dispatch ¶
Dispatch runs every rule whose first side self carries and second side other carries.
func (*PairRules[P]) DispatchEitherWay ¶
DispatchEitherWay is Dispatch for a pair with no direction, run whichever way the sides fit.
func (*PairRules[P]) DispatchGrouped ¶
func (r *PairRules[P]) DispatchGrouped(t Tick, self Marks, others []Marks, build func(matched []int) P)
DispatchGrouped is Dispatch for one entity against many others, run with none matched too unless the rule names the other's side; build makes the moment of the others matched, by their places in others.
type Places ¶ added in v0.3.0
Places are those of a Placing within N of the moment: whom cond.At and act.At turn a rule to, a branch run once a place.
type Placing ¶ added in v0.3.0
type Placing struct {
// contains filtered or unexported fields
}
Placing is a kind of places the hosts of a library tell for their moments (Tick.Places), named for the messages: Takes says of a moment whether it has them.
func NewPlacing ¶ added in v0.3.0
NewPlacing is the kind of places name, of the moments takes reports, each a pointer to the moment a rule fires on.
type Rules ¶
type Rules[P any] struct { // contains filtered or unexported fields }
Rules are the rules of a moment P a pass runs over the entities it walks anyway: Bind them to the columns of its query as it is built, Run them over each block of entities.
func (*Rules[P]) Bind ¶
Bind binds what the rules read to the columns of the pass's query. Call it once, as the query is built.
type Side ¶
type Side struct {
// contains filtered or unexported fields
}
Side is one side of a pair rule: a tag of a family, or anybody.
type StepRules ¶
type StepRules[P any] struct { // contains filtered or unexported fields }
StepRules are the rules of a moment P of the world as a whole, run once a step and walking no entities. A role's fire while the entity the moment is About plays the role (Tick.Roles).
func (*StepRules[P]) Add ¶
Add takes a rule of P asking nothing of the entity; ErrUnhosted for another, ErrHostBuilt after Bind.
func (*StepRules[P]) Bind ¶
func (r *StepRules[P]) Bind()
Bind marks the system running the rules built, so no rule is taken after. Call it in its Init.
type Tick ¶
type Tick struct {
Now time.Time // read once for the whole pass
Dt time.Duration
Commands *command.Carrier
Effects effect.Runtime
Time time.Duration // game time at the step's end
Seed uint64
World uid.UID64 // the world's own entity
// Places tells each the places p are of the moment, a pointer to it; nil where there are
// none.
Places func(moment any, p Places, each func(uid.UID64))
// Roles tells the roles an entity plays, a bit each; nil where there are none.
Roles func(id uid.UID64) uint64
}
Tick is what a host tells the rules it runs about its pass.