using System; 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; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.7.1", FrameworkDisplayName = "")] [assembly: AssemblyCompany("FileCopyPreLoader")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyFileVersion("1.0.0.0")] [assembly: AssemblyInformationalVersion("1.0.0")] [assembly: AssemblyProduct("FileCopyPreLoader")] [assembly: AssemblyTitle("FileCopyPreLoader")] [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; } } } namespace FileCopyPreLoader { [BepInPlugin("FileCopyPreLoader", "FileCopyPreLoader", "1.0.0")] public class FileCopyPreloader : BaseUnityPlugin { internal static ManualLogSource Log; private static ConfigEntry configSourceFile; private static ConfigEntry configOverwriteExisting; private static ConfigEntry configBackupExisting; private static ConfigEntry configEnabled; private void Awake() { Log = ((BaseUnityPlugin)this).Logger; InitializeConfig(); if (configEnabled.Value) { try { CopyFile(); return; } catch (Exception ex) { Log.LogError((object)("文件复制失败: " + ex.Message)); Log.LogDebug((object)ex); return; } } Log.LogInfo((object)"插件已禁用,跳过文件复制"); } private void InitializeConfig() { configEnabled = ((BaseUnityPlugin)this).Config.Bind("General", "Enabled", true, "启用/禁用插件"); configSourceFile = ((BaseUnityPlugin)this).Config.Bind("File Copy", "SourceFile", "Fonts/arialuni_sdf_u2022", "要复制的源文件路径(相对于BepInEx配置文件目录)"); configOverwriteExisting = ((BaseUnityPlugin)this).Config.Bind("File Copy", "OverwriteExisting", true, "是否覆盖已存在的目标文件"); configBackupExisting = ((BaseUnityPlugin)this).Config.Bind("File Copy", "BackupExisting", false, "是否备份已存在的目标文件(备份文件会添加.bak后缀)"); } private void CopyFile() { string text = Path.Combine(Paths.ConfigPath, configSourceFile.Value); if (!File.Exists(text)) { Log.LogError((object)("源文件不存在: " + text)); return; } string gameRootPath = Paths.GameRootPath; string fileName = Path.GetFileName(text); string text2 = Path.Combine(gameRootPath, fileName); Log.LogInfo((object)"准备复制文件:"); Log.LogInfo((object)("源: " + text)); Log.LogInfo((object)("目标: " + text2)); if (File.Exists(text2)) { if (configBackupExisting.Value) { string text3 = text2 + ".bak"; File.Copy(text2, text3, overwrite: true); Log.LogInfo((object)("已备份现有文件到: " + text3)); } if (!configOverwriteExisting.Value) { Log.LogWarning((object)"目标文件已存在且未启用覆盖选项,跳过复制"); return; } } File.Copy(text, text2, overwrite: true); Log.LogInfo((object)"文件复制成功!"); } } public static class MyPluginInfo { public const string PLUGIN_GUID = "FileCopyPreLoader"; public const string PLUGIN_NAME = "FileCopyPreLoader"; public const string PLUGIN_VERSION = "1.0.0"; } }