feat: implement game saving and loading in TicTacToe

- Add serialization support to `World`, `EntityAllocator`, and
  `SparseSet`
- Implement `SaveGame` and `LoadGame` functionality in the TicTacToe
  example
- Add ability to resume a game from a saved state
- Implement auto-save after every move in the game loop
This commit is contained in:
2026-07-18 21:06:57 +08:00
parent a19861c080
commit 0a28890f2c
5 changed files with 124 additions and 48 deletions
@@ -38,9 +38,9 @@ public struct PlaceMarkCommand : ICommand
if (target == null)
return; // Cell already occupied or invalid position.
// Place the mark.
// Place the mark. ComponentAdded is sufficient — MarkModified
// is only needed when mutating an existing component via GetComponent<T>.
world.AddComponent(target.Value, new Mark { Player = state.CurrentPlayer });
world.MarkModified<Mark>(target.Value);
// Advance turn.
state.MoveCount++;