Decompiled source of RoundsOfRain v0.4.0

plugins/Local-RoundsOfRain/RoundsOfRain.dll

Decompiled a day ago
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using EntityStates;
using KinematicCharacterController;
using R2API;
using R2API.Utils;
using RoR2;
using RoR2.Networking;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.UI;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace RoundsOfRain;

internal static class Art
{
	private static Texture2D[] tiles;

	private static Sprite[] skills;

	private static void Load()
	{
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Expected O, but got Unknown
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Expected O, but got Unknown
		//IL_0171: 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)
		if (tiles != null)
		{
			return;
		}
		byte[] array;
		using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("RoundsOfRain.ArtAtlas"))
		{
			if (stream == null)
			{
				throw new InvalidOperationException("Embedded card art is missing.");
			}
			using MemoryStream memoryStream = new MemoryStream();
			stream.CopyTo(memoryStream);
			array = memoryStream.ToArray();
		}
		Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
		if (!ImageConversion.LoadImage(val, array, false))
		{
			throw new InvalidOperationException("Cannot decode card art.");
		}
		int num = Cards.All.Length + 4;
		int num2 = (num + 7) / 8 * 256;
		if (((Texture)val).width != 2048 || ((Texture)val).height != num2)
		{
			throw new InvalidOperationException("Unexpected card atlas dimensions.");
		}
		tiles = (Texture2D[])(object)new Texture2D[num];
		skills = (Sprite[])(object)new Sprite[4];
		for (int i = 0; i < tiles.Length; i++)
		{
			Texture2D val2 = new Texture2D(256, 256, (TextureFormat)4, false);
			((Object)val2).name = "RoundsArt_" + i;
			((Texture)val2).wrapMode = (TextureWrapMode)1;
			val2.SetPixels(val.GetPixels(i % 8 * 256, num2 - (i / 8 + 1) * 256, 256, 256));
			val2.Apply(false, true);
			tiles[i] = val2;
			if (i >= Cards.All.Length)
			{
				skills[i - Cards.All.Length] = Sprite.Create(val2, new Rect(0f, 0f, 256f, 256f), new Vector2(0.5f, 0.5f));
			}
		}
		Object.Destroy((Object)(object)val);
	}

	internal static Texture2D Card(int index)
	{
		Load();
		return tiles[index];
	}

	internal static Sprite Skill(string token)
	{
		Load();
		return skills[token switch
		{
			"ROR_BURST" => 3, 
			"ROR_HOP" => 2, 
			"ROR_BLOCK" => 1, 
			_ => 0, 
		}];
	}
}
public static class Ballistics
{
	public const float BaseSpeed = 42f;

	public const float BaseGravity = 10f;

	public const float BounceSpeedRetention = 0.86f;

	public const float BounceRangeRetention = 0.85f;

	public const float BounceGravityGain = 1.12f;

	public static float BounceGravity(float current)
	{
		return Math.Min(4f, current * 1.12f);
	}

	public static double DropAtDistance(BuildStats stats, double metres)
	{
		double num = metres / (double)(42f * stats.BulletSpeed);
		return 5.0 * (double)stats.Gravity * num * num;
	}
}
public enum CardRarity
{
	Common,
	Uncommon,
	Rare,
	Legendary
}
public sealed class Card
{
	public readonly string Name;

	public readonly string Description;

	public readonly int Weight;

	public readonly CardRarity Rarity;

	public readonly bool Mechanic;

	public readonly int StackLimit;

	public readonly Action<BuildStats> Apply;

	public Card(string name, string description, int weight, Action<BuildStats> apply, bool mechanic = false, bool legendary = false, bool unique = false)
	{
		Name = name;
		Description = description;
		Weight = weight;
		Apply = apply;
		Rarity = (legendary ? CardRarity.Legendary : (weight switch
		{
			4 => CardRarity.Uncommon, 
			1 => CardRarity.Rare, 
			_ => CardRarity.Common, 
		}));
		Mechanic = mechanic || weight == 1;
		StackLimit = (unique ? 1 : 99);
	}
}
public sealed class BuildStats
{
	public float Damage;

	public float Health;

	public float AttackSpeed;

	public float MoveSpeed;

	public float JumpPower;

	public float Regen;

	public float Armor;

	public float Crit;

	public float BulletSpeed = 1f;

	public float BulletSize = 1f;

	public float Explosion;

	public float Lifesteal;

	public float BlockHeal;

	public float BlockBlast;

	public float GravityPull;

	public float Homing;

	public float BlockCooldown = 1f;

	public int Pellets = 1;

	public int Bounces;

	public int Ammo;

	public int ExtraJumps;

	public int Echoes;

	public bool Radial;

	public float FlightGrowth;

	public float Poison;

	public float Thruster;

	public float BloodCost;

	public float KillHeal;

	public float BlockTeleport;

	public float SawDamage;

	public int Fragments;

	public int BounceSplits;

	public int TargetBounces;

	public int HivePellets;

	public bool ChargeGun;

	public bool AmmoRefund;

	public float Gravity = 1f;

	public float Range = 90f;

	public bool Boomerang;

	public bool Mines;

	public bool Orbit;

	public bool Grapple;

	public bool GravitySwitch;

	public bool BankShot;

	public bool Mirror;

	public bool Portals;

	public bool ReturnOnHit;

	public bool AutoMines;

	public bool PortalRelay;

	public float ReloadMultiplier = 1f;

	public float GrappleLeap;

	public float PortalSeparation = 40f;

	public bool Recall;

	public bool StickyMines;

	public bool BounceRecharge;

	public bool OrbitShred;

	public bool ShootMines;

	public float MineFuse;
}
public static class Cards
{
	public static readonly Card[] All = new Card[72]
	{
		new Card("Big Bullet", "+15% damage; +25% bullet size", 10, delegate(BuildStats s)
		{
			s.Damage += 0.15f;
			s.BulletSize *= 1.25f;
		}),
		new Card("Quick Shot", "+15% attack speed; +20% bullet speed", 10, delegate(BuildStats s)
		{
			s.AttackSpeed += 0.15f;
			s.BulletSpeed *= 1.2f;
		}),
		new Card("Tank", "+25% health; -10% move speed", 10, delegate(BuildStats s)
		{
			s.Health += 0.25f;
			s.MoveSpeed -= 0.1f;
		}),
		new Card("Glass Cannon", "+40% damage; -25% health", 4, delegate(BuildStats s)
		{
			s.Damage += 0.4f;
			s.Health -= 0.25f;
		}),
		new Card("Shotgun", "+2 bullets per shot; -15% damage", 4, delegate(BuildStats s)
		{
			s.Pellets += 2;
			s.Damage -= 0.15f;
		}),
		new Card("Bouncy", "+2 wall bounces; +15% bullet speed", 10, delegate(BuildStats s)
		{
			s.Bounces += 2;
			s.BulletSpeed *= 1.15f;
		}),
		new Card("Explosive Bullet", "+2m splash radius; -10% direct damage", 4, delegate(BuildStats s)
		{
			s.Explosion += 2f;
			s.Damage -= 0.1f;
		}, mechanic: true),
		new Card("Vampire", "+3% lifesteal; -10% damage", 4, delegate(BuildStats s)
		{
			s.Lifesteal += 0.03f;
			s.Damage -= 0.1f;
		}, mechanic: true),
		new Card("Fast Hands", "Block recharges 20% faster; +10% attack speed", 10, delegate(BuildStats s)
		{
			s.BlockCooldown *= 0.8f;
			s.AttackSpeed += 0.1f;
		}),
		new Card("Healing Block", "Block heals 8% max health; -10% attack speed", 4, delegate(BuildStats s)
		{
			s.BlockHeal += 0.08f;
			s.AttackSpeed -= 0.1f;
		}, mechanic: true),
		new Card("EMP", "Block releases a 200% damage shockwave", 4, delegate(BuildStats s)
		{
			s.BlockBlast += 2f;
		}, mechanic: true),
		new Card("Ammo Cache", "+3 magazine capacity", 10, delegate(BuildStats s)
		{
			s.Ammo += 3;
		}),
		new Card("Spray", "+3 bullets per shot; -25% damage", 4, delegate(BuildStats s)
		{
			s.Pellets += 3;
			s.Damage -= 0.25f;
		}),
		new Card("Buckshot", "+1 bullet per shot; +5% attack speed", 10, delegate(BuildStats s)
		{
			s.Pellets++;
			s.AttackSpeed += 0.05f;
		}),
		new Card("Super Sonic", "+25% move speed; +10% jump power", 4, delegate(BuildStats s)
		{
			s.MoveSpeed += 0.25f;
			s.JumpPower += 0.1f;
		}),
		new Card("Double Jump", "+1 air jump; +10% move speed", 10, delegate(BuildStats s)
		{
			s.ExtraJumps++;
			s.MoveSpeed += 0.1f;
		}),
		new Card("Regeneration", "+2 health regeneration per second", 10, delegate(BuildStats s)
		{
			s.Regen += 2f;
		}),
		new Card("Steel Skin", "+10 armor; +10% health", 10, delegate(BuildStats s)
		{
			s.Armor += 10f;
			s.Health += 0.1f;
		}),
		new Card("Critical Hit", "+10% critical chance", 10, delegate(BuildStats s)
		{
			s.Crit += 10f;
		}),
		new Card("Small but Deadly", "+25% damage; +15% move speed; -10% health", 4, delegate(BuildStats s)
		{
			s.Damage += 0.25f;
			s.MoveSpeed += 0.15f;
			s.Health -= 0.1f;
		}),
		new Card("Huge", "+30% health; +10 armor; -15% move speed", 4, delegate(BuildStats s)
		{
			s.Health += 0.3f;
			s.Armor += 10f;
			s.MoveSpeed -= 0.15f;
		}),
		new Card("Railgun", "Faster, flatter bullets: double speed; -80% drop; +25% range; +40% damage; -25% attack speed", 1, delegate(BuildStats s)
		{
			s.Damage += 0.4f;
			s.BulletSpeed *= 2f;
			s.Gravity *= 0.2f;
			s.Range *= 1.25f;
			s.AttackSpeed -= 0.25f;
		}),
		new Card("Bullet Storm", "+5 bullets per shot; +3 ammo; -35% damage", 1, delegate(BuildStats s)
		{
			s.Pellets += 5;
			s.Ammo += 3;
			s.Damage -= 0.35f;
		}),
		new Card("Soul Harvest", "Kills heal 3% max health; -20% gun damage", 1, delegate(BuildStats s)
		{
			s.KillHeal += 0.03f;
			s.Damage -= 0.2f;
		}),
		new Card("Ricochet", "+4 wall bounces; +30% bullet speed", 4, delegate(BuildStats s)
		{
			s.Bounces += 4;
			s.BulletSpeed *= 1.3f;
		}),
		new Card("Bombardier", "+4 metres splash radius; -15% attack speed", 1, delegate(BuildStats s)
		{
			s.Explosion += 4f;
			s.AttackSpeed -= 0.15f;
		}),
		new Card("Leech", "+4% lifesteal; -20% damage", 4, delegate(BuildStats s)
		{
			s.Lifesteal += 0.04f;
			s.Damage -= 0.2f;
		}, mechanic: true),
		new Card("Power Block", "Block shockwave grows; block recharges 10% faster", 4, delegate(BuildStats s)
		{
			s.BlockBlast += 1.5f;
			s.BlockCooldown *= 0.9f;
		}),
		new Card("Minigun", "+75% attack speed; +6 ammo; -30% damage", 1, delegate(BuildStats s)
		{
			s.AttackSpeed += 0.75f;
			s.Ammo += 6;
			s.Damage -= 0.3f;
		}),
		new Card("Bullet Hell", "+7 bullets; -20% damage; -10% attack speed", 1, delegate(BuildStats s)
		{
			s.Pellets += 7;
			s.Damage -= 0.2f;
			s.AttackSpeed -= 0.1f;
		}),
		new Card("Planet Buster", "+10m splash; -25% damage; -15% attack speed", 1, delegate(BuildStats s)
		{
			s.Explosion += 10f;
			s.Damage -= 0.25f;
			s.AttackSpeed -= 0.15f;
		}),
		new Card("Quantum Scatter", "+4 bullets; +3 wall bounces; homing; -35% damage", 1, delegate(BuildStats s)
		{
			s.Pellets += 4;
			s.Bounces += 3;
			s.Homing += 60f;
			s.Damage -= 0.35f;
		}, mechanic: true, legendary: true),
		new Card("Black Hole", "Impacts pull enemies inward; +5m splash; -20% damage", 1, delegate(BuildStats s)
		{
			s.GravityPull += 20f;
			s.Explosion += 5f;
			s.Damage -= 0.2f;
		}, mechanic: true, legendary: true),
		new Card("Homing", "Bullets seek enemies; -25% damage; -25% bullet speed", 4, delegate(BuildStats s)
		{
			s.Homing += 120f;
			s.Damage -= 0.25f;
			s.BulletSpeed *= 0.75f;
		}, mechanic: true),
		new Card("Unstable Reactor", "Block deals 600% splash and heals 8%; block takes 25% longer to recharge", 1, delegate(BuildStats s)
		{
			s.BlockBlast += 6f;
			s.BlockHeal += 0.08f;
			s.BlockCooldown *= 1.25f;
		}),
		new Card("360 No Scope", "Shoot in all directions; +7 bullets; -25% damage", 1, delegate(BuildStats s)
		{
			s.Radial = true;
			s.Pellets += 7;
			s.Damage -= 0.25f;
		}),
		new Card("Echo Chamber", "Add one echo shot; shared damage; -10% damage", 1, delegate(BuildStats s)
		{
			s.Echoes++;
			s.Damage -= 0.1f;
		}),
		new Card("Pinball Wizard", "+8 wall bounces; +75% bullet speed; -15% attack speed", 1, delegate(BuildStats s)
		{
			s.Bounces += 8;
			s.BulletSpeed *= 1.75f;
			s.AttackSpeed -= 0.15f;
		}),
		new Card("Omega Leech", "+6% lifesteal; +25% health; +2 regen; -25% damage", 1, delegate(BuildStats s)
		{
			s.Lifesteal += 0.06f;
			s.Health += 0.25f;
			s.Regen += 2f;
			s.Damage -= 0.25f;
		}),
		new Card("THE SUN", "+12m splash; triple bullet size; -35% damage; -30% attack speed; -15% health", 1, delegate(BuildStats s)
		{
			s.Explosion += 12f;
			s.BulletSize *= 3f;
			s.Damage -= 0.35f;
			s.AttackSpeed -= 0.3f;
			s.Health -= 0.15f;
		}, mechanic: true, legendary: true),
		new Card("Grow", "Bullets grow in flight: up to +60% damage over 2s; -20% attack speed", 4, delegate(BuildStats s)
		{
			s.FlightGrowth += 0.6f;
			s.AttackSpeed -= 0.2f;
		}, mechanic: true),
		new Card("Fragmentation", "Hits spawn 3 fragments at 18% parent damage each; -20% gun damage", 1, delegate(BuildStats s)
		{
			s.Fragments += 3;
			s.Damage -= 0.2f;
		}),
		new Card("Splitting Rounds", "Wall bounces spawn 2 side shots at 25% parent damage; -30% gun damage", 1, delegate(BuildStats s)
		{
			s.BounceSplits += 2;
			s.Bounces++;
			s.Damage -= 0.3f;
		}),
		new Card("Target Bounce", "After hitting, redirect to 2 new enemies; lose 35% damage each hop; -25% gun damage", 1, delegate(BuildStats s)
		{
			s.TargetBounces += 2;
			s.Damage -= 0.25f;
		}),
		new Card("Thruster", "Hits push enemies away; +350 knockback force; -20% damage", 4, delegate(BuildStats s)
		{
			s.Thruster += 350f;
			s.Damage -= 0.2f;
		}, mechanic: true),
		new Card("Demonic Pact", "Attacks spend 1% max health (cannot kill you); +2 bullets; +40% damage; -20% max health", 1, delegate(BuildStats s)
		{
			s.BloodCost += 0.01f;
			s.Pellets += 2;
			s.Damage += 0.4f;
			s.Health -= 0.2f;
		}, mechanic: true, legendary: true),
		new Card("Hive", "Block arms the next volley: +6 strongly homing bullets; -20% gun damage", 1, delegate(BuildStats s)
		{
			s.HivePellets += 6;
			s.Damage -= 0.2f;
		}),
		new Card("Parasite", "Hits infect for 45% damage over 3s (one infection per target); +2% lifesteal; -20% direct damage", 4, delegate(BuildStats s)
		{
			s.Poison += 0.45f;
			s.Lifesteal += 0.02f;
			s.Damage -= 0.2f;
		}, mechanic: true),
		new Card("Scavenger", "Hits return one ammo, at most every 0.4s; -15% gun damage", 1, delegate(BuildStats s)
		{
			s.AmmoRefund = true;
			s.Damage -= 0.15f;
		}),
		new Card("Teleport", "Block blinks up to 6m along your aim; -15% max health", 1, delegate(BuildStats s)
		{
			s.BlockTeleport += 6f;
			s.Health -= 0.15f;
		}),
		new Card("Saw", "Block creates a 6m saw aura for 2s (300% damage/s); -25% gun damage", 1, delegate(BuildStats s)
		{
			s.SawDamage += 3f;
			s.Damage -= 0.25f;
		}),
		new Card("Wind Up", "Hold Shoot to charge, then release; up to double shot damage; -25% attack speed", 4, delegate(BuildStats s)
		{
			s.ChargeGun = true;
			s.AttackSpeed -= 0.25f;
		}, mechanic: true),
		new Card("Boomerang Rounds", "Bullets return after 0.8s. Catching refunds ammo (max 1 per 0.4s); -25% damage. Unique.", 4, delegate(BuildStats s)
		{
			s.Boomerang = true;
			s.Damage -= 0.25f;
		}, mechanic: true, legendary: false, unique: true),
		new Card("Mine Layer", "After their bounces, bullets stick as mines. Block detonates yours; max 8. +20% reload time; -20% damage. Unique.", 1, delegate(BuildStats s)
		{
			s.Mines = true;
			s.ReloadMultiplier *= 1.2f;
			s.Damage -= 0.2f;
		}, mechanic: true, legendary: false, unique: true),
		new Card("Orbital Magazine", "Shoot loads up to 12 orbiting bullets; Block launches them. Holding ammo slows movement 20%; -15% damage. Unique.", 1, delegate(BuildStats s)
		{
			s.Orbit = true;
			s.Damage -= 0.15f;
		}, mechanic: true, legendary: false, unique: true),
		new Card("Grapple Shot", "Hits pull you toward enemies, at most once per 0.6s. -20% damage; -10% health. Unique.", 1, delegate(BuildStats s)
		{
			s.Grapple = true;
			s.Damage -= 0.2f;
			s.Health -= 0.1f;
		}, mechanic: true, legendary: false, unique: true),
		new Card("Gravity Switch", "Block reverses gravity on your airborne bullets for 2s; -20% bullet speed. Unique.", 4, delegate(BuildStats s)
		{
			s.GravitySwitch = true;
			s.BulletSpeed *= 0.8f;
		}, mechanic: true, legendary: false, unique: true),
		new Card("Bank Shot", "Bullets cannot hurt enemies until a wall bounce. +1 bounce; +20% damage. Unique.", 4, delegate(BuildStats s)
		{
			s.BankShot = true;
			s.Bounces++;
			s.Damage += 0.2f;
		}, mechanic: true, legendary: false, unique: true),
		new Card("Mirror Pact", "Block catches up to 6 nearby enemy projectiles for your next volley. Protection shrinks to 0.18s. No beams/melee. Unique.", 1, delegate(BuildStats s)
		{
			s.Mirror = true;
		}, mechanic: true, legendary: true, unique: true),
		new Card("Portal Rounds", "First two surface hits place gates; later bullets warp through. F7 resets/repositions. Max 40m apart; -20% damage. Unique.", 1, delegate(BuildStats s)
		{
			s.Portals = true;
			s.Damage -= 0.2f;
		}, mechanic: true, legendary: true, unique: true),
		new Card("Return Ticket", "Enemy hits turn bullets back toward you. Catching refunds ammo; -15% damage. Unique.", 4, delegate(BuildStats s)
		{
			s.Boomerang = true;
			s.ReturnOnHit = true;
			s.Damage -= 0.15f;
		}, mechanic: true, legendary: false, unique: true),
		new Card("Tripwire Mines", "Enable mine shots. Your armed mines trigger near enemies (3m); Block also detonates. -15% damage. Unique.", 4, delegate(BuildStats s)
		{
			s.Mines = true;
			s.AutoMines = true;
			s.Damage -= 0.15f;
		}, mechanic: true, legendary: false, unique: true),
		new Card("Slingshot", "Enable grapple hits with an upward launch; +1 air jump; -20% health. Unique.", 1, delegate(BuildStats s)
		{
			s.Grapple = true;
			s.GrappleLeap += 8f;
			s.ExtraJumps++;
			s.Health -= 0.2f;
		}, mechanic: true, legendary: false, unique: true),
		new Card("Portal Relay", "Enable gates usable by teammates' ROUNDS bullets. +20m separation; -15% damage. F7 repositions. Unique.", 1, delegate(BuildStats s)
		{
			s.Portals = true;
			s.PortalRelay = true;
			s.PortalSeparation += 20f;
			s.Damage -= 0.15f;
		}, mechanic: true, legendary: false, unique: true),
		new Card("Recall", "Block recalls your airborne bullets and mines instead of detonating mines. Catch them for ammo; -15% damage. Unique.", 4, delegate(BuildStats s)
		{
			s.Recall = true;
			s.Boomerang = true;
			s.Damage -= 0.15f;
		}, mechanic: true, legendary: false, unique: true),
		new Card("Timed Charges", "Enable mine shots that detonate 2s after sticking; Block can trigger them sooner. -15% damage. Unique.", 4, delegate(BuildStats s)
		{
			s.Mines = true;
			s.MineFuse = 2f;
			s.Damage -= 0.15f;
		}, mechanic: true, legendary: false, unique: true),
		new Card("Anchor Shot", "Enable mines that stick to enemies as well as surfaces. Block detonates; -20% damage. Unique.", 1, delegate(BuildStats s)
		{
			s.Mines = true;
			s.StickyMines = true;
			s.Damage -= 0.2f;
		}, mechanic: true, legendary: false, unique: true),
		new Card("Ricochet Recharge", "Wall bounces restore one Block charge, at most every 2s. +1 bounce; -25% damage. Unique.", 1, delegate(BuildStats s)
		{
			s.BounceRecharge = true;
			s.Bounces++;
			s.Damage -= 0.25f;
		}, mechanic: true, legendary: false, unique: true),
		new Card("Orbit Shredder", "Enable orbit ammo. Held bullets damage nearby enemies (2.5m) twice per second; -20% gun damage. Unique.", 1, delegate(BuildStats s)
		{
			s.Orbit = true;
			s.OrbitShred = true;
			s.Damage -= 0.2f;
		}, mechanic: true, legendary: false, unique: true),
		new Card("Minesweeper", "Enable mine shots. Your shots passing near your mines detonate them. Block also triggers; -15% damage. Unique.", 4, delegate(BuildStats s)
		{
			s.Mines = true;
			s.ShootMines = true;
			s.Damage -= 0.15f;
		}, mechanic: true, legendary: false, unique: true),
		new Card("Pinwheel", "Enable orbit ammo; Block launches stored bullets in every direction. Holding slows you 20%; -25% damage. Unique.", 1, delegate(BuildStats s)
		{
			s.Orbit = true;
			s.Radial = true;
			s.Damage -= 0.25f;
		}, mechanic: true, legendary: false, unique: true),
		new Card("Portal Snare", "Enable portals and mine shots: send traps through gates, then detonate with Block. -30% gun damage. F7 repositions. Unique.", 1, delegate(BuildStats s)
		{
			s.Portals = true;
			s.Mines = true;
			s.Damage -= 0.3f;
		}, mechanic: true, legendary: false, unique: true)
	};

	public static BuildStats Calculate(int[] stacks)
	{
		if (stacks == null || stacks.Length != All.Length)
		{
			throw new ArgumentException("Invalid deck length");
		}
		BuildStats buildStats = new BuildStats();
		for (int i = 0; i < All.Length; i++)
		{
			if (stacks[i] < 0 || stacks[i] > All[i].StackLimit)
			{
				throw new ArgumentException("Invalid card stack");
			}
			for (int j = 0; j < stacks[i]; j++)
			{
				All[i].Apply(buildStats);
			}
		}
		buildStats.Damage = Clamp(buildStats.Damage, -0.8f, 1.5f);
		buildStats.Health = Clamp(buildStats.Health, -0.75f, 1.5f);
		buildStats.MoveSpeed = Clamp(buildStats.MoveSpeed, -0.7f, 2f);
		buildStats.AttackSpeed = Clamp(buildStats.AttackSpeed, -0.6f, 1.5f);
		buildStats.Regen = Clamp(buildStats.Regen, 0f, 12f);
		buildStats.Armor = Clamp(buildStats.Armor, 0f, 60f);
		buildStats.Crit = Clamp(buildStats.Crit, 0f, 100f);
		buildStats.JumpPower = Clamp(buildStats.JumpPower, 0f, 2f);
		buildStats.BulletSpeed = Clamp(buildStats.BulletSpeed, 0.2f, 5f);
		buildStats.BulletSize = Clamp(buildStats.BulletSize, 0.5f, 4f);
		buildStats.BlockCooldown = Clamp(buildStats.BlockCooldown, 0.4f, 2.5f);
		buildStats.BlockHeal = Clamp(buildStats.BlockHeal, 0f, 0.2f);
		buildStats.BlockBlast = Clamp(buildStats.BlockBlast, 0f, 12f);
		buildStats.Lifesteal = Clamp(buildStats.Lifesteal, 0f, 0.12f);
		buildStats.Explosion = Clamp(buildStats.Explosion, 0f, 16f);
		buildStats.FlightGrowth = Clamp(buildStats.FlightGrowth, 0f, 1.2f);
		buildStats.Poison = Clamp(buildStats.Poison, 0f, 0.9f);
		buildStats.Thruster = Clamp(buildStats.Thruster, 0f, 1000f);
		buildStats.BloodCost = Clamp(buildStats.BloodCost, 0f, 0.04f);
		buildStats.KillHeal = Clamp(buildStats.KillHeal, 0f, 0.06f);
		buildStats.BlockTeleport = Clamp(buildStats.BlockTeleport, 0f, 12f);
		buildStats.SawDamage = Clamp(buildStats.SawDamage, 0f, 6f);
		buildStats.Fragments = Math.Min(buildStats.Fragments, 6);
		buildStats.BounceSplits = Math.Min(buildStats.BounceSplits, 4);
		buildStats.TargetBounces = Math.Min(buildStats.TargetBounces, 6);
		buildStats.HivePellets = Math.Min(buildStats.HivePellets, 12);
		buildStats.Gravity = Clamp(buildStats.Gravity, 0.04f, 3f);
		buildStats.Range = Clamp(buildStats.Range, 30f, 180f);
		buildStats.Homing = Clamp(buildStats.Homing, 0f, 360f);
		buildStats.GravityPull = Clamp(buildStats.GravityPull, 0f, 60f);
		buildStats.Echoes = Math.Min(buildStats.Echoes, 4);
		buildStats.Pellets = Math.Min(buildStats.Pellets, 32);
		buildStats.Bounces = Math.Min(buildStats.Bounces, 24);
		buildStats.Ammo = Math.Min(buildStats.Ammo, 48);
		buildStats.ExtraJumps = Math.Min(buildStats.ExtraJumps, 8);
		return buildStats;
	}

	public static float Clamp(float value, float min, float max)
	{
		return Math.Max(min, Math.Min(max, value));
	}

	public static float PelletDamageScale(int pellets)
	{
		return (float)(1.0 / Math.Pow(Math.Max(1, pellets), 0.85));
	}

	public static float EchoDamageScale(int echoes)
	{
		return 1f / (1f + (float)Math.Max(0, echoes) * 0.65f);
	}
}
public sealed class Draft
{
	public int[] Stacks = new int[Cards.All.Length];

	public int[] Offer = new int[0];

	public int Remaining;

	public int Token;

	public int LastLevel = 1;

	public bool InitialGranted;

	private readonly Random rng;

	public Draft(int seed)
	{
		rng = new Random(seed);
	}

	public void Grant(int picks, int choices)
	{
		Remaining = Math.Min(200, Remaining + Math.Max(0, picks));
		if (Remaining > 0 && Offer.Length == 0)
		{
			Draw(choices);
		}
	}

	public bool Choose(int token, int slot, int choices)
	{
		if (token != Token || Remaining <= 0 || slot < 0 || slot >= Offer.Length)
		{
			return false;
		}
		int num = Offer[slot];
		if (Stacks[num] >= Cards.All[num].StackLimit)
		{
			return false;
		}
		Stacks[num]++;
		Remaining--;
		Offer = new int[0];
		if (Remaining > 0)
		{
			Draw(choices);
		}
		else
		{
			Token++;
		}
		return true;
	}

	private void Draw(int choices)
	{
		int num = 0;
		int[] stacks = Stacks;
		foreach (int num2 in stacks)
		{
			num += num2;
		}
		List<int> list = new List<int>();
		for (int j = 0; j < Cards.All.Length; j++)
		{
			if (Stacks[j] < Cards.All[j].StackLimit && (num >= 8 || Cards.All[j].Rarity != CardRarity.Legendary))
			{
				list.Add(j);
			}
		}
		List<int> list2 = new List<int>();
		List<int> list3 = list.FindAll((int num3) => Cards.All[num3].Mechanic);
		if (list3.Count > 0 && choices > 0)
		{
			int item = Weighted(list3);
			list2.Add(item);
			list.Remove(item);
		}
		while (list2.Count < Math.Min(choices, Cards.All.Length) && list.Count > 0)
		{
			int item2 = Weighted(list);
			list2.Add(item2);
			list.Remove(item2);
		}
		Offer = list2.ToArray();
		if (Offer.Length == 0)
		{
			Remaining = 0;
		}
		Token++;
	}

	private int Weighted(List<int> candidates)
	{
		int num = 0;
		foreach (int candidate in candidates)
		{
			num += RarityWeight(Cards.All[candidate].Rarity);
		}
		int num2 = rng.Next(num);
		foreach (int candidate2 in candidates)
		{
			num2 -= RarityWeight(Cards.All[candidate2].Rarity);
			if (num2 < 0)
			{
				return candidate2;
			}
		}
		return candidates[0];
	}

	public static int RarityWeight(CardRarity rarity)
	{
		return rarity switch
		{
			CardRarity.Rare => 3, 
			CardRarity.Uncommon => 10, 
			CardRarity.Common => 30, 
			_ => 1, 
		};
	}
}
public static class Gun
{
	public static void Fire(CharacterBody body, Ray aim, float coefficient)
	{
		//IL_001d: 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_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: 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_01c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01da: Unknown result type (might be due to invalid IL or missing references)
		//IL_0264: Unknown result type (might be due to invalid IL or missing references)
		if (!NetworkServer.active)
		{
			if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.master))
			{
				Net.RequestFire(body, aim, coefficient);
			}
		}
		else
		{
			if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)ProjectileManager.instance) || !Object.op_Implicit((Object)(object)Plugin.ProjectilePrefab))
			{
				return;
			}
			BuildStats buildStats = Plugin.Stats(body);
			RoundsMechanics roundsMechanics = RoundsMechanics.For(body);
			if (roundsMechanics.Placing(buildStats))
			{
				Spawn(body, aim, 0f, crit: false, Plugin.PortalProjectilePrefab);
				return;
			}
			buildStats.Pellets = Mathf.Min(32, buildStats.Pellets + roundsMechanics.MirrorAmmo);
			roundsMechanics.MirrorAmmo = 0;
			RoundsDriver component = ((Component)body).GetComponent<RoundsDriver>();
			bool flag = Object.op_Implicit((Object)(object)component) && component.HiveReady;
			if (flag)
			{
				component.HiveReady = false;
				buildStats.Pellets = Mathf.Min(32, buildStats.Pellets + buildStats.HivePellets);
			}
			float num = coefficient * Cards.PelletDamageScale(buildStats.Pellets);
			int num2 = (buildStats.Orbit ? Mathf.Max(0, 12 - roundsMechanics.OrbitCount) : Mathf.Max(0, 64 - RoundsImpact.ActiveFor(((Component)body).gameObject)));
			for (int i = 0; i < Mathf.Min(buildStats.Pellets, num2); i++)
			{
				float num3 = (buildStats.Radial ? ((float)i * 360f / (float)buildStats.Pellets) : ((buildStats.Pellets == 1) ? 0f : (((float)i - ((float)buildStats.Pellets - 1f) * 0.5f) * Mathf.Min(4f, 70f / (float)buildStats.Pellets))));
				Quaternion rotation = Quaternion.LookRotation(((Ray)(ref aim)).direction) * Quaternion.Euler(0f, num3, 0f);
				FireProjectileInfo val = new FireProjectileInfo
				{
					projectilePrefab = (flag ? Plugin.HiveProjectilePrefab : Plugin.ProjectilePrefab),
					position = ((Ray)(ref aim)).origin + ((Ray)(ref aim)).direction * 0.8f,
					rotation = rotation,
					owner = ((Component)body).gameObject,
					damage = body.damage * num,
					force = 80f,
					crit = Util.CheckRoll(body.crit, body.master)
				};
				((FireProjectileInfo)(ref val)).speedOverride = 42f * buildStats.BulletSpeed;
				if (buildStats.Orbit)
				{
					roundsMechanics.Store(val.damage, val.crit, flag);
				}
				else if (RoundsImpact.CanSpawn(((Component)body).gameObject))
				{
					ProjectileManager.instance.FireProjectile(val);
				}
			}
		}
	}

	internal static void Spawn(CharacterBody body, Ray aim, float damage, bool crit, GameObject prefab)
	{
		//IL_0017: 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_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: 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_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		if (NetworkServer.active && RoundsImpact.CanSpawn(((Component)body).gameObject))
		{
			FireProjectileInfo val = new FireProjectileInfo
			{
				projectilePrefab = prefab,
				owner = ((Component)body).gameObject,
				position = ((Ray)(ref aim)).origin + ((Ray)(ref aim)).direction * 0.8f,
				rotation = Quaternion.LookRotation(((Ray)(ref aim)).direction),
				damage = damage,
				crit = crit,
				force = 80f
			};
			((FireProjectileInfo)(ref val)).speedOverride = 42f * Plugin.Stats(body).BulletSpeed;
			ProjectileManager.instance.FireProjectile(val);
			RoundsAnimator.Trigger(body, "shoot");
		}
	}

	public static void BloodPrice(CharacterBody body, float attacks)
	{
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Expected O, but got Unknown
		//IL_009a: 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)
		if (NetworkServer.active && Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.healthComponent) && body.healthComponent.alive)
		{
			float num = Plugin.Stats(body).BloodCost * attacks;
			if (!(num <= 0f))
			{
				DamageInfo val = new DamageInfo();
				val.attacker = ((Component)body).gameObject;
				val.inflictor = ((Component)body).gameObject;
				val.damage = Mathf.Min(body.maxHealth * num, Mathf.Max(0f, body.healthComponent.health - 1f));
				val.procCoefficient = 0f;
				val.damageType = DamageTypeCombo.op_Implicit((DamageType)3);
				body.healthComponent.TakeDamage(val);
			}
		}
	}
}
public sealed class RoundsShot : BaseSkillState
{
	private float duration;

