Decompiled source of Hold To Walk v1.0.1

HoldToWalkMod2.dll

Decompiled a month 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.Configuration;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyCompany("HoldToWalkMod2")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Changes Valheim walk to a hold command")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HoldToWalkMod2")]
[assembly: AssemblyTitle("HoldToWalkMod2")]
[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;
		}
	}
}
namespace HoldToWalkMod
{
	[BepInPlugin("com.cybin.holdtowalk", "Hold to Walk Mod", "1.0.0")]
	public class HoldToWalkPlugin : BaseUnityPlugin
	{
		private readonly Harmony harmony = new Harmony("com.cybin.holdtowalk");

		public static ConfigEntry<KeyCode> WalkKeyConfig;

		public static bool VanillaToggleState;

		private void Awake()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			WalkKeyConfig = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "HoldToWalkKey", (KeyCode)308, "The keyboard key you hold down to force your character to walk.");
			harmony.PatchAll();
			((BaseUnityPlugin)this).Logger.LogInfo((object)$"Hold to Walk Mod loaded! Both Toggle and Hold are active. Hotkey: {WalkKeyConfig.Value}");
		}
	}
	[HarmonyPatch(typeof(Player), "Update")]
	public class Player_Update_Patch
	{
		[HarmonyPostfix]
		public static void Postfix(Player __instance)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			if (!((Character)__instance).IsOwner())
			{
				return;
			}
			KeyCode value = HoldToWalkPlugin.WalkKeyConfig.Value;
			if (Input.GetKey(value))
			{
				if (!((Character)__instance).GetWalk())
				{
					((Character)__instance).SetWalk(true);
				}
			}
			else if (((Character)__instance).GetWalk() != HoldToWalkPlugin.VanillaToggleState)
			{
				((Character)__instance).SetWalk(HoldToWalkPlugin.VanillaToggleState);
			}
		}
	}
	[HarmonyPatch(typeof(Character), "SetWalk")]
	public class Character_SetWalk_Patch
	{
		[HarmonyPrefix]
		public static void Prefix(bool walk)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (!Input.GetKey(HoldToWalkPlugin.WalkKeyConfig.Value))
			{
				HoldToWalkPlugin.VanillaToggleState = walk;
			}
		}
	}
}