Try stopping duplicate system cards

This commit is contained in:
Nick 2024-06-12 20:51:26 -04:00
parent abfb3246d6
commit dc3f10ba33

View File

@ -34,10 +34,13 @@ namespace NewHorizons.Components.ShipLog
private int _nextCardIndex;
private HashSet<string> _systemCards = new();
private void Awake()
{
// Prompts
Locator.GetPromptManager().AddScreenPrompt(_warpPrompt, PromptPosition.UpperLeft, false);
_systemCards.Clear();
}
public override void Initialize(ScreenPromptList centerPromptList, ScreenPromptList upperRightPromptList, OWAudioSource oneShotSource)
@ -70,8 +73,15 @@ namespace NewHorizons.Components.ShipLog
public void AddSystemCard(string uniqueID)
{
var card = CreateCard(uniqueID, root.transform, new Vector2(_nextCardIndex++ * 200, 0));
_starSystemCards.Add(card);
if (!_systemCards.Contains(uniqueID))
{
var card = CreateCard(uniqueID, root.transform, new Vector2(_nextCardIndex++ * 200, 0));
_starSystemCards.Add(card);
}
else
{
NHLogger.LogWarning($"Tried making duplicate system card {uniqueID}");
}
}
public void OnDestroy()