Map inventory docking from typed state
This commit is contained in:
parent
ca8b5858a2
commit
8b718d0da9
3 changed files with 30 additions and 61 deletions
|
|
@ -32,7 +32,6 @@ public class InventoryMenu : MonoBehaviour
|
|||
private UIDocument _equippedItemDetailsSurfaceDocument;
|
||||
private AetheriaUnityActionBarPresentation _actionBarPresentation;
|
||||
private AetheriaUnityObservedEntityIndex _observedEntityIndex;
|
||||
private AetheriaUnityObservedDockingIndex _observedDockingIndex;
|
||||
private readonly AetheriaEveUnitySurfaceChrome _shipSettingsSurfaceChrome = PanelChrome(360f, 420f);
|
||||
private readonly AetheriaEveUnitySurfaceChrome _cargoItemDetailsSurfaceChrome = PanelChrome(420f, 520f);
|
||||
private readonly AetheriaEveUnitySurfaceChrome _equippedItemDetailsSurfaceChrome = PanelChrome(460f, 560f);
|
||||
|
|
@ -58,11 +57,6 @@ public class InventoryMenu : MonoBehaviour
|
|||
|
||||
public void SetObservedEntityIndex(AetheriaUnityObservedEntityIndex observedEntityIndex)
|
||||
{
|
||||
if (!ReferenceEquals(_observedEntityIndex, observedEntityIndex))
|
||||
{
|
||||
_observedDockingIndex = null;
|
||||
}
|
||||
|
||||
_observedEntityIndex = observedEntityIndex;
|
||||
}
|
||||
// private int2 _dragCellOffset;
|
||||
|
|
@ -737,33 +731,31 @@ public class InventoryMenu : MonoBehaviour
|
|||
private bool TryResolveCurrentEntity(out Entity currentEntity)
|
||||
{
|
||||
currentEntity = null;
|
||||
return TryResolveObservedDockingIndex(out var dockingIndex) &&
|
||||
dockingIndex.TryResolveCurrentEntity(out currentEntity);
|
||||
var currentEntityKey = CurrentEntitySnapshot()?.EntityKey ?? "";
|
||||
return _observedEntityIndex != null &&
|
||||
!string.IsNullOrWhiteSpace(currentEntityKey) &&
|
||||
_observedEntityIndex.TryResolveEntityByRecordKey(currentEntityKey, out currentEntity);
|
||||
}
|
||||
|
||||
private bool TryResolveCurrentDockingBay(out EquippedCargoBay dockingBay)
|
||||
{
|
||||
dockingBay = null;
|
||||
if (!TryResolveObservedDockingIndex(out var dockingIndex) ||
|
||||
!dockingIndex.TryResolveCurrentDockingBay(out var resolvedDockingBay))
|
||||
var refit = StationRefitSnapshot();
|
||||
if (refit?.IsDocked != true ||
|
||||
refit.DockingBayIndex < 0 ||
|
||||
string.IsNullOrWhiteSpace(refit.DockParentEntityKey) ||
|
||||
_observedEntityIndex == null ||
|
||||
!_observedEntityIndex.TryResolveDockingBayByRecordKey(
|
||||
refit.DockParentEntityKey,
|
||||
refit.DockingBayIndex,
|
||||
out dockingBay))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
dockingBay = resolvedDockingBay;
|
||||
return dockingBay != null;
|
||||
}
|
||||
|
||||
private bool TryResolveObservedDockingIndex(out AetheriaUnityObservedDockingIndex dockingIndex)
|
||||
{
|
||||
dockingIndex = null;
|
||||
if (_observedEntityIndex == null)
|
||||
return false;
|
||||
|
||||
dockingIndex = _observedDockingIndex ??= new AetheriaUnityObservedDockingIndex(_observedEntityIndex);
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool TryResolveCargoBay(EquippedCargoBay cargoBay, out string entityKey, out int cargoIndex)
|
||||
{
|
||||
return TryResolveEquippedItem(cargoBay, out entityKey, out cargoIndex);
|
||||
|
|
@ -894,11 +886,6 @@ public class InventoryMenu : MonoBehaviour
|
|||
}
|
||||
}
|
||||
|
||||
private void ClearClientCaches()
|
||||
{
|
||||
_observedDockingIndex = null;
|
||||
}
|
||||
|
||||
private AetheriaRuntimeCurrentEntityDocument CurrentEntitySnapshot()
|
||||
{
|
||||
try
|
||||
|
|
@ -1081,8 +1068,6 @@ public class InventoryMenu : MonoBehaviour
|
|||
|
||||
private void OnDestroy()
|
||||
{
|
||||
ClearClientCaches();
|
||||
|
||||
if (_shipSettingsSurfaceDocument != null)
|
||||
{
|
||||
AetheriaEveUnitySurfaceHost.DestroyDocument(_shipSettingsSurfaceDocument);
|
||||
|
|
|
|||
|
|
@ -74,7 +74,6 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
|
|||
private RectTransform _firstRect;
|
||||
private AetheriaUnityDragSession _dragSession;
|
||||
private AetheriaUnityObservedEntityIndex _observedEntityIndex;
|
||||
private AetheriaUnityObservedDockingIndex _observedDockingIndex;
|
||||
|
||||
public ItemInstance FakeItem;
|
||||
public Shape FakeOccupancy;
|
||||
|
|
@ -88,11 +87,6 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
|
|||
|
||||
public void SetObservedEntityIndex(AetheriaUnityObservedEntityIndex observedEntityIndex)
|
||||
{
|
||||
if (!ReferenceEquals(_observedEntityIndex, observedEntityIndex))
|
||||
{
|
||||
_observedDockingIndex = null;
|
||||
}
|
||||
|
||||
_observedEntityIndex = observedEntityIndex;
|
||||
}
|
||||
|
||||
|
|
@ -1139,26 +1133,22 @@ private void Update()
|
|||
private bool TryResolveCurrentDockingBay(out EquippedCargoBay dockingBay)
|
||||
{
|
||||
dockingBay = null;
|
||||
if (!TryResolveObservedDockingIndex(out var dockingIndex) ||
|
||||
!dockingIndex.TryResolveCurrentDockingBay(out var resolvedDockingBay))
|
||||
var refit = StationRefitSnapshot();
|
||||
if (refit?.IsDocked != true ||
|
||||
refit.DockingBayIndex < 0 ||
|
||||
string.IsNullOrWhiteSpace(refit.DockParentEntityKey) ||
|
||||
_observedEntityIndex == null ||
|
||||
!_observedEntityIndex.TryResolveDockingBayByRecordKey(
|
||||
refit.DockParentEntityKey,
|
||||
refit.DockingBayIndex,
|
||||
out dockingBay))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
dockingBay = resolvedDockingBay;
|
||||
return dockingBay != null;
|
||||
}
|
||||
|
||||
private bool TryResolveObservedDockingIndex(out AetheriaUnityObservedDockingIndex dockingIndex)
|
||||
{
|
||||
dockingIndex = null;
|
||||
if (_observedEntityIndex == null)
|
||||
return false;
|
||||
|
||||
dockingIndex = _observedDockingIndex ??= new AetheriaUnityObservedDockingIndex(_observedEntityIndex);
|
||||
return true;
|
||||
}
|
||||
|
||||
private bool TryResolveStationRefitEntity(string entityKey, int optionIndex, out Entity entity)
|
||||
{
|
||||
entity = null;
|
||||
|
|
@ -1450,11 +1440,6 @@ private void Update()
|
|||
}
|
||||
}
|
||||
|
||||
private void ClearClientCaches()
|
||||
{
|
||||
_observedDockingIndex = null;
|
||||
}
|
||||
|
||||
private AetheriaRuntimeCurrentEntityDocument CurrentEntitySnapshot()
|
||||
{
|
||||
try
|
||||
|
|
@ -1625,8 +1610,6 @@ private void Update()
|
|||
|
||||
private void OnDestroy()
|
||||
{
|
||||
ClearClientCaches();
|
||||
|
||||
if (_dropdownSurfaceDocument != null)
|
||||
{
|
||||
AetheriaEveUnitySurfaceHost.DestroyDocument(_dropdownSurfaceDocument);
|
||||
|
|
|
|||
Loading…
Reference in a new issue