Decompiled source of BonusJump v1.1.0

plugins/BonusJump/BonusJump.dll

Decompiled 3 months 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.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using IL.RoR2;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour.HookGen;
using On.RoR2;
using RoR2;
using RoR2.ContentManagement;
using UnityEngine;
using UnityEngine.Networking;

[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("BonusJump")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BonusJump")]
[assembly: AssemblyTitle("BonusJump")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace TPDespair.BonusJump;

public class ServerBonusJumpBehavior : ItemBehavior
{
	private enum JumpState
	{
		Cooldown,
		Waiting,
		Available
	}

	internal static BuffIndex availableBuff = (BuffIndex)(-1);

	internal static BuffIndex waitingBuff = (BuffIndex)(-1);

	internal static BuffIndex cooldownBuff = (BuffIndex)(-1);

	private CharacterMotor motor;

	private JumpState jumpState = JumpState.Cooldown;

	private float timer = -1f;

	private bool cleanseCooldown = false;

	private bool requestedUsage = false;

	private float timeSinceLastGrounded = 0.25f;

	private float groundThreshold = 0.25f;

	public void Awake()
	{
		((Behaviour)this).enabled = false;
	}

	public void OnEnable()
	{
		if (Object.op_Implicit((Object)(object)base.body))
		{
			CharacterMotor characterMotor = base.body.characterMotor;
			if (Object.op_Implicit((Object)(object)characterMotor))
			{
				motor = characterMotor;
			}
			jumpState = JumpState.Cooldown;
			float value = BonusJumpPlugin.JumpCooldown.Value;
			if (value >= 1f)
			{
				timer = value;
			}
			groundThreshold = BonusJumpPlugin.GroundThreshold.Value;
			timeSinceLastGrounded = groundThreshold;
			ClearDisplayBuffs();
		}
	}

	public void OnDisable()
	{
		if (Object.op_Implicit((Object)(object)base.body))
		{
			ClearDisplayBuffs();
		}
	}

	public void FixedUpdate()
	{
		if (NetworkServer.active && timer >= 0f && Object.op_Implicit((Object)(object)base.body) && Object.op_Implicit((Object)(object)motor))
		{
			UpdateGroundTracking();
			UpdateJumpState();
			UpdateBuffDisplay();
		}
	}

	private void UpdateGroundTracking()
	{
		float fixedDeltaTime = Time.fixedDeltaTime;
		if (motor.isGrounded)
		{
			timeSinceLastGrounded = 0f;
		}
		else
		{
			timeSinceLastGrounded += fixedDeltaTime;
		}
		if (timeSinceLastGrounded <= groundThreshold)
		{
			timer = Mathf.Max(0f, timer - fixedDeltaTime);
		}
	}

	private void UpdateJumpState()
	{
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Invalid comparison between Unknown and I4
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		if (jumpState == JumpState.Cooldown && timer <= 0f)
		{
			jumpState = JumpState.Available;
		}
		if (jumpState == JumpState.Available && requestedUsage)
		{
			jumpState = JumpState.Waiting;
			requestedUsage = false;
		}
		if (jumpState == JumpState.Waiting && motor.isGrounded)
		{
			if (cleanseCooldown)
			{
				jumpState = JumpState.Available;
				timer = 0f;
			}
			else
			{
				jumpState = JumpState.Cooldown;
				float num = BonusJumpPlugin.JumpCooldown.Value;
				float value = BonusJumpPlugin.CloudCompat.Value;
				if (value > 0f && (int)BonusJumpPlugin.RainbowCloudItem != -1)
				{
					Inventory inventory = base.body.inventory;
					if (Object.op_Implicit((Object)(object)inventory))
					{
						int itemCount = inventory.GetItemCount(BonusJumpPlugin.RainbowCloudItem);
						if (itemCount > 0)
						{
							num *= 1f - Util.ConvertAmplificationPercentageIntoReductionPercentage(value * 100f * (float)itemCount) / 100f;
						}
					}
				}
				timer = Mathf.Max(1f, num);
			}
		}
		if (jumpState == JumpState.Cooldown && cleanseCooldown)
		{
			jumpState = JumpState.Available;
			timer = 0f;
		}
		if (jumpState != JumpState.Waiting)
		{
			cleanseCooldown = false;
		}
	}

	private void ClearDisplayBuffs()
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		if (NetworkServer.active)
		{
			base.body.SetBuffCount(availableBuff, 0);
			base.body.SetBuffCount(waitingBuff, 0);
			base.body.SetBuffCount(cooldownBuff, 0);
		}
	}

	private void UpdateBuffDisplay()
	{
		//IL_009a: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: 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)
		//IL_016c: 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_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: 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)
		if (jumpState == JumpState.Available)
		{
			if (!base.body.HasBuff(availableBuff))
			{
				base.body.SetBuffCount(availableBuff, 1);
			}
			if (base.body.HasBuff(waitingBuff))
			{
				base.body.SetBuffCount(waitingBuff, 0);
			}
			if (base.body.HasBuff(cooldownBuff))
			{
				base.body.SetBuffCount(cooldownBuff, 0);
			}
			return;
		}
		if (base.body.HasBuff(availableBuff))
		{
			base.body.SetBuffCount(availableBuff, 0);
		}
		if (jumpState == JumpState.Waiting)
		{
			if (!base.body.HasBuff(waitingBuff))
			{
				base.body.SetBuffCount(waitingBuff, 1);
			}
			if (base.body.HasBuff(cooldownBuff))
			{
				base.body.SetBuffCount(cooldownBuff, 0);
			}
			return;
		}
		if (base.body.HasBuff(waitingBuff))
		{
			base.body.SetBuffCount(waitingBuff, 0);
		}
		int num = Mathf.Max(1, Mathf.CeilToInt(timer));
		int buffCount = base.body.GetBuffCount(cooldownBuff);
		if (buffCount != num)
		{
			base.body.SetBuffCount(cooldownBuff, num);
		}
	}

	public void CleanseCooldown()
	{
		if (NetworkServer.active)
		{
			cleanseCooldown = true;
		}
	}

	public void ApplyUsageRequest()
	{
		if (NetworkServer.active)
		{
			requestedUsage = true;
		}
	}
}
public class AuthBonusJumpBehavior : ItemBehavior
{
	internal static BuffIndex availableBuff = (BuffIndex)(-1);

	internal static BuffIndex waitingBuff = (BuffIndex)(-1);

	private CharacterMotor motor;

	private bool broadcastedUsage = false;

	private bool dontConsumeBonus = false;

	private int prevJumpCount = 0;

	private float timeSinceLastChanged = 0f;

	public void Awake()
	{
		((Behaviour)this).enabled = false;
	}

	public void OnEnable()
	{
		if (Object.op_Implicit((Object)(object)base.body))
		{
			CharacterMotor characterMotor = base.body.characterMotor;
			if (Object.op_Implicit((Object)(object)characterMotor))
			{
				motor = characterMotor;
			}
		}
	}

	public void FixedUpdate()
	{
		if (IsAuthority() && Object.op_Implicit((Object)(object)base.body) && Object.op_Implicit((Object)(object)motor))
		{
			UpdateJumpTracking();
			UpdateJumpState();
		}
	}

	private void UpdateJumpTracking()
	{
		if (motor.jumpCount != prevJumpCount)
		{
			dontConsumeBonus = false;
			if (ReachedMaxJumpCount() && (timeSinceLastChanged <= 0.125f || motor.jumpCount - prevJumpCount > 1))
			{
				dontConsumeBonus = true;
			}
			timeSinceLastChanged = 0f;
			prevJumpCount = motor.jumpCount;
		}
		else
		{
			timeSinceLastChanged += Time.fixedDeltaTime;
		}
	}

	private void UpdateJumpState()
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		if (base.body.HasBuff(availableBuff) && ReachedMaxJumpCount() && !dontConsumeBonus && !broadcastedUsage)
		{
			broadcastedUsage = true;
			base.body.AddTimedBuffAuthority(waitingBuff, 0f);
		}
		if (motor.jumpCount == 0 && broadcastedUsage)
		{
			broadcastedUsage = false;
		}
	}

	private bool ReachedMaxJumpCount()
	{
		return motor.jumpCount >= base.body.maxJumpCount && base.body.maxJumpCount > 0;
	}

	private bool IsAuthority()
	{
		return NetworkClient.active && base.body.hasEffectiveAuthority;
	}

	public void DontConsume()
	{
		if (IsAuthority() && base.body.maxJumpCount > 0)
		{
			dontConsumeBonus = true;
			prevJumpCount = base.body.maxJumpCount;
			timeSinceLastChanged = 0f;
		}
	}
}
public class BonusJumpContent : IContentPackProvider
{
	public static class Buffs
	{
		public static BuffDef JumpAvailable;

