diff options
| author | historia <[not public]> | 2026-06-29 18:13:33 -0400 |
|---|---|---|
| committer | historia <[not public]> | 2026-06-29 18:13:33 -0400 |
| commit | 7d76673fa0707d204c7d084c8f90c8133c22a31a (patch) | |
| tree | 6fc832b9f3fde6ed455abb535f6e28b0e5db1fd9 /internal/game/core_object_def.go | |
| parent | feb80b7dde200d4121cd9f9c583a08f9869c5588 (diff) | |
| download | thehouseoficarus-7d76673fa0707d204c7d084c8f90c8133c22a31a.tar.gz | |
feat: migrated map (and bfs) to full 3D instead of individual 2D maps on different planes.
Diffstat (limited to 'internal/game/core_object_def.go')
| -rw-r--r-- | internal/game/core_object_def.go | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/internal/game/core_object_def.go b/internal/game/core_object_def.go new file mode 100644 index 0000000..6cf2464 --- /dev/null +++ b/internal/game/core_object_def.go @@ -0,0 +1,43 @@ +package game + +import "thehouseoficarus/internal/object" + +// resolveObjectDef returns the ObjectDef for a room object instance. File +// objects (the common case) resolve through the cached object store with no +// disk I/O on a hit, and a store miss is just a map lookup; only local objects +// — which never live in the store — fall through to a freshly-read room, so +// they keep live-edit semantics without slowing file-object lookups. defID is +// the ObjState DefID (a normalized name for local objects, a file id +// otherwise). +// +// Use this from display or generic-handling sites. Sites that look up a +// specific interactable behavior (gather/use-station/safespot/steal/etc.) may +// call ObjectStore.Load directly: local objects are guaranteed non-interactable +// and simply fall through those sites' existing error guards. +func (g *Game) resolveObjectDef(roomID int, defID string) (*object.ObjectDef, bool, error) { + def, err := g.ObjectStore.Load(defID) + if err == nil { + if room, rerr := g.World.LoadRoom(roomID); rerr == nil { + for i := range room.Objects { + ro := &room.Objects[i] + if ro.Local == nil && ro.ID == defID && ro.HiddenOverride { + copy := *def + copy.Hidden = true + return ©, false, nil + } + } + } + return def, false, nil + } + if room, rerr := g.World.LoadRoom(roomID); rerr == nil { + for i := range room.Objects { + ro := &room.Objects[i] + if ro.Local != nil && ro.ID == defID { + d := *ro.Local + d.ID = defID + return &d, true, nil + } + } + } + return nil, false, err +} |
