Centralize managed docking snapshot reads
This commit is contained in:
parent
14a4680c5f
commit
a924b0e35b
7 changed files with 110 additions and 79 deletions
|
|
@ -737,22 +737,14 @@ public class InventoryMenu : MonoBehaviour
|
|||
|
||||
private bool TryResolveCurrentEntityDocument(out AetheriaRuntimeCurrentEntityDocument currentEntity)
|
||||
{
|
||||
currentEntity = null;
|
||||
try
|
||||
currentEntity = ResolveDockingState()?.CurrentEntity;
|
||||
if (currentEntity == null)
|
||||
{
|
||||
currentEntity = ResolveClient()
|
||||
.Aetheria()
|
||||
.DockingState
|
||||
.Latest()
|
||||
?.CurrentEntity;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to read Aetheria current entity for inventory ship settings: {ex.Message}");
|
||||
Debug.LogWarning("Failed to read Aetheria current entity for inventory ship settings.");
|
||||
return false;
|
||||
}
|
||||
|
||||
return currentEntity != null;
|
||||
return true;
|
||||
}
|
||||
|
||||
private AetheriaRuntimeStationRefitDocument ResolveStationRefit()
|
||||
|
|
@ -782,18 +774,11 @@ public class InventoryMenu : MonoBehaviour
|
|||
|
||||
private AetheriaClientDockingSnapshot ResolveDockingState()
|
||||
{
|
||||
try
|
||||
{
|
||||
return ResolveClient()
|
||||
.Aetheria()
|
||||
.DockingState
|
||||
.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to read Aetheria docking state for inventory menu: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
if (ResolveClient().Aetheria().DockingState.TryLatest(out var docking))
|
||||
return docking;
|
||||
|
||||
Debug.LogWarning("Failed to read Aetheria docking state for inventory menu.");
|
||||
return null;
|
||||
}
|
||||
|
||||
private bool TryResolveObservedDockingIndex(out AetheriaUnityObservedDockingIndex dockingIndex)
|
||||
|
|
|
|||
|
|
@ -1162,18 +1162,11 @@ private void Update()
|
|||
|
||||
private AetheriaClientDockingSnapshot ResolveDockingState()
|
||||
{
|
||||
try
|
||||
{
|
||||
return ResolveClient()
|
||||
.Aetheria()
|
||||
.DockingState
|
||||
.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to read Aetheria docking state for inventory panel: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
if (ResolveClient().Aetheria().DockingState.TryLatest(out var docking))
|
||||
return docking;
|
||||
|
||||
Debug.LogWarning("Failed to read Aetheria docking state for inventory panel.");
|
||||
return null;
|
||||
}
|
||||
|
||||
private bool TryResolveObservedDockingIndex(out AetheriaUnityObservedDockingIndex dockingIndex)
|
||||
|
|
|
|||
|
|
@ -203,22 +203,10 @@ public class LocalMenu : MonoBehaviour
|
|||
|
||||
private bool TryResolveDockingState(out AetheriaClientDockingSnapshot dockingState)
|
||||
{
|
||||
dockingState = null;
|
||||
|
||||
try
|
||||
{
|
||||
dockingState = ResolveClient()
|
||||
.Aetheria()
|
||||
.DockingState
|
||||
.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to read Aetheria docking state for local story surface: {ex.Message}");
|
||||
return false;
|
||||
}
|
||||
|
||||
return dockingState != null;
|
||||
var resolved = ResolveClient().Aetheria().DockingState.TryLatest(out dockingState);
|
||||
if (!resolved)
|
||||
Debug.LogWarning("Failed to read Aetheria docking state for local story surface.");
|
||||
return resolved;
|
||||
}
|
||||
|
||||
private bool TryResolveDockedLocalStory(out LocationStory story)
|
||||
|
|
|
|||
|
|
@ -167,18 +167,11 @@ public class MenuPanel : MonoBehaviour
|
|||
|
||||
private AetheriaClientDockingSnapshot ResolveCurrentDocking()
|
||||
{
|
||||
try
|
||||
{
|
||||
return ResolveClient()
|
||||
.Aetheria()
|
||||
.DockingState
|
||||
.Latest();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to read Aetheria current docking for runtime menu tabs: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
if (ResolveClient().Aetheria().DockingState.TryLatest(out var docking))
|
||||
return docking;
|
||||
|
||||
Debug.LogWarning("Failed to read Aetheria current docking for runtime menu tabs.");
|
||||
return null;
|
||||
}
|
||||
|
||||
private AetheriaClient ResolveClient()
|
||||
|
|
|
|||
|
|
@ -539,20 +539,13 @@ public class TradeMenu : MonoBehaviour
|
|||
if (_dockingState != null)
|
||||
return _dockingState;
|
||||
|
||||
try
|
||||
if (!ResolveClient().Aetheria().DockingState.TryLatest(out _dockingState))
|
||||
{
|
||||
_dockingState = ResolveClient()
|
||||
.Aetheria()
|
||||
.DockingState
|
||||
.Latest();
|
||||
_stationRefit = _dockingState?.StationRefit;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Debug.LogWarning($"Failed to read Aetheria docking state for trade menu: {ex.Message}");
|
||||
Debug.LogWarning("Failed to read Aetheria docking state for trade menu.");
|
||||
return null;
|
||||
}
|
||||
|
||||
_stationRefit = _dockingState?.StationRefit;
|
||||
return _dockingState;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue