Use reactive zone contact documents
This commit is contained in:
parent
309450d60d
commit
870cd7c3e0
4 changed files with 54 additions and 12 deletions
|
|
@ -312,6 +312,8 @@ public class ActionGameManager : MonoBehaviour
|
|||
private void OnDisable()
|
||||
{
|
||||
_gameplayInputShell?.Dispose();
|
||||
_observedTargetQuery?.Dispose();
|
||||
_observedTargetQuery = null;
|
||||
AetheriaUnityRuntimeClientProvider.Dispose();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,12 +4,14 @@
|
|||
|
||||
using System;
|
||||
using System.Linq;
|
||||
using GameCult.Mesh;
|
||||
using GameCult.Aetheria.State.Verse;
|
||||
|
||||
public sealed class AetheriaUnityObservedTargetQuery
|
||||
public sealed class AetheriaUnityObservedTargetQuery : IDisposable
|
||||
{
|
||||
private readonly Func<AetheriaClient> _resolveClient;
|
||||
private readonly AetheriaUnityObservedEntityIndex _entityIndex;
|
||||
private CultMeshReactiveDocument<AetheriaRuntimeZoneContactsDocument> _zoneContacts;
|
||||
|
||||
public AetheriaUnityObservedTargetQuery(
|
||||
Func<AetheriaClient> resolveClient,
|
||||
|
|
@ -91,15 +93,25 @@ public sealed class AetheriaUnityObservedTargetQuery
|
|||
|
||||
private AetheriaRuntimeZoneContactsDocument ReadZoneContacts()
|
||||
{
|
||||
if (_zoneContacts != null)
|
||||
return _zoneContacts.Current;
|
||||
|
||||
try
|
||||
{
|
||||
return _resolveClient()
|
||||
_zoneContacts = _resolveClient()
|
||||
?.Aetheria()
|
||||
.LatestZoneContacts();
|
||||
.ReactiveZoneContacts();
|
||||
return _zoneContacts?.Current;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_zoneContacts?.Dispose();
|
||||
_zoneContacts = null;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -121,6 +121,7 @@ public class ZoneRenderer : MonoBehaviour
|
|||
Array.Empty<AetheriaRuntimeBodySnapshotCommit>();
|
||||
private string _clientStatePath = "";
|
||||
private CultMeshReactiveDocument<AetheriaRuntimeCatalogSnapshot> _catalog;
|
||||
private CultMeshReactiveDocument<AetheriaRuntimeZoneContactsDocument> _zoneContacts;
|
||||
|
||||
public Dictionary<int, (GameObject gravity, CompassIcon icon)> WormholeInstances = new Dictionary<int, (GameObject, CompassIcon)>();
|
||||
private List<ItemPickup> _loot = new List<ItemPickup>();
|
||||
|
|
@ -985,9 +986,7 @@ public class ZoneRenderer : MonoBehaviour
|
|||
_daemonContactRows.Clear();
|
||||
try
|
||||
{
|
||||
var contacts = ResolveClient()
|
||||
.Aetheria()
|
||||
.LatestZoneContacts();
|
||||
var contacts = ResolveZoneContacts();
|
||||
foreach (var target in contacts?.Targets ?? Array.Empty<AetheriaRuntimeZoneTargetRow>())
|
||||
{
|
||||
if (target != null && target.EntityIndex >= 0)
|
||||
|
|
@ -1230,6 +1229,23 @@ public class ZoneRenderer : MonoBehaviour
|
|||
return _catalog?.Current;
|
||||
}
|
||||
|
||||
private AetheriaRuntimeZoneContactsDocument ResolveZoneContacts()
|
||||
{
|
||||
if (_zoneContacts != null)
|
||||
return _zoneContacts.Current;
|
||||
|
||||
try
|
||||
{
|
||||
_zoneContacts = ResolveClient().Aetheria().ReactiveZoneContacts();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to bind Aetheria zone contacts for renderer target distances: {ex.Message}");
|
||||
}
|
||||
|
||||
return _zoneContacts?.Current;
|
||||
}
|
||||
|
||||
private AetheriaClient ResolveClient()
|
||||
{
|
||||
var stateBoot = AetheriaRuntimeStateBoot.Inspect(AetheriaUnityRuntimePaths.GameDataDirectory);
|
||||
|
|
@ -1247,7 +1263,9 @@ public class ZoneRenderer : MonoBehaviour
|
|||
private void ClearClientCaches()
|
||||
{
|
||||
_catalog?.Dispose();
|
||||
_zoneContacts?.Dispose();
|
||||
_catalog = null;
|
||||
_zoneContacts = null;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue