Decompiled source of HotswapFix v1.0.0

BepInEx/plugins/HotswapFix.dll

Decompiled a day ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("HotswapFix")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HotswapFix")]
[assembly: AssemblyTitle("HotswapFix")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[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;
		}
	}
}
[BepInPlugin("sparroh.hotswapfix", "HotswapFix", "1.0.0")]
[MycoMod(/*Could not decode attribute arguments.*/)]
public class HotswapFixPlugin : BaseUnityPlugin
{
	public const string PluginGUID = "sparroh.hotswapfix";

	public const string PluginName = "HotswapFix";

	public const string PluginVersion = "1.0.0";

	internal static ManualLogSource Log;

	private Harmony _harmony;

	private void Awake()
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Expected O, but got Unknown
		Log = ((BaseUnityPlugin)this).Logger;
		_harmony = new Harmony("sparroh.hotswapfix");
		_harmony.PatchAll(typeof(ScoutLaserRiflePatches));
		Log.LogInfo((object)"HotswapFix v1.0.0 loaded — Hotswap will keep Laser as the default mode after menus/missions.");
	}

	private void OnDestroy()
	{
		Harmony harmony = _harmony;
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
	}
}
[HarmonyPatch(typeof(ScoutLaserRifle))]
internal static class ScoutLaserRiflePatches
{
	private static readonly FieldInfo ToggleLaserOnUpgradesEnabledField = AccessTools.Field(typeof(ScoutLaserRifle), "toggleLaserOnUpgradesEnabled");

	[HarmonyPatch("AfterUpgradesEnabled")]
	[HarmonyPrefix]
	private static void AfterUpgradesEnabled_Prefix(ScoutLaserRifle __instance)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		if (UpgradeFlagsExtensions.IsEnabled(((Gun)__instance).UpgradeFlags, (DMLRUpgradeFlags)8))
		{
			if (ToggleLaserOnUpgradesEnabledField == null)
			{
				HotswapFixPlugin.Log.LogWarning((object)"Could not find toggleLaserOnUpgradesEnabled field; Hotswap fix may not apply.");
			}
			else
			{
				ToggleLaserOnUpgradesEnabledField.SetValue(__instance, false);
			}
		}
	}
}
namespace HotswapFix
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "HotswapFix";

		public const string PLUGIN_NAME = "HotswapFix";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}