diff --git a/QSB/RespawnSync/ShipRecoveryPoint.cs b/QSB/RespawnSync/ShipRecoveryPoint.cs index a98a63d0..f1742f62 100644 --- a/QSB/RespawnSync/ShipRecoveryPoint.cs +++ b/QSB/RespawnSync/ShipRecoveryPoint.cs @@ -15,15 +15,11 @@ internal class ShipRecoveryPoint : MonoBehaviour private int _refillIndex; private int _respawnIndex; private bool _wearingSuit; - - private static UITextType _respawnPlayerText; + private UITextType _respawnPlayerText; private void Awake() { - if (_respawnPlayerText == UITextType.None) - { - _respawnPlayerText = UIHelper.AddToUITable(QSBLocalization.Current.RespawnPlayer); - } + _respawnPlayerText = UIHelper.AddToUITable(QSBLocalization.Current.RespawnPlayer); _interactVolume = this.GetRequiredComponent(); _interactVolume.OnPressInteract += OnPressInteract; @@ -48,7 +44,6 @@ internal class ShipRecoveryPoint : MonoBehaviour _interactVolume.OnGainFocus -= OnGainFocus; GlobalMessenger.RemoveListener(OWEvents.SuitUp, OnSuitUp); GlobalMessenger.RemoveListener(OWEvents.RemoveSuit, OnRemoveSuit); - _respawnPlayerText = UITextType.None; } private void OnSuitUp() diff --git a/QSB/Utility/UIHelper.cs b/QSB/Utility/UIHelper.cs index ef15b672..f86f22d3 100644 --- a/QSB/Utility/UIHelper.cs +++ b/QSB/Utility/UIHelper.cs @@ -15,6 +15,12 @@ internal static class UIHelper public static UITextType AddToUITable(string text) { + var hasValue = UITableHasValue(text); + if (hasValue != UITextType.None) + { + return hasValue; + } + var table = TextTranslation.Get().m_table; var key = table.theUITable.Keys.Max() + 1; table.theUITable[key] = text; @@ -22,6 +28,12 @@ internal static class UIHelper return (UITextType)key; } + public static UITextType UITableHasValue(string text) + { + var table = TextTranslation.Get().m_table; + return (UITextType)table.theUITable.FirstOrDefault(x => x.Value == text).Key; + } + public static CultureInfo GetCurrentCultureInfo() => QSBLocalization.Current.Language switch {