| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- using GadgetCore.API;
- using GadgetCore.Util;
- using HarmonyLib;
- using System.Collections;
- using System.Threading;
- using System.Windows.Threading;
- using UnityEngine;
- namespace ShipDecorations.Patches
- {
- [HarmonyPatch(typeof(KylockeStand))]
- [HarmonyPatch("Awake")]
- [HarmonyGadget("ShipDecorations")]
- public static class Patch_KylockeStand_Awake
- {
- [HarmonyPostfix]
- public static void Prefix(KylockeStand __instance)
- {
- __instance.StartCoroutine(StartUpdateLoop(__instance));
- }
- public static IEnumerator DecpStockUpdateLoop(KylockeStand instance)
- {
- while (!Network.isServer && !Network.isClient)
- {
- yield return new WaitForSeconds(0f);
- }
- if (Network.isServer)
- {
- while (true)
- {
- yield return new WaitForSeconds(1f);
- if (instance.gameObject.activeSelf && Network.isServer)
- {
- instance.itemID = Core.itemStoreList[colorIndex];
- instance.cost = Core.itemStorePriceList[instance.itemID];
- instance.GetComponent<NetworkView>().RPC("Set", RPCMode.All, new object[]
- {
- new int[]{ instance.itemID, instance.cost }
- });
- }
- yield return new WaitForSeconds(9f);
- colorIndex = (colorIndex + 1) % Core.itemStoreList.Count;
- }
- }
- }
- private static IEnumerator StartUpdateLoop(KylockeStand instance)
- {
- if (instance.itemID == Core.itemStoreList[0])
- {
- instance.StartCoroutine(DecpStockUpdateLoop(instance));
- CoroutineManager newComponent = instance.gameObject.AddComponent<CoroutineManager>();
- newComponent.SetAction(new System.Action(() => { newComponent.StartCoroutine(DecpStockUpdateLoop(instance)); }));
- }
- yield break;
- }
- private static int colorIndex = 0;
- }
- }
|