Keep navigation shutdown on the outgoing Verse

This commit is contained in:
Meta Vens 2026-08-19 01:44:29 +02:00
commit 2fd5f4bbb9
3 changed files with 31 additions and 11 deletions

View file

@ -89,14 +89,21 @@ namespace GameCult.Eve.UnityScene
var navigation = navigable.NavigateAsync(target); var navigation = navigable.NavigateAsync(target);
StagedPresentation? staged = null; StagedPresentation? staged = null;
PresentationSwap? swap = null; PresentationSwap? swap = null;
Transform? previousRoot = null;
var previousRootWasActive = false;
while (!navigation.IsCompleted) while (!navigation.IsCompleted)
yield return null; yield return null;
try try
{ {
navigation.GetAwaiter().GetResult(); navigation.GetAwaiter().GetResult();
staged = PrepareStagedPresentation(); staged = PrepareStagedPresentation();
previousRoot = sceneRoot;
previousRootWasActive = previousRoot == null || previousRoot.gameObject.activeSelf;
if (previousRoot != null && !ReferenceEquals(previousRoot, transform) &&
!ReferenceEquals(previousRoot, staged.SceneRoot))
previousRoot.gameObject.SetActive(false);
navigable.CommitNavigation(); navigable.CommitNavigation();
swap = ActivateStagedPresentation(staged); swap = ActivateStagedPresentation(staged, previousRootWasActive);
navigable.FinalizeNavigation(); navigable.FinalizeNavigation();
swap.Complete(); swap.Complete();
swap = null; swap = null;
@ -119,7 +126,10 @@ namespace GameCult.Eve.UnityScene
{ {
try try
{ {
swap?.Rollback(); if (swap != null)
swap.Rollback();
else if (previousRoot != null)
previousRoot.gameObject.SetActive(previousRootWasActive);
} }
catch (Exception rollbackError) catch (Exception rollbackError)
{ {
@ -193,12 +203,13 @@ namespace GameCult.Eve.UnityScene
} }
} }
private PresentationSwap ActivateStagedPresentation(StagedPresentation staged) private PresentationSwap ActivateStagedPresentation(
StagedPresentation staged,
bool previousRootWasActive)
{ {
var previousHost = host; var previousHost = host;
var previousRoot = sceneRoot; var previousRoot = sceneRoot;
var previousPresentation = LastPresentation; var previousPresentation = LastPresentation;
var previousRootWasActive = previousRoot == null || previousRoot.gameObject.activeSelf;
var input = GetComponent<EveUnityPlayableWorldInputDriver>(); var input = GetComponent<EveUnityPlayableWorldInputDriver>();
var previousInputHost = input?.Host; var previousInputHost = input?.Host;
var previousInputCamera = input?.CameraTransform; var previousInputCamera = input?.CameraTransform;
@ -217,9 +228,6 @@ namespace GameCult.Eve.UnityScene
host = staged.Host; host = staged.Host;
sceneRoot = staged.SceneRoot; sceneRoot = staged.SceneRoot;
LastPresentation = staged.Presentation; LastPresentation = staged.Presentation;
if (previousRoot != null && !ReferenceEquals(previousRoot, transform) &&
!ReferenceEquals(previousRoot, staged.SceneRoot))
previousRoot.gameObject.SetActive(false);
return new PresentationSwap( return new PresentationSwap(
this, this,
staged, staged,
@ -252,8 +260,6 @@ namespace GameCult.Eve.UnityScene
host = previousHost; host = previousHost;
sceneRoot = previousRoot; sceneRoot = previousRoot;
LastPresentation = previousPresentation; LastPresentation = previousPresentation;
if (previousRoot != null)
previousRoot.gameObject.SetActive(previousRootWasActive);
throw; throw;
} }
} }

View file

@ -1172,6 +1172,9 @@ namespace GameCult.Eve.UnityScene.Tests
bootstrap.ConfigureProvider(provider); bootstrap.ConfigureProvider(provider);
bootstrap.Mount(); bootstrap.Mount();
var originalHost = bootstrap.Host; var originalHost = bootstrap.Host;
var deactivationRoutes = new List<string>();
var deactivationProbe = bootstrap.SceneRoot!.gameObject.AddComponent<NavigationDeactivationProbe>();
deactivationProbe.Deactivated = () => deactivationRoutes.Add(provider.ActiveRoute);
provider.PublishReceipt(new EveUnitySceneCommandReceipt( provider.PublishReceipt(new EveUnitySceneCommandReceipt(
"receipt:launch", "receipt:launch",
@ -1198,6 +1201,7 @@ namespace GameCult.Eve.UnityScene.Tests
Assert.That(provider.CommitNavigationCount, Is.EqualTo(1)); Assert.That(provider.CommitNavigationCount, Is.EqualTo(1));
Assert.That(provider.FinalizeNavigationCount, Is.EqualTo(1)); Assert.That(provider.FinalizeNavigationCount, Is.EqualTo(1));
Assert.That(provider.RollbackNavigationCount, Is.Zero); Assert.That(provider.RollbackNavigationCount, Is.Zero);
Assert.That(deactivationRoutes, Is.EqualTo(new[] { "original" }));
provider.PublishReceipt(new EveUnitySceneCommandReceipt( provider.PublishReceipt(new EveUnitySceneCommandReceipt(
"receipt:launch-again", "receipt:launch-again",
@ -3559,5 +3563,15 @@ namespace GameCult.Eve.UnityScene.Tests
Reactivated?.Invoke(); Reactivated?.Invoke();
} }
} }
private sealed class NavigationDeactivationProbe : MonoBehaviour
{
public Action? Deactivated { get; set; }
private void OnDisable()
{
Deactivated?.Invoke();
}
}
} }
} }

View file

@ -1,11 +1,11 @@
{ {
"name": "org.gamecult.eve.unity-scene", "name": "org.gamecult.eve.unity-scene",
"displayName": "Eve Unity Scene Lowering", "displayName": "Eve Unity Scene Lowering",
"version": "0.3.116", "version": "0.3.117",
"unity": "6000.0", "unity": "6000.0",
"description": "Provider-agnostic Unity scene shell for gamecult.eve.surface.v1 interactive world surfaces.", "description": "Provider-agnostic Unity scene shell for gamecult.eve.surface.v1 interactive world surfaces.",
"dependencies": { "dependencies": {
"org.gamecult.cultlib": "1.0.53", "org.gamecult.cultlib": "1.0.54",
"org.gamecult.eve.plugin-fields": "0.2.3", "org.gamecult.eve.plugin-fields": "0.2.3",
"org.gamecult.eve.surface": "0.3.3", "org.gamecult.eve.surface": "0.3.3",
"org.gamecult.eve.unity-uitoolkit": "0.1.6", "org.gamecult.eve.unity-uitoolkit": "0.1.6",