feat: add world serialization support
Introduce `toJSON` and `fromJSON` methods to the `World` class to allow saving and restoring world states. This requires components and relationships to have human-readable names for stable serialization.
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
/**
|
||||
* Plain JSON-compatible representation of a World.
|
||||
* Returned by `world.toJSON()`, consumed by `World.fromJSON()`.
|
||||
*/
|
||||
export interface WorldSnapshot {
|
||||
/** Entity stable ID → component map (component name → data). */
|
||||
entities: Record<string, Record<string, unknown>>;
|
||||
/** Relationship name → (source ID → target ID). */
|
||||
relationships: Record<string, Record<string, string>>;
|
||||
}
|
||||
Reference in New Issue
Block a user