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 into its query and runs it over every chunk, 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. 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, the time, the seed, the places round and the roles played.
Index ¶
- Variables
- func Own[T, P any](r *Rules[P], col *goke.OptComp[T])
- type About
- type Aimed
- type Columns
- type Host
- type Hosted
- type Marks
- type Met
- type PairRules
- func (r *PairRules[P]) Add(rule any) error
- func (r *PairRules[P]) At(query int, cursor *goke.Cursor) Marks
- func (r *PairRules[P]) Bind(queries ...*goke.QueryBuilder)
- 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]) InChunk(query int, cursor *goke.Cursor, 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 ¶
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 Columns ¶
type Columns struct {
// contains filtered or unexported fields
}
Columns are the optional columns of a host's query, by component, shared by the rules over one component and the system's own reading of it (Own).
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 plugin runs in its pass: it reads the tag families the rules name, eight at most, off the entities (InChunk, At) 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 ¶
func (r *PairRules[P]) Bind(queries ...*goke.QueryBuilder)
Bind adds every family the rules name to each of the system's queries. Call it once, before 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 plugin runs in the pass over its entities it makes anyway: Bind them into its query in Init, Run them over each chunk in Update.
func (*Rules[P]) Bind ¶
func (r *Rules[P]) Bind(qb *goke.QueryBuilder)
Bind adds what the rules read to the system's query. Call it once, before 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 {
CmdBuf *goke.CmdBuf
Now time.Time // read once for the whole pass
Dt time.Duration
Commands *command.Carrier
Effects *effect.Effects
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))
// 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.