Route docking bay UI through observed state
This commit is contained in:
parent
520454bbdf
commit
3bcdf519e5
5 changed files with 54 additions and 19 deletions
|
|
@ -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();
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Reference in a new issue