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, Placed for one standing on places that are entities of their own, Headed for one of those facing somewhere. Aimed is a command told the subject of the moment it is given on.
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 round and the roles played.
Index ¶
- Variables
- type About
- type Aimed
- type Headed
- 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]) Read(query int, row store.Row, i int) Marks
- type Placed
- 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 Headed ¶ added in v0.2.1
type Headed interface {
Placed
Headed()
}
Headed is a Placed moment of an entity facing somewhere, which Tick.Ahead tells the places in front of and act.Ahead turns a step on.
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 Placed ¶
type Placed interface {
About
Placed()
}
Placed is a moment of an entity standing on places that are entities of their own, which Tick.Around tells and act.Around turns a step 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
// Around tells each the places within rings of where the moment stands, those it stands on
// first; nil where there are none.
Around func(moment any, rings int, each func(uid.UID64))
// Ahead tells each the places on the cells one to steps ahead of the moment, the way its
// entity faces, the nearest first; nil where there are none.
Ahead func(moment any, steps int, 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.