22 Commits
Author SHA1 Message Date
sanspie c6a24ba393 Try it: scene keys in the hint, J label on Health and Hurtbox, faster Respawn, sound starts with the Try click; lighter web audio pump; release notes from tools/release/notes
ci-platforms / build (amd64, windows, windows-2022) (push) Skipped
ci-platforms / build (amd64, darwin, macos-15-intel) (push) Skipped
ci-platforms / build (arm64, darwin, macos-15) (push) Skipped
ci / release (push) Successful in 7m34s
ci / checks (push) Successful in 2m53s
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 5m2s
2026-10-22 18:55:33 +03:00
sanspie 7dca06e4b1 Icons in the engine style for gameplay, shake, clips, curves, dice, debug draw and install; web loader retries a stalled download
ci-platforms / build (amd64, darwin, macos-15-intel) (push) Skipped
ci-platforms / build (amd64, windows, windows-2022) (push) Skipped
ci-platforms / build (arm64, darwin, macos-15) (push) Skipped
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 17m5s
ci / release (push) Successful in 9m30s
ci / checks (push) Successful in 2m25s
2026-10-22 17:38:02 +03:00
sanspie 6dfdb824e2 Stage 10d3b: physics debug layers follow Game View overlays, PHY diagnostics pages
ci / checks (push) Successful in 3m4s
ci-platforms / build (amd64, darwin, macos-15-intel) (push) Skipped
ci-platforms / build (amd64, windows, windows-2022) (push) Skipped
ci-platforms / build (arm64, darwin, macos-15) (push) Skipped
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 3m53s
ci / release (push) Successful in 5m37s
2026-10-22 16:25:06 +03:00
sanspie de49a53172 Stage 10d3: docs, site demo, check levels, boundary audit (D316)
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
2026-10-22 16:00:33 +03:00
sanspie 1030dc9a43 Stage 10d2: audio fast path, shutdown order, profiler and monitor sections
ci-platforms / build (amd64, darwin, macos-15-intel) (push) Skipped
ci-platforms / build (amd64, windows, windows-2022) (push) Skipped
ci-platforms / build (arm64, darwin, macos-15) (push) Skipped
ci / checks (push) Successful in 4m58s
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 27m47s
ci / release (push) Successful in 11m57s
2026-10-22 14:41:24 +03:00
sanspie 3d25734dfa Stage 10d1: add-component requirements, play diff from history, node labels; one sound button on the web
ci-platforms / build (amd64, darwin, macos-15-intel) (push) Skipped
ci-platforms / build (amd64, windows, windows-2022) (push) Skipped
ci-platforms / build (arm64, darwin, macos-15) (push) Skipped
ci / build (amd64, linux, ubuntu-24.04) (push) Failing after 1s
ci / checks (push) Failing after 1s
ci / release (push) Skipped
2026-10-22 13:29:11 +03:00
sanspie 12f628c469 Stage 10c3: platformer and top-down examples on the gameplay kit, new music 2026-10-22 12:16:37 +03:00
sanspie 1529213434 Stage 10c2: health, hitboxes, zones, respawn, pickups, lifetime, templates, StateMachine, gameplay editor tools (D313, D330, D332) 2026-10-22 10:53:54 +03:00
sanspie f8bb865920 Stage 10c1: shape casts and Motion2D (D312, D328, D329) 2026-10-22 03:01:46 +03:00
sanspie f5fb32565e Stage 10b3: desktop onboarding, app icon, clip inspector, asset grid audio cards, web audio and docs fixes (D327) 2026-10-22 03:01:46 +03:00
sanspie f1a8f538d3 Stage 10b: audio mixer, codecs, clips, events, sources, zones and mixer UI (D307–D311, D321–D326) 2026-10-21 20:33:25 +03:00
sanspie 963b01a011 Docs: Try it for every component, quieter design, self-hosted fonts, OS downloads, page meta 2026-10-21 19:20:52 +03:00
sanspie 6aec9dc544 Stage 10a: virtual cameras, blends and zones (D305, D306); release 0.9.0-beta.1
ci / build (amd64, linux, ubuntu-24.04) (push) Failing after 1s
ci / checks (push) Failing after 1s
ci / release (push) Skipped
2026-10-21 02:37:55 +03:00
sanspie 70a0111deb Docs overhaul: redesigned site, Try it, runnable Script API examples, edge deploy (D301–D303) 2026-10-20 20:11:47 +03:00
sanspie 0da2549d91 Stage 9.6d: agent layer, CLI and MCP server, external edits in the editor (D297, D299, D300) 2026-10-20 14:06:22 +03:00
sanspie 810984ae7a Stage 9.6c: project refs, refactorings, prefab apply and data editing without the editor (D298) 2026-10-20 13:05:10 +03:00
sanspie 62c8129364 Stage 9: gameplay toolkit, export and web, agent tooling 2026-10-20 12:06:56 +03:00
sanspie 674af03a65 Stage 8: physics and module boundaries; CI on master 2026-10-16 12:10:43 +03:00
sanspie 6b0d006467 Stage 7: documentation, help, playground; templates, aego new/bootstrap/icons, launcher; push-to-deploy site 2026-10-14 22:40:20 +03:00
sanspie ff7e95afe4 Stage 6: coroutines, signals, ScriptRef, workspace CLI, editor tooling 2026-10-12 14:22:08 +03:00
sanspie 67b16d3da5 Stage 2–5: assets, scene/ECS, editor, 3D, and Aego Script 2026-10-08 13:31:21 +03:00
sanspie 56ca1c638e Stage 1: engine core, platform, gpu, vfs 2026-09-26 16:32:40 +03:00
258 changed files with 5963 additions and 730 deletions
+76 -25
View File
File diff suppressed because it is too large Load Diff
+39 -4
View File
File diff suppressed because it is too large Load Diff
+8
View File
@@ -0,0 +1,8 @@
# Aego
A 2D and 3D game engine with an editor, a scripting language and a web export, written in Go.
- Documentation and the playground: <https://aego.akarpov.ru>
- Installing and building from source: [engine/res/docs/install.md](engine/res/docs/install.md)
- Contributing, check levels and rules for engine code: [docs/contributing.md](docs/contributing.md)
- Architecture and decisions: [ARCHITECTURE.md](ARCHITECTURE.md)
+49 -3
View File
@@ -2,6 +2,7 @@ package agent
import ( import (
"errors" "errors"
"maps"
"os" "os"
"path" "path"
"slices" "slices"
@@ -65,9 +66,8 @@ func sceneCommands() []*Command {
{Name: "scene.rename", Doc: "rename a node", Write: true, Args: []Arg{argFile, argNode, {Name: "name", Type: "string", Doc: "new name", Required: true, Pos: true}}, Run: func(s *Session, a Args) (*Output, error) { {Name: "scene.rename", Doc: "rename a node", Write: true, Args: []Arg{argFile, argNode, {Name: "name", Type: "string", Doc: "new name", Required: true, Pos: true}}, Run: func(s *Session, a Args) (*Output, error) {
return s.sceneTx(a, "Rename", mutate.Rename(a.Str("node"), a.Str("name"))) return s.sceneTx(a, "Rename", mutate.Rename(a.Str("node"), a.Str("name")))
}}, }},
{Name: "scene.add-comp", Doc: "add a component with its defaults", Write: true, Args: []Arg{argFile, argNode, {Name: "comp", Type: "string", Doc: "component name, full or a unique suffix (Body2D)", Required: true, Pos: true}}, Run: func(s *Session, a Args) (*Output, error) { {Name: "scene.add-comp", Doc: "add a component with its defaults and the components it requires", Write: true, Args: []Arg{argFile, argNode, {Name: "comp", Type: "string", Doc: "component name, full or a unique suffix (Body2D)", Required: true, Pos: true},
return s.sceneTx(a, "Add Component", mutate.AddComp(a.Str("node"), a.Str("comp"))) {Name: "no-required", Type: "boolean", Doc: "add only this component; missing requirements stay as problems"}}, Run: (*Session).sceneAddComp},
}},
{Name: "scene.remove-comp", Doc: "remove a component", Write: true, Args: []Arg{argFile, argNode, {Name: "comp", Type: "string", Doc: "component name", Required: true, Pos: true}}, Run: func(s *Session, a Args) (*Output, error) { {Name: "scene.remove-comp", Doc: "remove a component", Write: true, Args: []Arg{argFile, argNode, {Name: "comp", Type: "string", Doc: "component name", Required: true, Pos: true}}, Run: func(s *Session, a Args) (*Output, error) {
return s.sceneTx(a, "Remove Component", mutate.RemoveComp(a.Str("node"), a.Str("comp"))) return s.sceneTx(a, "Remove Component", mutate.RemoveComp(a.Str("node"), a.Str("comp")))
}}, }},
@@ -93,6 +93,49 @@ func (s *Session) scene(a Args) (string, []byte, *mutate.Document, error) {
return rel, src, doc, err return rel, src, doc, err
} }
// sceneAddComp adds a component and, unless no-required is set, the components it requires first, in one transaction (D144).
func (s *Session) sceneAddComp(a Args) (*Output, error) {
rel, src, doc, err := s.scene(a)
if err != nil {
return nil, err
}
node, comp := a.Str("node"), a.Str("comp")
ops := []mutate.Op{mutate.AddComp(node, comp)}
var notes []string
if !a.Bool("no-required") {
td, err := doc.Component(comp)
if err != nil {
return nil, err
}
h, err := doc.Node(node)
if err != nil {
return nil, err
}
req, err := mutate.Required(doc.Scene, td, h)
if err != nil {
return nil, err
}
ops = ops[:0]
for _, r := range req {
ops = append(ops, mutate.AddComp(node, r.FullName))
notes = append(notes, "added "+label(r)+" (required by "+label(td)+")")
}
ops = append(ops, mutate.AddComp(node, td.FullName))
}
out, err := s.applyDoc(a, rel, src, doc, mutate.Tx{Label: "Add Component", Ops: ops})
if out != nil {
out.Notes = append(notes, out.Notes...)
}
return out, err
}
func label(td *schema.TypeDescriptor) string {
if td.DisplayName != "" {
return td.DisplayName
}
return td.FullName
}
func (s *Session) sceneTx(a Args, label string, ops ...mutate.Op) (*Output, error) { func (s *Session) sceneTx(a Args, label string, ops ...mutate.Op) (*Output, error) {
rel, src, doc, err := s.scene(a) rel, src, doc, err := s.scene(a)
if err != nil { if err != nil {
@@ -245,6 +288,9 @@ func (s *Session) sceneRun(a Args) (*Output, error) {
} }
var b strings.Builder var b strings.Builder
b.WriteString("frames: " + strconv.Itoa(rep.Frames) + "\nhash: " + rep.Hash + "\n") b.WriteString("frames: " + strconv.Itoa(rep.Frames) + "\nhash: " + rep.Hash + "\n")
for _, k := range slices.Sorted(maps.Keys(rep.Counters)) {
b.WriteString(k + ": " + strconv.FormatUint(rep.Counters[k], 10) + "\n")
}
for _, l := range rep.Log { for _, l := range rep.Log {
b.WriteString(l + "\n") b.WriteString(l + "\n")
} }
+55
View File
@@ -1,6 +1,7 @@
package agent package agent
import ( import (
"aego/script/abi"
"errors" "errors"
"strings" "strings"
@@ -34,6 +35,14 @@ type TypeView struct {
Requires []string `json:"requires,omitempty"` Requires []string `json:"requires,omitempty"`
Doc string `json:"doc,omitempty"` Doc string `json:"doc,omitempty"`
Fields []FieldView `json:"fields,omitempty"` Fields []FieldView `json:"fields,omitempty"`
Methods []CallView `json:"methods,omitempty"`
Signals []CallView `json:"signals,omitempty"`
}
type CallView struct {
Name string `json:"name"`
Sig string `json:"sig"`
Doc string `json:"doc,omitempty"`
} }
func schemaCommands() []*Command { func schemaCommands() []*Command {
@@ -163,5 +172,51 @@ func (s *Session) schemaShow(a Args) (*Output, error) {
} }
b.WriteString("\n") b.WriteString("\n")
} }
if s.kit != nil {
for _, cm := range s.kit.methods(td.FullName) {
v.Methods = append(v.Methods, CallView{Name: cm.Name, Sig: methodSig(cm.Sig, cm.Params), Doc: summary(cm.Doc)})
}
}
for _, sg := range td.Signals {
params := make([]string, len(sg.Params))
for i, p := range sg.Params {
params[i] = p
if i < len(sg.Names) && sg.Names[i] != "" {
params[i] = sg.Names[i] + " " + p
}
}
v.Signals = append(v.Signals, CallView{Name: sg.Name, Sig: "(" + strings.Join(params, ", ") + ")", Doc: summary(sg.Doc)})
}
for _, sec := range []struct {
title string
list []CallView
}{{"methods", v.Methods}, {"signals", v.Signals}} {
if len(sec.list) == 0 {
continue
}
b.WriteString(sec.title + ":\n")
for _, c := range sec.list {
b.WriteString(" " + c.Name + c.Sig)
if c.Doc != "" {
b.WriteString(" — " + c.Doc)
}
b.WriteString("\n")
}
}
return &Output{Value: v, Text: b.String()}, nil return &Output{Value: v, Text: b.String()}, nil
} }
func methodSig(sig abi.Signature, names []string) string {
params := make([]string, len(sig.Params))
for i, p := range sig.Params {
params[i] = p.String()
if i < len(names) && names[i] != "" {
params[i] = names[i] + " " + params[i]
}
}
out := "(" + strings.Join(params, ", ") + ")"
if sig.Result.Kind != abi.Void {
out += " " + sig.Result.String()
}
return out
}
+25 -4
View File
@@ -28,6 +28,7 @@ import (
"aego/scene/sceneio" "aego/scene/sceneio"
"aego/schema" "aego/schema"
"aego/script/bind" "aego/script/bind"
"aego/script/bind/manifest"
"aego/script/reload" "aego/script/reload"
"aego/script/runtime" "aego/script/runtime"
"aego/script/workspace" "aego/script/workspace"
@@ -46,10 +47,11 @@ type RunRequest struct {
} }
type RunReport struct { type RunReport struct {
Frames int `json:"frames"` Frames int `json:"frames"`
Hash string `json:"hash"` Hash string `json:"hash"`
Log []string `json:"log,omitempty"` Counters map[string]uint64 `json:"counters,omitempty"`
Error string `json:"error,omitempty"` Log []string `json:"log,omitempty"`
Error string `json:"error,omitempty"`
} }
type Runner func(p *project.Project, r RunRequest) (RunReport, error) type Runner func(p *project.Project, r RunRequest) (RunReport, error)
@@ -79,6 +81,25 @@ type Kit struct {
ws *workspace.Workspace ws *workspace.Workspace
binds *bind.Registry binds *bind.Registry
opt Options opt Options
man *manifest.Manifest
}
// methods lists the script methods the bindings give a component type, built once per kit.
func (k *Kit) methods(comp string) []manifest.CompMethod {
if k.man == nil {
m, err := manifest.FromRegistry(k.binds, k.Types.Schema())
if err != nil {
return nil
}
k.man = m
}
var out []manifest.CompMethod
for _, cm := range k.man.CompMethods {
if cm.Comp == comp {
out = append(out, cm)
}
}
return out
} }
func NewKit(p *project.Project, opt Options) (*Kit, error) { func NewKit(p *project.Project, opt Options) (*Kit, error) {
+5 -3
View File
@@ -41,6 +41,7 @@ type Config struct {
Editor bool Editor bool
FailOnScriptErrors bool FailOnScriptErrors bool
Catalog assembly.Catalog Catalog assembly.Catalog
Platform platform.Platform
Profile string Profile string
NoProfile bool NoProfile bool
} }
@@ -98,6 +99,9 @@ func (h *Host) build(cfg Config, mods []module.Module) error {
ecfg.LoopScope = cfg.LoopScope ecfg.LoopScope = cfg.LoopScope
} }
builder := engine.NewBuilder(ecfg).WithLogger(lg).Use(rmod) builder := engine.NewBuilder(ecfg).WithLogger(lg).Use(rmod)
if cfg.Platform != nil {
builder.WithPlatform(cfg.Platform)
}
if h.Types, err = assembly.NewTypes(); err != nil { if h.Types, err = assembly.NewTypes(); err != nil {
return err return err
} }
@@ -187,6 +191,7 @@ func (h *Host) build(cfg Config, mods []module.Module) error {
} }
h.Settings.SetNames(h.Sections.Names) h.Settings.SetNames(h.Sections.Names)
h.Engine.SetService(settings.ServiceID, h.Settings) h.Engine.SetService(settings.ServiceID, h.Settings)
h.Engine.OnClose(h.Modules.Shutdown)
if err = h.Modules.Init(&module.InitContext{Engine: h.Engine, Assets: h.Loader, Log: lg, Editor: cfg.Editor, Sections: h.Sections, Problems: h.Problems, Settings: h.Settings}); err != nil { if err = h.Modules.Init(&module.InitContext{Engine: h.Engine, Assets: h.Loader, Log: lg, Editor: cfg.Editor, Sections: h.Sections, Problems: h.Problems, Settings: h.Settings}); err != nil {
return err return err
} }
@@ -227,9 +232,6 @@ func (h *Host) Close() {
return return
} }
h.closed = true h.closed = true
if h.Modules != nil {
h.Modules.Shutdown()
}
if h.Engine != nil { if h.Engine != nil {
h.Engine.Close() h.Engine.Close()
} }
+70
View File
@@ -0,0 +1,70 @@
package docstool
import (
"fmt"
"io"
"strings"
"aego/app/playground"
"aego/engine/docs"
"aego/engine/module"
)
// CheckExamples loads the example scene of every module code, validates it and runs it headless; the code must be among the problems it reports (D146).
func CheckExamples(reg *docs.Registry, w io.Writer) int {
pg, err := playground.New()
if err != nil {
fmt.Fprintln(w, "examples: cannot start the docs runtime:", err)
return 1
}
pg.SetGame(playground.GameConfig{Headless: true, FrameTime: 1.0 / 60})
defer func() {
if g := pg.Game(); g != nil {
g.Close()
}
}()
bad := 0
for _, e := range reg.All() {
if e.Kind != docs.Code || e.Diag == nil || e.Diag.Example == "" {
continue
}
found, why := false, ""
code := ""
if e.Diag.ExampleScript != "" {
c, err := pg.TryCode(e.Diag.ExampleScript)
if err != nil {
fmt.Fprintf(w, "%s: error: example script does not compile: %v\n", e.ID, err)
bad++
continue
}
code = c
}
if res := pg.PlayScene("example-"+e.ID, []byte(e.Diag.Example), code, nil); !res.Started {
why = "does not load: " + res.Error
} else {
for _, d := range module.ValidateScene(pg.Game().Scene(), nil) {
found = found || d.Code == e.ID
}
if err := pg.Game().Step(tryFrames); err != nil {
why = "stops the engine: " + err.Error()
}
}
poll := pg.Poll()
for _, f := range poll.Faults {
found = found || f.Code == e.ID
}
for _, l := range poll.Log {
found = found || strings.Contains(l.Text, e.ID)
}
switch {
case why != "":
fmt.Fprintf(w, "%s: error: example %s %s\n", e.ID, e.Diag.ExampleFile, why)
bad++
case !found:
fmt.Fprintf(w, "%s: error: example of %s does not produce %s\n", e.ID, e.ID, e.ID)
bad++
}
}
pg.Stop()
return bad
}
+3
View File
@@ -76,6 +76,9 @@ func (e *Env) Check(strict bool) int {
if CheckTry(reg, e.Stdout) > 0 && code == 0 { if CheckTry(reg, e.Stdout) > 0 && code == 0 {
code = 1 code = 1
} }
if CheckExamples(reg, e.Stdout) > 0 && code == 0 {
code = 1
}
return code return code
} }
+13
View File
@@ -19,6 +19,7 @@ type request struct {
Component string `json:"component"` Component string `json:"component"`
Field string `json:"field"` Field string `json:"field"`
Value float64 `json:"value"` Value float64 `json:"value"`
Node string `json:"node"`
} }
type Reply struct { type Reply struct {
@@ -27,6 +28,7 @@ type Reply struct {
Error string `json:"error,omitempty"` Error string `json:"error,omitempty"`
State *docsession.State `json:"state,omitempty"` State *docsession.State `json:"state,omitempty"`
Log []Line `json:"log,omitempty"` Log []Line `json:"log,omitempty"`
Pose []float64 `json:"pose,omitempty"`
} }
func (a *App) Call(method string, payload []byte) Reply { func (a *App) Call(method string, payload []byte) Reply {
@@ -64,6 +66,17 @@ func (a *App) Call(method string, payload []byte) Reply {
case "state": case "state":
st := s.State() st := s.State()
return Reply{State: &st} return Reply{State: &st}
case "pose":
sc := s.Controller().Scene()
if sc == nil {
return Reply{Error: "the scene is not running"}
}
h := sc.Find(sc.Root(), req.Node)
if h.IsZero() || !sc.IsAlive(h) {
return Reply{Error: "no node " + strconv.Quote(req.Node)}
}
p := sc.WorldPosition(h)
return Reply{Pose: []float64{float64(p.X), float64(p.Y)}}
case "log": case "log":
out := Reply{Log: a.lines} out := Reply{Log: a.lines}
a.lines = nil a.lines = nil
+1 -1
View File
@@ -179,7 +179,7 @@ func TestProfilerSectionsFollowPlay(t *testing.T) {
s.Step() s.Step()
} }
drawPanel(s, prof) drawPanel(s, prof)
expectSections(t, prof.Sections(), "Frame", "Memory", "Game", "Scripts", "Physics", "Audio") expectSections(t, prof.Sections(), "Frame", "Memory", "Game", "Scripts", "Physics", "Audio", "Camera", "Gameplay")
if _, err := ctx.Docs.Open("scenes/other.aescene"); err != nil { if _, err := ctx.Docs.Open("scenes/other.aescene"); err != nil {
t.Fatal(err) t.Fatal(err)
} }
+67 -1
View File
@@ -7,8 +7,10 @@ import (
"os" "os"
"path/filepath" "path/filepath"
"aego/core/ids"
"aego/editor/core/command" "aego/editor/core/command"
"aego/editor/core/context" "aego/editor/core/context"
"aego/editor/core/vectors"
"aego/editor/core/workspace" "aego/editor/core/workspace"
"aego/editor/panels/gameview" "aego/editor/panels/gameview"
"aego/editor/shell" "aego/editor/shell"
@@ -56,7 +58,60 @@ func (s *Session) shots(dir string) error {
} }
return selectNamed(ctx, "Player") return selectNamed(ctx, "Player")
}}, }},
{name: "hitbox-gizmo", frames: 60, setup: func(s *Session) error {
sc := ctx.Scene()
var span []ids.NodeID
for _, n := range []string{"EnemyLeft", "PatrolA1", "PatrolB1"} {
span = append(span, sc.ID(sc.Find(sc.Root(), n)))
}
ctx.Select(span...)
if err := ctx.Commands.Run(command.SceneFrame); err != nil {
return err
}
for i := 0; i < 30; i++ {
s.Step()
}
return selectNamed(ctx, "EnemyLeft")
}},
{name: "camera-follow", frames: 60, setup: func(s *Session) error {
sc := ctx.Scene()
ctx.Select(sc.ID(sc.Find(sc.Root(), "Camera")), sc.ID(sc.Find(sc.Root(), "Player")))
if err := ctx.Commands.Run(command.SceneFrame); err != nil {
return err
}
for i := 0; i < 30; i++ {
s.Step()
}
return selectNamed(ctx, "Camera")
}},
{name: "camera-zone", frames: 60, setup: func(s *Session) error {
sc := ctx.Scene()
ctx.Select(sc.ID(sc.Find(sc.Root(), "ArenaZone")), sc.ID(sc.Find(sc.Root(), "PatrolA2")), sc.ID(sc.Find(sc.Root(), "PatrolB2")), sc.ID(sc.Find(sc.Root(), "GroundRight")))
if err := ctx.Commands.Run(command.SceneFrame); err != nil {
return err
}
for i := 0; i < 30; i++ {
s.Step()
}
return selectNamed(ctx, "ArenaZone")
}},
{name: "clip-inspector", frames: 60, setup: func(s *Session) error {
id, ok := s.Pipeline.Lookup("assets/audio/music.ogg")
if !ok {
return fmt.Errorf("no assets/audio/music.ogg")
}
s.App.Data().Inspect(id)
return nil
}},
{name: "add-required", frames: 30, setup: func(s *Session) error {
if err := selectNamed(ctx, "PatrolA1"); err != nil {
return err
}
s.App.Inspector().OpenAdd("follow")
return nil
}},
{name: "tags", frames: 60, setup: func(s *Session) error { {name: "tags", frames: 60, setup: func(s *Session) error {
ctx.UI.CloseAllPopups()
return selectNamed(ctx, "Player") return selectNamed(ctx, "Player")
}}, }},
{name: "prefab", frames: 60, setup: func(s *Session) error { {name: "prefab", frames: 60, setup: func(s *Session) error {
@@ -83,12 +138,23 @@ func (s *Session) shots(dir string) error {
scene() scene()
return ctx.Commands.Run(command.PlayStart) return ctx.Commands.Run(command.PlayStart)
}}, }},
{name: "motion-play", frames: 30, setup: func(s *Session) error {
s.App.Workspace().Show(workspace.Inspector)
s.App.Inspector().ScrollTo("gameplay.Motion2D")
return selectNamed(ctx, "Player")
}},
{name: "mixer", frames: 120, setup: func(s *Session) error {
s.App.Workspace().Switch(workspace.Audio)
s.App.Workspace().Show(workspace.Mixer)
return nil
}},
{name: "physics-debug", frames: 30, setup: func(s *Session) error { {name: "physics-debug", frames: 30, setup: func(s *Session) error {
s.App.Workspace().Switch(workspace.Design)
ctx.Overlay.Set("physics.debug.contacts", true) ctx.Overlay.Set("physics.debug.contacts", true)
return ctx.Commands.Run(gameview.CommandOverlays) return ctx.Commands.Run(gameview.CommandOverlays)
}}, }},
{name: "demo", frames: 60, inset: 2, bottom: 28, setup: func(s *Session) error { {name: "demo", frames: 60, inset: 2, bottom: 28, setup: func(s *Session) error {
for _, f := range []string{"physics.debug", "physics.debug.shapes", "physics.debug.contacts", "physics.debug.joints"} { for _, f := range []string{gameview.CommandOverlays, vectors.CommandToggle} {
ctx.Overlay.Set(f, false) ctx.Overlay.Set(f, false)
} }
return ctx.Commands.Run(shell.CommandFullscreenPlay) return ctx.Commands.Run(shell.CommandFullscreenPlay)
-1
View File
@@ -26,7 +26,6 @@ canvas { display: block; width: 100%; height: 100%; outline: none; touch-action:
#mute .off, #mute.muted .on { display: none; } #mute .off, #mute.muted .on { display: none; }
#mute.muted .off { display: inline; } #mute.muted .off { display: inline; }
</style> </style>
<link rel="preload" href="game.wasm?v={{.Build}}" as="fetch" type="application/wasm" crossorigin>
</head> </head>
<body> <body>
<canvas id="game" data-aego tabindex="0" aria-label="{{.Title}}"></canvas> <canvas id="game" data-aego tabindex="0" aria-label="{{.Title}}"></canvas>
File diff suppressed because it is too large Load Diff
+5
View File
@@ -198,6 +198,11 @@ func (g *Game) Engine() *engine.Engine {
return g.e return g.e
} }
// Scene is the scene Play loaded, nil before the first Play or after Stop.
func (g *Game) Scene() *scene.Scene {
return g.scene
}
func (g *Game) Play(name string, src []byte, mods []*bytecode.Module) error { func (g *Game) Play(name string, src []byte, mods []*bytecode.Module) error {
g.Stop() g.Stop()
rt := scriptruntime.New(scriptruntime.Options{Bindings: g.reg, Schema: g.types.Schema(), Log: g.log, VM: playmods.SandboxVM()}) rt := scriptruntime.New(scriptruntime.Options{Bindings: g.reg, Schema: g.types.Schema(), Log: g.log, VM: playmods.SandboxVM()})
+29
View File
@@ -9,6 +9,10 @@ import (
"aego/app/agent" "aego/app/agent"
"aego/core/log" "aego/core/log"
"aego/core/rewind" "aego/core/rewind"
"aego/engine/recorder"
"aego/modules/audio"
"aego/modules/camera"
"aego/modules/gameplay"
"aego/project" "aego/project"
"aego/sdk" "aego/sdk"
) )
@@ -45,6 +49,7 @@ func AgentRunner(mods ...sdk.Module) agent.Runner {
} }
sum, _, _ := WorldHash(a.Engine.MainWorld(), rewind.NewHasher()) sum, _, _ := WorldHash(a.Engine.MainWorld(), rewind.NewHasher())
rep.Hash = hex.EncodeToString(sum[:]) rep.Hash = hex.EncodeToString(sum[:])
rep.Counters = counters(a)
a.Close() a.Close()
rep.Log = logLines(buf.String()) rep.Log = logLines(buf.String())
return rep, nil return rep, nil
@@ -63,3 +68,27 @@ func logLines(s string) []string {
} }
return out return out
} }
// counters sums what the modules counted during the run, for scene run and run_headless.
func counters(a *App) map[string]uint64 {
out := map[string]uint64{}
w := a.Engine.MainWorld()
if s := gameplay.Of(w); s != nil {
st := s.Stats()
out["gameplay.steps"], out["gameplay.casts"], out["gameplay.hits"] = st.Steps, st.Casts, st.Hits
out["gameplay.deaths"], out["gameplay.respawns"], out["gameplay.pickups"] = st.Deaths, st.Respawns, st.Pickups
}
if c := camera.Of(w); c != nil {
c.Outputs(func(camera.OutputInfo) { out["camera.outputs"]++ })
}
if m := audio.ModuleOf(a.Engine); m != nil {
c, st := m.Counts(), m.Stats()
out["audio.finished"], out["audio.stolen"], out["audio.rejected"], out["audio.starved"] = c.Finished, c.Stolen, c.Rejected, c.Starved
out["audio.underruns"] = st.Underruns
}
if r := w.Recorder; r != nil {
counts := r.Counts()
out["events.audio"], out["events.gameplay"] = counts[recorder.Audio], counts[recorder.Gameplay]
}
return out
}
+1
View File
@@ -80,6 +80,7 @@ type bus struct {
target float32 target float32
delta float32 delta float32
ramp int ramp int
live bool
acc []float32 acc []float32
peak atomic.Uint32 peak atomic.Uint32
rms atomic.Uint32 rms atomic.Uint32
+84
View File
@@ -441,3 +441,87 @@ func TestVoicePositionAndKill(t *testing.T) {
t.Fatalf("kill: %+v, live %v", ev, m.Live(id)) t.Fatalf("kill: %+v, live %v", ev, m.Live(id))
} }
} }
func directPair(tb testing.TB, mem *Memory, loop bool) (*Mixer, voice, voice) {
m := newMixer(tb)
m.Play(PlayParams{Memory: mem, Gain: 0.7, Pan: 0.3, Loop: loop, FadeIn: 0.005})
buf := make([]float32, 64*2)
m.Mix(buf)
for i := range m.voices {
if m.voices[i].state == voicePlaying {
return m, m.voices[i], m.voices[i]
}
}
tb.Fatal("no playing voice")
return nil, voice{}, voice{}
}
// The direct path for pitch 1 gives the same samples, position, gain and end as Hermite, through fades, loops and the stop ramp.
func TestDirectPathMatchesHermite(t *testing.T) {
for _, ch := range []int{1, 2} {
for _, loop := range []bool{false, true} {
mem := sine(440, rate/20, ch, 0.5)
if loop {
mem.LoopStart, mem.LoopEnd = 100, mem.Frames()-50
}
m, a, b := directPair(t, mem, loop)
if b.step != 1 {
t.Fatalf("step %v, the direct path needs 1", b.step)
}
const n = 256
accA, accB := make([]float32, n*2), make([]float32, n*2)
for block := 0; block < 40; block++ {
if block == 20 {
a.rampTo(0, 300)
b.rampTo(0, 300)
a.stopping, b.stopping = true, true
}
clear(accA)
clear(accB)
da := m.renderMemory(&a, accA, n)
db := m.renderMemoryDirect(&b, accB, n)
if da != db || a.pos != b.pos || a.gain != b.gain {
t.Fatalf("ch=%d loop=%v block %d: done %v/%v pos %v/%v gain %v/%v", ch, loop, block, da, db, a.pos, b.pos, a.gain, b.gain)
}
for i := range accA {
if accA[i] != accB[i] {
t.Fatalf("ch=%d loop=%v block %d sample %d: %v != %v", ch, loop, block, i, accA[i], accB[i])
}
}
if da {
break
}
}
}
}
}
func loadedPitch1(tb testing.TB) (*Mixer, []float32) {
m := newMixer(tb)
mem := sine(440, rate/10, 1, 0.5)
for i := 0; i < 64; i++ {
m.Play(PlayParams{Memory: mem, Gain: 0.1, Pan: float32(i%3 - 1), Pitch: 1, Loop: true})
}
buf := make([]float32, 512*2)
m.Mix(buf)
if m.Active() != 64 {
tb.Fatalf("%d active voices", m.Active())
}
return m, buf
}
func TestMixPitch1Allocs(t *testing.T) {
m, buf := loadedPitch1(t)
if n := testing.AllocsPerRun(200, func() { m.Mix(buf) }); n != 0 {
t.Fatalf("Mix allocates %v times per call", n)
}
}
func BenchmarkMix64Pitch1(b *testing.B) {
m, buf := loadedPitch1(b)
b.ReportAllocs()
b.ResetTimer()
for b.Loop() {
m.Mix(buf)
}
}
+93 -3
View File
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -141,7 +141,7 @@ func (p *Pump) Start() {
func (p *Pump) run(stop, done chan struct{}) { func (p *Pump) run(stop, done chan struct{}) {
defer close(done) defer close(done)
period := time.Duration(float64(p.cfg.Block) / float64(p.cfg.SampleRate) / 2 * float64(time.Second)) period := time.Duration(float64(p.cfg.Block*p.cfg.Target) / float64(p.cfg.SampleRate) / 6 * float64(time.Second))
t := time.NewTicker(max(period, time.Millisecond)) t := time.NewTicker(max(period, time.Millisecond))
defer t.Stop() defer t.Stop()
for { for {
+30
View File
@@ -102,3 +102,33 @@ func TestAgentSceneTreeJSON(t *testing.T) {
t.Fatalf("output %v:\n%s", err, out) t.Fatalf("output %v:\n%s", err, out)
} }
} }
// The top-down example needs no native module, so the CLI can run it from a copy.
func TestAgentSceneRunCounters(t *testing.T) {
dir := copyProject(t, "topdown")
r, w, err := os.Pipe()
if err != nil {
t.Fatal(err)
}
stdout := os.Stdout
os.Stdout = w
code := dispatch([]string{"scene", "run", "scenes/main.aescene", "--frames", "300", "--json", "--project", dir})
os.Stdout = stdout
w.Close()
out, _ := io.ReadAll(r)
if code != 0 {
t.Fatalf("exit %d:\n%s", code, out)
}
var v struct {
Value struct {
Counters map[string]uint64 `json:"counters"`
} `json:"value"`
}
if err := json.Unmarshal(out, &v); err != nil {
t.Fatalf("output %v:\n%s", err, out)
}
c := v.Value.Counters
if c["gameplay.steps"] == 0 || c["camera.outputs"] != 1 {
t.Fatalf("counters %v, want gameplay steps and one camera output", c)
}
}
Binary file not shown.
+37
View File
@@ -0,0 +1,37 @@
# Contributing
## Build and run
```sh
bash tools/bootstrap-native.sh
make cli
.cache/bin/aego edit examples/platformer
```
`make res` regenerates icons, previews and ES shaders; `make golden-update` rewrites golden images after an intended UI change.
## Check levels
| Level | When | Command |
|---|---|---|
| 1 | after an edit | `make quick`: build and short tests of the packages your change touches and everything that imports them |
| 2 | before a commit | `make affected`, plus `make check-camera`, `check-audio`, `check-gameplay`, `check-mutate`, `check-editor`, `check-web` or `check-docs` for the areas you touched, and `make golden` after UI changes |
| 3 | before a push or a tag | `make ci` |
`tools/affected.sh [base]` lists the affected packages (default base `origin/master`, uncommitted files included). The CI server always runs the full `make ci`.
## Rules for engine code
- **Modules talk through contracts.** A module never imports another module: shared types and services live in `contracts/` (`physics2d`, `camera2d`, `scriptcall`, `signals`, `debugdraw`, …). `tools/depcheck` enforces the import rules; an exception goes into `tools/depcheck/exceptions.txt` with its file and reason.
- **Kernel stays neutral.** Kernel, editor and `sdk` never name a built-in module, its components or its diagnostic codes in string literals; names come from the module catalog.
- **Every component has a Try it scene.** It lives at `res/docs/try/<Component>.aescene` (with `<Component>.aes` and prefabs next to it when needed), shows the component's own effect and runs without warnings; `aego docs check` fails without it.
- **Internal state is not a component.** Controller state lives in unexported fields of the component it belongs to or in a world service. A component that exists only to carry state for a service is registered `Hidden`: it is not in Create, Add Component, Try it or the docs.
- **Requirements add, they do not block.** Declare `Requires`; Add Component, `scene add-comp`, Paste and presets add the missing components in the same undo step.
- **Every diagnostic code has a page with an example.** Component codes (`CAM`, `AUD`, `GMP`, `PHY`, …) also have an example scene that produces the code; `aego docs check` fails without one. Asset codes say `scope: asset`, codes that only an edit during Play produces say `scope: play`.
- **Nodes are labelled, not pathed.** UI shows nodes with `props.NodeLabel` (icon and name, the path in the tooltip).
- **Editor edits go through history.** Every edit is a history command, normally `commands.Mutation`, so Undo, the Play changes diff and agents see it.
- **Hot paths do not allocate.** Systems, mixers and controllers allocate nothing per frame; add `testing.AllocsPerRun` checks and a benchmark next to new hot code.
## Commits
One commit per sub-stage, named `Stage <n><x>: <what>`; decisions go into `ARCHITECTURE.md` as `D<number>` in the same commit.
+13 -1
View File
@@ -97,6 +97,16 @@ sdk.Component[Wind](r, sdk.Name("weather.Wind")).
`engine/problems` collects `sdk.Diagnostic{Owner, Code, Severity, Message, Subject, BlocksPlay}` from sources with a revision; the service rebuilds the list only when a revision changes. `sdk.Diagnostics(ctx)` in `Init` returns the service; a module adds runtime diagnostics as a `sdk.ProblemSource` from `AttachWorld` and removes it in `DetachWorld`. The Problems panel shows them with the owner as category; an error with `BlocksPlay` stops Play (D210). `engine/problems` collects `sdk.Diagnostic{Owner, Code, Severity, Message, Subject, BlocksPlay}` from sources with a revision; the service rebuilds the list only when a revision changes. `sdk.Diagnostics(ctx)` in `Init` returns the service; a module adds runtime diagnostics as a `sdk.ProblemSource` from `AttachWorld` and removes it in `DetachWorld`. The Problems panel shows them with the owner as category; an error with `BlocksPlay` stops Play (D210).
Every code a module reports is listed in `Info.Codes` and has a page `res/docs/diagnostics/<CODE>.md` with front matter `code`, `title`, `severity` (`error`, `warning` or `info`) and either `example: <CODE>.aescene`, a scene next to the page that produces the code (with `<CODE>.aes` next to it when a script has to act, as for PHY007), `scope: asset` for codes that come from importing or checking an asset, or `scope: play` for codes that only an edit during Play produces (PHY006). `aego docs check` fails on a declared code without a page, a page whose code is not declared, a component code without an example, and an example that does not produce its code after `module.ValidateScene` and 60 headless frames. The pages appear under Reference → Diagnostics next to the script codes (D146, D316).
### Contracts between modules
A module never imports another module. What two modules share lives in `contracts/<name>` as plain types, a service ID and an interface; the provider registers the service in its world, the consumer looks it up with `engine.ServiceOf` and works without it.
- **Provisions.** A value handed over at load time, keyed by a kind. `camera2d.AccessibilityKind` (`"camera2d.accessibility"`) carries the IDs of the Screen Shake and Reduce Motion settings: the settings module provides them with `r.Provide(camera2d.AccessibilityKind, camera2d.Accessibility{...})`, the camera module reads `ctx.Provided(camera2d.AccessibilityKind)` in `Init` and scales shake by them every frame.
- **`physics2d.Queries`** (`physics2d.ServiceID`). Ray, point, circle and box queries; shape casts `CastCircle`, `CastBox`, `CastCapsule` and `CastBody`, which sweeps every non-trigger collider of a body and returns the first hit with its fraction, normal and, when the shapes already overlap, `Initial` and `Depth`; `Penetration` lists the overlaps of a body for depenetration; `BodyPose`, `BodyVelocity`, `MoveKinematic` (moves a kinematic body so contacts see its velocity), `Teleport`, `ApplyImpulse` and `Gravity`. `QueryFilter` selects layers and triggers; `SkipDynamic` ignores dynamic bodies, and `ExcludeNode` and `ExcludeBody` skip the caller's own collider or body. The gameplay controller is written only against this interface.
- **`scriptcall.Caller`** (`scriptcall.ServiceID`). `Method(node, name, params)` finds a plain method by name in the scripts on a node and returns a `Ref`; `Call(&ref, args)` runs it. A hot reload starts a new `Generation`, which makes every older `Ref` stale: look the method up again when `Ref.Gen` differs. The State Machine finds its hooks this way.
### Resources ### Resources
Module icons are named `<owner>.*` or `cat.<owner>`; a clash with the engine atlas or another module is a build error. Built-in modules list their icon sources through `IconDir()`. Docs registered with `Registry.Docs` carry the module as owner and are left out of runtime builds (D211). Module icons are named `<owner>.*` or `cat.<owner>`; a clash with the engine atlas or another module is a build error. Built-in modules list their icon sources through `IconDir()`. Docs registered with `Registry.Docs` carry the module as owner and are left out of runtime builds (D211).
@@ -169,4 +179,6 @@ A panel gets a fresh `Frame` every draw (`UI`, drag and drop, time, focus). Anyt
A module can give any of its components a live example on the documentation site: put a scene in `res/docs/try/<Component>.aescene`, named after the last part of the component ID (`try/Body2D.aescene` for `physics.Body2D`). The page of that component gets a Try it block that runs the scene in the browser with the Inspector, selecting the first node that has the component; a guide page can show a scene with `try: try/name.aescene` and `try_select: module.Component` in its front matter. A module can give any of its components a live example on the documentation site: put a scene in `res/docs/try/<Component>.aescene`, named after the last part of the component ID (`try/Body2D.aescene` for `physics.Body2D`). The page of that component gets a Try it block that runs the scene in the browser with the Inspector, selecting the first node that has the component; a guide page can show a scene with `try: try/name.aescene` and `try_select: module.Component` in its front matter.
Try scenes run on the sandbox catalog (core, input, render2d, scripting, physics, debug) with builtin assets only and no scripts. `aego docs check` loads each one, runs it for 60 frames and fails on a load error, a warning or a fault, and on a scene of a module outside the sandbox. Keep the scene to what the component needs, put the documented node first, and add a camera. Try scenes run on the docs runtime catalog (core, input, render2d, render3d, scripting, physics, debug, tween, cameras, gameplay, spawn, savegame and audio) with builtin assets only. A script `<Component>.aes` and prefabs `<Component>.<name>.aeprefab` (with their `.meta`) next to the scene are compiled and mounted with it. `aego docs check` loads each one, runs it for 60 frames and fails on a load error, a warning or a fault, and on a scene of a module outside the catalog. Keep the scene to what the component needs, put the documented node first, and add a camera.
Every visible component needs one. A component registered `Hidden`, which only carries state for a service, has none and is left out of Create, Add Component, Try it and the docs. The rules for engine code, including these, are in [contributing.md](contributing.md).
+4
View File
@@ -61,8 +61,10 @@ Sources are `<id>.svg` files in `engine/res/icons/src` and `modules/<id>/res/ico
| `edit.paste` | engine | 16 | Paste (nodes, assets, inspector field) | ok | | `edit.paste` | engine | 16 | Paste (nodes, assets, inspector field) | ok |
| `edit.rename` | engine | 16 | Rename (nodes, assets, workspace) | ok | | `edit.rename` | engine | 16 | Rename (nodes, assets, workspace) | ok |
| `edit.select_all` | engine | 16 | Edit → Select All | ok | | `edit.select_all` | engine | 16 | Edit → Select All | ok |
| `file.audio` | engine | 16 | Documentation: sound clips page | ok |
| `file.autosave` | engine | 16 | File → Autosave Scripts | ok | | `file.autosave` | engine | 16 | File → Autosave Scripts | ok |
| `file.data` | engine | 24 | Assets: data asset tiles | ok | | `file.data` | engine | 24 | Assets: data asset tiles | ok |
| `file.download` | engine | 16 | Documentation: Install and run page | ok |
| `file.folder` | engine | 24 | Assets: folders | ok | | `file.folder` | engine | 24 | Assets: folders | ok |
| `file.mesh` | engine | 24 | Assets: mesh tiles | ok | | `file.mesh` | engine | 24 | Assets: mesh tiles | ok |
| `file.open` | engine | 16 | Assets menu: Open | ok | | `file.open` | engine | 16 | Assets menu: Open | ok |
@@ -134,6 +136,7 @@ Sources are `<id>.svg` files in `engine/res/icons/src` and `modules/<id>/res/ico
| `prefab.variant` | engine | 16 | Assets menu: Create Variant | ok | | `prefab.variant` | engine | 16 | Assets menu: Create Variant | ok |
| `shape.cube` | engine | 16 | template render3d.cube | ok | | `shape.cube` | engine | 16 | template render3d.cube | ok |
| `shape.cylinder` | engine | 16 | template render3d.cylinder | ok | | `shape.cylinder` | engine | 16 | template render3d.cylinder | ok |
| `shape.dice` | engine | 16 | Documentation: random numbers module | ok |
| `shape.plane` | engine | 16 | template render3d.plane | ok | | `shape.plane` | engine | 16 | template render3d.plane | ok |
| `shape.sphere` | engine | 16 | template render3d.sphere | ok | | `shape.sphere` | engine | 16 | template render3d.sphere | ok |
| `status.busy` | engine | 14 | Task Center: running task | ok | | `status.busy` | engine | 14 | Task Center: running task | ok |
@@ -151,6 +154,7 @@ Sources are `<id>.svg` files in `engine/res/icons/src` and `modules/<id>/res/ico
| `ui.chevron_down` | engine | 16 | trees, combos and drop-downs | ok | | `ui.chevron_down` | engine | 16 | trees, combos and drop-downs | ok |
| `ui.chevron_right` | engine | 16 | trees and submenus | ok | | `ui.chevron_right` | engine | 16 | trees and submenus | ok |
| `ui.close` | engine | 16 | tabs, chips and dialogs | ok | | `ui.close` | engine | 16 | tabs, chips and dialogs | ok |
| `ui.curve` | engine | 16 | Documentation: curves module | ok |
| `ui.lock` | engine | 16 | Inspector: locked | ok | | `ui.lock` | engine | 16 | Inspector: locked | ok |
| `ui.minus` | engine | 16 | list editors: remove | ok | | `ui.minus` | engine | 16 | list editors: remove | ok |
| `ui.more` | engine | 16 | card menus | ok | | `ui.more` | engine | 16 | card menus | ok |
Binary file not shown.

After

Width:  |  Height:  |  Size: 121 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 150 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 145 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 118 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 28 KiB

After

Width:  |  Height:  |  Size: 28 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 133 KiB

After

Width:  |  Height:  |  Size: 142 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 131 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 152 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 160 KiB

After

Width:  |  Height:  |  Size: 154 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 159 KiB

After

Width:  |  Height:  |  Size: 162 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 176 KiB

After

Width:  |  Height:  |  Size: 94 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 141 KiB

After

Width:  |  Height:  |  Size: 147 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 203 KiB

After

Width:  |  Height:  |  Size: 207 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 154 KiB

After

Width:  |  Height:  |  Size: 160 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 156 KiB

After

Width:  |  Height:  |  Size: 162 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 133 KiB

After

Width:  |  Height:  |  Size: 140 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 122 KiB

After

Width:  |  Height:  |  Size: 123 KiB

+6 -4
View File
@@ -39,14 +39,16 @@ const (
) )
type Env struct { type Env struct {
Clip context.DataClipboard Clip context.DataClipboard
Types *scene.Types Types *scene.Types
Res asset.Resolver Res asset.Resolver
OnAdd func(*schema.TypeDescriptor) func(*scene.Scene, scene.NodeHandle) OnAdd func(*schema.TypeDescriptor) func(*scene.Scene, scene.NodeHandle)
Notify func(string)
} }
func EnvOf(ctx *context.Editor) Env { func EnvOf(ctx *context.Editor) Env {
e := Env{Clip: ctx.Clipboard, Types: ctx.Types, OnAdd: ctx.OnAdd} e := Env{Clip: ctx.Clipboard, Types: ctx.Types, OnAdd: ctx.OnAdd}
e.Notify = func(text string) { ctx.Notify(context.LevelWarn, text) }
if ctx.Loader != nil { if ctx.Loader != nil {
e.Res = ctx.Loader e.Res = ctx.Loader
} }
+77
View File
@@ -0,0 +1,77 @@
package clipboard
import (
"testing"
"aego/core/ids"
"aego/core/log"
"aego/editor/core/command"
"aego/editor/core/context"
"aego/editor/core/document"
"aego/editor/core/selection"
"aego/engine/module"
"aego/scene"
"aego/scene/sceneio"
"aego/schema"
)
type reqBase struct {
A float32 `aego:"a"`
}
type reqNeeds struct {
B float32 `aego:"b"`
}
type reqModule struct{}
func (reqModule) Info() module.Info { return module.Info{ID: "reqtest"} }
func (reqModule) Register(r *module.Registry) error {
if err := module.Component[reqBase](r, schema.Name("reqtest.Base")).Err(); err != nil {
return err
}
return module.Component[reqNeeds](r, schema.Name("reqtest.Needs")).Requires("reqtest.Base").Err()
}
// Pasting a component adds what it requires in the same undo step (D144).
func TestPasteAddsRequiredComponents(t *testing.T) {
types := scene.NewTypes(schema.NewRegistry())
if err := sceneio.RegisterUnknown(types); err != nil {
t.Fatal(err)
}
if _, err := module.Load(types, nil, reqModule{}); err != nil {
t.Fatal(err)
}
if err := types.Schema().Freeze(); err != nil {
t.Fatal(err)
}
s := scene.New(types, nil, scene.Options{})
src := s.Create(s.Root(), "Src")
dst := s.Create(s.Root(), "Dst")
scene.Add[reqBase](s, src)
scene.Add[reqNeeds](s, src).B = 4
s.Flush()
m := document.NewManager(document.Options{Root: t.TempDir(), Types: types, Log: log.Nop()})
d := m.New("scenes/r.aescene", s)
ctx := &context.Editor{Types: types, Docs: m, Selection: selection.New(), Commands: command.New(), Clipboard: &fakeClip{}}
needs, _ := types.Schema().ByName("reqtest.Needs")
if err := CopyComponent(ctx, s, s.ID(src), needs.ID); err != nil {
t.Fatal(err)
}
if err := PasteComponent(ctx, d, []ids.NodeID{s.ID(dst)}); err != nil {
t.Fatal(err)
}
if !scene.Has[reqBase](s, dst) || !scene.Has[reqNeeds](s, dst) {
t.Fatal("paste did not add the required Base")
}
if n, _ := scene.Get[reqNeeds](s, dst); n.B != 4 {
t.Fatalf("pasted value %v", n.B)
}
if err := d.History.Undo(); err != nil {
t.Fatal(err)
}
if scene.Has[reqBase](s, dst) || scene.Has[reqNeeds](s, dst) {
t.Fatal("one Undo must remove both")
}
}
+13
View File
@@ -10,6 +10,7 @@ import (
"aego/editor/core/history" "aego/editor/core/history"
"aego/editor/core/history/commands" "aego/editor/core/history/commands"
"aego/scene" "aego/scene"
"aego/scene/mutate"
"aego/scene/sceneio" "aego/scene/sceneio"
"aego/scene/scriptcomp" "aego/scene/scriptcomp"
"aego/schema" "aego/schema"
@@ -32,6 +33,18 @@ func (e Env) pasteInto(tx *history.Transaction, d *document.SceneDocument, nodes
if !s.Accepts(h, td.ID) { if !s.Accepts(h, td.ID) {
continue continue
} }
req, err := mutate.Required(s, td, h)
if err != nil {
if e.Notify != nil {
e.Notify(s.Name(h) + ": " + err.Error())
}
continue
}
for _, r := range req {
if err := tx.Exec(commands.NewMutation("Add "+r.FullName, env, commands.AddComp(s, n, r, nil))); err != nil {
return err
}
}
if err := tx.Exec(commands.NewMutation("Add "+td.FullName, env, commands.AddComp(s, n, td, values))); err != nil { if err := tx.Exec(commands.NewMutation("Add "+td.FullName, env, commands.AddComp(s, n, td, values))); err != nil {
return err return err
} }
+3
View File
@@ -30,6 +30,9 @@ type ProfilerSection struct {
Draw func() Draw func()
} }
// OverlayGame is the flag of Window → Game View Overlays; module overlays and debug channels in the Game View follow it.
const OverlayGame = "view.game.overlays"
type Overlays struct { type Overlays struct {
on map[string]bool on map[string]bool
Scale float32 Scale float32
+3 -26
View File
@@ -1,39 +1,16 @@
package gizmo package gizmo
import ( import (
"aego/core/errs" "aego/core/ids"
"aego/editor/core/history/commands"
"aego/editor/core/props" "aego/editor/core/props"
"aego/schema" "aego/schema"
) )
func SetProperty(e *EditCtx, t schema.TypeID, fd *schema.FieldDescriptor, v schema.Value) { func SetProperty(e *EditCtx, t schema.TypeID, fd *schema.FieldDescriptor, v schema.Value) {
if e.Err != nil || e.Tx == nil || fd == nil { if e.Err != nil || e.Tx == nil || fd == nil || e.Scene.Handle(e.Node).IsZero() {
return return
} }
h := e.Scene.Handle(e.Node) if err := props.New(e.Scene, nil).Set(e.Tx, []ids.NodeID{e.Node}, t, fd.ID, v); err != nil {
if h.IsZero() {
return
}
td, ok := e.Scene.Registry().ByID(t)
if !ok {
e.Err = errs.New(errs.SchemaUnknownType, "component type is not registered")
return
}
nv, err := props.Normalize(fd, v)
if err != nil {
e.Err = err
return
}
before, err := e.Scene.GetProperty(h, t, fd.ID)
if err != nil {
e.Err = err
return
}
if props.Equal(before, nv) {
return
}
if err := e.Tx.Exec(commands.SetField(e.Scene, e.Node, td, fd, nv, props.Label(fd))); err != nil {
e.Err = err e.Err = err
} }
} }
+4
View File
@@ -58,7 +58,9 @@ var Editor = []module.IconUse{
use("edit.paste", 16, "Paste (nodes, assets, inspector field)"), use("edit.paste", 16, "Paste (nodes, assets, inspector field)"),
use("edit.rename", 16, "Rename (nodes, assets, workspace)"), use("edit.rename", 16, "Rename (nodes, assets, workspace)"),
use("edit.select_all", 16, "Edit → Select All"), use("edit.select_all", 16, "Edit → Select All"),
use("file.audio", 16, "Documentation: sound clips page"),
use("file.autosave", 16, "File → Autosave Scripts"), use("file.autosave", 16, "File → Autosave Scripts"),
use("file.download", 16, "Documentation: Install and run page"),
use("file.data", 24, "Assets: data asset tiles"), use("file.data", 24, "Assets: data asset tiles"),
use("file.folder", 24, "Assets: folders"), use("file.folder", 24, "Assets: folders"),
use("file.mesh", 24, "Assets: mesh tiles"), use("file.mesh", 24, "Assets: mesh tiles"),
@@ -74,6 +76,8 @@ var Editor = []module.IconUse{
use("file.texture", 24, "Assets: texture tiles"), use("file.texture", 24, "Assets: texture tiles"),
use("file.unknown", 24, "Assets: tiles of other kinds"), use("file.unknown", 24, "Assets: tiles of other kinds"),
use("help.about", 16, "Help → About Aego"), use("help.about", 16, "Help → About Aego"),
use("shape.dice", 16, "Documentation: random numbers module"),
use("ui.curve", 16, "Documentation: curves module"),
use("help.book", 16, "Documentation tab"), use("help.book", 16, "Documentation tab"),
use("log.error", 16, "Console: errors"), use("log.error", 16, "Console: errors"),
use("log.info", 16, "Console: info"), use("log.info", 16, "Console: info"),
File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More