Documentation
¶
Overview ¶
Package effect puts states on entities for a while: each effect with its own marker, tags granted, components altered and restored. An effect is defined once, from a Spec of traits, and cast from anywhere — a rule's act.Self.Put, Hold and Take, a command, another pass. The store that makes the effects runs their system every step, so they count down in its time.
Spec, the marker, Grant and Alter ¶
Effects.Define registers an effect from a Spec under a name and Effects.Named is the effect wherever it is built on. Every effect has its own marker of States, "effect.<name>", on while it runs (Effect.Mark; a cond clause of the effect, cond.Self.If(e), asks it in any pass). Lasts is how long a cast holds (without it, until Dispel); Stacking lets casts pile up instead of refreshing; Then casts another effect when this one's time is up, not when it is dispelled; Grant gives tags of a family while the effect runs; Alter changes a Knob — a component its owner only reads — and restores the original after, several Alters of one component stacking in slot order; Described gives it a sentence for a UI. At most 63 effects are defined.
Active, Cast and Dispel ¶
Active is what an entity is under, saved with it; Wide is the same with a slot for every effect, for an entity standing for a whole pass or for the whole. Effects.Cast and Effects.CastFor put an effect on an entity, landing with the effects' next pass; Effects.Dispel ends one; Effects.Has and the handle's Effect.On ask.
Changed ¶
An entity's markers have Changed on for the step after an Alter rewrote one of its components, as the effect began or ended, so the owner of that component learns of the change without keeping a copy to compare. An effect something is drawn by (Effect.Shows) turns it on as it begins and ends, altering nothing.
Index ¶
- Constants
- type Active
- type Effect
- type Effects
- func (e *Effects) Cast(cb *goke.CmdBuf, id uid.UID64, effect Effect)
- func (e *Effects) CastFor(cb *goke.CmdBuf, id uid.UID64, effect Effect, d time.Duration)
- func (e *Effects) Define(name string, spec Spec)
- func (e *Effects) Dispel(id uid.UID64, effect Effect)
- func (e *Effects) Guard(guard func(name string))
- func (e *Effects) Has(id uid.UID64, effect Effect) bool
- func (e *Effects) Lookup(name string) (Effect, bool)
- func (e *Effects) Module() goke.Module
- func (e *Effects) Named(name string) Effect
- type Knob
- type Spec
- type States
- type Trait
- type Wide
Constants ¶
const Changed tag.Tag[States] = 0
Changed is on for the one step after an effect changed the entity's components, as an Alter began or ended.
const Forever = time.Duration(-1)
Forever is the Left of a slot that lasts until Dispel.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Active ¶
type Active struct {
Slots [maxEffects]effectSlot
}
Active is what an entity is under: up to eight effects, saved with the entity.
type Effect ¶
type Effect struct {
// contains filtered or unexported fields
}
Effect is one effect defined with its Effects: what a rule or a plan casts.
func (Effect) Description ¶
Description is what the Spec's Described said of the effect, "" without one.
type Effects ¶
type Effects struct {
// contains filtered or unexported fields
}
Effects is a Stage's register of effects, which the world makes and runs (world.Plugin.Effects).
func New ¶
New makes the effects, naming each effect's marker with name, which must give Changed first.
func (*Effects) Cast ¶
Cast puts effect on id for as long as its Spec says, landing with the effects' next pass; cast again, it is refreshed unless it stacks.
func (*Effects) CastFor ¶
CastFor is Cast for a set time of the clock's; Forever for one that lasts until Dispel.
func (*Effects) Define ¶
Define registers an effect under name, with its own marker on while it runs (Effect.Mark). It panics once the game is set up, or past 63 effects.
type Knob ¶
type Knob interface{ Knob() }
Knob marks a component an effect may turn: one its owner only reads, so that an Alter ending puts back what it found. A type is one by its method Knob, a mark never called, confirmed where it is defined: var _ effect.Knob = Steering{}.
type Spec ¶
type Spec []Trait
Spec is the definition of one effect: what it does to an entity and for how long.
type States ¶
type States struct{}
States is the family of an entity's effect markers: Changed and each effect's own (Effect.Mark).
type Trait ¶
type Trait interface {
// contains filtered or unexported methods
}
Trait is one part of a Spec.
func Alter ¶
Alter changes the entity's T while the effect runs; the original comes back after. Several running Alters of one T stack from the original in slot order, whichever ends first.
func Described ¶
Described gives the effect a description for a UI, handed back by Effect.Description.
func Grant ¶
Grant gives the entity these tags of family F while the effect runs, and takes them back after unless another running effect grants them; an entity without the family gets it attached.
func Lasts ¶
Lasts is the default length of every cast of the effect; without it, an effect lasts until Dispel. CastFor overrides it per cast.