Scene exits, Back(), and the current/previous scene accessors
ci/woodpecker/push/woodpecker Pipeline was successful

A connection between two scenes had to be hand-built as a hotspot: an area,
a cursor, a GoTo, and a flag check written out again for every door. Scene
now carries Exits, and the engine expands each one into a hotspot.

- Exit{To, Label, Side, Area, Needs, Blocked, OnLook, OnTake} in scene.exit.go.
  With no Area an exit is an edge strip, sized as a fraction of Game.SceneArea()
  so a game whose HUD covers the foot of the window gets strips inside the
  painting. Game.ExitLook / Game.ExitTake supply the look and take responses
  once for the whole game, so the phrasing is not repeated per exit.
- Game.SceneHotspots(name) is the scene's own hotspots followed by its exits,
  cached per scene. Authored hotspots come first, so a painted thing beats the
  edge strip wherever the two overlap. HotspotAt and HotspotDebug read it.
- Game.CurrentScene() / PreviousScene(), both persisted in the save file. The
  engine tracked the current scene but exposed no accessor, so every game had
  to shadow it to know where it was.
- Back() returns to the previous scene — what an exit with an empty To binds
  to, for a scene reachable from several rooms whose way out is a direction
  rather than a place.
- Validate rejects an exit naming a scene nobody registered.

Generated hotspots are named ExitName(To) ("exit:street", "exit:back"), so the
location graph can be read straight back out of the registered scenes.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-08-30 00:09:20 +02:00
co-authored by Claude Opus 5
parent aa55f1166c
commit f9745e4266
7 changed files with 362 additions and 60 deletions
+17 -14
View File
@@ -15,14 +15,15 @@ const saveVersion = 1
// runtime mutable state lands here — managers, themes and assets are
// reconstructed by the domain's Build() on every launch.
type saveFile struct {
Version int `json:"version"`
Title string `json:"title"`
CurrentScene string `json:"current_scene"`
SelectedVerb string `json:"selected_verb"`
ActiveTheme string `json:"active_theme"`
Characters map[string]savedChar `json:"characters"`
Inventory savedInventory `json:"inventory"`
State savedState `json:"state"`
Version int `json:"version"`
Title string `json:"title"`
CurrentScene string `json:"current_scene"`
PreviousScene string `json:"previous_scene"`
SelectedVerb string `json:"selected_verb"`
ActiveTheme string `json:"active_theme"`
Characters map[string]savedChar `json:"characters"`
Inventory savedInventory `json:"inventory"`
State savedState `json:"state"`
}
type savedChar struct {
@@ -95,12 +96,13 @@ func (g *Game) Load(slot int) error {
func (g *Game) buildSave() saveFile {
sf := saveFile{
Version: saveVersion,
Title: g.Title,
CurrentScene: g.currentScene,
SelectedVerb: g.selectedVerb,
ActiveTheme: g.activeTheme,
Characters: make(map[string]savedChar, len(g.chars)),
Version: saveVersion,
Title: g.Title,
CurrentScene: g.currentScene,
PreviousScene: g.previousScene,
SelectedVerb: g.selectedVerb,
ActiveTheme: g.activeTheme,
Characters: make(map[string]savedChar, len(g.chars)),
Inventory: savedInventory{
Items: g.Inventory.Items(),
Selected: g.Inventory.Selected(),
@@ -142,6 +144,7 @@ func (g *Game) applySave(sf *saveFile) error {
g.flashTimer = 0
g.currentScene = sf.CurrentScene
g.previousScene = sf.PreviousScene
if sf.SelectedVerb != "" {
g.selectedVerb = sf.SelectedVerb
}