	private int echoes;

	private float nextEcho;

	private float shotCoefficient;

	private bool charging;

	public override void OnEnter()
	{
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		((BaseState)this).OnEnter();
		duration = Mathf.Max(0.06f, 0.22f / Mathf.Max(0.2f, ((BaseState)this).attackSpeedStat));
		echoes = Plugin.Stats(((EntityState)this).characterBody).Echoes;
		shotCoefficient = 2.2f * Cards.EchoDamageScale(echoes);
		charging = Plugin.Stats(((EntityState)this).characterBody).ChargeGun;
		Gun.BloodPrice(((EntityState)this).characterBody, 1f);
		nextEcho = duration / ((float)echoes + 1f);
		((BaseState)this).StartAimMode(2f, false);
		if (!charging)
		{
			RoundsAnimator.Trigger(((EntityState)this).characterBody, "shoot");
			if (((EntityState)this).isAuthority)
			{
				Gun.Fire(((EntityState)this).characterBody, ((BaseState)this).GetAimRay(), shotCoefficient);
			}
			Util.PlaySound("Play_commando_M1", ((EntityState)this).gameObject);
		}
	}

	public override void FixedUpdate()
	{
		//IL_0112: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		((EntityState)this).FixedUpdate();
		if (charging)
		{
			RoundsAnimator.SetCharge(((EntityState)this).characterBody, Mathf.Clamp01(((EntityState)this).fixedAge));
			if (((EntityState)this).isAuthority && ((!((EntityState)this).inputBank.skill1.down && ((EntityState)this).fixedAge >= 0.1f) || ((EntityState)this).fixedAge >= 2f))
			{
				shotCoefficient *= Mathf.Lerp(0.75f, 2f, Mathf.Clamp01(((EntityState)this).fixedAge));
				Gun.Fire(((EntityState)this).characterBody, ((BaseState)this).GetAimRay(), shotCoefficient);
				RoundsAnimator.Trigger(((EntityState)this).characterBody, "shoot");
				Util.PlaySound("Play_commando_M1", ((EntityState)this).gameObject);
				charging = false;
				nextEcho = ((EntityState)this).fixedAge + 0.04f;
				duration = ((EntityState)this).fixedAge + 0.15f;
			}
			return;
		}
		if (echoes > 0 && ((EntityState)this).fixedAge >= nextEcho)
		{
			if (((EntityState)this).isAuthority)
			{
				Gun.Fire(((EntityState)this).characterBody, ((BaseState)this).GetAimRay(), shotCoefficient);
			}
			RoundsAnimator.Trigger(((EntityState)this).characterBody, "shoot");
			echoes--;
			nextEcho = ((EntityState)this).fixedAge + 0.02f;
		}
		if (((EntityState)this).isAuthority && ((EntityState)this).fixedAge >= duration && echoes == 0)
		{
			((EntityState)this).outer.SetNextStateToMain();
		}
	}

	public override InterruptPriority GetMinimumInterruptPriority()
	{
		return (InterruptPriority)1;
	}

	public override void OnExit()
	{
		RoundsAnimator.SetCharge(((EntityState)this).characterBody, 0f);
		((EntityState)this).OnExit();
	}
}
public sealed class RoundsBurst : BaseSkillState
{
	private int salvos;

	private float nextShot;

	public override void OnEnter()
	{
		((BaseState)this).OnEnter();
		((BaseState)this).StartAimMode(2f, false);
		Gun.BloodPrice(((EntityState)this).characterBody, 3f);
	}

	public override void FixedUpdate()
	{
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		((EntityState)this).FixedUpdate();
		if (salvos < 3 && ((EntityState)this).fixedAge >= nextShot)
		{
			if (((EntityState)this).isAuthority)
			{
				Gun.Fire(((EntityState)this).characterBody, ((BaseState)this).GetAimRay(), 3f);
			}
			RoundsAnimator.Trigger(((EntityState)this).characterBody, "shoot");
			Util.PlaySound("Play_commando_M1", ((EntityState)this).gameObject);
			salvos++;
			nextShot = ((EntityState)this).fixedAge + 0.13f / Mathf.Max(0.2f, ((BaseState)this).attackSpeedStat);
		}
		if (((EntityState)this).isAuthority && salvos >= 3 && ((EntityState)this).fixedAge >= nextShot)
		{
			((EntityState)this).outer.SetNextStateToMain();
		}
	}

	public override InterruptPriority GetMinimumInterruptPriority()
	{
		return (InterruptPriority)1;
	}
}
public sealed class RoundsBlock : BaseSkillState
{
	private float protection = 0.3f;

	public override void OnEnter()
	{
		//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: Expected O, but got Unknown
		//IL_0225: Unknown result type (might be due to invalid IL or missing references)
		//IL_022a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_023c: 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_029c: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a3: 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)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: 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_014a: Unknown result type (might be due to invalid IL or missing references)
		((BaseState)this).OnEnter();
		if (Object.op_Implicit((Object)(object)((EntityState)this).characterBody))
		{
			Visuals.ShowBlock(((EntityState)this).characterBody, 0.3f);
		}
		RoundsAnimator.Trigger(((EntityState)this).characterBody, "block");
		if (Object.op_Implicit((Object)(object)((EntityState)this).characterBody))
		{
			BuildStats buildStats = Plugin.Stats(((EntityState)this).characterBody);
			RoundsDriver roundsDriver = ((Component)((EntityState)this).characterBody).GetComponent<RoundsDriver>();
			if (!Object.op_Implicit((Object)(object)roundsDriver))
			{
				roundsDriver = ((Component)((EntityState)this).characterBody).gameObject.AddComponent<RoundsDriver>();
			}
			roundsDriver.ArmBlock(buildStats);
			protection = (buildStats.Mirror ? 0.18f : 0.3f);
			if (NetworkServer.active)
			{
				RoundsMechanics.For(((EntityState)this).characterBody).Block(buildStats);
			}
			if (((EntityState)this).isAuthority && buildStats.BlockTeleport > 0f)
			{
				Ray aimRay = ((BaseState)this).GetAimRay();
				Vector3 direction = ((Ray)(ref aimRay)).direction;
				Vector3 normalized = ((Vector3)(ref direction)).normalized;
				float num = buildStats.BlockTeleport;
				Vector3 corePosition = ((EntityState)this).characterBody.corePosition;
				float num2 = num;
				LayerIndex world = LayerIndex.world;
				RaycastHit val = default(RaycastHit);
				if (Physics.SphereCast(corePosition, 0.65f, normalized, ref val, num2, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask)))
				{
					num = Mathf.Max(0f, ((RaycastHit)(ref val)).distance - 0.7f);
				}
				TeleportHelper.TeleportBody(((EntityState)this).characterBody, ((EntityState)this).characterBody.footPosition + normalized * num);
			}
			if (buildStats.SawDamage > 0f)
			{
				Visuals.ShowBlock(((EntityState)this).characterBody, 2f);
			}
		}
		if (NetworkServer.active && Object.op_Implicit((Object)(object)((EntityState)this).characterBody))
		{
			BuildStats buildStats2 = Plugin.Stats(((EntityState)this).characterBody);
			((EntityState)this).characterBody.AddTimedBuff(Buffs.HiddenInvincibility, protection);
			if (buildStats2.BlockHeal > 0f)
			{
				((EntityState)this).healthComponent.Heal(((EntityState)this).characterBody.maxHealth * buildStats2.BlockHeal, default(ProcChainMask), true);
			}
			if (buildStats2.BlockBlast > 0f)
			{
				BlastAttack val2 = new BlastAttack();
				val2.attacker = ((EntityState)this).gameObject;
				val2.inflictor = ((EntityState)this).gameObject;
				val2.teamIndex = ((EntityState)this).characterBody.teamComponent.teamIndex;
				val2.position = ((EntityState)this).characterBody.corePosition;
				val2.radius = Mathf.Min(18f, 8f + buildStats2.BlockBlast);
				val2.baseDamage = ((EntityState)this).characterBody.damage * buildStats2.BlockBlast;
				val2.baseForce = 400f;
				val2.procCoefficient = 0.5f;
				val2.falloffModel = (FalloffModel)0;
				val2.attackerFiltering = (AttackerFiltering)2;
				val2.Fire();
			}
		}
		Util.PlaySound("Play_item_proc_bear", ((EntityState)this).gameObject);
	}

	public override void FixedUpdate()
	{
		((EntityState)this).FixedUpdate();
		if (((EntityState)this).isAuthority && ((EntityState)this).fixedAge >= protection)
		{
			((EntityState)this).outer.SetNextStateToMain();
		}
	}

	public override InterruptPriority GetMinimumInterruptPriority()
	{
		return (InterruptPriority)2;
	}
}
public sealed class RoundsHop : BaseSkillState
{
	public override void OnEnter()
	{
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: 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_0063: 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_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		((BaseState)this).OnEnter();
		RoundsAnimator.Trigger(((EntityState)this).characterBody, "hop");
		if (((EntityState)this).isAuthority && Object.op_Implicit((Object)(object)((EntityState)this).characterMotor))
		{
			((BaseCharacterController)((EntityState)this).characterMotor).Motor.ForceUnground(0.1f);
			Ray aimRay = ((BaseState)this).GetAimRay();
			Vector3 direction = ((Ray)(ref aimRay)).direction;
			direction.y = 0f;
			((EntityState)this).characterMotor.velocity = ((Vector3)(ref direction)).normalized * ((BaseState)this).moveSpeedStat * 2f + Vector3.up * 13f;
		}
		if (NetworkServer.active && Object.op_Implicit((Object)(object)((EntityState)this).characterBody))
		{
			((EntityState)this).characterBody.AddTimedBuff(Buffs.HiddenInvincibility, 0.2f);
		}
	}

	public override void FixedUpdate()
	{
		((EntityState)this).FixedUpdate();
		if (((EntityState)this).isAuthority && ((EntityState)this).fixedAge >= 0.15f)
		{
			((EntityState)this).outer.SetNextStateToMain();
		}
	}

	public override InterruptPriority GetMinimumInterruptPriority()
	{
		return (InterruptPriority)1;
	}
}
public sealed class RoundsImpact : MonoBehaviour, IProjectileImpactBehavior
{
	private static readonly List<RoundsImpact> Live = new List<RoundsImpact>();

	private static readonly Dictionary<GameObject, float> NextEffect = new Dictionary<GameObject, float>();

	private ProjectileController controller;

	private ProjectileDamage damage;

	private BuildStats stats;

	private int bounces;

	private bool done;

	private float lastBounce = -1f;

	private float targetTimer;

	private Transform target;

	public bool ChildShot;

	public float ForcedHoming;

	private float born;

	private float previousGrowth = 1f;

	private int chains;

	private Vector3 flightVelocity;

	private Rigidbody flightBody;

	private float travel;

	private float rangeBudget;

	private float gravity;

	private float baseColliderRadius;

	private readonly HashSet<HealthComponent> struck = new HashSet<HealthComponent>();

	public bool PlacementShot;

	private bool returning;

	private bool mine;

	private bool armed;

	private float stuckAt;

	private float portalReady;

	private float nextMineCheck;

	private Transform attached;

	private RoundsMechanics mechanics;

	private Vector3 previousPosition;

	internal bool IsMine
	{
		get
		{
			if (mine)
			{
				return !done;
			}
			return false;
		}
	}

	internal static void ResetEffects()
	{
		NextEffect.Clear();
	}

	internal static bool CanSpawn(GameObject owner)
	{
		if (Live.Count < 256)
		{
			return ActiveFor(owner) < 64;
		}
		return false;
	}

	internal static void RecallFor(GameObject owner)
	{
		RoundsImpact[] array = Live.ToArray();
		foreach (RoundsImpact roundsImpact in array)
		{
			if (Object.op_Implicit((Object)(object)roundsImpact) && Object.op_Implicit((Object)(object)roundsImpact.controller) && (Object)(object)roundsImpact.controller.owner == (Object)(object)owner && !roundsImpact.PlacementShot)
			{
				roundsImpact.Return();
			}
		}
	}

	internal static void DiscardFor(GameObject owner)
	{
		RoundsImpact[] array = Live.ToArray();
		foreach (RoundsImpact roundsImpact in array)
		{
			if (Object.op_Implicit((Object)(object)roundsImpact) && Object.op_Implicit((Object)(object)roundsImpact.controller) && (Object)(object)roundsImpact.controller.owner == (Object)(object)owner)
			{
				roundsImpact.Discard();
			}
		}
	}

	internal void Discard()
	{
		Finish();
	}

	private void Return()
	{
		//IL_00a0: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		if (!NetworkServer.active || done)
		{
			return;
		}
		mine = false;
		attached = null;
		returning = true;
		Collider[] components = ((Component)this).GetComponents<Collider>();
		foreach (Collider val in components)
		{
			val.enabled = true;
		}
		if (Object.op_Implicit((Object)(object)flightBody))
		{
			flightBody.isKinematic = false;
		}
		if (Object.op_Implicit((Object)(object)controller) && Object.op_Implicit((Object)(object)controller.owner))
		{
			CharacterBody component = controller.owner.GetComponent<CharacterBody>();
			if (Object.op_Implicit((Object)(object)component))
			{
				Transform transform = ((Component)this).transform;
				Vector3 position = transform.position;
				Vector3 val2 = component.corePosition - ((Component)this).transform.position;
				transform.position = position + ((Vector3)(ref val2)).normalized * 0.65f;
			}
			if (Object.op_Implicit((Object)(object)flightBody))
			{
				flightBody.position = ((Component)this).transform.position;
			}
		}
		travel = 0f;
		rangeBudget = Mathf.Max(60f, stats.Range);
		born = Time.fixedTime;
	}

	public static int ActiveFor(GameObject owner)
	{
		int num = 0;
		foreach (RoundsImpact item in Live)
		{
			if (Object.op_Implicit((Object)(object)item) && Object.op_Implicit((Object)(object)item.controller) && (Object)(object)item.controller.owner == (Object)(object)owner)
			{
				num++;
			}
		}
		return num;
	}

	private void OnEnable()
	{
		Live.Add(this);
	}

	private void OnDisable()
	{
		Live.Remove(this);
	}

	private void Awake()
	{
		controller = ((Component)this).GetComponent<ProjectileController>();
		damage = ((Component)this).GetComponent<ProjectileDamage>();
	}

	private void Start()
	{
		//IL_00a0: 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_00bd: 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)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: 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_020b: Unknown result type (might be due to invalid IL or missing references)
		CharacterBody body = (Object.op_Implicit((Object)(object)controller.owner) ? controller.owner.GetComponent<CharacterBody>() : null);
		stats = Plugin.Stats(body);
		mechanics = (Plugin.IsRounds(body) ? RoundsMechanics.For(body) : null);
		if (PlacementShot)
		{
			stats = new BuildStats();
		}
		stats.Homing = Mathf.Max(stats.Homing, ForcedHoming);
		born = Time.fixedTime;
		chains = stats.TargetBounces;
		previousPosition = ((Component)this).transform.position;
		flightBody = ((Component)this).GetComponent<Rigidbody>();
		flightVelocity = ((Component)this).transform.forward * 42f * stats.BulletSpeed;
		gravity = stats.Gravity * (ChildShot ? 1.35f : 1f);
		rangeBudget = stats.Range * (ChildShot ? 0.55f : 1f);
		ProjectileSimple component = ((Component)this).GetComponent<ProjectileSimple>();
		if (Object.op_Implicit((Object)(object)component))
		{
			((Behaviour)component).enabled = false;
		}
		if (Object.op_Implicit((Object)(object)flightBody) && NetworkServer.active)
		{
			flightBody.useGravity = false;
			flightBody.collisionDetectionMode = (CollisionDetectionMode)2;
			flightBody.velocity = flightVelocity;
		}
		bounces = stats.Bounces;
		SphereCollider component2 = ((Component)this).GetComponent<SphereCollider>();
		if (Object.op_Implicit((Object)(object)component2))
		{
			baseColliderRadius = component2.radius;
			component2.radius *= stats.BulletSize;
		}
		if (Object.op_Implicit((Object)(object)controller.ghost))
		{
			Transform transform = ((Component)controller.ghost).transform;
			transform.localScale *= Mathf.Min(stats.BulletSize, Plugin.Instance.VisualBulletSize.Value);
		}
	}

	private void FixedUpdate()
	{
		//IL_003c: 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_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_0391: Unknown result type (might be due to invalid IL or missing references)
		//IL_0396: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cc: 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_02dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e1: 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_0322: Unknown result type (might be due to invalid IL or missing references)
		//IL_0329: Unknown result type (might be due to invalid IL or missing references)
		//IL_033e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0358: Unknown result type (might be due to invalid IL or missing references)
		//IL_035d: 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_01fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0201: 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_0164: Unknown result type (might be due to invalid IL or missing references)
		//IL_0425: Unknown result type (might be due to invalid IL or missing references)
		//IL_044d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0452: Unknown result type (might be due to invalid IL or missing references)
		//IL_0518: Unknown result type (might be due to invalid IL or missing references)
		//IL_053f: Unknown result type (might be due to invalid IL or missing references)
		//IL_05b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_05c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_05cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_05d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_06cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_06d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_06e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_06e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0712: Unknown result type (might be due to invalid IL or missing references)
		//IL_0717: Unknown result type (might be due to invalid IL or missing references)
		//IL_071f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0721: Unknown result type (might be due to invalid IL or missing references)
		//IL_072c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0739: Unknown result type (might be due to invalid IL or missing references)
		//IL_073e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0757: Unknown result type (might be due to invalid IL or missing references)
		//IL_0661: Unknown result type (might be due to invalid IL or missing references)
		//IL_0666: Unknown result type (might be due to invalid IL or missing references)
		//IL_0671: Unknown result type (might be due to invalid IL or missing references)
		//IL_067c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0681: Unknown result type (might be due to invalid IL or missing references)
		//IL_0686: Unknown result type (might be due to invalid IL or missing references)
		if (!NetworkServer.active || done || stats == null)
		{
			return;
		}
		if (mine)
		{
			if (Object.op_Implicit((Object)(object)attached))
			{
				((Component)this).transform.position = attached.position;
			}
			if (Time.fixedTime - stuckAt > 25f)
			{
				Finish();
			}
			else if (stats.MineFuse > 0f && Time.fixedTime - stuckAt >= stats.MineFuse)
			{
				DetonateMine();
			}
			else if (stats.AutoMines && Time.fixedTime - stuckAt > 0.4f && Time.fixedTime >= nextMineCheck)
			{
				nextMineCheck = Time.fixedTime + 0.2f;
				if (EnemyNear())
				{
					DetonateMine();
				}
			}
			return;
		}
		if (!PlacementShot && Time.fixedTime >= portalReady)
		{
			Vector3 position = ((Component)this).transform.position;
			foreach (RoundsMechanics item in RoundsMechanics.Live)
			{
				if (Object.op_Implicit((Object)(object)item) && item.Warp(controller.owner, previousPosition, ref position, ref flightVelocity))
				{
					((Component)this).transform.position = position;
					if (Object.op_Implicit((Object)(object)flightBody))
					{
						flightBody.position = position;
					}
					portalReady = Time.fixedTime + 0.3f;
					break;
				}
			}
		}
		if (!PlacementShot && stats.ShootMines && Object.op_Implicit((Object)(object)mechanics))
		{
			RoundsImpact[] array = mechanics.Mines.ToArray();
			foreach (RoundsImpact roundsImpact in array)
			{
				if (Object.op_Implicit((Object)(object)roundsImpact) && roundsImpact.IsMine)
				{
					Vector3 val = ((Component)roundsImpact).transform.position - ((Component)this).transform.position;
					if (((Vector3)(ref val)).sqrMagnitude < 0.48999998f)
					{
						roundsImpact.DetonateMine();
						Finish();
						return;
					}
				}
			}
		}
		previousPosition = ((Component)this).transform.position;
		if (!PlacementShot && stats.Boomerang && !returning && Time.fixedTime - born >= 0.8f)
		{
			returning = true;
		}
		if (returning)
		{
			if (!Object.op_Implicit((Object)(object)controller.owner))
			{
				Finish();
				return;
			}
			CharacterBody component = controller.owner.GetComponent<CharacterBody>();
			if (!Object.op_Implicit((Object)(object)component) || !component.healthComponent.alive)
			{
				Finish();
				return;
			}
			Vector3 val2 = component.corePosition - ((Component)this).transform.position;
			if (((Vector3)(ref val2)).sqrMagnitude < 1.21f)
			{
				RoundsDriver component2 = ((Component)component).GetComponent<RoundsDriver>();
				if (Object.op_Implicit((Object)(object)component2))
				{
					component2.RefundAmmo();
				}
				RoundsAnimator.Trigger(component, "catch");
				Finish();
				return;
			}
			flightVelocity = Vector3.RotateTowards(((Vector3)(ref flightVelocity)).normalized, ((Vector3)(ref val2)).normalized, 9f * Time.fixedDeltaTime, 0f) * Mathf.Max(18f, ((Vector3)(ref flightVelocity)).magnitude);
		}
		float num = ((Object.op_Implicit((Object)(object)mechanics) && Time.fixedTime < mechanics.InvertUntil) ? (-1f) : 1f);
		flightVelocity += Vector3.down * 10f * gravity * num * Time.fixedDeltaTime;
		travel += ((Vector3)(ref flightVelocity)).magnitude * Time.fixedDeltaTime;
		if (travel >= rangeBudget || Time.fixedTime - born >= 8f)
		{
			Finish();
			return;
		}
		if (Object.op_Implicit((Object)(object)flightBody))
		{
			flightBody.velocity = flightVelocity;
		}
		if (((Vector3)(ref flightVelocity)).sqrMagnitude > 0.01f)
		{
			((Component)this).transform.rotation = Quaternion.LookRotation(((Vector3)(ref flightVelocity)).normalized);
		}
		if (stats.FlightGrowth > 0f)
		{
			float num2 = 1f + stats.FlightGrowth * Mathf.Clamp01((Time.fixedTime - born) / 2f);
			ProjectileDamage obj = damage;
			obj.damage *= num2 / previousGrowth;
			previousGrowth = num2;
			SphereCollider component3 = ((Component)this).GetComponent<SphereCollider>();
			if (Object.op_Implicit((Object)(object)component3))
			{
				component3.radius = baseColliderRadius * Mathf.Min(4f, stats.BulletSize * num2);
			}
			if (Object.op_Implicit((Object)(object)controller.ghost))
			{
				((Component)controller.ghost).transform.localScale = Vector3.one * Mathf.Min(Plugin.Instance.VisualBulletSize.Value, stats.BulletSize * num2);
			}
		}
		if (!MechanicRules.ShouldSeekEnemies(returning, PlacementShot) || stats.Homing <= 0f)
		{
			return;
		}
		targetTimer -= Time.fixedDeltaTime;
		if (targetTimer <= 0f)
		{
			targetTimer = 0.3f;
			float num3 = 1600f;
			target = null;
			TeamIndex objectTeam = TeamComponent.GetObjectTeam(controller.owner);
			Vector3 position2 = ((Component)this).transform.position;
			LayerIndex entityPrecise = LayerIndex.entityPrecise;
			Collider[] array2 = Physics.OverlapSphere(position2, 40f, LayerMask.op_Implicit(((LayerIndex)(ref entityPrecise)).mask));
			foreach (Collider val3 in array2)
			{
				HurtBox component4 = ((Component)val3).GetComponent<HurtBox>();
				if (Object.op_Implicit((Object)(object)component4) && Object.op_Implicit((Object)(object)component4.healthComponent) && !struck.Contains(component4.healthComponent) && component4.healthComponent.alive && Object.op_Implicit((Object)(object)component4.healthComponent.body) && component4.healthComponent.body.teamComponent.teamIndex != objectTeam)
				{
					Vector3 val4 = ((Component)component4).transform.position - ((Component)this).transform.position;
					float sqrMagnitude = ((Vector3)(ref val4)).sqrMagnitude;
					if (sqrMagnitude < num3)
					{
						num3 = sqrMagnitude;
						target = ((Component)component4).transform;
					}
				}
			}
		}
		if (Object.op_Implicit((Object)(object)target))
		{
			Vector3 normalized = ((Vector3)(ref flightVelocity)).normalized;
			Vector3 val5 = target.position - ((Component)this).transform.position;
			Vector3 val6 = Vector3.RotateTowards(normalized, ((Vector3)(ref val5)).normalized, stats.Homing * ((float)Math.PI / 180f) * Time.fixedDeltaTime, 0f);
			((Component)this).transform.rotation = Quaternion.LookRotation(val6);
			flightVelocity = val6 * ((Vector3)(ref flightVelocity)).magnitude;
			if (Object.op_Implicit((Object)(object)flightBody))
			{
				flightBody.velocity = flightVelocity;
			}
		}
	}

	public void OnProjectileImpact(ProjectileImpactInfo info)
	{
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: 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_019a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0477: Unknown result type (might be due to invalid IL or missing references)
		//IL_047e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: 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_04c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_04df: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_052a: Unknown result type (might be due to invalid IL or missing references)
		//IL_052f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0537: Unknown result type (might be due to invalid IL or missing references)
		//IL_0539: Unknown result type (might be due to invalid IL or missing references)
		//IL_054b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0552: Unknown result type (might be due to invalid IL or missing references)
		//IL_055c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0561: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_0699: Unknown result type (might be due to invalid IL or missing references)
		//IL_066e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0584: Unknown result type (might be due to invalid IL or missing references)
		//IL_0591: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: Unknown result type (might be due to invalid IL or missing references)
		//IL_024b: Expected O, but got Unknown
		//IL_0296: Unknown result type (might be due to invalid IL or missing references)
		//IL_029b: 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_02ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b6: 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_02c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0308: Unknown result type (might be due to invalid IL or missing references)
		//IL_030d: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_05fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0356: Unknown result type (might be due to invalid IL or missing references)
		//IL_0349: Unknown result type (might be due to invalid IL or missing references)
		//IL_0627: Unknown result type (might be due to invalid IL or missing references)
		//IL_0417: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
		if (!NetworkServer.active || done || !Object.op_Implicit((Object)(object)info.collider) || !Object.op_Implicit((Object)(object)controller) || !Object.op_Implicit((Object)(object)damage) || (Object.op_Implicit((Object)(object)controller.owner) && ((Component)info.collider).transform.IsChildOf(controller.owner.transform)))
		{
			return;
		}
		if (stats == null)
		{
			stats = new BuildStats();
		}
		if (!PlacementShot && Time.fixedTime >= portalReady)
		{
			Vector3 position = info.estimatedPointOfImpact;
			foreach (RoundsMechanics item in RoundsMechanics.Live)
			{
				if (Object.op_Implicit((Object)(object)item) && item.Warp(controller.owner, previousPosition, ref position, ref flightVelocity))
				{
					((Component)this).transform.position = position;
					previousPosition = position;
					if (Object.op_Implicit((Object)(object)flightBody))
					{
						flightBody.position = position;
						flightBody.velocity = flightVelocity;
					}
					portalReady = Time.fixedTime + 0.3f;
					return;
				}
			}
		}
		HurtBox component = ((Component)info.collider).GetComponent<HurtBox>();
		HealthComponent val = (Object.op_Implicit((Object)(object)component) ? component.healthComponent : ((Component)info.collider).GetComponent<HealthComponent>());
		if (Object.op_Implicit((Object)(object)val))
		{
			TeamIndex objectTeam = TeamComponent.GetObjectTeam(controller.owner);
			if ((Object.op_Implicit((Object)(object)val.body) && Object.op_Implicit((Object)(object)val.body.teamComponent) && val.body.teamComponent.teamIndex == objectTeam) || PlacementShot || !MechanicRules.CanDamage(stats.BankShot, armed))
			{
				return;
			}
			if (stats.StickyMines && !returning)
			{
				Stick(info.estimatedPointOfImpact, Object.op_Implicit((Object)(object)val.body) ? val.body.coreTransform : ((Component)val).transform);
			}
			else
			{
				if (!struck.Add(val))
				{
					return;
				}
				DamageInfo val2 = new DamageInfo();
				val2.attacker = controller.owner;
				val2.inflictor = ((Component)this).gameObject;
				val2.damage = damage.damage;
				val2.crit = damage.crit;
				val2.damageType = damage.damageType;
				val2.damageColorIndex = damage.damageColorIndex;
				val2.position = info.estimatedPointOfImpact;
				val2.force = ((Component)this).transform.forward * (damage.force + stats.Thruster);
				val2.procCoefficient = controller.procCoefficient;
				val2.procChainMask = controller.procChainMask;
				val.TakeDamage(val2);
				if (stats.Grapple && Object.op_Implicit((Object)(object)mechanics))
				{
					mechanics.GrappleTo(Object.op_Implicit((Object)(object)val.body) ? val.body.corePosition : info.estimatedPointOfImpact);
				}
				if (stats.Poison > 0f)
				{
					ParasiteTicks.Apply(val, controller.owner, val2.damage * stats.Poison);
				}
				if (Object.op_Implicit((Object)(object)GlobalEventManager.instance))
				{
					GlobalEventManager.instance.OnHitEnemy(val2, ((Component)val).gameObject);
					GlobalEventManager.instance.OnHitAll(val2, ((Component)val).gameObject);
				}
				Explode(info.estimatedPointOfImpact);
				if (MechanicRules.CanSpawnChildren(ChildShot) && stats.Fragments > 0)
				{
					SpawnChildren(info.estimatedPointOfImpact, stats.Fragments, 0.18f);
				}
				if (chains > 0 && ChainFrom(info.estimatedPointOfImpact))
				{
					chains--;
				}
				else if (stats.Boomerang)
				{
					if (stats.ReturnOnHit)
					{
						Return();
					}
				}
				else
				{
					Finish();
				}
			}
		}
		else if (PlacementShot)
		{
			if (Object.op_Implicit((Object)(object)mechanics))
			{
				mechanics.PlaceGate(info.estimatedPointOfImpact, info.estimatedImpactNormal);
			}
			Finish();
		}
		else if (bounces > 0 && Time.fixedTime - lastBounce > 0.04f && ((Vector3)(ref info.estimatedImpactNormal)).sqrMagnitude > 0.1f)
		{
			flightVelocity = Vector3.Reflect(flightVelocity, info.estimatedImpactNormal) * 0.86f;
			rangeBudget = travel + Mathf.Max(0f, rangeBudget - travel) * 0.85f;
			gravity = Ballistics.BounceGravity(gravity);
			Vector3 normalized = ((Vector3)(ref flightVelocity)).normalized;
			((Component)this).transform.rotation = Quaternion.LookRotation(normalized);
			((Component)this).transform.position = info.estimatedPointOfImpact + info.estimatedImpactNormal * 0.18f;
			Rigidbody component2 = ((Component)this).GetComponent<Rigidbody>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				component2.position = ((Component)this).transform.position;
				component2.velocity = flightVelocity;
			}
			bounces--;
			armed = true;
			if (stats.BounceRecharge && Object.op_Implicit((Object)(object)mechanics))
			{
				mechanics.BounceCharge();
			}
			lastBounce = Time.fixedTime;
			if (MechanicRules.CanDamage(stats.BankShot, armed))
			{
				Explode(info.estimatedPointOfImpact);
			}
			if (MechanicRules.CanSpawnChildren(ChildShot) && stats.BounceSplits > 0)
			{
				SpawnChildren(((Component)this).transform.position, stats.BounceSplits, 0.25f);
			}
		}
		else if (!(Time.fixedTime - lastBounce <= 0.04f))
		{
			if (stats.Mines && !returning)
			{
				Stick(info.estimatedPointOfImpact, null);
				return;
			}
			if (stats.Boomerang && !returning)
			{
				Return();
				return;
			}
			Explode(info.estimatedPointOfImpact);
			Finish();
		}
	}

	private void Stick(Vector3 point, Transform parent)
	{
		//IL_001f: 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)
		mine = true;
		stuckAt = Time.fixedTime;
		attached = parent;
		((Component)this).transform.position = point;
		Collider[] components = ((Component)this).GetComponents<Collider>();
		foreach (Collider val in components)
		{
			val.enabled = false;
		}
		if (Object.op_Implicit((Object)(object)flightBody))
		{
			flightBody.velocity = Vector3.zero;
			flightBody.isKinematic = true;
		}
		if (Object.op_Implicit((Object)(object)mechanics))
		{
			mechanics.AddMine(this);
		}
	}

	private bool EnemyNear()
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: 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_008f: Unknown result type (might be due to invalid IL or missing references)
		Vector3 position = ((Component)this).transform.position;
		LayerIndex entityPrecise = LayerIndex.entityPrecise;
		Collider[] array = Physics.OverlapSphere(position, 3f, LayerMask.op_Implicit(((LayerIndex)(ref entityPrecise)).mask));
		foreach (Collider val in array)
		{
			HurtBox component = ((Component)val).GetComponent<HurtBox>();
			if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.healthComponent) && component.healthComponent.alive && Object.op_Implicit((Object)(object)component.healthComponent.body) && component.healthComponent.body.teamComponent.teamIndex != TeamComponent.GetObjectTeam(controller.owner))
			{
				return true;
			}
		}
		return false;
	}

	internal void DetonateMine()
	{
		//IL_0059: 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)
		if (!NetworkServer.active || !mine || done)
		{
			return;
		}
		if (MechanicRules.CanDamage(stats.BankShot, armed))
		{
			float explosion = stats.Explosion;
			stats.Explosion = Mathf.Max(4f, explosion);
			Explode(((Component)this).transform.position);
			stats.Explosion = explosion;
			if (MechanicRules.CanSpawnChildren(ChildShot) && stats.Fragments > 0)
			{
				SpawnChildren(((Component)this).transform.position, stats.Fragments, 0.18f);
			}
		}
		Finish();
	}

	private void SpawnChildren(Vector3 point, int count, float share)
	{
		//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_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: 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_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_010a: Unknown result type (might be due to invalid IL or missing references)
		int num = Mathf.Max(0, 64 - ActiveFor(controller.owner));
		for (int i = 0; i < Mathf.Min(count, num); i++)
		{
			Vector3 val = Quaternion.AngleAxis(((float)i - (float)(count - 1) * 0.5f) * 38f, Vector3.up) * ((Component)this).transform.forward;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			FireProjectileInfo val2 = new FireProjectileInfo
			{
				projectilePrefab = Plugin.ChildProjectilePrefab,
				owner = controller.owner,
				position = point + normalized * 0.8f,
				rotation = Quaternion.LookRotation(normalized),
				damage = damage.damage * share,
				crit = damage.crit,
				force = damage.force
			};
			((FireProjectileInfo)(ref val2)).speedOverride = 42f * stats.BulletSpeed;
			if (CanSpawn(controller.owner))
			{
				ProjectileManager.instance.FireProjectile(val2);
			}
		}
	}

	private bool ChainFrom(Vector3 point)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: 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_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_0028: 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_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: 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_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0169: 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_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0199: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		HurtBox val = null;
		float num = 625f;
		TeamIndex objectTeam = TeamComponent.GetObjectTeam(controller.owner);
		LayerIndex entityPrecise = LayerIndex.entityPrecise;
		Collider[] array = Physics.OverlapSphere(point, 25f, LayerMask.op_Implicit(((LayerIndex)(ref entityPrecise)).mask));
		foreach (Collider val2 in array)
		{
			HurtBox component = ((Component)val2).GetComponent<HurtBox>();
			if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.healthComponent) && !struck.Contains(component.healthComponent) && component.healthComponent.alive && Object.op_Implicit((Object)(object)component.healthComponent.body) && component.healthComponent.body.teamComponent.teamIndex != objectTeam)
			{
				Vector3 val3 = ((Component)component).transform.position - point;
				float sqrMagnitude = ((Vector3)(ref val3)).sqrMagnitude;
				if (sqrMagnitude < num)
				{
					num = sqrMagnitude;
					val = component;
				}
			}
		}
		if (!Object.op_Implicit((Object)(object)val))
		{
			return false;
		}
		Vector3 val4 = ((Component)val).transform.position - point;
		Vector3 normalized = ((Vector3)(ref val4)).normalized;
		((Component)this).transform.rotation = Quaternion.LookRotation(normalized);
		((Component)this).transform.position = point + normalized * 0.8f;
		target = ((Component)val).transform;
		ProjectileDamage obj = damage;
		obj.damage *= 0.65f;
		flightVelocity = normalized * ((Vector3)(ref flightVelocity)).magnitude;
		Rigidbody component2 = ((Component)this).GetComponent<Rigidbody>();
		if (Object.op_Implicit((Object)(object)component2))
		{
			component2.position = ((Component)this).transform.position;
			component2.velocity = flightVelocity;
		}
		return true;
	}

	private void Explode(Vector3 point)
	{
		//IL_0026: 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_002c: 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_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0184: Expected O, but got Unknown
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: 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)
		//IL_01bd: 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_0221: 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_0257: Unknown result type (might be due to invalid IL or missing references)
		//IL_0263: Unknown result type (might be due to invalid IL or missing references)
		//IL_0268: Unknown result type (might be due to invalid IL or missing references)
		//IL_026c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0421: Unknown result type (might be due to invalid IL or missing references)
		//IL_0428: Expected O, but got Unknown
		//IL_042a: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: 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_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0112: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_037d: Unknown result type (might be due to invalid IL or missing references)
		if (stats.GravityPull > 0f)
		{
			HashSet<HealthComponent> hashSet = new HashSet<HealthComponent>();
			TeamIndex objectTeam = TeamComponent.GetObjectTeam(controller.owner);
			float num = Mathf.Max(8f, stats.Explosion);
			LayerIndex entityPrecise = LayerIndex.entityPrecise;
			Collider[] array = Physics.OverlapSphere(point, num, LayerMask.op_Implicit(((LayerIndex)(ref entityPrecise)).mask));
			foreach (Collider val in array)
			{
				HurtBox component = ((Component)val).GetComponent<HurtBox>();
				if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.healthComponent) || !component.healthComponent.alive || !Object.op_Implicit((Object)(object)component.healthComponent.body) || !hashSet.Add(component.healthComponent))
				{
					continue;
				}
				CharacterBody body = component.healthComponent.body;
				if (!Object.op_Implicit((Object)(object)body.teamComponent) || body.teamComponent.teamIndex == objectTeam)
				{
					continue;
				}
				Vector3 val2 = point - body.corePosition;
				Vector3 val3 = ((Vector3)(ref val2)).normalized * stats.GravityPull;
				if (Object.op_Implicit((Object)(object)body.characterMotor))
				{
					CharacterMotor characterMotor = body.characterMotor;
					characterMotor.velocity += val3;
					continue;
				}
				Rigidbody component2 = ((Component)body).GetComponent<Rigidbody>();
				if (Object.op_Implicit((Object)(object)component2))
				{
					component2.AddForce(val3, (ForceMode)2);
				}
			}
		}
		if (stats.Explosion <= 0f)
		{
			return;
		}
		BlastAttack val4 = new BlastAttack();
		val4.attacker = controller.owner;
		val4.inflictor = ((Component)this).gameObject;
		val4.position = point;
		val4.teamIndex = TeamComponent.GetObjectTeam(controller.owner);
		val4.radius = stats.Explosion;
		val4.baseDamage = damage.damage * 0.6f;
		val4.crit = damage.crit;
		val4.baseForce = 150f;
		val4.procCoefficient = 0.3f;
		val4.attackerFiltering = (AttackerFiltering)2;
		val4.falloffModel = (FalloffModel)1;
		val4.Fire();
		if (stats.Poison > 0f || stats.Grapple)
		{
			HashSet<HealthComponent> hashSet2 = new HashSet<HealthComponent>();
			float explosion = stats.Explosion;
			LayerIndex entityPrecise2 = LayerIndex.entityPrecise;
			Collider[] array2 = Physics.OverlapSphere(point, explosion, LayerMask.op_Implicit(((LayerIndex)(ref entityPrecise2)).mask));
			foreach (Collider val5 in array2)
			{
				HurtBox component3 = ((Component)val5).GetComponent<HurtBox>();
				if (Object.op_Implicit((Object)(object)component3) && Object.op_Implicit((Object)(object)component3.healthComponent) && component3.healthComponent.alive && Object.op_Implicit((Object)(object)component3.healthComponent.body) && component3.healthComponent.body.teamComponent.teamIndex != val4.teamIndex && hashSet2.Add(component3.healthComponent))
				{
					if (stats.Poison > 0f)
					{
						ParasiteTicks.Apply(component3.healthComponent, controller.owner, damage.damage * 0.6f * stats.Poison);
					}
					if (stats.Grapple && Object.op_Implicit((Object)(object)mechanics))
					{
						mechanics.GrappleTo(component3.healthComponent.body.corePosition);
					}
				}
			}
		}
		float value = Plugin.Instance.EffectRate.Value;
		if (!(value <= 0f) && Object.op_Implicit((Object)(object)controller.owner) && (!NextEffect.TryGetValue(controller.owner, out var value2) || !(Time.time < value2)))
		{
			NextEffect[controller.owner] = Time.time + 1f / value;
			GameObject val6 = LegacyResourcesAPI.Load<GameObject>("Prefabs/Effects/ImpactEffects/ImpactCommando");
			if (Object.op_Implicit((Object)(object)val6))
			{
				EffectData val7 = new EffectData();
				val7.origin = point;
				val7.scale = Plugin.Instance.EffectScale.Value;
				EffectManager.SpawnEffect(val6, val7, true);
			}
		}
	}

	private void Finish()
	{
		if (!done)
		{
			done = true;
			if (NetworkServer.active)
			{
				NetworkServer.Destroy(((Component)this).gameObject);
			}
		}
	}
}
public sealed class DraftUI : MonoBehaviour
{
	private bool open;

	private CursorOpener cursor;

	private int waitingToken = -1;

	private float waitUntil;

	private int lastRemaining;

	private float noticeUntil;

	private GUIStyle title;

	private GUIStyle text;

	private GUIStyle cardStyle;

	private Texture2D background;

	private Vector2 scroll;

	private float dealStarted;

	private int displayedToken = -1;

	private GUIStyle cardName;

	private GUIStyle effectText;

	private GUIStyle badge;

	private GUIStyle pickHint;

	private void Awake()
	{
		MPEventSystemProvider val = ((Component)this).gameObject.AddComponent<MPEventSystemProvider>();
		val.fallBackToMainEventSystem = true;
		cursor = ((Component)this).gameObject.AddComponent<CursorOpener>();
		((Behaviour)cursor).enabled = false;
	}

	private NetworkUser LocalPlayer()
	{
		foreach (NetworkUser readOnlyLocalPlayers in NetworkUser.readOnlyLocalPlayersList)
		{
			if (Object.op_Implicit((Object)(object)readOnlyLocalPlayers) && Object.op_Implicit((Object)(object)readOnlyLocalPlayers.master) && Plugin.IsRounds(readOnlyLocalPlayers.GetCurrentBody()))
			{
				return readOnlyLocalPlayers;
			}
		}
		return null;
	}

