Decompiled source of ThorsLeap v1.0.4

plugins/ThorsLeap.dll

Decompiled 2 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using JetBrains.Annotations;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("NoMovementPenalty")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("NoMovementPenalty")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("05078777-8b4c-43fd-98ec-887e0f886aae")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ThorsLeap
{
	[BepInPlugin("posixone_ThorsLeap", "Thor's Leap", "1.0.4")]
	public class Main : BaseUnityPlugin
	{
		public const string MODNAME = "Thor's Leap";

		public const string AUTHOR = "posixone";

		public const string GUID = "posixone_ThorsLeap";

		public const string VERSION = "1.0.4";

		public const string utilityItem = "";

		public static bool isOnGround;

		public static ConfigEntry<bool> modEnable;

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			//IL_002b: Expected O, but got Unknown
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			modEnable = ((BaseUnityPlugin)this).Config.Bind<bool>(new ConfigDefinition("Global", "modEnable"), true, new ConfigDescription("Set this to true to enable and false to disable this mod.", (AcceptableValueBase)null, Array.Empty<object>()));
			Harmony val = new Harmony("posixone_ThorsLeap");
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			if (modEnable.Value)
			{
				val.PatchAll(executingAssembly);
			}
		}
	}
}
namespace ThorsLeap.FeatherFall
{
	[HarmonyPatch(typeof(Humanoid), "UpdateEquipmentStatusEffects")]
	public class FeatherFall_Humanoid_UpdateEquipmentStatusEffects_Patch
	{
		[UsedImplicitly]
		public static void Postfix(Humanoid __instance)
		{
			Player val = (Player)(object)((__instance is Player) ? __instance : null);
			if (val == null || (Object)(object)ObjectDB.instance == (Object)null)
			{
				return;
			}
			StatusEffect statusEffect = ObjectDB.instance.GetStatusEffect("SlowFall".GetHashCode());
			if (!((Object)(object)statusEffect == (Object)null))
			{
				if (!((Humanoid)val).m_equipmentStatusEffects.Contains(statusEffect))
				{
					((Humanoid)val).m_equipmentStatusEffects.Add(statusEffect);
				}
				((Character)val).m_seman.AddStatusEffect(statusEffect, false, 0, 0f, (short)(-1));
			}
		}
	}
}
namespace ThorsLeap.TLDoubleJump
{
	[HarmonyPatch]
	public static class TLDoubleJump
	{
		[HarmonyPatch(typeof(Character), "Jump")]
		[HarmonyPriority(800)]
		public static class Character_Jump_Patch
		{
			private static void SuppressEpicLoot()
			{
				try
				{
					Type type = Type.GetType("EpicLoot.MagicItemEffects.DoubleJump, EpicLoot");
					if (!(type == null))
					{
						FieldInfo field = type.GetField("MultiJumpCombo", BindingFlags.Static | BindingFlags.Public);
						if (field != null)
						{
							field.SetValue(null, 999);
						}
					}
				}
				catch
				{
				}
			}

			public static bool Prefix(Character __instance, bool force)
			{
				//IL_0040: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_0106: Unknown result type (might be due to invalid IL or missing references)
				//IL_010b: Unknown result type (might be due to invalid IL or missing references)
				//IL_010e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0113: Unknown result type (might be due to invalid IL or missing references)
				//IL_0118: Unknown result type (might be due to invalid IL or missing references)
				//IL_011d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0121: Unknown result type (might be due to invalid IL or missing references)
				//IL_0126: Unknown result type (might be due to invalid IL or missing references)
				//IL_0143: Unknown result type (might be due to invalid IL or missing references)
				//IL_0145: Unknown result type (might be due to invalid IL or missing references)
				//IL_0154: Unknown result type (might be due to invalid IL or missing references)
				//IL_0156: Unknown result type (might be due to invalid IL or missing references)
				//IL_015d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0162: Unknown result type (might be due to invalid IL or missing references)
				//IL_0167: Unknown result type (might be due to invalid IL or missing references)
				//IL_017f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0172: Unknown result type (might be due to invalid IL or missing references)
				//IL_0184: Unknown result type (might be due to invalid IL or missing references)
				//IL_0186: Unknown result type (might be due to invalid IL or missing references)
				//IL_0188: Unknown result type (might be due to invalid IL or missing references)
				//IL_0193: Unknown result type (might be due to invalid IL or missing references)
				//IL_0198: Unknown result type (might be due to invalid IL or missing references)
				//IL_019d: Unknown result type (might be due to invalid IL or missing references)
				//IL_01be: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
				//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_01af: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_01da: Unknown result type (might be due to invalid IL or missing references)
				if (!__instance.IsPlayer())
				{
					return true;
				}
				if (__instance.IsOnGround())
				{
					return true;
				}
				if (__instance.InLiquidSwimDepth() && __instance.m_hitWorldTime < 0.25f)
				{
					return true;
				}
				GrapplingPoint localGrappler = GrapplingPoint.m_localGrappler;
				if ((Object)(object)localGrappler != (Object)null && Vector3.Distance(((Component)localGrappler).transform.position, ((Component)__instance).transform.position) > localGrappler.m_jumpPullMaxDist)
				{
					return true;
				}
				if (__instance.IsDead() || __instance.IsEncumbered() || __instance.InDodge() || __instance.IsKnockedBack() || __instance.IsStaggering())
				{
					return true;
				}
				if (!force && __instance.InAttack())
				{
					return true;
				}
				if (!HasDoubleJumpCharge(__instance))
				{
					return true;
				}
				bool flag = !__instance.HaveStamina(__instance.m_jumpStaminaUsage);
				float speed = __instance.m_speed;
				__instance.m_seman.ApplyStatusEffectSpeedMods(ref speed, __instance.m_currentVel);
				if (speed <= 0f)
				{
					flag = true;
				}
				Skills skills = __instance.GetSkills();
				float num = 0f;
				if ((Object)(object)skills != (Object)null)
				{
					num = skills.GetSkillFactor((SkillType)100);
					if (!flag)
					{
						__instance.RaiseSkill((SkillType)100, 1f);
					}
				}
				Vector3 val = __instance.GetVelocity();
				Vector3 val2 = __instance.m_lastGroundNormal + Vector3.up;
				Vector3 normalized = ((Vector3)(ref val2)).normalized;
				float num2 = 1f + num * 0.4f;
				float num3 = __instance.m_jumpForce * num2;
				float num4 = Vector3.Dot(normalized, val);
				if (num4 < num3)
				{
					val += normalized * (num3 - num4);
				}
				Vector3 val3 = (__instance.m_slipping ? ((Vector3)(ref __instance.m_currentVel)).normalized : __instance.m_moveDir);
				val += val3 * (__instance.m_jumpForceForward * num2);
				if (flag)
				{
					val *= __instance.m_jumpForceTiredFactor;
				}
				__instance.m_seman.ApplyStatusEffectJumpMods(ref val);
				if (!(val.x <= 0f) || !(val.y <= 0f) || !(val.z <= 0f))
				{
					__instance.ForceJump(val, true);
				}
				UseDoubleJumpCharge(__instance);
				SuppressEpicLoot();
				return false;
			}
		}

		[HarmonyPatch(typeof(Character), "ResetGroundContact")]
		public static class Character_ResetGroundContact_Patch
		{
			public static bool Prefix(Character __instance)
			{
				if (!__instance.IsPlayer())
				{
					return true;
				}
				TLGroundContactTracker.TryGetValue(__instance, out var value);
				if (__instance.m_groundContact && value != __instance.m_groundContact)
				{
					ResetDoubleJumpCharges(__instance);
				}
				TLGroundContactTracker[__instance] = __instance.m_groundContact;
				return true;
			}
		}

		[HarmonyPatch(typeof(Humanoid), "EquipItem")]
		public static class Humanoid_EquipItem_Patch
		{
			public static void Postfix(Humanoid __instance)
			{
				ResetDoubleJumpCharges((Character)(object)__instance);
			}
		}

		[HarmonyPatch(typeof(Humanoid), "UnequipItem")]
		public static class Humanoid_UnequipItem_Patch
		{
			public static void Postfix(Humanoid __instance)
			{
				ResetDoubleJumpCharges((Character)(object)__instance);
			}
		}

		public const string TLDoubleJumpChargeKey = "TLDoubleJump";

		public static readonly Dictionary<Character, bool> TLGroundContactTracker = new Dictionary<Character, bool>();

		public static bool HasDoubleJumpCharge(Character TLcharacter)
		{
			return TLcharacter.m_nview.GetZDO().GetInt("TLDoubleJump", 0) > 0;
		}

		public static void UseDoubleJumpCharge(Character TLcharacter)
		{
			int num = TLcharacter.m_nview.GetZDO().GetInt("TLDoubleJump", 0);
			TLcharacter.m_nview.GetZDO().Set("TLDoubleJump", num - 1);
		}

		public static void ResetDoubleJumpCharges(Character TLcharacter)
		{
			if ((Object)(object)TLcharacter == (Object)null || (Object)(object)TLcharacter.m_nview == (Object)null || !TLcharacter.m_nview.IsValid())
			{
				return;
			}
			Character obj = (TLcharacter.IsPlayer() ? ((TLcharacter is Player) ? TLcharacter : null) : null);
			bool flag = false;
			if (!((Object)(object)obj != (Object)null))
			{
				return;
			}
			foreach (StatusEffect statusEffect in ((Character)Player.m_localPlayer).GetSEMan().GetStatusEffects())
			{
				if (((Object)statusEffect).name.StartsWith("GP_Moder"))
				{
					flag = true;
				}
			}
			if (flag)
			{
				TLcharacter.m_nview.GetZDO().Set("TLDoubleJump", 2);
			}
			else
			{
				TLcharacter.m_nview.GetZDO().Set("TLDoubleJump", 1);
			}
		}
	}
}