Documentation
¶
Overview ¶
Package hosts hands rules to the hosts of the moments they are of.
Package ceremony is a language and an engine for the behaviour of things that have state and are told what happens to them. An entity carries state; a fact is told to it when something happens (package fact); a state, an effect, is put on it for a while and turns knobs (package effect); a role says what it does about either — rules that fire within a pass at the moments it catches (package act, their conditions package cond) and plans that run over time on its mind (package plan) — and what a rule or a plan asks for is a command, carried by its type to whoever carries it out (package command). The hosts of rules, the pass's side, are package host; the components an entity is made of, package comp and package tag. This package ties them together: the roles whose players obey rules, the commands about effects, who an entity is called.
desk := ceremony.NewPart("desk", deskTag).Obeys(act.Branch[Review]{
Name: "escalate",
When: cond.Self.If(overdue).And(cond.Self.If(cond.Not(escalated))),
Then: act.Steps(act.Self.Put(escalated), act.Self.Do(Notify{To: "lead"})),
})
Roles ¶
A Part is a role: the rules those playing it obey (Part.Obeys), narrowed to its players. An entity plays roles through one component, Plays; NewPart makes a role out of a tag of cond.Roles, and Deliver hands every rule of every role to the host catching its moment.
Commands ¶
A Command is what somebody wants done about an effect, written as a sentence: Put, Take or Toggle an effect, On whom, By whom set off, For how long. A user gives one, a rule gives one with act.Self.Do, and an entity gives every Command whose By names it with Trigger. Whom a command is for is a Whom: Named, Group, ID or World; an entity is called by its Label.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var World = Whom{/* contains filtered or unexported fields */}
World is the world's own entity: the state of the whole game.
Functions ¶
Types ¶
type Command ¶
type Command struct {
Verb Verb
Effect effect.Effect
Whom Target
Source Whom // nobody for none
Lasts time.Duration // zero: as the effect's Spec says
Name string // empty for one not in the Stage's register
}
Command is a command about an effect and whom it is for, written as a sentence: Put(open).On(Group("trapdoors")).By(Named("lever")).For(pulse); a rule gives it with act.Self.Do. A step on whom a branch acts is act.Self.Put or act.Self.Take.
func Toggle ¶
Toggle takes e off whoever On names where any of them is under it, and puts it on them all otherwise.
func (Command) By ¶
By says who sets the command off: an entity bearing the name or the group, as it gives itself Trigger.
type Label ¶
type Label struct{ Name, Group uint64 }
Label is what an entity is called: its own name, borne by it alone, and the group it is in with others, each hashed, zero for none.
type Part ¶
type Part struct {
// contains filtered or unexported fields
}
Part is a role an entity plays: the rules those playing it obey, given to a kind with Plays.
func NewPart ¶
NewPart is the role named name with the tag t of cond.Roles, for the world's register of roles.
type Played ¶
type Played struct {
comp.Template[tag.Tags[cond.Roles]]
// contains filtered or unexported fields
}
Played is what Plays makes: the roles' tags as a kind's component.
type Router ¶
Router is a Target of a plugin's own: Route is the command that plugin carries out for c.
type Target ¶
type Target interface{ Target() }
Target is whom a Command is for: an Whom, or a plugin's own, which is a Router.
type Trigger ¶
type Trigger struct{}
Trigger is the command by which an entity sets off every Command whose By names it: a lever pulled gives itself act.Self.Do(Trigger{}).
type Whom ¶
type Whom struct {
// contains filtered or unexported fields
}
Whom says which entities a command is for, or who sets it off: those Named, those in a Group, those of an ID, or the World itself.
func (Whom) Each ¶
Each calls fn with every name and group it names, as written, and whether a Label bears it.
Directories
¶
| Path | Synopsis |
|---|---|
|
Package act is what a rule does: the Then of a Branch, every step said of whom it is done by or to, and the Branch itself, which given to a role is a rule.
|
Package act is what a rule does: the Then of a Branch, every step said of whom it is done by or to, and the Branch itself, which given to a role is a rule. |
|
Package command is how anything is asked for: a command is a value carried by its type to the one handler whose queue takes it, from a user and from an entity alike, and waits there for the handler's pass.
|
Package command is how anything is asked for: a command is a value carried by its type to the one handler whose queue takes it, from a user and from an entity alike, and waits there for the handler's pass. |
|
Package comp is how a template of entities names one component and where its value comes from: the same for every entity made from it (Const), read from each entity's own row (Load), the tags of one family (Tagged), the markers of one (Marks), or a default of the store's roster left out (Without).
|
Package comp is how a template of entities names one component and where its value comes from: the same for every entity made from it (Const), read from each entity's own row (Load), the tags of one family (Tagged), the markers of one (Marks), or a default of the store's roster left out (Without). |
|
Package cond is the When of a branch: who is in what state, every clause saying whom it is about.
|
Package cond is the When of a branch: who is in what state, every clause saying whom it is about. |
|
Package effect puts states on entities for a while: each effect with its own marker, tags granted, components altered and restored.
|
Package effect puts states on entities for a while: each effect with its own marker, tags granted, components altered and restored. |
|
Package fact is what happens to an entity: a fact is told to it and carried until it goes, a loop of a plan begins on it or waits for it; a message is a fact with its sender.
|
Package fact is what happens to an entity: a fact is told to it and carried until it goes, a loop of a plan begins on it or waits for it; a message is a fact with its sender. |
|
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.
|
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. |
|
internal
|
|
|
steps
Package steps runs the steps of rules and plans: the nodes packages cond, act and plan build, laid out as a tree, run at a moment within a pass (Instant) or every step on the entities' minds (Plans).
|
Package steps runs the steps of rules and plans: the nodes packages cond, act and plan build, laid out as a tree, run at a moment within a pass (Instant) or every step on the entities' minds (Plans). |
|
Package plan is what an entity does over time: loops run on its mind every step, made of the same steps a rule has and of what lasts.
|
Package plan is what an entity does over time: loops run on its mind every step, made of the same steps a rule has and of what lasts. |
|
Package tag is the tags an entity carries: a family's Tags, a component of up to MaxTagsPerFamily bits, each a Tag its owner defines by name and the store saves by name.
|
Package tag is the tags an entity carries: a family's Tags, a component of up to MaxTagsPerFamily bits, each a Tag its owner defines by name and the store saves by name. |