diff --git a/Aetheria.State.Verify/Program.cs b/Aetheria.State.Verify/Program.cs index f46748c62..c52003e36 100644 --- a/Aetheria.State.Verify/Program.cs +++ b/Aetheria.State.Verify/Program.cs @@ -4365,7 +4365,9 @@ static void RequireTradeCargoSelectorUseEveSurface(string root) "AetheriaRuntimeTradeCargoSelectorSurfaceBuilder.ShipBayCommand(", "AetheriaRuntimeTradeCargoSelectorSurfaceCommands.TryRead(request, out var command)", "AetheriaRuntimeTradeCargoSelectorCommandKind.Close", - "AetheriaRuntimeTradeCargoSelectorCommandKind.Select" + "AetheriaRuntimeTradeCargoSelectorCommandKind.Select", + "CountAvailablePlayerShips(", + "GameManager.AvailableEntities()" }; var missingSymbols = requiredSymbols @@ -4391,7 +4393,9 @@ static void RequireTradeCargoSelectorUseEveSurface(string root) "ContextMenu.AddOption(\"Docking Bay\"", "ContextMenu.AddOption($\"{ship.Name} Bay {bay.index+1}\"", "string.Equals(request.Command, AetheriaRuntimeTradeCargoSelectorSurfaceBuilder.Close", - "_cargoSelectionCommands.TryGetValue(request.Command" + "_cargoSelectionCommands.TryGetValue(request.Command", + "GameManager.DockedEntity.Children", + "GameManager.CurrentEntity.Parent.Children" }; var hits = forbiddenSymbols diff --git a/Assets/Scripts/UI/Menu/TradeMenu.cs b/Assets/Scripts/UI/Menu/TradeMenu.cs index 2b74af3fe..82fe9dfa6 100644 --- a/Assets/Scripts/UI/Menu/TradeMenu.cs +++ b/Assets/Scripts/UI/Menu/TradeMenu.cs @@ -192,7 +192,7 @@ public class TradeMenu : MonoBehaviour x => () => { if (x.IsHull) - return GameManager.DockedEntity.Children.Count(s => s.Hull.ItemKey == x.ItemKey && s is Ship {IsPlayerShip: true}).ToString(); + return CountAvailablePlayerShips(x.ItemKey).ToString(); if(x.Item is SimpleCommodity) return (_targetCargo.ItemsOfType.ContainsKey(x.ItemKey) ? _targetCargo.ItemsOfType[x.ItemKey].Cast().Sum(s=>s.Quantity) : 0).ToString(); return (_targetCargo.ItemsOfType.ContainsKey(x.ItemKey) ? _targetCargo.ItemsOfType[x.ItemKey].Count : 0).ToString(); @@ -200,7 +200,7 @@ public class TradeMenu : MonoBehaviour x => { if (x.IsHull) - return GameManager.DockedEntity.Children.Count(s => s.Hull.ItemKey == x.ItemKey && s is Ship {IsPlayerShip: true}); + return CountAvailablePlayerShips(x.ItemKey); if(x.Item is SimpleCommodity) return _targetCargo.ItemsOfType.ContainsKey(x.ItemKey) ? _targetCargo.ItemsOfType[x.ItemKey].Cast().Sum(s=>s.Quantity) : 0; return _targetCargo.ItemsOfType.ContainsKey(x.ItemKey) ? _targetCargo.ItemsOfType[x.ItemKey].Count : 0; @@ -1045,12 +1045,12 @@ public class TradeMenu : MonoBehaviour (GameManager.DockingBay, "Docking Bay"); } - if (GameManager.CurrentEntity?.Parent == null) + if (GameManager.DockingBay == null) return; - foreach (var ship in GameManager.CurrentEntity.Parent.Children - .Where(entity => entity is Ship { IsPlayerShip: true }) - .Cast() + foreach (var ship in GameManager.AvailableEntities() + .OfType() + .Where(ship => ship.IsPlayerShip) .Select((ship, shipIndex) => (ship, shipIndex))) { foreach (var bay in ship.ship.CargoBays.Select((cargoBay, index) => (cargoBay, index))) @@ -1184,7 +1184,14 @@ public class TradeMenu : MonoBehaviour children ?? Array.Empty()); } -private void OnDisable() + private int CountAvailablePlayerShips(string itemKey) + { + return GameManager.AvailableEntities() + .OfType() + .Count(ship => ship.IsPlayerShip && ship.Hull?.ItemKey == itemKey); + } + + private void OnDisable() { HideCargoSelectorSurface(); HideFilterSurface();