ci/woodpecker/push/ebitengine Pipeline was successful
The engine already had the registry the game was reimplementing: inkwell.Manager[T Named], and every entity type here is an alias of an engine struct, so they all carry GetName() already. manager.manager.go and manager.interface.go are gone; a category manager is now one call to inkwell.NewManager. registerAll goes with it — Each does the hand-off — and the selector writes its derived pins back with Set, which keeps the scene in place in the registration order. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
73 lines
1.3 KiB
Go
73 lines
1.3 KiB
Go
package inc
|
|
|
|
import (
|
|
"strings"
|
|
|
|
inkwell "git.teletypegames.org/engines/inkwell"
|
|
)
|
|
|
|
var exitToSelector = inkwell.Exit{
|
|
To: SceneSelector,
|
|
Label: "the rest of the city",
|
|
Side: inkwell.ExitNear,
|
|
}
|
|
|
|
func init() {
|
|
SceneManager.Register(Scene{
|
|
Name: SceneSelector,
|
|
Title: "SAN FRANCISCO",
|
|
Background: BgSelector,
|
|
Actors: []inkwell.SceneActor{},
|
|
Walkboxes: []inkwell.Polygon{},
|
|
})
|
|
}
|
|
|
|
func fillSelectorPins() {
|
|
selector, ok := SceneManager.Get(SceneSelector)
|
|
if !ok {
|
|
return
|
|
}
|
|
var exits []inkwell.Exit
|
|
for _, entity := range SceneManager.All() {
|
|
if !leadsToSelector(entity) {
|
|
continue
|
|
}
|
|
exits = append(exits, inkwell.Exit{
|
|
To: entity.Name,
|
|
Label: pinLabel(entity.Title),
|
|
Area: pin(len(exits)),
|
|
})
|
|
}
|
|
selector.Exits = exits
|
|
SceneManager.Set(selector)
|
|
}
|
|
|
|
func leadsToSelector(s Scene) bool {
|
|
for _, e := range s.Exits {
|
|
if e.To == SceneSelector {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|
|
|
|
const (
|
|
pinCols = 3
|
|
pinW = 192.0
|
|
pinH = 32.0
|
|
pinX = 16.0
|
|
pinY = 28.0
|
|
pinGapX = 204.0
|
|
pinGapY = 38.0
|
|
)
|
|
|
|
func pin(i int) inkwell.Shape {
|
|
col, row := i%pinCols, i/pinCols
|
|
return inkwell.Rect(pinX+float64(col)*pinGapX, pinY+float64(row)*pinGapY, pinW, pinH)
|
|
}
|
|
|
|
func pinLabel(title string) string {
|
|
name, _, _ := strings.Cut(title, " — ")
|
|
return name
|
|
}
|