How-To: Save Player Progression
Goal: persist per-player progression (stat tags, and your own attributes) using the CrimsonCore player-state integration.
ACrimsonPlayerState. It already implements ICrimsonSaveableSystem, registers itself server-side, and saves its stat tags and squad id as a Player-scoped fragment. It also carries a save adapter component per system - skill trees, ability state, inventory - each of which owns its own fragment and its own file, so one system failing to save takes nothing else with it.1. Stat tags persist automatically
Anything you store via AddStatTagStack on the player state is captured and restored per player with no extra code - it rides in the fragment's SavedStatTags.
2. Add your own data (e.g. attributes)
Subclass the fragment (UCrimsonPlayerStateSaveFragment) to add fields, then write and read them in the player-state hooks Gather Player Save Data / Restore Player Save Data. See How-To: Custom Fragments & Versioning for how the fragment subclass is created.
Create a Blueprint child of ACrimsonPlayerState (CrimsonCore - requires all Crimson plugins). In My Blueprint -> Functions, open the Override dropdown and pick Gather Player Save Data, then Restore Player Save Data. Each drops a red event node into the Event Graph carrying a Fragment input pin.
In Gather Player Save Data: Cast To your fragment Blueprint on the Fragment pin, then Set your own fields on the cast result - stat tags and squad id are already written by the base class, so add only what it does not cover. In Restore Player Save Data: cast the same way and read the fields back onto the player state. Both run on the server only; the restored values reach the owning client through normal replication.
See also
- How-To: Custom Fragments & Versioning - subclass the fragment for structured data
- Concept: Multiplayer & Save Scopes - how player keys work