Decompiled source of Antigravity Bubble v1.0.2

AntigravityBubbleMod.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BoplFixedMath;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("AntigravityBubbleMod")]
[assembly: AssemblyConfiguration("release")]
[assembly: AssemblyFileVersion("1.0.2.0")]
[assembly: AssemblyInformationalVersion("1.0.2")]
[assembly: AssemblyProduct("AntigravityBubbleMod")]
[assembly: AssemblyTitle("AntigravityBubbleMod")]
[assembly: AssemblyVersion("1.0.2.0")]
namespace AntigravityBubbleMod;

[BepInPlugin("com.owen.bopl.antigravbubble", "Antigravity Bubble Mod", "1.0.2")]
public class Plugin : BaseUnityPlugin
{
	private void Awake()
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		((BaseUnityPlugin)this).Logger.LogInfo((object)"Antigravity Bubble Mod loading...");
		new Harmony("com.owen.bopl.antigravbubble").PatchAll();
	}
}
public static class BubbleAntigravTracker
{
	public static bool NextIndicatorIsAntigrav = false;

	public static HashSet<int> AntigravIndicatorIds = new HashSet<int>();

	public static Dictionary<TeleportIndicator, HashSet<int>> BubblePlayers = new Dictionary<TeleportIndicator, HashSet<int>>();

	public static Dictionary<TeleportIndicator, HashSet<int>> BubbleObjects = new Dictionary<TeleportIndicator, HashSet<int>>();

	public static bool IsPlayerInAnyBubble(int playerId)
	{
		List<TeleportIndicator> list = new List<TeleportIndicator>();
		bool result = false;
		foreach (KeyValuePair<TeleportIndicator, HashSet<int>> bubblePlayer in BubblePlayers)
		{
			if ((Object)(object)bubblePlayer.Key == (Object)null || (Object)(object)((Component)bubblePlayer.Key).gameObject == (Object)null)
			{
				list.Add(bubblePlayer.Key);
			}
			else if (bubblePlayer.Value.Contains(playerId))
			{
				result = true;
			}
		}
		foreach (TeleportIndicator item in list)
		{
			BubblePlayers.Remove(item);
			BubbleObjects.Remove(item);
		}
		return result;
	}

	public static bool IsObjectInAnyBubble(int objectId)
	{
		List<TeleportIndicator> list = new List<TeleportIndicator>();
		bool result = false;
		foreach (KeyValuePair<TeleportIndicator, HashSet<int>> bubbleObject in BubbleObjects)
		{
			if ((Object)(object)bubbleObject.Key == (Object)null || (Object)(object)((Component)bubbleObject.Key).gameObject == (Object)null)
			{
				list.Add(bubbleObject.Key);
			}
			else if (bubbleObject.Value.Contains(objectId))
			{
				result = true;
			}
		}
		foreach (TeleportIndicator item in list)
		{
			BubblePlayers.Remove(item);
			BubbleObjects.Remove(item);
		}
		return result;
	}
}
[HarmonyPatch(typeof(AbilityGrid), "Awake")]
public class MenuInjectionPatch
{
	private static bool hasInjected;

	public static void Prefix(AbilityGrid __instance)
	{
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: 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_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		if (hasInjected)
		{
			return;
		}
		NamedSpriteList value = Traverse.Create((object)__instance).Field("abilityIcons").GetValue<NamedSpriteList>();
		if ((Object)(object)value == (Object)null || value.sprites == null)
		{
			return;
		}
		NamedSprite val = default(NamedSprite);
		bool flag = false;
		foreach (NamedSprite sprite in value.sprites)
		{
			if (sprite.name.ToLower().Contains("teleport"))
			{
				val = sprite;
				flag = true;
				break;
			}
		}
		if (flag)
		{
			GameObject val2 = Object.Instantiate<GameObject>(val.associatedGameObject);
			Object.DontDestroyOnLoad((Object)(object)val2);
			((Object)val2).name = "antigrav_bubble_spawner";
			NamedSprite item = default(NamedSprite);
			((NamedSprite)(ref item))..ctor("antigrav_bubble", CreatePurpleBubbleSprite(), val2, true);
			value.sprites.Add(item);
			hasInjected = true;
		}
	}

