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

namespace First.Patches
{

	[HarmonyPatch(typeof(KylockeStand))]
	[HarmonyPatch("Awake")]
	[HarmonyGadget("First")]
	public static class Patch_KylockeStand_Awake
	{
		[HarmonyPostfix]
		public static void Prefix(KylockeStand __instance)
		{
			__instance.StartCoroutine(WaitAMoment(__instance));
		}

		private static IEnumerator WaitAMoment(KylockeStand instance)
		{
			if (instance.itemID == 2402)
			{
				instance.itemID = Core.itemWhiteLampId;
			}
			else if (instance.itemID == 2401)
			{
				switch (Random.Range(0, 6))
				{
					case 0:
						instance.itemID = Core.itemYellowLampId;
						break;
					case 1:
						instance.itemID = Core.itemOrangeLampId;
						break;
					case 2:
						instance.itemID = 2401;
						break;
					case 3:
						instance.itemID = Core.itemPurpleLampId;
						break;
					case 4:
						instance.itemID = 2402;
						break;
					case 5:
						instance.itemID = Core.itemGreenLampId;
						break;
				}
			}
			yield break;
		}
	}
}
