Decompiled source of DodgeKey v0.0.1

plugins\valheim-dodge-key.dll

Decompiled a year ago
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Managers;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("valheim-dodge-key")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("valheim-dodge-key")]
[assembly: AssemblyCopyright("Copyright ©  2021")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("0.0.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.1.0")]
namespace DodgeKey;

[BepInPlugin("DualMono", "DodgeKey", "0.0.1")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
internal class DodgeKey : BaseUnityPlugin
{
	public const string PluginGUID = "DualMono";

	public const string PluginName = "DodgeKey";

	public const string PluginVersion = "0.0.1";

	private ConfigEntry<KeyCode> DodgeButtonKey;

	private ConfigEntry<GamepadButton> DodgeInputGamepad;

	private ButtonConfig DodgeButton;

	private ConfigEntry<bool> InvertDodge;

	private void Awake()
	{
		CreateConfig();
		AddInputs();
		Logger.LogInfo((object)"DodgeKey loaded");
	}

	private void Update()
	{
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		if (ZInput.instance != null && !((Object)(object)Player.m_localPlayer == (Object)null) && ZInput.GetButtonDown(DodgeButton.Name))
		{
			Vector3 lookDir = ((Character)Player.m_localPlayer).m_lookDir;
			Vector3 moveDir = ((Character)Player.m_localPlayer).m_moveDir;
			Vector3 val = ((!(((Vector3)(ref moveDir)).magnitude > 0.1f)) ? (InvertDodge.Value ? (-lookDir) : lookDir) : moveDir);
			Player.m_localPlayer.Dodge(val);
		}
	}

	private void CreateConfig()
	{
		DodgeButtonKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("General", "DodgeKey", (KeyCode)308, "Key to dodge");
		DodgeInputGamepad = ((BaseUnityPlugin)this).Config.Bind<GamepadButton>("General", "DodgeInputGamepad", (GamepadButton)5, "Gamepad button to dodge");
		InvertDodge = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "InvertDodge", true, "Invert dodge look direction");
	}

	private void AddInputs()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Expected O, but got Unknown
		DodgeButton = new ButtonConfig
		{
			Name = "Dodge",
			Config = DodgeButtonKey,
			GamepadConfig = DodgeInputGamepad
		};
		InputManager.Instance.AddButton("DualMono", DodgeButton);
	}
}