Decompiled source of StartupHotfix v0.1.0

patchers/StartupHotfix.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx.Bootstrap;
using BepInEx.Logging;
using HarmonyLib;
using Mono.Cecil;
using Splatform;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("StartupHotfix")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("StartupHotfix")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("FE8B42E3-7082-4DFF-A5CC-6B62B0315ACA")]
[assembly: AssemblyFileVersion("0.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.0.0")]
[module: UnverifiableCode]
namespace StartupHotfix;

public static class Patcher
{
	public static ManualLogSource logger;

	public static IDistributionPlatform platform;

	public static IEnumerable<string> TargetDLLs { get; } = Array.Empty<string>();


	public static void Patch(AssemblyDefinition assembly)
	{
	}

	public static void Finish()
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Expected O, but got Unknown
		logger = Logger.CreateLogSource("StartupHotfix");
		Harmony val = new Harmony("com.maxsch.valheim.StartupHotfix.patcher");
		val.PatchAll(typeof(Patcher));
	}

	[HarmonyPatch(typeof(Chainloader), "Start")]
	[HarmonyPrefix]
	public static void FindPlaform()
	{
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Expected O, but got Unknown
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Expected O, but got Unknown
		Type type2 = AccessTools.AllTypes().FirstOrDefault((Type type) => type.Name == "SteamPlatform");
		if (type2 != null)
		{
			logger.LogInfo((object)"Setting Splatform SteamPlatform as distribution platform");
			platform = (IDistributionPlatform)Activator.CreateInstance(type2);
			PlatformManager.SetDistributionPlatform(platform);
			return;
		}
		Type type3 = AccessTools.AllTypes().FirstOrDefault((Type type) => type.Name == "XboxPlatform");
		if (type3 != null)
		{
			logger.LogInfo((object)"Setting Splatform XboxPlatform as distribution platform");
			platform = (IDistributionPlatform)Activator.CreateInstance(type3);
			PlatformManager.SetDistributionPlatform(platform);
		}
		else
		{
			logger.LogWarning((object)"SteamPlatform is not found");
		}
	}

	[HarmonyPatch(/*Could not decode attribute arguments.*/)]
	[HarmonyPostfix]
	public static void SetDistributionPlatform(ref IDistributionPlatform __result)
	{
		if (__result == null && platform != null)
		{
			__result = platform;
		}
	}
}