		public static BuffDef JumpWaiting;

		public static BuffDef JumpCooldown;

		public static List<BuffDef> buffDefs = new List<BuffDef>();

		public static void Create()
		{
			//IL_002f: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: 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)
			JumpAvailable = ScriptableObject.CreateInstance<BuffDef>();
			((Object)JumpAvailable).name = "BonusJumpAvailable";
			JumpAvailable.buffColor = new Color(0.35f, 0.65f, 0.35f);
			JumpAvailable.canStack = false;
			JumpAvailable.isDebuff = false;
			JumpAvailable.iconSprite = Sprites.BonusJumpNormal;
			buffDefs.Add(JumpAvailable);
			JumpWaiting = ScriptableObject.CreateInstance<BuffDef>();
			((Object)JumpWaiting).name = "BonusJumpWaiting";
			JumpWaiting.buffColor = new Color(0.65f, 0.65f, 0.35f);
			JumpWaiting.canStack = false;
			JumpWaiting.isDebuff = false;
			JumpWaiting.iconSprite = Sprites.BonusJumpShaded;
			buffDefs.Add(JumpWaiting);
			JumpCooldown = ScriptableObject.CreateInstance<BuffDef>();
			((Object)JumpCooldown).name = "BonusJumpCooldown";
			JumpCooldown.buffColor = new Color(0.65f, 0.35f, 0.35f);
			JumpCooldown.canStack = true;
			JumpCooldown.isDebuff = false;
			JumpCooldown.iconSprite = Sprites.BonusJumpShaded;
			buffDefs.Add(JumpCooldown);
		}
	}

