using System;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
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 RiskOfOptions;
using RiskOfOptions.Options;
using RoR2;
using UnityEngine;
using Zio;
using Zio.FileSystems;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("UserProfilesSelector")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+cfd44c4bbf5f322c988056455d0ec5834d27f225")]
[assembly: AssemblyProduct("UserProfilesSelector")]
[assembly: AssemblyTitle("UserProfilesSelector")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.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;
}
}
[EditorBrowsable(EditorBrowsableState.Never)]
public static class IsExternalInit
{
}
}
namespace UserProfilesSelector
{
internal static class Log
{
private static ManualLogSource _logSource;
internal static void Init(ManualLogSource logSource)
{
_logSource = logSource;
}
internal static void Debug(object data)
{
_logSource.LogDebug(data);
}
internal static void Error(object data)
{
_logSource.LogError(data);
}
internal static void Fatal(object data)
{
_logSource.LogFatal(data);
}
internal static void Info(object data)
{
_logSource.LogInfo(data);
}
internal static void Message(object data)
{
_logSource.LogMessage(data);
}
internal static void Warning(object data)
{
_logSource.LogWarning(data);
}
}
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInPlugin("Lawlzee.UserProfilesSelector", "UserProfilesSelector", "1.0.0")]
public class UserProfilesSelectorPlugin : BaseUnityPlugin
{
public const string PluginGUID = "Lawlzee.UserProfilesSelector";
public const string PluginAuthor = "Lawlzee";
public const string PluginName = "UserProfilesSelector";
public const string PluginVersion = "1.0.0";
public static ConfigEntry<string> ProfilesFolder;
public void Awake()
{
//IL_0034: Unknown result type (might be due to invalid IL or missing references)
//IL_003e: Expected O, but got Unknown
//IL_0045: Unknown result type (might be due to invalid IL or missing references)
//IL_004f: Expected O, but got Unknown
//IL_0056: Unknown result type (might be due to invalid IL or missing references)
//IL_0060: Expected O, but got Unknown
//IL_0085: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
Log.Init(((BaseUnityPlugin)this).Logger);
ProfilesFolder = ((BaseUnityPlugin)this).Config.Bind<string>("Configuration", "User profiles folder", "UserProfiles2", "Choose the folder that stores the profiles. See C:\\Program Files (x86)\\Steam\\userdata\\<number>\\632360\\remote");
ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(ProfilesFolder));
SaveSystem.PlatformInitProfile += new hook_PlatformInitProfile(SaveSystem_PlatformInitProfile);
SaveSystem.LoadUserProfiles += new hook_LoadUserProfiles(SaveSystem_LoadUserProfiles);
Texture2D val = LoadTexture("icon.png");
ModSettingsManager.SetModIcon(Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0f, 0f)));
}
private void SaveSystem_PlatformInitProfile(orig_PlatformInitProfile orig, SaveSystem self, ref UserProfile newProfile, IFileSystem fileSystem, string name)
{
//IL_0048: Unknown result type (might be due to invalid IL or missing references)
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
orig.Invoke(self, ref newProfile, fileSystem, name);
newProfile.filePath = UPath.op_Implicit("/" + ProfilesFolder.Value + "/" + newProfile.fileName + ".xml");
}
private void SaveSystem_LoadUserProfiles(orig_LoadUserProfiles orig, SaveSystem self)
{
//IL_003c: Unknown result type (might be due to invalid IL or missing references)
//IL_007c: Unknown result type (might be due to invalid IL or missing references)
//IL_005d: Unknown result type (might be due to invalid IL or missing references)
//IL_008f: Unknown result type (might be due to invalid IL or missing references)
//IL_0094: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Unknown result type (might be due to invalid IL or missing references)
//IL_009e: Unknown result type (might be due to invalid IL or missing references)
//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
//IL_00db: Unknown result type (might be due to invalid IL or missing references)
//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
self.badFileResults.Clear();
self.loadedUserProfiles.Clear();
UserProfile.LoadDefaultProfile();
FileSystem cloudStorage = RoR2Application.cloudStorage;
if (cloudStorage != null)
{
if (!cloudStorage.DirectoryExists(UPath.op_Implicit("/" + ProfilesFolder.Value)))
{
cloudStorage.CreateDirectory(UPath.op_Implicit("/" + ProfilesFolder.Value));
}
foreach (UPath item in FileSystemExtensions.EnumeratePaths((IFileSystem)(object)cloudStorage, UPath.op_Implicit("/" + ProfilesFolder.Value)))
{
if (cloudStorage.FileExists(item) && string.CompareOrdinal(UPathExtensions.GetExtensionWithDot(item), ".xml") == 0)
{
LoadUserProfileOperationResult val = ((SaveSystemBase)self).LoadUserProfileFromDisk((IFileSystem)(object)cloudStorage, item);
UserProfile userProfile = val.userProfile;
if (userProfile != null)
{
self.loadedUserProfiles[userProfile.fileName] = userProfile;
}
if (val.exception != null)
{
self.badFileResults.Add(val);
}
}
}
self.OutputBadFileResults();
((Action)typeof(SaveSystem).GetField("onAvailableUserProfilesChanged", BindingFlags.Static | BindingFlags.NonPublic).GetValue(null))?.Invoke();
}
else
{
Debug.LogError((object)"cloud storage is null");
}
}
private Texture2D LoadTexture(string name)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0028: Expected O, but got Unknown
//IL_002a: Expected O, but got Unknown
Texture2D val = new Texture2D(2, 2);
ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location), name)));
return val;
}
}
}