using System; using System.Collections; using System.Collections.Generic; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using System.Security; using System.Security.Permissions; using BepInEx; using BepInEx.Configuration; using BepInEx.Logging; using HarmonyLib; using Microsoft.CodeAnalysis; using Photon.Pun; 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("JustRetryPlus")] [assembly: AssemblyConfiguration("Debug")] [assembly: AssemblyFileVersion("1.0.3.0")] [assembly: AssemblyInformationalVersion("1.0.3")] [assembly: AssemblyProduct("JustRetryPlus")] [assembly: AssemblyTitle("JustRetryPlus")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.3.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace JustRetryPlus { [HarmonyPatch(typeof(RunManager), "ChangeLevel")] public static class ChangeLevelPatch { private static bool Prefix(RunManager __instance, ref bool _completedLevel, ref bool _levelFailed, ref ChangeLevelType _changeLevelType) { //IL_0092: Unknown result type (might be due to invalid IL or missing references) //IL_0099: Expected O, but got Unknown if (!Plugin.IsEnabled) { return true; } Plugin.Logger.LogInfo((object)$"Level failed?: {_levelFailed}"); Plugin.DidFailLevel = _levelFailed; if (Plugin.DidFailLevel) { if (Plugin.ShouldResetLevel) { Plugin.Logger.LogInfo((object)"Restarting at level one"); __instance.ResetProgress(); __instance.SetRunLevel(); } else if (Plugin.ShouldHealAfterFail) { Plugin.Logger.LogInfo((object)"Preparing to heal after retry..."); GameObject val = new GameObject("JustRetryPlus_HealRunner"); Object.DontDestroyOnLoad((Object)(object)val); HealRunner healRunner = val.AddComponent(); ((MonoBehaviour)healRunner).StartCoroutine(Plugin.HandleRestartHeal((MonoBehaviour)(object)healRunner)); } Plugin.Logger.LogInfo((object)"Level failed, retrying..."); __instance.RestartScene(); Plugin.Logger.LogInfo((object)"Restarted scene"); return false; } return true; } } public class HealRunner : MonoBehaviour { } public static class MyPluginInfo { public const string PLUGIN_GUID = "JustRetryPlus"; public const string PLUGIN_NAME = "JustRetryPlus"; public const string PLUGIN_VERSION = "1.0.3"; } [BepInPlugin("JustRetryPlus", "JustRetryPlus", "1.0.3")] public class Plugin : BaseUnityPlugin { [CompilerGenerated] private sealed class d__20 : IEnumerator, IEnumerator, IDisposable { private int <>1__state; private object <>2__current; public MonoBehaviour runner; private int 5__1; private List.Enumerator <>s__2; private PlayerAvatar 5__3; private string 5__4; private int 5__5; private PhotonView 5__6; private List 5__7; private List.Enumerator <>s__8; private string 5__9; object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return <>2__current; } } [DebuggerHidden] public d__20(int <>1__state) { this.<>1__state = <>1__state; } [DebuggerHidden] void IDisposable.Dispose() { <>s__2 = default(List.Enumerator); 5__3 = null; 5__4 = null; 5__6 = null; 5__7 = null; <>s__8 = default(List.Enumerator); 5__9 = null; <>1__state = -2; } private bool MoveNext() { //IL_004c: Unknown result type (might be due to invalid IL or missing references) //IL_0056: Expected O, but got Unknown //IL_00b2: Unknown result type (might be due to invalid IL or missing references) //IL_00bc: Expected O, but got Unknown //IL_006f: Unknown result type (might be due to invalid IL or missing references) //IL_0079: Expected O, but got Unknown //IL_00e7: Unknown result type (might be due to invalid IL or missing references) //IL_00f1: Expected O, but got Unknown //IL_0133: Unknown result type (might be due to invalid IL or missing references) //IL_013d: Expected O, but got Unknown switch (<>1__state) { default: return false; case 0: <>1__state = -1; <>2__current = (object)new WaitForSeconds(1f); <>1__state = 1; return true; case 1: <>1__state = -1; goto IL_008a; case 2: <>1__state = -1; goto IL_008a; case 3: <>1__state = -1; goto IL_00cd; case 4: <>1__state = -1; goto IL_0102; case 5: { <>1__state = -1; 5__1 = HealthToHealValue; <>s__2 = SemiFunc.PlayerGetAll().GetEnumerator(); try { while (<>s__2.MoveNext()) { 5__3 = <>s__2.Current; if ((Object)(object)5__3 != (Object)null && (Object)(object)5__3.playerHealth != (Object)null) { 5__4 = SemiFunc.PlayerGetSteamID(5__3); if ((Object)(object)StatsManager.instance != (Object)null) { StatsManager.instance.SetPlayerHealth(5__4, 5__1, false); } 5__5 = (int)AccessTools.Field(typeof(PlayerHealth), "maxHealth").GetValue(5__3.playerHealth); 5__1 = Mathf.Clamp(5__1, 0, 5__5); AccessTools.Field(typeof(PlayerHealth), "health").SetValue(5__3.playerHealth, 5__1); 5__6 = ((Component)5__3.playerHealth).GetComponent(); if ((Object)(object)5__6 != (Object)null) { 5__6.RPC("UpdateHealthRPC", (RpcTarget)0, new object[4] { 5__1, 5__5, true, false }); } Logger.LogInfo((object)$"[JustRetryPlus] Successfully healed {5__4} to {5__1} HP."); 5__4 = null; 5__6 = null; } 5__3 = null; } } finally { ((IDisposable)<>s__2).Dispose(); } <>s__2 = default(List.Enumerator); if ((Object)(object)StatsManager.instance != (Object)null) { if (StatsManager.instance.runStats.ContainsKey("chargingStationChargeTotal")) { StatsManager.instance.runStats["chargingStationCharge"] = StatsManager.instance.runStats["chargingStationChargeTotal"]; } else { StatsManager.instance.runStats["chargingStationCharge"] = 100; } 5__7 = new List(StatsManager.instance.itemStatBattery.Keys); <>s__8 = 5__7.GetEnumerator(); try { while (<>s__8.MoveNext()) { 5__9 = <>s__8.Current; StatsManager.instance.itemStatBattery[5__9] = 100; 5__9 = null; } } finally { ((IDisposable)<>s__8).Dispose(); } <>s__8 = default(List.Enumerator); 5__7 = null; } if ((Object)(object)runner != (Object)null && (Object)(object)((Component)runner).gameObject != (Object)null) { Object.Destroy((Object)(object)((Component)runner).gameObject); } return false; } IL_00cd: if (!LevelGenerator.Instance.Generated) { <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 3; return true; } goto IL_0102; IL_008a: if ((Object)(object)GameDirector.instance == (Object)null || (Object)(object)LevelGenerator.Instance == (Object)null) { <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 2; return true; } goto IL_00cd; IL_0102: if (GameDirector.instance.PlayerList == null || GameDirector.instance.PlayerList.Count < PhotonNetwork.PlayerList.Length) { <>2__current = (object)new WaitForSeconds(0.5f); <>1__state = 4; return true; } <>2__current = (object)new WaitForSeconds(1.5f); <>1__state = 5; return true; } } 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 Logger; private static ConfigEntry _shouldResetLevel; private static ConfigEntry _shouldHealAfterFail; private static ConfigEntry _isEnabled; private static ConfigEntry _healthToHeal; public static Plugin Instance; public static bool ShouldResetLevel => _shouldResetLevel.Value; public static bool ShouldHealAfterFail => _shouldHealAfterFail.Value; public static bool DidFailLevel { get; set; } public static bool IsEnabled => _isEnabled.Value; public static int HealthToHealValue => _healthToHeal.Value; private void Awake() { //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_004d: Expected O, but got Unknown //IL_0081: Unknown result type (might be due to invalid IL or missing references) //IL_0090: Expected O, but got Unknown //IL_008b: Unknown result type (might be due to invalid IL or missing references) //IL_0095: Expected O, but got Unknown //IL_00b7: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Expected O, but got Unknown //IL_00c1: Unknown result type (might be due to invalid IL or missing references) //IL_00cb: Expected O, but got Unknown //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00fc: Expected O, but got Unknown //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_0101: Expected O, but got Unknown //IL_0128: Unknown result type (might be due to invalid IL or missing references) //IL_0137: Expected O, but got Unknown //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Expected O, but got Unknown Instance = this; Logger = ((BaseUnityPlugin)this).Logger; Logger.LogInfo((object)"Plugin JustRetryPlus is loaded!"); Logger.LogInfo((object)"Thanks for nickklmao for the original Idea and bits of code! please check out their mods on Thunderstore!"); Logger.LogInfo((object)"Without them this mod wouldn't be possible!"); Harmony val = new Harmony("eu.xaru.justretryplus"); val.PatchAll(); Logger.LogInfo((object)"Harmony patches applied."); _isEnabled = ((BaseUnityPlugin)this).Config.Bind("Settings", "IsEnabled", true, new ConfigDescription("Toggle if the plugin should be enabled, if false the normal game death scene will take over", (AcceptableValueBase)new AcceptableValueRange(false, true), Array.Empty())); _shouldResetLevel = ((BaseUnityPlugin)this).Config.Bind("Settings", "ShouldResetLevel", false, new ConfigDescription("Toggle if the game should restart at level one & reset the map when failing a level", (AcceptableValueBase)new AcceptableValueRange(false, true), Array.Empty())); _shouldHealAfterFail = ((BaseUnityPlugin)this).Config.Bind("Settings", "ShouldHealAfterFail", true, new ConfigDescription("Toggle if the game should restart with full health when failing a level", (AcceptableValueBase)new AcceptableValueRange(false, true), Array.Empty())); _healthToHeal = ((BaseUnityPlugin)this).Config.Bind("Settings", "HealthToHeal", 100, new ConfigDescription("The amount of health to heal when failing a level", (AcceptableValueBase)new AcceptableValueRange(0, 500), Array.Empty())); } private void Start() { Logger.LogInfo((object)"JustRetryPlus started!"); } [IteratorStateMachine(typeof(d__20))] public static IEnumerator HandleRestartHeal(MonoBehaviour runner) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new d__20(0) { runner = runner }; } } public static class PluginInfo { public const string PLUGIN_GUID = "JustRetryPlus"; public const string PLUGIN_NAME = "JustRetryPlus"; public const string PLUGIN_VERSION = "1.0.3"; } }