	public static class Sprites
	{
		public static Sprite BonusJumpNormal;

		public static Sprite BonusJumpShaded;

		public static void Create()
		{
			BonusJumpNormal = BonusJumpPlugin.Assets.LoadAsset<Sprite>("Assets/Icons/texBuffJump.png");
			BonusJumpShaded = BonusJumpPlugin.Assets.LoadAsset<Sprite>("Assets/Icons/texBuffJumpShaded.png");
		}
	}

	public ContentPack contentPack = new ContentPack();

	public string identifier => "BonusJumpContent";

	public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
	{
		BonusJumpPlugin.LoadAssets();
		Sprites.Create();
		Buffs.Create();
		SetInternalRef();
		contentPack.buffDefs.Add(Buffs.buffDefs.ToArray());
		args.ReportProgress(1f);
		yield break;
	}

	public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
	{
		ContentPack.Copy(contentPack, args.output);
		args.ReportProgress(1f);
		yield break;
	}

	public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
	{
		args.ReportProgress(1f);
		yield break;
	}

	public static void SetInternalRef()
	{
		BonusJumpPlugin.availableBuff = Buffs.JumpAvailable;
		BonusJumpPlugin.waitingBuff = Buffs.JumpWaiting;
		BonusJumpPlugin.cooldownBuff = Buffs.JumpCooldown;
	}
}
[BepInPlugin("com.TPDespair.BonusJump", "BonusJump", "1.1.0")]
public class BonusJumpPlugin : BaseUnityPlugin
{
	[Serializable]
	[CompilerGenerated]
	private sealed class <>c
	{
		public static readonly <>c <>9 = new <>c();

		public static hook_TokenIsRegistered <>9__30_0;

		public static hook_GetString_string <>9__30_1;

		public static Func<Instruction, bool> <>9__34_1;

		public static Func<Instruction, bool> <>9__34_2;

		public static Func<Instruction, bool> <>9__34_3;

		public static Func<CharacterBody, int, int> <>9__34_5;

		public static Manipulator <>9__34_0;

		public static hook_Init <>9__35_0;

		public static hook_CleanseBody <>9__38_0;

		public static hook_AddTimedBuff_BuffIndex_float <>9__39_0;

		public static Func<Instruction, bool> <>9__42_0;

		public static Func<Instruction, bool> <>9__42_1;

		public static Action<EntityState> <>9__42_2;

