Skip to content

DRAFT: Refactor game state#2235

Draft
wjt wants to merge 1 commit into
mainfrom
wjt/refactor-game-state
Draft

DRAFT: Refactor game state#2235
wjt wants to merge 1 commit into
mainfrom
wjt/refactor-game-state

Conversation

@wjt
Copy link
Copy Markdown
Member

@wjt wjt commented May 21, 2026

DRAFT: Refactor game state

GameState mixes the actual load/save logic with the state itself, and
also is based on a mixture of directly accessing the contents of a
ConfigFile object and fields of the GameState node.

Factor all the state itself out to a tree of Resource subclasses:

  • Global state
    • Player state
    • Quest state (nullable)
      • Quest-specific player state
    • Scene state

Replace the ConfigFile-based load/save logic with
ResourceLoader/ResourceSaver. This avoids writing bespoke serialisation
code & makes it easy to add new saved fields – drop an @export into the
appropriate state class – at the cost of tightly coupling the savegame
format to the game's internals.

#2016

GameState mixes the actual load/save logic with the state itself, and
also is based on a mixture of directly accessing the contents of a
ConfigFile object and fields of the GameState node.

Factor all the state itself out to a tree of Resource subclasses:

- Global state
  - Player state
  - Quest state (nullable)
    - Quest-specific player state
  - Scene state

Replace the ConfigFile-based load/save logic with
ResourceLoader/ResourceSaver. This avoids writing bespoke serialisation
code & makes it easy to add new saved fields – drop an @export into the
appropriate state class – at the cost of tightly coupling the savegame
format to the game's internals.

#2016
@github-actions
Copy link
Copy Markdown

Play this branch at https://play.threadbare.game/branches/endlessm/wjt/refactor-game-state/.

(This launches the game from the start, not directly at the change(s) in this pull request.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant