Decompiled source of RazzsEpicGamerMoments v0.9.3

RazzsEpicGamerMoments.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using InControl;
using Photon.Pun;
using RazzsEpicGamerMoments.Art;
using RazzsEpicGamerMoments.Cards;
using RazzsEpicGamerMoments.Challenges;
using RazzsEpicGamerMoments.Elements;
using TMPro;
using UnboundLib;
using UnboundLib.Cards;
using UnboundLib.GameModes;
using UnboundLib.Networking;
using UnboundLib.Utils;
using UnboundLib.Utils.UI;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace RazzsEpicGamerMoments
{
	internal static class Aim
	{
		private const float ControllerAimDistance = 10f;

		public static Vector2 CursorPoint(Player player)
		{
			//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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_003e: 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_0044: 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)
			CharacterData data = player.data;
			if ((data.playerActions == null || ((PlayerActionSet)data.playerActions).Device == null) && (Object)(object)MainCam.instance != (Object)null)
			{
				Vector3 val = MainCam.instance.cam.ScreenToWorldPoint(Input.mousePosition);
				return new Vector2(val.x, val.y);
			}
			Vector2 val2 = Vector2.op_Implicit(data.input.aimDirection);
			if (((Vector2)(ref val2)).sqrMagnitude < 0.01f)
			{
				val2 = Vector2.right;
			}
			return Vector2.op_Implicit(((Component)player).transform.position) + ((Vector2)(ref val2)).normalized * 10f;
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.razz.rounds.epicgamermoments", "Razz's Epic Gamer Moments", "0.9.3")]
	[BepInProcess("Rounds.exe")]
	public class EpicGamerPlugin : BaseUnityPlugin
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__6_0;

			public static Action<MomentsTracker> <>9__10_0;

			public static Action<ChallengeTracker> <>9__10_1;

			public static Action<MomentsTracker> <>9__11_0;

			public static Action<ChallengeTracker> <>9__11_1;

			internal void <Start>b__6_0()
			{
			}

			internal void <OnPointStart>b__10_0(MomentsTracker t)
			{
				t.OnPointStart();
			}

			internal void <OnPointStart>b__10_1(ChallengeTracker t)
			{
				t.OnPointStart();
			}

			internal void <OnPointEnd>b__11_0(MomentsTracker t)
			{
				t.OnPointEnd();
			}

			internal void <OnPointEnd>b__11_1(ChallengeTracker t)
			{
				t.OnPointEnd();
			}
		}

		public const string ModId = "com.razz.rounds.epicgamermoments";

		public const string ModName = "Razz's Epic Gamer Moments";

		public const string ModInitials = "RAZZ";

		public const string Version = "0.9.3";

		private static ManualLogSource logger;

		private void Awake()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			logger = ((BaseUnityPlugin)this).Logger;
			ChallengeState.Init(((BaseUnityPlugin)this).Config);
			new Harmony("com.razz.rounds.epicgamermoments").PatchAll();
			LobbyToggle.Init();
		}

		private void Start()
		{
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Expected O, but got Unknown
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: 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_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Expected O, but got Unknown
			CustomCard.BuildCard<ClutchCard>();
			CustomCard.BuildCard<LastBulletCard>();
			CustomCard.BuildCard<ParryGodCard>();
			CustomCard.BuildCard<HypeTrainCard>();
			CustomCard.BuildCard<MainCharacterCard>();
			CustomCard.BuildCard<LowDiffCard>();
			CustomCard.BuildCard<ComebackKidCard>();
			CustomCard.BuildCard<GravityCrushCard>();
			CustomCard.BuildCard<GravityWellCard>();
			CustomCard.BuildCard<FireRoundsCard>();
			CustomCard.BuildCard<FireTrailCard>();
			CustomCard.BuildCard<InfernoCard>();
			CustomCard.BuildCard<ArcRoundsCard>();
			CustomCard.BuildCard<StunRoundsCard>();
			CustomCard.BuildCard<ThunderstormCard>();
			CustomCard.BuildCard<FrostRoundsCard>();
			CustomCard.BuildCard<BrainFreezeCard>();
			CustomCard.BuildCard<PermafrostCard>();
			CustomCard.BuildCard<VenomRoundsCard>();
			CustomCard.BuildCard<CorrosionCard>();
			CustomCard.BuildCard<PandemicCard>();
			CustomCard.BuildCard<EventHorizonCard>();
			CustomCard.BuildCard<TectonicGripCard>();
			CustomCard.BuildCard<RaiseEarthCard>();
			CustomCard.BuildCard<BedrockCard>();
			CustomCard.BuildCard<SkywardCard>();
			CustomCard.BuildCard<GaleThrowCard>();
			CustomCard.BuildCard<JetStreamCard>();
			CustomCard.BuildCard<UnmakeCard>();
			CustomCard.BuildCard<PhaseRoundsCard>();
			CustomCard.BuildCard<OblivionCard>();
			CustomCard.BuildCard<CombustionCard>();
			CustomCard.BuildCard<ShatterCard>();
			CustomCard.BuildCard<ContagionCard>();
			CustomCard.BuildCard<StoneSkinCard>();
			CustomCard.BuildCard<UpdraftCard>();
			CustomCard.BuildCard<HollowCard>();
			ChallengeRewards.Register();
			Unbound.RegisterCredits("Razz's Epic Gamer Moments", new string[1] { "Razz" }, new string[0], new string[0]);
			object obj = <>c.<>9__6_0;
			if (obj == null)
			{
				UnityAction val = delegate
				{
				};
				<>c.<>9__6_0 = val;
				obj = (object)val;
			}
			Unbound.RegisterMenu("Razz's Epic Gamer Moments", (UnityAction)obj, (Action<GameObject>)ChallengeState.BuildMenu, (GameObject)null, true);
			Unbound.RegisterHandshake("com.razz.rounds.epicgamermoments", (Action)ChallengeState.Push);
			GameModeManager.AddHook("GameStart", (Func<IGameModeHandler, IEnumerator>)OnGameStart);
			GameModeManager.AddHook("PointStart", (Func<IGameModeHandler, IEnumerator>)OnPointStart);
			GameModeManager.AddHook("PointEnd", (Func<IGameModeHandler, IEnumerator>)OnPointEnd);
			GameModeManager.AddHook("PickStart", (Func<IGameModeHandler, IEnumerator>)OnPickStart);
			GameModeManager.AddHook("PickEnd", (Func<IGameModeHandler, IEnumerator>)OnPickEnd);
			GameObject val2 = new GameObject("EpicGamerAnnouncer");
			Object.DontDestroyOnLoad((Object)val2);
			val2.AddComponent<MomentBanner>();
			val2.AddComponent<ChallengeHud>();
			val2.AddComponent<LobbyToggle>();
			((MonoBehaviour)this).StartCoroutine(TagCardsOnceLoaded());
		}

		private IEnumerator TagCardsOnceLoaded()
		{
			yield return (object)new WaitForSecondsRealtime(3f);
			ElementTags.TagAll();
			yield return (object)new WaitForSecondsRealtime(10f);
			ElementTags.TagAll();
		}

		internal static void Log(string msg)
		{
			if (logger != null)
			{
				logger.LogInfo((object)msg);
			}
		}

		private static IEnumerator OnGameStart(IGameModeHandler gm)
		{
			MomentsTracker.ResetAllForNewGame();
			MomentBanner.Clear();
			ChallengeHud.Clear();
			ChallengeState.LockInForGame();
			ChallengeRewards.ResetForGame();
			ChallengeTracker.SetupForGame();
			ElementTags.TagAll();
			yield break;
		}

		private static IEnumerator OnPointStart(IGameModeHandler gm)
		{
			MomentsTracker.ForEach(delegate(MomentsTracker t)
			{
				t.OnPointStart();
			});
			ChallengeTracker.EnsureLocal();
			ChallengeTracker.ForEach(delegate(ChallengeTracker t)
			{
				t.OnPointStart();
			});
			yield break;
		}

		private static IEnumerator OnPointEnd(IGameModeHandler gm)
		{
			MomentsTracker.ForEach(delegate(MomentsTracker t)
			{
				t.OnPointEnd();
			});
			ChallengeTracker.ForEach(delegate(ChallengeTracker t)
			{
				t.OnPointEnd();
			});
			GravityPin.ClearAll();
			ElementHits.ResetForPoint();
			yield break;
		}

		private static IEnumerator OnPickStart(IGameModeHandler gm)
		{
			ChallengeTracker.EnsureLocal();
			ChallengeHud.PickPhase = true;
			ElementTags.TagAll();
			yield break;
		}

		private static IEnumerator OnPickEnd(IGameModeHandler gm)
		{
			ChallengeHud.PickPhase = false;
			yield break;
		}
	}
	[HarmonyPatch(typeof(PlayerManager), "PlayerDied")]
	internal static class PlayerDiedPatch
	{
		private static void Postfix(Player player)
		{
			MomentsTracker.HandleDeath(player);
			ChallengeTracker.HandleDeath(player);
			ElementDeaths.Handle(player);
		}
	}
	public static class GravityCrush
	{
		public const float WarningSeconds = 0.5f;

		public const float PullSeconds = 0.25f;

		public const float BaseRadius = 5f;

		public const float RadiusPerExtraStack = 2f;

		public const float BaseDamage = 10f;

		public const float DamagePerUnitPulled = 2.5f;

		public const float MaxDamage = 50f;

		public const float ParryWindow = 0.6f;

		private const float ControllerAimDistance = 10f;

		public static float RadiusFor(int stacks)
		{
			return 5f + 2f * (float)Mathf.Max(0, stacks - 1);
		}

		public static void Cast(Player caster, int stacks)
		{
			//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_002c: 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)
			Vector2 val = Aim.CursorPoint(caster);
			NetworkingManager.RPC(typeof(GravityCrush), "RPC_Crush", new object[4]
			{
				caster.playerID,
				val.x,
				val.y,
				RadiusFor(stacks) * ChallengeRewards.GravityZoneMultiplier(caster) * ElementRegistry.Power(caster, Element.Gravity)
			});
		}

		[UnboundRPC]
		public static void RPC_Crush(int casterId, float x, float y, float radius)
		{
			//IL_004f: 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)
			Player val = null;
			foreach (Player player in PlayerManager.instance.players)
			{
				if (player.playerID == casterId)
				{
					val = player;
				}
			}
			if (!((Object)(object)val == (Object)null))
			{
				new GameObject("GravityCrushZone").AddComponent<GravityCrushZone>().Begin(val, new Vector2(x, y), radius);
			}
		}
	}
	internal class GravityCrushZone : MonoBehaviour
	{
		private const int Segments = 48;

		private static readonly FieldRef<PlayerVelocity, Vector2> PlayerVelocityField = AccessTools.FieldRefAccess<PlayerVelocity, Vector2>("velocity");

		private Player caster;

		private Vector2 center;

		private float radius;

		private LineRenderer ring;

		public void Begin(Player caster, Vector2 center, float radius)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: 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_001c: 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_0076: Expected O, but got Unknown
			this.caster = caster;
			this.center = center;
			this.radius = radius;
			((Component)this).transform.position = Vector2.op_Implicit(center);
			ring = ((Component)this).gameObject.AddComponent<LineRenderer>();
			ring.useWorldSpace = true;
			ring.loop = true;
			ring.positionCount = 48;
			((Renderer)ring).material = new Material(Shader.Find("Sprites/Default"));
			((Renderer)ring).sortingOrder = 100;
			((MonoBehaviour)this).StartCoroutine(Run());
		}

		private IEnumerator Run()
		{
			float t = 0f;
			while (t < 0.5f)
			{
				float num = 0.5f + 0.5f * Mathf.Sin(t * 40f);
				DrawRing(radius, new Color(0.7f, 0.3f, 1f, 0.4f + 0.5f * num), 0.15f + 0.1f * num);
				t += Time.deltaTime;
				yield return null;
			}
			List<Player> victims = new List<Player>();
			foreach (Player player in PlayerManager.instance.players)
			{
				if (!((Object)(object)player == (Object)(object)caster) && player.teamID != caster.teamID && !player.data.dead && !(Vector2.Distance(Vector2.op_Implicit(((Component)player).transform.position), center) > radius))
				{
					if (player.data.block.sinceBlock < 0.6f)
					{
						MomentBanner.Show("PARRIED!", player, new Color(0.4f, 0.9f, 1f));
					}
					else
					{
						victims.Add(player);
					}
				}
			}
			Dictionary<Player, float> startDistance = new Dictionary<Player, float>();
			foreach (Player item in victims)
			{
				startDistance[item] = Vector2.Distance(Vector2.op_Implicit(((Component)item).transform.position), center);
			}
			List<Rigidbody2D> objects = LooseObjectsInZone();
			t = 0f;
			while (t < 0.25f)
			{
				float num2 = Mathf.Max(0.05f, 0.25f - t);
				DrawRing(Mathf.Lerp(radius, 0.3f, t / 0.25f), new Color(1f, 0.3f, 0.9f, 1f), 0.3f);
				foreach (Player item2 in victims)
				{
					if (!((Object)(object)item2 == (Object)null) && !item2.data.dead && item2.data.view.IsMine)
					{
						PlayerVelocityField.Invoke(item2.data.playerVel) = (center - Vector2.op_Implicit(((Component)item2).transform.position)) / num2;
					}
				}
				foreach (Rigidbody2D item3 in objects)
				{
					if (!((Object)(object)item3 == (Object)null))
					{
						item3.velocity = (center - item3.position) / num2;
					}
				}
				t += Time.deltaTime;
				yield return null;
			}
			foreach (Player item4 in victims)
			{
				if (!((Object)(object)item4 == (Object)null) && !item4.data.dead && item4.data.view.IsMine)
				{
					PlayerVelocityField.Invoke(item4.data.playerVel) = Vector2.zero;
					float num3 = ElementRegistry.Power(caster, Element.Gravity);
					float num4 = Mathf.Min(50f, 10f + 2.5f * startDistance[item4]) * num3;
					((Damagable)item4.data.healthHandler).CallTakeDamage(Vector2.up * num4, center, (GameObject)null, caster, true);
				}
			}
			if (victims.Count >= 2)
			{
				ChallengeTracker.Report(caster, ChallengeId.CrowdControl);
			}
			if (victims.Count >= 2)
			{
				MomentBanner.Show("GRAVITY CRUSH x" + victims.Count, caster, new Color(0.7f, 0.3f, 1f));
			}
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

		private List<Rigidbody2D> LooseObjectsInZone()
		{
			//IL_0007: 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)
			List<Rigidbody2D> list = new List<Rigidbody2D>();
			Collider2D[] array = Physics2D.OverlapCircleAll(center, radius);
			for (int i = 0; i < array.Length; i++)
			{
				Rigidbody2D attachedRigidbody = array[i].attachedRigidbody;
				if (!((Object)(object)attachedRigidbody == (Object)null) && (int)attachedRigidbody.bodyType == 0 && !list.Contains(attachedRigidbody) && !((Object)(object)((Component)attachedRigidbody).GetComponentInParent<Player>() != (Object)null) && (!((Object)(object)((Component)attachedRigidbody).GetComponent<NetworkPhysicsObject>() != (Object)null) || PhotonNetwork.IsMasterClient))
				{
					list.Add(attachedRigidbody);
				}
			}
			return list;
		}

		private void DrawRing(float r, Color color, float width)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: 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_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			LineRenderer obj = ring;
			Color startColor = (ring.endColor = color);
			obj.startColor = startColor;
			LineRenderer obj2 = ring;
			float startWidth = (ring.endWidth = width);
			obj2.startWidth = startWidth;
			for (int i = 0; i < 48; i++)
			{
				float num2 = (float)i * (float)Math.PI * 2f / 48f;
				ring.SetPosition(i, new Vector3(center.x + Mathf.Cos(num2) * r, center.y + Mathf.Sin(num2) * r, 0f));
			}
		}
	}
	public static class GravityWell
	{
		public const float BaseRadius = 5f;

		public const float RadiusPerExtraStack = 2f;

		public const float BaseSeconds = 3f;

		public const float SecondsPerExtraStack = 1f;

		public const float SlamDamage = 25f;

		public const float SlowFraction = 0.5f;

		public const float DownSpeed = 30f;

		public static void Cast(Player caster, int stacks)
		{
			//IL_000b: 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_0036: 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)
			int num = Mathf.Max(0, stacks - 1);
			Vector2 val = Aim.CursorPoint(caster);
			NetworkingManager.RPC(typeof(GravityWell), "RPC_Well", new object[5]
			{
				caster.playerID,
				val.x,
				val.y,
				(5f + 2f * (float)num) * ChallengeRewards.GravityZoneMultiplier(caster) * Power(caster),
				(3f + 1f * (float)num) * Power(caster)
			});
		}

		public static float Power(Player caster)
		{
			return ElementRegistry.Power(caster, Element.Gravity);
		}

		[UnboundRPC]
		public static void RPC_Well(int casterId, float x, float y, float radius, float seconds)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			Player val = null;
			foreach (Player player in PlayerManager.instance.players)
			{
				if (player.playerID == casterId)
				{
					val = player;
				}
			}
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(x, y);
			new GameObject("GravityWellZone").AddComponent<GravityWellFlash>().Begin(val2, radius);
			int num = 0;
			foreach (Player player2 in PlayerManager.instance.players)
			{
				if (!((Object)(object)player2 == (Object)(object)val) && player2.teamID != val.teamID && !player2.data.dead && !(Vector2.Distance(Vector2.op_Implicit(((Component)player2).transform.position), val2) > radius))
				{
					GravityPin.Apply(player2, val, seconds);
					num++;
				}
			}
			if (num >= 2)
			{
				ChallengeTracker.Report(val, ChallengeId.CrowdControl);
			}
		}
	}
	public class GravityPin : MonoBehaviour
	{
		private static readonly FieldRef<PlayerVelocity, Vector2> Velocity = AccessTools.FieldRefAccess<PlayerVelocity, Vector2>("velocity");

		private Player player;

		private Player caster;

		private float endsAt;

		private bool slamPending;

		private float moveDelta;

		private LineRenderer ring;

		public static bool IsPinned(CharacterData data)
		{
			if ((Object)(object)data != (Object)null)
			{
				return (Object)(object)((Component)data).GetComponent<GravityPin>() != (Object)null;
			}
			return false;
		}

		public static void Apply(Player target, Player caster, float seconds)
		{
			GravityPin gravityPin = ((Component)target).GetComponent<GravityPin>();
			if ((Object)(object)gravityPin == (Object)null)
			{
				gravityPin = ((Component)target).gameObject.AddComponent<GravityPin>();
				gravityPin.player = target;
				gravityPin.moveDelta = target.data.stats.movementSpeed * Mathf.Min(0.85f, 0.5f * GravityWell.Power(caster));
				CharacterStatModifiers stats = target.data.stats;
				stats.movementSpeed -= gravityPin.moveDelta;
				gravityPin.BuildRing();
			}
			gravityPin.caster = caster;
			gravityPin.endsAt = Mathf.Max(gravityPin.endsAt, Time.time + seconds);
			if (!target.data.isGrounded)
			{
				gravityPin.slamPending = true;
			}
		}

		public static void ClearAll()
		{
			GravityPin[] array = Object.FindObjectsOfType<GravityPin>();
			for (int i = 0; i < array.Length; i++)
			{
				Object.Destroy((Object)(object)array[i]);
			}
		}

		private void Update()
		{
			//IL_0045: 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_0065: 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_0087: 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_0119: 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_00c8: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			CharacterData data = player.data;
			if (data.dead || Time.time >= endsAt)
			{
				Object.Destroy((Object)(object)this);
				return;
			}
			if (data.view.IsMine)
			{
				Vector2 val = Velocity.Invoke(data.playerVel);
				float num = 30f * GravityWell.Power(caster);
				if (!data.isGrounded && val.y > 0f - num)
				{
					Velocity.Invoke(data.playerVel) = new Vector2(val.x, 0f - num);
				}
			}
			if (slamPending && data.isGrounded)
			{
				slamPending = false;
				if (data.view.IsMine)
				{
					((Damagable)data.healthHandler).CallTakeDamage(Vector2.down * 25f * GravityWell.Power(caster), Vector2.op_Implicit(((Component)player).transform.position), (GameObject)null, caster, true);
				}
				MomentBanner.Show("SLAMMED!", player, new Color(0.7f, 0.3f, 1f));
			}
			DrawRing();
		}

		private void OnDestroy()
		{
			if ((Object)(object)player != (Object)null)
			{
				CharacterStatModifiers stats = player.data.stats;
				stats.movementSpeed += moveDelta;
			}
			if ((Object)(object)ring != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)ring).gameObject);
			}
		}

		private void BuildRing()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Expected O, but got Unknown
			GameObject val = new GameObject("GravityPinRing");
			ring = val.AddComponent<LineRenderer>();
			ring.useWorldSpace = true;
			ring.positionCount = 32;
			ring.loop = true;
			((Renderer)ring).material = new Material(Shader.Find("Sprites/Default"));
			((Renderer)ring).sortingOrder = 100;
		}

		private void DrawRing()
		{
			//IL_000b: 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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = ((Component)player).transform.position + Vector3.up * 1.6f;
			float num = 0.5f + 0.5f * Mathf.Sin(Time.time * 18f);
			LineRenderer obj = ring;
			LineRenderer obj2 = ring;
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(0.75f, 0.3f, 1f, 0.6f + 0.4f * num);
			obj2.endColor = val2;
			obj.startColor = val2;
			LineRenderer obj3 = ring;
			float startWidth = (ring.endWidth = 0.12f);
			obj3.startWidth = startWidth;
			for (int i = 0; i < 32; i++)
			{
				float num3 = (float)i * (float)Math.PI * 2f / 32f;
				ring.SetPosition(i, val + new Vector3(Mathf.Cos(num3) * 1.2f, Mathf.Sin(num3) * 0.35f, 0f));
			}
		}
	}
	[HarmonyPatch(typeof(PlayerJump), "Jump")]
	internal static class PinnedJumpPatch
	{
		private static bool Prefix(PlayerJump __instance)
		{
			return (Object)(object)((Component)__instance).GetComponent<GravityPin>() == (Object)null;
		}
	}
	internal class GravityWellFlash : MonoBehaviour
	{
		private const float Seconds = 0.45f;

		private const int Streaks = 10;

		public void Begin(Vector2 center, float radius)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			((MonoBehaviour)this).StartCoroutine(Run(center, radius));
		}

		private IEnumerator Run(Vector2 center, float radius)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			Material mat = new Material(Shader.Find("Sprites/Default"));
			List<LineRenderer> streaks = new List<LineRenderer>();
			float[] offsets = new float[10];
			for (int i = 0; i < 10; i++)
			{
				streaks.Add(Line("Streak" + i, mat, 2, loop: false));
				offsets[i] = Random.Range(0f, 0.35f);
			}
			float t = 0f;
			Color endColor = default(Color);
			while (t < 0.45f)
			{
				float num = t / 0.45f;
				float num2 = 1f - num;
				((Color)(ref endColor))..ctor(0.75f, 0.3f, 1f, num2);
				for (int j = 0; j < 10; j++)
				{
					float num3 = center.x + Mathf.Lerp((0f - radius) * 0.9f, radius * 0.9f, (float)j / 9f);
					float num4 = center.y + radius * (1f + offsets[j]) - num * radius * 2.2f;
					streaks[j].startColor = new Color(1f, 0.5f, 1f, 0f);
					streaks[j].endColor = endColor;
					LineRenderer obj = streaks[j];
					float startWidth = (streaks[j].endWidth = 0.18f);
					obj.startWidth = startWidth;
					streaks[j].SetPosition(0, new Vector3(num3, num4 + 3f, 0f));
					streaks[j].SetPosition(1, new Vector3(num3, num4, 0f));
				}
				t += Time.deltaTime;
				yield return null;
			}
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

		private LineRenderer Line(string name, Material mat, int points, bool loop)
		{
			//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)
			GameObject val = new GameObject(name);
			val.transform.SetParent(((Component)this).transform, false);
			LineRenderer obj = val.AddComponent<LineRenderer>();
			obj.useWorldSpace = true;
			obj.loop = loop;
			obj.positionCount = points;
			((Renderer)obj).material = mat;
			((Renderer)obj).sortingOrder = 100;
			return obj;
		}
	}
	public enum Moment
	{
		Clutch,
		LastBullet,
		ParryGod,
		HypeTrain,
		MainCharacter,
		LowDiff,
		ComebackKid,
		GravityCrush,
		GravityWell
	}
	internal class MomentBanner : MonoBehaviour
	{
		private struct Entry
		{
			public string Title;

			public string Sub;

			public Color Color;
		}

		private const float ShowSeconds = 1.8f;

		private const int MaxQueued = 4;

		private static readonly Queue<Entry> queue = new Queue<Entry>();

		private static Entry? current;

		private static float shownAt;

		private GUIStyle titleStyle;

		private GUIStyle subStyle;

		public static void Show(string title, Player who, Color color)
		{
			//IL_0058: 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)
			if (queue.Count < 4)
			{
				string text = (((Object)(object)who != (Object)null) ? ("PLAYER " + (who.playerID + 1)) : "");
				queue.Enqueue(new Entry
				{
					Title = title,
					Sub = text,
					Color = color
				});
				EpicGamerPlugin.Log("Moment: " + title + " " + text);
			}
		}

		public static void Clear()
		{
			queue.Clear();
			current = null;
		}

		private void Update()
		{
			if (current.HasValue && Time.unscaledTime - shownAt > 1.8f)
			{
				current = null;
			}
			if (!current.HasValue && queue.Count > 0)
			{
				current = queue.Dequeue();
				shownAt = Time.unscaledTime;
			}
		}

		private void OnGUI()
		{
			//IL_0102: 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_0118: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: 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)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			if (current.HasValue)
			{
				EnsureStyles();
				Entry value = current.Value;
				float num = Time.unscaledTime - shownAt;
				float num2 = ((num < 0.15f) ? Mathf.Lerp(0.4f, 1.15f, num / 0.15f) : ((num < 0.25f) ? Mathf.Lerp(1.15f, 1f, (num - 0.15f) / 0.1f) : 1f));
				float num3 = ((num > 1.5f) ? Mathf.Clamp01((1.8f - num) / 0.3f) : 1f);
				int num4 = Mathf.Max(32, Screen.height / 12);
				titleStyle.fontSize = Mathf.RoundToInt((float)num4 * num2);
				subStyle.fontSize = Mathf.Max(16, num4 / 3);
				float num5 = (float)Screen.height * 0.12f;
				Color textColor = default(Color);
				((Color)(ref textColor))..ctor(0f, 0f, 0f, 0.8f * num3);
				Color textColor2 = default(Color);
				((Color)(ref textColor2))..ctor(value.Color.r, value.Color.g, value.Color.b, num3);
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(0f, num5, (float)Screen.width, (float)num4 * 1.6f);
				titleStyle.normal.textColor = textColor;
				GUI.Label(new Rect(((Rect)(ref val)).x + 4f, ((Rect)(ref val)).y + 4f, ((Rect)(ref val)).width, ((Rect)(ref val)).height), value.Title, titleStyle);
				titleStyle.normal.textColor = textColor2;
				GUI.Label(val, value.Title, titleStyle);
				if (!string.IsNullOrEmpty(value.Sub))
				{
					subStyle.normal.textColor = new Color(1f, 1f, 1f, num3);
					GUI.Label(new Rect(0f, num5 + (float)num4 * 1.5f, (float)Screen.width, (float)num4 * 0.6f), value.Sub, subStyle);
				}
			}
		}

		private void EnsureStyles()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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)
			//IL_002c: Expected O, but got Unknown
			//IL_0037: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Expected O, but got Unknown
			if (titleStyle == null)
			{
				titleStyle = new GUIStyle(GUI.skin.label)
				{
					alignment = (TextAnchor)4,
					fontStyle = (FontStyle)1
				};
				subStyle = new GUIStyle(GUI.skin.label)
				{
					alignment = (TextAnchor)4,
					fontStyle = (FontStyle)1
				};
			}
		}
	}
	public class MomentsTracker : MonoBehaviour
	{
		private class Buff
		{
			public float Damage;

			public float AttackSpeed;

			public float Move;

			public float ExpiresAt;
		}

		private const float ClutchHealthFraction = 0.25f;

		private const float ClutchAttackSpeedBonus = 0.5f;

		private const float ClutchBuffSeconds = 4f;

		private const float LastBulletDamageBonus = 0.75f;

		private const float ParryDamageBonus = 1f;

		private const float ParryBuffSeconds = 2f;

		private const float HypeBonusPerStack = 0.1f;

		private const int HypeMaxStacks = 5;

		private const float MainCharDamageBonus = 0.5f;

		private const float MainCharMoveBonus = 0.3f;

		private const float LowDiffDamagePerStack = 0.05f;

		private const int LowDiffMaxStacks = 10;

		private const float ComebackDamagePerLoss = 0.15f;

		private const float ComebackMovePerLoss = 0.1f;

		private const int ComebackMaxLosses = 3;

		private static readonly FieldRef<GunAmmo, int> CurrentAmmo = AccessTools.FieldRefAccess<GunAmmo, int>("currentAmmo");

		private static readonly List<MomentsTracker> all = new List<MomentsTracker>();

		private Player player;

		private CharacterData data;

		private Gun gun;

		private GunAmmo gunAmmo;

		private Block block;

		private CharacterStatModifiers stats;

		private readonly Dictionary<Moment, int> copies = new Dictionary<Moment, int>();

		private readonly List<Buff> buffs = new List<Buff>();

		private Buff lastBulletBuff;

		private bool diedThisPoint;

		private bool tookDamageThisPoint;

		private bool mainCharacterFired;

		private int hypeStacks;

		private int lowDiffStacks;

		private int lossStreak;

		private float lastParryBanner = -10f;

		private float lastParryRefund = -10f;

		private const float ParryRefundCooldown = 3f;

		public static MomentsTracker For(Player player)
		{
			MomentsTracker momentsTracker = ((Component)player).GetComponent<MomentsTracker>();
			if ((Object)(object)momentsTracker == (Object)null)
			{
				momentsTracker = ((Component)player).gameObject.AddComponent<MomentsTracker>();
				momentsTracker.Init(player);
			}
			return momentsTracker;
		}

		public static void ForEach(Action<MomentsTracker> action)
		{
			foreach (MomentsTracker item in all.ToList())
			{
				if ((Object)(object)item != (Object)null)
				{
					action(item);
				}
			}
		}

		public static void ResetAllForNewGame()
		{
			ForEach(delegate(MomentsTracker t)
			{
				t.buffs.Clear();
				t.lastBulletBuff = null;
				t.lowDiffStacks = 0;
				t.lossStreak = 0;
				t.hypeStacks = 0;
			});
		}

		private void Init(Player p)
		{
			player = p;
			data = p.data;
			gun = data.weaponHandler.gun;
			gunAmmo = ((Component)gun).GetComponentInChildren<GunAmmo>();
			block = data.block;
			stats = data.stats;
			all.Add(this);
			Subscribe();
		}

		private void Subscribe()
		{
			CharacterStatModifiers obj = stats;
			obj.WasDealtDamageAction = (Action<Vector2, bool>)Delegate.Remove(obj.WasDealtDamageAction, new Action<Vector2, bool>(OnDamaged));
			CharacterStatModifiers obj2 = stats;
			obj2.WasDealtDamageAction = (Action<Vector2, bool>)Delegate.Combine(obj2.WasDealtDamageAction, new Action<Vector2, bool>(OnDamaged));
			Block obj3 = block;
			obj3.BlockProjectileAction = (Action<GameObject, Vector3, Vector3>)Delegate.Remove(obj3.BlockProjectileAction, new Action<GameObject, Vector3, Vector3>(OnBlockedProjectile));
			Block obj4 = block;
			obj4.BlockProjectileAction = (Action<GameObject, Vector3, Vector3>)Delegate.Combine(obj4.BlockProjectileAction, new Action<GameObject, Vector3, Vector3>(OnBlockedProjectile));
			Block obj5 = block;
			obj5.BlockAction = (Action<BlockTriggerType>)Delegate.Remove(obj5.BlockAction, new Action<BlockTriggerType>(OnBlock));
			Block obj6 = block;
			obj6.BlockAction = (Action<BlockTriggerType>)Delegate.Combine(obj6.BlockAction, new Action<BlockTriggerType>(OnBlock));
		}

		private void OnDestroy()
		{
			all.Remove(this);
			if ((Object)(object)stats != (Object)null)
			{
				CharacterStatModifiers obj = stats;
				obj.WasDealtDamageAction = (Action<Vector2, bool>)Delegate.Remove(obj.WasDealtDamageAction, new Action<Vector2, bool>(OnDamaged));
			}
			if ((Object)(object)block != (Object)null)
			{
				Block obj2 = block;
				obj2.BlockProjectileAction = (Action<GameObject, Vector3, Vector3>)Delegate.Remove(obj2.BlockProjectileAction, new Action<GameObject, Vector3, Vector3>(OnBlockedProjectile));
				Block obj3 = block;
				obj3.BlockAction = (Action<BlockTriggerType>)Delegate.Remove(obj3.BlockAction, new Action<BlockTriggerType>(OnBlock));
			}
			RevertAll();
		}

		public void AddCard(Moment m)
		{
			copies[m] = Copies(m) + 1;
		}

		public void RemoveCard(Moment m)
		{
			copies[m] = Math.Max(0, Copies(m) - 1);
		}

		private int Copies(Moment m)
		{
			if (!copies.TryGetValue(m, out var value))
			{
				return 0;
			}
			return value;
		}

		public void OnPointStart()
		{
			RevertAll();
			Subscribe();
			diedThisPoint = false;
			tookDamageThisPoint = false;
			mainCharacterFired = false;
			hypeStacks = 0;
			if (lowDiffStacks > 0)
			{
				AddBuff(0.05f * (float)lowDiffStacks, 0f, 0f, float.PositiveInfinity);
			}
			int num = Copies(Moment.ComebackKid);
			if (num > 0 && lossStreak > 0)
			{
				int num2 = Math.Min(lossStreak, 3);
				AddBuff(0.15f * (float)num2 * (float)num, 0f, 0.1f * (float)num2 * (float)num, float.PositiveInfinity);
			}
		}

		public void OnPointEnd()
		{
			//IL_0061: 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)
			bool flag = !diedThisPoint && !data.dead;
			int num = Copies(Moment.LowDiff);
			if (num > 0 && flag && !tookDamageThisPoint)
			{
				lowDiffStacks = Math.Min(10, lowDiffStacks + num);
				MomentBanner.Show("LOW DIFF", player, new Color(0.75f, 0.45f, 1f));
			}
			if (flag)
			{
				if (lossStreak >= 2 && Copies(Moment.ComebackKid) > 0)
				{
					MomentBanner.Show("COMEBACK!", player, new Color(0.35f, 0.7f, 1f));
				}
				lossStreak = 0;
			}
			else
			{
				lossStreak++;
			}
			RevertAll();
		}

		public static void HandleDeath(Player dead)
		{
			if ((Object)(object)dead == (Object)null)
			{
				return;
			}
			MomentsTracker component = ((Component)dead).GetComponent<MomentsTracker>();
			if ((Object)(object)component != (Object)null)
			{
				component.diedThisPoint = true;
				component.RevertAll();
			}
			Player val = (((Object)(object)dead.data != (Object)null) ? dead.data.lastSourceOfDamage : null);
			if (!((Object)(object)val == (Object)null) && !((Object)(object)val == (Object)(object)dead) && val.teamID != dead.teamID)
			{
				MomentsTracker component2 = ((Component)val).GetComponent<MomentsTracker>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.OnKill();
				}
			}
		}

		private void OnKill()
		{
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: 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)
			if (!data.dead)
			{
				int num = Copies(Moment.Clutch);
				if (num > 0 && data.health <= data.maxHealth * 0.25f)
				{
					data.healthHandler.Heal(data.maxHealth);
					AddBuff(0f, 0.5f * (float)num, 0f, Time.time + 4f);
					MomentBanner.Show("CLUTCH!", player, new Color(1f, 0.3f, 0.25f));
				}
				if (Copies(Moment.LastBullet) > 0 && (Object)(object)gunAmmo != (Object)null && CurrentAmmo.Invoke(gunAmmo) <= 0)
				{
					gunAmmo.ReloadAmmo(true);
					MomentBanner.Show("LAST BULLET!", player, new Color(1f, 0.85f, 0.2f));
				}
				int num2 = Copies(Moment.HypeTrain);
				if (num2 > 0 && hypeStacks < 5)
				{
					hypeStacks++;
					float num3 = 0.1f * (float)num2;
					AddBuff(0f, num3, num3, float.PositiveInfinity);
					MomentBanner.Show("HYPE TRAIN x" + hypeStacks, player, new Color(1f, 0.55f, 0.1f));
				}
			}
		}

		private void OnDamaged(Vector2 damage, bool selfDamage)
		{
			if (((Vector2)(ref damage)).sqrMagnitude > 0f)
			{
				tookDamageThisPoint = true;
			}
		}

		private void OnBlock(BlockTriggerType trigger)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			int num = Copies(Moment.GravityCrush);
			if (num > 0 && (int)trigger == 0 && data.view.IsMine && !data.dead)
			{
				GravityCrush.Cast(player, num);
			}
			int num2 = Copies(Moment.GravityWell);
			if (num2 > 0 && (int)trigger == 0 && data.view.IsMine && !data.dead)
			{
				GravityWell.Cast(player, num2);
			}
		}

		private void OnBlockedProjectile(GameObject projectile, Vector3 forward, Vector3 hitPos)
		{
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			int num = Copies(Moment.ParryGod);
			if (num <= 0 || data.dead)
			{
				return;
			}
			float num2 = Mathf.Max(1f, 3f - 0.75f * (float)(num - 1));
			if (!(Time.time - lastParryRefund < num2))
			{
				lastParryRefund = Time.time;
				block.ResetCD(false);
				if (Time.time - lastParryBanner > 1f)
				{
					lastParryBanner = Time.time;
					MomentBanner.Show("PARRIED!", player, new Color(0.4f, 0.9f, 1f));
				}
			}
		}

		private void Update()
		{
			//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)data == (Object)null)
			{
				return;
			}
			for (int num = buffs.Count - 1; num >= 0; num--)
			{
				if (Time.time >= buffs[num].ExpiresAt)
				{
					Revert(buffs[num]);
					buffs.RemoveAt(num);
				}
			}
			bool num2 = data.isPlaying && !data.dead;
			int num3 = Copies(Moment.LastBullet);
			bool flag = num2 && num3 > 0 && (Object)(object)gunAmmo != (Object)null && !gun.isReloading && CurrentAmmo.Invoke(gunAmmo) == 1;
			if (flag && lastBulletBuff == null)
			{
				lastBulletBuff = AddBuff(0.75f * (float)num3, 0f, 0f, float.PositiveInfinity);
			}
			else if (!flag && lastBulletBuff != null)
			{
				Revert(lastBulletBuff);
				buffs.Remove(lastBulletBuff);
				lastBulletBuff = null;
			}
			int num4 = Copies(Moment.MainCharacter);
			if (num2 && num4 > 0 && !mainCharacterFired && (Object)(object)PlayerManager.instance != (Object)null)
			{
				List<Player> players = PlayerManager.instance.players;
				int num5 = players.Count((Player p) => p.teamID == player.teamID && !p.data.dead);
				int num6 = players.Count((Player p) => p.teamID != player.teamID && !p.data.dead);
				if (num5 == 1 && num6 >= 2)
				{
					mainCharacterFired = true;
					AddBuff(0.5f * (float)num4, 0f, 0.3f * (float)num4, float.PositiveInfinity);
					block.ResetCD(false);
					MomentBanner.Show("1v" + num6 + " MAIN CHARACTER", player, new Color(1f, 0.45f, 0.8f));
				}
			}
		}

		private Buff AddBuff(float damage, float attackSpeed, float move, float expiresAt)
		{
			Buff buff = new Buff
			{
				ExpiresAt = expiresAt
			};
			buff.Damage = gun.damage * damage;
			buff.AttackSpeed = ((attackSpeed > 0f) ? (gun.attackSpeed / (1f + attackSpeed) - gun.attackSpeed) : 0f);
			buff.Move = stats.movementSpeed * move;
			Gun obj = gun;
			obj.damage += buff.Damage;
			Gun obj2 = gun;
			obj2.attackSpeed += buff.AttackSpeed;
			CharacterStatModifiers obj3 = stats;
			obj3.movementSpeed += buff.Move;
			buffs.Add(buff);
			return buff;
		}

		private void Revert(Buff b)
		{
			Gun obj = gun;
			obj.damage -= b.Damage;
			Gun obj2 = gun;
			obj2.attackSpeed -= b.AttackSpeed;
			CharacterStatModifiers obj3 = stats;
			obj3.movementSpeed -= b.Move;
		}

		private void RevertAll()
		{
			if ((Object)(object)gun == (Object)null)
			{
				return;
			}
			foreach (Buff buff in buffs)
			{
				Revert(buff);
			}
			buffs.Clear();
			lastBulletBuff = null;
		}
	}
	[HarmonyPatch(typeof(CharacterStatModifiers), "ResetStats")]
	internal static class StatResetFix
	{
		internal static readonly Dictionary<Gravity, float> baseGravity = new Dictionary<Gravity, float>();

		private static void Postfix(CharacterStatModifiers __instance)
		{
			CharacterData component = ((Component)__instance).GetComponent<CharacterData>();
			if ((Object)(object)component != (Object)null)
			{
				component.jumps = 1;
				if (component.currentJumps > 1)
				{
					component.currentJumps = 1;
				}
			}
			Gravity component2 = ((Component)__instance).GetComponent<Gravity>();
			if (!((Object)(object)component2 == (Object)null))
			{
				if (baseGravity.TryGetValue(component2, out var value))
				{
					component2.gravityForce = value;
				}
				else
				{
					baseGravity[component2] = component2.gravityForce;
				}
			}
		}
	}
	[HarmonyPatch(typeof(Gravity), "Start")]
	internal static class GravityBaselinePatch
	{
		private static void Postfix(Gravity __instance)
		{
			if (!StatResetFix.baseGravity.ContainsKey(__instance))
			{
				StatResetFix.baseGravity[__instance] = __instance.gravityForce;
			}
		}
	}
}
namespace RazzsEpicGamerMoments.Elements
{
	public class AirFlight : MonoBehaviour
	{
		public const float FlightSeconds = 3f;

		public const float ExtraSecondsPerCopy = 1f;

		public const float FlySpeed = 11f;

		public const float GlideFallSpeed = 3f;

		private const float HoldDelay = 0.15f;

		private static readonly FieldRef<PlayerVelocity, Vector2> Velocity = AccessTools.FieldRefAccess<PlayerVelocity, Vector2>("velocity");

		private Player player;

		private CharacterData data;

		private float fuel;

		private float holdTime;

		private SpriteRenderer barBack;

		private SpriteRenderer barFill;

		private readonly List<SpriteRenderer> puffs = new List<SpriteRenderer>();

		private float nextPuff;

		private int puffIndex;

		private bool flying;

		private bool gliding;

		private static Sprite white;

		private float MaxFuel
		{
			get
			{
				int num = ElementRegistry.Copies(player, "Skyward");
				if (num == 0)
				{
					return 0f;
				}
				return (3f + 1f * (float)(num - 1)) * ElementRegistry.Power(player, Element.Air);
			}
		}

		private bool IsOwner
		{
			get
			{
				if ((Object)(object)data != (Object)null && (Object)(object)data.view != (Object)null)
				{
					return data.view.IsMine;
				}
				return false;
			}
		}

		public static void Ensure(Player p)
		{
			if (!((Object)(object)((Component)p).GetComponent<AirFlight>() != (Object)null))
			{
				AirFlight airFlight = ((Component)p).gameObject.AddComponent<AirFlight>();
				airFlight.player = p;
				airFlight.data = p.data;
			}
		}

		internal void PhysicsStep(PlayerVelocity vel)
		{
			//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_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: 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_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			flying = (gliding = false);
			if (!IsOwner)
			{
				return;
			}
			float maxFuel = MaxFuel;
			bool flag = !data.dead && data.isPlaying;
			float fixedDeltaTime = Time.fixedDeltaTime;
			if (data.isGrounded || data.isWallGrab || !flag)
			{
				fuel = maxFuel;
			}
			bool flag2 = flag && maxFuel > 0f && !data.isGrounded && (Object)(object)data.input != (Object)null && data.input.jumpIsPressed;
			holdTime = (flag2 ? (holdTime + fixedDeltaTime) : 0f);
			if (!flag2 || holdTime < 0.15f)
			{
				return;
			}
			Vector2 val = Velocity.Invoke(vel);
			float num = ElementRegistry.Power(player, Element.Air);
			if (fuel > 0f)
			{
				fuel -= fixedDeltaTime;
				float num2 = 11f * Mathf.Sqrt(num);
				if (val.y < num2)
				{
					val.y = Mathf.Min(num2, Mathf.Max(val.y, 0f) + 90f * fixedDeltaTime);
				}
				flying = true;
			}
			else
			{
				float num3 = 3f / num;
				if (val.y < 0f - num3)
				{
					val.y = 0f - num3;
				}
				gliding = true;
			}
			Velocity.Invoke(vel) = val;
		}

		private void Update()
		{
			if (IsOwner)
			{
				float maxFuel = MaxFuel;
				bool flag = !data.dead && data.isPlaying;
				DrawBar(maxFuel, flag && maxFuel > 0f && fuel < maxFuel - 0.01f);
				if ((flying || gliding) && Time.time >= nextPuff)
				{
					nextPuff = Time.time + (flying ? 0.05f : 0.12f);
					Puff(flying);
				}
				FadePuffs();
			}
		}

		private void DrawBar(float max, bool show)
		{
			//IL_0029: 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_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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: 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_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: 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_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)barBack == (Object)null)
			{
				barBack = Sprite("FlightBarBack", new Color(0f, 0f, 0f, 0.5f), 60);
				barFill = Sprite("FlightBarFill", new Color(0.85f, 0.95f, 1f), 61);
				SpriteRenderer obj = barBack;
				Sprite sprite = (barFill.sprite = WhiteSprite());
				obj.sprite = sprite;
			}
			SpriteRenderer obj2 = barBack;
			bool enabled = (((Renderer)barFill).enabled = show);
			((Renderer)obj2).enabled = enabled;
			if (show)
			{
				Vector3 val2 = ((Component)player).transform.position + Vector3.up * 1.7f;
				((Component)barBack).transform.position = val2;
				((Component)barBack).transform.localScale = new Vector3(1.2f, 0.14f, 1f);
				float num = ((max > 0f) ? Mathf.Clamp01(fuel / max) : 0f);
				((Component)barFill).transform.position = val2 + Vector3.left * (0.6f * (1f - num));
				((Component)barFill).transform.localScale = new Vector3(1.2f * num, 0.1f, 1f);
				barFill.color = ((num > 0f) ? new Color(0.85f, 0.95f, 1f) : new Color(0.6f, 0.7f, 0.8f));
			}
		}

