using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("ShopReset")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("ShopReset")] [assembly: AssemblyTitle("ShopReset")] [assembly: AssemblyVersion("1.0.0.0")] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)] internal sealed class NullableAttribute : Attribute { public readonly byte[] NullableFlags; public NullableAttribute(byte P_0) { NullableFlags = new byte[1] { P_0 }; } public NullableAttribute(byte[] P_0) { NullableFlags = P_0; } } [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)] internal sealed class NullableContextAttribute : Attribute { public readonly byte Flag; public NullableContextAttribute(byte P_0) { Flag = P_0; } } } namespace ShopReset { [BepInPlugin("com.ace.ShopReset", "ShopReset", "1.0.0")] public class Plugin : BaseUnityPlugin { [CompilerGenerated] private sealed class d__7 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__7(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>1__state = -2; } private bool MoveNext() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(0f); <>1__state = 1; return true; case 1: <>1__state = -1; DoSnapshot(); SnapshotScheduled = false; return false; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } } internal static ManualLogSource Log; internal static bool HasSnapshotted = false; internal static bool SnapshotScheduled = false; internal static Plugin Instance; internal static List<(PhysGrabObject obj, Vector3 pos, Quaternion rot)> Snapshot = new List<(PhysGrabObject, Vector3, Quaternion)>(); private void Awake() { Instance = this; Log = ((BaseUnityPlugin)this).Logger; Log.LogInfo((object)"ShopReset loaded!"); Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null); } internal static void ScheduleSnapshot() { if (!SnapshotScheduled) { SnapshotScheduled = true; Log.LogInfo((object)"ShopReset: Tube is up, scheduling snapshot..."); ((MonoBehaviour)Instance).StartCoroutine(DelayedSnapshot()); } } [IteratorStateMachine(typeof(d__7))] private static IEnumerator DelayedSnapshot() { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__7(0); } internal static void DoSnapshot() { //IL_004d: Unknown result type (might be due to invalid IL or missing references) //IL_0058: Unknown result type (might be due to invalid IL or missing references) Snapshot.Clear(); PhysGrabObject[] array = Object.FindObjectsOfType(); PhysGrabObject[] array2 = array; foreach (PhysGrabObject val in array2) { if (!((Object)(object)val == (Object)null) && !((Object)(object)((Component)val).GetComponent() == (Object)null)) { Snapshot.Add((val, ((Component)val).transform.position, ((Component)val).transform.rotation)); } } HasSnapshotted = true; Log.LogInfo((object)$"ShopReset: Snapshotted {Snapshot.Count} items from scene"); } internal static void ResetAllItems() { //IL_0033: Unknown result type (might be due to invalid IL or missing references) //IL_0039: Unknown result type (might be due to invalid IL or missing references) //IL_004f: Unknown result type (might be due to invalid IL or missing references) //IL_0065: Unknown result type (might be due to invalid IL or missing references) int num = 0; foreach (var item in Snapshot) { if (!((Object)(object)item.obj == (Object)null)) { item.obj.Teleport(item.pos, item.rot); item.obj.rb.velocity = Vector3.zero; item.obj.rb.angularVelocity = Vector3.zero; num++; } } Log.LogInfo((object)$"ShopReset: Reset {num} items"); } } [HarmonyPatch(typeof(ShopManager), "ShopInitialize")] public class ResetSnapshotOnNewShop { private static void Postfix() { Plugin.HasSnapshotted = false; Plugin.SnapshotScheduled = false; Plugin.Snapshot.Clear(); Plugin.Log.LogInfo((object)"ShopReset: New shop detected, snapshot cleared"); } } [HarmonyPatch(typeof(ExtractionPoint), "Update")] public class WatchTubeRise { private static FieldInfo tubeSlamDownEvalField = typeof(ExtractionPoint).GetField("tubeSlamDownEval", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); private static void Postfix(ExtractionPoint __instance) { if (SemiFunc.RunIsShop() && !Plugin.HasSnapshotted && !Plugin.SnapshotScheduled && !((Object)(object)Plugin.Instance == (Object)null) && !(tubeSlamDownEvalField == null)) { float num = (float)tubeSlamDownEvalField.GetValue(__instance); if (num >= 1f) { Plugin.Log.LogInfo((object)"ShopReset: Tube fully raised, scheduling snapshot"); Plugin.ScheduleSnapshot(); } } } } [HarmonyPatch(typeof(ExtractionPoint), "OnShopClick")] public class ShopResetPatch { private static bool Prefix(ExtractionPoint __instance) { Type typeFromHandle = typeof(ExtractionPoint); FieldInfo field = typeFromHandle.GetField("haulCurrent", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic); if (field == null) { return true; } int num = (int)field.GetValue(__instance); if (!Plugin.HasSnapshotted) { Plugin.Log.LogInfo((object)"ShopReset: Fallback snapshot on button press"); Plugin.DoSnapshot(); } if (num == 0) { Plugin.Log.LogInfo((object)"ShopReset: Nothing in buy zone, resetting items!"); Plugin.ResetAllItems(); return false; } return true; } } public static class PluginInfo { public const string PLUGIN_GUID = "ShopReset"; public const string PLUGIN_NAME = "ShopReset"; public const string PLUGIN_VERSION = "1.0.0"; } }