Decompiled source of CodyGunCards v1.0.0

CodyGunCards.dll

Decompiled 21 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using CodyGunCards.Cards;
using CodyGunCards.Core;
using CodyGunCards.Runtime;
using HarmonyLib;
using Photon.Pun;
using UnboundLib;
using UnboundLib.Cards;
using UnboundLib.GameModes;
using UnboundLib.Networking;
using UnityEngine;
using UnityEngine.UI;

[assembly: AssemblyTitle("CodyGunCards")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("1.0.0.0")]
namespace CodyGunCards.Cards
{
	public abstract class CodyCard : CustomCard
	{
		protected abstract Weapon Weapon { get; }

		protected abstract string Art { get; }

		protected override string GetTitle()
		{
			foreach (Card card in Rules.Cards)
			{
				if (card.Weapon == Weapon)
				{
					return card.Name;
				}
			}
			return Weapon.ToString();
		}

		protected override Rarity GetRarity()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			foreach (Card card in Rules.Cards)
			{
				if (card.Weapon == Weapon && card.Tier == Tier.VeryRare)
				{
					return VeryRare.Value;
				}
			}
			return (Rarity)2;
		}

		protected override GameObject GetCardArt()
		{
			return CardArt.Create(Art);
		}

		protected override CardThemeColorType GetTheme()
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			foreach (Card card in Rules.Cards)
			{
				if (card.Weapon == Weapon && card.Tier == Tier.VeryRare)
				{
					return (CardThemeColorType)1;
				}
			}
			return (CardThemeColorType)0;
		}

		public override string GetModName()
		{
			return "CGC";
		}

		public override void SetupCard(CardInfo cardInfo, Gun gun, ApplyCardStats cardStats, CharacterStatModifiers statModifiers)
		{
			cardInfo.allowMultiple = false;
			if ((Object)(object)gun != (Object)null)
			{
				gun.gravity = 1f;
			}
			Setup(gun);
		}

		protected virtual void Setup(Gun gun)
		{
		}

		public override void OnAddCard(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
		{
			Loadout.Invalidate();
			GunController.Ensure(player);
			Loadout.EnforceMagazine(player);
		}

		public override void OnRemoveCard(Player player, Gun gun, GunAmmo gunAmmo, CharacterData data, HealthHandler health, Gravity gravity, Block block, CharacterStatModifiers characterStats)
		{
			Loadout.Invalidate();
		}

		internal static CardInfoStat Stat(bool positive, string stat, string amount)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Expected O, but got Unknown
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			CardInfoStat val = new CardInfoStat();
			val.positive = positive;
			val.stat = stat;
			val.amount = amount;
			val.simepleAmount = (SimpleAmount)0;
			return val;
		}
	}
	public class LaserCard : CodyCard
	{
		internal static CardInfo Card;

		protected override Weapon Weapon
		{
			[CompilerGenerated]
			get
			{
				return Weapon.Laser;
			}
		}

		protected override string Art
		{
			[CompilerGenerated]
			get
			{
				return "laser";
			}
		}

		protected override string GetDescription()
		{
			return "Fire a continuous beam for 5s, then reload for 5s. Each extra bullet adds 1s but multiplies DPS by 0.9. Bounces reflect the beam.";
		}

		protected override CardInfoStat[] GetStats()
		{
			return (CardInfoStat[])(object)new CardInfoStat[3]
			{
				CodyCard.Stat(positive: true, "Beam", "5s"),
				CodyCard.Stat(positive: true, "Damage", "33 HP/s"),
				CodyCard.Stat(positive: false, "Beam reload", "5s")
			};
		}
	}
	public class MinesCard : CodyCard
	{
		internal static CardInfo Card;

		protected override Weapon Weapon
		{
			[CompilerGenerated]
			get
			{
				return Weapon.Mines;
			}
		}

		protected override string Art
		{
			[CompilerGenerated]
			get
			{
				return "mines";
			}
		}

		protected override string GetDescription()
		{
			return "Bullets that hit terrain plant a mine. Armed mines explode once when an enemy gets close. Direct hits deal half damage.";
		}

		protected override CardInfoStat[] GetStats()
		{
			return (CardInfoStat[])(object)new CardInfoStat[3]
			{
				CodyCard.Stat(positive: true, "Mine blast", "125%"),
				CodyCard.Stat(positive: false, "Direct hit damage", "-50%"),
				CodyCard.Stat(positive: true, "Mine cap", "8")
			};
		}
	}
	public class HarpoonCard : CodyCard
	{
		internal static CardInfo Card;

		protected override Weapon Weapon
		{
			[CompilerGenerated]
			get
			{
				return Weapon.Harpoon;
			}
		}

		protected override string Art
		{
			[CompilerGenerated]
			get
			{
				return "harpoon";
			}
		}

		protected override string GetDescription()
		{
			return "Hits drag the target towards you. Hitting terrain yanks you towards the anchor.";
		}

		protected override CardInfoStat[] GetStats()
		{
			return (CardInfoStat[])(object)new CardInfoStat[3]
			{
				CodyCard.Stat(positive: true, "Pull", "On hit"),
				CodyCard.Stat(positive: false, "Magazine", "1 shot"),
				CodyCard.Stat(positive: false, "Reload", "+1s")
			};
		}

		protected override void Setup(Gun gun)
		{
			gun.reloadTimeAdd = 1f;
		}
	}
	public class SawbladeCard : CodyCard
	{
		internal static CardInfo Card;

		protected override Weapon Weapon
		{
			[CompilerGenerated]
			get
			{
				return Weapon.Sawblade;
			}
		}

		protected override string Art
		{
			[CompilerGenerated]
			get
			{
				return "sawblade";
			}
		}

		protected override string GetDescription()
		{
			return "Bullets that hit terrain release a sawblade that rides along surfaces for 4s, cutting enemies it touches.";
		}

		protected override CardInfoStat[] GetStats()
		{
			return (CardInfoStat[])(object)new CardInfoStat[2]
			{
				CodyCard.Stat(positive: true, "Saw contact", "40% dmg"),
				CodyCard.Stat(positive: true, "Saw life", "4s")
			};
		}
	}
	public class LightningArcCard : CodyCard
	{
		internal static CardInfo Card;

		protected override Weapon Weapon
		{
			[CompilerGenerated]
			get
			{
				return Weapon.LightningArc;
			}
		}

		protected override string Art
		{
			[CompilerGenerated]
			get
			{
				return "lightning";
			}
		}

		protected override string GetDescription()
		{
			return "Short-range shots. Each hit arcs to the nearest other enemy for 60% damage.";
		}

		protected override CardInfoStat[] GetStats()
		{
			return (CardInfoStat[])(object)new CardInfoStat[3]
			{
				CodyCard.Stat(positive: true, "Chain", "1 target"),
				CodyCard.Stat(positive: false, "Damage", "-40%"),
				CodyCard.Stat(positive: false, "Range", "Short")
			};
		}

		protected override void Setup(Gun gun)
		{
			gun.damage = 0.6f;
			gun.destroyBulletAfter = 0.2f;
		}
	}
	public class GravityWellCard : CodyCard
	{
		internal static CardInfo Card;

		protected override Weapon Weapon
		{
			[CompilerGenerated]
			get
			{
				return Weapon.GravityWell;
			}
		}

		protected override string Art
		{
			[CompilerGenerated]
			get
			{
				return "gravity";
			}
		}

		protected override string GetDescription()
		{
			return "Impacts open a well for 0.5s that pulls players (you too) and bullets, then bursts.";
		}

		protected override CardInfoStat[] GetStats()
		{
			return (CardInfoStat[])(object)new CardInfoStat[4]
			{
				CodyCard.Stat(positive: true, "Well", "0.5s pull"),
				CodyCard.Stat(positive: true, "Burst", "50% dmg"),
				CodyCard.Stat(positive: false, "Magazine", "1 shot"),
				CodyCard.Stat(positive: false, "Reload", "+0.5s")
			};
		}

		protected override void Setup(Gun gun)
		{
			gun.reloadTimeAdd = 0.5f;
		}
	}
	public class SplitterPodsCard : CodyCard
	{
		internal static CardInfo Card;

		protected override Weapon Weapon
		{
			[CompilerGenerated]
			get
			{
				return Weapon.SplitterPods;
			}
		}

		protected override string Art
		{
			[CompilerGenerated]
			get
			{
				return "splitter";
			}
		}

		protected override string GetDescription()
		{
			return "Bullets become harmless pods that burst into 6 shards after 0.8s or on impact. Shards can't split again.";
		}

		protected override CardInfoStat[] GetStats()
		{
			return (CardInfoStat[])(object)new CardInfoStat[2]
			{
				CodyCard.Stat(positive: true, "Shards", "6 x 25% dmg"),
				CodyCard.Stat(positive: false, "Pod damage", "None")
			};
		}
	}
	public class RemoteChargesCard : CodyCard
	{
		internal static CardInfo Card;

		protected override Weapon Weapon
		{
			[CompilerGenerated]
			get
			{
				return Weapon.RemoteCharges;
			}
		}

		protected override string Art
		{
			[CompilerGenerated]
			get
			{
				return "remote";
			}
		}

		protected override string GetDescription()
		{
			return "Bullets that hit terrain plant a charge. Blocking detonates all your charges.";
		}

		protected override CardInfoStat[] GetStats()
		{
			return (CardInfoStat[])(object)new CardInfoStat[3]
			{
				CodyCard.Stat(positive: true, "Charge blast", "125%"),
				CodyCard.Stat(positive: true, "Trigger", "Block"),
				CodyCard.Stat(positive: false, "Charge cap", "4")
			};
		}
	}
	public class RailgunCard : CodyCard
	{
		internal static CardInfo Card;

		protected override Weapon Weapon
		{
			[CompilerGenerated]
			get
			{
				return Weapon.Railgun;
			}
		}

		protected override string Art
		{
			[CompilerGenerated]
			get
			{
				return "railgun";
			}
		}

		protected override string GetDescription()
		{
			return "After a visible 1s wind-up, fire one ray that pierces every player in its path. Then a full reload.";
		}

		protected override CardInfoStat[] GetStats()
		{
			return (CardInfoStat[])(object)new CardInfoStat[3]
			{
				CodyCard.Stat(positive: true, "Rail damage", "175%"),
				CodyCard.Stat(positive: true, "Pierce", "All players"),
				CodyCard.Stat(positive: false, "Wind-up", "1s")
			};
		}
	}
	public class ChargeCannonCard : CodyCard
	{
		internal static CardInfo Card;

		protected override Weapon Weapon
		{
			[CompilerGenerated]
			get
			{
				return Weapon.ChargeCannon;
			}
		}

		protected override string Art
		{
			[CompilerGenerated]
			get
			{
				return "charge";
			}
		}

		protected override string GetDescription()
		{
			return "Hold fire to charge for up to 2s. Release for up to 250% damage. A full charge empties the magazine. You move slower while charging.";
		}

		protected override CardInfoStat[] GetStats()
		{
			return (CardInfoStat[])(object)new CardInfoStat[2]
			{
				CodyCard.Stat(positive: true, "Full charge", "250% dmg"),
				CodyCard.Stat(positive: false, "Move speed", "-40% charging")
			};
		}
	}
}
namespace CodyGunCards
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.cody.rounds.codyguncards", "Cody Gun Cards", "1.0.0")]
	[BepInProcess("Rounds.exe")]
	public class Plugin : BaseUnityPlugin
	{
		public const string ModId = "com.cody.rounds.codyguncards";

		public const string ModName = "Cody Gun Cards";

		public const string Version = "1.0.0";

		public const string ModInitials = "CGC";

		public static Plugin Instance { get; private set; }

		private void Awake()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			Instance = this;
			VeryRare.Register();
			Harmony val = new Harmony("com.cody.rounds.codyguncards");
			Type[] types;
			try
			{
				types = typeof(Plugin).Assembly.GetTypes();
			}
			catch (ReflectionTypeLoadException ex)
			{
				types = ex.Types;
			}
			Type[] array = types;
			foreach (Type type in array)
			{
				if (!(type == null))
				{
					try
					{
						val.CreateClassProcessor(type).Patch();
					}
					catch (Exception ex2)
					{
						((BaseUnityPlugin)this).Logger.LogWarning((object)("Harmony skipped " + type.FullName + ": " + ex2.Message));
					}
				}
			}
		}

		private void Start()
		{
			Unbound.RegisterCredits("Cody Gun Cards", new string[1] { "Cody" }, new string[0], new string[0]);
			CustomCard.BuildCard<LaserCard>((Action<CardInfo>)delegate(CardInfo c)
			{
				LaserCard.Card = c;
			});
			CustomCard.BuildCard<MinesCard>((Action<CardInfo>)delegate(CardInfo c)
			{
				MinesCard.Card = c;
			});
			CustomCard.BuildCard<HarpoonCard>((Action<CardInfo>)delegate(CardInfo c)
			{
				HarpoonCard.Card = c;
			});
			CustomCard.BuildCard<SawbladeCard>((Action<CardInfo>)delegate(CardInfo c)
			{
				SawbladeCard.Card = c;
			});
			CustomCard.BuildCard<LightningArcCard>((Action<CardInfo>)delegate(CardInfo c)
			{
				LightningArcCard.Card = c;
			});
			CustomCard.BuildCard<GravityWellCard>((Action<CardInfo>)delegate(CardInfo c)
			{
				GravityWellCard.Card = c;
			});
			CustomCard.BuildCard<SplitterPodsCard>((Action<CardInfo>)delegate(CardInfo c)
			{
				SplitterPodsCard.Card = c;
			});
			CustomCard.BuildCard<RemoteChargesCard>((Action<CardInfo>)delegate(CardInfo c)
			{
				RemoteChargesCard.Card = c;
			});
			CustomCard.BuildCard<RailgunCard>((Action<CardInfo>)delegate(CardInfo c)
			{
				RailgunCard.Card = c;
			});
			CustomCard.BuildCard<ChargeCannonCard>((Action<CardInfo>)delegate(CardInfo c)
			{
				ChargeCannonCard.Card = c;
			});
			GameModeManager.AddHook("GameStart", (Func<IGameModeHandler, IEnumerator>)ClearWorld);
			GameModeManager.AddHook("PointStart", (Func<IGameModeHandler, IEnumerator>)OnPointStart);
			GameModeManager.AddHook("PointEnd", (Func<IGameModeHandler, IEnumerator>)ClearWorld);
			GameModeManager.AddHook("RoundEnd", (Func<IGameModeHandler, IEnumerator>)ClearWorld);
		}

		private static IEnumerator ClearWorld(IGameModeHandler gm)
		{
			Hazards.ClearAll();
			GunController.ResetAll();
			yield break;
		}

		private static IEnumerator OnPointStart(IGameModeHandler gm)
		{
			Hazards.ClearAll();
			GunController.ResetAll();
			Loadout.EnforceMagazines();
			yield break;
		}

		internal static void Log(string message)
		{
			if ((Object)(object)Instance != (Object)null)
			{
				((BaseUnityPlugin)Instance).Logger.LogInfo((object)message);
			}
		}

		internal static void Warn(string message)
		{
			if ((Object)(object)Instance != (Object)null)
			{
				((BaseUnityPlugin)Instance).Logger.LogWarning((object)message);
			}
		}
	}
	internal static class VeryRare
	{
		internal const string Name = "Very Rare";

		internal const float Weight = 0.04f;

		private static bool _resolved;

		private static Rarity _value = (Rarity)2;

		internal static Rarity Value
		{
			get
			{
				//IL_000a: 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_006e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0073: Unknown result type (might be due to invalid IL or missing references)
				//IL_0074: 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_007b: Unknown result type (might be due to invalid IL or missing references)
				if (_resolved)
				{
					return _value;
				}
				try
				{
					Type type = AccessTools.TypeByName("RarityLib.Utils.RarityUtils");
					MethodInfo methodInfo = ((!(type == null)) ? AccessTools.Method(type, "GetRarity", new Type[1] { typeof(string) }, (Type[])null) : null);
					if (methodInfo != null)
					{
						Rarity val = (Rarity)methodInfo.Invoke(null, new object[1] { "Very Rare" });
						if ((int)val != 0)
						{
							_value = val;
						}
					}
					_resolved = true;
				}
				catch
				{
				}
				return _value;
			}
		}

		internal static void Register()
		{
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Type type = AccessTools.TypeByName("RarityLib.Utils.RarityUtils");
				MethodInfo methodInfo = ((!(type == null)) ? AccessTools.Method(type, "AddRarity", new Type[4]
				{
					typeof(string),
					typeof(float),
					typeof(Color),
					typeof(Color)
				}, (Type[])null) : null);
				if (methodInfo == null)
				{
					Plugin.Warn("RarityLib not found; Very Rare cards fall back to Rare.");
					return;
				}
				methodInfo.Invoke(null, new object[4]
				{
					"Very Rare",
					0.04f,
					(object)new Color(1f, 0.45f, 0.05f),
					(object)new Color(0.55f, 0.25f, 0.05f)
				});
			}
			catch (Exception ex)
			{
				Plugin.Warn("Could not register Very Rare: " + ex.Message);
			}
		}
	}
}
namespace CodyGunCards.Runtime
{
	internal sealed class CodyBullet : MonoBehaviour
	{
		internal Player Owner;

		internal Weapon Weapons;

		internal bool Planted;

		internal bool Popped;

		internal float Born;

		private ProjectileHit _hit;

		internal float BaseDamage
		{
			get
			{
				float num = ((!((Object)(object)_hit != (Object)null)) ? 0f : _hit.damage);
				return (!(num > 0.5f)) ? Util.BulletDamage(Util.GunOf(Owner)) : num;
			}
		}

		internal void Init(Player owner, Weapon w)
		{
			Owner = owner;
			Weapons = w;
			Born = Time.time;
			_hit = ((Component)this).GetComponent<ProjectileHit>();
			if ((Object)(object)_hit == (Object)null)
			{
				_hit = ((Component)this).GetComponentInChildren<ProjectileHit>();
			}
			if ((Object)(object)_hit != (Object)null)
			{
				if ((w & Weapon.SplitterPods) != Weapon.None)
				{
					_hit.dealDamageMultiplierr = 0f;
				}
				else if ((w & Weapon.Mines) != Weapon.None)
				{
					ProjectileHit hit = _hit;
					hit.dealDamageMultiplierr *= 0.5f;
				}
			}
		}

		private void Update()
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			if (!Popped && (Weapons & Weapon.SplitterPods) != Weapon.None && !((double)(Time.time - Born) < 0.8))
			{
				Pop(Vector2.op_Implicit(((Component)this).transform.position), Vector2.up);
			}
		}

		internal void Pop(Vector2 at, Vector2 normal)
		{
			//IL_001a: 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)
			if (!Popped)
			{
				Popped = true;
				Hazards.Spawn(HazardKind.Shards, Owner, at, normal, Vector2.zero, BaseDamage);
			}
		}
	}
	internal static class Payload
	{
		internal const float ChainRange = 8f;

		internal static Player ChainTarget(Player owner, Player exclude, Vector2 from)
		{
			//IL_0065: 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_0070: 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)
			if ((Object)(object)PlayerManager.instance == (Object)null)
			{
				return null;
			}
			Player result = null;
			float num = 64f;
			foreach (Player player in PlayerManager.instance.players)
			{
				if (Util.Alive(player) && !((Object)(object)player == (Object)(object)exclude) && Util.IsEnemy(owner, player))
				{
					Vector2 val = Vector2.op_Implicit(((Component)player).transform.position) - from;
					float sqrMagnitude = ((Vector2)(ref val)).sqrMagnitude;
					if (sqrMagnitude < num)
					{
						num = sqrMagnitude;
						result = player;
					}
				}
			}
			return result;
		}

		internal static Vector2 PullForce(Vector2 from, Vector2 to)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_005a: 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)
			Vector2 val = to - from;
			float magnitude = ((Vector2)(ref val)).magnitude;
			if (magnitude < 0.01f)
			{
				return Vector2.zero;
			}
			Vector2 val2 = val / magnitude + Vector2.up * 0.25f;
			return ((Vector2)(ref val2)).normalized * Mathf.Clamp(magnitude * 650f, 3000f, 9000f);
		}

		internal static void OnProjectileHit(ProjectileHit ph, Vector2 point, Vector2 normal, Vector2 vel, int viewID, bool blocked)
		{
			//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)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0294: Unknown result type (might be due to invalid IL or missing references)
			//IL_0295: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0205: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: 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_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_022e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_026f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0274: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)ph == (Object)null || (Object)(object)ph.ownPlayer == (Object)null || blocked)
			{
				return;
			}
			Player ownPlayer = ph.ownPlayer;
			Weapon weapon = Loadout.Of(ownPlayer);
			if (weapon == Weapon.None)
			{
				return;
			}
			CodyBullet codyBullet = ((Component)ph).GetComponent<CodyBullet>();
			if ((Object)(object)codyBullet == (Object)null)
			{
				codyBullet = ((Component)ph).gameObject.AddComponent<CodyBullet>();
				codyBullet.Init(ownPlayer, weapon);
				codyBullet.Popped = (weapon & Weapon.SplitterPods) == 0;
			}
			float baseDamage = codyBullet.BaseDamage;
			bool flag = Util.IsAuthority();
			Player val = null;
			if (viewID > 0)
			{
				PhotonView photonView = PhotonNetwork.GetPhotonView(viewID);
				if ((Object)(object)photonView != (Object)null)
				{
					val = ((Component)photonView).GetComponentInParent<Player>() ?? ((Component)photonView).GetComponentInChildren<Player>();
				}
			}
			if ((Object)(object)val == (Object)(object)ownPlayer)
			{
				val = null;
			}
			if ((Object)(object)val != (Object)null)
			{
				if ((weapon & Weapon.Harpoon) != Weapon.None)
				{
					Fx.FlashLine(Vector2.op_Implicit(((Component)ownPlayer).transform.position), Vector2.op_Implicit(((Component)val).transform.position), 0.08f, new Color(0.75f, 0.6f, 0.4f, 1f), 0.3f);
					if (flag)
					{
						Util.Push(val, PullForce(Vector2.op_Implicit(((Component)val).transform.position), Vector2.op_Implicit(((Component)ownPlayer).transform.position)), 0.6f);
					}
				}
				if ((weapon & Weapon.LightningArc) != Weapon.None)
				{
					Player val2 = ChainTarget(ownPlayer, val, Vector2.op_Implicit(((Component)val).transform.position));
					if ((Object)(object)val2 != (Object)null)
					{
						Fx.Lightning(Vector2.op_Implicit(((Component)val).transform.position), Vector2.op_Implicit(((Component)val2).transform.position), 0.2f);
						if (flag)
						{
							Util.Damage(val2, baseDamage * 0.6f, Vector2.op_Implicit(((Component)val).transform.position), ownPlayer);
						}
					}
				}
			}
			else if (!codyBullet.Planted)
			{
				codyBullet.Planted = true;
				if ((weapon & (Weapon.Mines | Weapon.RemoteCharges)) != Weapon.None)
				{
					Hazards.Spawn(HazardKind.Charge, ownPlayer, point, normal, vel, baseDamage);
				}
				if ((weapon & Weapon.Sawblade) != Weapon.None)
				{
					Hazards.Spawn(HazardKind.Saw, ownPlayer, point, normal, vel, baseDamage);
				}
				if ((weapon & Weapon.Harpoon) != Weapon.None)
				{
					Fx.FlashLine(Vector2.op_Implicit(((Component)ownPlayer).transform.position), point, 0.08f, new Color(0.75f, 0.6f, 0.4f, 1f), 0.3f);
					if (flag)
					{
						Util.Push(ownPlayer, PullForce(Vector2.op_Implicit(((Component)ownPlayer).transform.position), point), 0.5f);
					}
				}
			}
			if ((weapon & Weapon.GravityWell) != Weapon.None)
			{
				Hazards.Spawn(HazardKind.Well, ownPlayer, point, normal, vel, baseDamage);
			}
			if ((weapon & Weapon.SplitterPods) != Weapon.None)
			{
				codyBullet.Pop(point, normal);
			}
		}

		internal static void OnRayPlayer(Player owner, Weapon w, Player victim, float dealt, bool continuous)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: 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)
			//IL_0046: 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_003c: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: 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_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			if ((w & Weapon.Harpoon) != Weapon.None)
			{
				Vector2 val = PullForce(Vector2.op_Implicit(((Component)victim).transform.position), Vector2.op_Implicit(((Component)owner).transform.position));
				Util.Push(victim, (!continuous) ? val : (val * 0.12f), (!continuous) ? 0.6f : 0.1f);
			}
			if ((w & Weapon.LightningArc) != Weapon.None)
			{
				Player val2 = ChainTarget(owner, victim, Vector2.op_Implicit(((Component)victim).transform.position));
				if ((Object)(object)val2 != (Object)null)
				{
					Util.Damage(val2, dealt * 0.6f, Vector2.op_Implicit(((Component)victim).transform.position), owner);
					NetworkingManager.RPC(typeof(Net), "RPCA_Arc", new object[4]
					{
						((Component)victim).transform.position.x,
						((Component)victim).transform.position.y,
						((Component)val2).transform.position.x,
						((Component)val2).transform.position.y
					});
				}
			}
		}

		internal static void OnRayTerrain(Player owner, Weapon w, Vector2 point, Vector2 normal, Vector2 dir, float dmg, RayTimers timers, bool continuous)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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_004f: 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)
			//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_009b: 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_009d: 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_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			float time = Time.time;
			float interval = 0.5f;
			if ((w & (Weapon.Mines | Weapon.RemoteCharges)) != Weapon.None && timers.Ready(0, time, interval))
			{
				Net.SendSpawn(HazardKind.Charge, owner, point, normal, dir, dmg);
			}
			if ((w & Weapon.Sawblade) != Weapon.None && timers.Ready(1, time, interval))
			{
				Net.SendSpawn(HazardKind.Saw, owner, point, normal, dir, dmg);
			}
			if ((w & Weapon.GravityWell) != Weapon.None && timers.Ready(2, time, interval))
			{
				Net.SendSpawn(HazardKind.Well, owner, point, normal, dir, dmg);
			}
			if ((w & Weapon.SplitterPods) != Weapon.None && timers.Ready(3, time, 0.8f))
			{
				Net.SendSpawn(HazardKind.Shards, owner, point, normal, dir, dmg);
			}
			if ((w & Weapon.Harpoon) != Weapon.None && timers.Ready(4, time, (!continuous) ? 0f : 0.1f))
			{
				Vector2 val = PullForce(Vector2.op_Implicit(((Component)owner).transform.position), point);
				Util.Push(owner, (!continuous) ? val : (val * 0.12f), (!continuous) ? 0.5f : 0.1f);
				if (!continuous)
				{
					NetworkingManager.RPC(typeof(Net), "RPCA_Rope", new object[4]
					{
						((Component)owner).transform.position.x,
						((Component)owner).transform.position.y,
						point.x,
						point.y
					});
				}
			}
		}
	}
	internal sealed class RayTimers
	{
		private readonly float[] _next = new float[8];

		internal bool Ready(int slot, float now, float interval)
		{
			if (now < _next[slot])
			{
				return false;
			}
			_next[slot] = now + interval;
			return true;
		}

		internal void Reset()
		{
			for (int i = 0; i < _next.Length; i++)
			{
				_next[i] = 0f;
			}
		}
	}
	[HarmonyPatch(typeof(Gun), "BulletInit")]
	internal static class BulletInitPatch
	{
		private static void Postfix(Gun __instance, GameObject bullet)
		{
			try
			{
				if (!((Object)(object)bullet == (Object)null) && !((Object)(object)__instance == (Object)null) && !((Object)(object)__instance.player == (Object)null))
				{
					Weapon weapon = Loadout.Of(__instance.player);
					if (weapon != Weapon.None)
					{
						CodyBullet codyBullet = bullet.GetComponent<CodyBullet>() ?? bullet.AddComponent<CodyBullet>();
						codyBullet.Init(__instance.player, weapon);
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Warn("BulletInit: " + ex.Message);
			}
		}
	}
	[HarmonyPatch(typeof(ProjectileHit), "RPCA_DoHit")]
	internal static class DoHitPatch
	{
		private static void Postfix(ProjectileHit __instance, Vector2 hitPoint, Vector2 hitNormal, Vector2 vel, int viewID, bool wasBlocked)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Payload.OnProjectileHit(__instance, hitPoint, hitNormal, vel, viewID, wasBlocked);
			}
			catch (Exception ex)
			{
				Plugin.Warn("DoHit: " + ex.Message);
			}
		}
	}
	[HarmonyPatch(typeof(Block), "RPCA_DoBlock")]
	internal static class BlockPatch
	{
		private static void Postfix(Block __instance)
		{
			try
			{
				Player componentInParent = ((Component)__instance).GetComponentInParent<Player>();
				if ((Object)(object)componentInParent != (Object)null && Loadout.Has(componentInParent, Weapon.RemoteCharges))
				{
					Hazards.DetonateRemote(componentInParent);
				}
			}
			catch (Exception ex)
			{
				Plugin.Warn("Block: " + ex.Message);
			}
		}
	}
	[HarmonyPatch(typeof(Gun), "Attack")]
	internal static class AttackPatch
	{
		internal static bool Passthrough;

		internal static float PassthroughDamage = 1f;

		private static bool Prefix(Gun __instance, ref bool __result, ref float damageM)
		{
			try
			{
				if (Passthrough)
				{
					damageM *= PassthroughDamage;
					return true;
				}
				Player player = __instance.player;
				if ((Object)(object)player == (Object)null)
				{
					return true;
				}
				Weapon weapon = Loadout.Of(player);
				if ((weapon & (Weapon.Laser | Weapon.Railgun | Weapon.ChargeCannon)) == 0)
				{
					return true;
				}
				if (!Util.IsMine(player))
				{
					return true;
				}
				GunController gunController = GunController.Ensure(player);
				if ((Object)(object)gunController == (Object)null)
				{
					return true;
				}
				if (gunController.HandleAttack(__instance, weapon))
				{
					return true;
				}
				__result = false;
				return false;
			}
			catch (Exception ex)
			{
				Plugin.Warn("Attack: " + ex.Message);
				return true;
			}
		}
	}
	internal static class CardArt
	{
		private static readonly Dictionary<string, GameObject> Cache = new Dictionary<string, GameObject>();

		internal static GameObject Create(string name)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: 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_00d4: 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)
			if (Cache.TryGetValue(name, out var value) && (Object)(object)value != (Object)null)
			{
				return value;
			}
			try
			{
				Sprite val = LoadSprite(name);
				if ((Object)(object)val == (Object)null)
				{
					return null;
				}
				GameObject val2 = new GameObject("CGC_Art_" + name, new Type[1] { typeof(RectTransform) });
				Object.DontDestroyOnLoad((Object)(object)val2);
				Image val3 = val2.AddComponent<Image>();
				val3.sprite = val;
				val3.preserveAspect = true;
				((Graphic)val3).raycastTarget = false;
				((Graphic)val3).color = Color.white;
				RectTransform component = val2.GetComponent<RectTransform>();
				component.anchorMin = Vector2.zero;
				component.anchorMax = Vector2.one;
				component.pivot = new Vector2(0.5f, 0.5f);
				component.offsetMin = Vector2.zero;
				component.offsetMax = Vector2.zero;
				((Transform)component).localScale = Vector3.one;
				Cache[name] = val2;
				return val2;
			}
			catch (Exception ex)
			{
				Plugin.Warn("Card art '" + name + "' failed: " + ex.Message);
				return null;
			}
		}

		private static Sprite LoadSprite(string name)
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			//IL_00d2: 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)
			Assembly assembly = typeof(CardArt).Assembly;
			using Stream stream = assembly.GetManifestResourceStream("CodyGunCards.Art." + name + ".png");
			if (stream == null)
			{
				Plugin.Warn("Missing embedded art " + name);
				return null;
			}
			byte[] array = new byte[stream.Length];
			int num;
			for (int i = 0; i < array.Length; i += num)
			{
				num = stream.Read(array, i, array.Length - i);
				if (num <= 0)
				{
					break;
				}
			}
			Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
			if (!ImageConversion.LoadImage(val, array))
			{
				return null;
			}
			((Texture)val).filterMode = (FilterMode)1;
			Object.DontDestroyOnLoad((Object)(object)val);
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f), 100f);
		}
	}
	internal enum HazardKind
	{
		Charge = 1,
		Saw,
		Well,
		Shards
	}
	internal static class Hazards
	{
		internal const float ChargeArm = 0.4f;

		internal const float ChargeTrigger = 1.3f;

		internal const float BlastRadius = 2.8f;

		internal const float SawRadius = 0.9f;

		internal const float SawSpeed = 9f;

		internal const float WellRadius = 7f;

		internal const float WellBurstRadius = 2.6f;

		internal const int SawCap = 6;

		internal const int WellCap = 3;

		internal static readonly List<Hazard> Live = new List<Hazard>();

		internal static void ClearAll()
		{
			for (int num = Live.Count - 1; num >= 0; num--)
			{
				if ((Object)(object)Live[num] != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)Live[num]).gameObject);
				}
			}
			Live.Clear();
			Shard[] array = Object.FindObjectsOfType<Shard>();
			foreach (Shard shard in array)
			{
				if ((Object)(object)shard != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)shard).gameObject);
				}
			}
		}

		internal static void Spawn(HazardKind kind, Player owner, Vector2 pos, Vector2 normal, Vector2 dir, float damage)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Expected O, but got Unknown
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: 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_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Expected O, but got Unknown
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00a9: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)owner == (Object)null)
			{
				return;
			}
			if (((Vector2)(ref normal)).sqrMagnitude < 0.01f)
			{
				normal = Vector2.up;
			}
			((Vector2)(ref normal)).Normalize();
			switch (kind)
			{
			case HazardKind.Charge:
			{
				Weapon weapon = Loadout.Of(owner);
				bool flag = (weapon & Weapon.Mines) != 0;
				bool flag2 = (weapon & Weapon.RemoteCharges) != 0;
				if (flag || flag2)
				{
					Cap(owner.playerID, HazardKind.Charge, Rules.HazardLimit(weapon));
					GameObject val3 = new GameObject("CGC_Charge");
					val3.transform.position = Vector2.op_Implicit(pos + normal * 0.15f);
					val3.AddComponent<ChargeHazard>().Init(owner, damage, flag, flag2);
				}
				break;
			}
			case HazardKind.Saw:
			{
				Cap(owner.playerID, HazardKind.Saw, 6);
				GameObject val2 = new GameObject("CGC_Saw");
				val2.transform.position = Vector2.op_Implicit(pos + normal * 0.35f);
				val2.AddComponent<SawHazard>().Init(owner, damage, normal, dir);
				break;
			}
			case HazardKind.Well:
			{
				Cap(owner.playerID, HazardKind.Well, 3);
				GameObject val = new GameObject("CGC_Well");
				val.transform.position = Vector2.op_Implicit(pos + normal * 0.3f);
				val.AddComponent<WellHazard>().Init(owner, damage);
				break;
			}
			case HazardKind.Shards:
				Shard.Spray(owner, pos + normal * 0.2f, damage);
				break;
			}
		}

		private static void Cap(int ownerId, HazardKind kind, int max)
		{
			int num = 0;
			for (int num2 = Live.Count - 1; num2 >= 0; num2--)
			{
				if ((Object)(object)Live[num2] != (Object)null && Live[num2].OwnerId == ownerId && Live[num2].Kind == kind)
				{
					num++;
				}
			}
			for (int i = 0; i < Live.Count; i++)
			{
				if (num < max)
				{
					break;
				}
				Hazard hazard = Live[i];
				if (!((Object)(object)hazard == (Object)null) && hazard.OwnerId == ownerId && hazard.Kind == kind)
				{
					hazard.Remove();
					num--;
					i--;
				}
			}
		}

		internal static void ConsumeNear(int ownerId, Vector2 pos)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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_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)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			ChargeHazard chargeHazard = null;
			float num = 2.25f;
			foreach (Hazard item in Live)
			{
				ChargeHazard chargeHazard2 = item as ChargeHazard;
				if (!((Object)(object)chargeHazard2 == (Object)null) && chargeHazard2.OwnerId == ownerId)
				{
					Vector2 val = Vector2.op_Implicit(((Component)chargeHazard2).transform.position) - pos;
					float sqrMagnitude = ((Vector2)(ref val)).sqrMagnitude;
					if (sqrMagnitude < num)
					{
						num = sqrMagnitude;
						chargeHazard = chargeHazard2;
					}
				}
			}
			if ((Object)(object)chargeHazard != (Object)null)
			{
				chargeHazard.Explode();
			}
			else
			{
				Fx.Burst(pos, 2.8f, new Color(1f, 0.4f, 0.1f, 0.9f));
			}
		}

		internal static void DetonateRemote(Player owner)
		{
			if ((Object)(object)owner == (Object)null)
			{
				return;
			}
			List<ChargeHazard> list = new List<ChargeHazard>();
			foreach (Hazard item in Live)
			{
				ChargeHazard chargeHazard = item as ChargeHazard;
				if ((Object)(object)chargeHazard != (Object)null && chargeHazard.OwnerId == owner.playerID && chargeHazard.Remote && chargeHazard.Armed)
				{
					list.Add(chargeHazard);
				}
			}
			foreach (ChargeHazard item2 in list)
			{
				item2.Explode();
			}
		}

		internal static void BlastDamage(Player owner, Vector2 at, float radius, float amount)
		{
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: 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_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			if (!Util.IsAuthority() || (Object)(object)PlayerManager.instance == (Object)null)
			{
				return;
			}
			foreach (Player player in PlayerManager.instance.players)
			{
				if (Util.Alive(player) && Util.IsEnemy(owner, player))
				{
					Vector2 val = Vector2.op_Implicit(((Component)player).transform.position) - at;
					if (!(((Vector2)(ref val)).sqrMagnitude > radius * radius))
					{
						Util.Damage(player, amount, at, owner);
						Vector2 val2 = ((!(((Vector2)(ref val)).sqrMagnitude < 0.01f)) ? ((Vector2)(ref val)).normalized : Vector2.up);
						Vector2 val3 = val2 + Vector2.up * 0.4f;
						Util.Push(player, ((Vector2)(ref val3)).normalized * 4500f, 0.4f);
					}
				}
			}
		}
	}
	internal abstract class Hazard : MonoBehaviour
	{
		internal Player Owner;

		internal int OwnerId;

		internal float Damage;

		internal float Born;

		internal abstract HazardKind Kind { get; }

		protected void Register(Player owner, float damage)
		{
			Owner = owner;
			OwnerId = owner.playerID;
			Damage = damage;
			Born = Time.time;
			Hazards.Live.Add(this);
		}

		internal void Remove()
		{
			Hazards.Live.Remove(this);
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

		protected virtual void OnDestroy()
		{
			Hazards.Live.Remove(this);
		}
	}
	internal sealed class ChargeHazard : Hazard
	{
		internal bool Proximity;

		internal bool Remote;

		private bool _done;

		private bool _requested;

		private SpriteRenderer _body;

		private SpriteRenderer _light;

		internal override HazardKind Kind => HazardKind.Charge;

		internal bool Armed => !_done && Time.time - Born >= 0.4f;

		internal void Init(Player owner, float damage, bool prox, bool remote)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			Register(owner, damage);
			Proximity = prox;
			Remote = remote;
			_body = Fx.MakeSprite("body", Fx.Disc, (!remote || prox) ? new Color(0.3f, 0.3f, 0.32f) : new Color(0.95f, 0.55f, 0.1f), 5);
			((Component)_body).transform.SetParent(((Component)this).transform, false);
			((Component)_body).transform.localScale = Vector3.one * 0.55f;
			_light = Fx.MakeSprite("light", Fx.Disc, Color.red, 6);
			((Component)_light).transform.SetParent(((Component)this).transform, false);
			((Component)_light).transform.localScale = Vector3.one * 0.22f;
		}

		private void Update()
		{
			//IL_0076: 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_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: 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_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			if (_done || (Object)(object)_light == (Object)null)
			{
				return;
			}
			float num = Time.time - Born;
			bool flag = !Armed || Mathf.PingPong(num * 3f, 1f) > 0.5f;
			_light.color = (Color)((!Armed) ? new Color(1f, 0.9f, 0.2f, 0.8f) : ((!flag) ? new Color(0.35f, 0f, 0f, 1f) : Color.red));
			if (!Proximity || !Armed || _requested || !Util.IsAuthority() || (Object)(object)PlayerManager.instance == (Object)null)
			{
				return;
			}
			foreach (Player player in PlayerManager.instance.players)
			{
				if (Util.Alive(player) && Util.IsEnemy(Owner, player))
				{
					Vector2 val = Vector2.op_Implicit(((Component)player).transform.position) - Vector2.op_Implicit(((Component)this).transform.position);
					if (!(((Vector2)(ref val)).sqrMagnitude > 1.6899998f))
					{
						_requested = true;
						NetworkingManager.RPC(typeof(Net), "RPCA_Consume", new object[3]
						{
							OwnerId,
							((Component)this).transform.position.x,
							((Component)this).transform.position.y
						});
						break;
					}
				}
			}
		}

		internal void Explode()
		{
			//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_003c: 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)
			if (!_done)
			{
				_done = true;
				Fx.Burst(Vector2.op_Implicit(((Component)this).transform.position), 2.8f, new Color(1f, 0.45f, 0.1f, 0.95f));
				Hazards.BlastDamage(Owner, Vector2.op_Implicit(((Component)this).transform.position), 2.8f, Damage * 1.25f);
				Remove();
			}
		}
	}
	internal sealed class SawHazard : Hazard
	{
		private Vector2 _normal;

		private Vector2 _tangent;

		private float _fall;

		private Transform _spin;

		private readonly Dictionary<int, float> _lastHit = new Dictionary<int, float>();

		internal override HazardKind Kind => HazardKind.Saw;

		internal void Init(Player owner, float damage, Vector2 normal, Vector2 dir)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: 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_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			Register(owner, damage);
			_normal = normal;
			_tangent = new Vector2(normal.y, 0f - normal.x);
			if (Vector2.Dot(_tangent, dir) < 0f)
			{
				_tangent = -_tangent;
			}
			SpriteRenderer val = Fx.MakeSprite("blade", Fx.Saw, Color.white, 5);
			((Component)val).transform.SetParent(((Component)this).transform, false);
			((Component)val).transform.localScale = Vector3.one * 0.9f;
			_spin = ((Component)val).transform;
		}

		private void Update()
		{
			//IL_004a: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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_0072: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: 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_010a: 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_0114: 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_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: 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_0145: 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)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0243: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_025f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0312: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0321: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_042c: Unknown result type (might be due to invalid IL or missing references)
			float deltaTime = Time.deltaTime;
			if ((double)(Time.time - Born) > 4.0)
			{
				Remove();
				return;
			}
			_spin.Rotate(0f, 0f, -720f * deltaTime);
			Vector2 val = Vector2.op_Implicit(((Component)this).transform.position);
			float num = 9f * deltaTime;
			int groundMask = Util.GroundMask;
			RaycastHit2D val2 = Physics2D.Raycast(val, _tangent, 0.45f + num, groundMask);
			if (RaycastHit2D.op_Implicit(val2) && (Object)(object)((RaycastHit2D)(ref val2)).collider != (Object)null && (Object)(object)Util.PlayerFromCollider(((RaycastHit2D)(ref val2)).collider) == (Object)null)
			{
				Vector2 normal = ((RaycastHit2D)(ref val2)).normal;
				Vector2 val3 = default(Vector2);
				((Vector2)(ref val3))..ctor(normal.y, 0f - normal.x);
				if (Vector2.Dot(val3, _normal) < 0f)
				{
					val3 = -val3;
				}
				_normal = normal;
				_tangent = ((Vector2)(ref val3)).normalized;
			}
			Vector2 val4 = val + _tangent * num;
			RaycastHit2D val5 = Physics2D.Raycast(val4 + _normal * 0.2f, -_normal, 0.9f, groundMask);
			if (RaycastHit2D.op_Implicit(val5) && (Object)(object)((RaycastHit2D)(ref val5)).collider != (Object)null && (Object)(object)Util.PlayerFromCollider(((RaycastHit2D)(ref val5)).collider) == (Object)null)
			{
				_fall = 0f;
				Vector2 normal2 = ((RaycastHit2D)(ref val5)).normal;
				Vector2 val6 = default(Vector2);
				((Vector2)(ref val6))..ctor(normal2.y, 0f - normal2.x);
				if (Vector2.Dot(val6, _tangent) < 0f)
				{
					val6 = -val6;
				}
				_normal = normal2;
				_tangent = ((Vector2)(ref val6)).normalized;
				val4 = ((RaycastHit2D)(ref val5)).point + normal2 * 0.35f;
			}
			else
			{
				_fall += 25f * deltaTime;
				val4 = val + _tangent * num * 0.5f + Vector2.down * _fall * deltaTime;
				RaycastHit2D val7 = Physics2D.Raycast(val, Vector2.down, 0.4f + _fall * deltaTime, groundMask);
				if (RaycastHit2D.op_Implicit(val7) && (Object)(object)((RaycastHit2D)(ref val7)).collider != (Object)null && (Object)(object)Util.PlayerFromCollider(((RaycastHit2D)(ref val7)).collider) == (Object)null)
				{
					_normal = ((RaycastHit2D)(ref val7)).normal;
					_tangent = new Vector2(_normal.y, 0f - _normal.x) * ((!(Vector2.Dot(new Vector2(_normal.y, 0f - _normal.x), _tangent) < 0f)) ? 1f : (-1f));
					val4 = ((RaycastHit2D)(ref val7)).point + _normal * 0.35f;
					_fall = 0f;
				}
			}
			((Component)this).transform.position = Vector2.op_Implicit(val4);
			if (!Util.IsAuthority() || (Object)(object)PlayerManager.instance == (Object)null)
			{
				return;
			}
			foreach (Player player in PlayerManager.instance.players)
			{
				if (Util.Alive(player) && Util.IsEnemy(Owner, player))
				{
					Vector2 val8 = Vector2.op_Implicit(((Component)player).transform.position) - val4;
					if (!(((Vector2)(ref val8)).sqrMagnitude > 1.9599999f) && (!_lastHit.TryGetValue(player.playerID, out var value) || !((double)(Time.time - value) < 0.25)))
					{
						_lastHit[player.playerID] = Time.time;
						Util.Damage(player, Damage * 0.4f, val4, Owner);
					}
				}
			}
		}
	}
	internal sealed class WellHazard : Hazard
	{
		private float _nextPull;

		private SpriteRenderer _core;

		private SpriteRenderer _ring;

		internal override HazardKind Kind => HazardKind.Well;

		internal void Init(Player owner, float damage)
		{
			//IL_0027: 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_0063: 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)
			Register(owner, damage);
			_core = Fx.MakeSprite("core", Fx.Disc, new Color(0.45f, 0.1f, 0.8f, 0.9f), 5);
			((Component)_core).transform.SetParent(((Component)this).transform, false);
			((Component)_core).transform.localScale = Vector3.one * 0.8f;
			_ring = Fx.MakeSprite("ring", Fx.Ring, new Color(0.7f, 0.4f, 1f, 0.6f), 5);
			((Component)_ring).transform.SetParent(((Component)this).transform, false);
		}

		private void Update()
		{
			//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_0023: 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_0089: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0228: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: 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)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			float num = Time.time - Born;
			float num2 = 0.5f;
			Vector2 val = Vector2.op_Implicit(((Component)this).transform.position);
			float num3 = Mathf.Lerp(14f, 0.5f, Mathf.Repeat(num * 4f, 1f));
			((Component)_ring).transform.localScale = new Vector3(num3, num3, 1f);
			MoveTransform[] array = Object.FindObjectsOfType<MoveTransform>();
			foreach (MoveTransform val2 in array)
			{
				if (!((Object)(object)val2 == (Object)null))
				{
					Vector2 val3 = val - Vector2.op_Implicit(((Component)val2).transform.position);
					float magnitude = ((Vector2)(ref val3)).magnitude;
					if (!(magnitude > 7f) && !(magnitude < 0.05f))
					{
						val2.velocity += Vector2.op_Implicit(val3 / magnitude * 140f * Time.deltaTime);
					}
				}
			}
			if (Util.IsAuthority() && Time.time >= _nextPull && (Object)(object)PlayerManager.instance != (Object)null)
			{
				_nextPull = Time.time + 0.1f;
				foreach (Player player in PlayerManager.instance.players)
				{
					if (Util.Alive(player))
					{
						Vector2 val4 = val - Vector2.op_Implicit(((Component)player).transform.position);
						float magnitude2 = ((Vector2)(ref val4)).magnitude;
						if (!(magnitude2 > 7f) && !(magnitude2 < 0.3f))
						{
							Util.Push(player, val4 / magnitude2 * Mathf.Lerp(2200f, 900f, magnitude2 / 7f), 0.15f);
						}
					}
				}
			}
			if (num >= num2)
			{
				Fx.Burst(val, 2.6f, new Color(0.75f, 0.4f, 1f, 0.95f));
				Hazards.BlastDamage(Owner, val, 2.6f, Damage * 0.5f);
				Remove();
			}
		}
	}
	internal sealed class Shard : MonoBehaviour
	{
		private Player _owner;

		private float _damage;

		private float _born;

		private Vector2 _vel;

		private SpriteRenderer _sr;

		private const float Speed = 24f;

		private const float Life = 0.6f;

		internal static void Spray(Player owner, Vector2 at, float parentDamage)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//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_0069: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			int num = 6;
			float num2 = Random.Range(0f, 360f / (float)num);
			for (int i = 0; i < num; i++)
			{
				float num3 = (num2 + (float)i * 360f / (float)num) * ((float)Math.PI / 180f);
				GameObject val = new GameObject("CGC_Shard");
				val.transform.position = Vector2.op_Implicit(at);
				val.AddComponent<Shard>().Init(owner, parentDamage * 0.25f, new Vector2(Mathf.Cos(num3), Mathf.Sin(num3)));
			}
			Fx.Burst(at, 1.2f, new Color(0.3f, 1f, 0.5f, 0.9f));
		}

		private void Init(Player owner, float damage, Vector2 dir)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: 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)
			_owner = owner;
			_damage = damage;
			_vel = dir * 24f;
			_born = Time.time;
			_sr = Fx.MakeSprite("shard", Fx.Disc, new Color(0.4f, 1f, 0.55f, 1f), 6);
			((Component)_sr).transform.SetParent(((Component)this).transform, false);
			((Component)_sr).transform.localScale = Vector3.one * 0.3f;
		}

		private void Update()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: 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_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: 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_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: 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_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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			if (Time.time - _born > 0.6f)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			Vector2 val = Vector2.op_Implicit(((Component)this).transform.position);
			Vector2 val2 = _vel * Time.deltaTime;
			if ((Object)(object)PlayerManager.instance != (Object)null)
			{
				foreach (Player player in PlayerManager.instance.players)
				{
					if (!Util.Alive(player) || !Util.IsEnemy(_owner, player))
					{
						continue;
					}
					Vector2 p = Vector2.op_Implicit(((Component)player).transform.position);
					if (DistToSegment(p, val, val + val2) > 0.8f)
					{
						continue;
					}
					if (Util.IsAuthority())
					{
						Util.Damage(player, _damage, val, _owner);
					}
					Object.Destroy((Object)(object)((Component)this).gameObject);
					return;
				}
			}
			RaycastHit2D val3 = Physics2D.Raycast(val, ((Vector2)(ref val2)).normalized, ((Vector2)(ref val2)).magnitude, Util.GroundMask);
			if (RaycastHit2D.op_Implicit(val3) && (Object)(object)((RaycastHit2D)(ref val3)).collider != (Object)null && (Object)(object)Util.PlayerFromCollider(((RaycastHit2D)(ref val3)).collider) == (Object)null)
			{
				if (Util.IsAuthority() && (Loadout.Of(_owner) & (Weapon.Mines | Weapon.RemoteCharges)) != Weapon.None)
				{
					Net.SendSpawn(HazardKind.Charge, _owner, ((RaycastHit2D)(ref val3)).point, ((RaycastHit2D)(ref val3)).normal, _vel, _damage / 0.25f);
				}
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
			else
			{
				((Component)this).transform.position = Vector2.op_Implicit(val + val2);
			}
		}

		private static float DistToSegment(Vector2 p, Vector2 a, Vector2 b)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: 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_003e: 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_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = b - a;
			float num = ((!(((Vector2)(ref val)).sqrMagnitude < 1E-06f)) ? Mathf.Clamp01(Vector2.Dot(p - a, val) / ((Vector2)(ref val)).sqrMagnitude) : 0f);
			Vector2 val2 = p - (a + val * num);
			return ((Vector2)(ref val2)).magnitude;
		}
	}
	public static class Net
	{
		internal static void SendSpawn(HazardKind kind, Player owner, Vector2 pos, Vector2 normal, Vector2 dir, float damage)
		{
			if (!((Object)(object)owner == (Object)null))
			{
				NetworkingManager.RPC(typeof(Net), "RPCA_Spawn", new object[9]
				{
					(int)kind,
					owner.playerID,
					pos.x,
					pos.y,
					normal.x,
					normal.y,
					dir.x,
					dir.y,
					damage
				});
			}
		}

		[UnboundRPC]
		public static void RPCA_Spawn(int kind, int ownerId, float x, float y, float nx, float ny, float dx, float dy, float damage)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			Hazards.Spawn((HazardKind)kind, Util.PlayerById(ownerId), new Vector2(x, y), new Vector2(nx, ny), new Vector2(dx, dy), damage);
		}

		[UnboundRPC]
		public static void RPCA_Consume(int ownerId, float x, float y)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			Hazards.ConsumeNear(ownerId, new Vector2(x, y));
		}

		[UnboundRPC]
		public static void RPCA_Beam(int playerId, float windup, float duration, float dps, bool pierce)
		{
			GunController gunController = GunController.Ensure(Util.PlayerById(playerId));
			if ((Object)(object)gunController != (Object)null)
			{
				gunController.BeginBeam(windup, duration, dps, pierce);
			}
		}

		[UnboundRPC]
		public static void RPCA_RailWindup(int playerId, float windup)
		{
			GunController gunController = GunController.Ensure(Util.PlayerById(playerId));
			if ((Object)(object)gunController != (Object)null)
			{
				gunController.BeginRailWindup(windup);
			}
		}

		[UnboundRPC]
		public static void RPCA_RailFire(int playerId, float[] xy)
		{
			//IL_003b: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			GunController gunController = GunController.Ensure(Util.PlayerById(playerId));
			if ((Object)(object)gunController != (Object)null)
			{
				gunController.EndRailWindup();
			}
			if (xy != null)
			{
				List<Vector2> list = new List<Vector2>();
				for (int i = 0; i + 1 < xy.Length; i += 2)
				{
					list.Add(new Vector2(xy[i], xy[i + 1]));
				}
				Fx.FlashPath(list, 0.35f, new Color(0.6f, 0.95f, 1f, 1f), 0.4f);
				Fx.FlashPath(list, 0.12f, Color.white, 0.25f);
			}
		}

		[UnboundRPC]
		public static void RPCA_Charging(int playerId, bool on)
		{
			GunController gunController = GunController.Ensure(Util.PlayerById(playerId));
			if ((Object)(object)gunController != (Object)null)
			{
				gunController.ShowCharge(on);
			}
		}

		[UnboundRPC]
		public static void RPCA_Arc(float x1, float y1, float x2, float y2)
		{
			//IL_0002: 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)
			Fx.Lightning(new Vector2(x1, y1), new Vector2(x2, y2), 0.18f);
		}

		[UnboundRPC]
		public static void RPCA_Rope(float x1, float y1, float x2, float y2)
		{
			//IL_0002: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			Fx.FlashLine(new Vector2(x1, y1), new Vector2(x2, y2), 0.08f, new Color(0.75f, 0.6f, 0.4f, 1f), 0.3f);
		}
	}
	internal sealed class GunController : MonoBehaviour
	{
		internal sealed class TraceResult
		{
			internal readonly List<Vector2> Points = new List<Vector2>();

			internal readonly List<Player> Players = new List<Player>();

			internal bool HitTerrain;

			internal Vector2 TerrainPoint;

			internal Vector2 TerrainNormal;

			internal Vector2 TerrainDir;
		}

		private static readonly List<GunController> All = new List<GunController>();

		private Player _player;

		private float _lockedUntil;

		private bool _charging;

		private float _chargeStart;

		private float _lastAttackCall;

		private float _savedMove = -1f;

		private float _slowedMove = -1f;

		private float _pendingRailAt = -1f;

		private float _pendingRailMult = 1f;

		private float _windupEnd = -1f;

		private float _beamEnd = -1f;

		private float _beamDps;

		private bool _beamPierce;

		private float _nextTick;

		private readonly RayTimers _timers = new RayTimers();

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

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

		private float _railWindupEnd = -1f;

		private SpriteRenderer _aim;

		private SpriteRenderer _chargeGlow;

		private static FieldInfo _inputField;

		private static FieldInfo _shootHeldField;

		private static FieldInfo _currentAmmo;

		private Gun Gun => Util.GunOf(_player);

		private bool BeamBusy => Time.time < _beamEnd;

		internal static GunController Ensure(Player player)
		{
			if ((Object)(object)player == (Object)null)
			{
				return null;
			}
			GunController gunController = ((Component)player).GetComponent<GunController>();
			if ((Object)(object)gunController == (Object)null)
			{
				gunController = ((Component)player).gameObject.AddComponent<GunController>();
			}
			return gunController;
		}

		internal static void ResetAll()
		{
			GunController[] array = All.ToArray();
			foreach (GunController gunController in array)
			{
				if ((Object)(object)gunController != (Object)null)
				{
					gunController.ResetState();
				}
			}
		}

		private void Awake()
		{
			_player = ((Component)this).GetComponent<Player>();
			All.Add(this);
		}

		private void OnDestroy()
		{
			All.Remove(this);
			ClearVisuals();
		}

		private void ResetState()
		{
			_lockedUntil = 0f;
			StopCharging();
			_pendingRailAt = -1f;
			_windupEnd = (_beamEnd = (_railWindupEnd = -1f));
			_timers.Reset();
			ClearVisuals();
		}

		private void ClearVisuals()
		{
			foreach (SpriteRenderer segment in _segments)
			{
				if ((Object)(object)segment != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)segment).gameObject);
				}
			}
			foreach (SpriteRenderer core in _cores)
			{
				if ((Object)(object)core != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)core).gameObject);
				}
			}
			_segments.Clear();
			_cores.Clear();
			if ((Object)(object)_aim != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)_aim).gameObject);
			}
			if ((Object)(object)_chargeGlow != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)_chargeGlow).gameObject);
			}
			_aim = null;
			_chargeGlow = null;
		}

		internal bool HandleAttack(Gun gun, Weapon w)
		{
			float time = Time.time;
			bool flag = (w & (Weapon.Laser | Weapon.Railgun)) != 0;
			if (time < _lockedUntil || BeamBusy || _pendingRailAt > 0f)
			{
				return false;
			}
			if ((w & Weapon.ChargeCannon) != Weapon.None)
			{
				if (!flag && gun.isReloading)
				{
					return false;
				}
				if (!_charging)
				{
					StartCharging();
				}
				_lastAttackCall = time;
				return false;
			}
			if (!flag)
			{
				return true;
			}
			Fire(gun, w, 1f, fullCharge: false);
			return false;
		}

		private void StartCharging()
		{
			_charging = true;
			_chargeStart = Time.time;
			_lastAttackCall = Time.time;
			Gun gun = Gun;
			if ((Object)(object)gun != (Object)null)
			{
				gun.dontAllowAutoFire = false;
			}
			try
			{
				CharacterStatModifiers stats = _player.data.stats;
				_savedMove = stats.movementSpeed;
				stats.movementSpeed = _savedMove * 0.6f;
				_slowedMove = stats.movementSpeed;
			}
			catch
			{
				_savedMove = -1f;
			}
			NetworkingManager.RPC(typeof(Net), "RPCA_Charging", new object[2] { _player.playerID, true });
		}

		private void StopCharging()
		{
			if (!_charging)
			{
				return;
			}
			_charging = false;
			try
			{
				CharacterStatModifiers stats = _player.data.stats;
				if (_savedMove > 0f && Mathf.Approximately(stats.movementSpeed, _slowedMove))
				{
					stats.movementSpeed = _savedMove;
				}
			}
			catch
			{
			}
			_savedMove = (_slowedMove = -1f);
			if (Util.IsMine(_player))
			{
				NetworkingManager.RPC(typeof(Net), "RPCA_Charging", new object[2] { _player.playerID, false });
			}
		}

		private bool? FireHeld()
		{
			try
			{
				if (_inputField == null)
				{
					_inputField = AccessTools.Field(typeof(CharacterData), "input");
				}
				object obj = ((!(_inputField == null)) ? _inputField.GetValue(_player.data) : null);
				if (obj == null)
				{
					return null;
				}
				if (_shootHeldField == null)
				{
					_shootHeldField = AccessTools.Field(obj.GetType(), "shootIsPressed");
				}
				if (_shootHeldField == null)
				{
					return null;
				}
				return (bool)_shootHeldField.GetValue(obj);
			}
			catch
			{
				return null;
			}
		}

		private void OwnerUpdate()
		{
			Gun gun = Gun;
			if ((Object)(object)gun == (Object)null)
			{
				return;
			}
			Weapon weapon = Loadout.Of(_player);
			if (_charging)
			{
				if (!Util.Alive(_player) || (weapon & Weapon.ChargeCannon) == 0)
				{
					StopCharging();
					return;
				}
				bool? flag = FireHeld();
				if ((!flag.HasValue) ? (Time.time - _lastAttackCall > 0.12f) : (!flag.Value))
				{
					float num = Time.time - _chargeStart;
					StopCharging();
					float mult = (float)Rules.ChargeMultiplier(num);
					bool fullCharge = (double)num >= 2.0;
					Fire(gun, weapon, mult, fullCharge);
				}
			}
			if (_pendingRailAt > 0f && Time.time >= _pendingRailAt)
			{
				_pendingRailAt = -1f;
				if (Util.Alive(_player))
				{
					FireRail(gun, weapon, _pendingRailMult);
				}
			}
		}

		private void Fire(Gun gun, Weapon w, float mult, bool fullCharge)
		{
			float time = Time.time;
			GunAmmo componentInChildren = ((Component)gun).GetComponentInChildren<GunAmmo>(true);
			float num = 2f;
			try
			{
				if ((Object)(object)componentInChildren != (Object)null)
				{
					num = Mathf.Max(0.5f, componentInChildren.ReloadTime());
				}
			}
			catch
			{
			}
			if ((w & Weapon.Laser) != Weapon.None)
			{
				int totalProjectiles = Mathf.Max(1, gun.numberOfProjectiles);
				float num2 = (float)Rules.LaserDuration(totalProjectiles);
				float num3 = (float)Rules.LaserDps(totalProjectiles, Mathf.Max(0f, gun.damage * gun.bulletDamageMultiplier)) * mult;
				bool flag = (w & Weapon.Railgun) != 0;
				float num4 = ((!flag) ? 0f : 1f);
				_lockedUntil = time + num4 + num2 + 5f;
				NetworkingManager.RPC(typeof(Net), "RPCA_Beam", new object[5] { _player.playerID, num4, num2, num3, flag });
				return;
			}
			if ((w & Weapon.Railgun) != Weapon.None)
			{
				float num5 = 1f;
				_pendingRailAt = time + num5;
				_pendingRailMult = mult;
				_lockedUntil = time + num5 + num;
				NetworkingManager.RPC(typeof(Net), "RPCA_RailWindup", new object[2] { _player.playerID, num5 });
				return;
			}
			if (fullCharge)
			{
				SetCurrentAmmo(componentInChildren, 1);
			}
			AttackPatch.Passthrough = true;
			AttackPatch.PassthroughDamage = mult;
			try
			{
				gun.Attack(0f, false, 1f, 1f, true);
			}
			finally
			{
				AttackPatch.Passthrough = false;
				AttackPatch.PassthroughDamage = 1f;
			}
		}

		private static void SetCurrentAmmo(GunAmmo ammo, int value)
		{
			if ((Object)(object)ammo == (Object)null)
			{
				return;
			}
			try
			{
				if (_currentAmmo == null)
				{
					_currentAmmo = AccessTools.Field(typeof(GunAmmo), "currentAmmo");
				}
				if (!(_currentAmmo == null))
				{
					int num = (int)_currentAmmo.GetValue(ammo);
					if (num > value)
					{
						_currentAmmo.SetValue(ammo, value);
					}
				}
			}
			catch
			{
			}
		}

		private void FireRail(Gun gun, Weapon w, float mult)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: 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_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			TraceResult traceResult = Trace(gun, pierce: true, 60f);
			float num = Util.BulletDamage(gun) * 1.75f * mult;
			foreach (Player player in traceResult.Players)
			{
				Util.Damage(player, num, traceResult.Points[0], _player);
				Payload.OnRayPlayer(_player, w, player, num, continuous: false);
			}
			if (traceResult.HitTerrain)
			{
				Payload.OnRayTerrain(_player, w, traceResult.TerrainPoint, traceResult.TerrainNormal, traceResult.TerrainDir, Util.BulletDamage(gun) * mult, new RayTimers(), continuous: false);
			}
			float[] array = new float[traceResult.Points.Count * 2];
			for (int i = 0; i < traceResult.Points.Count; i++)
			{
				array[i * 2] = traceResult.Points[i].x;
				array[i * 2 + 1] = traceResult.Points[i].y;
			}
			NetworkingManager.RPC(typeof(Net), "RPCA_RailFire", new object[2] { _player.playerID, array });
		}

		internal void BeginRailWindup(float windup)
		{
			_railWindupEnd = Time.time + windup;
		}

		internal void EndRailWindup()
		{
			_railWindupEnd = -1f;
		}

		internal void ShowCharge(bool on)
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			if (!on)
			{
				if ((Object)(object)_chargeGlow != (Object)null)
				{
					Object.Destroy((Object)(object)((Component)_chargeGlow).gameObject);
				}
				_chargeGlow = null;
			}
			else
			{
				_chargeStart = Time.time;
				if ((Object)(object)_chargeGlow == (Object)null)
				{
					_chargeGlow = Fx.MakeSprite("CGC_Charge", Fx.Disc, new Color(1f, 0.8f, 0.2f, 0.6f), 8);
				}
			}
		}

		internal void BeginBeam(float windup, float duration, float dps, bool pierce)
		{
			_windupEnd = Time.time + windup;
			_beamEnd = _windupEnd + duration;
			_beamDps = dps;
			_beamPierce = pierce;
			_nextTick = _windupEnd;
			_timers.Reset();
		}

		private void Update()
		{
			//IL_0072: 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_00a4: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_0195: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0355: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_player == (Object)null)
			{
				return;
			}
			if (Util.IsMine(_player))
			{
				OwnerUpdate();
			}
			Gun gun = Gun;
			float time = Time.time;
			if ((Object)(object)_chargeGlow != (Object)null && (Object)(object)gun != (Object)null)
			{
				float num = Mathf.Clamp01((time - _chargeStart) / 2f);
				((Component)_chargeGlow).transform.position = Vector2.op_Implicit(Util.Muzzle(gun));
				float num2 = Mathf.Lerp(0.3f, 1.3f, num);
				((Component)_chargeGlow).transform.localScale = new Vector3(num2, num2, 1f);
				_chargeGlow.color = (Color)((!(num >= 1f) || !(Mathf.PingPong(time * 8f, 1f) > 0.5f)) ? new Color(1f, 0.8f - 0.5f * num, 0.2f, 0.7f) : Color.white);
			}
			bool flag = _railWindupEnd > 0f && time < _railWindupEnd;
			bool flag2 = time < _windupEnd;
			bool flag3 = !flag2 && time < _beamEnd;
			if ((Object)(object)gun == (Object)null || !Util.Alive(_player))
			{
				if (flag3 || flag2)
				{
					_beamEnd = (_windupEnd = -1f);
				}
				HideBeam();
				SetAim(on: false, Vector2.zero, Vector2.zero, 0f);
				return;
			}
			if (flag || flag2)
			{
				float num3 = ((!flag) ? _windupEnd : _railWindupEnd);
				float t = 1f - Mathf.Clamp01((num3 - time) / 1f);
				TraceResult traceResult = Trace(gun, pierce: true, 60f);
				Vector2 a = traceResult.Points[0];
				Vector2 b = traceResult.Points[(traceResult.Points.Count > 1) ? 1 : 0];
				SetAim(on: true, a, b, t);
			}
			else
			{
				SetAim(on: false, Vector2.zero, Vector2.zero, 0f);
			}
			if (!flag3)
			{
				HideBeam();
				return;
			}
			TraceResult traceResult2 = Trace(gun, _beamPierce, 60f);
			DrawBeam(traceResult2.Points);
			if (!Util.IsMine(_player) || time < _nextTick)
			{
				return;
			}
			_nextTick = Mathf.Max(_nextTick + 0.1f, time - 0.1f);
			Weapon w = Loadout.Of(_player);
			float num4 = _beamDps * 0.1f;
			foreach (Player player in traceResult2.Players)
			{
				Util.Damage(player, num4, traceResult2.Points[0], _player);
				Payload.OnRayPlayer(_player, w, player, num4, continuous: true);
			}
			if (traceResult2.HitTerrain)
			{
				Payload.OnRayTerrain(_player, w, traceResult2.TerrainPoint, traceResult2.TerrainNormal, traceResult2.TerrainDir, Util.BulletDamage(gun), _timers, continuous: true);
			}
		}

		private void SetAim(bool on, Vector2 a, Vector2 b, float t)
		{
			//IL_006c: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			if (!on)
			{
				if ((Object)(object)_aim != (Object)null)
				{
					((Component)_aim).gameObject.SetActive(false);
				}
				return;
			}
			if ((Object)(object)_aim == (Object)null)
			{
				_aim = Fx.MakeSprite("CGC_Aim", Fx.Pixel, Color.white, 6);
			}
			((Component)_aim).gameObject.SetActive(true);
			Fx.PlaceLine(_aim, a, b, Mathf.Lerp(0.03f, 0.12f, t));
			bool flag = Mathf.PingPong(Time.time * Mathf.Lerp(4f, 20f, t), 1f) > 0.5f;
			_aim.color = ((!flag) ? new Color(1f, 1f, 1f, 0.5f) : new Color(1f, 0.3f, 0.3f, 0.9f));
		}

		private void DrawBeam(List<Vector2> pts)
		{
			//IL_0038: 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_00fd: 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_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			int num = Mathf.Max(0, pts.Count - 1);
			while (_segments.Count < num)
			{
				_segments.Add(Fx.MakeSprite("CGC_Beam", Fx.Pixel, new Color(1f, 0.15f, 0.2f, 0.85f), 6));
				_cores.Add(Fx.MakeSprite("CGC_BeamCore", Fx.Pixel, new Color(1f, 0.9f, 0.9f, 1f), 7));
			}
			float width = 0.32f + 0.06f * Mathf.Sin(Time.time * 40f);
			for (int i = 0; i < _segments.Count; i++)
			{
				bool flag = i < num;
				((Component)_segments[i]).gameObject.SetActive(flag);
				((Component)_cores[i]).gameObject.SetActive(flag);
				if (flag)
				{
					Fx.PlaceLine(_segments[i], pts[i], pts[i + 1], width);
					Fx.PlaceLine(_cores[i], pts[i], pts[i + 1], 0.1f);
				}
			}
		}

		private void HideBeam()
		{
			foreach (SpriteRenderer segment in _segments)
			{
				if ((Object)(object)segment != (Object)null)
				{
					((Component)segment).gameObject.SetActive(false);
				}
			}
			foreach (SpriteRenderer core in _cores)
			{
				if ((Object)(object)core != (Object)null)
				{
					((Component)core).gameObject.SetActive(false);
				}
			}
		}

		private TraceResult Trace(Gun gun, bool pierce, float maxLen)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: 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_001e: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: 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)
			//IL_0063: 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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or mis