Route inventory current ship through observed state
This commit is contained in:
parent
3bcdf519e5
commit
05146a6768
4 changed files with 40 additions and 10 deletions
|
|
@ -65,14 +65,15 @@ public class InventoryMenu : MonoBehaviour
|
|||
// {
|
||||
// _destroyItem = false;
|
||||
// });
|
||||
var hasObservedCurrentEntity = GameManager.TryGetObservedCurrentEntity(out var currentEntity);
|
||||
var cargo = GameManager.TryGetObservedDockingBay(out var dockingBay)
|
||||
? dockingBay
|
||||
: GameManager.CurrentEntity?.CargoBays.FirstOrDefault();
|
||||
: currentEntity?.CargoBays.FirstOrDefault();
|
||||
if (cargo!=null)
|
||||
InventoryPanels[0].Display(cargo);
|
||||
else InventoryPanels[0].Clear();
|
||||
if(GameManager.CurrentEntity != null)
|
||||
InventoryPanels[1].Display(GameManager.CurrentEntity);
|
||||
if(hasObservedCurrentEntity)
|
||||
InventoryPanels[1].Display(currentEntity);
|
||||
else InventoryPanels[1].Clear();
|
||||
}
|
||||
|
||||
|
|
@ -158,9 +159,9 @@ public class InventoryMenu : MonoBehaviour
|
|||
|
||||
panel.OnBackgroundClick.Subscribe(data =>
|
||||
{
|
||||
if (GameManager.CurrentEntity == null) return; // Only show ship settings if there's a ship, duh!
|
||||
if (!GameManager.TryGetObservedCurrentEntity(out var currentEntity)) return;
|
||||
|
||||
RenderCurrentShipSettingsSurface(GameManager.CurrentEntity);
|
||||
RenderCurrentShipSettingsSurface(currentEntity);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -185,7 +186,12 @@ public class InventoryMenu : MonoBehaviour
|
|||
|
||||
private void HandleCurrentShipSettingsSurfaceCommand(EveSurfaceCommandRequest request)
|
||||
{
|
||||
var entity = GameManager.CurrentEntity;
|
||||
if (!GameManager.TryGetObservedCurrentEntity(out var entity))
|
||||
{
|
||||
HideCurrentShipSettingsSurface();
|
||||
return;
|
||||
}
|
||||
|
||||
if (entity?.Settings == null)
|
||||
{
|
||||
HideCurrentShipSettingsSurface();
|
||||
|
|
|
|||
|
|
@ -134,7 +134,10 @@ public class InventoryPanel : MonoBehaviour, IPointerClickHandler
|
|||
Current.onClick.AddListener(() =>
|
||||
{
|
||||
HideDropdownSurface();
|
||||
if (_displayedEntity != GameManager.CurrentEntity)
|
||||
var isDisplayedCurrentEntity =
|
||||
GameManager.TryGetObservedCurrentEntity(out var currentEntity) &&
|
||||
_displayedEntity == currentEntity;
|
||||
if (!isDisplayedCurrentEntity)
|
||||
{
|
||||
if(_displayedEntity is Ship ship)
|
||||
{
|
||||
|
|
@ -533,7 +536,10 @@ private void Update()
|
|||
if (Current)
|
||||
{
|
||||
Current.gameObject.SetActive(true);
|
||||
Current.targetGraphic.color = entity == GameManager.CurrentEntity ? ToggleEnabledColor : ToggleDisabledColor;
|
||||
Current.targetGraphic.color =
|
||||
GameManager.TryGetObservedCurrentEntity(out var currentEntity) && entity == currentEntity
|
||||
? ToggleEnabledColor
|
||||
: ToggleDisabledColor;
|
||||
}
|
||||
if (Thermal)
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue