using HarmonyLib;
using System.Linq;
using Dawn;

namespace HookahPlace;

[HarmonyPatch(typeof(Terminal))]
internal static class TerminalPatch
{
    [HarmonyPrefix]
    [HarmonyPatch("Update")]
    private static void UpdatePatch(Terminal __instance)
    {
        var hookahNode = LethalContent.Unlockables[HookahPlaceKeys.Hookah].UnlockableItem.shopSelectionNode;

        if (!__instance.ShipDecorSelection.Any(node => node.shipUnlockableID == hookahNode.shipUnlockableID))
        {
            HookahPlace.Logger.LogInfo($"Patching terminal selection list {hookahNode.shipUnlockableID}");
            __instance.ShipDecorSelection = [.. __instance.ShipDecorSelection, hookahNode];
        }
    }
}
