Decompiled source of Bhops v1.0.0

plugins/HowToFishBhops.dll

Decompiled an hour ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("HowToFishBhops")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HowToFishBhops")]
[assembly: AssemblyTitle("HowToFishBhops")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace HowToFishBhops;

[HarmonyPatch]
public static class Bhop
{
	private static readonly FieldRef<PlayerMovement, Rigidbody> Rig = AccessTools.FieldRefAccess<PlayerMovement, Rigidbody>("_rig");

	private static readonly FieldRef<PlayerMovement, Player> Owner = AccessTools.FieldRefAccess<PlayerMovement, Player>("_player");

	private static readonly FieldRef<PlayerMovement, float> SprintSpeedRef = AccessTools.FieldRefAccess<PlayerMovement, float>("_sprintSpeed");

	private static readonly FieldRef<PlayerMovement, bool> IsSwimming = AccessTools.FieldRefAccess<PlayerMovement, bool>("_isSwimming");

	private static readonly FieldRef<PlayerMovement, bool> HasJumped = AccessTools.FieldRefAccess<PlayerMovement, bool>("_hasJumped");

	private static readonly FieldRef<PlayerMovement, bool> HasInheritedVel = AccessTools.FieldRefAccess<PlayerMovement, bool>("_hasInheritedVel");

	private static readonly FieldRef<PlayerMovement, float> GroundAngle = AccessTools.FieldRefAccess<PlayerMovement, float>("_groundAngle");

	private static readonly FieldRef<PlayerMovement, float> JumpAngle = AccessTools.FieldRefAccess<PlayerMovement, float>("_jumpAngle");

	private static Vector3 _dir;

	private static bool _wasGrounded = true;

	private static bool _leftGround;

	private static float _landTime;

	private static float _jumpTime;

	private static float _lastApplied;

	private static InputAction _jumpAction;

	private static float _lastJumpPress = -100f;

	private static bool _autoJumping;

	public static int Chain { get; private set; }

	public static float Speed { get; private set; }

	public static float CurrentSpeed { get; private set; }

	public static float SprintSpeed { get; private set; } = 1f;

	public static bool ChainIsAuto { get; private set; }

	public static bool IsLocal(PlayerMovement m)
	{
		Player localPlayer = Player.LocalPlayer;
		if (Object.op_Implicit((Object)(object)localPlayer))
		{
			return (Object)(object)localPlayer.Movement == (Object)(object)m;
		}
		return false;
	}

	private static bool CanBhop(PlayerMovement m)
	{
		Player val = Owner.Invoke(m);
		if (Plugin.Enabled.Value && Object.op_Implicit((Object)(object)val) && !val.BlockInputs && !IsSwimming.Invoke(m) && !m.OnBoat && !HasInheritedVel.Invoke(m))
		{
			return !Boat.IsDrivingLocally;
		}
		return false;
	}

	public static void Break()
	{
		if (Chain != 0)
		{
			Chain = 0;
			Speed = 0f;
			_lastApplied = 0f;
			ChainIsAuto = false;
			BhopController.OnChainBroken();
		}
	}

	private static Vector3 Flat(Vector3 v)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		return new Vector3(v.x, 0f, v.z);
	}

	private static InputAction JumpAction()
	{
		try
		{
			if (_jumpAction == null && Object.op_Implicit((Object)(object)GameInfo.Input))
			{
				_jumpAction = GameInfo.Input.actions["PlayerJump"];
			}
		}
		catch
		{
			_jumpAction = null;
		}
		return _jumpAction;
	}

	private static bool JumpHeld()
	{
		if (ChatManager.IsTyping)
		{
			return false;
		}
		try
		{
			InputAction val = JumpAction();
			return val != null && val.IsPressed();
		}
		catch
		{
			_jumpAction = null;
			return false;
		}
	}

	public static void PollJumpPress()
	{
		if (ChatManager.IsTyping)
		{
			return;
		}
		try
		{
			InputAction val = JumpAction();
			if (val != null && val.WasPressedThisFrame())
			{
				_lastJumpPress = Time.time;
			}
		}
		catch
		{
			_jumpAction = null;
		}
	}

	[HarmonyPatch(typeof(PlayerMovement), "GroundCheck")]
	[HarmonyPostfix]
	private static void AfterGroundCheck(PlayerMovement __instance)
	{
		if (!IsLocal(__instance))
		{
			return;
		}
		bool grounded = __instance.Grounded;
		if (grounded && !_wasGrounded)
		{
			_landTime = Time.time;
		}
		if (!grounded)
		{
			_leftGround = true;
		}
		_wasGrounded = grounded;
		if (!grounded || HasJumped.Invoke(__instance) || GroundAngle.Invoke(__instance) >= JumpAngle.Invoke(__instance) || !CanBhop(__instance))
		{
			return;
		}
		if (Time.time - _lastJumpPress <= Plugin.JumpBuffer.Value)
		{
			__instance.Jump();
		}
		else if (Plugin.AutoBhop.Value && JumpHeld())
		{
			_autoJumping = true;
			try
			{
				__instance.Jump();
			}
			finally
			{
				_autoJumping = false;
			}
		}
	}

	[HarmonyPatch(typeof(PlayerMovement), "Jump")]
	[HarmonyPostfix]
	private static void AfterJump(PlayerMovement __instance)
	{
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: 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_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		//IL_0147: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		if (!IsLocal(__instance))
		{
			return;
		}
		_lastJumpPress = -100f;
		if (!CanBhop(__instance))
		{
			return;
		}
		Rigidbody val = Rig.Invoke(__instance);
		if (!Object.op_Implicit((Object)(object)val))
		{
			return;
		}
		float time = Time.time;
		SprintSpeed = Mathf.Max(0.01f, SprintSpeedRef.Invoke(__instance));
		Vector3 val2 = Flat(val.linearVelocity);
		float num = SprintSpeed * Plugin.MaxSpeed.Value;
		if (Chain > 0 && _leftGround)
		{
			Chain++;
			Vector2 input = __instance.Input;
			float num2 = ((((Vector2)(ref input)).sqrMagnitude > 0.01f) ? (SprintSpeed * Plugin.SpeedGainPerHop.Value) : 0f);
			if (_autoJumping)
			{
				num2 *= Plugin.AutoBhopGain.Value;
			}
			Speed = Mathf.Min(Mathf.Max(Speed, ((Vector3)(ref val2)).magnitude) + num2, Mathf.Max(num, Speed));
		}
		else
		{
			if (Chain != 0)
			{
				return;
			}
			Chain = 1;
			Speed = ((Vector3)(ref val2)).magnitude;
			Vector3 normalized;
			if (!(((Vector3)(ref val2)).sqrMagnitude > 0.0001f))
			{
				Vector3 val3 = Flat(Owner.Invoke(__instance).CurPlayerRot * Vector3.forward);
				normalized = ((Vector3)(ref val3)).normalized;
			}
			else
			{
				normalized = ((Vector3)(ref val2)).normalized;
			}
			_dir = normalized;
		}
		if (_autoJumping)
		{
			ChainIsAuto = true;
		}
		_leftGround = false;
		_jumpTime = time;
		BhopController.OnHop(Chain, _autoJumping);
	}

	[HarmonyPatch(typeof(PlayerMovement), "Move")]
	[HarmonyPrefix]
	private static void BeforeMove(PlayerMovement __instance)
	{
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		if (!IsLocal(__instance) || Chain == 0)
		{
			return;
		}
		Rigidbody val = Rig.Invoke(__instance);
		if (Object.op_Implicit((Object)(object)val))
		{
			Vector3 val2 = Flat(val.linearVelocity);
			float magnitude = ((Vector3)(ref val2)).magnitude;
			if (_lastApplied > 0f && magnitude < _lastApplied * 0.7f)
			{
				Speed = Mathf.Min(Speed, magnitude);
			}
		}
	}

	[HarmonyPatch(typeof(PlayerMovement), "Move")]
	[HarmonyPostfix]
	private static void AfterMove(PlayerMovement __instance)
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: 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_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: Unknown result type (might be due to invalid IL or missing references)
		if (!IsLocal(__instance))
		{
			return;
		}
		Rigidbody val = Rig.Invoke(__instance);
		if (!Object.op_Implicit((Object)(object)val))
		{
			return;
		}
		Vector3 val2 = Flat(val.linearVelocity);
		CurrentSpeed = ((Vector3)(ref val2)).magnitude;
		SprintSpeed = Mathf.Max(0.01f, SprintSpeedRef.Invoke(__instance));
		if (Chain == 0)
		{
			return;
		}
		if (!CanBhop(__instance))
		{
			Break();
			return;
		}
		float time = Time.time;
		if (__instance.Grounded && ((_leftGround && time - _landTime > Plugin.HopWindow.Value) || (!_leftGround && time - _jumpTime > 0.4f)))
		{
			Break();
			return;
		}
		Vector3 linearVelocity = val.linearVelocity;
		Vector3 val3 = Flat(linearVelocity);
		if (((Vector3)(ref val3)).sqrMagnitude > 0.0004f)
		{
			_dir = Vector3.RotateTowards(_dir, ((Vector3)(ref val3)).normalized, Plugin.AirTurnSpeed.Value * ((float)Math.PI / 180f) * Time.fixedDeltaTime, 0f);
		}
		_dir.y = 0f;
		if (!(((Vector3)(ref _dir)).sqrMagnitude < 0.0001f))
		{
			((Vector3)(ref _dir)).Normalize();
			float num = Mathf.Max(Speed, ((Vector3)(ref val3)).magnitude);
			Vector3 val4 = _dir * num;
			val.linearVelocity = new Vector3(val4.x, linearVelocity.y, val4.z);
			_lastApplied = num;
			CurrentSpeed = num;
		}
	}
}
public class BhopController : MonoBehaviour
{
	private static BhopController _instance;