		private void Puff(bool flying)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: 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_00b2: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
			SpriteRenderer val;
			if (puffs.Count < 12)
			{
				val = Sprite("Puff", Color.white, 55);
				val.sprite = ArtSprites.SoftCircle;
				puffs.Add(val);
			}
			else
			{
				val = puffs[puffIndex = (puffIndex + 1) % puffs.Count];
			}
			((Component)val).transform.position = ((Component)player).transform.position + new Vector3(Random.Range(-0.3f, 0.3f), flying ? (-0.9f) : (-0.4f), 0f);
			((Component)val).transform.localScale = Vector3.one * (flying ? 0.6f : 0.4f);
			val.color = new Color(0.9f, 0.97f, 1f, flying ? 0.7f : 0.4f);
		}

		private void FadePuffs()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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)
			foreach (SpriteRenderer puff in puffs)
			{
				Color color = puff.color;
				if (!(color.a <= 0f))
				{
					color.a -= Time.deltaTime * 1.5f;
					puff.color = color;
					Transform transform = ((Component)puff).transform;
					transform.localScale += Vector3.one * Time.deltaTime;
					Transform transform2 = ((Component)puff).transform;
					transform2.position += Vector3.down * Time.deltaTime;
				}
			}
		}

		private SpriteRenderer Sprite(string name, Color c, int order)
		{
			//IL_0001: 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)
			SpriteRenderer obj = new GameObject(name).AddComponent<SpriteRenderer>();
			obj.color = c;
			((Renderer)obj).sortingOrder = order;
			return obj;
		}

		private static Sprite WhiteSprite()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)white != (Object)null)
			{
				return white;
			}
			Texture2D val = new Texture2D(4, 4);
			Color[] array = (Color[])(object)new Color[16];
			for (int i = 0; i < 16; i++)
			{
				array[i] = Color.white;
			}
			val.SetPixels(array);
			val.Apply();
			white = Sprite.Create(val, new Rect(0f, 0f, 4f, 4f), new Vector2(0.5f, 0.5f), 4f);
			return white;
		}

		private void OnDestroy()
		{
			if ((Object)(object)barBack != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)barBack).gameObject);
			}
			if ((Object)(object)barFill != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)barFill).gameObject);
			}
			foreach (SpriteRenderer puff in puffs)
			{
				if ((Object)(object)puff != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)puff).gameObject);
				}
			}
		}
	}
	[HarmonyPatch(typeof(PlayerVelocity), "FixedUpdate")]
	internal static class FlightPhysicsPatch
	{
		private static void Prefix(PlayerVelocity __instance)
		{
			AirFlight component = ((Component)__instance).GetComponent<AirFlight>();
			if ((Object)(object)component != (Object)null)
			{
				component.PhysicsStep(__instance);
			}
		}
	}
	public class AirThrower : MonoBehaviour
	{
		public const float HoldSeconds = 1f;

		public const float GrabRadius = 1.2f;

		public const float ThrowMultiplier = 1.6f;

		public const float MaxThrowSpeed = 90f;

		private Player player;

		private Block block;

		private static readonly Dictionary<Rigidbody2D, Vector2> holdTargets = new Dictionary<Rigidbody2D, Vector2>();

		private static AirSimulator sim;

		public static void Ensure(Player p)
		{
			if (!((Object)(object)((Component)p).GetComponent<AirThrower>() != (Object)null))
			{
				AirThrower airThrower = ((Component)p).gameObject.AddComponent<AirThrower>();
				airThrower.player = p;
				airThrower.block = p.data.block;
				Block obj = airThrower.block;
				obj.BlockAction = (Action<BlockTriggerType>)Delegate.Combine(obj.BlockAction, new Action<BlockTriggerType>(airThrower.OnBlock));
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)block != (Object)null)
			{
				Block obj = block;
				obj.BlockAction = (Action<BlockTriggerType>)Delegate.Remove(obj.BlockAction, new Action<BlockTriggerType>(OnBlock));
			}
		}

		private void OnBlock(BlockTriggerType trigger)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			if ((int)trigger == 0 && !player.data.dead && !((Object)(object)player.data.view == (Object)null) && player.data.view.IsMine && ElementRegistry.Copies(player, "Gale Throw") != 0 && !((Object)(object)((Component)this).GetComponent<AirHold>() != (Object)null))
			{
				Rigidbody2D val = Find(Aim.CursorPoint(player));
				if (!((Object)(object)val == (Object)null))
				{
					((Component)this).gameObject.AddComponent<AirHold>().Begin(player, val, 1f * ElementRegistry.Power(player, Element.Air));
				}
			}
		}

		private static Rigidbody2D Find(Vector2 point)
		{
			//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_0029: Unknown result type (might be due to invalid IL or missing references)
			Transform root = MapPieces.MapRoot();
			if ((Object)(object)root == (Object)null)
			{
				return null;
			}
			return (from c in Physics2D.OverlapCircleAll(point, 1.2f)
				select c.attachedRigidbody into r
				where (Object)(object)r != (Object)null && (int)r.bodyType == 0 && ((Component)r).transform.IsChildOf(root) && (Object)(object)((Component)r).GetComponentInParent<Player>() == (Object)null
				orderby Vector2.Distance(r.position, point)
				select r).FirstOrDefault();
		}

		internal static bool ShouldSimulate(Rigidbody2D rig)
		{
			if ((Object)(object)((Component)rig).GetComponent<NetworkPhysicsObject>() != (Object)null && !PhotonNetwork.OfflineMode)
			{
				return PhotonNetwork.IsMasterClient;
			}
			return true;
		}

		[UnboundRPC]
		public static void RPC_Hold(string path, float x, float y)
		{
			//IL_0034: 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_005b: Expected O, but got Unknown
			Transform val = MapPieces.Resolve(path);
			Rigidbody2D val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<Rigidbody2D>() : null);
			if (!((Object)(object)val2 == (Object)null) && ShouldSimulate(val2))
			{
				holdTargets[val2] = new Vector2(x, y);
				if ((Object)(object)sim == (Object)null)
				{
					GameObject val3 = new GameObject("AirSimulator");
					Object.DontDestroyOnLoad((Object)val3);
					sim = val3.AddComponent<AirSimulator>();
				}
			}
		}

		[UnboundRPC]
		public static void RPC_Throw(string path, float vx, float vy)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			Transform val = MapPieces.Resolve(path);
			Rigidbody2D val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<Rigidbody2D>() : null);
			if (!((Object)(object)val2 == (Object)null))
			{
				holdTargets.Remove(val2);
				if (ShouldSimulate(val2))
				{
					val2.velocity = new Vector2(vx, vy);
				}
			}
		}

		internal static void SimulateHolds()
		{
			//IL_0046: 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_0061: Unknown result type (might be due to invalid IL or missing references)
			foreach (KeyValuePair<Rigidbody2D, Vector2> item in holdTargets.ToList())
			{
				if ((Object)(object)item.Key == (Object)null)
				{
					holdTargets.Remove(item.Key);
					continue;
				}
				item.Key.velocity = (item.Value - item.Key.position) * 15f;
				Rigidbody2D key = item.Key;
				key.angularVelocity *= 0.9f;
			}
		}

		public static void ClearAll()
		{
			holdTargets.Clear();
		}
	}
	internal class AirSimulator : MonoBehaviour
	{
		private void FixedUpdate()
		{
			AirThrower.SimulateHolds();
		}
	}
	internal class AirHold : MonoBehaviour
	{
		private Player player;

		private Rigidbody2D rig;

		private string path;

		private Vector2 offset;

		private float endsAt;

		private float nextSend;

		private readonly Queue<KeyValuePair<float, Vector2>> history = new Queue<KeyValuePair<float, Vector2>>();

		private LineRenderer tether;

		public void Begin(Player p, Rigidbody2D target, float seconds)
		{
			//IL_0021: 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_0031: 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_009b: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			player = p;
			rig = target;
			path = MapPieces.PathOf(((Component)target).transform);
			offset = target.position - Aim.CursorPoint(p);
			if (((Vector2)(ref offset)).magnitude > 0.6f)
			{
				offset = ((Vector2)(ref offset)).normalized * 0.6f;
			}
			endsAt = Time.time + seconds;
			tether = ((Component)this).gameObject.AddComponent<LineRenderer>();
			((Renderer)tether).material = new Material(Shader.Find("Sprites/Default"));
			tether.positionCount = 2;
			((Renderer)tether).sortingOrder = 100;
			tether.startColor = new Color(0.85f, 0.95f, 1f, 0.8f);
			tether.endColor = new Color(0.85f, 0.95f, 1f, 0.1f);
			tether.startWidth = 0.12f;
			tether.endWidth = 0.04f;
		}

		private void Update()
		{
			//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_0033: 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)
			//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_004b: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)rig == (Object)null || player.data.dead)
			{
				Object.Destroy((Object)(object)this);
				return;
			}
			Vector2 val = Aim.CursorPoint(player);
			Vector2 val2 = val + offset;
			history.Enqueue(new KeyValuePair<float, Vector2>(Time.time, val));
			while (history.Count > 0 && Time.time - history.Peek().Key > 0.12f)
			{
				history.Dequeue();
			}
			tether.SetPosition(0, Vector2.op_Implicit(rig.position));
			tether.SetPosition(1, ((Component)player).transform.position);
			if (Time.time >= nextSend)
			{
				nextSend = Time.time + 0.04f;
				NetworkingManager.RPC(typeof(AirThrower), "RPC_Hold", new object[3] { path, val2.x, val2.y });
			}
			if (Time.time >= endsAt)
			{
				Throw(val);
			}
		}

		private void Throw(Vector2 cursor)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: 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_0038: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_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_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = Vector2.zero;
			if (history.Count > 1)
			{
				KeyValuePair<float, Vector2> keyValuePair = history.Peek();
				float num = Mathf.Max(0.02f, Time.time - keyValuePair.Key);
				val = (cursor - keyValuePair.Value) / num * 1.6f * ElementRegistry.Power(player, Element.Air);
				val = Vector2.ClampMagnitude(val, 90f);
			}
			NetworkingManager.RPC(typeof(AirThrower), "RPC_Throw", new object[3] { path, val.x, val.y });
			if (((Vector2)(ref val)).magnitude > 8f)
			{
				SnipeWatch.Track(player, rig);
			}
			Object.Destroy((Object)(object)this);
		}

		private void OnDestroy()
		{
			if ((Object)(object)tether != (Object)null)
			{
				Object.Destroy((Object)(object)tether);
			}
		}
	}
	internal class SnipeWatch : MonoBehaviour
	{
		public const float SnipeDistance = 28f;

		private Player thrower;

		private Rigidbody2D rig;

		private Vector2 origin;

		private float endsAt;

		public static void Track(Player thrower, Rigidbody2D rig)
		{
			//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)
			SnipeWatch obj = ((Component)rig).gameObject.GetComponent<SnipeWatch>() ?? ((Component)rig).gameObject.AddComponent<SnipeWatch>();
			obj.thrower = thrower;
			obj.rig = rig;
			obj.origin = rig.position;
			obj.endsAt = Time.time + 4f;
		}

		private void Update()
		{
			//IL_0036: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_0082: 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_00f6: 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_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)rig == (Object)null || (Object)(object)thrower == (Object)null || Time.time > endsAt)
			{
				Object.Destroy((Object)(object)this);
				return;
			}
			Vector2 velocity = rig.velocity;
			if (((Vector2)(ref velocity)).magnitude < 5f)
			{
				return;
			}
			float num;
			if (!((Object)(object)((Component)rig).GetComponent<Collider2D>() != (Object)null))
			{
				num = 0.5f;
			}
			else
			{
				Bounds bounds = ((Component)rig).GetComponent<Collider2D>().bounds;
				Vector3 extents = ((Bounds)(ref bounds)).extents;
				num = ((Vector3)(ref extents)).magnitude;
			}
			float num2 = 1.1f + Mathf.Max(num, 0.5f);
			foreach (Player player in PlayerManager.instance.players)
			{
				if (!((Object)(object)player == (Object)null) && !player.data.dead && player.teamID != thrower.teamID && !(Vector2.Distance(Vector2.op_Implicit(((Component)player).transform.position), rig.position) > num2))
				{
					float num3 = Vector2.Distance(origin, rig.position);
					if (num3 >= 28f)
					{
						MomentBanner.Show("SNIPED! (" + Mathf.RoundToInt(num3) + "m)", thrower, new Color(0.85f, 0.95f, 1f));
						ChallengeTracker.Report(thrower, ChallengeId.Snipe);
					}
					Object.Destroy((Object)(object)this);
					break;
				}
			}
		}
	}
	public class EarthCaster : MonoBehaviour
	{
		public const float DragSeconds = 1f;

		public const float MaxPieceSize = 16f;

		public const float PlatformWidth = 4f;

		public const float PlatformHeight = 0.8f;

		public const float PlatformSeconds = 5f;

		private Player player;

		private Block block;

		public static void Ensure(Player p)
		{
			if (!((Object)(object)((Component)p).GetComponent<EarthCaster>() != (Object)null))
			{
				EarthCaster earthCaster = ((Component)p).gameObject.AddComponent<EarthCaster>();
				earthCaster.player = p;
				earthCaster.block = p.data.block;
				Block obj = earthCaster.block;
				obj.BlockAction = (Action<BlockTriggerType>)Delegate.Combine(obj.BlockAction, new Action<BlockTriggerType>(earthCaster.OnBlock));
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)block != (Object)null)
			{
				Block obj = block;
				obj.BlockAction = (Action<BlockTriggerType>)Delegate.Remove(obj.BlockAction, new Action<BlockTriggerType>(OnBlock));
			}
		}

		private void OnBlock(BlockTriggerType trigger)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: 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)
			if ((int)trigger != 0 || player.data.dead || (Object)(object)player.data.view == (Object)null || !player.data.view.IsMine)
			{
				return;
			}
			int num = ElementRegistry.Copies(player, "Tectonic Grip");
			int num2 = ElementRegistry.Copies(player, "Raise Earth");
			if (num + num2 == 0)
			{
				return;
			}
			float num3 = ElementRegistry.Power(player, Element.Earth);
			float num4 = (ChallengeList.HasCard(player, "Landslide") ? 1.5f : 1f);
			Vector2 val = Aim.CursorPoint(player);
			if (num > 0)
			{
				Transform val2 = MapPieces.FindAt(val, 16f * num3);
				if ((Object)(object)val2 != (Object)null)
				{
					float seconds = (1f + 0.5f * (float)(num - 1)) * num3 * num4;
					((Component)this).gameObject.AddComponent<EarthDrag>().Begin(player, val2, val, seconds);
					ChallengeTracker.NoteEarth(player);
					return;
				}
			}
			if (num2 > 0)
			{
				float num5 = (4f + 1.5f * (float)(num2 - 1)) * num3 * num4;
				NetworkingManager.RPC(typeof(EarthCaster), "RPC_Raise", new object[5]
				{
					player.playerID,
					val.x,
					val.y,
					num5,
					5f * num3 * num4
				});
				ChallengeTracker.NoteEarth(player);
			}
		}

		[UnboundRPC]
		public static void RPC_Raise(int playerId, float x, float y, float width, float seconds)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			EarthPlatform.Spawn(new Vector2(x, y), width, 0.8f, seconds);
		}
	}
	internal class EarthDrag : MonoBehaviour
	{
		private Player player;

		private Transform piece;

		private string path;

		private Vector2 offset;

		private float endsAt;

		private float nextSend;

		public void Begin(Player p, Transform target, Vector2 cursor, float seconds)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			player = p;
			piece = target;
			path = MapPieces.PathOf(target);
			offset = Vector2.op_Implicit(target.position) - cursor;
			endsAt = Time.time + seconds;
			MapPieces.Remember(target);
			NetworkingManager.RPC(typeof(MapPieces), "RPC_Grab", new object[2] { path, true });
		}

		private void Update()
		{
			//IL_003b: 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_0046: 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_0052: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: 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 ((Object)(object)piece == (Object)null || (Object)(object)player == (Object)null || player.data.dead)
			{
				Finish();
				return;
			}
			Vector2 val = Aim.CursorPoint(player) + offset;
			piece.position = new Vector3(val.x, val.y, piece.position.z);
			if (Time.time >= nextSend)
			{
				nextSend = Time.time + 0.05f;
				NetworkingManager.RPC_Others(typeof(MapPieces), "RPC_Move", new object[3] { path, val.x, val.y });
			}
			if (Time.time >= endsAt)
			{
				Finish();
			}
		}

		private void Finish()
		{
			//IL_0034: 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)
			if ((Object)(object)piece != (Object)null)
			{
				NetworkingManager.RPC_Others(typeof(MapPieces), "RPC_Move", new object[3]
				{
					path,
					piece.position.x,
					piece.position.y
				});
				NetworkingManager.RPC(typeof(MapPieces), "RPC_Grab", new object[2] { path, false });
			}
			Object.Destroy((Object)(object)this);
		}
	}
	public static class MapPieces
	{
		private static readonly Dictionary<Transform, Vector3> original = new Dictionary<Transform, Vector3>();

		private static readonly Dictionary<Transform, Vector3> targets = new Dictionary<Transform, Vector3>();

		private static readonly HashSet<Transform> held = new HashSet<Transform>();

		private static MapSmoother smoother;

		private static readonly Dictionary<SpriteRenderer, Color> tints = new Dictionary<SpriteRenderer, Color>();

		internal static Transform MapRoot()
		{
			MapManager instance = MapManager.instance;
			if ((Object)(object)instance == (Object)null || instance.currentMap == null || (Object)(object)instance.currentMap.Map == (Object)null)
			{
				return null;
			}
			return ((Component)instance.currentMap.Map).transform;
		}

		public static Transform FindAt(Vector2 point, float maxSize)
		{
			//IL_0011: 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_007a: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			Transform val = MapRoot();
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			Collider2D[] array = Physics2D.OverlapPointAll(point);
			foreach (Collider2D val2 in array)
			{
				if (!((Object)(object)val2 == (Object)null) && !val2.isTrigger && ((Component)val2).transform.IsChildOf(val) && !((Object)(object)((Component)val2).transform == (Object)(object)val) && (!((Object)(object)val2.attachedRigidbody != (Object)null) || (int)val2.attachedRigidbody.bodyType != 0) && !((Object)(object)((Component)val2).GetComponentInParent<Player>() != (Object)null))
				{
					Bounds bounds = val2.bounds;
					Vector3 size = ((Bounds)(ref bounds)).size;
					if (!(size.x > maxSize) && !(size.y > maxSize))
					{
						return ((Component)val2).transform;
					}
				}
			}
			return null;
		}

		internal static bool IsSolidPiece(Collider2D col, Transform root)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)col == (Object)null || (Object)(object)root == (Object)null || col.isTrigger || !((Behaviour)col).enabled)
			{
				return false;
			}
			if ((Object)(object)((Component)col).transform == (Object)(object)root || !((Component)col).transform.IsChildOf(root))
			{
				return false;
			}
			if ((Object)(object)col.attachedRigidbody != (Object)null && (int)col.attachedRigidbody.bodyType == 0)
			{
				return false;
			}
			return (Object)(object)((Component)col).GetComponentInParent<Player>() == (Object)null;
		}

		internal static Transform PieceOf(Collider2D col, Transform root)
		{
			Transform val = ((Component)col).transform;
			while ((Object)(object)val.parent != (Object)null && (Object)(object)val.parent != (Object)(object)root && ((Component)val.parent).GetComponentsInChildren<Collider2D>().Length <= 1)
			{
				val = val.parent;
			}
			return val;
		}

		public static Transform FindNear(Vector2 point, float reach)
		{
			//IL_0011: 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_006a: 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_0073: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			Transform val = MapRoot();
			if ((Object)(object)val == (Object)null)
			{
				return null;
			}
			Collider2D[] array = Physics2D.OverlapPointAll(point);
			foreach (Collider2D col in array)
			{
				if (IsSolidPiece(col, val))
				{
					return PieceOf(col, val);
				}
			}
			Collider2D val2 = null;
			float num = float.MaxValue;
			array = Physics2D.OverlapCircleAll(point, reach);
			foreach (Collider2D val3 in array)
			{
				if (IsSolidPiece(val3, val))
				{
					Bounds bounds = val3.bounds;
					float num2 = Vector2.Distance(Vector2.op_Implicit(((Bounds)(ref bounds)).ClosestPoint(Vector2.op_Implicit(point))), point);
					if (num2 < num)
					{
						num = num2;
						val2 = val3;
					}
				}
			}
			if (!((Object)(object)val2 != (Object)null))
			{
				return null;
			}
			return PieceOf(val2, val);
		}

		public static string PathOf(Transform t)
		{
			Transform val = MapRoot();
			List<int> list = new List<int>();
			while ((Object)(object)t != (Object)null && (Object)(object)t != (Object)(object)val)
			{
				list.Add(t.GetSiblingIndex());
				t = t.parent;
			}
			list.Reverse();
			return string.Join("/", list.Select((int i) => i.ToString()).ToArray());
		}

		internal static Transform Resolve(string path)
		{
			Transform val = MapRoot();
			if ((Object)(object)val == (Object)null || string.IsNullOrEmpty(path))
			{
				return null;
			}
			string[] array = path.Split(new char[1] { '/' });
			for (int i = 0; i < array.Length; i++)
			{
				if (!int.TryParse(array[i], out var result) || result >= val.childCount)
				{
					return null;
				}
				val = val.GetChild(result);
			}
			return val;
		}

		public static void Remember(Transform t)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)t != (Object)null && !original.ContainsKey(t))
			{
				original[t] = t.position;
			}
		}

		[UnboundRPC]
		public static void RPC_Grab(string path, bool grabbing)
		{
			Transform val = Resolve(path);
			if (!((Object)(object)val == (Object)null))
			{
				Remember(val);
				if (grabbing)
				{
					held.Add(val);
				}
				else
				{
					held.Remove(val);
				}
				Highlight(val, grabbing);
			}
		}

		[UnboundRPC]
		public static void RPC_Move(string path, float x, float y)
		{
			//IL_0020: 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_0046: 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_0051: Expected O, but got Unknown
			Transform val = Resolve(path);
			if (!((Object)(object)val == (Object)null))
			{
				Remember(val);
				targets[val] = new Vector3(x, y, val.position.z);
				if ((Object)(object)smoother == (Object)null)
				{
					GameObject val2 = new GameObject("MapPieceSmoother");
					Object.DontDestroyOnLoad((Object)val2);
					smoother = val2.AddComponent<MapSmoother>();
				}
			}
		}

		public static void RestoreAll()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			foreach (KeyValuePair<Transform, Vector3> item in original)
			{
				if ((Object)(object)item.Key != (Object)null)
				{
					item.Key.position = item.Value;
					Highlight(item.Key, on: false);
				}
			}
			original.Clear();
			targets.Clear();
			held.Clear();
		}

		internal static void Smooth()
		{
			//IL_004e: 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_005f: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			foreach (KeyValuePair<Transform, Vector3> item in targets.ToList())
			{
				if ((Object)(object)item.Key == (Object)null)
				{
					targets.Remove(item.Key);
					continue;
				}
				item.Key.position = Vector3.Lerp(item.Key.position, item.Value, 0.5f);
				Vector3 val = item.Key.position - item.Value;
				if (((Vector3)(ref val)).sqrMagnitude < 0.0001f)
				{
					targets.Remove(item.Key);
				}
			}
		}

		private static void Highlight(Transform t, bool on)
		{
			//IL_0078: 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_004e: 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_0029: Unknown result type (might be due to invalid IL or missing references)
			SpriteRenderer[] componentsInChildren = ((Component)t).GetComponentsInChildren<SpriteRenderer>();
			foreach (SpriteRenderer val in componentsInChildren)
			{
				if (on)
				{
					if (!tints.ContainsKey(val))
					{
						tints[val] = val.color;
					}
					val.color = Color.Lerp(tints[val], new Color(1f, 0.8f, 0.45f), 0.45f);
				}
				else if (tints.ContainsKey(val))
				{
					val.color = tints[val];
					tints.Remove(val);
				}
			}
		}
	}
	internal class MapSmoother : MonoBehaviour
	{
		private void Update()
		{
			MapPieces.Smooth();
		}
	}
	internal class EarthPlatform : MonoBehaviour
	{
		private static readonly List<EarthPlatform> live = new List<EarthPlatform>();

		private static Sprite rock;

		private const int MaxPlatforms = 12;

		private float width;

		private float height;

		private float born;

		private float lifetime;

		private BoxCollider2D box;

		private SpriteRenderer sr;

		private readonly List<Transform> chunks = new List<Transform>();

		private readonly List<Vector2> chunkVel = new List<Vector2>();

		private bool crumbling;

		public static void Spawn(Vector2 at, float width, float height, float seconds)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			//IL_0047: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			if (live.Count >= 12 && (Object)(object)live[0] != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)live[0]).gameObject);
			}
			GameObject val = new GameObject("EarthPlatform");
			val.transform.position = Vector2.op_Implicit(at);
			val.layer = MapLayer();
			EarthPlatform earthPlatform = val.AddComponent<EarthPlatform>();
			earthPlatform.width = width;
			earthPlatform.height = height;
			earthPlatform.lifetime = seconds;
			earthPlatform.born = Time.time;
			earthPlatform.box = val.AddComponent<BoxCollider2D>();
			earthPlatform.box.size = new Vector2(width, height);
			earthPlatform.sr = val.AddComponent<SpriteRenderer>();
			earthPlatform.sr.sprite = RockSprite();
			earthPlatform.sr.drawMode = (SpriteDrawMode)2;
			earthPlatform.sr.size = new Vector2(width, height);
			((Renderer)earthPlatform.sr).sortingOrder = 5;
			live.Add(earthPlatform);
		}

		public static void ClearAll()
		{
			EarthPlatform[] array = live.ToArray();
			foreach (EarthPlatform earthPlatform in array)
			{
				if ((Object)(object)earthPlatform != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)earthPlatform).gameObject);
				}
			}
			live.Clear();
		}

		private static int MapLayer()
		{
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			MapManager instance = MapManager.instance;
			Map val = (((Object)(object)instance != (Object)null && instance.currentMap != null) ? instance.currentMap.Map : null);
			if ((Object)(object)val != (Object)null)
			{
				Collider2D[] componentsInChildren = ((Component)val).GetComponentsInChildren<Collider2D>();
				foreach (Collider2D val2 in componentsInChildren)
				{
					if (!val2.isTrigger && ((Object)(object)val2.attachedRigidbody == (Object)null || (int)val2.attachedRigidbody.bodyType != 0))
					{
						return ((Component)val2).gameObject.layer;
					}
				}
			}
			return 0;
		}

		private static Sprite RockSprite()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)rock != (Object)null)
			{
				return rock;
			}
			Texture2D val = new Texture2D(32, 16, (TextureFormat)4, false)
			{
				filterMode = (FilterMode)0,
				wrapMode = (TextureWrapMode)0
			};
			Random random = new Random(3);
			for (int i = 0; i < 16; i++)
			{
				for (int j = 0; j < 32; j++)
				{
					float num = (float)random.NextDouble() * 0.12f;
					Color val2 = ((i >= 13) ? new Color(0.55f + num, 0.42f + num, 0.28f + num) : (((j + i * 3) % 11 == 0) ? new Color(0.22f, 0.16f, 0.12f) : new Color(0.38f + num, 0.28f + num, 0.2f + num)));
					val.SetPixel(j, i, val2);
				}
			}
			val.Apply();
			rock = Sprite.Create(val, new Rect(0f, 0f, 32f, 16f), new Vector2(0.5f, 0.5f), 20f, 0u, (SpriteMeshType)0, Vector4.zero);
			return rock;
		}

		private void Update()
		{
			//IL_004e: 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_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_00d2: 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_00e1: 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_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: 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_0171: 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_0191: Unknown result type (might be due to invalid IL or missing references)
			float num = Time.time - born;
			float num2 = lifetime - num;
			if (!crumbling)
			{
				float num3 = Mathf.Clamp01(num / 0.15f);
				((Component)this).transform.localScale = new Vector3(1f, Mathf.Lerp(0.1f, 1f, num3), 1f);
				if (num2 < 0.6f)
				{
					float num4 = (0.6f - num2) * 0.12f;
					((Component)sr).transform.localPosition = new Vector3(Random.Range(0f - num4, num4), Random.Range(0f - num4, num4), 0f);
				}
				if (num2 <= 0f)
				{
					Crumble();
				}
				return;
			}
			for (int i = 0; i < chunks.Count; i++)
			{
				List<Vector2> list = chunkVel;
				int index = i;
				list[index] += Vector2.down * 25f * Time.deltaTime;
				Transform obj = chunks[i];
				obj.position += Vector2.op_Implicit(chunkVel[i] * Time.deltaTime);
				chunks[i].Rotate(0f, 0f, chunkVel[i].x * 40f * Time.deltaTime);
				SpriteRenderer component = ((Component)chunks[i]).GetComponent<SpriteRenderer>();
				Color color = component.color;
				color.a = Mathf.Clamp01(1f + num2 / 1.2f);
				component.color = color;
			}
			if (num2 < -1.2f)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		private void Crumble()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_0057: 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_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			crumbling = true;
			((Behaviour)box).enabled = false;
			((Renderer)sr).enabled = false;
			int num = Mathf.Clamp(Mathf.RoundToInt(width * 2f), 4, 14);
			for (int i = 0; i < num; i++)
			{
				GameObject val = new GameObject("Chunk");
				val.transform.position = ((Component)this).transform.position + new Vector3(Mathf.Lerp((0f - width) / 2f, width / 2f, ((float)i + 0.5f) / (float)num), Random.Range((0f - height) / 3f, height / 3f), 0f);
				val.transform.SetParent(((Component)this).transform, true);
				SpriteRenderer obj = val.AddComponent<SpriteRenderer>();
				obj.sprite = RockSprite();
				obj.drawMode = (SpriteDrawMode)2;
				float num2 = width / (float)num * Random.Range(0.7f, 1.1f);
				obj.size = new Vector2(num2, num2 * 0.8f);
				((Renderer)obj).sortingOrder = 5;
				chunks.Add(val.transform);
				chunkVel.Add(new Vector2(Random.Range(-2f, 2f), Random.Range(1f, 4f)));
			}
		}

		private void OnDestroy()
		{
			live.Remove(this);
		}
	}
	public enum Element
	{
		Fire,
		Lightning,
		Ice,
		Poison,
		Gravity,
		Earth,
		Air,
		Void
	}
	public static class ElementRegistry
	{
		public const string FireRounds = "Fire Rounds";

		public const string FireTrail = "Fire Trail";

		public const string Inferno = "Inferno";

		public const string ArcRounds = "Arc Rounds";

		public const string StunRounds = "Overcharge";

		public const string Thunderstorm = "Thunderstorm";

		public const string FrostRounds = "Frost Rounds";

		public const string BrainFreeze = "Brain Freeze";

		public const string Permafrost = "Permafrost";

		public const string VenomRounds = "Venom Rounds";

		public const string Corrosion = "Corrosion";

		public const string Pandemic = "Pandemic";

		public const string EventHorizon = "Event Horizon";

		public const string TectonicGrip = "Tectonic Grip";

		public const string RaiseEarth = "Raise Earth";

		public const string Bedrock = "Bedrock";

		public const string Skyward = "Skyward";

		public const string GaleThrow = "Gale Throw";

		public const string JetStream = "Jet Stream";

		public const string Unmake = "Unmake";

		public const string PhaseRounds = "Rift Rounds";

		public const string Oblivion = "Oblivion";

		public const string Combustion = "Combustion";

		public const string Shatter = "Shatter";

		public const string Contagion = "Contagion";

		public const string StoneSkin = "Stone Skin";

		public const string Updraft = "Updraft";

		public const string Hollow = "Hollow";

		public const string RiftRounds = "Rift Rounds";

		public static readonly Dictionary<Element, string> BuffCard = new Dictionary<Element, string>
		{
			{
				Element.Fire,
				"Inferno"
			},
			{
				Element.Lightning,
				"Thunderstorm"
			},
			{
				Element.Ice,
				"Permafrost"
			},
			{
				Element.Poison,
				"Pandemic"
			},
			{
				Element.Gravity,
				"Event Horizon"
			},
			{
				Element.Earth,
				"Bedrock"
			},
			{
				Element.Air,
				"Jet Stream"
			},
			{
				Element.Void,
				"Oblivion"
			}
		};

		public static readonly Dictionary<string, Element> Gated = new Dictionary<string, Element>(StringComparer.OrdinalIgnoreCase)
		{
			{
				"Inferno",
				Element.Fire
			},
			{
				"Thunderstorm",
				Element.Lightning
			},
			{
				"Permafrost",
				Element.Ice
			},
			{
				"Pandemic",
				Element.Poison
			},
			{
				"Event Horizon",
				Element.Gravity
			},
			{
				"Bedrock",
				Element.Earth
			},
			{
				"Jet Stream",
				Element.Air
			},
			{
				"Oblivion",
				Element.Void
			},
			{
				"Fire Trail",
				Element.Fire
			},
			{
				"Overcharge",
				Element.Lightning
			},
			{
				"Combustion",
				Element.Fire
			},
			{
				"Shatter",
				Element.Ice
			},
			{
				"Contagion",
				Element.Poison
			}
		};

		private static readonly Dictionary<string, Element> Explicit = new Dictionary<string, Element>(StringComparer.OrdinalIgnoreCase)
		{
			{
				"Fire Rounds",
				Element.Fire
			},
			{
				"Fire Trail",
				Element.Fire
			},
			{
				"Arc Rounds",
				Element.Lightning
			},
			{
				"Overcharge",
				Element.Lightning
			},
			{
				"Frost Rounds",
				Element.Ice
			},
			{
				"Brain Freeze",
				Element.Ice
			},
			{
				"Venom Rounds",
				Element.Poison
			},
			{
				"Corrosion",
				Element.Poison
			},
			{
				"Gravity Crush",
				Element.Gravity
			},
			{
				"Gravity Well",
				Element.Gravity
			},
			{
				"Tectonic Grip",
				Element.Earth
			},
			{
				"Raise Earth",
				Element.Earth
			},
			{
				"Skyward",
				Element.Air
			},
			{
				"Gale Throw",
				Element.Air
			},
			{
				"Unmake",
				Element.Void
			},
			{
				"Combustion",
				Element.Fire
			},
			{
				"Shatter",
				Element.Ice
			},
			{
				"Contagion",
				Element.Poison
			},
			{
				"Stone Skin",
				Element.Earth
			},
			{
				"Updraft",
				Element.Air
			},
			{
				"Hollow",
				Element.Void
			},
			{
				"Rift Rounds",
				Element.Void
			},
			{
				"Explosive Bullet",
				Element.Fire
			},
			{
				"Timed Detonation",
				Element.Fire
			},
			{
				"Bombs Away",
				Element.Fire
			},
			{
				"Thruster",
				Element.Fire
			},
			{
				"Static Field",
				Element.Lightning
			},
			{
				"Dazzle",
				Element.Lightning
			},
			{
				"Cold Bullets",
				Element.Ice
			},
			{
				"Chilling Presence",
				Element.Ice
			},
			{
				"Frost Slam",
				Element.Ice
			},
			{
				"Poison",
				Element.Poison
			},
			{
				"Toxic Cloud",
				Element.Poison
			},
			{
				"Decay",
				Element.Poison
			},
			{
				"Parasite",
				Element.Poison
			},
			{
				"Supernova",
				Element.Gravity
			},
			{
				"Tank",
				Element.Earth
			},
			{
				"Defender",
				Element.Earth
			},
			{
				"Huge",
				Element.Earth
			},
			{
				"Big Bullet",
				Element.Earth
			},
			{
				"Fastball",
				Element.Air
			},
			{
				"Quick Shot",
				Element.Air
			},
			{
				"Wind Up",
				Element.Air
			},
			{
				"Teleport",
				Element.Void
			},
			{
				"Drill Ammo",
				Element.Void
			},
			{
				"Silence",
				Element.Void
			},
			{
				"Abyssal Countdown",
				Element.Void
			}
		};

		private static readonly Dictionary<Element, string[]> Words = new Dictionary<Element, string[]>
		{
			{
				Element.Fire,
				new string[12]
				{
					"fire", "flame", "flames", "burn", "burning", "ember", "embers", "blaze", "ignite", "lava",
					"heat", "explosive"
				}
			},
			{
				Element.Lightning,
				new string[12]
				{
					"lightning", "static", "shock", "shockwave", "spark", "sparks", "thunder", "volt", "zap", "emp",
					"electric", "storm"
				}
			},
			{
				Element.Ice,
				new string[12]
				{
					"ice", "icy", "frost", "frosty", "cold", "chill", "chilling", "freeze", "frozen", "snow",
					"glacier", "slow"
				}
			},
			{
				Element.Poison,
				new string[8] { "poison", "poisonous", "toxic", "venom", "acid", "plague", "decay", "corrosive" }
			},
			{
				Element.Gravity,
				new string[6] { "gravity", "graviton", "singularity", "vortex", "magnet", "magnetic" }
			},
			{
				Element.Earth,
				new string[11]
				{
					"earth", "rock", "rocks", "stone", "boulder", "quake", "earthquake", "ground", "pebble", "terra",
					"tectonic"
				}
			},
			{
				Element.Air,
				new string[12]
				{
					"air", "wind", "gust", "gale", "sky", "fly", "flight", "feather", "glide", "breeze",
					"tornado", "updraft"
				}
			},
			{
				Element.Void,
				new string[11]
				{
					"void", "null", "abyss", "rift", "oblivion", "phase", "phasing", "shadow", "erase", "nothing",
					"ethereal"
				}
			}
		};

		public static Element? Of(CardInfo card)
		{
			if ((Object)(object)card == (Object)null || string.IsNullOrEmpty(card.cardName))
			{
				return null;
			}
			if (BuffCard.ContainsValue(card.cardName))
			{
				return null;
			}
			if (Explicit.TryGetValue(card.cardName, out var value))
			{
				return value;
			}
			string[] source = card.cardName.ToLowerInvariant().Split(new char[4] { ' ', '-', '_', '.' }, StringSplitOptions.RemoveEmptyEntries);
			foreach (KeyValuePair<Element, string[]> kv in Words)
			{