Decompiled source of BetterJumpPads v1.2.1

BetterJumpPads.dll

Decompiled 10 months ago
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.Logging;
using IL.RoR2;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.RoR2;
using R2API;
using RoR2;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;

[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.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("BetterJumpPads")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("BetterJumpPads")]
[assembly: AssemblyTitle("BetterJumpPads")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace BetterJumpPads
{
	[BepInPlugin("HIFU.BetterJumpPads", "BetterJumpPads", "1.2.0")]
	public class Main : BaseUnityPlugin
	{
		public const string PluginGUID = "HIFU.BetterJumpPads";

		public const string PluginAuthor = "HIFU";

		public const string PluginName = "BetterJumpPads";

		public const string PluginVersion = "1.2.0";

		public ManualLogSource BJPLogger;

		public static AssetBundle betterraincoaticon;

		public static BuffDef fallDamageRemoval;

		public void Awake()
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Expected O, but got Unknown
			BJPLogger = ((BaseUnityPlugin)this).Logger;
			fallDamageRemoval = ScriptableObject.CreateInstance<BuffDef>();
			fallDamageRemoval.isDebuff = false;
			fallDamageRemoval.isHidden = true;
			fallDamageRemoval.isCooldown = false;
			fallDamageRemoval.canStack = false;
			((Object)fallDamageRemoval).name = "Fall Damage Removal";
			ContentAddition.AddBuffDef(fallDamageRemoval);
			JumpVolume.OnTriggerStay += new hook_OnTriggerStay(JumpVolume_OnTriggerStay1);
			JumpVolume.OnTriggerStay += new Manipulator(JumpVolume_OnTriggerStay);
			SceneDirector.Start += new hook_Start(SceneDirector_Start);
			HealthComponent.TakeDamage += new hook_TakeDamage(HealthComponent_TakeDamage);
			CharacterMotor.OnLanded += new hook_OnLanded(CharacterMotor_OnLanded);
		}

		private void CharacterMotor_OnLanded(orig_OnLanded orig, CharacterMotor self)
		{
			orig.Invoke(self);
			CharacterBody body = self.body;
			if (Object.op_Implicit((Object)(object)body) && NetworkServer.active && body.HasBuff(fallDamageRemoval))
			{
				body.RemoveBuff(fallDamageRemoval);
			}
		}

		private void HealthComponent_TakeDamage(orig_TakeDamage orig, HealthComponent self, DamageInfo damageInfo)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Invalid comparison between Unknown and I4
			if ((damageInfo.damageType & 0x200000) > 0 && Object.op_Implicit((Object)(object)self.body) && self.body.HasBuff(fallDamageRemoval))
			{
				damageInfo.damage = 0f;
			}
			orig.Invoke(self, damageInfo);
		}

		private void JumpVolume_OnTriggerStay1(orig_OnTriggerStay orig, JumpVolume self, Collider other)
		{
			orig.Invoke(self, other);
			CharacterBody component = ((Component)other).GetComponent<CharacterBody>();
			if (NetworkServer.active && Object.op_Implicit((Object)(object)component) && !component.HasBuff(fallDamageRemoval))
			{
				component.AddBuff(fallDamageRemoval);
			}
		}

		private void SceneDirector_Start(orig_Start orig, SceneDirector self)
		{
			//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)
			Scene activeScene = SceneManager.GetActiveScene();
			ApplyJumpPadChanges(((Scene)(ref activeScene)).name);
			orig.Invoke(self);
		}

		private void ApplyJumpPadChanges(string sceneName)
		{
			//IL_0691: Unknown result type (might be due to invalid IL or missing references)
			//IL_0696: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: Unknown result type (might be due to invalid IL or missing references)
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0400: Unknown result type (might be due to invalid IL or missing references)
			//IL_0405: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0249: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_079a: Unknown result type (might be due to invalid IL or missing references)
			//IL_079f: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_07cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_07fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_082a: Unknown result type (might be due to invalid IL or missing references)
			//IL_082f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0876: Unknown result type (might be due to invalid IL or missing references)
			//IL_087b: Unknown result type (might be due to invalid IL or missing references)
			//IL_08ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_08b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0918: Unknown result type (might be due to invalid IL or missing references)
			//IL_091d: Unknown result type (might be due to invalid IL or missing references)
			//IL_094e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0953: Unknown result type (might be due to invalid IL or missing references)
			//IL_0984: Unknown result type (might be due to invalid IL or missing references)
			//IL_0989: Unknown result type (might be due to invalid IL or missing references)
			//IL_09ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_09bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0718: Unknown result type (might be due to invalid IL or missing references)
			//IL_071d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0754: Unknown result type (might be due to invalid IL or missing references)
			//IL_0759: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0532: Unknown result type (might be due to invalid IL or missing references)
			//IL_0537: Unknown result type (might be due to invalid IL or missing references)
			//IL_0562: Unknown result type (might be due to invalid IL or missing references)
			//IL_0567: Unknown result type (might be due to invalid IL or missing references)
			//IL_0446: Unknown result type (might be due to invalid IL or missing references)
			//IL_044b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0476: Unknown result type (might be due to invalid IL or missing references)
			//IL_047b: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0601: Unknown result type (might be due to invalid IL or missing references)
			//IL_064b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0650: Unknown result type (might be due to invalid IL or missing references)
			if (sceneName == null)
			{
				return;
			}
			switch (sceneName.Length)
			{
			case 11:
				switch (sceneName[2])
				{
				case 'c':
					if (sceneName == "ancientloft")
					{
						JumpVolume component9 = ((Component)GameObject.Find("AncientLoft_Geyser (1)").transform.GetChild(0)).GetComponent<JumpVolume>();
						component9.jumpVelocity = new Vector3(-40.8797f, 59.0024f, 6.0314f);
						JumpVolume component10 = ((Component)GameObject.Find("AncientLoft_Geyser").transform.GetChild(0)).GetComponent<JumpVolume>();
						component10.jumpVelocity = new Vector3(-50.912f, 27.0073f, -50.3548f);
					}
					break;
				case 'o':
					if (sceneName == "snowyforest")
					{
						Transform transform5 = GameObject.Find("HOLDER: Geysers").transform;
						JumpVolume component11 = ((Component)transform5.GetChild(0).GetChild(2)).GetComponent<JumpVolume>();
						component11.jumpVelocity = new Vector3(-9.5988f, 47.1578f, -9.6674f);
						JumpVolume component12 = ((Component)transform5.GetChild(2).GetChild(2)).GetComponent<JumpVolume>();
						component12.jumpVelocity = new Vector3(-25.7586f, 45.8282f, -1.8743f);
					}
					break;
				case 'l':
					if (sceneName == "sulfurpools")
					{
						Transform transform4 = GameObject.Find("HOLDER: Geysers").transform;
						JumpVolume component7 = ((Component)transform4.GetChild(5).GetChild(2)).GetComponent<JumpVolume>();
						component7.jumpVelocity = new Vector3(-15.6221f, 30.876f, 45.2898f);
						JumpVolume component8 = ((Component)transform4.GetChild(3).GetChild(2)).GetComponent<JumpVolume>();
						component8.jumpVelocity = new Vector3(5.9332f, 40.0777f, -33.4413f);
					}
					break;
				}
				break;
			case 10:
				switch (sceneName[0])
				{
				case 'f':
					if (sceneName == "frozenwall")
					{
						JumpVolume component5 = ((Component)GameObject.Find("PERMUTATION: Human Fan").transform.GetChild(2).GetChild(0).GetChild(0)).GetComponent<JumpVolume>();
						component5.jumpVelocity = new Vector3(2.2689f, 46.7217f, 13.1013f);
					}
					break;
				case 'r':
					if (sceneName == "rootjungle")
					{
						Transform transform2 = GameObject.Find("HOLDER: Jump Pads").transform;
						Transform transform3 = GameObject.Find("HOLDER: Randomization").transform;
						JumpVolume component3 = ((Component)transform2.GetChild(1).GetChild(0)).GetComponent<JumpVolume>();
						component3.jumpVelocity = new Vector3(-30f, 67f, 0.9657f);
						JumpVolume component4 = ((Component)transform3.GetChild(2).GetChild(0).GetChild(2)
							.GetChild(0)).GetComponent<JumpVolume>();
						component4.jumpVelocity = new Vector3(30.5242f, 57.02f, -45.692f);
					}
					break;
				}
				break;
			case 9:
				switch (sceneName[0])
				{
				case 's':
					if (sceneName == "skymeadow")
					{
						Transform transform10 = GameObject.Find("HOLDER: Jump Pads").transform;
						JumpVolume component28 = ((Component)transform10.GetChild(0).GetChild(2)).GetComponent<JumpVolume>();
						component28.jumpVelocity = new Vector3(10.8445f, 70.7327f, 50.4467f);
						GameObject val = GameObject.Find("HOLDER: Randomization");
						JumpVolume component29 = ((Component)val.transform.GetChild(4).GetChild(0).GetChild(3)
							.GetChild(2)).GetComponent<JumpVolume>();
						component29.jumpVelocity = new Vector3(-140.6104f, 20.6631f, -33.7556f);
						JumpVolume component30 = ((Component)transform10.GetChild(4).GetChild(2)).GetComponent<JumpVolume>();
						component30.jumpVelocity = new Vector3(-45.5706f, 20.4607f, 115.4046f);
						JumpVolume component31 = ((Component)transform10.GetChild(3).GetChild(2)).GetComponent<JumpVolume>();
						component31.jumpVelocity = new Vector3(-48.1144f, 43.5799f, 6.7542f);
						JumpVolume component32 = ((Component)val.transform.GetChild(0).GetChild(2).GetChild(0)
							.GetChild(2)).GetComponent<JumpVolume>();
						component32.jumpVelocity = new Vector3(-65f, 66f, -4.60673f);
						JumpVolume component33 = ((Component)val.transform.GetChild(0).GetChild(1).GetChild(2)
							.GetChild(2)).GetComponent<JumpVolume>();
						component33.jumpVelocity = new Vector3(-35f, 65f, -12f);
					}
					break;
				case 'v':
					if (sceneName == "voidstage")
					{
						Transform transform9 = GameObject.Find("HOLDER: Geysers").transform;
						JumpVolume component21 = ((Component)transform9.GetChild(2).GetChild(4).GetChild(0)).GetComponent<JumpVolume>();
						component21.jumpVelocity = new Vector3(-11.56456f, 35f, 60f);
						JumpVolume component22 = ((Component)transform9.GetChild(0).GetChild(4).GetChild(0)).GetComponent<JumpVolume>();
						component22.jumpVelocity = new Vector3(11.98292f, 15f, -60f);
						JumpVolume component23 = ((Component)transform9.GetChild(3).GetChild(4).GetChild(0)).GetComponent<JumpVolume>();
						component23.jumpVelocity = new Vector3(70f, 22f, 32.141f);
						JumpVolume component24 = ((Component)transform9.GetChild(1).GetChild(4).GetChild(0)).GetComponent<JumpVolume>();
						component24.jumpVelocity = new Vector3(-3.829206f, 85f, -50f);
						JumpVolume component25 = ((Component)transform9.GetChild(6).GetChild(4).GetChild(0)).GetComponent<JumpVolume>();
						component25.jumpVelocity = new Vector3(-12.05236f, 55f, -45f);
						JumpVolume component26 = ((Component)transform9.GetChild(5).GetChild(4).GetChild(0)).GetComponent<JumpVolume>();
						component26.jumpVelocity = new Vector3(-30f, 35f, -60f);
						JumpVolume component27 = ((Component)transform9.GetChild(4).GetChild(4).GetChild(0)).GetComponent<JumpVolume>();
						component27.jumpVelocity = new Vector3(19.65478f, 25f, 75f);
					}
					break;
				}
				break;
			case 13:
				switch (sceneName[0])
				{
				case 's':
					if (sceneName == "shipgraveyard")
					{
						Transform transform7 = GameObject.Find("HOLDER: Jump Pads").transform;
						JumpVolume component17 = ((Component)transform7.GetChild(0).GetChild(2)).GetComponent<JumpVolume>();
						component17.jumpVelocity = new Vector3(-11.1291f, 55.3482f, -40.5845f);
						JumpVolume component18 = ((Component)transform7.GetChild(1).GetChild(2)).GetComponent<JumpVolume>();
						component18.jumpVelocity = new Vector3(2.9656f, 45.0318f, 13.4763f);
					}
					break;
				case 'w':
					if (sceneName == "wispgraveyard")
					{
						Transform transform8 = GameObject.Find("ENTIRE SCENE HOLDER").transform;
						JumpVolume component19 = ((Component)transform8.GetChild(4).GetChild(2).GetChild(0)
							.GetChild(0)
							.GetChild(2)).GetComponent<JumpVolume>();
						component19.jumpVelocity = new Vector3(65.3068f, 46.1934f, -2.5635f);
						JumpVolume component20 = ((Component)transform8.GetChild(4).GetChild(3).GetChild(4)
							.GetChild(12)
							.GetChild(0)
							.GetChild(6)
							.GetChild(2)).GetComponent<JumpVolume>();
						component20.jumpVelocity = new Vector3(-65.2731f, 0.442f, 7.7863f);
					}
					break;
				case 'a':
					if (sceneName == "artifactworld")
					{
						Transform transform6 = GameObject.Find("HOLDER: Geysers").transform;
						JumpVolume component13 = ((Component)transform6.GetChild(3).GetChild(0)).GetComponent<JumpVolume>();
						component13.jumpVelocity = new Vector3(0f, 20f, -40f);
						JumpVolume component14 = ((Component)transform6.GetChild(4).GetChild(0)).GetComponent<JumpVolume>();
						component14.jumpVelocity = new Vector3(0f, 5f, 45f);
						JumpVolume component15 = ((Component)transform6.GetChild(2).GetChild(0)).GetComponent<JumpVolume>();
						component15.jumpVelocity = new Vector3(60f, 0f, 0f);
						JumpVolume component16 = ((Component)transform6.GetChild(1).GetChild(0)).GetComponent<JumpVolume>();
						component16.jumpVelocity = new Vector3(15f, 40f, -11f);
					}
					break;
				}
				break;
			case 14:
				if (sceneName == "dampcavesimple")
				{
					JumpVolume component6 = ((Component)GameObject.Find("HOLDER: Geyser").transform.GetChild(2).GetChild(2)).GetComponent<JumpVolume>();
					component6.jumpVelocity = new Vector3(45.2695f, 50.4077f, 35.7247f);
				}
				break;
			case 12:
				if (sceneName == "golemplains2")
				{
					Transform transform = GameObject.Find("HOLDER: Jump Pads").transform;
					JumpVolume component = ((Component)transform.GetChild(1).GetChild(2)).GetComponent<JumpVolume>();
					component.jumpVelocity = new Vector3(38.2099f, 64.9923f, -5.1331f);
					JumpVolume component2 = ((Component)transform.GetChild(0).GetChild(2)).GetComponent<JumpVolume>();
					component2.jumpVelocity = new Vector3(-13.4416f, 44.981f, 8.4832f);
				}
				break;
			}
		}

		private void JumpVolume_OnTriggerStay(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 1)
			}))
			{
				val.Index += 1;
				val.EmitDelegate<Func<int, int>>((Func<int, int>)((int useless) => 0));
			}
			else
			{
				BJPLogger.LogError((object)"Failed to apply Jump Pad hook");
			}
		}
	}
}