	private AudioSource _src;

	private AudioClip _clip;

	private bool _wantSong;

	private bool _restartNext = true;

	private string _toast;

	private float _toastUntil;

	private GUIStyle _hud;

	private GUIStyle _toastStyle;

	private bool _paused;

	private void Awake()
	{
		_instance = this;
		_src = ((Component)this).gameObject.AddComponent<AudioSource>();
		_src.playOnAwake = false;
		_src.loop = true;
		_src.spatialBlend = 0f;
		_src.volume = 0f;
		_src.ignoreListenerPause = true;
		((MonoBehaviour)this).StartCoroutine(LoadSong());
	}

	private IEnumerator LoadSong()
	{
		string[] exts = new string[3] { ".mp3", ".ogg", ".wav" };
		IEnumerable<string> source = new string[2]
		{
			Plugin.Folder,
			Path.Combine(Plugin.Folder, "song")
		}.Where(Directory.Exists);
		string path = (from f in source.SelectMany(Directory.GetFiles)
			where exts.Contains(Path.GetExtension(f).ToLowerInvariant())
			orderby f
			select f).FirstOrDefault();
		if (path == null)
		{
			Plugin.Log.LogWarning((object)"No song found. Put an .mp3, .ogg or .wav next to HowToFishBhops.dll to have one play while you bhop.");
			yield break;
		}
		string text = Path.GetExtension(path).ToLowerInvariant();
		AudioType val = ((text == ".mp3") ? ((AudioType)13) : ((!(text == ".ogg")) ? ((AudioType)20) : ((AudioType)14)));
		string text2 = "file:///" + path.Replace('\\', '/');
		UnityWebRequest req = UnityWebRequestMultimedia.GetAudioClip(text2, val);
		try
		{
			yield return req.SendWebRequest();
			if ((int)req.result != 1)
			{
				Plugin.Log.LogError((object)("Couldn't load song " + Path.GetFileName(path) + ": " + req.error));
				yield break;
			}
			_clip = DownloadHandlerAudioClip.GetContent(req);
		}
		finally
		{
			((IDisposable)req)?.Dispose();
		}
		if (Object.op_Implicit((Object)(object)_clip))
		{
			((Object)_clip).name = Path.GetFileNameWithoutExtension(path);
			_src.clip = _clip;
			Plugin.Log.LogInfo((object)$"Bhop song: {Path.GetFileName(path)} ({_clip.length:0}s)");
		}
	}

