Decompiled source of DK UnlockOnStartPlus v1.0.0

DK_UnlockOnStartPlus.dll

Decompiled 4 days ago
using System;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using DK_LethalMod;
using DK_LethalMod.Patches;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnlockOnStart;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("DK_LethalMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("DK_LethalMod")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a0bf24d0-862f-4bc6-87d7-9452a7f63997")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: NeutralResourcesLanguage("en")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[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;
		}
	}
}
public class Logger
{
	private static readonly string logFilePath;

	private static readonly string FileName;

	private const long MaxFileSize = 524288000L;

	static Logger()
	{
		FileName = "DK_Logs.txt";
		try
		{
			logFilePath = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), FileName);
			if (!File.Exists(logFilePath))
			{
				File.Create(logFilePath).Dispose();
			}
		}
		catch (Exception ex)
		{
			Variables.mls.LogError((object)("Error in Logger static constructor: " + ex.Message));
		}
	}

	public static void Log(string message)
	{
		try
		{
			if (new FileInfo(logFilePath).Length > 524288000)
			{
				File.WriteAllText(logFilePath, "");
			}
			using StreamWriter streamWriter = File.AppendText(logFilePath);
			streamWriter.WriteLine($"{DateTime.Now}: {message}\n");
		}
		catch (Exception ex)
		{
			Variables.mls.LogError((object)("--------- Error in logging: " + ex.Message + " ---------"));
		}
	}

	public static void Close()
	{
		Log("---End of Session---");
	}

	public static void Start()
	{
		Log("---Start of Session---");
	}
}
namespace DK_LethalMod
{
	public class Config
	{
		public ConfigEntry<bool> UseLethalConfigListener;

		public ConfigEntry<bool> Unlock_Microwave;

		public ConfigEntry<bool> Unlock_Sofa;

		public ConfigEntry<bool> Unlock_Fridge;

		public ConfigEntry<bool> Unlock_ClassicPainting;

		public ConfigEntry<bool> Unlock_ElectricChair;

		public ConfigEntry<bool> Unlock_DogHouse;

		public ConfigEntry<int> BeltBag;

		public Config(ConfigFile cfg)
		{
			UseLethalConfigListener = cfg.Bind<bool>("Lethal Config", "Use Listener", false, "If you use Lethal Config settings this to true will try to load the changes made at runtime if applicable.");
			Unlock_Microwave = cfg.Bind<bool>("UnlockOnStart", "Unlock Microwave", false, "Unlock Microwave on new file.");
			Unlock_Sofa = cfg.Bind<bool>("UnlockOnStart", "Unlock Sofa", false, "Unlock Sofa on new file.");
			Unlock_Fridge = cfg.Bind<bool>("UnlockOnStart", "Unlock Fridge", false, "Unlock Fridge on new file.");
			Unlock_ClassicPainting = cfg.Bind<bool>("UnlockOnStart", "Unlock Painting", false, "Unlock Painting on new file.");
			Unlock_ElectricChair = cfg.Bind<bool>("UnlockOnStart", "Unlock Electric Chair", false, "Unlock Electric Chair on new file.");
			Unlock_DogHouse = cfg.Bind<bool>("UnlockOnStart", "Unlock DogHouse", false, "Unlock DogHouse on new file.");
			BeltBag = cfg.Bind<int>("UnlockOnStart", "Belt Bag", 0, "If greater than 0 spawns belt bags on new file.");
		}
	}
	[BepInPlugin("DarklordKnaag.UnlockOnStartPlus", "DK Unlock On Start Plus", "1.0.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		private const string modGUID = "DarklordKnaag.UnlockOnStartPlus";

		private const string modName = "DK Unlock On Start Plus";

		private const string modVersion = "1.0.0.0";

		private bool allowUpdate = false;

		public static Plugin instance;

		private readonly Harmony harmony = new Harmony("DarklordKnaag.UnlockOnStartPlus");

		private void Awake()
		{
			if ((Object)(object)instance == (Object)null)
			{
				instance = this;
			}
			Variables.mls = Logger.CreateLogSource("DarklordKnaag.UnlockOnStartPlus");
			Variables.config = new Config(((BaseUnityPlugin)this).Config);
			harmony.PatchAll(typeof(Plugin));
			harmony.PatchAll(typeof(UnlockOnStart_Extender));
			Variables.mls.LogInfo((object)"Base Awake :)");
			allowUpdate = true;
		}

		private void Update()
		{
			if (allowUpdate && Variables.config.UseLethalConfigListener.Value && Variables.reloadConfig > 0f)
			{
				Variables.reloadConfig -= Time.deltaTime;
				if (Variables.reloadConfig < 0f)
				{
					Variables.config = new Config(((BaseUnityPlugin)this).Config);
				}
			}
		}
	}
	public static class Variables
	{
		public static ManualLogSource mls;

		public static Config config;

		public static float reloadConfig = -1f;
	}
}
namespace DK_LethalMod.Patches
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	internal class UnlockOnStart_Extender
	{
		[HarmonyPatch(typeof(Plugin), "Awake")]
		[HarmonyPostfix]
		public static void DataPatch()
		{
			try
			{
				Unlockables.DecorationDictionary.Add("Microwave", Variables.config.Unlock_Microwave.Value);
				Unlockables.DecorationDictionary.Add("Sofa chair", Variables.config.Unlock_Sofa.Value);
				Unlockables.DecorationDictionary.Add("Fridge", Variables.config.Unlock_Fridge.Value);
				Unlockables.DecorationDictionary.Add("Classic painting", Variables.config.Unlock_ClassicPainting.Value);
				Unlockables.DecorationDictionary.Add("Electric chair", Variables.config.Unlock_ElectricChair.Value);
				Unlockables.DecorationDictionary.Add("Dog house", Variables.config.Unlock_DogHouse.Value);
				Unlockables.ItemsDictionary.Add("Belt bag", Variables.config.BeltBag.Value);
			}
			catch (Exception ex)
			{
				Logger.Log("Exception in UnlockOnStart.DataPatch(): " + ex.Message);
			}
		}
	}
}