using MessagePack; namespace OECS; /// /// Serializable snapshot of the entire world state. /// [MessagePackObject] public class WorldSnapshot { [Key(0)] public EntitySnapshot[] Entities { get; set; } = []; } /// /// A single entity and all its components, serialized as name/data pairs. /// Entity ID and Version are stored separately to avoid issues with /// MessagePack deserialization of the opaque Entity struct. /// [MessagePackObject] public class EntitySnapshot { [Key(0)] public uint Id { get; set; } [Key(1)] public uint Version { get; set; } [Key(2)] public ComponentEntry[] Components { get; set; } = []; [IgnoreMember] public Entity Entity => new(Id, Version); } /// /// A single component, identified by its fully-qualified type name and /// serialized as a MessagePack byte blob. /// [MessagePackObject] public class ComponentEntry { [Key(0)] public string TypeName { get; set; } = ""; [Key(1)] public byte[] Data { get; set; } = []; }