using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
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.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[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.2")]
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.2";
public const string utilityItem = "";
public static bool isOnGround;
public static ConfigEntry<bool> modEnable;
private void Awake()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_0022: Unknown result type (might be due to invalid IL or missing references)
//IL_002c: Expected O, but got Unknown
//IL_002c: Expected O, but got Unknown
//IL_0036: Unknown result type (might be due to invalid IL or missing references)
//IL_003c: 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)
{
return;
}
StatusEffect statusEffect = ObjectDB.instance.GetStatusEffect("SlowFall".GetHashCode());
if (!((Object)(object)statusEffect == (Object)null))
{
bool flag = ((Humanoid)val).m_equipmentStatusEffects.Contains(statusEffect);
((Humanoid)val).m_equipmentStatusEffects.Add(statusEffect);
((Character)val).m_seman.AddStatusEffect(statusEffect, false, 0, 0f);
string text = string.Join(", ", ((Humanoid)val).m_equipmentStatusEffects.Select((StatusEffect x) => ((Object)x).name));
}
}
}
}
namespace ThorsLeap.TLDoubleJump
{
[HarmonyPatch]
public static class TLDoubleJump
{
[HarmonyPatch(typeof(Character), "Jump")]
public static class Character_Jump_Patch
{
public static bool Prefix(Character __instance)
{
if (__instance.IsPlayer())
{
TLIsJumping = true;
TLIsDoubleJumping = false;
TLFirstCallToIsOnGround = false;
}
return true;
}
public static void Postfix(Character __instance)
{
if (__instance.IsPlayer())
{
TLIsJumping = false;
TLIsDoubleJumping = false;
}
}
}
[HarmonyPatch(typeof(Character), "IsOnGround")]
public static class Character_IsOnGround_Patch
{
public static void Postfix(Character __instance, ref bool __result)
{
if (!TLFirstCallToIsOnGround && __instance.IsPlayer() && !__result && TLIsJumping && HasDoubleJumpCharge(__instance))
{
TLFirstCallToIsOnGround = true;
__result = true;
TLIsDoubleJumping = true;
}
}
}
[HarmonyPatch(typeof(Player), "OnJump")]
public static class Player_OnJump_Patch
{
public static void Postfix(Player __instance)
{
if (TLIsJumping && TLIsDoubleJumping)
{
UseDoubleJumpCharge((Character)(object)__instance);
}
}
}
[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 bool TLIsJumping;
public static bool TLIsDoubleJumping;
public static bool TLFirstCallToIsOnGround;
public static readonly Dictionary<Character, bool> TLGroundContactTracker = new Dictionary<Character, bool>();
public static bool HasDoubleJumpCharge(Character TLcharacter)
{
int @int = TLcharacter.m_nview.GetZDO().GetInt("TLDoubleJump", 0);
return @int > 0;
}
public static void UseDoubleJumpCharge(Character TLcharacter)
{
int @int = TLcharacter.m_nview.GetZDO().GetInt("TLDoubleJump", 0);
TLcharacter.m_nview.GetZDO().Set("TLDoubleJump", @int - 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;
}
Player val = (Player)(object)(TLcharacter.IsPlayer() ? ((TLcharacter is Player) ? TLcharacter : null) : null);
bool flag = false;
if (!((Object)(object)val != (Object)null))
{
return;
}
SEMan sEMan = ((Character)Player.m_localPlayer).GetSEMan();
foreach (StatusEffect statusEffect in sEMan.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);
}
}
}
}