diff --git a/Assets/Scripts/Intrepid/Gameplay/Entities/Player/PDA/UI/PDAApplicationSelectionUI.cs b/Assets/Scripts/Intrepid/Gameplay/Entities/Player/PDA/UI/PDAApplicationSelectionUI.cs index 4baad7f..e1004b0 100644 --- a/Assets/Scripts/Intrepid/Gameplay/Entities/Player/PDA/UI/PDAApplicationSelectionUI.cs +++ b/Assets/Scripts/Intrepid/Gameplay/Entities/Player/PDA/UI/PDAApplicationSelectionUI.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using Intrepid.Diagnostics; using Intrepid.GameManagers; using Intrepid.Gameplay.Entities.Player.PDA.Events; using Intrepid.Gameplay.Entities.Player.PDA.Inputs; @@ -35,9 +36,16 @@ namespace Intrepid.Gameplay.Entities.Player.PDA.UI if (inputs.Enter()) { + var currentContentFocus = contents.CurrentContentFocus; + if (currentContentFocus is null) + { + DLogger.LogError("we should not be able to enter an application without a content reference"); + return; + } + Proxy.Instance.EventBus.Raise(new PDAEnterApplicationEvent { - ContentTag = contents.CurrentContentFocus.ContentTag, + ContentTag = currentContentFocus.ContentTag, }); } } diff --git a/Assets/Scripts/Intrepid/Gameplay/Entities/Player/PDA/UI/PDAContentsUI.cs b/Assets/Scripts/Intrepid/Gameplay/Entities/Player/PDA/UI/PDAContentsUI.cs index 653a94a..d84e5b6 100644 --- a/Assets/Scripts/Intrepid/Gameplay/Entities/Player/PDA/UI/PDAContentsUI.cs +++ b/Assets/Scripts/Intrepid/Gameplay/Entities/Player/PDA/UI/PDAContentsUI.cs @@ -45,7 +45,10 @@ namespace Intrepid.Gameplay.Entities.Player.PDA.UI private bool ChangingContentFocus { get; set; } private List ContentTagsToLoad { get; set; } private GameObjectPool Pool { get; set; } - public PDAContentReferenceUI CurrentContentFocus => contentReferences[currentIndex]; + public PDAContentReferenceUI CurrentContentFocus => contentReferences + .TryGetValue(currentIndex, out var contentReference) + ? contentReference + : null; private void OnValidate() { @@ -184,7 +187,7 @@ namespace Intrepid.Gameplay.Entities.Player.PDA.UI private void GoLeft() { - if (ChangingContentFocus) return; + if (ChangingContentFocus || numberOfContents <= 0) return; ContentUnFocus(); if (currentIndex <= 0) { @@ -205,7 +208,7 @@ namespace Intrepid.Gameplay.Entities.Player.PDA.UI private void GoRight() { - if (ChangingContentFocus) return; + if (ChangingContentFocus || numberOfContents <= 0) return; ContentUnFocus(); if (currentIndex >= numberOfContents - 1) { @@ -226,6 +229,12 @@ namespace Intrepid.Gameplay.Entities.Player.PDA.UI private void ContentFocus() { var contentReference = CurrentContentFocus; + if (contentReference is null) + { + title.text = ""; + description.NotOperational(); + return; + } title.text = contentReference.Title; description.Operational(contentReference.Description); contentReference.Focus(); @@ -237,7 +246,7 @@ namespace Intrepid.Gameplay.Entities.Player.PDA.UI description.NotOperational(); if (currentIndex < contentReferences.Count) { - CurrentContentFocus.UnFocus(); + CurrentContentFocus?.UnFocus(); } } diff --git a/Assets/Scripts/Intrepid/Gameplay/Entities/Player/Sentinel/Cadence/UI/CodexCadenceStatusControllerUI.cs b/Assets/Scripts/Intrepid/Gameplay/Entities/Player/Sentinel/Cadence/UI/CodexCadenceStatusControllerUI.cs index 11bbf58..bdae3a9 100644 --- a/Assets/Scripts/Intrepid/Gameplay/Entities/Player/Sentinel/Cadence/UI/CodexCadenceStatusControllerUI.cs +++ b/Assets/Scripts/Intrepid/Gameplay/Entities/Player/Sentinel/Cadence/UI/CodexCadenceStatusControllerUI.cs @@ -1,4 +1,3 @@ -using System; using Intrepid.Gameplay.Codex.UI.Components; using Intrepid.Gameplay.Codex.UI.Controllers; using Intrepid.Utilities;