Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Profiler v1.0.2
Profiler.dll
Decompiled a year agousing System; using System.Collections.Generic; using System.Diagnostics; using System.Linq; 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 Microsoft.CodeAnalysis; using On.RoR2; using Profiler.Features; using Profiler.Utils; using Rewired; using RoR2; using Zio; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")] [assembly: AssemblyCompany("SylentHuntress")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("MIT")] [assembly: AssemblyDescription("QOL mod for save files. Currently allows you to associate save files with modpacks.")] [assembly: AssemblyFileVersion("1.0.2.0")] [assembly: AssemblyInformationalVersion("1.0.2+d2e094fc17f9cb62c83421d211f4142124b9dc32")] [assembly: AssemblyProduct("Profiler")] [assembly: AssemblyTitle("Profiler")] [assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/SylentHuntress/Profiler")] [assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)] [assembly: AssemblyVersion("1.0.2.0")] [module: UnverifiableCode] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Microsoft.CodeAnalysis.Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Microsoft.CodeAnalysis.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; } } } namespace Profiler { [BepInPlugin("SylentHuntress.Profiler", "Profiler", "1.0.0")] public class Profiler : BaseUnityPlugin { [CompilerGenerated] private static class <>O { public static hook_AddUser <0>__SelectDefaultProfile; } public const string PluginGUID = "SylentHuntress.Profiler"; public const string PluginAuthor = "SylentHuntress"; public const string PluginName = "Profiler"; public const string PluginVersion = "1.0.0"; public void Awake() { Log.Init(((BaseUnityPlugin)this).Logger); Config.Init(((BaseUnityPlugin)this).Config); } private void OnEnable() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__SelectDefaultProfile; if (obj == null) { hook_AddUser val = DefaultProfileSelector.SelectDefaultProfile; <>O.<0>__SelectDefaultProfile = val; obj = (object)val; } LocalUserManager.AddUser += (hook_AddUser)obj; } private void OnDisable() { //IL_0010: Unknown result type (might be due to invalid IL or missing references) //IL_0015: Unknown result type (might be due to invalid IL or missing references) //IL_001b: Expected O, but got Unknown object obj = <>O.<0>__SelectDefaultProfile; if (obj == null) { hook_AddUser val = DefaultProfileSelector.SelectDefaultProfile; <>O.<0>__SelectDefaultProfile = val; obj = (object)val; } LocalUserManager.AddUser -= (hook_AddUser)obj; } } } namespace Profiler.Utils { internal static class Config { public static ConfigEntry<string> StartupProfile { get; private set; } public static ConfigEntry<bool> CreateStartupProfileIfAbsent { get; private set; } public static void Init(ConfigFile config) { StartupProfile = config.Bind<string>("Startup", "DefaultProfile", (string)null, "Which profile to select on startup. [username] parses to the user's username."); CreateStartupProfileIfAbsent = config.Bind<bool>("Startup", "CreateDefaultProfileIfAbsent", true, "Create default profile on startup if absent"); } } internal static class Log { private static ManualLogSource _logSource; internal static void Init(ManualLogSource logSource) { _logSource = logSource; Info("{}-{} has loaded!", "SylentHuntress.Profiler", "1.0.0"); } internal static void Debug(string message) { Debug(message, null); } internal static void Debug(string message, params object[] data) { _logSource.LogDebug((object)Write(message, data)); } internal static void Error(string message) { Error(message, null); } internal static void Error(string message, params object[] data) { _logSource.LogError((object)Write(message, data)); } internal static void Fatal(string message) { Fatal(message, null); } internal static void Fatal(string message, params object[] data) { _logSource.LogFatal((object)Write(message, data)); } internal static void Info(string message) { Info(message, null); } internal static void Info(string message, params object[] data) { _logSource.LogInfo((object)Write(message, data)); } internal static void Message(string message) { Message(message, null); } internal static void Message(string message, params object[] data) { _logSource.LogMessage((object)Write(message, data)); } internal static void Warning(string message) { Warning(message, null); } internal static void Warning(string message, params object[] data) { _logSource.LogWarning((object)Write(message, data)); } private static string Write(string message, params object[] data) { if (data == null) { return message; } int num = 0; foreach (object obj in data) { int num2 = message.IndexOf("{" + num + "}", StringComparison.Ordinal); int num3 = ("{" + num + "}").Length; if (num2 == -1) { num2 = message.IndexOf("{}", StringComparison.Ordinal); num3 = 2; if (num2 == -1) { break; } } string text = message.Substring(0, num2); string? obj2 = obj?.ToString(); string text2 = message; int num4 = num2 + num3; message = text + obj2 + text2.Substring(num4, text2.Length - num4); num++; } return message; } } } namespace Profiler.Features { internal static class DefaultProfileSelector { internal const string NameVariable = "[username]"; private static bool _hasRunOnce; public static void SelectDefaultProfile(orig_AddUser orig, Player player, UserProfile userProfile) { if (_hasRunOnce) { orig.Invoke(player, userProfile); return; } _hasRunOnce = true; Log.Info("The following save files were detected:"); foreach (UserProfile item in PlatformSystems.saveSystem.loadedUserProfiles.Select((KeyValuePair<string, UserProfile> entry) => entry.Value)) { Log.Info(" - {} ({})", item.name, item.fileName); } string text = ParseProfileName(Config.StartupProfile.Value); if (string.IsNullOrEmpty(text)) { Log.Info("No startup profile found. Defaulting..."); orig.Invoke(player, userProfile); return; } UserProfile val = null; foreach (UserProfile item2 in PlatformSystems.saveSystem.loadedUserProfiles.Select((KeyValuePair<string, UserProfile> entry) => entry.Value)) { if (item2.name == text) { val = item2; } } if (val == null) { if (!Config.CreateStartupProfileIfAbsent.Value) { Log.Warning("Profile {} not found. Fallback profile creation is disabled. Defaulting...", text); orig.Invoke(player, userProfile); return; } val = PlatformSystems.saveSystem.CreateProfile((IFileSystem)(object)RoR2Application.fileSystem, text, 0uL); Log.Warning("Profile {} not found. Fallback profile creation is enabled. Creating...", text); } Log.Info("Profile {} found! Selecting...", text); orig.Invoke(player, val); } private static string ParseProfileName(string name) { if (string.IsNullOrEmpty(name)) { return name; } return name.Replace("[username]", ((SaveSystemBase)PlatformSystems.saveSystem).GetPlatformUsernameOrDefault("Nameless Survivor")); } } }