	public static void OnHop(int chain, bool auto)
	{
		if (Object.op_Implicit((Object)(object)_instance) && Plugin.SongEnabled.Value && Object.op_Implicit((Object)(object)_instance._clip) && chain >= Plugin.SongStartHops.Value && (!Bhop.ChainIsAuto || Plugin.SongWithAutoBhop.Value))
		{
			_instance.StartSong();
		}
	}

	public static void OnChainBroken()
	{
		if (Object.op_Implicit((Object)(object)_instance))
		{
			_instance._wantSong = false;
			if (Plugin.SongRestartEachStreak.Value)
			{
				_instance._restartNext = true;
			}
		}
	}

	private void StartSong()
	{
		_wantSong = true;
		if (!_src.isPlaying)
		{
			if (_restartNext || !_paused)
			{
				_src.Stop();
				_src.Play();
				_src.volume = Plugin.SongVolume.Value;
				_restartNext = false;
			}
			else
			{
				_src.UnPause();
			}
			_paused = false;
		}
	}

	private void Update()
	{
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		Bhop.PollJumpPress();
		if (Input.GetKeyDown(Plugin.AutoBhopKey.Value) && !ChatManager.IsTyping)
		{
			Plugin.AutoBhop.Value = !Plugin.AutoBhop.Value;
			_toast = (Plugin.AutoBhop.Value ? "Auto bhop ON (hold jump)" : "Auto bhop OFF");
			_toastUntil = Time.unscaledTime + 2f;
		}
		if (Input.GetKeyDown(Plugin.SongToggleKey.Value) && !ChatManager.IsTyping)
		{
			Plugin.SongEnabled.Value = !Plugin.SongEnabled.Value;
			_toast = (Plugin.SongEnabled.Value ? "Bhop song ON" : "Bhop song OFF");
			_toastUntil = Time.unscaledTime + 2f;
			if (Plugin.SongEnabled.Value && Bhop.Chain >= Plugin.SongStartHops.Value && (!Bhop.ChainIsAuto || Plugin.SongWithAutoBhop.Value) && Object.op_Implicit((Object)(object)_clip))
			{
				StartSong();
			}
		}
		if (!Object.op_Implicit((Object)(object)Player.LocalPlayer) && Bhop.Chain > 0)
		{
			Bhop.Break();
		}
		if (Object.op_Implicit((Object)(object)_src.clip))
		{
			float num = ((_wantSong && Plugin.SongEnabled.Value) ? Plugin.SongVolume.Value : 0f);
			float num2 = Mathf.Max(0.01f, Plugin.SongFadeTime.Value);
			float num3 = (_wantSong ? 4f : (Plugin.SongVolume.Value / num2));
			_src.volume = Mathf.MoveTowards(_src.volume, num, num3 * Time.unscaledDeltaTime);
			if (num <= 0f && _src.isPlaying && _src.volume <= 0.001f)
			{
				_src.Pause();
				_paused = true;
			}
		}
	}

	private void OnGUI()
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Expected O, but got Unknown
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Expected O, but got Unknown
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		if (_hud == null)
		{
			_hud = new GUIStyle(GUI.skin.label)
			{
				alignment = (TextAnchor)4,
				fontStyle = (FontStyle)1,
				richText = true
			};
			_toastStyle = new GUIStyle(_hud);
		}
		_hud.fontSize = Mathf.Max(16, Screen.height / 40);
		_toastStyle.fontSize = Mathf.Max(18, Screen.height / 32);
		if (_toast != null && Time.unscaledTime < _toastUntil)
		{
			Shadowed(new Rect(0f, (float)Screen.height * 0.2f, (float)Screen.width, 50f), "<color=#7fe0ff>" + _toast + "</color>", _toastStyle);
		}
		if (Plugin.ShowHud.Value && Bhop.Chain >= 2 && Object.op_Implicit((Object)(object)Player.LocalPlayer))
		{
			float num = Bhop.CurrentSpeed / Bhop.SprintSpeed;
			string text = ((num >= Plugin.MaxSpeed.Value - 0.01f) ? "#ff6a6a" : ((num >= 1.5f) ? "#ffd84a" : "#ffffff"));
			string text2 = (Bhop.ChainIsAuto ? " <color=#7fe0ff>(auto)</color>" : "");
			float num2 = KillBonus.CurrentWorth();
			if (num2 > 1.001f)
			{
				text2 += $"  <color=#9fff7a>kills ${num2:0.00}x</color>";
			}
			Shadowed(new Rect(0f, (float)Screen.height * 0.62f, (float)Screen.width, 40f), $"<color={text}>x{Bhop.Chain} hops  ·  {Bhop.CurrentSpeed:0.0} m/s  ({num:0.00}x)</color>{text2}", _hud);
		}
	}

	private static void Shadowed(Rect r, string text, GUIStyle style)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		string text2 = Regex.Replace(text, "<.*?>", "");
		Color color = GUI.color;
		GUI.color = new Color(0f, 0f, 0f, 0.75f);
		GUI.Label(new Rect(((Rect)(ref r)).x + 2f, ((Rect)(ref r)).y + 2f, ((Rect)(ref r)).width, ((Rect)(ref r)).height), text2, style);
		GUI.color = color;
		GUI.Label(r, text, style);
	}
}
[HarmonyPatch]
public static class KillBonus
{
	[HarmonyPatch(typeof(KillScoreCalculator), "GetMeleeBonuses")]
	[HarmonyPostfix]
	private static void AfterMelee(ref List<Bonus> __result)
	{
		Add(ref __result);
	}

