Restore provider route before presentation rollback
This commit is contained in:
parent
7ba4041320
commit
909ce43727
3 changed files with 108 additions and 5 deletions
|
|
@ -105,9 +105,35 @@ namespace GameCult.Eve.UnityScene
|
|||
}
|
||||
catch (Exception error)
|
||||
{
|
||||
swap?.Rollback();
|
||||
staged?.Dispose();
|
||||
navigable.RollbackNavigation();
|
||||
var providerRestored = false;
|
||||
try
|
||||
{
|
||||
navigable.RollbackNavigation();
|
||||
providerRestored = true;
|
||||
}
|
||||
catch (Exception rollbackError)
|
||||
{
|
||||
Debug.LogError($"Eve provider route rollback failed; the previous presentation will remain inactive. {rollbackError}");
|
||||
}
|
||||
if (providerRestored)
|
||||
{
|
||||
try
|
||||
{
|
||||
swap?.Rollback();
|
||||
}
|
||||
catch (Exception rollbackError)
|
||||
{
|
||||
Debug.LogError($"Eve previous presentation rollback failed after provider restoration. {rollbackError}");
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
staged?.Dispose();
|
||||
}
|
||||
catch (Exception cleanupError)
|
||||
{
|
||||
Debug.LogWarning($"Eve rejected presentation cleanup failed. {cleanupError}");
|
||||
}
|
||||
var failure = new EveUnitySceneNavigationFailure(target, error.Message, DateTimeOffset.UtcNow);
|
||||
LastNavigationFailure = failure;
|
||||
NavigationFailed?.Invoke(failure);
|
||||
|
|
|
|||
|
|
@ -1289,6 +1289,60 @@ namespace GameCult.Eve.UnityScene.Tests
|
|||
}
|
||||
}
|
||||
|
||||
[UnityTest]
|
||||
public IEnumerator PlayableWorldClientBootstrapRestoresProviderRouteBeforeReactivatingPreviousView()
|
||||
{
|
||||
var hostObject = new GameObject("generic-eve-navigation-order-client");
|
||||
try
|
||||
{
|
||||
var provider = hostObject.AddComponent<FakePlayableWorldProviderComponent>();
|
||||
provider.Set(
|
||||
new EveUnitySceneProviderSurfaceDocument(
|
||||
PlayableArpgDocument(),
|
||||
Advertisement("aetheria.daemon.game"),
|
||||
"cultmesh://aetheria/eve/surfaces/aetheria.daemon.game",
|
||||
1),
|
||||
new EveUnityPlayableWorldAssetManifestDocument(
|
||||
"cultmesh://aetheria/assets/manifest",
|
||||
Array.Empty<EveUnityPlayableWorldAssetManifestDocumentEntry>(),
|
||||
"aetheria"));
|
||||
var bootstrap = hostObject.AddComponent<EveUnityPlayableWorldClientBootstrap>();
|
||||
bootstrap.ConfigureProvider(provider);
|
||||
bootstrap.Mount();
|
||||
var probe = bootstrap.SceneRoot!.gameObject.AddComponent<NavigationReactivationProbe>();
|
||||
probe.Reactivated = () => provider.RoutesObservedDuringReactivation.Add(provider.ActiveRoute);
|
||||
provider.FailNextNavigationFinalize = true;
|
||||
LogAssert.Expect(LogType.Error, new Regex("Eve provider navigation failed; the current surface remains mounted"));
|
||||
|
||||
provider.PublishReceipt(new EveUnitySceneCommandReceipt(
|
||||
"receipt:launch-finalize-failure",
|
||||
"aetheria.hangar.launch",
|
||||
"launch",
|
||||
"accepted",
|
||||
"Aetheria",
|
||||
"commander-daemon",
|
||||
navigation: new EveUnitySceneNavigationTarget(
|
||||
"gamecult.aetheria",
|
||||
"candidate-provider",
|
||||
"aetheria.pilot",
|
||||
"interactive-world",
|
||||
new[] { "cultnet+tcp://odin.example:3999" })));
|
||||
|
||||
yield return null;
|
||||
yield return null;
|
||||
|
||||
Assert.That(provider.CommitNavigationCount, Is.EqualTo(1));
|
||||
Assert.That(provider.RollbackNavigationCount, Is.EqualTo(1));
|
||||
Assert.That(provider.ActiveRoute, Is.EqualTo("original"));
|
||||
Assert.That(provider.RoutesObservedDuringReactivation, Is.EqualTo(new[] { "original" }));
|
||||
Assert.That(bootstrap.Host!.Runtime, Is.Not.Null);
|
||||
}
|
||||
finally
|
||||
{
|
||||
UnityEngine.Object.DestroyImmediate(hostObject);
|
||||
}
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void PlayableWorldClientHostSubmitsProviderOwnedMoveVector()
|
||||
{
|
||||
|
|
@ -3391,6 +3445,12 @@ namespace GameCult.Eve.UnityScene.Tests
|
|||
|
||||
public bool FailNextNavigationMount { get; set; }
|
||||
|
||||
public bool FailNextNavigationFinalize { get; set; }
|
||||
|
||||
public string ActiveRoute { get; private set; } = "original";
|
||||
|
||||
public List<string> RoutesObservedDuringReactivation { get; } = new List<string>();
|
||||
|
||||
private bool _failSurfaceRead;
|
||||
|
||||
public string SinkKind => "fake-provider-command-sink";
|
||||
|
|
@ -3468,19 +3528,36 @@ namespace GameCult.Eve.UnityScene.Tests
|
|||
public void CommitNavigation()
|
||||
{
|
||||
CommitNavigationCount++;
|
||||
ActiveRoute = "candidate";
|
||||
_failSurfaceRead = false;
|
||||
}
|
||||
|
||||
public void FinalizeNavigation()
|
||||
{
|
||||
FinalizeNavigationCount++;
|
||||
if (FailNextNavigationFinalize)
|
||||
{
|
||||
FailNextNavigationFinalize = false;
|
||||
throw new InvalidOperationException("Deliberate provider finalization failure.");
|
||||
}
|
||||
}
|
||||
|
||||
public void RollbackNavigation()
|
||||
{
|
||||
RollbackNavigationCount++;
|
||||
ActiveRoute = "original";
|
||||
_failSurfaceRead = false;
|
||||
}
|
||||
}
|
||||
|
||||
private sealed class NavigationReactivationProbe : MonoBehaviour
|
||||
{
|
||||
public Action? Reactivated { get; set; }
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
Reactivated?.Invoke();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,11 @@
|
|||
{
|
||||
"name": "org.gamecult.eve.unity-scene",
|
||||
"displayName": "Eve Unity Scene Lowering",
|
||||
"version": "0.3.115",
|
||||
"version": "0.3.116",
|
||||
"unity": "6000.0",
|
||||
"description": "Provider-agnostic Unity scene shell for gamecult.eve.surface.v1 interactive world surfaces.",
|
||||
"dependencies": {
|
||||
"org.gamecult.cultlib": "1.0.52",
|
||||
"org.gamecult.cultlib": "1.0.53",
|
||||
"org.gamecult.eve.plugin-fields": "0.2.3",
|
||||
"org.gamecult.eve.surface": "0.3.3",
|
||||
"org.gamecult.eve.unity-uitoolkit": "0.1.6",
|
||||
|
|
|
|||
Reference in a new issue