using GadgetCore.API;
using HarmonyLib;
using System.Collections;
using UnityEngine;

namespace ScrapYard.Patches
{

  [HarmonyPatch(typeof(KylockeStand))]
  [HarmonyPatch("Awake")]
  [HarmonyGadget("ScrapYard")]
  public static class Patch_KylockeStand_Awake
  {
    [HarmonyPostfix]
    public static void Postfix(KylockeStand __instance)
    {
      __instance.StartCoroutine(Deactivate(__instance));
    }

    private static IEnumerator Deactivate(KylockeStand instance)
    {
      yield return new WaitForSeconds(2f);
      if (instance.itemID >= 2000 && instance.itemID < 2500 || instance.itemID == ItemRegistry.GetItemIDByRegistryName("Gadget Core:Crafter Block"))
      {
        Core.logger.Log("Hiding a Default Stand with Item " + instance.itemID);
        instance.gameObject.SetActive(false);
      }
      yield break;
    }
  }
}
