From 2aeb3c6325405ccfb974541531c409e0ef7da4e7 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Fri, 10 Jul 2026 05:05:27 +0100 Subject: [PATCH] Keep Eve surface wire fields transport-safe --- .../Runtime/EveSurfaceDocument.cs | 66 ++++++++++++++++--- 1 file changed, 57 insertions(+), 9 deletions(-) diff --git a/packages/org.gamecult.eve.surface/Runtime/EveSurfaceDocument.cs b/packages/org.gamecult.eve.surface/Runtime/EveSurfaceDocument.cs index 35944d2..c4eb051 100644 --- a/packages/org.gamecult.eve.surface/Runtime/EveSurfaceDocument.cs +++ b/packages/org.gamecult.eve.surface/Runtime/EveSurfaceDocument.cs @@ -122,7 +122,6 @@ namespace GameCult.Eve.Surface { } - [SerializationConstructor] public EveSurfaceComponent( string id, string kind, @@ -132,12 +131,36 @@ namespace GameCult.Eve.Surface IReadOnlyList embeddedDocuments, IReadOnlyDictionary? layout = null, IReadOnlyDictionary? style = null) + : this( + id, + kind, + props, + children, + (stateBindings ?? Array.Empty()) + .Select(CultMeshStateBindingRecord.FromBinding) + .ToArray(), + embeddedDocuments, + layout, + style) + { + } + + [SerializationConstructor] + public EveSurfaceComponent( + string id, + string kind, + IReadOnlyDictionary props, + IReadOnlyList children, + CultMeshStateBindingRecord[] stateBindingRecords, + IReadOnlyList embeddedDocuments, + IReadOnlyDictionary? layout = null, + IReadOnlyDictionary? style = null) { Id = id ?? ""; Kind = kind ?? ""; Props = props ?? new Dictionary(StringComparer.Ordinal); Children = children ?? Array.Empty(); - StateBindings = stateBindings ?? Array.Empty(); + StateBindingRecords = stateBindingRecords ?? Array.Empty(); EmbeddedDocuments = embeddedDocuments ?? Array.Empty(); Layout = layout ?? new Dictionary(StringComparer.Ordinal); Style = style ?? new Dictionary(StringComparer.Ordinal); @@ -156,7 +179,11 @@ namespace GameCult.Eve.Surface public IReadOnlyList Children { get; } [Key(4)] - public IReadOnlyList StateBindings { get; } + public CultMeshStateBindingRecord[] StateBindingRecords { get; } + + [IgnoreMember] + public IReadOnlyList StateBindings => + StateBindingRecords.Select(record => record.ToBinding()).ToArray(); [Key(5)] public IReadOnlyList EmbeddedDocuments { get; } @@ -200,19 +227,29 @@ namespace GameCult.Eve.Surface [MessagePackObject] public sealed class EveEmbeddedDocumentSlot { - [SerializationConstructor] public EveEmbeddedDocumentSlot( string slotId, string documentId, string schemaId, string presentationKind, CultMeshRouteHint? routeHint = null) + : this(slotId, documentId, schemaId, presentationKind, CultMeshRouteRecord.FromRoute(routeHint)) + { + } + + [SerializationConstructor] + public EveEmbeddedDocumentSlot( + string slotId, + string documentId, + string schemaId, + string presentationKind, + CultMeshRouteRecord route) { SlotId = slotId ?? ""; DocumentId = documentId ?? ""; SchemaId = schemaId ?? ""; PresentationKind = presentationKind ?? ""; - RouteHint = routeHint ?? CultMeshRouteHint.Automatic; + Route = route ?? CultMeshRouteRecord.FromRoute(CultMeshRouteHint.Automatic); } [Key(0)] @@ -228,7 +265,10 @@ namespace GameCult.Eve.Surface public string PresentationKind { get; } [Key(4)] - public CultMeshRouteHint RouteHint { get; } + public CultMeshRouteRecord Route { get; } + + [IgnoreMember] + public CultMeshRouteHint RouteHint => Route.ToRoute(); } [MessagePackObject] @@ -251,14 +291,22 @@ namespace GameCult.Eve.Surface [MessagePackObject] public sealed class EveCommandTemplate { - [SerializationConstructor] public EveCommandTemplate(CultMeshOperationBindingDescriptor operation) + : this(CultMeshOperationBindingRecord.FromBinding(operation)) { - Operation = operation ?? throw new ArgumentNullException(nameof(operation)); + } + + [SerializationConstructor] + public EveCommandTemplate(CultMeshOperationBindingRecord operationRecord) + { + OperationRecord = operationRecord ?? throw new ArgumentNullException(nameof(operationRecord)); } [Key(0)] - public CultMeshOperationBindingDescriptor Operation { get; } + public CultMeshOperationBindingRecord OperationRecord { get; } + + [IgnoreMember] + public CultMeshOperationBindingDescriptor Operation => OperationRecord.ToBinding(); [IgnoreMember] public string Command => Operation.OperationId;