using GadgetCore.API; using GadgetCore.Util; using HarmonyLib; using System.Collections; using System.Linq; using UnityEngine; namespace MoreLights.Patches { [HarmonyPatch(typeof(KylockeStand))] [HarmonyPatch("Set")] [HarmonyGadget("MoreLights")] public static class Patch_KylockeStand_Set { [HarmonyPostfix] public static void Prefix(KylockeStand __instance, int[] p) { __instance.StartCoroutine(DoUpdateAnimation(__instance)); if (new int[] { Core.itemYellowLampId, Core.itemOrangeLampId, 2402, Core.itemPurpleLampId, 2401, Core.itemGreenLampId }.Contains(p[0])) __instance.StartCoroutine(DoUpdateLoadingAnimation(__instance)); } private static IEnumerator DoUpdateAnimation(KylockeStand instance) { if (!GameScript.inInstance) { instance.GetComponent().PlayOneShot((AudioClip)Resources.Load("Au/shipdroid" + UnityEngine.Random.Range(0, 3)), Menuu.soundLevel / 10f); } var scale = instance.icon.transform.localScale; instance.icon.transform.localScale = new Vector3(scale.x * 0.90f, scale.y); yield return new WaitForSeconds(0.05f); instance.icon.transform.localScale = new Vector3(scale.x * 0.76f, scale.y); yield return new WaitForSeconds(0.05f); instance.icon.transform.localScale = new Vector3(scale.x * 0.70f, scale.y); yield return new WaitForSeconds(0.05f); instance.icon.transform.localScale = new Vector3(scale.x * 0.76f, scale.y); yield return new WaitForSeconds(0.05f); instance.icon.transform.localScale = new Vector3(scale.x * 0.90f, scale.y); yield return new WaitForSeconds(0.05f); instance.icon.transform.localScale = new Vector3(scale.y, scale.y); } private static Texture2D textureStand0 = GadgetCoreAPI.LoadTexture2D("stand0.png"); private static Texture2D textureStand1 = GadgetCoreAPI.LoadTexture2D("stand1.png"); private static Texture2D textureStand2 = GadgetCoreAPI.LoadTexture2D("stand2.png"); private static Texture2D textureStand3 = GadgetCoreAPI.LoadTexture2D("stand3.png"); private static Texture2D textureStand4 = GadgetCoreAPI.LoadTexture2D("stand4.png"); private static Texture2D textureStand5 = GadgetCoreAPI.LoadTexture2D("stand5.png"); private static Texture2D textureStand6 = GadgetCoreAPI.LoadTexture2D("stand6.png"); private static IEnumerator DoUpdateLoadingAnimation(KylockeStand instance) { UpdateTexture(instance, textureStand0); yield return new WaitForSeconds(1.43f); UpdateTexture(instance, textureStand1); yield return new WaitForSeconds(1.43f); UpdateTexture(instance, textureStand2); yield return new WaitForSeconds(1.43f); UpdateTexture(instance, textureStand3); yield return new WaitForSeconds(1.43f); UpdateTexture(instance, textureStand4); yield return new WaitForSeconds(1.43f); UpdateTexture(instance, textureStand5); yield return new WaitForSeconds(1.43f); UpdateTexture(instance, textureStand6); } private static void UpdateTexture(KylockeStand instance, Texture2D texture) { Renderer renderer = instance.gameObject.transform.GetChild(0).gameObject.GetComponentInChildren(); renderer.material = new Material(Shader.Find("Unlit/Transparent")) { mainTexture = texture }; } } }