using System;
using System.Diagnostics;
using System.Linq;
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 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.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;
}
}
[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
{
[BepInPlugin("JustRetryPlus", "JustRetryPlus", "1.0.3")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Logger;
private static ConfigEntry<bool> _shouldResetLevel;
private static ConfigEntry<bool> _shouldHealAfterFail;
private static ConfigEntry<bool> _isEnabled;
private static ConfigEntry<int> _healthToHeal;
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_0041: Unknown result type (might be due to invalid IL or missing references)
//IL_0047: Expected O, but got Unknown
//IL_0080: Unknown result type (might be due to invalid IL or missing references)
//IL_008a: Expected O, but got Unknown
//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
//IL_00bb: Expected O, but got Unknown
//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
//IL_00ec: Expected O, but got Unknown
//IL_0118: Unknown result type (might be due to invalid IL or missing references)
//IL_0122: Expected O, but got Unknown
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<bool>("Settings", "IsEnabled", true, new ConfigDescription("Toggle if the plugin should be enabled, if false the normal game death scene will take over", (AcceptableValueBase)(object)new AcceptableValueRange<bool>(false, true), Array.Empty<object>()));
_shouldResetLevel = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "ShouldResetLevel", false, new ConfigDescription("Toggle if the game should restart at level one & reset the map when failing a level", (AcceptableValueBase)(object)new AcceptableValueRange<bool>(false, true), Array.Empty<object>()));
_shouldHealAfterFail = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "ShouldHealAfterFail", true, new ConfigDescription("Toggle if the game should restart with full health when failing a level", (AcceptableValueBase)(object)new AcceptableValueRange<bool>(false, true), Array.Empty<object>()));
_healthToHeal = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "HealthToHeal", 100, new ConfigDescription("The amount of health to heal when failing a level", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 500), Array.Empty<object>()));
}
private void Start()
{
Logger.LogInfo((object)"JustRetryPlus started!");
}
}
[HarmonyPatch(typeof(RunManager), "ChangeLevel")]
public static class ChangeLevelPatch
{
private static void Prefix(RunManager __instance, ref bool _completedLevel, ref bool _levelFailed, ref ChangeLevelType _changeLevelType)
{
if (!Plugin.IsEnabled)
{
return;
}
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();
}
Plugin.Logger.LogInfo((object)"Level failed, retrying...");
__instance.RestartScene();
Plugin.Logger.LogInfo((object)"Restarted scene");
}
}
}
[HarmonyPatch(typeof(RoundDirector), "StartRoundLogic")]
public static class RoundDirectorPatch
{
private static void Postfix(RoundDirector __instance)
{
if (!Plugin.IsEnabled || !Plugin.ShouldHealAfterFail || !Plugin.DidFailLevel || !SemiFunc.IsMasterClientOrSingleplayer())
{
return;
}
foreach (PlayerHealth item in from player in SemiFunc.PlayerGetAll()
select player.playerHealth)
{
if (!((Object)(object)item == (Object)null))
{
item.HealOther(Plugin.HealthToHealValue, true);
}
}
}
}
public static class MyPluginInfo
{
public const string PLUGIN_GUID = "JustRetryPlus";
public const string PLUGIN_NAME = "JustRetryPlus";
public const string PLUGIN_VERSION = "1.0.3";
}
}