diff --git a/Packages/org.gamecult.aetheria.eve-runtime/Runtime/AetheriaEveUnitySceneProviderBridge.cs b/Packages/org.gamecult.aetheria.eve-runtime/Runtime/AetheriaEveUnitySceneProviderBridge.cs index 9edcda60b..5adfd60b8 100644 --- a/Packages/org.gamecult.aetheria.eve-runtime/Runtime/AetheriaEveUnitySceneProviderBridge.cs +++ b/Packages/org.gamecult.aetheria.eve-runtime/Runtime/AetheriaEveUnitySceneProviderBridge.cs @@ -16,6 +16,7 @@ namespace GameCult.Aetheria.EveRuntime IEveUnitySceneProviderSurfaceDocumentSource, IEveUnityPlayableWorldAssetManifestDocumentSource, IEveUnitySceneCommandSink, + IEveUnitySceneCommandReceiptSource, IEveUnityProviderRefreshSource, IDisposable { @@ -58,6 +59,8 @@ namespace GameCult.Aetheria.EveRuntime public event Action? DocumentAvailable; + public event Action? ReceiptAvailable; + event Action IEveUnityPlayableWorldAssetManifestDocumentSource.DocumentAvailable { add => AssetManifestDocumentAvailable += value; @@ -92,6 +95,7 @@ namespace GameCult.Aetheria.EveRuntime { Debug.Log( $"Submitted Aetheria daemon operation from Eve Unity scene: {daemonEnvelope!.Kind} {daemonEnvelope.CommandId}"); + ReceiptAvailable?.Invoke(ToReceipt(request, daemonEnvelope)); return; } @@ -101,6 +105,7 @@ namespace GameCult.Aetheria.EveRuntime .GetAwaiter() .GetResult(); Debug.Log($"Submitted Eve Unity scene operation for CultMesh bridge: {envelope.OperationId}"); + ReceiptAvailable?.Invoke(ToReceipt(request, envelope)); } public void Dispose() @@ -181,6 +186,54 @@ namespace GameCult.Aetheria.EveRuntime : $"{path}#{_surfaceId}"; } + private static EveUnitySceneCommandReceipt ToReceipt( + EveSurfaceCommandRequest request, + AetheriaRuntimeDaemonCommandEnvelope envelope) + { + if (request == null) throw new ArgumentNullException(nameof(request)); + if (envelope == null) throw new ArgumentNullException(nameof(envelope)); + + return new EveUnitySceneCommandReceipt( + string.IsNullOrWhiteSpace(envelope.CommandId) ? envelope.OperationId : envelope.CommandId, + envelope.OperationId, + envelope.CommandId, + envelope.Accepted ? "accepted" : "denied", + "Aetheria", + "aetheria-daemon-command-boundary", + request.ReceiptSchema, + request.ProviderId, + request.SurfaceId, + envelope.Diagnostic ?? "", + ParseIssuedAt(envelope.IssuedAtUtc, request.IssuedAt)); + } + + private static EveUnitySceneCommandReceipt ToReceipt( + EveSurfaceCommandRequest request, + CultMeshOperationReceipt receipt) + { + if (request == null) throw new ArgumentNullException(nameof(request)); + if (receipt == null) throw new ArgumentNullException(nameof(receipt)); + + var commandId = request.Operation?.IdempotencyKey ?? ""; + return new EveUnitySceneCommandReceipt( + string.IsNullOrWhiteSpace(commandId) ? receipt.OperationId : commandId, + receipt.OperationId, + commandId, + receipt.Accepted ? "accepted" : "denied", + "Aetheria", + "aetheria-eve-command-boundary", + request.ReceiptSchema, + request.ProviderId, + request.SurfaceId, + receipt.Diagnostic ?? "", + request.IssuedAt); + } + + private static DateTimeOffset ParseIssuedAt(string value, DateTimeOffset fallback) + { + return DateTimeOffset.TryParse(value, out var parsed) ? parsed : fallback; + } + private static EveUnityPlayableWorldAssetManifestDocument ToUnityPlayableWorldAssetManifest( AetheriaRuntimeAssetManifestDocument manifest) { diff --git a/Packages/org.gamecult.aetheria.eve-runtime/Runtime/AetheriaEveUnitySceneProviderComponent.cs b/Packages/org.gamecult.aetheria.eve-runtime/Runtime/AetheriaEveUnitySceneProviderComponent.cs index fef9f40df..1e4b3a820 100644 --- a/Packages/org.gamecult.aetheria.eve-runtime/Runtime/AetheriaEveUnitySceneProviderComponent.cs +++ b/Packages/org.gamecult.aetheria.eve-runtime/Runtime/AetheriaEveUnitySceneProviderComponent.cs @@ -13,6 +13,7 @@ namespace GameCult.Aetheria.EveRuntime IEveUnitySceneProviderSurfaceDocumentSource, IEveUnityPlayableWorldAssetManifestDocumentSource, IEveUnitySceneCommandSink, + IEveUnitySceneCommandReceiptSource, IEveUnityProviderRefreshSource, IDisposable { @@ -38,6 +39,12 @@ namespace GameCult.Aetheria.EveRuntime remove => Bridge.DocumentAvailable -= value; } + public event Action? ReceiptAvailable + { + add => Bridge.ReceiptAvailable += value; + remove => Bridge.ReceiptAvailable -= value; + } + event Action IEveUnityPlayableWorldAssetManifestDocumentSource.DocumentAvailable { add => ((IEveUnityPlayableWorldAssetManifestDocumentSource)Bridge).DocumentAvailable += value;