using System;
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 QuickTurn.Patches;
using Reptile;
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("BRC_HarmonyTemplate")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("BRC_HarmonyTemplate")]
[assembly: AssemblyCopyright("Copyright © 2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("12be06c6-8330-4159-aff6-3b8ccc8fde38")]
[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 QuickTurn
{
public class NewQuickTurnAbility : Ability
{
public static float savedSpeed;
public static float turnTimer;
public static float cooldown;
public NewQuickTurnAbility(Player player)
: base(player)
{
}
public override void Init()
{
base.normalRotation = false;
base.allowNormalJump = false;
}
public override void OnStartAbility()
{
savedSpeed = base.p.GetForwardSpeed();
base.p.PlayAnim(Animator.StringToHash("boostBrake"), false, false, -1f);
base.p.SetForwardSpeed(base.p.GetForwardSpeed() * QuickTurnPlugin.abilitySpeed.Value);
base.p.SetDustEmission(50);
base.p.SetDustSize(0.5f);
turnTimer = 0f;
}
public override void FixedUpdateAbility()
{
turnTimer += Core.dt;
if (turnTimer >= QuickTurnPlugin.delay.Value)
{
if (base.p.isJumping && !base.p.IsGrounded())
{
base.p.StopCurrentAbility();
}
if (base.p.jumpButtonNew)
{
DoTheThing(QuickTurnPlugin.jumpDirection.Value, QuickTurnPlugin.turnAngleJump.Value, QuickTurnPlugin.returnedSpeedJump.Value);
base.p.Jump();
base.p.ForceUnground(true);
}
if (base.p.slideButtonNew)
{
DoTheThing(QuickTurnPlugin.slideDirection.Value, QuickTurnPlugin.turnAngleSlide.Value, QuickTurnPlugin.returnedSpeedSlide.Value);
base.p.ActivateAbility((Ability)(object)base.p.slideAbility);
}
if (base.p.AnyTrickInput())
{
base.p.ActivateAbility((Ability)(object)base.p.groundTrickAbility);
if (base.p.CheckBoostTrick())
{
DoTheThing(QuickTurnPlugin.boostTrickDirection.Value, QuickTurnPlugin.turnAngleBoostTrick.Value, QuickTurnPlugin.returnedSpeedBoostTrick.Value);
}
else
{
DoTheThing(QuickTurnPlugin.trickDirection.Value, QuickTurnPlugin.turnAngleTrick.Value, QuickTurnPlugin.returnedSpeedTrick.Value);
}
}
}
if (turnTimer >= 0.5f)
{
base.p.SetDustEmission(0);
base.p.SetDustSize(1f);
}
if (turnTimer >= 0.65f)
{
base.p.StopCurrentAbility();
}
}
public override void OnStopAbility()
{
cooldown = QuickTurnPlugin.cooldown.Value;
turnTimer = 0f;
base.p.SetDustEmission(0);
base.p.SetDustSize(1f);
}
public void PassiveUpdate()
{
//IL_004d: Unknown result type (might be due to invalid IL or missing references)
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
if (cooldown > 0f)
{
cooldown -= Core.dt;
}
float num = Remap(QuickTurnPlugin.sens.Value, 0f, 1f, -1f, 0f);
if (Vector3.Dot(base.p.dir, base.p.moveInput) <= num && (base.p.ability == null || base.p.ability == base.p.slideAbility || base.p.ability == base.p.boostAbility) && base.p.IsGrounded() && base.p.GetForwardSpeed() >= QuickTurnPlugin.minimumSpeed.Value && cooldown <= 0f)
{
base.p.ActivateAbility((Ability)(object)this);
}
}
public void DoTheThing(QuickTurnPlugin.Direction direction, float maxAngle, float speed)
{
//IL_0023: Unknown result type (might be due to invalid IL or missing references)
//IL_0029: 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_0045: Unknown result type (might be due to invalid IL or missing references)
float num = 1f;
if (direction == QuickTurnPlugin.Direction.Backward)
{
num = -1f;
}
base.p.SetRotHard(Vector3.RotateTowards(base.p.forward * num, base.p.moveInput, maxAngle * ((float)Math.PI / 180f), 0f));
base.p.SetForwardSpeed(savedSpeed * speed);
base.p.ringParticles.Emit(1);
}
public static float Remap(float val, float in1, float in2, float out1, float out2)
{
return out1 + (val - in1) * (out2 - out1) / (in2 - in1);
}
}
[BepInPlugin("com.yuril.QuickTurn", "QuickTurn", "1.0.0")]
public class QuickTurnPlugin : BaseUnityPlugin
{
public enum Direction
{
Forward,
Backward
}
private const string MyGUID = "com.yuril.QuickTurn";
private const string PluginName = "QuickTurn";
private const string VersionString = "1.0.0";
public static ConfigEntry<float> abilitySpeed;
public static ConfigEntry<Direction> jumpDirection;
public static ConfigEntry<float> turnAngleJump;
public static ConfigEntry<float> returnedSpeedJump;
public static ConfigEntry<Direction> slideDirection;
public static ConfigEntry<float> turnAngleSlide;
public static ConfigEntry<float> returnedSpeedSlide;
public static ConfigEntry<Direction> trickDirection;
public static ConfigEntry<float> turnAngleTrick;
public static ConfigEntry<float> returnedSpeedTrick;
public static ConfigEntry<Direction> boostTrickDirection;
public static ConfigEntry<float> turnAngleBoostTrick;
public static ConfigEntry<float> returnedSpeedBoostTrick;
public static ConfigEntry<float> sens;
public static ConfigEntry<float> cooldown;
public static ConfigEntry<float> delay;
public static ConfigEntry<float> minimumSpeed;
private Harmony harmony;
public static Player player;
private void Awake()
{
//IL_0007: Unknown result type (might be due to invalid IL or missing references)
//IL_0011: Expected O, but got Unknown
//IL_0075: Unknown result type (might be due to invalid IL or missing references)
//IL_007f: Expected O, but got Unknown
//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
//IL_0100: Expected O, but got Unknown
//IL_0177: Unknown result type (might be due to invalid IL or missing references)
//IL_0181: Expected O, but got Unknown
//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
//IL_0202: Expected O, but got Unknown
//IL_0259: Unknown result type (might be due to invalid IL or missing references)
//IL_0263: Expected O, but got Unknown
harmony = new Harmony("com.yuril.QuickTurn");
harmony.PatchAll(typeof(PlayerPatch));
jumpDirection = ((BaseUnityPlugin)this).Config.Bind<Direction>("1:Jump", "Direction Jump", Direction.Backward, "");
turnAngleJump = ((BaseUnityPlugin)this).Config.Bind<float>("1:Jump", "Angle Jump", 45f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 180f), Array.Empty<object>()));
returnedSpeedJump = ((BaseUnityPlugin)this).Config.Bind<float>("1:Jump", "Speed Jump", 0.7f, "");
slideDirection = ((BaseUnityPlugin)this).Config.Bind<Direction>("2:Slide", "Direction Slide", Direction.Forward, "");
turnAngleSlide = ((BaseUnityPlugin)this).Config.Bind<float>("2:Slide", "Angle Slide", 75f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 180f), Array.Empty<object>()));
returnedSpeedSlide = ((BaseUnityPlugin)this).Config.Bind<float>("2:Slide", "Speed Slide", 0.95f, "");
trickDirection = ((BaseUnityPlugin)this).Config.Bind<Direction>("3:Trick", "Direction Trick", Direction.Forward, "");
turnAngleTrick = ((BaseUnityPlugin)this).Config.Bind<float>("3:Trick", "Angle Trick", 180f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 180f), Array.Empty<object>()));
returnedSpeedTrick = ((BaseUnityPlugin)this).Config.Bind<float>("3:Trick", "Speed Trick", 0.5f, "");
boostTrickDirection = ((BaseUnityPlugin)this).Config.Bind<Direction>("4:Boost Trick", "Direction Boost Trick", Direction.Forward, "");
turnAngleBoostTrick = ((BaseUnityPlugin)this).Config.Bind<float>("4:Boost Trick", "Angle Boost Trick", 180f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 180f), Array.Empty<object>()));
returnedSpeedBoostTrick = ((BaseUnityPlugin)this).Config.Bind<float>("4:Boost Trick", "Speed Boost Trick", 0.9f, "");
sens = ((BaseUnityPlugin)this).Config.Bind<float>("0:General", "Sensitivity", 0.6f, new ConfigDescription("", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
abilitySpeed = ((BaseUnityPlugin)this).Config.Bind<float>("0:General", "Speed During Ability", 0.4f, "");
cooldown = ((BaseUnityPlugin)this).Config.Bind<float>("0:General", "Cooldown", 0.5f, "");
delay = ((BaseUnityPlugin)this).Config.Bind<float>("0:General", "Delay", 0.1f, "");
minimumSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("0:General", "Minimum Speed", 2f, "");
}
}
}
namespace QuickTurn.Patches
{
internal static class PlayerPatch
{
private static NewQuickTurnAbility newQuickTurnAbility;
[HarmonyPatch(typeof(Player), "Init")]
[HarmonyPostfix]
private static void Player_Init_Postfix(Player __instance)
{
if (!__instance.isAI)
{
QuickTurnPlugin.player = __instance;
newQuickTurnAbility = new NewQuickTurnAbility(__instance);
}
}
[HarmonyPatch(typeof(Player), "FixedUpdateAbilities")]
[HarmonyPostfix]
private static void Player_FixedUpdateAbilities_Postfix(Player __instance)
{
if (!__instance.isAI)
{
newQuickTurnAbility.PassiveUpdate();
}
}
}
}