using System;
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;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyCompany("amione.InfiniteSave")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+db84c8be58998cba7edeb2f8999e707d658a5ad6")]
[assembly: AssemblyProduct("InfiniteSave")]
[assembly: AssemblyTitle("amione.InfiniteSave")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
[CompilerGenerated]
[Embedded]
internal sealed class EmbeddedAttribute : Attribute
{
}
}
namespace System.Runtime.CompilerServices
{
[CompilerGenerated]
[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;
}
}
}
internal static class PluginInfo
{
public const string PluginGuid = "amione.InfiniteSave";
public const string PluginName = "InfiniteSave";
public const string PluginVersion = "1.0.0";
}
namespace InfiniteSave
{
[BepInPlugin("amione.InfiniteSave", "InfiniteSave", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
internal static ManualLogSource Log;
internal static ConfigEntry<bool> InfiniteDiscSaves;
internal static ConfigEntry<bool> NotifyInConsole;
private void Awake()
{
//IL_0051: Unknown result type (might be due to invalid IL or missing references)
//IL_0057: Expected O, but got Unknown
Log = ((BaseUnityPlugin)this).Logger;
InfiniteDiscSaves = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "InfiniteDiscSaves", true, "When enabled, loading/reviving from a disc save never spends a use. The save stays exactly as valid as it was before you loaded it, forever, instead of eventually running out and being deleted.");
NotifyInConsole = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "NotifyInConsole", true, "Print a short message in the in-game developer console every time a disc save is protected from being used up.");
Harmony val = new Harmony("amione.InfiniteSave");
val.PatchAll();
Log.LogInfo((object)"InfiniteSave v1.0.0 loaded - disc saves will no longer be consumed.");
}
}
[HarmonyPatch(typeof(SaveState), "LoadSave")]
internal static class SaveState_LoadSave_Patch
{
private static void Prefix(SaveState __instance)
{
//IL_0019: Unknown result type (might be due to invalid IL or missing references)
//IL_001f: Invalid comparison between Unknown and I4
if (Plugin.InfiniteDiscSaves.Value && __instance != null && (int)__instance.type == 1)
{
__instance.amount++;
if (Plugin.NotifyInConsole.Value)
{
CommandConsole.Log("<color=grey>[InfiniteSave] Disc save use restored - this save will not run out.</color>");
}
Plugin.Log.LogInfo((object)$"Protected disc save '{__instance.id}' from being consumed (amount bumped to {__instance.amount} before load).");
}
}
}
}