		internal bool <LanguageOverride>b__30_0(orig_TokenIsRegistered orig, Language self, string token)
		{
			if (token != null && LangTokens.ContainsKey(token))
			{
				return true;
			}
			return orig.Invoke(self, token);
		}

		internal string <LanguageOverride>b__30_1(orig_GetString_string orig, string token)
		{
			if (token != null && LangTokens.ContainsKey(token))
			{
				return LangTokens[token];
			}
			return orig.Invoke(token);
		}

		internal void <JumpCountHook>b__34_0(ILContext il)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			<>c__DisplayClass34_0 CS$<>8__locals0 = new <>c__DisplayClass34_0();
			ILCursor val = new ILCursor(il);
			CS$<>8__locals0.index = -1;
			if (val.TryGotoNext(new Func<Instruction, bool>[4]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<CharacterBody>(x, "baseJumpCount"),
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref CS$<>8__locals0.index)
			}))
			{
				val.Emit(OpCodes.Ldarg, 0);
				val.Emit(OpCodes.Ldloc, CS$<>8__locals0.index);
				val.EmitDelegate<Func<CharacterBody, int, int>>((Func<CharacterBody, int, int>)delegate(CharacterBody self, int value)
				{
					if (self.HasBuff(BonusJumpContent.Buffs.JumpAvailable) || self.HasBuff(BonusJumpContent.Buffs.JumpWaiting))
					{
						value++;
					}
					return value;
				});
				val.Emit(OpCodes.Stloc, CS$<>8__locals0.index);
			}
			else
			{
				LogWarn("JumpCountHook Failed");
			}
		}

		internal bool <JumpCountHook>b__34_1(Instruction x)
		{
			return ILPatternMatchingExt.MatchLdarg(x, 0);
		}

		internal bool <JumpCountHook>b__34_2(Instruction x)
		{
			return ILPatternMatchingExt.MatchLdarg(x, 0);
		}

		internal bool <JumpCountHook>b__34_3(Instruction x)
		{
			return ILPatternMatchingExt.MatchLdfld<CharacterBody>(x, "baseJumpCount");
		}

		internal int <JumpCountHook>b__34_5(CharacterBody self, int value)
		{
			if (self.HasBuff(BonusJumpContent.Buffs.JumpAvailable) || self.HasBuff(BonusJumpContent.Buffs.JumpWaiting))
			{
				value++;
			}
			return value;
		}

		internal void <IndicatorBuffDisplayHook>b__35_0(orig_Init orig)
		{
			orig.Invoke();
			HoistIndicatorBuffs();
		}

		internal void <HandleCleanseHook>b__38_0(orig_CleanseBody orig, CharacterBody body, bool debuff, bool buff, bool cooldown, bool dot, bool stun, bool proj)
		{
			if (Object.op_Implicit((Object)(object)body) && cooldown)
			{
				ServerBonusJumpBehavior component = ((Component)body).GetComponent<ServerBonusJumpBehavior>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.CleanseCooldown();
				}
			}
			orig.Invoke(body, debuff, buff, cooldown, dot, stun, proj);
		}

		internal void <UsageRequestedHook>b__39_0(orig_AddTimedBuff_BuffIndex_float orig, CharacterBody body, BuffIndex buff, float duration)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: 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 (buff == waitingBuff.buffIndex)
			{
				ServerBonusJumpBehavior component = ((Component)body).GetComponent<ServerBonusJumpBehavior>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.ApplyUsageRequest();
				}
			}
			else
			{
				orig.Invoke(body, buff, duration);
			}
		}

		internal bool <PaladinAirSlamHook>b__42_0(Instruction x)
		{
			return ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(x, "get_maxJumpCount");
		}

		internal bool <PaladinAirSlamHook>b__42_1(Instruction x)
		{
			return ILPatternMatchingExt.MatchStfld<CharacterMotor>(x, "jumpCount");
		}

		internal void <PaladinAirSlamHook>b__42_2(EntityState entityState)
		{
			CharacterMotor characterMotor = entityState.characterMotor;
			CharacterBody characterBody = entityState.characterBody;
			if (characterMotor.jumpCount < characterBody.maxJumpCount)
			{
				AuthBonusJumpBehavior component = ((Component)characterBody).GetComponent<AuthBonusJumpBehavior>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.DontConsume();
				}
			}
		}
	}

	[CompilerGenerated]
	private sealed class <>c__DisplayClass34_0
	{
		public int index;

		internal bool <JumpCountHook>b__4(Instruction x)
		{
			return ILPatternMatchingExt.MatchLdloc(x, ref index);
		}
	}

	public const string ModVer = "1.1.0";

	public const string ModName = "BonusJump";

	public const string ModGuid = "com.TPDespair.BonusJump";

	public static ConfigFile configFile;

	public static ManualLogSource logSource;

	public static AssetBundle Assets;

	public static Dictionary<string, string> LangTokens = new Dictionary<string, string>();

	private static readonly BindingFlags Flags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

	public static BuffDef availableBuff;

	public static BuffDef waitingBuff;

	public static BuffDef cooldownBuff;

	public static ItemIndex RainbowCloudItem = (ItemIndex)(-1);

	public static ConfigEntry<float> JumpCooldown { get; set; }

	public static ConfigEntry<float> GroundThreshold { get; set; }

	public static ConfigEntry<float> CloudCompat { get; set; }

	public void Awake()
	{
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Expected O, but got Unknown
		RoR2Application.isModded = true;
		NetworkModCompatibilityHelper.networkModList = NetworkModCompatibilityHelper.networkModList.Append("com.TPDespair.BonusJump:1.1.0");
		configFile = ((BaseUnityPlugin)this).Config;
		logSource = ((BaseUnityPlugin)this).Logger;
		SetupConfig();
		LanguageOverride();
		if (CloudCompat.Value > 0f)
		{
			float num = CloudCompat.Value * 100f;
			RegisterToken("ITEM_MYSTICSBADITEMS_RAINBOWTRAIL_DESC", "Gain <style=cIsUtility>" + num + "%</style> <style=cStack>(+" + num + "% per stack)</style> <style=cIsUtility>cooldown reduction</style> towards <style=cIsUtility>bonus jump</style>.\nLeave a <link=\"MysticsBadItemsRainbowWavy\">rainbow trail</link> behind.");
			RegisterToken("ITEM_MYSTICSBADITEMS_RAINBOWTRAIL_PICKUP", "Gain bonus jump cooldown recovery and leave a <link=\"MysticsBadItemsRainbowWavy\">rainbow trail</link> behind.");
		}
		ContentManager.collectContentPackProviders += new CollectContentPackProvidersDelegate(ContentManager_collectContentPackProviders);
		JumpCountHook();
		IndicatorBuffDisplayHook();
		CharacterBody.onBodyInventoryChangedGlobal += HandleItemBehavior;
		HandleCleanseHook();
		UsageRequestedHook();
		RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(LateSetup));
	}

	private static void LateSetup()
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		AllocateBehaviorBuffs();
		if (PluginLoaded("com.themysticsword.mysticsbaditems"))
		{
			RainbowCloudItem = FindItemIndex("MysticsBadItems_RainbowTrail");
		}
		PaladinCompat();
	}

	private static ItemIndex FindItemIndex(string itemName)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Invalid comparison between Unknown and I4
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		ItemIndex val = ItemCatalog.FindItemIndex(itemName);
		if ((int)val == -1)
		{
			LogWarn("Could not find ItemIndex for : " + itemName);
		}
		return val;
	}

	private static void SetupConfig()
	{
		JumpCooldown = configFile.Bind<float>("General", "JumpCooldown", 10f, "Cooldown of bonus jump. Cooldown only recovers while grounded.");
		GroundThreshold = configFile.Bind<float>("General", "GroundThreshold", 0.25f, "Time after not being grounded to still be counted as grounded for cooldown recovery.");
		CloudCompat = configFile.Bind<float>("General", "CloudCompat", 0.25f, "Bonus jump cooldown reduction per Cloud Nine. Set to 0 to disable.");
	}

	private void ContentManager_collectContentPackProviders(AddContentPackProviderDelegate addContentPackProvider)
	{
		addContentPackProvider.Invoke((IContentPackProvider)(object)new BonusJumpContent());
	}

	internal static void LoadAssets()
	{
		using Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("TPDespair.BonusJump.bonusjumpbundle");
		Assets = AssetBundle.LoadFromStream(stream);
	}

	private static void LanguageOverride()
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Expected O, but got Unknown
		object obj = <>c.<>9__30_0;
		if (obj == null)
		{
			hook_TokenIsRegistered val = (orig_TokenIsRegistered orig, Language self, string token) => (token != null && LangTokens.ContainsKey(token)) || orig.Invoke(self, token);
			<>c.<>9__30_0 = val;
			obj = (object)val;
		}
		Language.TokenIsRegistered += (hook_TokenIsRegistered)obj;
		object obj2 = <>c.<>9__30_1;
		if (obj2 == null)
		{
			hook_GetString_string val2 = (orig_GetString_string orig, string token) => (token != null && LangTokens.ContainsKey(token)) ? LangTokens[token] : orig.Invoke(token);
			<>c.<>9__30_1 = val2;
			obj2 = (object)val2;
		}
		Language.GetString_string += (hook_GetString_string)obj2;
	}

	public static void RegisterToken(string token, string text)
	{
		if (!LangTokens.ContainsKey(token))
		{
			LangTokens.Add(token, text);
		}
		else
		{
			LangTokens[token] = text;
		}
	}

	internal static void LogWarn(object data)
	{
		logSource.LogWarning(data);
	}

	internal static bool PluginLoaded(string key)
	{
		return Chainloader.PluginInfos.ContainsKey(key);
	}

	private static void JumpCountHook()
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		object obj = <>c.<>9__34_0;
		if (obj == null)
		{
			Manipulator val = delegate(ILContext il)
			{
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Expected O, but got Unknown
				//IL_009e: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
				ILCursor val2 = new ILCursor(il);
				int index = -1;
				if (val2.TryGotoNext(new Func<Instruction, bool>[4]
				{
					(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
					(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
					(Instruction x) => ILPatternMatchingExt.MatchLdfld<CharacterBody>(x, "baseJumpCount"),
					(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref index)
				}))
				{
					val2.Emit(OpCodes.Ldarg, 0);
					val2.Emit(OpCodes.Ldloc, index);
					val2.EmitDelegate<Func<CharacterBody, int, int>>((Func<CharacterBody, int, int>)delegate(CharacterBody self, int value)
					{
						if (self.HasBuff(BonusJumpContent.Buffs.JumpAvailable) || self.HasBuff(BonusJumpContent.Buffs.JumpWaiting))
						{
							value++;
						}
						return value;
					});
					val2.Emit(OpCodes.Stloc, index);
				}
				else
				{
					LogWarn("JumpCountHook Failed");
				}
			};
			<>c.<>9__34_0 = val;
			obj = (object)val;
		}
		CharacterBody.RecalculateStats += (Manipulator)obj;
	}

	private static void IndicatorBuffDisplayHook()
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		object obj = <>c.<>9__35_0;
		if (obj == null)
		{
			hook_Init val = delegate(orig_Init orig)
			{
				orig.Invoke();
				HoistIndicatorBuffs();
			};
			<>c.<>9__35_0 = val;
			obj = (object)val;
		}
		BuffCatalog.Init += (hook_Init)obj;
	}

	private static void HoistIndicatorBuffs()
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: 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_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Expected I4, but got Unknown
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Expected I4, but got Unknown
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Expected I4, but got Unknown
		BuffIndex jumpAvailable = availableBuff.buffIndex;
		BuffIndex jumpWaiting = waitingBuff.buffIndex;
		BuffIndex jumpCooldown = cooldownBuff.buffIndex;
		BuffIndex[] collection = (BuffIndex[])(object)new BuffIndex[3]
		{
			(BuffIndex)(int)jumpAvailable,
			(BuffIndex)(int)jumpWaiting,
			(BuffIndex)(int)jumpCooldown
		};
		List<BuffIndex> list = new List<BuffIndex>(BuffCatalog.nonHiddenBuffIndices);
		list.RemoveAll((BuffIndex t) => t == jumpAvailable || t == jumpWaiting || t == jumpCooldown);
		List<BuffIndex> list2 = new List<BuffIndex>();
		list2.AddRange(collection);
		list2.AddRange(list);
		BuffCatalog.nonHiddenBuffIndices = list2.ToArray();
	}

	private static void HandleItemBehavior(CharacterBody body)
	{
		int num = (body.isPlayerControlled ? 1 : 0);
		body.AddItemBehavior<AuthBonusJumpBehavior>(num);
		if (NetworkServer.active)
		{
			body.AddItemBehavior<ServerBonusJumpBehavior>(num);
		}
	}

	private static void HandleCleanseHook()
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		object obj = <>c.<>9__38_0;
		if (obj == null)
		{
			hook_CleanseBody val = delegate(orig_CleanseBody orig, CharacterBody body, bool debuff, bool buff, bool cooldown, bool dot, bool stun, bool proj)
			{
				if (Object.op_Implicit((Object)(object)body) && cooldown)
				{
					ServerBonusJumpBehavior component = ((Component)body).GetComponent<ServerBonusJumpBehavior>();
					if (Object.op_Implicit((Object)(object)component))
					{
						component.CleanseCooldown();
					}
				}
				orig.Invoke(body, debuff, buff, cooldown, dot, stun, proj);
			};
			<>c.<>9__38_0 = val;
			obj = (object)val;
		}
		Util.CleanseBody += (hook_CleanseBody)obj;
	}

	private static void UsageRequestedHook()
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		object obj = <>c.<>9__39_0;
		if (obj == null)
		{
			hook_AddTimedBuff_BuffIndex_float val = delegate(orig_AddTimedBuff_BuffIndex_float orig, CharacterBody body, BuffIndex buff, float duration)
			{
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: 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 (buff == waitingBuff.buffIndex)
				{
					ServerBonusJumpBehavior component = ((Component)body).GetComponent<ServerBonusJumpBehavior>();
					if (Object.op_Implicit((Object)(object)component))
					{
						component.ApplyUsageRequest();
					}
				}
				else
				{
					orig.Invoke(body, buff, duration);
				}
			};
			<>c.<>9__39_0 = val;
			obj = (object)val;
		}
		CharacterBody.AddTimedBuff_BuffIndex_float += (hook_AddTimedBuff_BuffIndex_float)obj;
	}

	private static void AllocateBehaviorBuffs()
	{
		//IL_0006: 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_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: 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_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		ServerBonusJumpBehavior.availableBuff = availableBuff.buffIndex;
		ServerBonusJumpBehavior.waitingBuff = waitingBuff.buffIndex;
		ServerBonusJumpBehavior.cooldownBuff = cooldownBuff.buffIndex;
		AuthBonusJumpBehavior.availableBuff = availableBuff.buffIndex;
		AuthBonusJumpBehavior.waitingBuff = waitingBuff.buffIndex;
	}

	private static void PaladinCompat()
	{
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Expected O, but got Unknown
		if (!PluginLoaded("com.rob.Paladin"))
		{
			return;
		}
		BaseUnityPlugin instance = Chainloader.PluginInfos["com.rob.Paladin"].Instance;
		Assembly assembly = Assembly.GetAssembly(((object)instance).GetType());
		Type type = Type.GetType("PaladinMod.States.AirSlam, " + assembly.FullName, throwOnError: false);
		if (type != null)
		{
			MethodInfo method = type.GetMethod("OnEnter", Flags);
			if (method != null)
			{
				HookEndpointManager.Modify((MethodBase)method, (Delegate)new Manipulator(PaladinAirSlamHook));
			}
			else
			{
				LogWarn("[PaladinAirSlam] - Could Not Find Method : AirSlam.OnEnter");
			}
		}
		else
		{
			LogWarn("[PaladinAirSlam] - Could Not Find Type : PaladinMod.States.AirSlam");
		}
	}

	private static void PaladinAirSlamHook(ILContext il)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Expected O, but got Unknown
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		ILCursor val = new ILCursor(il);
		if (val.TryGotoNext(new Func<Instruction, bool>[2]
		{
			(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(x, "get_maxJumpCount"),
			(Instruction x) => ILPatternMatchingExt.MatchStfld<CharacterMotor>(x, "jumpCount")
		}))
		{
			val.Emit(OpCodes.Ldarg, 0);
			val.EmitDelegate<Action<EntityState>>((Action<EntityState>)delegate(EntityState entityState)
			{
				CharacterMotor characterMotor = entityState.characterMotor;
				CharacterBody characterBody = entityState.characterBody;
				if (characterMotor.jumpCount < characterBody.maxJumpCount)
				{
					AuthBonusJumpBehavior component = ((Component)characterBody).GetComponent<AuthBonusJumpBehavior>();
					if (Object.op_Implicit((Object)(object)component))
					{
						component.DontConsume();
					}
				}
			});
		}
		else
		{
			LogWarn("PaladinAirSlamHook Failed");
		}
	}
}