	private static Sprite CreatePurpleBubbleSprite()
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_0144: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: 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_00f6: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		int num = 256;
		int num2 = num / 2;
		Texture2D val = new Texture2D(num, num);
		Color[] array = (Color[])(object)new Color[num * num];
		Color val2 = default(Color);
		((Color)(ref val2))..ctor(0f, 0f, 0f, 0f);
		Color val3 = default(Color);
		((Color)(ref val3))..ctor(0.6f, 0.2f, 0.8f, 1f);
		Color val4 = default(Color);
		((Color)(ref val4))..ctor(0.4f, 0.1f, 0.6f, 0.5f);
		for (int i = 0; i < num; i++)
		{
			for (int j = 0; j < num; j++)
			{
				float num3 = (float)(j - num2) / 0.75f + (float)num2;
				float num4 = (float)(i - num2) / 0.75f + (float)num2;
				float num5 = Mathf.Sqrt((num3 - (float)num2) * (num3 - (float)num2) + (num4 - (float)num2) * (num4 - (float)num2));
				if (num5 > 120f)
				{
					array[i * num + j] = val2;
				}
				else if (num5 > 110f)
				{
					array[i * num + j] = val3;
				}
				else
				{
					array[i * num + j] = val4;
				}
			}
		}
		val.SetPixels(array);
		val.Apply();
		return Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f));
	}
}
[HarmonyPatch(typeof(Teleport), "CastAbility")]
public class TeleportCastAbilityPatch
{
	public static bool Prefix(Teleport __instance)
	{
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0144: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)((Component)__instance).gameObject).name.ToLower().Contains("antigrav_bubble"))
		{
			return true;
		}
		Traverse val = Traverse.Create((object)__instance);
		TeleportIndicator value = val.Field("teleportIndicator").GetValue<TeleportIndicator>();
		if ((Object)(object)value == (Object)null || ((MonoUpdatable)value).IsDestroyed)
		{
			BubbleAntigravTracker.NextIndicatorIsAntigrav = true;
			InstantAbility component = ((Component)__instance).GetComponent<InstantAbility>();
			FixTransform component2 = ((Component)__instance).GetComponent<FixTransform>();
			Fix scale = PlayerHandler.Get().GetPlayer(component.GetPlayerId()).Scale;
			AudioManager.Get().Play("swapIndicator");
			component.ignoreNextCooldown = true;
			TeleportIndicator val2 = FixTransform.InstantiateFixed<TeleportIndicator>(__instance.tpiPrefab, component2.position + Vec2.up * __instance.upCastOffset);
			val.Field("teleportIndicator").SetValue((object)val2);
			val2.SetParticleColor(component.GetPlayerMaterial().GetColor("_ShadowColor"));
			val2.SetScale(scale);
			val2.ownerId = component.GetPlayerId();
			ParticleSystem val3 = Object.Instantiate<ParticleSystem>(__instance.onSpawnIndicatorParticlePrefab, (Vector3)component2.position, Quaternion.identity);
			Color val4 = default(Color);
			((Color)(ref val4))..ctor(0.7f, 0.2f, 1f, 1f);
			ParticleSystem[] componentsInChildren = ((Component)val3).GetComponentsInChildren<ParticleSystem>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				MainModule main = componentsInChildren[i].main;
				((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(val4);
			}
			SpriteRenderer[] componentsInChildren2 = ((Component)val3).GetComponentsInChildren<SpriteRenderer>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				componentsInChildren2[i].color = val4;
			}
			portalIndicatorParticle component3 = ((Component)val3).GetComponent<portalIndicatorParticle>();
			if ((Object)(object)component3 != (Object)null)
			{
				component3.SetScale((float)scale);
			}
			return false;
		}
		return false;
	}
}
[HarmonyPatch(typeof(TeleportIndicator), "Awake")]
public class TeleportIndicatorAwakePatch
{
	public static void Postfix(TeleportIndicator __instance)
	{
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: 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_0071: Unknown result type (might be due to invalid IL or missing references)
		if (BubbleAntigravTracker.NextIndicatorIsAntigrav)
		{
			BubbleAntigravTracker.AntigravIndicatorIds.Add(((Object)__instance).GetInstanceID());
			BubbleAntigravTracker.NextIndicatorIsAntigrav = false;
			Color val = default(Color);
			((Color)(ref val))..ctor(0.7f, 0.2f, 1f, 1f);
			SpriteRenderer[] componentsInChildren = ((Component)__instance).GetComponentsInChildren<SpriteRenderer>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].color = val;
			}
			ParticleSystem[] componentsInChildren2 = ((Component)__instance).GetComponentsInChildren<ParticleSystem>(true);
			for (int i = 0; i < componentsInChildren2.Length; i++)
			{
				MainModule main = componentsInChildren2[i].main;
				((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(val);
			}
		}
	}
}
[HarmonyPatch(typeof(TeleportIndicator), "SetParticleColor")]
public class TeleportIndicatorColorPatch
{
	public static void Prefix(TeleportIndicator __instance, ref Color c)
	{
		//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)
		if (BubbleAntigravTracker.AntigravIndicatorIds.Contains(((Object)__instance).GetInstanceID()))
		{
			c = new Color(0.7f, 0.2f, 1f, 1f);
		}
	}
}
[HarmonyPatch(typeof(TeleportIndicator), "TeleportEveryoneLaterThisFrame")]
public class TeleportIndicatorNoTeleportPatch
{
	public static bool Prefix(TeleportIndicator __instance)
	{
		if (BubbleAntigravTracker.AntigravIndicatorIds.Contains(((Object)__instance).GetInstanceID()))
		{
			return false;
		}
		return true;
	}
}
[HarmonyPatch(typeof(TeleportIndicator), "UpdateSim")]
public class TeleportIndicatorUpdatePatch
{
	private static PhysicsParent[] hitBuffer = (PhysicsParent[])(object)new PhysicsParent[100];

