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 UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("PersonalSuits")]
[assembly: AssemblyDescription("A mod for Lethal Company utilizing MoreSuits by x753, this .dll creates a config option to toggle the presence of a !less-suits.txt file")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PersonalSuits")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c2520e1b-d3fd-4900-9485-af52ef10e43b")]
[assembly: AssemblyFileVersion("1.2.7.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.2.7.0")]
namespace PersonalSuits;
[BepInPlugin("FaurinFox.PersonalSuits", "PersonalSuits", "1.2.7")]
public class ModPersonalSuits : BaseUnityPlugin
{
private const string Author = "FaurinFox";
private const string Name = "PersonalSuits";
private const string GUID = "FaurinFox.PersonalSuits";
private const string Version = "1.2.7";
private readonly Harmony harmony = new Harmony("FaurinFox.PersonalSuits");
internal static ManualLogSource logSource;
private static ModPersonalSuits Instance;
private static string CreationState;
private ConfigEntry<bool> ConfigCreateLessSuits;
public static bool CreateLessSuits;
private static string ModFolder => Path.Combine(Paths.PluginPath, "FaurinFox-PersonalSuits");
private static string LessSuitsFile => Path.Combine(ModFolder, "moresuits", "!less-suits.txt");
public void Awake()
{
if ((Object)(object)Instance == (Object)null)
{
Instance = this;
}
logSource = Logger.CreateLogSource("FaurinFox.PersonalSuits");
ConfigCreateLessSuits = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Create !less-suits.txt", false, "When true, creates a !less-suits.txt file for this mod in order to make MoreSuits not load additional suits, provided it is configured to respect this file. When false, this file will not be created, or if it has been created, will be removed.");
CreateLessSuits = ConfigCreateLessSuits.Value;
if (CreateLessSuits)
{
CreationState = "enabled";
}
else
{
CreationState = "disabled";
}
logSource.LogInfo((object)("Creation of !less-suits.txt is " + CreationState));
HandleLessSuitsFile();
harmony.PatchAll(typeof(ModPersonalSuits));
}
private void HandleLessSuitsFile()
{
try
{
if (CreateLessSuits)
{
if (!File.Exists(LessSuitsFile))
{
logSource.LogInfo((object)"Creation of !less-suits.txt was enabled, but it did not exist. Creating.");
File.WriteAllText(LessSuitsFile, "ThisFilePreventsMoreSuitsFromLoadingOtherSuitsIfConfiguredToRespectThisFile.png");
logSource.LogInfo((object)"!less-suits.txt created.");
}
}
else if (File.Exists(LessSuitsFile))
{
File.Delete(LessSuitsFile);
logSource.LogInfo((object)"Creation of !less-suits.txt was disabled, but it exists. Removing.");
logSource.LogInfo((object)"!less-suits.txt removed.");
}
}
catch (Exception ex)
{
logSource.LogError((object)("Error handling !less-suits.txt: " + ex.Message));
}
}
}