Share managed runtime client access
This commit is contained in:
parent
1e9ba3a8bb
commit
a1fa5f1425
6 changed files with 71 additions and 112 deletions
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
using UnityEngine;
|
||||
|
||||
|
|
@ -26,8 +25,6 @@ public sealed class AetheriaUnityRenderSplatViewportSource : MonoBehaviour
|
|||
[SerializeField]
|
||||
private bool renderInLateUpdate = true;
|
||||
|
||||
private AetheriaClient _client;
|
||||
private string _clientStatePath = "";
|
||||
private float _nextRefreshTime;
|
||||
private AetheriaRuntimeRenderSplatsViewportDocument _document;
|
||||
|
||||
|
|
@ -135,33 +132,9 @@ public sealed class AetheriaUnityRenderSplatViewportSource : 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-render-splat-viewport",
|
||||
"local",
|
||||
pullOnOpen: true)
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
_clientStatePath = stateBoot.StateFilePath;
|
||||
return _client;
|
||||
return AetheriaUnityRuntimeClientProvider.ResolveClient(
|
||||
AetheriaRuntimeStateBoot.Inspect(AetheriaUnityRuntimePaths.GameDataDirectory),
|
||||
"unity-render-splat-viewport");
|
||||
}
|
||||
|
||||
private void OnDestroy()
|
||||
{
|
||||
DisposeClient();
|
||||
}
|
||||
|
||||
private void DisposeClient()
|
||||
{
|
||||
_client?.Dispose();
|
||||
_client = null;
|
||||
_clientStatePath = "";
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -42,6 +42,16 @@ public static class AetheriaUnityRuntimeClientProvider
|
|||
return _runtimeClient;
|
||||
}
|
||||
|
||||
public static AetheriaClient ResolveClient(AetheriaRuntimeStateBootReport stateBoot, string runtimeId = "")
|
||||
{
|
||||
if (stateBoot == null)
|
||||
throw new ArgumentNullException(nameof(stateBoot));
|
||||
|
||||
return ResolveClient(
|
||||
stateBoot.StateFilePath,
|
||||
string.IsNullOrWhiteSpace(runtimeId) ? stateBoot.RuntimeId : runtimeId);
|
||||
}
|
||||
|
||||
public static AetheriaClient CurrentClientForStateFile(string stateFilePath)
|
||||
{
|
||||
return _runtimeClient != null &&
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
|
|
@ -54,8 +53,6 @@ public class VolumeCloudRenderer : EffectBase
|
|||
// The index of 4x4 pixels.
|
||||
private int frameIndex = 0;
|
||||
private bool firstFrame = true;
|
||||
private AetheriaClient _client;
|
||||
private string _clientStatePath = "";
|
||||
private AetheriaRuntimePlayerSettingsDocument _playerSettings;
|
||||
|
||||
[SerializeField]
|
||||
|
|
@ -68,7 +65,7 @@ public class VolumeCloudRenderer : EffectBase
|
|||
}
|
||||
|
||||
private void OnDestroy() {
|
||||
DisposeClient();
|
||||
_playerSettings = null;
|
||||
if (this.fullBuffer != null) {
|
||||
for (int i = 0; i < fullBuffer.Length; i++) {
|
||||
fullBuffer[i].Release();
|
||||
|
|
@ -118,30 +115,9 @@ public class VolumeCloudRenderer : EffectBase
|
|||
|
||||
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-volume-cloud-renderer",
|
||||
"local",
|
||||
pullOnOpen: true)
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
_clientStatePath = stateBoot.StateFilePath;
|
||||
return _client;
|
||||
}
|
||||
|
||||
private void DisposeClient()
|
||||
{
|
||||
_client?.Dispose();
|
||||
_client = null;
|
||||
_clientStatePath = "";
|
||||
_playerSettings = null;
|
||||
return AetheriaUnityRuntimeClientProvider.ResolveClient(
|
||||
AetheriaRuntimeStateBoot.Inspect(AetheriaUnityRuntimePaths.GameDataDirectory),
|
||||
"unity-volume-cloud-renderer");
|
||||
}
|
||||
|
||||
[ImageEffectOpaque]
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@
|
|||
using System;
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Cinemachine;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
|
|
@ -118,8 +117,6 @@ public class ZoneRenderer : MonoBehaviour
|
|||
Array.Empty<AetheriaRuntimeZoneRenderAsteroidBeltPose>();
|
||||
private IReadOnlyList<AetheriaRuntimeBodySnapshotCommit> _zoneRenderBodies =
|
||||
Array.Empty<AetheriaRuntimeBodySnapshotCommit>();
|
||||
private AetheriaClient _client;
|
||||
private string _clientStatePath = "";
|
||||
private AetheriaRuntimeCatalogSnapshot _catalog;
|
||||
|
||||
public Dictionary<int, (GameObject gravity, CompassIcon icon)> WormholeInstances = new Dictionary<int, (GameObject, CompassIcon)>();
|
||||
|
|
@ -970,7 +967,7 @@ public class ZoneRenderer : MonoBehaviour
|
|||
|
||||
private void OnDestroy()
|
||||
{
|
||||
DisposeClient();
|
||||
_catalog = null;
|
||||
}
|
||||
|
||||
private float GetTerrainHeight(float2 position)
|
||||
|
|
@ -1194,30 +1191,9 @@ public class ZoneRenderer : 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-zone-renderer",
|
||||
"local",
|
||||
pullOnOpen: true)
|
||||
.GetAwaiter()
|
||||
.GetResult();
|
||||
_clientStatePath = stateBoot.StateFilePath;
|
||||
return _client;
|
||||
}
|
||||
|
||||
private void DisposeClient()
|
||||
{
|
||||
_client?.Dispose();
|
||||
_client = null;
|
||||
_clientStatePath = "";
|
||||
_catalog = null;
|
||||
return AetheriaUnityRuntimeClientProvider.ResolveClient(
|
||||
AetheriaRuntimeStateBoot.Inspect(AetheriaUnityRuntimePaths.GameDataDirectory),
|
||||
"unity-zone-renderer");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue