Wire the audio player in Run, not in NewGame
ci/woodpecker/push/woodpecker Pipeline was successful

AudioPlayer keeps the *AssetManager it is handed, so attaching it during
construction quietly pinned it to the manager NewGame happened to make. A
domain that assigns its own registry onto the Game — legal, the fields are
plain *Manager values — got a working image path and a silent audio one.

Run attaches instead, once the Game is final.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-30 10:36:13 +02:00
co-authored by Claude Opus 5
parent 08f15a7e3d
commit 39af65f3c9
3 changed files with 32 additions and 6 deletions
+24 -5
View File
@@ -275,6 +275,23 @@ selects `classic-scumm` as the active theme. Widgets are **not**
auto-registered — call `RegisterDefaultUI(g)` (or one of its siblings)
explicitly, or let `Run` install the default set if `UIManager` is empty.
The manager fields are ordinary `*Manager` values, so a domain that keeps its
own registries can **assign them onto the Game** instead of copying every entry
across:
```go
g := inkwell.NewGame("Real World", 640, 380)
g.SceneManager = mySceneManager
g.AssetManager = myAssetManager
```
Do it before `Run` — that is where the engine wires up the parts that hold a
registry directly, so whichever managers the `*Game` carries by then are the
ones that get used. Two of them are worth a second thought before replacing:
`ThemeManager` arrives holding the four presets and `classic-scumm` selected,
and `VerbManager` the four SCUMM verbs. Replacing either throws that away —
register into them instead unless that is what you want.
### 4.2 Lifecycle hooks
```go
@@ -1517,13 +1534,15 @@ func Run(g *Game) error // toplevel — same as g.Run()
`Run` does, in order:
1. `g.Validate()` — cross-check name references between managers.
2. If `UIManager` is empty, call `RegisterDefaultUI(g)`.
3. Place the start scene directly (no transition), bump
1. `g.Audio.attach(g.AssetManager)` — wire the audio player to whichever
asset registry the game is carrying by now.
2. `g.Validate()` — cross-check name references between managers.
3. If `UIManager` is empty, call `RegisterDefaultUI(g)`.
4. Place the start scene directly (no transition), bump
`State.NoteVisit`, position registered actors, kick off music.
4. Compose `Seq(scene.OnEnter, game.OnStart)` and queue it as the initial
5. Compose `Seq(scene.OnEnter, game.OnStart)` and queue it as the initial
action — the first script tick runs both in order.
5. `ebiten.SetWindowSize(Width*4, Height*4)`,
6. `ebiten.SetWindowSize(Width*4, Height*4)`,
`ebiten.SetWindowTitle(g.Title)`, then `ebiten.RunGame(&engine{g})`.
### 15.1 `engine.Update`