Decompiled source of NoMoreCosmetics v1.3.1

NoMoreCosmetics.dll

Decompiled 3 months ago
using System;
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.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using MoreCompany;
using MoreCompany.Cosmetics;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("NoMoreCosmetics")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NoMoreCosmetics")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a3b9bbf3-e125-4a5a-9779-c1b457b92202")]
[assembly: AssemblyFileVersion("1.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace NoMoreCosmetics;

[BepInPlugin("lufurrius.NoMoreCosmetics", "NoMoreConsmetics", "1.3.0")]
public class Plugin : BaseUnityPlugin
{
	private const string modGUID = "lufurrius.NoMoreCosmetics";

	private const string modName = "NoMoreConsmetics";

	private const string modVersion = "1.3.0";

	private readonly Harmony harmony = new Harmony("lufurrius.NoMoreCosmetics");

	public static ManualLogSource logger;

	private static Plugin Instance;

	private ConfigFile moreCompanyConfig;

	public static string dynamicCosmeticsPath;

	public static string cosmeticSavePath;

	private void Awake()
	{
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Expected O, but got Unknown
		if ((Object)(object)Instance == (Object)null)
		{
			Instance = this;
		}
		logger = Logger.CreateLogSource("NoMoreConsmetics");
		logger.LogInfo((object)"Loading lufurrius.NoMoreCosmetics 1.3.0\r\n    ________                 ____\r\n  _/ ______ \\_   |\\     |   /    \\\r\n /O /      \\ O\\  | \\    |  |      |\r\n \\O \\______/ O/  |  \\   |  |      |\r\n  '-/  \\/  \\-'   |   \\  |  |      |\r\n  .-\\__/\\__/-.   |    \\ |  |      |\r\n /            \\  |     \\|   \\____/\r\n ");
		string text = Path.Combine(Paths.ConfigPath, "me.swipez.melonloader.morecompany.cfg");
		if (File.Exists(text))
		{
			moreCompanyConfig = new ConfigFile(text, true);
			bool value = moreCompanyConfig.Bind<bool>("Cosmetics", "Per Profile Cosmetics", false, "Should the cosmetics be saved per-profile?").Value;
			logger.LogInfo((object)$"MoreCompany \"Per Profile Cosmetics\" config value: {value}");
			if (value)
			{
				cosmeticSavePath = (Application.persistentDataPath + "/morecompanycosmetics-" + Directory.GetParent(Paths.BepInExRootPath).Name).Replace("/", "\\");
			}
			else
			{
				cosmeticSavePath = (Application.persistentDataPath + "/morecompanycosmetics").Replace("/", "\\");
			}
		}
		else
		{
			logger.LogWarning((object)"MoreCompany config not found! Assuming it's default values");
			cosmeticSavePath = (Application.persistentDataPath + "/morecompanycosmetics").Replace("/", "\\");
		}
		logger.LogInfo((object)("Player cosmetics save path: " + cosmeticSavePath));
		File.WriteAllText(cosmeticSavePath + ".txt", "");
		File.WriteAllText(cosmeticSavePath + ".mcs", "");
		CosmeticRegistry.locallySelectedCosmetics.Clear();
		try
		{
			logger.LogInfo((object)"Patching MoreCompany cosmetic loaders...");
			harmony.PatchAll();
		}
		catch (Exception ex)
		{
			logger.LogError((object)("Failed applying patch: " + ex));
		}
		logger.LogInfo((object)"Finished loading NoMoreConsmetics!");
	}
}
[HarmonyPatch(typeof(MainClass), "ReadCosmeticsFromFile")]
public class CosmeticPatch
{
	private static void Postfix()
	{
		CosmeticRegistry.locallySelectedCosmetics.Clear();
	}
}
[HarmonyPatch(typeof(CosmeticRegistry), "LoadCosmeticsFromBundle")]
public class CosmeticBundlePatch
{
	private static bool Prefix()
	{
		return false;
	}
}
[HarmonyPatch(typeof(CosmeticRegistry), "LoadCosmeticsFromAssembly")]
public class CosmeticAssemblyePatch
{
	private static bool Prefix()
	{
		return false;
	}
}
[HarmonyPatch(typeof(CosmeticRegistry), "SpawnCosmeticGUI")]
public class CosmeticUIPatch
{
	private static bool Prefix()
	{
		return false;
	}
}