Share managed client access in menu surfaces
This commit is contained in:
parent
a1fa5f1425
commit
82596467ac
5 changed files with 37 additions and 120 deletions
|
|
@ -2,7 +2,6 @@ using System;
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using GameCult.Aetheria.EveRuntime;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
|
|
@ -13,7 +12,6 @@ using UniRx;
|
|||
using UniRx.Triggers;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UIElements;
|
||||
using Path = System.IO.Path;
|
||||
|
||||
public class LocalMenu : MonoBehaviour
|
||||
{
|
||||
|
|
@ -28,8 +26,6 @@ public class LocalMenu : MonoBehaviour
|
|||
private readonly List<ActiveStoryChoice> _activeChoices = new List<ActiveStoryChoice>();
|
||||
private UIDocument _surfaceDocument;
|
||||
private readonly AetheriaEveUnitySurfaceChrome _surfaceChrome = new AetheriaEveUnitySurfaceChrome();
|
||||
private AetheriaClient _client;
|
||||
private string _clientStatePath = "";
|
||||
private AetheriaUnityObservedFacadeIndex _observedFacadeIndex;
|
||||
|
||||
public void SetObservedFacadeIndex(AetheriaUnityObservedFacadeIndex observedFacadeIndex)
|
||||
|
|
@ -248,23 +244,9 @@ public class LocalMenu : MonoBehaviour
|
|||
|
||||
private AetheriaClient ResolveClient()
|
||||
{
|
||||
var gameDataDirectory = new DirectoryInfo(Path.Combine(Application.dataPath, "..", "GameData"));
|
||||
var stateBoot = AetheriaRuntimeStateBoot.Inspect(gameDataDirectory);
|
||||
|
||||
if (_client != null && string.Equals(_clientStatePath, stateBoot.StateFilePath, StringComparison.Ordinal))
|
||||
return _client;
|
||||
|
||||
DisposeClient();
|
||||
_client = AetheriaClient
|
||||
.OpenLocalAsync(
|
||||
gameDataDirectory,
|
||||
"unity-runtime-local-story",
|
||||
"local",
|
||||
pullOnOpen: true)
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
_clientStatePath = stateBoot.StateFilePath;
|
||||
return _client;
|
||||
return AetheriaUnityRuntimeClientProvider.ResolveClient(
|
||||
AetheriaRuntimeStateBoot.Inspect(AetheriaUnityRuntimePaths.GameDataDirectory),
|
||||
"unity-runtime-local-story");
|
||||
}
|
||||
|
||||
private void HideStorySurface()
|
||||
|
|
@ -275,13 +257,6 @@ public class LocalMenu : MonoBehaviour
|
|||
AetheriaEveUnitySurfaceHost.Hide(_surfaceDocument);
|
||||
}
|
||||
|
||||
private void DisposeClient()
|
||||
{
|
||||
_client?.Dispose();
|
||||
_client = null;
|
||||
_clientStatePath = "";
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
HideStorySurface();
|
||||
|
|
@ -289,7 +264,6 @@ public class LocalMenu : MonoBehaviour
|
|||
|
||||
private void OnDestroy()
|
||||
{
|
||||
DisposeClient();
|
||||
if (_surfaceDocument != null)
|
||||
{
|
||||
AetheriaEveUnitySurfaceHost.DestroyDocument(_surfaceDocument);
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using TMPro;
|
||||
|
|
@ -40,8 +39,6 @@ public class MapRenderer : MonoBehaviour
|
|||
private RenderTexture _mapTexture;
|
||||
private int2 _size;
|
||||
private bool _init;
|
||||
private AetheriaClient _client;
|
||||
private string _clientStatePath = "";
|
||||
private AetheriaRuntimeObjectsViewportDocument _objectsViewport;
|
||||
private AetheriaRuntimeRenderSplatsViewportDocument _renderSplatsViewport;
|
||||
private float _nextViewportRefreshTime;
|
||||
|
|
@ -91,11 +88,6 @@ public class MapRenderer : MonoBehaviour
|
|||
ZoneRenderer.ShowAsteroidUI = false;
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
DisposeClient();
|
||||
}
|
||||
|
||||
void ReleaseTextures()
|
||||
{
|
||||
_mapTexture.Release();
|
||||
|
|
@ -341,28 +333,8 @@ public class MapRenderer : MonoBehaviour
|
|||
|
||||
private AetheriaClient ResolveClient()
|
||||
{
|
||||
var gameDataDirectory = new DirectoryInfo(Path.Combine(Application.dataPath, "..", "GameData"));
|
||||
var stateBoot = AetheriaRuntimeStateBoot.Inspect(gameDataDirectory);
|
||||
if (_client != null && string.Equals(_clientStatePath, stateBoot.StateFilePath, StringComparison.Ordinal))
|
||||
return _client;
|
||||
|
||||
DisposeClient();
|
||||
_client = AetheriaClient
|
||||
.OpenLocalAsync(
|
||||
gameDataDirectory,
|
||||
"unity-map-renderer",
|
||||
"local",
|
||||
pullOnOpen: true)
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
_clientStatePath = stateBoot.StateFilePath;
|
||||
return _client;
|
||||
}
|
||||
|
||||
private void DisposeClient()
|
||||
{
|
||||
_client?.Dispose();
|
||||
_client = null;
|
||||
_clientStatePath = "";
|
||||
return AetheriaUnityRuntimeClientProvider.ResolveClient(
|
||||
AetheriaRuntimeStateBoot.Inspect(AetheriaUnityRuntimePaths.GameDataDirectory),
|
||||
"unity-map-renderer");
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@
|
|||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using GameCult.Aetheria.EveRuntime;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
|
|
@ -32,8 +31,6 @@ public class MenuPanel : MonoBehaviour
|
|||
private MenuTabBinding _current;
|
||||
private UIDocument _tabSurfaceDocument;
|
||||
private readonly AetheriaEveUnitySurfaceChrome _tabSurfaceChrome = new AetheriaEveUnitySurfaceChrome();
|
||||
private AetheriaClient _client;
|
||||
private string _clientStatePath = "";
|
||||
|
||||
public MenuTab CurrentTab { get; private set; }
|
||||
|
||||
|
|
@ -91,7 +88,6 @@ public class MenuPanel : MonoBehaviour
|
|||
|
||||
private void OnDestroy()
|
||||
{
|
||||
DisposeClient();
|
||||
if (_tabSurfaceDocument != null)
|
||||
{
|
||||
AetheriaEveUnitySurfaceHost.DestroyDocument(_tabSurfaceDocument);
|
||||
|
|
@ -187,30 +183,9 @@ public class MenuPanel : MonoBehaviour
|
|||
|
||||
private AetheriaClient ResolveClient()
|
||||
{
|
||||
var gameDataDirectory = new DirectoryInfo(Path.Combine(Application.dataPath, "..", "GameData"));
|
||||
var stateBoot = AetheriaRuntimeStateBoot.Inspect(gameDataDirectory);
|
||||
|
||||
if (_client != null && string.Equals(_clientStatePath, stateBoot.StateFilePath, StringComparison.Ordinal))
|
||||
return _client;
|
||||
|
||||
DisposeClient();
|
||||
_client = AetheriaClient
|
||||
.OpenLocalAsync(
|
||||
gameDataDirectory,
|
||||
"unity-runtime-menu-tabs",
|
||||
"local",
|
||||
pullOnOpen: true)
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
_clientStatePath = stateBoot.StateFilePath;
|
||||
return _client;
|
||||
}
|
||||
|
||||
private void DisposeClient()
|
||||
{
|
||||
_client?.Dispose();
|
||||
_client = null;
|
||||
_clientStatePath = "";
|
||||
return AetheriaUnityRuntimeClientProvider.ResolveClient(
|
||||
AetheriaRuntimeStateBoot.Inspect(AetheriaUnityRuntimePaths.GameDataDirectory),
|
||||
"unity-runtime-menu-tabs");
|
||||
}
|
||||
|
||||
private static string GetTabLabel(MenuTabBinding tabBinding)
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using TMPro;
|
||||
|
|
@ -54,8 +53,6 @@ public class SectorMap : MonoBehaviour
|
|||
private readonly Dictionary<int, AetheriaRuntimeSectorMapZone> _zonesByIndex =
|
||||
new Dictionary<int, AetheriaRuntimeSectorMapZone>();
|
||||
private AetheriaRuntimeSectorMapDocument _sectorMap;
|
||||
private AetheriaClient _client;
|
||||
private string _clientStatePath = "";
|
||||
private bool _sectorMapLoaded;
|
||||
|
||||
public bool TryMarkPlayerLocation(int zoneIndex)
|
||||
|
|
@ -258,7 +255,7 @@ public class SectorMap : MonoBehaviour
|
|||
|
||||
private void OnDestroy()
|
||||
{
|
||||
DisposeClient();
|
||||
_sectorMapLoaded = false;
|
||||
}
|
||||
|
||||
private void AddFactionMaterials(int factionIndex)
|
||||
|
|
@ -501,30 +498,9 @@ public class SectorMap : MonoBehaviour
|
|||
|
||||
private AetheriaClient ResolveClient()
|
||||
{
|
||||
var gameDataDirectory = new DirectoryInfo(Path.Combine(Application.dataPath, "..", "GameData"));
|
||||
var stateBoot = AetheriaRuntimeStateBoot.Inspect(gameDataDirectory);
|
||||
if (_client != null && string.Equals(_clientStatePath, stateBoot.StateFilePath, StringComparison.Ordinal))
|
||||
return _client;
|
||||
|
||||
DisposeClient();
|
||||
_client = AetheriaClient
|
||||
.OpenLocalAsync(
|
||||
gameDataDirectory,
|
||||
"unity-sector-map",
|
||||
"local",
|
||||
pullOnOpen: true)
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
_clientStatePath = stateBoot.StateFilePath;
|
||||
return _client;
|
||||
}
|
||||
|
||||
private void DisposeClient()
|
||||
{
|
||||
_client?.Dispose();
|
||||
_client = null;
|
||||
_clientStatePath = "";
|
||||
_sectorMapLoaded = false;
|
||||
return AetheriaUnityRuntimeClientProvider.ResolveClient(
|
||||
AetheriaRuntimeStateBoot.Inspect(AetheriaUnityRuntimePaths.GameDataDirectory),
|
||||
"unity-sector-map");
|
||||
}
|
||||
|
||||
private static float2 Position(AetheriaRuntimeSectorMapZone zone)
|
||||
|
|
|
|||
Loading…
Reference in a new issue