	[HarmonyPatch(typeof(KillScoreCalculator), "GetRangedBonuses")]
	[HarmonyPostfix]
	private static void AfterRanged(ref List<Bonus> __result)
	{
		Add(ref __result);
	}

	public static float CurrentWorth()
	{
		if (!Plugin.Enabled.Value || !Plugin.KillBonusEnabled.Value || !Object.op_Implicit((Object)(object)Player.LocalPlayer))
		{
			return 1f;
		}
		float num = Bhop.CurrentSpeed / Bhop.SprintSpeed;
		if (num < Plugin.KillBonusMinSpeed.Value)
		{
			return 1f;
		}
		float num2 = Mathf.Clamp01((num - 1f) / Mathf.Max(0.01f, Plugin.MaxSpeed.Value - 1f));
		return 1f + Plugin.KillBonusMax.Value * num2 * num2;
	}

	private static void Add(ref List<Bonus> bonuses)
	{
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			if (bonuses == null)
			{
				return;
			}
			float num = CurrentWorth();
			if (!(num <= 1.001f))
			{
				float num2 = Bhop.CurrentSpeed / Bhop.SprintSpeed;
				bonuses.Add(new Bonus($"Bhop Speed {num2:0.0}x", num));
				bonuses = bonuses.OrderByDescending((Bonus b) => b.Worth).ToList();
			}
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("Bhop kill bonus failed: " + ex.Message));
		}
	}
}
[BepInPlugin("com.howtofish.bhops", "Bhops", "1.0.0")]
public class Plugin : BaseUnityPlugin
{
	public const string Guid = "com.howtofish.bhops";

	public const string Name = "Bhops";

	public const string Version = "1.0.0";

	public static ConfigEntry<bool> Enabled;

	public static ConfigEntry<float> SpeedGainPerHop;

	public static ConfigEntry<float> MaxSpeed;

	public static ConfigEntry<float> HopWindow;

	public static ConfigEntry<float> AirTurnSpeed;

	public static ConfigEntry<float> JumpBuffer;

	public static ConfigEntry<bool> AutoBhop;

	public static ConfigEntry<KeyCode> AutoBhopKey;

	public static ConfigEntry<float> AutoBhopGain;

	public static ConfigEntry<bool> SongEnabled;

	public static ConfigEntry<KeyCode> SongToggleKey;

	public static ConfigEntry<int> SongStartHops;

	public static ConfigEntry<float> SongVolume;

	public static ConfigEntry<float> SongFadeTime;

	public static ConfigEntry<bool> SongWithAutoBhop;

	public static ConfigEntry<bool> SongRestartEachStreak;

	public static ConfigEntry<bool> KillBonusEnabled;

	public static ConfigEntry<float> KillBonusMinSpeed;

	public static ConfigEntry<float> KillBonusMax;

	public static ConfigEntry<bool> ShowHud;

	public static Plugin Instance { get; private set; }

	public static ManualLogSource Log { get; private set; }

	public static string Folder { get; private set; }