	private void Update()
	{
		//IL_0098: 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)
		if (!Object.op_Implicit((Object)(object)Plugin.Instance))
		{
			return;
		}
		NetworkUser val = LocalPlayer();
		if (!Object.op_Implicit((Object)(object)Run.instance) || !Object.op_Implicit((Object)(object)val) || !Plugin.Decks.TryGetValue(Plugin.Id(val.master), out var value))
		{
			open = false;
			((Behaviour)cursor).enabled = false;
			lastRemaining = 0;
			return;
		}
		if (value.Remaining > lastRemaining)
		{
			noticeUntil = Time.unscaledTime + 8f;
		}
		lastRemaining = value.Remaining;
		bool flag = open;
		if (Input.GetKeyDown(Plugin.Instance.DraftKey.Value))
		{
			open = !open;
		}
		if (Input.GetKeyDown((KeyCode)27))
		{
			open = false;
		}
		if (open && (!flag || displayedToken != value.Token))
		{
			dealStarted = Time.unscaledTime;
			displayedToken = value.Token;
			scroll = Vector2.zero;
		}
		((Behaviour)cursor).enabled = open;
		if (!open || value.Remaining <= 0)
		{
			return;
		}
		for (int i = 0; i < value.Offer.Length; i++)
		{
			if (Input.GetKeyDown((KeyCode)(49 + i)))
			{
				Pick(val, value, i);
			}
		}
	}

	private void Pick(NetworkUser user, Draft draft, int index)
	{
		if (waitingToken != draft.Token || !(Time.unscaledTime < waitUntil))
		{
			waitingToken = draft.Token;
			waitUntil = Time.unscaledTime + 2f;
			Net.Choose(user, draft, index);
		}
	}

	private void OnDestroy()
	{
		if (Object.op_Implicit((Object)(object)cursor))
		{
			((Behaviour)cursor).enabled = false;
			Object.Destroy((Object)(object)cursor);
		}
		if (Object.op_Implicit((Object)(object)background))
		{
			Object.Destroy((Object)(object)background);
		}
	}

	private void OnGUI()
	{
		//IL_026c: 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_0062: Expected O, but got Unknown
		//IL_0086: 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_00a5: Expected O, but got Unknown
		//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Expected O, but got Unknown
		//IL_00fc: 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_0126: Expected O, but got Unknown
		//IL_014a: 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_0182: Expected O, but got Unknown
		//IL_0189: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: Expected O, but got Unknown
		//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c9: Expected O, but got Unknown
		//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: Expected O, but got Unknown
		//IL_021f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: Expected O, but got Unknown
		//IL_02db: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0432: Unknown result type (might be due to invalid IL or missing references)
		//IL_0487: Unknown result type (might be due to invalid IL or missing references)
		//IL_0775: Unknown result type (might be due to invalid IL or missing references)
		//IL_0332: Unknown result type (might be due to invalid IL or missing references)
		//IL_0346: Unknown result type (might be due to invalid IL or missing references)
		//IL_07dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0563: Unknown result type (might be due to invalid IL or missing references)
		//IL_0575: Expected O, but got Unknown
		//IL_060d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0610: Unknown result type (might be due to invalid IL or missing references)
		//IL_0636: Unknown result type (might be due to invalid IL or missing references)
		//IL_063b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0640: Unknown result type (might be due to invalid IL or missing references)
		//IL_070c: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)Plugin.Instance) || !Object.op_Implicit((Object)(object)Run.instance))
		{
			return;
		}
		NetworkUser val = LocalPlayer();
		if (!Object.op_Implicit((Object)(object)val) || !Plugin.Decks.TryGetValue(Plugin.Id(val.master), out var value))
		{
			return;
		}
		if (title == null)
		{
			title = new GUIStyle(GUI.skin.label);
			title.fontSize = 28;
			title.fontStyle = (FontStyle)1;
			title.normal.textColor = Color.white;
			this.text = new GUIStyle(GUI.skin.label);
			this.text.fontSize = 16;
			this.text.wordWrap = true;
			this.text.normal.textColor = Color.white;
			background = new Texture2D(1, 1);
			background.SetPixel(0, 0, new Color(0.025f, 0.055f, 0.09f, 0.96f));
			background.Apply();
			cardStyle = new GUIStyle(GUI.skin.button);
			cardStyle.fontSize = 16;
			cardStyle.wordWrap = true;
			cardStyle.normal.textColor = Color.white;
			cardStyle.normal.background = background;
			cardStyle.padding = new RectOffset(15, 15, 15, 15);
			cardName = new GUIStyle(this.text);
			cardName.fontSize = 19;
			cardName.fontStyle = (FontStyle)1;
			cardName.alignment = (TextAnchor)4;
			effectText = new GUIStyle(this.text);
			effectText.fontSize = 15;
			effectText.alignment = (TextAnchor)0;
			badge = new GUIStyle(this.text);
			badge.fontSize = 12;
			badge.fontStyle = (FontStyle)1;
			badge.alignment = (TextAnchor)4;
			pickHint = new GUIStyle(badge);
			pickHint.fontSize = 14;
		}
		string text = string.Concat("ROUNDS  |  ", value.Remaining, " picks waiting  |  ", Plugin.Instance.DraftKey.Value, " : cards");
		CharacterBody currentBody = val.GetCurrentBody();
		MechanicsVisual mechanicsVisual = (Object.op_Implicit((Object)(object)currentBody) ? ((Component)currentBody).GetComponent<MechanicsVisual>() : null);
		if (Object.op_Implicit((Object)(object)mechanicsVisual))
		{
			text += mechanicsVisual.Hint;
		}
		GUI.Label(new Rect(24f, (float)Screen.height - 72f, (float)Screen.width - 48f, 32f), text, this.text);
		if (!open && value.Remaining > 0 && Time.unscaledTime < noticeUntil)
		{
			GUI.Label(new Rect((float)Screen.width * 0.5f - 300f, (float)Screen.height * 0.22f, 650f, 55f), "CARD DRAW READY! Press " + Plugin.Instance.DraftKey.Value, title);
		}
		if (!open)
		{
			return;
		}
		float num = Mathf.Min((float)Screen.width - 40f, 1320f);
		float num2 = Mathf.Min((float)Screen.height - 40f, 740f);
		Rect val2 = default(Rect);
		((Rect)(ref val2))..ctor(((float)Screen.width - num) * 0.5f, ((float)Screen.height - num2) * 0.5f, num, num2);
		GUI.DrawTexture(val2, (Texture)(object)background);
		GUI.Label(new Rect(((Rect)(ref val2)).x + 24f, ((Rect)(ref val2)).y + 16f, num - 48f, 40f), "ONE MORE CARD", title);
		GUI.Label(new Rect(((Rect)(ref val2)).x + 24f, ((Rect)(ref val2)).y + 59f, num - 48f, 40f), string.Concat("Choose a card with the mouse or keys 1-", value.Offer.Length, ".  ", value.Remaining, " picks waiting.  ", Plugin.Instance.DraftKey.Value, " closes the hand. The run keeps moving."), this.text);
		if (value.Remaining > 0)
		{
			float num3 = num - 48f;
			int num4 = Mathf.Min(value.Offer.Length, (num3 >= 1000f) ? 5 : ((num3 >= 760f) ? 4 : ((num3 >= 540f) ? 3 : 2)));
			num4 = Mathf.Max(1, num4);
			float num5 = 12f;
			float num6 = (num3 - (float)(num4 - 1) * num5 - 18f) / (float)num4;
			float num7 = Mathf.Min(num6 - 24f, 198f);
			float num8 = 90f;
			int[] offer = value.Offer;
			foreach (int num9 in offer)
			{
				num8 = Mathf.Max(num8, effectText.CalcHeight(new GUIContent(Cards.All[num9].Description), num6 - 28f) + 6f);
			}
			float num10 = num7 + num8 + 142f;
			int num11 = Mathf.CeilToInt((float)value.Offer.Length / (float)num4);
			Rect val3 = default(Rect);
			((Rect)(ref val3))..ctor(((Rect)(ref val2)).x + 24f, ((Rect)(ref val2)).y + 108f, num3, num2 - 204f);
			float num12 = Mathf.Max(0f, 1f - (Time.unscaledTime - dealStarted) * 3f) * 64f + 8f;
			scroll = GUI.BeginScrollView(val3, scroll, new Rect(0f, 0f, num3 - 18f, (float)num11 * (num10 + 20f) + num12));
			bool flag = waitingToken == value.Token && Time.unscaledTime < waitUntil;
			GUI.enabled = !flag;
			Rect rect = default(Rect);
			for (int j = 0; j < value.Offer.Length; j++)
			{
				Card card = Cards.All[value.Offer[j]];
				string rarity = card.Rarity.ToString().ToUpperInvariant();
				float num13 = Mathf.Clamp01((Time.unscaledTime - dealStarted - (float)j * 0.035f) / 0.24f);
				float num14 = (1f - num13) * (1f - num13) * 64f;
				((Rect)(ref rect))..ctor((float)(j % num4) * (num6 + num5), (float)(j / num4) * (num10 + 20f) + num14 + 6f, num6, num10);
				DrawCard(rect, card, value.Offer[j], rarity, j + 1, num7, num8, flag, val, value);
			}
			GUI.enabled = true;
			GUI.EndScrollView();
		}
		else
		{
			GUI.Label(new Rect(((Rect)(ref val2)).x + 24f, ((Rect)(ref val2)).y + 120f, num - 48f, 80f), "No picks waiting. Level up or finish charging a teleporter to draw more.", this.text);
		}
		int num15 = 0;
		int[] stacks = value.Stacks;
		foreach (int num16 in stacks)
		{
			num15 += num16;
		}
		GUI.Label(new Rect(((Rect)(ref val2)).x + 24f, ((Rect)(ref val2)).yMax - 86f, num - 48f, 72f), "Deck: " + num15 + " cards. Bullet gravity is real. Each wall bounce loses 14% speed / 15% remaining range and adds 12% drop.\nPellets and echoes share damage. Lifesteal caps at 10% max health/s. Legendary rules unlock after 8 owned cards.", this.text);
	}

	private void DrawCard(Rect rect, Card card, int artIndex, string rarity, int number, float artHeight, float descriptionHeight, bool waiting, NetworkUser user, Draft draft)
	{
		//IL_000e: 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_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)
		//IL_00aa: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0228: Unknown result type (might be due to invalid IL or missing references)
		//IL_026a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: 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)
		if (GUI.enabled && ((Rect)(ref rect)).Contains(Event.current.mousePosition))
		{
			((Rect)(ref rect)).y = ((Rect)(ref rect)).y - 4f;
		}
		Color color = GUI.color;
		Color textColor = (GUI.color = ((card.Rarity == CardRarity.Legendary) ? new Color(0.78f, 0.59f, 1f) : ((card.Rarity == CardRarity.Rare) ? new Color(1f, 0.81f, 0.44f) : ((card.Rarity == CardRarity.Uncommon) ? new Color(0.53f, 0.92f, 0.72f) : new Color(0.33f, 0.84f, 0.92f)))));
		GUI.DrawTexture(rect, (Texture)(object)Texture2D.whiteTexture);
		GUI.color = new Color(0.055f, 0.095f, 0.15f);
		GUI.DrawTexture(new Rect(((Rect)(ref rect)).x + 2f, ((Rect)(ref rect)).y + 2f, ((Rect)(ref rect)).width - 4f, ((Rect)(ref rect)).height - 4f), (Texture)(object)Texture2D.whiteTexture);
		GUI.color = color;
		badge.normal.textColor = textColor;
		GUI.Label(new Rect(((Rect)(ref rect)).x + 10f, ((Rect)(ref rect)).y + 8f, ((Rect)(ref rect)).width - 20f, 24f), rarity + "  /  " + number, badge);
		GUI.DrawTexture(new Rect(((Rect)(ref rect)).x + (((Rect)(ref rect)).width - artHeight) * 0.5f, ((Rect)(ref rect)