using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using UnityEngine;
[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ValheimMod_Bootconfig")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("ValheimMod_Bootconfig")]
[assembly: AssemblyCopyright("Copyright © 2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("c8d2cc1c-5b98-403d-9d74-de030697f7da")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
[BepInPlugin("sx66627.bootconfig", "BootConfig", "0.1")]
public class BootConfigModifier : BaseUnityPlugin
{
private void Awake()
{
try
{
string path = Path.Combine(Application.dataPath, "boot.config");
if (!File.Exists(path))
{
File.Create(path).Close();
}
List<string> list = File.ReadAllLines(path).ToList();
Dictionary<string, string> dictionary = new Dictionary<string, string>();
foreach (string item in list)
{
Match match = Regex.Match(item, "^(.*?)=(.*)$");
if (match.Success)
{
dictionary[match.Groups[1].Value.Trim()] = match.Groups[2].Value.Trim();
}
}
int processorCount = Environment.ProcessorCount;
dictionary["gfx-enable-gfx-jobs"] = "1";
dictionary["gfx-enable-native-gfx-jobs"] = "1";
dictionary["scripting-runtime-version"] = "latest";
dictionary["wait-for-native-debugger"] = "0";
dictionary["vr-enabled"] = "0";
dictionary["hdr-display-enabled"] = "0";
dictionary["gc-max-time-slice"] = processorCount.ToString();
List<string> list2 = new List<string>();
foreach (KeyValuePair<string, string> item2 in dictionary)
{
list2.Add(item2.Key + "=" + item2.Value);
}
File.WriteAllLines(path, list2);
((BaseUnityPlugin)this).Logger.LogInfo((object)"boot.config updated successfully.");
}
catch (Exception ex)
{
((BaseUnityPlugin)this).Logger.LogError((object)("Error while processing boot.config: " + ex.Message));
}
}
}