	public static bool Prefix(TeleportIndicator __instance)
	{
		//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_002b: 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_0036: 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)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: 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_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_0185: Unknown result type (might be due to invalid IL or missing references)
		if (!BubbleAntigravTracker.AntigravIndicatorIds.Contains(((Object)__instance).GetInstanceID()))
		{
			return true;
		}
		Fix value = Traverse.Create((object)__instance).Field("scale").GetValue<Fix>();
		Fix val = __instance.teleportRadius * value;
		int num = DetPhysics.Get().CircleCastAll((Vec2)((Component)__instance).transform.position, val, __instance.teleportableThings, ref hitBuffer);
		if (!BubbleAntigravTracker.BubblePlayers.ContainsKey(__instance))
		{
			BubbleAntigravTracker.BubblePlayers[__instance] = new HashSet<int>();
		}
		if (!BubbleAntigravTracker.BubbleObjects.ContainsKey(__instance))
		{
			BubbleAntigravTracker.BubbleObjects[__instance] = new HashSet<int>();
		}
		BubbleAntigravTracker.BubblePlayers[__instance].Clear();
		BubbleAntigravTracker.BubbleObjects[__instance].Clear();
		for (int i = 0; i < num; i++)
		{
			PhysicsParent val2 = hitBuffer[i];
			if ((Object)(object)val2.fixTrans == (Object)null || val2.fixTrans.IsDestroyed)
			{
				continue;
			}
			GameObject gameObject = ((Component)val2.fixTrans).gameObject;
			if ((gameObject.layer == LayerMask.NameToLayer("wall") && !gameObject.CompareTag("boulder")) || gameObject.layer == LayerMask.NameToLayer("LethalTerrain"))
			{
				continue;
			}
			PlayerPhysics component = ((Component)val2.fixTrans).GetComponent<PlayerPhysics>();
			if ((Object)(object)component != (Object)null)
			{
				BubbleAntigravTracker.BubblePlayers[__instance].Add(((Object)component).GetInstanceID());
				continue;
			}
			BoplBody component2 = ((Component)val2.fixTrans).GetComponent<BoplBody>();
			if ((Object)(object)component2 != (Object)null && component2.StartingMass != Fix.Zero)
			{
				BubbleAntigravTracker.BubbleObjects[__instance].Add(((Object)((Component)component2).gameObject).GetInstanceID());
			}
		}
		return false;
	}
}
[HarmonyPatch(typeof(PlayerPhysics), "AddGravityFactor")]
[HarmonyPriority(600)]
public class EnforceBubbleAntigravPatch
{
	public static void Prefix(PlayerPhysics __instance)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//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)
		if (BubbleAntigravTracker.IsPlayerInAnyBubble(((Object)__instance).GetInstanceID()))
		{
			__instance.gravity_modifier *= (Fix)(-1L);
		}
	}

	public static void Postfix(PlayerPhysics __instance)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//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)
		if (BubbleAntigravTracker.IsPlayerInAnyBubble(((Object)__instance).GetInstanceID()))
		{
			__instance.gravity_modifier *= (Fix)(-1L);
		}
	}
}
[HarmonyPatch(typeof(PlayerPhysics), "Jump")]
[HarmonyPriority(600)]
public class BubbleJumpPatch
{
	public static void Prefix(PlayerPhysics __instance)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//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)
		if (BubbleAntigravTracker.IsPlayerInAnyBubble(((Object)__instance).GetInstanceID()))
		{
			__instance.gravity_modifier *= (Fix)(-1L);
		}
	}

	public static void Postfix(PlayerPhysics __instance)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//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)
		if (BubbleAntigravTracker.IsPlayerInAnyBubble(((Object)__instance).GetInstanceID()))
		{
			__instance.gravity_modifier *= (Fix)(-1L);
		}
	}
}
[HarmonyPatch(typeof(PlayerPhysics), "Jump")]
public class FixInvertedJumpPatch
{
	public static bool Prefix(PlayerPhysics __instance)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: 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_003f: 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_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: 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_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_005f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: 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_006f: 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_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: 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_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: 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)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: 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_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0112: 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_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		if (__instance.gravity_modifier >= Fix.Zero)
		{
			return true;
		}
		__instance.jumpedThisFrame = true;
		PlayerBody playerBody = __instance.GetPlayerBody();
		StickyRoundedRectangle attachedGround = __instance.getAttachedGround();
		Vec2 val = ((!__instance.IsGrounded()) ? Vec2.down : attachedGround.currentNormal(playerBody));
		Vec2 val2 = default(Vec2);
		((Vec2)(ref val2))..ctor(val.x, Fix.Zero);
		Vec2 down = Vec2.down;
		Fix val3 = (-val.y + Fix.One) / __instance.jumpNormalScaleFactor;
		val3 = Fix.Min(Fix.One, val3);
		val3 = Fix.Max(Fix.Zero, val3);
		down *= val3;
		down += val2 * __instance.jumpExtraXStrength;
		Vec2 val4 = new Vec2(val.y, -val.x) * __instance.groundedSpeed;
		playerBody.selfImposedVelocity = val4 * __instance.jumpKeptMomentum + down * __instance.jumpStrength;
		playerBody.position += playerBody.selfImposedVelocity * __instance.extraJumpTeleportMultiplier;
		((Component)__instance).transform.position = (Vector3)playerBody.position;
		__instance.UnGround(true, true);
		return false;
	}
}
[HarmonyPatch(typeof(PlayerPhysics), "AddGravityFactor")]
public class FixInvertedDragPatch
{
	public static bool Prefix(PlayerPhysics __instance)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: 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_0022: 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_002c: 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_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//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_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004a: 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_005a: 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_0066: 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_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: 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_0099: Unknown result type (might be due to invalid IL or missing references)
		if (__instance.gravity_modifier >= Fix.Zero)
		{
			return true;
		}
		PlayerBody playerBody = __instance.GetPlayerBody();
		Fix val = __instance.gravity_accel * __instance.gravity_modifier;
		playerBody.selfImposedVelocity += Vec2.down * val;
		Fix val2 = Fix.Abs(val) / __instance.gravity_maxFallSpeed;
		if (playerBody.selfImposedVelocity.y > Fix.Zero)
		{
			playerBody.selfImposedVelocity += Vec2.down * val2 * playerBody.selfImposedVelocity.y;
		}
		return false;
	}
}
[HarmonyPatch(typeof(BoplBody), "UpdateSim")]
public class BubbleBoplBodyPatch
{
	public static void Postfix(BoplBody __instance)
	{
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: 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_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cc: 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_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: 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)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		if (!BubbleAntigravTracker.IsObjectInAnyBubble(((Object)((Component)__instance).gameObject).GetInstanceID()))
		{
			return;
		}
		bool flag = false;
		Type type = Type.GetType("AntigravityMod.AntigravTracker, AntigravityMod");
		if (type != null)
		{
			FieldInfo field = type.GetField("FlippedObjects", BindingFlags.Static | BindingFlags.Public);
			if (field != null && field.GetValue(null) is HashSet<int> hashSet && hashSet.Contains(((Object)((Component)__instance).gameObject).GetInstanceID()))
			{
				flag = true;
			}
		}
		Fix val = (Constants.isSpaceLevel ? ((Fix)3.2f) : ((Fix)6.4f));
		if (flag)
		{
			val = -val;
		}
		__instance.velocity += new Vec2(Fix.Zero, val);
		if (__instance.velocity.y > (Fix)27f)
		{
			__instance.velocity = new Vec2(__instance.velocity.x, (Fix)27f);
		}
		else if (__instance.velocity.y < (Fix)(-27f))
		{
			__instance.velocity = new Vec2(__instance.velocity.x, (Fix)(-27f));
		}
	}
}