	private void Awake()
	{
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Expected O, but got Unknown
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Expected O, but got Unknown
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Expected O, but got Unknown
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: Expected O, but got Unknown
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: Expected O, but got Unknown
		//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: Expected O, but got Unknown
		//IL_025c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: Expected O, but got Unknown
		//IL_0299: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a3: Expected O, but got Unknown
		//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e0: Expected O, but got Unknown
		//IL_0373: Unknown result type (might be due to invalid IL or missing references)
		//IL_037d: Expected O, but got Unknown
		//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ba: Expected O, but got Unknown
		//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ef: Expected O, but got Unknown
		//IL_03ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_0402: Unknown result type (might be due to invalid IL or missing references)
		//IL_0407: Unknown result type (might be due to invalid IL or missing references)
		Instance = this;
		Log = ((BaseUnityPlugin)this).Logger;
		Folder = Path.GetDirectoryName(((BaseUnityPlugin)this).Info.Location);
		Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Momentum", "Enabled", true, "Bunny hopping keeps and builds speed. Turn off to play with the normal movement.");
		SpeedGainPerHop = ((BaseUnityPlugin)this).Config.Bind<float>("Momentum", "SpeedGainPerHop", 0.08f, new ConfigDescription("Extra speed for every hop you land, as a fraction of sprint speed (0.08 = +8% of sprint speed per hop).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.5f), Array.Empty<object>()));
		MaxSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Momentum", "MaxSpeed", 2.5f, new ConfigDescription("Top bhop speed, as a multiple of sprint speed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>()));
		HopWindow = ((BaseUnityPlugin)this).Config.Bind<float>("Momentum", "HopWindow", 0.12f, new ConfigDescription("Seconds you can stay on the ground after landing and still keep your chain. Smaller = harder.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.02f, 0.5f), Array.Empty<object>()));
		JumpBuffer = ((BaseUnityPlugin)this).Config.Bind<float>("Momentum", "JumpBuffer", 0.1f, new ConfigDescription("Press jump up to this many seconds before you land and you'll hop the moment you touch the ground. 0 = off (hardcore).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 0.3f), Array.Empty<object>()));
		AirTurnSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Momentum", "AirTurnSpeed", 270f, new ConfigDescription("How fast (degrees per second) you can steer your momentum in the air.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 2000f), Array.Empty<object>()));
		AutoBhop = ((BaseUnityPlugin)this).Config.Bind<bool>("Auto Bhop", "AutoBhop", false, "Hold jump to hop automatically every time you touch the ground.");
		AutoBhopKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Auto Bhop", "ToggleKey", (KeyCode)291, "Turns auto bhop on / off in game.");
		AutoBhopGain = ((BaseUnityPlugin)this).Config.Bind<float>("Auto Bhop", "AutoBhopSpeedGain", 1f, new ConfigDescription("Multiplier on SpeedGainPerHop for automatic hops (1 = same as perfect manual hops, 0.5 = half).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
		SongEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Song", "Enabled", true, "Play the song while you keep a bhop chain going. Put an .mp3, .ogg or .wav next to HowToFishBhops.dll to use your own.");
		SongToggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Song", "ToggleKey", (KeyCode)45, "Turns the song on / off in game.");
		SongStartHops = ((BaseUnityPlugin)this).Config.Bind<int>("Song", "StartAfterHops", 3, new ConfigDescription("Hops in a row you have to land before the song starts.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 50), Array.Empty<object>()));
		SongVolume = ((BaseUnityPlugin)this).Config.Bind<float>("Song", "Volume", 0.6f, new ConfigDescription("Song volume.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
		SongFadeTime = ((BaseUnityPlugin)this).Config.Bind<float>("Song", "FadeOutTime", 0.75f, new ConfigDescription("Seconds the song takes to fade out after you lose your chain.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 5f), Array.Empty<object>()));
		SongWithAutoBhop = ((BaseUnityPlugin)this).Config.Bind<bool>("Song", "PlayWithAutoBhop", true, "Auto bhop chains also play the song.");
		SongRestartEachStreak = ((BaseUnityPlugin)this).Config.Bind<bool>("Song", "RestartEachStreak", false, "Start the song from the beginning every new chain (otherwise it carries on where it left off).");
		KillBonusEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Kill Bonus", "Enabled", true, "Killing a creature while bhopping fast adds a \"Bhop Speed\" kill score bonus, so it sells for more.");
		KillBonusMinSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Kill Bonus", "MinSpeed", 1.25f, new ConfigDescription("How fast you need to be going (multiple of sprint speed) to get the bonus.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>()));
		KillBonusMax = ((BaseUnityPlugin)this).Config.Bind<float>("Kill Bonus", "MaxBonus", 4f, new ConfigDescription("Extra worth at top bhop speed (4 = sells for 5x, 2 = 3x). Ramps up the faster you go, so halfway to top speed is about 2x. Stacks with the game's other kill bonuses.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
		ShowHud = ((BaseUnityPlugin)this).Config.Bind<bool>("HUD", "ShowSpeed", true, "Show your hop count and speed while bhopping.");
		GameObject val = new GameObject("HowToFishBhops");
		Object.DontDestroyOnLoad((Object)val);
		((Object)val).hideFlags = (HideFlags)61;
		val.AddComponent<BhopController>();
		Harmony val2 = new Harmony("com.howtofish.bhops");
		val2.PatchAll(typeof(Plugin).Assembly);
		int num = 0;
		foreach (MethodBase patchedMethod in val2.GetPatchedMethods())
		{
			_ = patchedMethod;
			num++;
		}
		if (num < 5)
		{
			Log.LogError((object)$"Only {num} of 5 game methods got patched - some features won't work. The game probably updated.");
		}
		Log.LogInfo((object)string.Format("{0} {1} loaded ({2} methods patched)", "Bhops", "1.0.0", num));
	}
}