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 IL.RoR2;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using RoR2;
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(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("DynamicJump")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("DynamicJump")]
[assembly: AssemblyTitle("DynamicJump")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace DynamicJump;
[BepInPlugin("com.RiskOfBrainrot.DynamicJump", "DynamicJump", "1.0.1")]
public class DynamicJumpPlugin : BaseUnityPlugin
{
public const string guid = "com.RiskOfBrainrot.DynamicJump";
public const string teamName = "RiskOfBrainrot";
public const string modName = "DynamicJump";
public const string version = "1.0.1";
public static ConfigEntry<float> DynamicJumpAscentHoldGravity;
public static ConfigEntry<float> DynamicJumpAscentReleaseGravity;
public static ConfigEntry<float> DynamicJumpDescentGravity;
public static PluginInfo PInfo { get; private set; }
public static ConfigFile CustomConfigFile { get; set; }
public static float dynamicJumpAscentHoldGravity => DynamicJumpAscentHoldGravity.Value;
public static float dynamicJumpAscentReleaseGravity => DynamicJumpAscentReleaseGravity.Value;
public static float dynamicJumpDescentGravity => DynamicJumpDescentGravity.Value;
private void Awake()
{
//IL_0011: Unknown result type (might be due to invalid IL or missing references)
//IL_001b: Expected O, but got Unknown
//IL_008c: Unknown result type (might be due to invalid IL or missing references)
//IL_0096: Expected O, but got Unknown
CustomConfigFile = new ConfigFile(Paths.ConfigPath + "\\DynamicJump.cfg", true);
DynamicJumpAscentHoldGravity = CustomConfigFile.Bind<float>("Dynamic Jump", "Ascent Hold Gravity", 0.8f, "The gravity multiplier applied to to the character while the jump input is HELD, during their ASCENT. Lower numbers make the character go higher.");
DynamicJumpAscentReleaseGravity = CustomConfigFile.Bind<float>("Dynamic Jump", "Ascent Release Gravity", 1.5f, "The gravity multiplier applied to to the character while the jump input is RELEASED, during their ASCENT. Higher numbers make the character go lower.");
DynamicJumpDescentGravity = CustomConfigFile.Bind<float>("Dynamic Jump", "Descent Gravity", 1f, "The gravity multiplier applied to to the character during their DESCENT. There's probably no reason to modify this value.");
CharacterMotor.PreMove += new Manipulator(DynamicJumpHook);
}
private void DynamicJumpHook(ILContext il)
{
//IL_0002: Unknown result type (might be due to invalid IL or missing references)
//IL_0008: Expected O, but got Unknown
//IL_005b: Unknown result type (might be due to invalid IL or missing references)
ILCursor val = new ILCursor(il);
val.GotoNext((MoveType)2, new Func<Instruction, bool>[2]
{
(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Physics>(x, "get_gravity"),
(Instruction x) => ILPatternMatchingExt.MatchLdfld<Vector3>(x, "y")
});
val.Emit(OpCodes.Ldarg_0);
val.EmitDelegate<Func<float, CharacterMotor, float>>((Func<float, CharacterMotor, float>)delegate(float gravityIn, CharacterMotor motor)
{
if (motor != null)
{
CharacterBody body = motor.body;
if (((body != null) ? new bool?(body.isPlayerControlled) : null) == false)
{
goto IL_0048;
}
}
if (!motor.disableAirControlUntilCollision)
{
float num = gravityIn;
return (!(motor.velocity.y >= 0f)) ? (num * dynamicJumpDescentGravity) : ((!motor.body.inputBank.jump.down) ? (num * dynamicJumpAscentReleaseGravity) : (num * dynamicJumpAscentHoldGravity));
}
goto IL_0048;
IL_0048:
return gravityIn;
});
}
}