Route docking bay UI through observed state

This commit is contained in:
Meta Vens 2026-06-21 19:19:50 +01:00
commit 3bcdf519e5
5 changed files with 54 additions and 19 deletions

View file

@ -3918,7 +3918,9 @@ static void RequireRuntimeMenuTabsUseEveSurface(string root)
var requiredDockedStoryObserverSymbols = new[]
{
"public bool IsObservedDocked => DockedEntity != null && TryGetDaemonEntitySnapshot(DockedEntity, out _);",
"public bool IsObservedDocked => TryGetObservedDockingBay(out _);",
"public bool TryGetObservedDockingBay(out EquippedDockingBay dockingBay)",
"TryResolveDaemonDockingBay(CurrentEntity, out var dockParent, out var resolvedDockingBay)",
"public bool TryGetObservedDockedLocalStory(out LocationStory story)",
"TryGetObservedDockedLocalStory(out _currentLocation)"
};
@ -4406,7 +4408,7 @@ static void RequireTradeCargoSelectorUseEveSurface(string root)
"AetheriaRuntimeTradeCargoSelectorCommandKind.Close",
"AetheriaRuntimeTradeCargoSelectorCommandKind.Select",
"CountAvailablePlayerShips(",
"GameManager.IsObservedDocked",
"GameManager.TryGetObservedDockingBay(out var dockingBay)",
"GameManager.AvailableEntities()"
};
@ -4436,7 +4438,8 @@ static void RequireTradeCargoSelectorUseEveSurface(string root)
"_cargoSelectionCommands.TryGetValue(request.Command",
"GameManager.DockedEntity.Children",
"GameManager.CurrentEntity.Parent.Children",
"GameManager.DockedEntity == null"
"GameManager.DockedEntity == null",
"GameManager.DockingBay"
};
var hits = forbiddenSymbols
@ -4699,6 +4702,7 @@ static void RequireTradeItemDetailsUseEveSurface(string root)
static void RequireInventoryDropdownUseEveSurface(string root)
{
var inventoryPanelPath = Path.Combine(root, "Assets", "Scripts", "UI", "Menu", "InventoryPanel.cs");
var inventoryMenuPath = Path.Combine(root, "Assets", "Scripts", "UI", "Menu", "InventoryMenu.cs");
var inventoryDropdownSurfaceBuilderPath = Path.Combine(
root,
"Packages",
@ -4709,12 +4713,17 @@ static void RequireInventoryDropdownUseEveSurface(string root)
{
throw new InvalidOperationException("Cannot verify inventory dropdown shell; InventoryPanel.cs is missing.");
}
if (!File.Exists(inventoryMenuPath))
{
throw new InvalidOperationException("Cannot verify inventory dropdown shell; InventoryMenu.cs is missing.");
}
if (!File.Exists(inventoryDropdownSurfaceBuilderPath))
{
throw new InvalidOperationException("Cannot verify inventory dropdown shell; shared runtime inventory dropdown surface builder is missing.");
}
var source = File.ReadAllText(inventoryPanelPath);
var inventoryMenu = File.ReadAllText(inventoryMenuPath);
var inventoryDropdownSurfaceBuilder = File.ReadAllText(inventoryDropdownSurfaceBuilderPath);
var requiredSymbols = new[]
{
@ -4730,7 +4739,8 @@ static void RequireInventoryDropdownUseEveSurface(string root)
"AetheriaRuntimeInventoryDropdownCommandKind.Close",
"AetheriaRuntimeInventoryDropdownCommandKind.Select",
"AetheriaRuntimeInventoryDropdownSurfaceBuilder.EntityEquipmentCommand(",
"AetheriaRuntimeInventoryDropdownSurfaceBuilder.LoadoutCommand("
"AetheriaRuntimeInventoryDropdownSurfaceBuilder.LoadoutCommand(",
"GameManager.TryGetObservedDockingBay(out var dockingBay)"
};
var missingSymbols = requiredSymbols
@ -4760,7 +4770,8 @@ static void RequireInventoryDropdownUseEveSurface(string root)
"ContextMenu.AddDropdown(\"Restore Loadout\"",
"ContextMenu.Show();",
"string.Equals(request.Command, AetheriaRuntimeInventoryDropdownSurfaceBuilder.Close",
"_dropdownCommands.TryGetValue(request.Command"
"_dropdownCommands.TryGetValue(request.Command",
"GameManager.DockingBay"
};
var hits = forbiddenSymbols
@ -4774,6 +4785,13 @@ static void RequireInventoryDropdownUseEveSurface(string root)
string.Join(", ", hits));
}
if (!inventoryMenu.Contains("GameManager.TryGetObservedDockingBay(out var dockingBay)", StringComparison.Ordinal) ||
inventoryMenu.Contains("GameManager.DockingBay", StringComparison.Ordinal))
{
throw new InvalidOperationException(
"InventoryMenu must open against daemon-observed docking bay state instead of peeking GameManager.DockingBay directly.");
}
var requiredBuilderSymbols = new[]
{
"public static class AetheriaRuntimeInventoryDropdownSurfaceBuilder",

View file

@ -494,12 +494,26 @@ public class ActionGameManager : MonoBehaviour
set => _currentEntity = value;
}
public bool IsObservedDocked => DockedEntity != null && TryGetDaemonEntitySnapshot(DockedEntity, out _);
public bool IsObservedDocked => TryGetObservedDockingBay(out _);
public bool TryGetObservedDockingBay(out EquippedDockingBay dockingBay)
{
dockingBay = null;
if (CurrentEntity == null ||
!TryResolveDaemonDockingBay(CurrentEntity, out var dockParent, out var resolvedDockingBay) ||
!ReferenceEquals(dockParent, DockedEntity))
{
return false;
}
dockingBay = resolvedDockingBay;
return true;
}
public bool TryGetObservedDockedLocalStory(out LocationStory story)
{
story = null;
if (!IsObservedDocked || DockedEntity is not OrbitalEntity { Story: { } dockedStory })
if (!TryGetObservedDockingBay(out _) || DockedEntity is not OrbitalEntity { Story: { } dockedStory })
return false;
story = dockedStory;

View file

@ -65,7 +65,9 @@ public class InventoryMenu : MonoBehaviour
// {
// _destroyItem = false;
// });
var cargo = GameManager.DockingBay ?? GameManager.CurrentEntity.CargoBays.FirstOrDefault();
var cargo = GameManager.TryGetObservedDockingBay(out var dockingBay)
? dockingBay
: GameManager.CurrentEntity?.CargoBays.FirstOrDefault();
if (cargo!=null)
InventoryPanels[0].Display(cargo);
else InventoryPanels[0].Clear();

View file

@ -233,9 +233,9 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
}
}
if (GameManager.DockingBay != null && _displayedCargo != GameManager.DockingBay)
if (GameManager.TryGetObservedDockingBay(out var dockingBay) && _displayedCargo != dockingBay)
{
_dropdownCommands[AetheriaRuntimeInventoryDropdownSurfaceBuilder.DockingBay] = () => Display(GameManager.DockingBay);
_dropdownCommands[AetheriaRuntimeInventoryDropdownSurfaceBuilder.DockingBay] = () => Display(dockingBay);
}
if (_displayedEntity != null)
@ -341,7 +341,8 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
}
}
if (_dropdownCommands.ContainsKey(AetheriaRuntimeInventoryDropdownSurfaceBuilder.DockingBay))
if (_dropdownCommands.ContainsKey(AetheriaRuntimeInventoryDropdownSurfaceBuilder.DockingBay) &&
GameManager.TryGetObservedDockingBay(out var dockingBay))
{
groups.Add(new AetheriaRuntimeInventoryDropdownGroup(
$"{AetheriaRuntimeInventoryDropdownSurfaceBuilder.SurfaceId}.dockingBay.card",
@ -350,7 +351,7 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
{
new AetheriaRuntimeInventoryDropdownOption(
$"{AetheriaRuntimeInventoryDropdownSurfaceBuilder.SurfaceId}.dockingBay.select",
GameManager.DockingBay.Name,
dockingBay.Name,
AetheriaRuntimeInventoryDropdownSurfaceBuilder.DockingBay)
}));
}

View file

@ -48,8 +48,8 @@ public class TradeMenu : MonoBehaviour
private void OnEnable()
{
if (!GameManager.IsObservedDocked) return;
_targetCargo = GameManager.DockingBay;
if (!GameManager.TryGetObservedDockingBay(out var dockingBay)) return;
_targetCargo = dockingBay;
TargetCargoLabel.text = "Docking Bay";
HideCargoSelectorSurface();
HideFilterSurface();
@ -1039,15 +1039,15 @@ public class TradeMenu : MonoBehaviour
{
_cargoSelectionCommands.Clear();
if (GameManager.DockingBay != null && _targetCargo != GameManager.DockingBay)
if (!GameManager.TryGetObservedDockingBay(out var dockingBay))
return;
if (_targetCargo != dockingBay)
{
_cargoSelectionCommands[AetheriaRuntimeTradeCargoSelectorSurfaceBuilder.DockingBay] =
(GameManager.DockingBay, "Docking Bay");
(dockingBay, "Docking Bay");
}
if (GameManager.DockingBay == null)
return;
foreach (var ship in GameManager.AvailableEntities()
.OfType<Ship>()
.Where(ship => ship.IsPlayerShip)