Decompiled source of AcidDrop v1.0.0

aciddrop.dll

Decompiled a month 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 HarmonyLib;
using MapStation.Common.Gameplay;
using MapStation.Plugin.Gameplay;
using Microsoft.CodeAnalysis;
using Reptile;
using UnityEngine;
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(".NETFramework,Version=v4.7.1", FrameworkDisplayName = ".NET Framework 4.7.1")]
[assembly: AssemblyCompany("aciddrop")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyDescription("Acid Drop for Bomb Rush Cyberfunk")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("aciddrop")]
[assembly: AssemblyTitle("aciddrop")]
[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 aciddrop
{
	[BepInPlugin("info.mariobluegloves.aciddrop2", "Acid Drop", "1.0.0")]
	[BepInProcess("Bomb Rush Cyberfunk.exe")]
	public class AcidDrop : BaseUnityPlugin
	{
		private static AcidDrop _instance;

		private bool sceneLoaded = false;

		private Player p;

		private bool canAcidDrop = true;

		public bool hasMapStationVerted = false;

		public bool mapStationVertingDown = false;

		public bool hasVerted = false;

		public bool vertingDown = false;

		public static AcidDrop Instance
		{
			get
			{
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Expected O, but got Unknown
				if ((Object)(object)_instance == (Object)null)
				{
					_instance = Object.FindObjectOfType<AcidDrop>();
					if ((Object)(object)_instance == (Object)null)
					{
						GameObject val = new GameObject("AcidDrop");
						_instance = val.AddComponent<AcidDrop>();
					}
				}
				return _instance;
			}
		}

		private void Awake()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			SceneManager.sceneLoaded += OnSceneLoaded;
			Harmony val = new Harmony("info.mariobluegloves.aciddrop2");
			val.PatchAll(typeof(GriTAPatchAD));
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			sceneLoaded = true;
		}

		private void Update()
		{
			if (!sceneLoaded)
			{
				return;
			}
			GameObject val = GameObject.Find("Player_HUMAN0");
			if (!((Object)(object)val != (Object)null))
			{
				return;
			}
			p = val.GetComponent<Player>();
			if (!((Object)(object)p != (Object)null))
			{
				return;
			}
			DropCheck();
			if (p.OnAnyGround())
			{
				StopMapstationVerting();
				StopVerting();
				if (!mapStationVertingDown && hasMapStationVerted)
				{
					p.userInputEnabled = true;
					hasMapStationVerted = false;
				}
				canAcidDrop = true;
			}
			else if (mapStationVertingDown && p.boostAbility != null)
			{
				((Ability)p.boostAbility).p.StopCurrentAbility();
			}
		}

		public void DropCheck()
		{
			if ((Object)(object)p != (Object)null && (p.slideButtonHeld || p.slideButtonNew) && (p.boostButtonHeld || (p.boostButtonNew && (Object)(object)p.grindAbility.nextNode == (Object)null)))
			{
				CheckObjectDirectlyUnderneathPlayer();
			}
		}

		private void CheckObjectDirectlyUnderneathPlayer()
		{
			//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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)p == (Object)null)
			{
				return;
			}
			Vector3 position = ((Component)p).transform.position;
			Vector3 down = Vector3.down;
			RaycastHit[] array = Physics.RaycastAll(position, down);
			Array.Sort(array, (RaycastHit a, RaycastHit b) => ((RaycastHit)(ref a)).distance.CompareTo(((RaycastHit)(ref b)).distance));
			bool flag = false;
			RaycastHit hit = default(RaycastHit);
			GameObject val = null;
			bool flag2 = false;
			RaycastHit[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				RaycastHit val2 = array2[i];
				GameObject gameObject = ((Component)((RaycastHit)(ref val2)).collider).gameObject;
				if ((Object)(object)gameObject.GetComponent<VertShape>() != (Object)null || (Object)(object)gameObject.GetComponent<MapStationVert>() != (Object)null)
				{
					if (!flag2)
					{
						hit = val2;
						val = gameObject;
						flag = true;
						break;
					}
				}
				else
				{
					flag2 = true;
				}
			}
			if (!flag || !((Object)(object)val != (Object)null))
			{
				return;
			}
			VertShape component = val.GetComponent<VertShape>();
			if ((Object)(object)component != (Object)null)
			{
				ProcessVertShape(val, hit);
				return;
			}
			MapStationVert component2 = val.GetComponent<MapStationVert>();
			if ((Object)(object)component2 != (Object)null)
			{
				ProcessMapStationVert(val, hit);
			}
		}

		private void ProcessVertShape(GameObject obj, RaycastHit hit)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: 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)
			//IL_0028: 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_0031: 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_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: 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_0045: 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)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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_00af: 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_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: 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_00cd: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: 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_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			VertShape component = obj.GetComponent<VertShape>();
			Vector3 bottomLeft = component.bottomLeft;
			Vector3 topLeft = component.topLeft;
			Vector3 topRight = component.topRight;
			Transform transform = ((Component)component).transform;
			Vector3 val = transform.TransformPoint(bottomLeft);
			Vector3 val2 = transform.TransformPoint(topLeft);
			Vector3 val3 = transform.TransformPoint(topRight);
			Vector3 val4 = val3 - val2;
			Vector3 normalized = ((Vector3)(ref val4)).normalized;
			if (!p.IsGrounded() && canAcidDrop)
			{
				p.ActivateAbility((Ability)(object)p.vertAbility);
				Vector3 val5 = ((Component)p).transform.position - val3;
				float num = Vector3.Dot(val5, normalized) / Vector3.Dot(normalized, normalized);
				Vector3 val6 = num * normalized;
				Vector3 val7 = val3 + val6;
				Vector3 position = default(Vector3);
				((Vector3)(ref position))..ctor(val7.x, ((Component)p).transform.position.y, val7.z);
				((Component)p).transform.position = position;
				Vector3 val8 = val - val2;
				Vector3 normalized2 = ((Vector3)(ref val8)).normalized;
				((Component)p).transform.rotation = Quaternion.LookRotation(normalized2, Vector3.up);
				((Component)p).transform.Translate(Vector3.forward * 0.5f, (Space)1);
				StartVerting();
				p.ringParticles.Emit(1);
				p.audioManager.PlayVoice(ref p.currentVoicePriority, p.character, (AudioClipID)489, p.playerGameplayVoicesAudioSource, (VoicePriority)0);
				p.DoTrick((TrickType)22, "Acid Drop", 0);
				float totalSpeed = p.GetTotalSpeed();
				Vector3 velocity = (0f - totalSpeed) * Vector3.up;
				Rigidbody component2 = ((Component)p).GetComponent<Rigidbody>();
				component2.velocity = velocity;
				canAcidDrop = false;
			}
		}

		private void ProcessMapStationVert(GameObject obj, RaycastHit hit)
		{
			//IL_0057: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: 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_0141: 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_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			if (p.IsGrounded() || !canAcidDrop)
			{
				return;
			}
			MapStationPlayer component = ((Component)p).GetComponent<MapStationPlayer>();
			MeshCollider component2 = obj.GetComponent<MeshCollider>();
			if (!((Object)(object)component2 == (Object)null))
			{
				Vector3 val = ((Collider)component2).ClosestPointOnBounds(((Component)p).transform.position);
				Vector3 val2 = ((Component)this).transform.TransformPoint(val);
				Vector3 normal = ((RaycastHit)(ref hit)).normal;
				float num = Vector3.Dot(normal, Vector3.up);
				if (num < Mathf.Cos((float)Math.PI / 4f))
				{
					Vector3 val3 = default(Vector3);
					((Vector3)(ref val3))..ctor(val2.x, ((Component)p).transform.position.y, val2.z);
					((Component)p).transform.position = val3;
					Vector3 normalized = ((Vector3)(ref normal)).normalized;
					normalized.y = 0f;
					Quaternion rotation = Quaternion.LookRotation(normalized, Vector3.up);
					p.SetRotation(rotation);
					Vector3 position = val3 + ((Vector3)(ref normal)).normalized * 0.6f;
					((Component)p).transform.position = position;
					component.GroundVertVector = normal;
					component.AirVertBegin();
					component.OnVertAir = true;
					StartMapstationVerting();
					p.ringParticles.Emit(1);
					p.audioManager.PlayVoice(ref p.currentVoicePriority, p.character, (AudioClipID)489, p.playerGameplayVoicesAudioSource, (VoicePriority)0);
					p.DoTrick((TrickType)22, "Acid Drop", 0);
					float totalSpeed = p.GetTotalSpeed();
					Vector3 velocity = (0f - totalSpeed) * Vector3.up;
					Rigidbody component3 = ((Component)p).GetComponent<Rigidbody>();
					component3.velocity = velocity;
					p.userInputEnabled = false;
					canAcidDrop = false;
				}
			}
		}

		private void StartMapstationVerting()
		{
			mapStationVertingDown = true;
			if (!hasMapStationVerted)
			{
				hasMapStationVerted = true;
			}
		}

		private void StopMapstationVerting()
		{
			mapStationVertingDown = false;
		}

		private void StartVerting()
		{
			vertingDown = true;
			if (!hasVerted)
			{
				hasVerted = true;
			}
		}

		private void StopVerting()
		{
			vertingDown = false;
		}
	}
	public class GriTAPatchAD
	{
		[HarmonyPatch(typeof(GrindAbility), "CanSetToLine")]
		[HarmonyPrefix]
		private static bool GriTAPatchPreFixAD(GrindLine line)
		{
			if (((Object)(object)AcidDrop.Instance != (Object)null && AcidDrop.Instance.vertingDown) || ((Object)(object)AcidDrop.Instance != (Object)null && AcidDrop.Instance.mapStationVertingDown))
			{
				return false;
			}
			return true;
		}
	}
	[BepInPlugin("info.mariobluegloves.aciddrop", "Acid Drop", "1.0.0")]
	[BepInProcess("Bomb Rush Cyberfunk.exe")]
	public class VertAbilityPatches : BaseUnityPlugin
	{
		private void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Drop it like it's hot");
		}
	}
}