bevy-save-load
/bevy-save-load
Projektuje zapis stanu gry w Bevy 0.19 przez DynamicWorldBuilder, IoTaskPool i SettingsPlugin: stabilne ID, wersjonowane DTO i migracje, sumy kontrolne, zapisy atomowe, migawki z deltami i pamięć natywna lub przeglądarkowa.
- Autor
- chrisgliddon ↗
- Repozytorium
- bevy-skills ↗
- Licencja
- MIT
- Ostatnia zmiana repozytorium
- 25.08.2026
Ocena i bezpieczeństwo
- Pliki w paczce
- 4
- Skrypty
- 0
- Komentarze HTML
- 0
- Adresy URL w SKILL.md
- 2
Brak sygnałów. Repozytorium zmienione 25.08.2026, bez odwołań do wycofanych modeli i API.
MIT, otwarta: można używać i zmieniać, z zachowaniem informacji o autorze.
Co robi i kiedy
Projektuje zapis stanu gry w Bevy 0.19 przez DynamicWorldBuilder, IoTaskPool i SettingsPlugin: stabilne ID, wersjonowane DTO i migracje, sumy kontrolne, zapisy atomowe, migawki z deltami i pamięć natywna lub przeglądarkowa.
Oryginalny opis (EN)
Use when designing Bevy 0.19 persistence with `DynamicWorldBuilder`, `IoTaskPool`, or `SettingsPlugin`: stable IDs, versioned save DTOs/migrations, checksums and atomic writes, snapshots plus sparse deltas, native/browser storage, and safe ECS serialization boundaries.
Jak działa
- When to use this skill
- Canonical pattern
- Version the envelope and payload
- Stable IDs and two-pass load
- Storage is platform-specific
- Gotchas: world serialization boundary
- Choose the relevant deep dive
- Review checklist
- See also
Podgląd SKILL.md
---
name: bevy-save-load
description: "Use when designing Bevy 0.19 persistence with `DynamicWorldBuilder`, `IoTaskPool`, or `SettingsPlugin`: stable IDs, versioned save DTOs/migrations, checksums and atomic writes, snapshots plus sparse deltas, native/browser storage, and safe ECS serialization boundaries."
license: MIT
compatibility: opencode,claude-code,cursor
metadata:
tier: "2"
area: persistence
bevy_version: "0.19"
---
# Bevy 0.19 — save and load
## When to use this skill
- Gameplay state must remain loadable across ECS/content/code refactors.
- Large worlds need base snapshots, sparse deltas, compaction, and recovery.
- Native and browser builds need one asynchronous save-service contract.
- Reflected world serialization is being considered as a durable save format.
A save file is a long-lived product API. Serialize an explicit, versioned data model
and convert it to/from the live ECS. Runtime `Entity` values, dense palette indices,
query order, Rust enum discriminants, and reflected component layout are not stable
persistence identities.
## Canonical pattern
```rust
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Eq, Hash, PartialEq, Serialize)]
#[serde(transparent)]
struct SaveId(String);
#[derive(Debug, Deserialize, Serialize)]
struct SaveV3 {
world_seed: u64,
player: SaveId,
actors: Vec<ActorV3>,
}
#[derive(Debug, Deserialize, Serialize)]
struct ActorV3 {
id: SaveId,
archetype: String,
position: [f32; 3],
}
```
```text
live Bevy World
-> validate/capture one logical revision
-> current Save DTO with stable IDs
-> encode + checksum envelope
-> platform storage transaction
platform bytes
-> size/magic/checksum validation
-> decode declared old DTO
-> migrate one version at a time
-> validate current DTO
-> allocate entities, then resolve stable-ID references
-> rebuild derived/runtime-only state
```
Never partially mutate the active world while bytes are still being decoded or
migrated. Load into staging, validate, then commit or replace the gameplay world.
## Version the envelope and payload
Wrap encoded payload bytes with magic, format version, schema/content version,
payload length, codec/compression identifiers, and checksum. A checksum detects
accidental corruption; it does not prevent malicious tampering. Use authentication
or a signature when trust is part of the requirement.
Keep migrations as explicit `V1 -> V2 -> V3` pure functions. Test golden fixtures
from every supported version, including corrupt, truncated, duplicated-ID, unknown-ID,
and future-version files. Never deserialize an old version directly into today's
struct and hope Serde defaults reproduce old semantics.
## Stable IDs and two-pass load
Use immutable domain IDs for saved objects, content, quests, items, and voxel block
types. During load:
1. validate ID uniqueness and all size/count limits;
2. spawn/allocate objects and build `SaveId -> Entity` or stable-ID -> dense-palette
maps;
3. resolve relationships in a second pass;
4. reject or explicitly preserve unknown content according to policy;
5. rebuild caches, handles, physics state, tasks, diagnostics, and presentation.
## Storage is platform-specific
Native writes should use a temporary file in the destination directory, flush and
sync it as required, then atomically replace/rename the committed slot. Retain a
validated backup or two-slot generation when recovery matters. Do blocking file I/O
on `IoTaskPool`, and send the result back to the main world.
Browsers have no ordinary save-file path. Use IndexedDB for game saves and blobs;
small preferences may use local storage. Handle asynchronous completion, quota,
eviction, private modes, tab races, export/import, and page termination. A “save
complete” UI state requires committed storage confirmation.
Bevy 0.19's `SettingsPlugin` targets user settings with native/local-storage
backends; it is not a general campaign/world save schema.
## Gotchas: world serialization boundary
`bevy_world_serialization` and `DynamicWorldBuilder` can extract reflected entities
and resources with component/resource allow/deny filters. This is useful for authored
world assets, editor tooling, controlled snapshots, and short-lived internal formats.
It does not automatically create stable gameplay IDs, schema migrations, corruption
recovery, transactional storage, or compatibility across component refactors.
Use an explicit DTO for durable player saves. If a filtered `DynamicWorld` is nested
inside that format, version and migrate the surrounding contract and audit every
reflected type intentionally.
## Choose the relevant deep dive
| Problem | Read |
|---|---|
| DTO versions, migrations, stable IDs, validation and golden fixtures | [Schema, migrations, and IDs](references/schema-migrations-and-ids.md) |
| Atomic native writes, browser storage, async state and recovery | [Native and browser I/O](references/native-and-browser-io.md) |
| Full snapshots, sparse deltas, compaction, world-serialization boundary | [Snapshots, deltas, and world serialization](references/snapshots-deltas-and-world-serialization.md) |
## Review checklist
- Save schema types are separate from live ECS/runtime components.
- Every persistent reference uses a documented stable ID.
- Old versions migrate sequentially and have committed fixtures.
- Decoder limits untrusted lengths/counts before allocation/decompression.
- Native power-loss and browser quota/termination failures leave a recoverable slot.
- Success is reported only after the platform commit completes.
- Snapshot/delta generations cannot be mixed accidentally.
- Unknown future versions fail safely without overwriting the original.
## See also
- [`bevy-voxel-data`](../bevy-voxel-data/SKILL.md) — stable block IDs versus dense runtime palettes.
- [`bevy-testing`](../bevy-testing/SKILL.md) — deterministic migration and failure-path tests.
- [`bevy-assets`](../bevy-assets/SKILL.md) — stable asset paths/labels and asset readiness.
- [Bevy world serialization](https://docs.rs/bevy/0.19.0/bevy/world_serialization/index.html)
- [`DynamicWorldBuilder`](https://docs.rs/bevy/0.19.0/bevy/world_serialization/struct.DynamicWorldBuilder.html)
Pliki w paczce (4)
- SKILL.md 6 KB
- references/native-and-browser-io.md 3 KB
- references/schema-migrations-and-ids.md 3 KB
- references/snapshots-deltas-and-world-serialization.md 3 KB
Wersje
| Repozytorium | Wynik | Licencja |
|---|---|---|
| Ta strona · chrisgliddon/bevy-skills | 100 | MIT |
| ianpurton/disposable-heroes | 100 | MIT |
| thedivergentai/game-dev-agentic-skills | 100 | LGPL |
Migawka bazy z 13.11.2026 · wersja paczki 2a5d076780d1 (skrót SHA-256 całej paczki)
Pobrania w ostatnich 30 dniach: 0 · ranking
Zgłoś problem z tym skillem: szkodliwa treść, błędny opis albo prośba autora o usunięcie.
Podobne skille
- 100bevy-master
Stanowi centralny przewodnik po Bevy ECS od wersji 0.20: pomaga zacząć grę, wyznaczyć granice ECS i wybrać odpowiedni skill Bevy. - 100bevy
Wspiera projekty silnika gry Bevy: architekturę ECS, wzorce komponentów, kolejność systemów, interfejs UI i pułapki. - 100bevy-game-engine
Pomaga budować gry w silniku Bevy w Rust: ECS, renderowanie, wejście i zarządzanie zasobami, w tym encje, komponenty i systemy oraz gry 2D i 3D. - 100save-systems
Projektuje zapis i wczytywanie stanu gry: wybór serializowanych danych, formaty plików, sloty, atomowe zapisy odporne na awarie, wersjonowanie schematu, migracje i autosave. - 100save-systems
Projektuje zapis i wczytywanie stanu gry: co serializować, formaty, sloty, atomowe zapisy i migracje wersji. Przydaje się przy autosave i uszkodzonych plikach zapisu. - 100bevy-ecs-patterns
Pomaga w trudniejszych zagadnieniach Bevy ECS: złożone zapytania, harmonogram systemów, wykrywanie zmian i strojenie wydajności przy optymalizacji architektury gier.