Decompiled source of Digitalroots Slope Combat Assistance v2.0.26

plugins/Digitalroot.Valheim.SlopeCombatAssistance.dll

Decompiled 2 weeks ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using JetBrains.Annotations;
using Jotunn.Utils;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("Digitalroot Technologies")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright © Digitalroot Technologies 2021 - 2024")]
[assembly: AssemblyDescription("Slope Combat Assistance for Valheim")]
[assembly: AssemblyFileVersion("2.0.26.0")]
[assembly: AssemblyInformationalVersion("2.0.26+47d9e0b33377c37298a93078252b776c09bce0ed")]
[assembly: AssemblyProduct("Digitalroot Valheim Slope Combat Assistance")]
[assembly: AssemblyTitle("Digitalroot.Valheim.SlopeCombatAssistance")]
[assembly: AssemblyMetadata("RepositoryUrl", "https://github.com/Digitalroot-Valheim/Digitalroot.Valheim.SlopeCombatFix")]
[assembly: NeutralResourcesLanguage("en-US")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.0.26.0")]
[module: UnverifiableCode]
namespace Digitalroot.Valheim.SlopeCombatAssistance;

[BepInPlugin("digitalroot.mods.slopecombatassistance", "Digitalroot's Slope Combat Assistance", "2.0.26")]
[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
[BepInDependency("com.jotunn.jotunn", "2.10.0")]
[BepInIncompatibility("hitbox.fix")]
[BepInIncompatibility("digitalroot.mods.slopecombatfix")]
public class Main : BaseUnityPlugin
{
	public static Main Instance;

	private Harmony _harmony;

	[UsedImplicitly]
	public static ConfigEntry<int> NexusId;

	public readonly ConfigEntry<float> Offset;

	public readonly ConfigEntry<float> Height;

	public const string Version = "2.0.26";

	public const string Name = "Digitalroot's Slope Combat Assistance";

	public const string Guid = "digitalroot.mods.slopecombatassistance";

	public const string Namespace = "Digitalroot.Valheim.SlopeCombatAssistance";

	public Main()
	{
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Expected O, but got Unknown
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Expected O, but got Unknown
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Expected O, but got Unknown
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Expected O, but got Unknown
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Expected O, but got Unknown
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Expected O, but got Unknown
		Instance = this;
		NexusId = ((BaseUnityPlugin)this).Config.Bind<int>("General", "NexusID", 1569, new ConfigDescription("Nexus mod ID for updates", (AcceptableValueBase)null, new object[1] { (object)new ConfigurationManagerAttributes
		{
			Browsable = false,
			ReadOnly = true
		} }));
		Offset = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Offset", 0f, new ConfigDescription("Modify offset", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Browsable = true,
			Order = 1
		} }));
		Height = ((BaseUnityPlugin)this).Config.Bind<float>("General", "Height", 1f, new ConfigDescription("Modify height (0.6 default, 1 mod default)", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), new object[1] { (object)new ConfigurationManagerAttributes
		{
			IsAdminOnly = true,
			Browsable = true,
			Order = 0
		} }));
	}

	private void Awake()
	{
		try
		{
			_harmony = Harmony.CreateAndPatchAll(typeof(Main).Assembly, "digitalroot.mods.slopecombatassistance");
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)ex);
		}
	}

	private void OnDestroy()
	{
		try
		{
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}
		catch (Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)ex);
		}
	}
}
public static class Patch
{
	[HarmonyPatch(typeof(Attack), "DoMeleeAttack")]
	public class PatchAttackDoMeleeAttack
	{
		private static void Prefix(ref Attack __instance, ref float ___m_maxYAngle, ref float ___m_attackOffset, ref float ___m_attackHeight)
		{
			Humanoid character = __instance.m_character;
			Player val = (Player)(object)((character is Player) ? character : null);
			if (val != null && !((Object)(object)val != (Object)(object)Player.m_localPlayer))
			{
				___m_maxYAngle = 180f;
				___m_attackOffset = Main.Instance.Offset.Value;
				___m_attackHeight = Main.Instance.Height.Value;
			}
		}
	}
}