Skip to content

[Epic] Save/load: serialize and restore EcsWorld state #567

Description

@stormmuller

Goal

Let a game save and restore its EcsWorld. Storage backends already exist on dev: #722 added StorageBackend, the localStorage and memory backends, and createPersistentState for flat, typed records such as settings. What's missing is serializing the world itself, so every game still has to write its own save-game code.

Scope (suggested)

  • Serialize and deserialize EcsWorld state (entities and component data) to plain data. JSON is the obvious default for a browser engine.
  • Handle component data that refers to other entities, such as the parent link and joints that reference other bodies. Entities are generational handles, so their IDs need a stable remapping across save and load.
  • Decide how component data that isn't plain data is saved, for example anything holding a texture or other asset handle.
  • Write saves through the existing StorageBackend abstraction, so game code doesn't change when the backend does (localStorage, IndexedDB or a remote endpoint).
  • Version saved data and plan how to migrate it as a game's components change.

Why this is a milestone, not a single issue

Serializing arbitrary ECS state correctly, especially entity references and component data that isn't plain data, is a real design problem rather than a small utility. Expect sub-issues for core world serialization, reference remapping and versioning.

Acceptance criteria (top-level)

  • At least one storage backend (localStorage) is provided out of the box (#722)
  • An EcsWorld's state can be serialized and later restored, keeping relationships between entities
  • Saved data is versioned and can be migrated
  • Documented in documentation-site/docs/docs, with a demo showing save and load

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions