using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using LethalLevelLoader;
using UnityEngine;
using WesleyMoonsProgressSaver.Patches;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("WesleyMoonsProgressSaver")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WesleyMoonsProgressSaver")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("d671060e-794a-4f15-8233-c8dd6f786b78")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace WesleyMoonsProgressSaver.Patches
{
[HarmonyPatch(typeof(ExtendedLevelData), "ApplySavedValues")]
internal class MoonsDataLoader
{
internal ManualLogSource manualLogSource;
public void Prefix(ExtendedLevelData __instance, ExtendedLevel extendedLevel)
{
//IL_0024: Unknown result type (might be due to invalid IL or missing references)
//IL_0035: Unknown result type (might be due to invalid IL or missing references)
string filePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "levelsData.txt");
Dictionary<string, Tuple<bool, bool>> dictionary = LoadLevelDataFromFile(filePath);
if (dictionary.ContainsKey(__instance.uniqueIdentifier))
{
Tuple<bool, bool> tuple = dictionary[__instance.uniqueIdentifier];
extendedLevel.IsRouteHidden = tuple.Item1;
extendedLevel.IsRouteLocked = tuple.Item2;
}
}
private Dictionary<string, Tuple<bool, bool>> LoadLevelDataFromFile(string filePath)
{
Dictionary<string, Tuple<bool, bool>> dictionary = new Dictionary<string, Tuple<bool, bool>>();
manualLogSource = Logger.CreateLogSource("imabatby.lethallevelloader");
try
{
if (!File.Exists(filePath))
{
File.Create(filePath).Dispose();
manualLogSource.LogInfo((object)"Configuration file not found, created new file.");
}
foreach (string item3 in File.ReadLines(filePath))
{
string[] array = item3.Split(new char[1] { ':' });
if (array.Length == 3)
{
string key = array[0].Trim();
bool item = bool.Parse(array[1].Trim());
bool item2 = bool.Parse(array[2].Trim());
dictionary[key] = new Tuple<bool, bool>(item, item2);
}
}
}
catch (Exception ex)
{
manualLogSource.LogError((object)("Error reading file: " + ex.Message));
}
return dictionary;
}
}
}
namespace WesleysMoonsProgressSaver
{
[BepInPlugin("Lance.WesleysMoonsProgressionSaver", "WesleysMoonsProgressionSaver", "1.0.0")]
public class ModBase : BaseUnityPlugin
{
private const string modGUID = "Lance.WesleysMoonsProgressionSaver";
private const string modName = "WesleysMoonsProgressionSaver";
private const string modVersion = "1.0.0";
private readonly Harmony harmony = new Harmony("Lance.WesleysMoonsProgressionSaver");
private static ModBase Instance;
internal ManualLogSource manualLogSource;
private void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
manualLogSource = Logger.CreateLogSource("Lance.WesleysMoonsProgressionSaver");
manualLogSource.LogInfo((object)"Starting WesleysMoonsProgressionSaver");
harmony.PatchAll(typeof(ModBase));
harmony.PatchAll(typeof(MoonsDataLoader));
}
}
}