Files
aego/engine/module/module.go
T
sanspie de49a53172
ci-platforms / build (amd64, windows, windows-2022) (push) Skipped
ci-platforms / build (arm64, darwin, macos-15) (push) Skipped
ci / checks (push) Successful in 21m50s
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 6m46s
ci-platforms / build (amd64, darwin, macos-15-intel) (push) Skipped
ci / release (push) Successful in 17m42s
Stage 10d3: docs, site demo, check levels, boundary audit (D316)
2026-10-22 16:00:33 +03:00

94 lines
1.6 KiB
Go

package module
import (
"aego/asset"
"aego/core/log"
"aego/engine"
"aego/engine/problems"
"aego/engine/settings"
"aego/scene"
)
type Info struct {
ID string
Version string
Requires []string
Builtin bool
NonDeterministic string
DisplayName string
DocsOrder int
DocsIcon string
DocsGroup string
Codes []string
}
type Module interface {
Info() Info
Register(r *Registry) error
}
type Initer interface {
Init(ctx *InitContext) error
}
type WorldAttacher interface {
AttachWorld(ctx *AttachContext) error
DetachWorld(ctx *AttachContext)
}
type Reconfigurer interface {
Reconfigure(ctx *AttachContext) error
}
type Shutdowner interface {
Shutdown()
}
type InitContext struct {
Engine *engine.Engine
Assets asset.Resolver
Log *log.Logger
Editor bool
Sections *Sections
Problems *problems.Service
Settings *settings.Store
provided []provision
owner string
}
func (c *InitContext) Setting(d settings.Desc) (settings.Key, error) {
if c.Settings == nil {
return 0, nil
}
d.Owner = c.owner
return c.Settings.Register(d)
}
func (c *InitContext) Provided(kind string) []Provision {
var out []Provision
for _, p := range c.provided {
if p.kind == kind {
out = append(out, p.Provision)
}
}
return out
}
func (c *InitContext) Section(id string) any {
v, _ := c.Sections.Get(id)
return v
}
type AttachContext struct {
World *engine.World
Scene *scene.Scene
Log *log.Logger
Editor bool
Play bool
}
type Hook struct {
Owner string
Fn any
}