Decompiled source of Control Enemies Mod v1.0.2

UMM/Mods/Control Enemies Mod/Control Enemies Mod.dll

Decompiled 3 weeks ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using BitCode;
using BroMakerLib;
using BroMakerLib.CustomObjects;
using BroMakerLib.Loaders;
using HarmonyLib;
using Localisation;
using Networking;
using Rewired;
using RocketLib;
using RocketLib.Utils;
using TFBGames.Management.Asset;
using UnityEngine;
using UnityModManagerNet;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Control Enemies Mod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Control Enemies Mod")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("52724136-162b-41e7-94f7-ea1e65b59a0c")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Control_Enemies_Mod;

public enum GhostState
{
	Idle,
	Attacking,
	Taunting,
	Resurrecting,
	Reviving
}
public class GhostPlayer : MonoBehaviour
{
	public int playerNum;

	public Player player;

	public float spawnDelay = 0.25f;

	public GhostState state;

	public Vector3 overrideSpawnPoint = Vector3.zero;

	protected bool ableToRevive;

	protected float forceReviveTime;

	protected float startReviveFlashTime;

	public const float ghostSpawnOffset = 16f;

	public SpriteSM sprite;

	public float currentTransparency;

	protected const float finalTransparency = 0.75f;

	public Color playerColor = new Color(1f, 1f, 1f);

	public int frame;

	protected float frameCounter;

	protected const float idleFramerate = 0.11f;

	protected float attackingFramerate = 0.08f;

	protected float dancingFramerate = 0.11f;

	protected float resurrectingFramerate = 0.11f;

	protected float reviveFramerate = 0.11f;

	protected const float spriteWidth = 32f;

	protected const float spriteHeight = 32f;

	protected Color reviveColor = new Color(1f, 0.8431f, 0f);

	public static Color[] playerColors = (Color[])(object)new Color[4]
	{
		new Color(0f, 0.5f, 1f),
		new Color(1f, 0f, 0f),
		new Color(1f, 0.45f, 0f),
		new Color(0.55f, 0f, 1f)
	};

	public static Color burningColor = new Color(0.53f, 0.05f, 0.15f);

	public bool up;

	public bool left;

	public bool down;

	public bool right;

	public bool fire;

	public bool buttonJump;

	public bool special;

	public bool highfive;

	public bool buttonGesture;

	public bool sprint;

	protected float yI;

	protected float xI;

	protected const float normalSpeed = 130f;

	protected const float sprintSpeed = 180f;

	protected const float accelerationFactor = 3.5f;

	protected const float decelerationFactor = 1.5f;

	protected float screenMinX;

	protected float screenMaxX;

	protected float screenMinY;

	protected float screenMaxY;

	protected bool usingController;

	protected int controllerNum;

	private TestVanDammeAnim characterToPossess;

	private Vector3 frozenPosition = Vector3.zero;

	private float frozenXI;

	private float frozenYI;

	public void Setup()
	{
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			MeshRenderer component = ((Component)this).gameObject.GetComponent<MeshRenderer>();
			Material material = ResourcesController.GetMaterial(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "sprites"), "ghostSprite.png");
			((Renderer)component).material = material;
			sprite = ((Component)this).gameObject.GetComponent<SpriteSM>();
			sprite.SetTextureDefaults();
			((SpriteBase)sprite).SetSize(32f, 32f);
			sprite.lowerLeftPixel = new Vector2(0f, 32f);
			sprite.pixelDimensions = new Vector2(32f, 32f);
			((SpriteBase)sprite).plane = (SPRITE_PLANE)0;
			((SpriteBase)sprite).width = 32f;
			((SpriteBase)sprite).height = 32f;
			((SpriteBase)sprite).color = new Color(playerColor.r, playerColor.g, playerColor.b, currentTransparency);
			((SpriteBase)sprite).CalcUVs();
			((SpriteBase)sprite).UpdateUVs();
			((SpriteBase)sprite).offset = new Vector3(0f, 0f, 0f);
			((Component)this).gameObject.layer = 28;
		}
		catch (Exception ex)
		{
			Main.Log("Exception creating ghost: " + ex.ToString());
		}
	}

	public virtual void Start()
	{
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Unknown result type (might be due to invalid IL or missing references)
		player = HeroController.players[playerNum];
		playerColor = playerColors[playerNum];
		if (Main.isBurning && playerNum == 1)
		{
			playerColor = burningColor;
		}
		if (player.controllerNum > 3)
		{
			usingController = true;
			controllerNum = player.controllerNum - 4;
		}
	}

	public void SetSpawn()
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val;
		if (overrideSpawnPoint == Vector3.zero)
		{
			val = Map.FindStartLocation();
			if (Mathf.Abs(SortOfFollow.GetScreenMinX() - val.x) < 100f)
			{
				val.y += 40f;
				val.x = SortOfFollow.GetScreenMinX() + 25f + (SortOfFollow.GetScreenMaxX() - SortOfFollow.GetScreenMinX() - 50f) / 4f * (float)(playerNum + 1);
			}
			else
			{
				val.y = SortOfFollow.GetScreenMinY() + 60f + (SortOfFollow.GetScreenMaxY() - SortOfFollow.GetScreenMinY()) / 2f;
				val.x = SortOfFollow.GetScreenMinX() + 25f + (SortOfFollow.GetScreenMaxX() - SortOfFollow.GetScreenMinX() - 50f) / 4f * (float)(playerNum + 1);
			}
		}
		else
		{
			val = overrideSpawnPoint;
			val.y += 16f;
		}
		((Component)this).transform.position = val;
	}

	public virtual void Update()
	{
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		if (spawnDelay > 0f)
		{
			spawnDelay -= Time.deltaTime;
			if (spawnDelay <= 0f)
			{
				SetSpawn();
			}
			return;
		}
		HandleTransparency();
		HandleInput();
		ConstrainToScreen();
		ChangeFrame();
		if (ableToRevive && state != GhostState.Reviving)
		{
			forceReviveTime -= Time.deltaTime;
			if (forceReviveTime <= 0f)
			{
				StartReviving();
			}
			else
			{
				float num = 0.5f + Mathf.Sin((Time.time - startReviveFlashTime) * 15f) * 0.23f;
				Color val = default(Color);
				((Color)(ref val))..ctor(num, num, num, 1f);
				((Component)sprite).GetComponent<Renderer>().material.SetColor("_TintColor", val);
			}
		}
		if (state == GhostState.Attacking && ((Object)(object)characterToPossess == (Object)null || !((BroforceObject)characterToPossess).IsAlive() || ((BroforceObject)characterToPossess).health <= 0))
		{
			if ((Object)(object)characterToPossess != (Object)null)
			{
				((Object)characterToPossess).name = "enemy";
			}
			characterToPossess = null;
			state = GhostState.Idle;
			frame = 0;
			SetFrame();
		}
	}

	public virtual void LateUpdate()
	{
		if ((Object)(object)characterToPossess != (Object)null)
		{
			((BroforceObject)characterToPossess).X = frozenPosition.x;
			((BroforceObject)characterToPossess).Y = frozenPosition.y;
			((BroforceObject)characterToPossess).xI = frozenXI;
			((BroforceObject)characterToPossess).yI = frozenYI;
		}
	}

	public void HandleTransparency()
	{
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		if (currentTransparency < 0.75f)
		{
			currentTransparency += Time.deltaTime / 1.5f;
			if (currentTransparency > 0.75f)
			{
				currentTransparency = 0.75f;
			}
			((SpriteBase)sprite).SetColor(new Color(playerColor.r, playerColor.g, playerColor.b, currentTransparency));
		}
	}

	public void HandleInput()
	{
		//IL_06b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_06db: Unknown result type (might be due to invalid IL or missing references)
		//IL_071b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0462: 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_0488: Unknown result type (might be due to invalid IL or missing references)
		//IL_04fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_05c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_05c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_05fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0620: Unknown result type (might be due to invalid IL or missing references)
		//IL_0626: Unknown result type (might be due to invalid IL or missing references)
		//IL_022f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0275: Unknown result type (might be due to invalid IL or missing references)
		//IL_0258: Unknown result type (might be due to invalid IL or missing references)
		//IL_029e: Unknown result type (might be due to invalid IL or missing references)
		player.GetInput(ref up, ref down, ref left, ref right, ref fire, ref buttonJump, ref special, ref highfive, ref buttonGesture, ref sprint);
		if (state == GhostState.Idle || state == GhostState.Reviving)
		{
			sprint = InputReader.GetDashStart(player.controllerNum);
			if (usingController)
			{
				Player val = ReInput.players.GetPlayer(controllerNum);
				float num = val.GetAxis("Up") - val.GetAxis("Down");
				float num2 = val.GetAxis("Right") - val.GetAxis("Left");
				float num3 = (sprint ? 180f : 130f);
				if (Mathf.Abs(yI) < Mathf.Abs(num * num3))
				{
					yI += num * num3 * Time.deltaTime * 3.5f;
				}
				if (yI > num3)
				{
					yI = num3;
				}
				else if (yI < 0f - num3)
				{
					yI = 0f - num3;
				}
				if (Mathf.Abs(xI) < Mathf.Abs(num2 * num3))
				{
					xI += num2 * num3 * Time.deltaTime * 3.5f;
				}
				if (xI > num3)
				{
					xI = num3;
				}
				else if (xI < 0f - num3)
				{
					xI = 0f - num3;
				}
				if (!up && !down)
				{
					if (yI > 0f)
					{
						yI -= num3 * Time.deltaTime * 1.5f;
						if (yI < 0f)
						{
							yI = 0f;
						}
					}
					else if (yI < 0f)
					{
						yI += num3 * Time.deltaTime * 1.5f;
						if (yI > 0f)
						{
							yI = 0f;
						}
					}
				}
				if (right)
				{
					if (((Component)this).transform.localScale.x != 1f)
					{
						((Component)this).transform.localScale = new Vector3(1f, 1f, 1f);
					}
				}
				else if (left)
				{
					if (((Component)this).transform.localScale.x != -1f)
					{
						((Component)this).transform.localScale = new Vector3(-1f, 1f, 1f);
					}
				}
				else if (xI > 0f)
				{
					xI -= num3 * Time.deltaTime * 1.5f;
					if (xI < 0f)
					{
						xI = 0f;
					}
				}
				else if (xI < 0f)
				{
					xI += num3 * Time.deltaTime * 1.5f;
					if (xI > 0f)
					{
						xI = 0f;
					}
				}
			}
			else
			{
				float num4 = (sprint ? 180f : 130f);
				if (up)
				{
					yI += num4 * Time.deltaTime * 3.5f;
					if (yI > num4)
					{
						yI = num4;
					}
				}
				else if (down)
				{
					yI -= num4 * Time.deltaTime * 3.5f;
					if (yI < 0f - num4)
					{
						yI = 0f - num4;
					}
				}
				else if (yI > 0f)
				{
					yI -= num4 * Time.deltaTime * 1.5f;
					if (yI < 0f)
					{
						yI = 0f;
					}
				}
				else if (yI < 0f)
				{
					yI += num4 * Time.deltaTime * 1.5f;
					if (yI > 0f)
					{
						yI = 0f;
					}
				}
				if (right)
				{
					if (((Component)this).transform.localScale.x != 1f)
					{
						((Component)this).transform.localScale = new Vector3(1f, 1f, 1f);
					}
					xI += num4 * Time.deltaTime * 3.5f;
					if (xI > num4)
					{
						xI = num4;
					}
				}
				else if (left)
				{
					if (((Component)this).transform.localScale.x != -1f)
					{
						((Component)this).transform.localScale = new Vector3(-1f, 1f, 1f);
					}
					xI -= num4 * Time.deltaTime * 3.5f;
					if (xI < 0f - num4)
					{
						xI = 0f - num4;
					}
				}
				else if (xI > 0f)
				{
					xI -= num4 * Time.deltaTime * 1.5f;
					if (xI < 0f)
					{
						xI = 0f;
					}
				}
				else if (xI < 0f)
				{
					xI += num4 * Time.deltaTime * 1.5f;
					if (xI > 0f)
					{
						xI = 0f;
					}
				}
			}
			Vector3 position = ((Component)this).transform.position;
			position.x += xI * Time.deltaTime;
			position.y += yI * Time.deltaTime;
			((Component)this).transform.position = position;
			if (state == GhostState.Reviving || ableToRevive)
			{
				((BroforceObject)player.character).SetXY(position.x, position.y);
			}
			if (state == GhostState.Reviving)
			{
				return;
			}
			if (fire)
			{
				if (!ableToRevive)
				{
					TryToAttack();
					HeroController.SetAvatarAngry(playerNum, true);
				}
				else
				{
					StartReviving();
				}
			}
			else
			{
				HeroController.SetAvatarCalm(playerNum, true);
			}
			if (buttonGesture && state != GhostState.Attacking)
			{
				frame = 0;
				state = GhostState.Taunting;
			}
		}
		else
		{
			if (state != GhostState.Taunting)
			{
				return;
			}
			if (right)
			{
				if (((Component)this).transform.localScale.x != 1f)
				{
					((Component)this).transform.localScale = new Vector3(1f, 1f, 1f);
				}
			}
			else if (left && ((Component)this).transform.localScale.x != -1f)
			{
				((Component)this).transform.localScale = new Vector3(-1f, 1f, 1f);
			}
			float num5 = (sprint ? 180f : 130f);
			if (yI > 0f)
			{
				yI -= num5 * Time.deltaTime * 1.5f;
				if (yI < 0f)
				{
					yI = 0f;
				}
			}
			else if (yI < 0f)
			{
				yI += num5 * Time.deltaTime * 1.5f;
				if (yI > 0f)
				{
					yI = 0f;
				}
			}
			if (xI > 0f)
			{
				xI -= num5 * Time.deltaTime * 1.5f;
				if (xI < 0f)
				{
					xI = 0f;
				}
			}
			else if (xI < 0f)
			{
				xI += num5 * Time.deltaTime * 1.5f;
				if (xI > 0f)
				{
					xI = 0f;
				}
			}
			if (!buttonGesture)
			{
				frame = 0;
				state = GhostState.Idle;
			}
		}
	}

	public void ConstrainToScreen()
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: 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_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		SetResolutionCamera.GetScreenExtents(ref screenMinX, ref screenMaxX, ref screenMinY, ref screenMaxY);
		Vector3 position = ((Component)this).transform.position;
		if (position.x < screenMinX + 5f)
		{
			position.x = screenMinX + 5f;
		}
		else if (position.x > screenMaxX - 5f)
		{
			position.x = screenMaxX - 5f;
		}
		if (position.y < screenMinY + 10f)
		{
			position.y = screenMinY + 10f;
		}
		else if (position.y > screenMaxY - 10f)
		{
			position.y = screenMaxY - 10f;
		}
		((Component)this).transform.position = position;
	}

	public void ChangeFrame()
	{
		frameCounter += Time.deltaTime;
		switch (state)
		{
		case GhostState.Idle:
			if (frameCounter > 0.11f)
			{
				frameCounter -= 0.11f;
				frame++;
				if (frame > 7)
				{
					frame = 0;
				}
				sprite.SetLowerLeftPixel((float)frame * 32f, 32f);
			}
			break;
		case GhostState.Attacking:
			if (frameCounter > attackingFramerate)
			{
				frameCounter -= attackingFramerate;
				frame++;
				if (frame > 13)
				{
					frame = 0;
					FinishAttack();
				}
				sprite.SetLowerLeftPixel((float)frame * 32f, 64f);
			}
			break;
		case GhostState.Taunting:
			if (frameCounter > dancingFramerate)
			{
				frameCounter -= dancingFramerate;
				frame++;
				if (frame > 21)
				{
					frame = 4;
				}
				sprite.SetLowerLeftPixel((float)frame * 32f, 96f);
			}
			break;
		case GhostState.Resurrecting:
			if (frameCounter > resurrectingFramerate)
			{
				frameCounter -= resurrectingFramerate;
				frame++;
				if (frame > 15)
				{
					frame = 0;
					state = GhostState.Idle;
					sprite.SetLowerLeftPixel((float)frame * 32f, 32f);
				}
				else
				{
					sprite.SetLowerLeftPixel((float)frame * 32f, 128f);
				}
			}
			break;
		case GhostState.Reviving:
			if (frameCounter > reviveFramerate)
			{
				frameCounter -= reviveFramerate;
				frame++;
				if (frame > 14)
				{
					ReviveCharacter();
					frame = 0;
				}
				sprite.SetLowerLeftPixel((float)frame * 32f, 160f);
			}
			break;
		}
	}

	public void SetFrame()
	{
		switch (state)
		{
		case GhostState.Idle:
			sprite.SetLowerLeftPixel((float)frame * 32f, 32f);
			break;
		case GhostState.Attacking:
			sprite.SetLowerLeftPixel((float)frame * 32f, 64f);
			break;
		case GhostState.Taunting:
			sprite.SetLowerLeftPixel((float)frame * 32f, 96f);
			break;
		case GhostState.Resurrecting:
			sprite.SetLowerLeftPixel((float)frame * 32f, 128f);
			break;
		case GhostState.Reviving:
			sprite.SetLowerLeftPixel((float)frame * 32f, 32f);
			break;
		}
	}

	public static TestVanDammeAnim GetNextClosestUnit(int playerNum, float xRange, float yRange, float x, float y)
	{
		if (Map.units == null)
		{
			return null;
		}
		float num = xRange;
		TestVanDammeAnim val = null;
		for (int num2 = Map.units.Count - 1; num2 >= 0; num2--)
		{
			Unit obj = Map.units[num2];
			TestVanDammeAnim val2 = (TestVanDammeAnim)(object)((obj is TestVanDammeAnim) ? obj : null);
			if ((Object)(object)val2 != (Object)null && Main.AvailableToPossess(val2))
			{
				float num3 = ((BroforceObject)val2).Y + ((Unit)val2).height / 2f + 3f - y;
				if (Mathf.Abs(num3) - yRange < ((Unit)val2).height && Mathf.Abs(((BroforceObject)val2).X - x) - num < ((Unit)val2).width)
				{
					val = val2;
					num = Mathf.Abs(num3);
				}
			}
		}
		if ((Object)(object)val != (Object)null)
		{
			return val;
		}
		return null;
	}

	public void TryToAttack()
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: 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_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_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		if (player.Lives > 0)
		{
			TestVanDammeAnim nextClosestUnit = GetNextClosestUnit(playerNum, 15f, 10f, ((Component)this).transform.position.x, ((Component)this).transform.position.y);
			if ((Object)(object)nextClosestUnit != (Object)null)
			{
				characterToPossess = nextClosestUnit;
				((Object)characterToPossess).name = "p";
				((Component)this).transform.localScale = new Vector3(Mathf.Sign(((BroforceObject)characterToPossess).X - ((Component)this).transform.position.x), 1f, 1f);
				frozenPosition = ((Component)characterToPossess).transform.position;
				frozenXI = ((BroforceObject)characterToPossess).xI;
				frozenYI = ((BroforceObject)characterToPossess).yI;
				((Component)this).transform.position = new Vector3(((BroforceObject)characterToPossess).X - ((Component)this).transform.localScale.x * 11f, ((BroforceObject)characterToPossess).Y + ((Unit)characterToPossess).height + 3f, 0f);
				state = GhostState.Attacking;
				frame = 0;
				xI = 0f;
				yI = 0f;
			}
		}
	}

	public void FinishAttack()
	{
		if ((Object)(object)characterToPossess != (Object)null && ((BroforceObject)characterToPossess).IsAlive() && ((BroforceObject)characterToPossess).health > 0)
		{
			Main.StartControllingUnit(playerNum, characterToPossess);
			characterToPossess = null;
			state = GhostState.Idle;
			((Component)this).gameObject.SetActive(false);
			return;
		}
		if ((Object)(object)characterToPossess != (Object)null)
		{
			((Object)characterToPossess).name = "enemy";
		}
		characterToPossess = null;
		state = GhostState.Idle;
		frame = 0;
		SetFrame();
	}

	public void SetCanReviveCharacter()
	{
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		state = GhostState.Idle;
		if ((Object)(object)characterToPossess != (Object)null)
		{
			((Object)characterToPossess).name = "enemy";
			characterToPossess = null;
		}
		ableToRevive = true;
		forceReviveTime = 1.5f;
		startReviveFlashTime = Time.time;
		((SpriteBase)sprite).SetColor(new Color(reviveColor.r, reviveColor.g, reviveColor.b, currentTransparency));
	}

	public void StartReviving()
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		ableToRevive = false;
		state = GhostState.Reviving;
		frame = 0;
		((Component)sprite).GetComponent<Renderer>().material.SetColor("_TintColor", Color.gray);
	}

	public void ReviveCharacter()
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		((Component)player.character).transform.position = ((Component)this).transform.position;
		((BroforceObject)player.character).SetXY(((Component)this).transform.position.x, ((Component)this).transform.position.y - 15f);
		((Component)player.character).transform.localScale = ((Component)this).transform.localScale;
		((Component)this).gameObject.SetActive(false);
		((BroforceObject)player.character).xI = xI;
		((BroforceObject)player.character).yI = yI;
		((Component)player.character).gameObject.SetActive(true);
		Main.SwitchToHeroAvatar(playerNum);
		state = GhostState.Idle;
		currentTransparency = 0.75f;
		((SpriteBase)sprite).SetColor(new Color(playerColor.r, playerColor.g, playerColor.b, currentTransparency));
	}

	public void StartResurrecting()
	{
		frame = 0;
		state = GhostState.Resurrecting;
		SetFrame();
	}

	public void ReActivate()
	{
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		if (HeroController.players[playerNum].Lives <= 0)
		{
			playerColor = new Color(1f, 1f, 1f, 1f);
			((SpriteBase)sprite).SetColor(new Color(playerColor.r, playerColor.g, playerColor.b, currentTransparency));
		}
		((Component)this).gameObject.SetActive(true);
	}
}
public class HarmonyPatches
{
	[HarmonyPatch(typeof(PolymorphicAI), "Update")]
	private static class PolymorphicAI_Update_Patch
	{
		public static bool Prefix(PolymorphicAI __instance)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if (!Main.enabled)
			{
				return true;
			}
			if (((Object)__instance).name == "c")
			{
				if (Main.settings.competitiveModeEnabled && !Main.revealed[((NetworkedUnit)((Component)__instance).gameObject.GetComponent<TestVanDammeAnim>()).playerNum])
				{
					__instance.mentalState = (MentalState)0;
				}
				else
				{
					__instance.mentalState = (MentalState)2;
				}
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(PolymorphicAI), "LateUpdate")]
	private static class PolymorphicAI_LateUpdate_Patch
	{
		public static bool Prefix(PolymorphicAI __instance)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			if (!Main.enabled)
			{
				return true;
			}
			if (((Object)__instance).name == "c")
			{
				if (Main.settings.competitiveModeEnabled && !Main.revealed[((NetworkedUnit)((Component)__instance).gameObject.GetComponent<TestVanDammeAnim>()).playerNum])
				{
					__instance.mentalState = (MentalState)0;
				}
				else
				{
					__instance.mentalState = (MentalState)2;
				}
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(TestVanDammeAnim), "GetEnemyMovement")]
	private static class TestVanDammeAnim_GetEnemyMovement_Patch
	{
		public static bool Prefix(TestVanDammeAnim __instance)
		{
			if (!Main.enabled)
			{
				return true;
			}
			if (((Object)__instance).name == "c")
			{
				return false;
			}
			if (((Object)__instance).name == "p")
			{
				__instance.left = (__instance.right = false);
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(TestVanDammeAnim), "SetGestureAnimation")]
	private static class TestVanDammeAnim_SetGestureAnimation_Patch
	{
		public static bool Prefix(TestVanDammeAnim __instance, ref Gestures gesture)
		{
			if (!Main.enabled || !Main.settings.disableTaunting)
			{
				return true;
			}
			if ((int)gesture == 4 && ((Object)__instance).name == "c")
			{
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(TestVanDammeAnim), "Death", new Type[]
	{
		typeof(float),
		typeof(float),
		typeof(DamageObject)
	})]
	public static class TestVanDammeAnim_Death_Patch
	{
		public static bool outOfBounds;

		public static void Prefix(TestVanDammeAnim __instance, ref float xI, ref float yI, ref DamageObject damage)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Invalid comparison between Unknown and I4
			if (Main.enabled && ((Object)__instance).name == "c" && damage != null)
			{
				outOfBounds = (int)damage.damageType == 5;
			}
		}

		public static void Postfix(TestVanDammeAnim __instance, ref float xI, ref float yI, ref DamageObject damage)
		{
			if (!Main.enabled)
			{
				return;
			}
			try
			{
				if (Main.settings.competitiveModeEnabled)
				{
					if (((NetworkedUnit)__instance).playerNum >= 0 && ((NetworkedUnit)__instance).playerNum < 4)
					{
						Main.PlayerDiedInCompetitiveMode(__instance, damage);
					}
				}
				else if (((Object)__instance).name == "c" && ((NetworkedUnit)__instance).playerNum >= 0 && ((NetworkedUnit)__instance).playerNum < 4 && (!Main.settings.respawnFromCorpse || HeroController.players[((NetworkedUnit)__instance).playerNum].Lives <= 0 || outOfBounds || !((Object)(object)Main.previousCharacter[((NetworkedUnit)__instance).playerNum] != (Object)null)))
				{
					SatanMiniboss val = (SatanMiniboss)(object)((__instance is SatanMiniboss) ? __instance : null);
					if ((Object)(object)val == (Object)null || val.IsInStage2())
					{
						Main.LeaveUnit(__instance, ((NetworkedUnit)__instance).playerNum, onlyLeaveUnit: true);
					}
				}
			}
			catch (Exception ex)
			{
				Main.Log("Exception in death: " + ex.ToString());
			}
		}
	}

	[HarmonyPatch(typeof(TestVanDammeAnim), "Gib")]
	private static class TestVanDammeAnim_Gib_Patch
	{
		public static void Prefix(TestVanDammeAnim __instance, ref DamageType damageType)
		{
			if (!Main.enabled)
			{
				return;
			}
			try
			{
				if (((NetworkedUnit)__instance).playerNum < 0 || ((NetworkedUnit)__instance).playerNum >= 4 || !((Object)(object)HeroController.players[((NetworkedUnit)__instance).playerNum].character == (Object)(object)__instance))
				{
					return;
				}
				if (Main.settings.competitiveModeEnabled)
				{
					Main.PlayerDiedInCompetitiveMode(__instance);
				}
				else if (((Object)__instance).name == "c")
				{
					if (!TestVanDammeAnim_Death_Patch.outOfBounds)
					{
						TestVanDammeAnim_Death_Patch.outOfBounds = (int)damageType == 5;
					}
					typeof(TestVanDammeAnim).GetMethod("ReduceLives", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[1] { false });
				}
			}
			catch (Exception ex)
			{
				Main.Log("Exception in gib: " + ex.ToString());
			}
		}
	}

	[HarmonyPatch(typeof(TestVanDammeAnim), "ReduceLives")]
	public static class TestVanDammeAnim_ReduceLives_Patch
	{
		public static bool ignoreNextLifeLoss;

		public static bool Prefix(TestVanDammeAnim __instance)
		{
			if (!Main.enabled)
			{
				return true;
			}
			if (!Main.settings.competitiveModeEnabled && ((Object)__instance).name == "c" && ((NetworkedUnit)__instance).playerNum >= 0 && ((NetworkedUnit)__instance).playerNum < 4 && Main.currentlyEnemy[((NetworkedUnit)__instance).playerNum])
			{
				bool flag = false;
				if (__instance is AlienFaceHugger)
				{
					AlienFaceHugger val = (AlienFaceHugger)(object)((__instance is AlienFaceHugger) ? __instance : null);
					if (val.insemenationCompleted && val.layEggsInsideBros)
					{
						flag = true;
						AlienXenomorph_Start_Patch.controlNextAlien = true;
						AlienXenomorph_Start_Patch.controllerPlayerNum = ((NetworkedUnit)__instance).playerNum;
					}
				}
				if ((Main.settings.respawnFromCorpse && !TestVanDammeAnim_Death_Patch.outOfBounds && (Object)(object)Main.previousCharacter[((NetworkedUnit)__instance).playerNum] != (Object)null) || flag)
				{
					if (Main.settings.loseLifeOnDeath && !flag && ((int)Main.previousDeathType[((NetworkedUnit)__instance).playerNum] != 2 || !Main.settings.noLifeLossOnSuicide))
					{
						HeroController.players[((NetworkedUnit)__instance).playerNum].RemoveLife();
					}
					if (HeroController.players[((NetworkedUnit)__instance).playerNum].Lives > 0)
					{
						Main.countdownToRespawn[((NetworkedUnit)__instance).playerNum] = (flag ? 10f : 0.6f);
						return false;
					}
					return true;
				}
				if (!Main.settings.loseLifeOnDeath && (Object)(object)Main.previousCharacter[((NetworkedUnit)__instance).playerNum] != (Object)null)
				{
					ignoreNextLifeLoss = true;
				}
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Mook), "NotifyDeathType")]
	private static class Mook_NotifyDeathType_Patch
	{
		public static void Prefix(Mook __instance, DeathType ___deathType)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected I4, but got Unknown
			if (Main.enabled && ((Object)__instance).name == "c" && (int)Main.previousDeathType[((NetworkedUnit)__instance).playerNum] != 2)
			{
				Main.previousDeathType[((NetworkedUnit)__instance).playerNum] = (DeathType)(int)___deathType;
			}
		}
	}

	[HarmonyPatch(typeof(Player), "RemoveLife")]
	public static class Player_RemoveLife_Patch
	{
		public static bool allowLifeLoss;

		public static bool Prefix(Player __instance)
		{
			if (!Main.enabled)
			{
				return true;
			}
			if (TestVanDammeAnim_ReduceLives_Patch.ignoreNextLifeLoss)
			{
				TestVanDammeAnim_ReduceLives_Patch.ignoreNextLifeLoss = false;
				Main.previousDeathType[__instance.playerNum] = (DeathType)1;
				return false;
			}
			if (Main.settings.noLifeLossOnSuicide && (Object)(object)__instance.character != (Object)null && ((Object)__instance.character).name == "c" && UnitTypes.IsSuicideUnit(Main.currentUnitType[__instance.playerNum]) && (int)Main.previousDeathType[__instance.playerNum] == 2)
			{
				Main.previousDeathType[__instance.playerNum] = (DeathType)1;
				return false;
			}
			Main.previousDeathType[__instance.playerNum] = (DeathType)1;
			if (Main.settings.competitiveModeEnabled)
			{
				if (Main.settings.ghostLives == 0 && __instance.playerNum != Main.currentHeroNum)
				{
					allowLifeLoss = false;
					return false;
				}
				if (Main.settings.heroLives == 0 && __instance.playerNum == Main.currentHeroNum)
				{
					allowLifeLoss = false;
					return false;
				}
				if (allowLifeLoss)
				{
					allowLifeLoss = false;
					return true;
				}
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Player), "IsAlive")]
	private static class Player_IsAlive_Patch
	{
		public static bool Prefix(Player __instance, ref bool __result)
		{
			if (!Main.enabled)
			{
				return true;
			}
			if (Main.everyoneDead)
			{
				__result = false;
				return false;
			}
			if (Main.countdownToRespawn[__instance.playerNum] > 0f)
			{
				__result = true;
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(PlayerHUD), "SetAvatarDead")]
	private static class PlayerHUD_SetAvatarDead_Patch
	{
		public static bool Prefix(PlayerHUD __instance, int ___playerNum, ref bool ___SetToDead)
		{
			if (!Main.enabled)
			{
				return true;
			}
			if (Main.countdownToRespawn[___playerNum] > 0f)
			{
				___SetToDead = true;
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(TestVanDammeAnim), "IsOverFinish")]
	private static class TestVanDammeAnim_IsOverFinish_Patch
	{
		public static LayerMask victoryLayer = LayerMask.op_Implicit(1 << LayerMask.NameToLayer("Finish"));

		public static float AttachToHelicopter(TestVanDammeAnim __instance, float ladderXPos, Helicopter helicopter)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			helicopter.attachedHeroes.Add(__instance);
			ladderXPos = ((Component)helicopter).transform.position.x + 13f;
			helicopter.Leave();
			((Component)__instance).transform.parent = helicopter.ladderHolder;
			float x = ((Component)helicopter).transform.position.x;
			if (((BroforceObject)__instance).X > x)
			{
				((Component)__instance).transform.localScale = new Vector3(-1f, 1f, 1f);
				((BroforceObject)__instance).X = x + 5f;
			}
			else
			{
				((Component)__instance).transform.localScale = new Vector3(1f, 1f, 1f);
				((BroforceObject)__instance).X = x - 5f;
			}
			((Component)__instance).transform.position = new Vector3(Mathf.Round(((BroforceObject)__instance).X), Mathf.Round(((BroforceObject)__instance).Y), -50f);
			return ladderXPos;
		}

		public static void IsOverFinish(TestVanDammeAnim character, ref float ladderXPos, ref bool __result, bool canTakePortal = true)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: 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_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			Collider[] array = Physics.OverlapSphere(new Vector3(((BroforceObject)character).X, ((BroforceObject)character).Y, 0f), 4f, LayerMask.op_Implicit(victoryLayer));
			if (array.Length == 0)
			{
				return;
			}
			HeroLevelExitPortal component = ((Component)array[0]).GetComponent<HeroLevelExitPortal>();
			if ((Object)(object)component != (Object)null && !canTakePortal)
			{
				__result = false;
				return;
			}
			((Unit)character).invulnerable = true;
			if ((Object)(object)((Component)character).GetComponent<AudioSource>() != (Object)null)
			{
				((Component)character).GetComponent<AudioSource>().Stop();
			}
			((Behaviour)character).enabled = false;
			if ((Object)(object)((Component)array[0]).transform.parent != (Object)null)
			{
				if ((Object)(object)((Component)((Component)array[0]).transform.parent).GetComponent<HelicopterFake>() != (Object)null || Map.MapData.onlyTriggersCanWinLevel)
				{
					Helicopter component2 = ((Component)((Component)array[0]).transform.parent).GetComponent<Helicopter>();
					ladderXPos = AttachToHelicopter(character, ladderXPos, component2);
					Networking.RPC<Vector3, float, TestVanDammeAnim, Helicopter, bool>(PID.TargetAll, (RpcSignature<Vector3, float, TestVanDammeAnim, Helicopter, bool>)HeroController.Instance.AttachHeroToHelicopter, ((Component)character).transform.localPosition, ((Component)character).transform.localScale.x, character, component2, false, false);
					__result = true;
				}
				Helicopter component3 = ((Component)((Component)array[0]).transform.parent).GetComponent<Helicopter>();
				if ((Object)(object)component3 != (Object)null)
				{
					ladderXPos = AttachToHelicopter(character, ladderXPos, component3);
					Networking.RPC<Vector3, float, TestVanDammeAnim, Helicopter, bool>(PID.TargetAll, (RpcSignature<Vector3, float, TestVanDammeAnim, Helicopter, bool>)HeroController.Instance.AttachHeroToHelicopter, ((Component)character).transform.localPosition, ((Component)character).transform.localScale.x, character, component3, true, false);
				}
			}
			Traverse obj = Traverse.Create((object)character);
			obj.Field("jumpTime").SetValue((object)0.07f);
			obj.Field("doubleJumpsLeft").SetValue((object)0);
			if ((Object)(object)component != (Object)null)
			{
				typeof(TestVanDammeAnim).GetMethod("SuckIntoPortal", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(character, null);
			}
			GameModeController.LevelFinish((LevelResult)1);
			Map.StartLevelEndExplosionsOverNetwork();
			character.isOnHelicopter = true;
			((NetworkedUnit)character).playerNum = 5;
			__result = true;
		}

		public static bool Prefix(TestVanDammeAnim __instance, ref float ladderXPos, ref bool __result)
		{
			if (!Main.enabled)
			{
				return true;
			}
			if (!Main.settings.competitiveModeEnabled)
			{
				if (((Object)__instance).name == "c" && ((Unit)__instance).IsHeavy())
				{
					__result = false;
					if (((NetworkedUnit)__instance).playerNum >= 0 && ((NetworkedUnit)__instance).playerNum < 4)
					{
						IsOverFinish(__instance, ref ladderXPos, ref __result);
					}
					return false;
				}
			}
			else
			{
				if (((NetworkedUnit)__instance).playerNum != Main.currentHeroNum || !((Component)__instance).gameObject.activeSelf)
				{
					return false;
				}
				if (Main.openedPortal && ((NetworkedUnit)__instance).playerNum == Main.currentHeroNum && !ScoreManager.CanWin(((NetworkedUnit)__instance).playerNum))
				{
					IsOverFinish(__instance, ref ladderXPos, ref __result, canTakePortal: false);
					return false;
				}
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(TestVanDammeAnim), "RecallBro")]
	private static class TestVanDammeAnim_RecallBro_Patch
	{
		public static void Prefix(TestVanDammeAnim __instance)
		{
			if (Main.enabled && ((NetworkedUnit)__instance).playerNum >= 0 && ((NetworkedUnit)__instance).playerNum < 4)
			{
				Main.previousCharacter[((NetworkedUnit)__instance).playerNum] = null;
			}
		}
	}

	[HarmonyPatch(typeof(TestVanDammeAnim), "ShowStartBubble")]
	private static class TestVanDammeAnim_ShowStartBubble_Patch
	{
		public static bool Prefix(TestVanDammeAnim __instance)
		{
			if (!Main.enabled)
			{
				return true;
			}
			return ((Object)__instance).name != "c";
		}
	}

	[HarmonyPatch(typeof(TestVanDammeAnim), "RestartBubble", new Type[] { typeof(float) })]
	private static class TestVanDammeAnim_RestartBubble_float_Patch
	{
		public static bool Prefix(TestVanDammeAnim __instance)
		{
			if (!Main.enabled)
			{
				return true;
			}
			return ((Object)__instance).name != "c";
		}
	}

	[HarmonyPatch(typeof(TestVanDammeAnim), "RestartBubble", new Type[] { })]
	private static class TestVanDammeAnim_RestartBubble_Patch
	{
		public static bool Prefix(TestVanDammeAnim __instance)
		{
			if (!Main.enabled)
			{
				return true;
			}
			return ((Object)__instance).name != "c";
		}
	}

	[HarmonyPatch(typeof(HeroController), "SwitchAvatarMaterial")]
	private static class HeroController_SwitchAvatarMaterial_Patch
	{
		public static bool Prefix(ref SpriteSM sprite, ref bool __result)
		{
			if (!Main.enabled)
			{
				return true;
			}
			if (Main.settings.competitiveModeEnabled && Main.playerWon)
			{
				int num = -1;
				PlayerScoreDisplay component = ((Component)((Component)sprite).transform.parent.parent.parent).gameObject.GetComponent<PlayerScoreDisplay>();
				if ((Object)(object)component != (Object)null && LevelOverScreen_Show_Patch.scoreDisplays.Length != 0)
				{
					for (int i = 0; i < LevelOverScreen_Show_Patch.scoreDisplays.Length; i++)
					{
						if ((Object)(object)LevelOverScreen_Show_Patch.scoreDisplays[i] == (Object)(object)component)
						{
							num = i;
							break;
						}
					}
				}
				if (num == -1)
				{
					return true;
				}
				if (num == Main.attemptingWin)
				{
					if (Main.isBroMakerInstalled && Main.SetAvatarToSwitch(HeroController.players[num].character, num))
					{
						HeroController.SwitchAvatarMaterial(sprite, (HeroType)(-1));
						return false;
					}
					return true;
				}
				((Component)sprite).GetComponent<Renderer>().material = Main.ghostAvatarMat;
				return false;
			}
			PlayerHUD component2 = ((Component)sprite).gameObject.GetComponent<PlayerHUD>();
			if ((Object)(object)component2 != (Object)null)
			{
				int num2 = (int)Traverse.Create((object)component2).Field("playerNum").GetValue();
				if (Main.currentlyEnemy[num2])
				{
					((Component)sprite).GetComponent<Renderer>().material = Main.defaultAvatarMat;
					return false;
				}
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Map), "Start")]
	private static class Map_Start_Patch
	{
		public static void Prefix(Map __instance)
		{
			if (Main.enabled)
			{
				Main.ClearVariables();
				if (Main.settings.competitiveModeEnabled && Main.currentHeroNum == -1)
				{
					Main.currentHeroNum = Random.Range(0, HeroController.NumberOfPlayers());
				}
			}
		}
	}

	[HarmonyPatch(typeof(TestVanDammeAnim), "AnimateWallAnticipation")]
	private static class TestVanDammeAnim_AnimateWallAnticipation_Patch
	{
		public static bool Prefix(TestVanDammeAnim __instance)
		{
			if (!Main.enabled)
			{
				return true;
			}
			if (((Object)__instance).name == "c")
			{
				((Component)__instance).GetComponent<SpriteSM>().SetLowerLeftPixel(0f, Main.currentSpriteHeight[((NetworkedUnit)__instance).playerNum]);
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(TestVanDammeAnim), "AnimateWallClimb")]
	private static class TestVanDammeAnim_AnimateWallClimb_Patch
	{
		public static bool Prefix(TestVanDammeAnim __instance)
		{
			if (!Main.enabled)
			{
				return true;
			}
			if (((Object)__instance).name == "c")
			{
				((Component)__instance).GetComponent<SpriteSM>().SetLowerLeftPixel(0f, Main.currentSpriteHeight[((NetworkedUnit)__instance).playerNum]);
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(TestVanDammeAnim), "AnimateWallDrag")]
	private static class TestVanDammeAnim_AnimateWallDrag_Patch
	{
		public static bool Prefix(TestVanDammeAnim __instance)
		{
			if (!Main.enabled)
			{
				return true;
			}
			if (((Object)__instance).name == "c")
			{
				((Component)__instance).GetComponent<SpriteSM>().SetLowerLeftPixel(0f, Main.currentSpriteHeight[((NetworkedUnit)__instance).playerNum]);
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(TestVanDammeAnim), "PlayStunnedSound")]
	private static class TestVanDammeAnim_PlayStunnedSound_Patch
	{
		public static bool Prefix(TestVanDammeAnim __instance, ref float ___stunVocalDelay)
		{
			if (!Main.enabled)
			{
				return true;
			}
			if (((Object)__instance).name == "c" && Main.holdingGesture[((NetworkedUnit)__instance).playerNum])
			{
				__instance.PlayLaughterSound();
				___stunVocalDelay = 0.4f + Random.Range(0.3f, 0.9f);
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(TestVanDammeAnim), "ThrowBackGrenade")]
	private static class TestVanDammeAnim_ThrowBackGrenade_Patch
	{
		public static bool Prefix(TestVanDammeAnim __instance)
		{
			if (!Main.enabled)
			{
				return true;
			}
			if (((Object)__instance).name == "c" && (int)Main.currentUnitType[((NetworkedUnit)__instance).playerNum] == 13)
			{
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Mook), "FallDamage")]
	private static class Mook_FallDamage_Patch
	{
		public static bool Prefix(Mook __instance, ref float yI)
		{
			if (!Main.enabled || !Main.settings.disableFallDamage)
			{
				return true;
			}
			if (((Object)__instance).name == "c")
			{
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(MookBigGuy), "FallDamage")]
	private static class MookBigGuy_FallDamage_Patch
	{
		public static bool Prefix(MookBigGuy __instance, ref float yI)
		{
			if (!Main.enabled || !Main.settings.disableFallDamage)
			{
				return true;
			}
			if (((Object)__instance).name == "c")
			{
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Alien), "FallDamage")]
	private static class Alien_FallDamage_Patch
	{
		public static bool Prefix(Alien __instance, ref float yI)
		{
			if (!Main.enabled || !Main.settings.disableFallDamage)
			{
				return true;
			}
			if (((Object)__instance).name == "c")
			{
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(AlienFaceHugger), "FallDamage")]
	private static class AlienFaceHugger_FallDamage_Patch
	{
		public static bool Prefix(AlienFaceHugger __instance, ref float yI)
		{
			if (!Main.enabled || !Main.settings.disableFallDamage)
			{
				return true;
			}
			if (((Object)__instance).name == "c")
			{
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(AlienMelter), "FallDamage")]
	private static class AlienMelter_FallDamage_Patch
	{
		public static bool Prefix(AlienMelter __instance, ref float yI)
		{
			if (!Main.enabled || !Main.settings.disableFallDamage)
			{
				return true;
			}
			if (((Object)__instance).name == "c")
			{
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Animal), "FallDamage")]
	private static class Animal_FallDamage_Patch
	{
		public static bool Prefix(Animal __instance, ref float yI)
		{
			if (!Main.enabled || !Main.settings.disableFallDamage)
			{
				return true;
			}
			if (((Object)__instance).name == "c")
			{
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(MookArmouredGuy), "FallDamage")]
	private static class MookArmouredGuy_FallDamage_Patch
	{
		public static bool Prefix(MookArmouredGuy __instance, ref float yI)
		{
			if (!Main.enabled || !Main.settings.disableFallDamage)
			{
				return true;
			}
			if (((Object)__instance).name == "c")
			{
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(MookDog), "FallDamage")]
	private static class MookDog_FallDamage_Patch
	{
		public static bool Prefix(MookDog __instance, ref float yI)
		{
			if (!Main.enabled || !Main.settings.disableFallDamage)
			{
				return true;
			}
			if (((Object)__instance).name == "c")
			{
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(MookHellBigGuy), "FallDamage")]
	private static class MookHellBigGuy_FallDamage_Patch
	{
		public static bool Prefix(MookHellBigGuy __instance, ref float yI)
		{
			if (!Main.enabled || !Main.settings.disableFallDamage)
			{
				return true;
			}
			if (((Object)__instance).name == "c")
			{
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(MookHellBoomer), "FallDamage")]
	private static class MookHellBoomer_FallDamage_Patch
	{
		public static bool Prefix(MookHellBoomer __instance, ref float yI)
		{
			if (!Main.enabled || !Main.settings.disableFallDamage)
			{
				return true;
			}
			if (((Object)__instance).name == "c")
			{
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(MookSuicide), "FallDamage")]
	private static class MookSuicide_FallDamage_Patch
	{
		public static bool Prefix(MookSuicide __instance, ref float yI)
		{
			if (!Main.enabled || !Main.settings.disableFallDamage)
			{
				return true;
			}
			if (((Object)__instance).name == "c")
			{
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(SkinnedMook), "FallDamage")]
	private static class MSkinnedMook_FallDamage_Patch
	{
		public static bool Prefix(SkinnedMook __instance, ref float yI)
		{
			if (!Main.enabled || !Main.settings.disableFallDamage)
			{
				return true;
			}
			if (((Object)__instance).name == "c")
			{
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Villager), "FallDamage")]
	private static class Villager_FallDamage_Patch
	{
		public static bool Prefix(Villager __instance, ref float yI)
		{
			if (!Main.enabled || !Main.settings.disableFallDamage)
			{
				return true;
			}
			if (((Object)__instance).name == "c")
			{
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(SetResolutionCamera), "IsItVisible")]
	private static class SetResolutionCamera_IsItVisible_Patch
	{
		public static bool Prefix(SetResolutionCamera __instance, ref bool __result)
		{
			if (!Main.enabled)
			{
				return true;
			}
			if (overrideNextVisibilityCheck)
			{
				__result = true;
				overrideNextVisibilityCheck = false;
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(SortOfFollow), "IsItSortOfVisible", new Type[]
	{
		typeof(float),
		typeof(float),
		typeof(float),
		typeof(float)
	})]
	private static class SortOfFollow_IsItSortOfVisible_Patch
	{
		public static bool Prefix(SortOfFollow __instance, ref bool __result)
		{
			if (!Main.enabled)
			{
				return true;
			}
			if (overrideNextVisibilityCheck)
			{
				__result = true;
				overrideNextVisibilityCheck = false;
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Mook), "UseFire")]
	private static class Mook_UseFire_Patch
	{
		public static void Prefix(Mook __instance)
		{
			if (Main.enabled && ((Object)__instance).name == "c")
			{
				overrideNextVisibilityCheck = true;
			}
		}
	}

	[HarmonyPatch(typeof(MookArmouredGuy), "UseFire")]
	private static class MookArmouredGuy_UseFire_Patch
	{
		public static void Prefix(MookArmouredGuy __instance)
		{
			if (Main.enabled && ((Object)__instance).name == "c")
			{
				overrideNextVisibilityCheck = true;
			}
		}
	}

	[HarmonyPatch(typeof(MookBigGuy), "UseFire")]
	private static class MookBigGuy_UseFire_Patch
	{
		public static void Prefix(MookBigGuy __instance)
		{
			if (Main.enabled && ((Object)__instance).name == "c")
			{
				overrideNextVisibilityCheck = true;
			}
		}
	}

	[HarmonyPatch(typeof(MookHellBoomer), "UseFire")]
	private static class MookHellBoomer_UseFire_Patch
	{
		public static void Prefix(MookHellBoomer __instance)
		{
			if (Main.enabled && ((Object)__instance).name == "c")
			{
				overrideNextVisibilityCheck = true;
			}
		}
	}

	[HarmonyPatch(typeof(MookJetpackBazooka), "UseFire")]
	private static class MookJetpackBazooka_UseFire_Patch
	{
		public static void Prefix(MookJetpackBazooka __instance)
		{
			if (Main.enabled && ((Object)__instance).name == "c")
			{
				overrideNextVisibilityCheck = true;
			}
		}
	}

	[HarmonyPatch(typeof(MookBigGuyElite), "UseFire")]
	private static class MookBigGuyElite_UseFire_Patch
	{
		public static void Prefix(MookBigGuyElite __instance)
		{
			if (Main.enabled && ((Object)__instance).name == "c")
			{
				overrideNextVisibilityCheck = true;
			}
		}
	}

	[HarmonyPatch(typeof(MookBazooka), "UseFire")]
	private static class MookBazooka_UseFire_Patch
	{
		public static void Prefix(MookBazooka __instance)
		{
			if (Main.enabled && ((Object)__instance).name == "c")
			{
				overrideNextVisibilityCheck = true;
			}
		}
	}

	[HarmonyPatch(typeof(Mook), "CanPassThroughBarriers")]
	private static class Mook_CanPassThroughBarriers_Patch
	{
		public static bool Prefix(Mook __instance, ref bool __result)
		{
			if (!Main.enabled)
			{
				return true;
			}
			if (((Object)__instance).name == "c")
			{
				__result = true;
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(MookDog), "CanPassThroughBarriers")]
	private static class MookDog_CanPassThroughBarriers_Patch
	{
		public static bool Prefix(MookDog __instance, ref bool __result)
		{
			if (!Main.enabled)
			{
				return true;
			}
			if (((Object)__instance).name == "c")
			{
				__result = true;
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(MookSuicide), "Gib")]
	private static class MookSuicide_Gib_Patch
	{
		public static void Prefix(MookSuicide __instance, ref DamageType damageType)
		{
			if (!Main.enabled || ((NetworkedUnit)__instance).playerNum < 0 || ((NetworkedUnit)__instance).playerNum >= 4 || !((Object)(object)HeroController.players[((NetworkedUnit)__instance).playerNum].character == (Object)(object)__instance))
			{
				return;
			}
			if (Main.settings.competitiveModeEnabled)
			{
				Main.PlayerDiedInCompetitiveMode((TestVanDammeAnim)(object)__instance);
			}
			else if (((Object)__instance).name == "c")
			{
				if (!TestVanDammeAnim_Death_Patch.outOfBounds)
				{
					TestVanDammeAnim_Death_Patch.outOfBounds = (int)damageType == 5;
				}
				typeof(TestVanDammeAnim).GetMethod("ReduceLives", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[1] { false });
			}
		}
	}

	[HarmonyPatch(typeof(MookJetpack), "Gib")]
	private static class MookJetpack_Gib_Patch
	{
		public static void Prefix(MookJetpack __instance, ref DamageType damageType)
		{
			if (!Main.enabled || ((NetworkedUnit)__instance).playerNum < 0 || ((NetworkedUnit)__instance).playerNum >= 4 || !((Object)(object)HeroController.players[((NetworkedUnit)__instance).playerNum].character == (Object)(object)__instance))
			{
				return;
			}
			if (Main.settings.competitiveModeEnabled)
			{
				Main.PlayerDiedInCompetitiveMode((TestVanDammeAnim)(object)__instance);
			}
			else if (((Object)__instance).name == "c")
			{
				if (!TestVanDammeAnim_Death_Patch.outOfBounds)
				{
					TestVanDammeAnim_Death_Patch.outOfBounds = (int)damageType == 5;
				}
				typeof(TestVanDammeAnim).GetMethod("ReduceLives", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[1] { false });
			}
		}
	}

	[HarmonyPatch(typeof(AlienMelter), "Gib")]
	private static class AlienMelter_Gib_Patch
	{
		public static void Prefix(AlienMelter __instance, ref DamageType damageType)
		{
			if (!Main.enabled || ((NetworkedUnit)__instance).playerNum < 0 || ((NetworkedUnit)__instance).playerNum >= 4 || !((Object)(object)HeroController.players[((NetworkedUnit)__instance).playerNum].character == (Object)(object)__instance))
			{
				return;
			}
			if (Main.settings.competitiveModeEnabled)
			{
				Main.PlayerDiedInCompetitiveMode((TestVanDammeAnim)(object)__instance);
			}
			else if (((Object)__instance).name == "c")
			{
				if (!TestVanDammeAnim_Death_Patch.outOfBounds)
				{
					TestVanDammeAnim_Death_Patch.outOfBounds = (int)damageType == 5;
				}
				typeof(TestVanDammeAnim).GetMethod("ReduceLives", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[1] { false });
			}
		}
	}

	[HarmonyPatch(typeof(AlienMosquito), "Gib")]
	private static class AlienMosquito_Gib_Patch
	{
		public static void Prefix(AlienMosquito __instance, ref DamageType damageType)
		{
			if (!Main.enabled || ((NetworkedUnit)__instance).playerNum < 0 || ((NetworkedUnit)__instance).playerNum >= 4 || !((Object)(object)HeroController.players[((NetworkedUnit)__instance).playerNum].character == (Object)(object)__instance))
			{
				return;
			}
			if (Main.settings.competitiveModeEnabled)
			{
				Main.PlayerDiedInCompetitiveMode((TestVanDammeAnim)(object)__instance);
			}
			else if (((Object)__instance).name == "c")
			{
				if (!TestVanDammeAnim_Death_Patch.outOfBounds)
				{
					TestVanDammeAnim_Death_Patch.outOfBounds = (int)damageType == 5;
				}
				typeof(TestVanDammeAnim).GetMethod("ReduceLives", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[1] { false });
			}
		}
	}

	[HarmonyPatch(typeof(MookSuicideUndead), "Gib")]
	private static class MookSuicideUndead_Gib_Patch
	{
		public static void Prefix(MookSuicideUndead __instance, ref DamageType damageType)
		{
			if (!Main.enabled || ((NetworkedUnit)__instance).playerNum < 0 || ((NetworkedUnit)__instance).playerNum >= 4 || !((Object)(object)HeroController.players[((NetworkedUnit)__instance).playerNum].character == (Object)(object)__instance))
			{
				return;
			}
			if (Main.settings.competitiveModeEnabled)
			{
				Main.PlayerDiedInCompetitiveMode((TestVanDammeAnim)(object)__instance);
			}
			else if (((Object)__instance).name == "c")
			{
				if (!TestVanDammeAnim_Death_Patch.outOfBounds)
				{
					TestVanDammeAnim_Death_Patch.outOfBounds = (int)damageType == 5;
				}
				typeof(TestVanDammeAnim).GetMethod("ReduceLives", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[1] { false });
			}
		}
	}

	[HarmonyPatch(typeof(Villager), "Death")]
	private static class Villager_Death_Patch
	{
		public static void Prefix(Villager __instance, ref DamageObject damage)
		{
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Invalid comparison between Unknown and I4
			if (!Main.enabled || ((NetworkedUnit)__instance).playerNum < 0 || ((NetworkedUnit)__instance).playerNum >= 4 || !((Object)(object)HeroController.players[((NetworkedUnit)__instance).playerNum].character == (Object)(object)__instance))
			{
				return;
			}
			if (Main.settings.competitiveModeEnabled)
			{
				Main.PlayerDiedInCompetitiveMode((TestVanDammeAnim)(object)__instance, damage);
			}
			else if (((Object)__instance).name == "c")
			{
				if (!TestVanDammeAnim_Death_Patch.outOfBounds && damage != null)
				{
					TestVanDammeAnim_Death_Patch.outOfBounds = (int)damage.damageType == 5;
				}
				typeof(TestVanDammeAnim).GetMethod("ReduceLives", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[1] { false });
			}
		}
	}

	[HarmonyPatch(typeof(Villager), "Gib", new Type[]
	{
		typeof(DamageType),
		typeof(float),
		typeof(float)
	})]
	private static class Villager_Gib_Patch
	{
		public static void Prefix(Villager __instance, ref DamageType damageType)
		{
			if (!Main.enabled || ((NetworkedUnit)__instance).playerNum < 0 || ((NetworkedUnit)__instance).playerNum >= 4 || !((Object)(object)HeroController.players[((NetworkedUnit)__instance).playerNum].character == (Object)(object)__instance))
			{
				return;
			}
			if (Main.settings.competitiveModeEnabled)
			{
				Main.PlayerDiedInCompetitiveMode((TestVanDammeAnim)(object)__instance);
			}
			else if (((Object)__instance).name == "c")
			{
				if (!TestVanDammeAnim_Death_Patch.outOfBounds)
				{
					TestVanDammeAnim_Death_Patch.outOfBounds = (int)damageType == 5;
				}
				typeof(TestVanDammeAnim).GetMethod("ReduceLives", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[1] { false });
			}
		}
	}

	[HarmonyPatch(typeof(Villager), "Gib", new Type[] { })]
	private static class Villager_Gib2_Patch
	{
		public static void Prefix(Villager __instance)
		{
			if (Main.enabled && ((NetworkedUnit)__instance).playerNum >= 0 && ((NetworkedUnit)__instance).playerNum < 4 && (Object)(object)HeroController.players[((NetworkedUnit)__instance).playerNum].character == (Object)(object)__instance)
			{
				if (Main.settings.competitiveModeEnabled)
				{
					Main.PlayerDiedInCompetitiveMode((TestVanDammeAnim)(object)__instance);
				}
				else if (((Object)__instance).name == "c")
				{
					typeof(TestVanDammeAnim).GetMethod("ReduceLives", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[1] { false });
				}
			}
		}
	}

	[HarmonyPatch(typeof(SatanMiniboss), "StartDeathRattle")]
	private static class SatanMiniboss_StartDeathRattle_Patch
	{
		public static void Prefix(SatanMiniboss __instance)
		{
			if (!Main.enabled || Main.settings.competitiveModeEnabled)
			{
				return;
			}
			if (((Object)__instance).name == "c")
			{
				Main.LeaveUnit((TestVanDammeAnim)(object)__instance, ((NetworkedUnit)__instance).playerNum, onlyLeaveUnit: true);
			}
			else
			{
				if (!(((Object)__instance).name == "Enemy"))
				{
					return;
				}
				for (int i = 0; i < 4; i++)
				{
					if (HeroController.IsPlaying(i) && (Object)(object)HeroController.players[i].character == (Object)(object)__instance)
					{
						HeroController.players[i].character = null;
					}
				}
			}
		}
	}

	[HarmonyPatch(typeof(MookSuicide), "MakeEffects")]
	private static class MookSuicide_MakeEffects_Patch
	{
		public static bool Prefix(MookSuicide __instance, bool ___recalling)
		{
			if (!Main.enabled)
			{
				return true;
			}
			if (((Object)__instance).name == "c" && ___recalling)
			{
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(MookSuicideUndead), "MakeEffects")]
	private static class MookSuicideUndead_MakeEffects_Patch
	{
		public static bool Prefix(MookSuicideUndead __instance, bool ___recalling)
		{
			if (!Main.enabled)
			{
				return true;
			}
			if (((Object)__instance).name == "c" && ___recalling)
			{
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(HellLostSoul), "MakeEffects")]
	private static class HellLostSoul_MakeEffects_Patch
	{
		public static void Prefix(HellLostSoul __instance, bool ___diving)
		{
			if (Main.enabled && ((Object)__instance).name == "c" && ___diving)
			{
				((TestVanDammeAnim)__instance).fire = true;
			}
		}
	}

	[HarmonyPatch(typeof(AlienMosquito), "MakeEffects")]
	private static class AlienMosquito_MakeEffects_Patch
	{
		public static void Prefix(AlienMosquito __instance, bool ___diving)
		{
			if (Main.enabled && ((Object)__instance).name == "c" && ___diving)
			{
				((TestVanDammeAnim)__instance).fire = true;
			}
		}
	}

	[HarmonyPatch(typeof(HellDogEgg), "MakeEffects")]
	public static class HellDogEgg_MakeEffects_Patch
	{
		public static bool nextDogFriendly = false;

		public static int playerNum = -1;

		public static void Prefix(HellDogEgg __instance)
		{
			if (Main.enabled && (((Object)((Projectile)__instance).firedBy).name == "c" || ((NetworkedUnit)/*isinst with value type is only supported in some contexts*/).playerNum >= 0))
			{
				nextDogFriendly = true;
				MonoBehaviour firedBy = ((Projectile)__instance).firedBy;
				playerNum = ((NetworkedUnit)((firedBy is Mook) ? firedBy : null)).playerNum;
			}
		}
	}

	[HarmonyPatch(typeof(HellDog), "GrowFromEgg")]
	private static class HellDog_GrowFromEgg_Patch
	{
		public static void Prefix(HellDog __instance)
		{
			if (Main.enabled && HellDogEgg_MakeEffects_Patch.nextDogFriendly)
			{
				((Mook)__instance).firingPlayerNum = HellDogEgg_MakeEffects_Patch.playerNum;
				((NetworkedUnit)__instance).playerNum = HellDogEgg_MakeEffects_Patch.playerNum;
				HellDogEgg_MakeEffects_Patch.nextDogFriendly = false;
			}
		}
	}

	[HarmonyPatch(typeof(AlienXenomorph), "Start")]
	public static class AlienXenomorph_Start_Patch
	{
		public static int controllerPlayerNum = -1;

		public static bool controlNextAlien = false;

		public static void Postfix(AlienXenomorph __instance)
		{
			if (!Main.enabled)
			{
				return;
			}
			if (controlNextAlien)
			{
				if ((Object)(object)Main.previousCharacter[controllerPlayerNum] == (Object)null)
				{
					Main.StartControllingUnit(controllerPlayerNum, (TestVanDammeAnim)(object)__instance, gentleLeave: true, savePreviousCharacter: false);
				}
				else
				{
					Main.StartControllingUnit(controllerPlayerNum, (TestVanDammeAnim)(object)__instance, gentleLeave: true);
				}
				controlNextAlien = false;
				Main.countdownToRespawn[controllerPlayerNum] = -1f;
			}
			else if (((Object)__instance).name == "c")
			{
				int num = Main.currentUnit.IndexOf((Unit)(object)__instance);
				if (num != ((NetworkedUnit)__instance).playerNum)
				{
					Main.ReaffirmControl(num);
				}
				((TestVanDammeAnim)__instance).SpecialAmmo = 0;
			}
		}
	}

	[HarmonyPatch(typeof(MookJetpack), "StartJetPacks")]
	public static class MookJetpack_StartJetPacks_Patch
	{
		public static bool allowJetpack;

		public static bool Prefix(MookJetpack __instance, ref float ___jetpacksDelay)
		{
			if (!Main.enabled)
			{
				return true;
			}
			if (((Object)__instance).name == "c")
			{
				if (!allowJetpack)
				{
					___jetpacksDelay = 1000000f;
					return false;
				}
				allowJetpack = false;
				___jetpacksDelay = 0f;
				return true;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(MookJetpack), "Land")]
	private static class MookJetpack_Land_Patch
	{
		public static void Postfix(MookJetpack __instance)
		{
			if (Main.enabled && ((Object)__instance).name == "c")
			{
				__instance.jetPackHeight = ((TestVanDammeAnim)__instance).groundHeight + 48f;
			}
		}
	}

	[HarmonyPatch(typeof(PolymorphicAI), "GetSeenPlayerNum")]
	private static class PolymorphicAI_GetSeenPlayerNum_Patch
	{
		public static void Postfix(PolymorphicAI __instance, ref int __result)
		{
			if (Main.enabled && ((Object)__instance).name == "c" && __instance is MookWarlockAI)
			{
				if (Main.settings.competitiveModeEnabled)
				{
					__result = Main.currentHeroNum;
				}
				else
				{
					__result = ((NetworkedUnit)((Component)__instance).GetComponent<TestVanDammeAnim>()).playerNum;
				}
			}
		}
	}

	[HarmonyPatch(typeof(WarlockPortal), "SpawnUnit")]
	private static class WarlockPortal_SpawnUnit_Patch
	{
		public static void Postfix(WarlockPortal __instance)
		{
			if (Main.enabled && (Object)(object)__instance.owner != (Object)null && ((Object)__instance.owner).name == "c")
			{
				((NetworkedUnit)__instance.unit).playerNum = ((NetworkedUnit)__instance.owner).playerNum;
			}
		}
	}

	[HarmonyPatch(typeof(MookArmouredGuy), "DisChargePilotRPC")]
	private static class MookArmouredGuy_DisChargePilotRPC_Patch
	{
		public static void Prefix(MookArmouredGuy __instance)
		{
			if (Main.enabled && ((Object)__instance).name == "c")
			{
				Unit pilotUnit = __instance.pilotUnit;
				TestVanDammeAnim val = (TestVanDammeAnim)(object)((pilotUnit is TestVanDammeAnim) ? pilotUnit : null);
				if ((Object)(object)val != (Object)null && Main.AvailableToPossess(val))
				{
					int playerNum = ((NetworkedUnit)__instance).playerNum;
					Main.LeaveUnit((TestVanDammeAnim)(object)__instance, playerNum, onlyLeaveUnit: true);
					Main.countdownToRespawn[playerNum] = 1f;
					Main.StartControllingUnit(playerNum, val, gentleLeave: true, savePreviousCharacter: false);
					Main.countdownToRespawn[playerNum] = 0f;
					((Component)val).transform.parent = ((Component)Map.Instance).transform;
				}
			}
		}
	}

	[HarmonyPatch(typeof(Mook), "DischargePilotingUnit")]
	private static class Mook_DischargePilotingUnit_Patch
	{
		public static bool Prefix(Mook __instance, ref float x, ref float y, ref float xI, ref float yI, ref bool stunUnit, ref float ___ignoreHighFivePressTime, ref float ___jumpTime, ref float ___stunTime)
		{
			if (!Main.enabled)
			{
				return true;
			}
			if (((Object)__instance).name == "c")
			{
				((TestVanDammeAnim)__instance).SetInvulnerable(0.1f, false, false);
				if ((Object)(object)((TestVanDammeAnim)__instance).gunSprite != (Object)null)
				{
					((Behaviour)((TestVanDammeAnim)__instance).gunSprite).enabled = true;
					((Component)((TestVanDammeAnim)__instance).gunSprite).GetComponent<Renderer>().enabled = true;
				}
				((Component)__instance).GetComponent<Renderer>().enabled = true;
				___ignoreHighFivePressTime = 0.1f;
				___jumpTime = 0.13f;
				((Behaviour)__instance).enabled = true;
				((BroforceObject)__instance).health = 1;
				((TestVanDammeAnim)__instance).pilottedUnit = null;
				((TestVanDammeAnim)__instance).SpecialAmmo = ((TestVanDammeAnim)__instance).SpecialAmmo;
				((BroforceObject)__instance).SetXY(x, y);
				((BroforceObject)__instance).yI = yI;
				if (!stunUnit)
				{
					((TestVanDammeAnim)__instance).xIBlast = xI;
				}
				else
				{
					((TestVanDammeAnim)__instance).xIBlast = xI * 0.5f;
					((BroforceObject)__instance).xI = xI * 0.5f;
				}
				((TestVanDammeAnim)__instance).ShowStartBubble();
				((Component)__instance).gameObject.SetActive(true);
				if (stunUnit)
				{
					((Unit)__instance).Stun(1f);
				}
				else
				{
					___stunTime = 0f;
				}
				((BroforceObject)__instance).xI = xI;
				((TestVanDammeAnim)__instance).xIBlast = 0f;
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(MookGeneral), "SpawnMook")]
	private static class MookGeneral_SpawnMook_Patch
	{
		public static bool Prefix(MookGeneral __instance, ref Mook prefab, ref float x, ref float y)
		{
			if (!Main.enabled)
			{
				return true;
			}
			if (((Object)__instance).name == "c")
			{
				Mook obj = MapController.SpawnMook_Networked(prefab, x, y, 0f, 0f, false, false, true, false, true);
				((NetworkedUnit)obj).playerNum = ((NetworkedUnit)__instance).playerNum;
				obj.firingPlayerNum = ((Mook)__instance).firingPlayerNum;
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(MookSuicide), "Start")]
	private static class MookSuicide_Start_Patch
	{
		public static void Postfix(MookSuicide __instance, ref float ___halfWidth)
		{
			if (Main.enabled && ((Object)__instance).name == "c")
			{
				___halfWidth = 6f;
			}
		}
	}

	[HarmonyPatch]
	private static class RemoteControlExplosiveCar_CheckInput_Patch
	{
		[MethodImpl(MethodImplOptions.NoInlining)]
		[HarmonyReversePatch(/*Could not decode attribute arguments.*/)]
		[HarmonyPatch(typeof(TestVanDammeAnim), "CheckInput")]
		private static void CheckInput(RemoteControlExplosiveCar instance)
		{
		}

		[HarmonyPatch(typeof(RemoteControlExplosiveCar), "CheckInput")]
		private static void Prefix(RemoteControlExplosiveCar __instance)
		{
			if (Main.enabled)
			{
				if (((Object)__instance).name == "c")
				{
					CheckInput(__instance);
				}
				if (((TestVanDammeAnim)__instance).fire || ((TestVanDammeAnim)__instance).special)
				{
					RemoteControlExplosiveCar_Explode_Patch.manualActivation = true;
					((TestVanDammeAnim)__instance).fire = (((TestVanDammeAnim)__instance).special = false);
					__instance.Explode();
				}
			}
		}
	}

	[HarmonyPatch(typeof(RemoteControlExplosiveCar), "Explode")]
	public static class RemoteControlExplosiveCar_Explode_Patch
	{
		public static bool manualActivation;

		public static void Prefix(RemoteControlExplosiveCar __instance)
		{
			if (Main.enabled && ((Object)__instance).name == "c")
			{
				if (manualActivation && Main.settings.noLifeLossOnSuicide)
				{
					manualActivation = false;
					return;
				}
				typeof(TestVanDammeAnim).GetMethod("ReduceLives", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[1] { false });
			}
		}
	}

	[HarmonyPatch(typeof(SkinnedMook), "Start")]
	private static class SkinnedMook_Start_Patch
	{
		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions, ILGenerator generator)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Expected O, but got Unknown
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected O, but got Unknown
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Expected O, but got Unknown
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Expected O, but got Unknown
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Expected O, but got Unknown
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Expected O, but got Unknown
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Expected O, but got Unknown
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0172: Expected O, but got Unknown
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Expected O, but got Unknown
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Expected O, but got Unknown
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Expected O, but got Unknown
			CodeMatcher val = new CodeMatcher(instructions, generator);
			MethodInfo deathRPCMethod = AccessTools.Method(typeof(Unit), "DeathRPC", new Type[4]
			{
				typeof(float),
				typeof(float),
				typeof(float),
				typeof(float)
			}, (Type[])null);
			FieldInfo fieldInfo = AccessTools.Field(typeof(NetworkedUnit), "_playerNum");
			val.MatchStartForward((CodeMatch[])(object)new CodeMatch[8]
			{
				new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)0f, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldc_R4, (object)0f, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Ldarg_0, (object)null, (string)null),
				new CodeMatch((OpCode?)OpCodes.Call, (object)null, (string)null),
				new CodeMatch((Func<CodeInstruction, bool>)((CodeInstruction i) => CodeInstructionExtensions.Calls(i, deathRPCMethod)), (string)null)
			});
			if (!val.IsValid)
			{
				Main.mod.Logger.Log("SkinnedMook.Start transpiler: Could not find DeathRPC call");
				return instructions;
			}
			Label label = generator.DefineLabel();
			val.Insert((CodeInstruction[])(object)new CodeInstruction[4]
			{
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Ldfld, (object)fieldInfo),
				new CodeInstruction(OpCodes.Ldc_I4_0, (object)null),
				new CodeInstruction(OpCodes.Bge_S, (object)label)
			});
			val.Advance(12);
			val.Labels.Add(label);
			return val.InstructionEnumeration();
		}
	}

	[HarmonyPatch(typeof(Player), "SpawnHero")]
	private static class Player_SpawnHero_Patch
	{
		private static void Prefix(Player __instance, ref HeroType nextHeroType)
		{
			if (!Main.enabled)
			{
				return;
			}
			Main.currentlyEnemy[__instance.playerNum] = false;
			if (Main.settings.spawnAsEnemyEnabled)
			{
				Main.willReplaceBro[__instance.playerNum] = Main.settings.spawnAsEnemyChance > 0f && Main.settings.spawnAsEnemyChance >= Random.value * 100f;
				if (Main.willReplaceBro[__instance.playerNum])
				{
					Main.DisableBroMaker(__instance.playerNum);
				}
			}
		}

		private static void Postfix(Player __instance)
		{
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Invalid comparison between Unknown and I4
			if (!Main.enabled)
			{
				return;
			}
			try
			{
				if (Main.willReplaceBro[__instance.playerNum])
				{
					Main.EnableBroMaker();
					Main.willReplaceBro[__instance.playerNum] = false;
					if (!Main.settings.alwaysChosen)
					{
						Main.settings.selGridInt[__instance.playerNum] = Random.Range(0, Main.currentUnitList.Length);
					}
					TestVanDammeAnim component = Main.SpawnUnit(Main.GetSelectedUnit(__instance.playerNum), new Vector3(0f, 0f, 0f)).GetComponent<TestVanDammeAnim>();
					Main.StartControllingUnit(__instance.playerNum, component, gentleLeave: false, savePreviousCharacter: false, erasePreviousCharacter: true);
					Main.WorkOutSpawnPosition(__instance, component);
					if ((int)Main.GetSelectedUnit(__instance.playerNum) == 38)
					{
						HarmonyExtensions.SetFieldValue<bool>((object)Traverse.Create((object)component), "flying", true);
						((BroforceObject)component).yI = ((BroforceObject)component).yI + 30f;
						((BroforceObject)component).xI = ((BroforceObject)component).xI + 30f;
						((BroforceObject)component).Y = ((BroforceObject)component).Y + 10f;
					}
				}
				else
				{
					Main.previousCharacter[__instance.playerNum] = null;
					Main.currentlyEnemy[__instance.playerNum] = false;
				}
				if (Main.settings.competitiveModeEnabled && __instance.playerNum != Main.currentHeroNum)
				{
					Main.HidePlayer(__instance.playerNum);
				}
			}
			catch (Exception ex)
			{
				Main.Log("Exception replacing bro: " + ex.ToString());
			}
		}
	}

	[HarmonyPatch(typeof(Player), "InstantiateHero")]
	private static class Player_InstantiateHero_Patch
	{
		private static void Postfix(Player __instance, ref TestVanDammeAnim __result)
		{
			if (Main.enabled && Main.willReplaceBro[__instance.playerNum])
			{
				((Component)__result).gameObject.SetActive(false);
			}
		}
	}

	[HarmonyPatch(typeof(Map), "AddBroToHeroTransport")]
	private static class Map_AddBroToHeroTransport_Patch
	{
		private static bool Prefix(Map __instance, ref TestVanDammeAnim Bro)
		{
			if (Main.enabled)
			{
				if (((NetworkedUnit)Bro).playerNum >= 0 && ((NetworkedUnit)Bro).playerNum < 4)
				{
					return !Main.willReplaceBro[((NetworkedUnit)Bro).playerNum];
				}
				return true;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Player), "WorkOutSpawnPosition")]
	private static class Player_WorkOutSpawnPosition_Patch
	{
		private static void Prefix(Player __instance, ref TestVanDammeAnim bro)
		{
			if (Main.enabled && Main.willReplaceBro[__instance.playerNum])
			{
				Main.wasFirstDeployment[__instance.playerNum] = __instance.firstDeployment;
			}
		}
	}

	[HarmonyPatch(typeof(Player), "WorkOutSpawnScenario")]
	public static class Player_WorkOutSpawnScenario_Patch
	{
		public static bool forceCheckpointSpawn;

		private static void Postfix(Player __instance, ref SpawnType __result)
		{
			if (!Main.enabled)
			{
				return;
			}
			if (Main.settings.competitiveModeEnabled)
			{
				if (__instance.firstDeployment)
				{
					if (__instance.playerNum == Main.currentHeroNum)
					{
						if (Main.settings.heroLives == 0)
						{
							__instance.Lives = 10;
						}
						else if (Main.anyAttemptingWin)
						{
							__instance.Lives = Main.settings.heroLives + Main.settings.extraLiveOnBossLevel + Main.settings.livesHandicap[__instance.playerNum];
						}
						else
						{
							__instance.Lives = Main.settings.heroLives + Main.settings.livesHandicap[__instance.playerNum];
						}
					}
					else if (Main.settings.ghostLives == 0)
					{
						__instance.Lives = 10;
					}
					else
					{
						__instance.Lives = Main.settings.ghostLives + Main.settings.livesHandicap[__instance.playerNum];
					}
				}
				if (forceCheckpointSpawn)
				{
					__result = (SpawnType)2;
					if (Main.isBroMakerInstalled)
					{
						Main.OverrideSpawn(__instance.playerNum);
					}
					forceCheckpointSpawn = false;
				}
			}
			if (Main.willReplaceBro[__instance.playerNum])
			{
				Main.previousSpawnInfo[__instance.playerNum] = __result;
			}
		}
	}

	[HarmonyPatch(typeof(HeroTransport), "ReleaseBros")]
	private static class HeroTransport_ReleaseBros_Patch
	{
		public static void Postfix(HeroTransport __instance)
		{
			if (!Main.enabled)
			{
				return;
			}
			for (int i = 0; i < 4; i++)
			{
				if (HeroController.PlayerIsAlive(i) && Main.currentlyEnemy[i])
				{
					TestVanDammeAnim character = HeroController.players[i].character;
					if ((Object)(object)((NetworkedUnit)character).enemyAI != (Object)null)
					{
						((Behaviour)((NetworkedUnit)character).enemyAI).enabled = true;
					}
				}
			}
		}
	}

	[HarmonyPatch(typeof(Player), "GetInput")]
	private static class Player_GetInput_Patch
	{
		public static void Postfix(Player __instance, ref bool up, ref bool down, ref bool left, ref bool right, ref bool fire, ref bool buttonJump, ref bool special, ref bool highFive, ref bool buttonGesture, ref bool sprint)
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: 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_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Invalid comparison between Unknown and I4
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Invalid comparison between Unknown and I4
			if (!Main.enabled)
			{
				return;
			}
			int playerNum = __instance.playerNum;
			if (Main.settings.spawnAsEnemyEnabled)
			{
				bool flag = Main.swapEnemiesLeft.IsDown(playerNum);
				bool flag2 = Main.swapEnemiesRight.IsDown(playerNum);
				if ((((flag || flag2) && Main.currentSpawnCooldown[playerNum] <= 0f && __instance.IsAlive()) || (Main.settings.clickingSwapEnabled && Main.switched[playerNum])) && (Object)(object)__instance.character.pilottedUnit == (Object)null)
				{
					Vector3 characterPosition = __instance.GetCharacterPosition();
					float x = characterPosition.x;
					float y = characterPosition.y;
					float num = (float)Traverse.Create((object)__instance.character).Field("xI").GetValue();
					float num2 = (float)Traverse.Create((object)__instance.character).Field("yI").GetValue();
					if (Main.settings.clickingSwapEnabled && Main.switched[playerNum])
					{
						try
						{
							TestVanDammeAnim component = Main.SpawnUnit(Main.GetSelectedUnit(playerNum), characterPosition).GetComponent<TestVanDammeAnim>();
							Main.StartControllingUnit(playerNum, component, gentleLeave: false, savePreviousCharacter: false, erasePreviousCharacter: true);
							((Unit)__instance.character).SetPositionAndVelocity(x, y, num, num2);
							__instance.character.SetInvulnerable(0f, false, false);
							if ((int)Main.GetSelectedUnit(__instance.playerNum) == 38)
							{
								HarmonyExtensions.SetFieldValue<bool>((object)Traverse.Create((object)component), "flying", true);
								((BroforceObject)component).yI = ((BroforceObject)component).yI + 30f;
								((BroforceObject)component).xI = ((BroforceObject)component).xI + 30f;
								((BroforceObject)component).Y = ((BroforceObject)component).Y + 10f;
							}
							Main.switched[playerNum] = false;
							return;
						}
						catch (Exception ex)
						{
							Main.Log("Exception switching unit: " + ex.ToString());
							return;
						}
					}
					if (flag)
					{
						Main.settings.selGridInt[playerNum]--;
						if (Main.settings.selGridInt[playerNum] < 0)
						{
							Main.settings.selGridInt[playerNum] = Main.currentUnitList.Length - 1;
						}
					}
					else if (flag2)
					{
						Main.settings.selGridInt[playerNum]++;
						if (Main.settings.selGridInt[playerNum] > Main.currentUnitList.Length - 1)
						{
							Main.settings.selGridInt[playerNum] = 0;
						}
					}
					TestVanDammeAnim component2 = Main.SpawnUnit(Main.GetSelectedUnit(playerNum), characterPosition).GetComponent<TestVanDammeAnim>();
					Main.StartControllingUnit(playerNum, component2, gentleLeave: false, savePreviousCharacter: false, erasePreviousCharacter: true);
					((Unit)__instance._character).SetPositionAndVelocity(x, y, num, num2);
					__instance.character.SetInvulnerable(0f, false, false);
					if ((int)Main.GetSelectedUnit(__instance.playerNum) == 38)
					{
						HarmonyExtensions.SetFieldValue<bool>((object)Traverse.Create((object)component2), "flying", true);
						((BroforceObject)component2).yI = ((BroforceObject)component2).yI + 30f;
						((BroforceObject)component2).xI = ((BroforceObject)component2).xI + 30f;
						((BroforceObject)component2).Y = ((BroforceObject)component2).Y + 10f;
					}
					Main.currentSpawnCooldown[playerNum] = Main.settings.spawnSwapCooldown;
				}
			}
			if (!Main.currentlyEnemy[playerNum])
			{
				return;
			}
			TestVanDammeAnim character = __instance.character;
			bool down2 = Main.special2[playerNum].IsDown();
			bool down3 = Main.special3[playerNum].IsDown();
			Main.HandleSpecial(ref special, ref Main.specialWasDown[playerNum], ref Main.holdingSpecial[playerNum], character, playerNum);
			Main.HandleButton(down2, ref Main.holdingSpecial2[playerNum], ref Main.special2[playerNum].wasDown, Main.PressSpecial2, Main.ReleaseSpecial2, character, playerNum);
			Main.HandleButton(down3, ref Main.holdingSpecial3[playerNum], ref Main.special3[playerNum].wasDown, Main.PressSpecial3, Main.ReleaseSpecial3, character, playerNum);
			special = Main.holdingSpecial[playerNum];
			if (buttonGesture && !Main.holdingGesture[playerNum] && UnitTypes.CanDance(Main.currentUnitType[playerNum]))
			{
				Main.holdingGesture[playerNum] = true;
				((Unit)character).Dance(10000000f);
			}
			if (Main.settings.competitiveModeEnabled)
			{
				if (fire && Main.currentHeroNum != playerNum)
				{
					Main.revealed[playerNum] = true;
				}
				if (((Unit)character).IsIncapacitated() || ((Unit)character).IsBlind())
				{
					up = (down = (left = (right = (fire = (buttonJump = (special = (highFive = (buttonGesture = (sprint = false)))))))));
				}
			}
		}
	}

	[HarmonyPatch(typeof(TestVanDammeAnim), "Start")]
	private static class TestVanDammeAnim_Start_Patch
	{
		public static void Postfix(TestVanDammeAnim __instance)
		{
			if (!Main.enabled)
			{
				return;
			}
			if (Main.settings.spawnAsEnemyEnabled)
			{
				if (((Object)__instance).name == "c")
				{
					int num = Main.currentUnit.IndexOf((Unit)(object)__instance);
					if (num != ((NetworkedUnit)__instance).playerNum)
					{
						Main.ReaffirmControl(num);
					}
					__instance.SpecialAmmo = 0;
				}
			}
			else if (Main.settings.competitiveModeEnabled && Main.waitingToBecomeEnemy.Count > 0)
			{
				int num2 = Main.waitingToBecomeEnemy[Random.Range(0, Main.waitingToBecomeEnemy.Count)];
				if (num2 == Main.currentHeroNum)
				{
					Main.waitingToBecomeEnemy.Remove(num2);
				}
				else if ((((NetworkedUnit)__instance).playerNum < 0 || ((NetworkedUnit)__instance).playerNum >= 4) && ((Object)__instance).name != "c" && ((Object)__instance).name != "Hobro")
				{
					Main.StartControllingUnit(num2, __instance);
				}
			}
		}
	}

	[HarmonyPatch(typeof(Alien), "Start")]
	private static class Alien_Start_Patch
	{
		public static void Postfix(Alien __instance)
		{
			if (Main.enabled && ((Object)__instance).name == "c")
			{
				int num = Main.currentUnit.IndexOf((Unit)(object)__instance);
				if (num != ((NetworkedUnit)__instance).playerNum)
				{
					Main.ReaffirmControl(num);
				}
				((TestVanDammeAnim)__instance).SpecialAmmo = 0;
			}
		}
	}

	[HarmonyPatch(typeof(GameModeController), "DoesPlayerNumDamage")]
	private static class GameModeController_DoesPlayerNumDamage_Patch
	{
		public static void Postfix(GameModeController __instance, ref int fromNum, ref int toNum, ref bool __result)
		{
			if (!Main.enabled || !Main.settings.competitiveModeEnabled || fromNum == toNum)
			{
				return;
			}
			if (toNum == Main.currentHeroNum)
			{
				if (fromNum < 4)
				{
					__result = true;
				}
			}
			else if (fromNum == Main.currentHeroNum)
			{
				if (toNum >= 0 && toNum < 4 && Main.currentlyEnemy[toNum])
				{
					__result = true;
				}
			}
			else if (fromNum != Main.currentHeroNum)
			{
				if (toNum >= 0 && toNum < 4)
				{
					__result = false;
				}
				else
				{
					__result = false;
				}
			}
		}
	}

	[HarmonyPatch(typeof(Player), "HasFollowPosition")]
	private static class Player_HasFollowPosition_Patch
	{
		public static bool Prefix(Player __instance, ref bool __result)
		{
			if (!Main.enabled || !Main.settings.competitiveModeEnabled)
			{
				return true;
			}
			if ((Object)(object)__instance != (Object)null && __instance.playerNum != Main.currentHeroNum && (!Main.settings.ghostControlledEnemiesAffectCamera || (Object)(object)__instance.character == (Object)null || ((BroforceObject)__instance.character).destroyed || ((Object)__instance.character).name != "c" || !((BroforceObject)__instance.character).IsAlive()))
			{
				__result = false;
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(TestVanDammeAnim), "AlertNearbyMooks")]
	private static class TestVanDammeAnim_AlertNearbyMooks_Patch
	{
		public static bool Prefix(TestVanDammeAnim __instance)
		{
			if (!Main.enabled || !Main.settings.competitiveModeEnabled)
			{
				return true;
			}
			if (((NetworkedUnit)__instance).IsHero && ((NetworkedUnit)__instance).playerNum != Main.currentHeroNum)
			{
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(TestVanDammeAnim), "IsInStealthMode")]
	private static class TestVanDammeAnim_IsInStealthMode_Patch
	{
		public static bool Prefix(TestVanDammeAnim __instance, ref bool __result)
		{
			if (!Main.enabled || !Main.settings.competitiveModeEnabled)
			{
				return true;
			}
			if (((NetworkedUnit)__instance).playerNum >= 0 && ((NetworkedUnit)__instance).playerNum < 4 && ((NetworkedUnit)__instance).playerNum != Main.currentHeroNum)
			{
				__result = true;
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Map), "DisturbWildLife")]
	private static class Map_DisturbWildLife_Patch
	{
		public static bool Prefix(Map __instance, ref int playerNum)
		{
			if (!Main.enabled || !Main.settings.competitiveModeEnabled)
			{
				return true;
			}
			if (playerNum >= 0 && playerNum < 4 && playerNum != Main.currentHeroNum)
			{
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Map), "BotherNearbyMooks")]
	private static class Map_BotherNearbyMooks_Patch
	{
		public static bool Prefix(Map __instance, ref int playerNum)
		{
			if (!Main.enabled || !Main.settings.competitiveModeEnabled)
			{
				return true;
			}
			if (playerNum >= 0 && playerNum < 4 && playerNum != Main.currentHeroNum)
			{
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Player), "Start")]
	private static class Player_Start_Patch
	{
		public static void Postfix(Player __instance)
		{
			if (!Main.enabled || !Main.settings.competitiveModeEnabled)
			{
				return;
			}
			ScoreManager.SetupSprites(__instance.playerNum);
			if (__instance.playerNum == Main.currentHeroNum)
			{
				if (Main.settings.heroLives == 0)
				{
					__instance.Lives = 10;
				}
				else if (Main.anyAttemptingWin)
				{
					__instance.Lives = Main.settings.heroLives + Main.settings.extraLiveOnBossLevel + Main.settings.livesHandicap[__instance.playerNum];
				}
				else
				{
					__instance.Lives = Main.settings.heroLives + Main.settings.livesHandicap[__instance.playerNum];
				}
			}
			else if (Main.settings.ghostLives == 0)
			{
				__instance.Lives = 10;
			}
			else
			{
				__instance.Lives = Main.settings.ghostLives + Main.settings.livesHandicap[__instance.playerNum];
			}
		}
	}

	[HarmonyPatch(typeof(HeroController), "FlashAvatar")]
	private static class HeroController_FlashAvatar_Patch
	{
		public static bool Prefix(ref int playerNum)
		{
			if (!Main.enabled || !Main.settings.competitiveModeEnabled)
			{
				return true;
			}
			return playerNum == Main.currentHeroNum;
		}
	}

	[HarmonyPatch(typeof(PlayerHUD), "FlashAvatar")]
	private static class PlayerHUD_FlashAvatar_Patch
	{
		public static bool Prefix(PlayerHUD __instance, int ___playerNum)
		{
			if (!Main.enabled || !Main.settings.competitiveModeEnabled)
			{
				return true;
			}
			return ___playerNum == Main.currentHeroNum;
		}
	}

	[HarmonyPatch(typeof(HeroController), "DropoutRPC")]
	private static class HeroController_DropoutRPC_Patch
	{
		public static void Prefix(ref int playerNum)
		{
			if (Main.enabled && Main.settings.competitiveModeEnabled && (Object)(object)Main.currentGhosts[playerNum] != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)Main.currentGhosts[playerNum]).gameObject);
				Main.previousCharacter[playerNum] = null;
				Main.currentlyEnemy[playerNum] = false;
				Main.currentGhosts[playerNum] = null;
			}
		}
	}

	[HarmonyPatch(typeof(TestVanDammeAnim), "CheckRescues")]
	private static class TestVanDammeAnim_CheckRescues_Patch
	{
		public static bool Prefix(TestVanDammeAnim __instance)
		{
			if (!Main.enabled || !Main.settings.competitiveModeEnabled)
			{
				return true;
			}
			return ((NetworkedUnit)__instance).playerNum == Main.currentHeroNum;
		}
	}

	[HarmonyPatch(typeof(HeroController), "IsAnotherPlayerNearby")]
	private static class HeroController_IsAnotherPlayerNearby_Patch
	{
		public static bool Prefix(HeroController __instance, ref bool __result)
		{
			if (!Main.enabled || !Main.settings.competitiveModeEnabled)
			{
				return true;
			}
			__result = false;
			return false;
		}
	}

	[HarmonyPatch(typeof(Map), "GetNearbyMook")]
	private static class Map_GetNearbyMook_Patch
	{
		public static bool Prefix(Map __instance, ref float xRange, ref float yRange, ref float x, ref float y, ref int direction, ref bool canBeDead, ref Mook __result)
		{
			if (!Main.enabled || !Main.settings.competitiveModeEnabled)
			{
				return true;
			}
			__result = null;
			float num = Mathf.Max(xRange, yRange) + 1f;
			for (int num2 = Map.units.Count - 1; num2 >= 0; num2--)
			{
				Unit val = Map.units[num2];
				if (!((Object)(object)val == (Object)null) && (((NetworkedUnit)val).playerNum < 0 || ((Object)val).name == "c") && (canBeDead || ((BroforceObject)val).health > 0))
				{
					float num3 = ((BroforceObject)val).X - x;
					if (Tools.FastAbsWithinRange(num3, xRange) && Mathf.Sign(num3) == (float)direction)
					{
						float num4 = ((BroforceObject)val).Y - y;
						if (Tools.FastAbsWithinRange(num4, yRange))
						{
							Mook component = ((Component)val).GetComponent<Mook>();
							if ((Object)(object)component != (Object)null)
							{
								float num5 = Mathf.Abs(num3) + Mathf.Abs(num4);
								if (num5 < num)
								{
									num = num5;
									__result = component;
								}
							}
						}
					}
				}
			}
			return false;
		}
	}

	[HarmonyPatch(typeof(Map), "GetNearbyMookVertical")]
	private static class Map_GetNearbyMookVertical_Patch
	{
		public static bool Prefix(Map __instance, ref float xRange, ref float yRange, ref float x, ref float y, ref int direction, ref bool canBeDead, ref Mook __result)
		{
			if (!Main.enabled || !Main.settings.competitiveModeEnabled)
			{
				return true;
			}
			if (Map.units == null)
			{
				__result = null;
				return false;
			}
			float num = Mathf.Max(xRange, yRange) + 1f;
			for (int num2 = Map.units.Count - 1; num2 >= 0; num2--)
			{
				Unit val = Map.units[num2];
				if (!((Object)(object)val == (Object)null) && ((NetworkedUnit)val).playerNum < 0 && (canBeDead || ((BroforceObject)val).health > 0))
				{
					float num3 = ((BroforceObject)val).X - x;
					if (Tools.FastAbsWithinRange(num3, xRange))
					{
						float num4 = ((BroforceObject)val).Y - y;
						if (Tools.FastAbsWithinRange(num4, yRange) && Mathf.Sign(num4) == (float)direction)
						{
							Mook component = ((Component)val).GetComponent<Mook>();
							if ((Object)(object)component != (Object)null)
							{
								float num5 = Mathf.Abs(num3) + Mathf.Abs(num4);
								if (num5 < num)
								{
									num = num5;
									__result = component;
								}
							}
						}
					}
				}
			}
			return false;
		}
	}

	[HarmonyPatch(typeof(HeroController), "MayIRescueThisBro")]
	private static class HeroController_MayIRescueThisBro_Patch
	{
		public static bool Prefix(HeroController __instance, ref int playerNum, ref RescueBro rescueBro, ref Ack ackRequest)
		{
			if (!Main.enabled || !Main.settings.competitiveModeEnabled)
			{
				return true;
			}
			if (playerNum == Main.currentHeroNum)
			{
				typeof(HeroController).GetMethod("SwapBro", BindingFlags.Instance | BindingFlags.NonPublic).Invoke(__instance, new object[4]
				{
					playerNum,
					rescueBro,
					HeroController.Instance.playerDeathOrder.ToArray(),
					ackRequest
				});
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(GameModeController), "LevelFinish")]
	public static class GameModeController_LevelFinish_Patch
	{
		public static bool finishedThisLevel;

		public static void Prefix(GameModeController __instance, ref LevelResult result)
		{
			if (Main.enabled && Main.settings.competitiveModeEnabled && (int)result == 1 && !finishedThisLevel)
			{
				finishedThisLevel = true;
				ScoreManager.currentScore[Main.currentHeroNum]++;
				ScoreManager.UpdateScore(Main.currentHeroNum);
			}
		}
	}

	[HarmonyPatch(typeof(Animal), "RunFalling")]
	private static class Animal_RunFalling_Patch
	{
		public static bool Prefix(Animal __instance)
		{
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			if (!Main.enabled || !Main.settings.competitiveModeEnabled)
			{
				return true;
			}
			if (((Object)__instance).name == "c" && __instance.fatAnimal)
			{
				((Unit)__instance).invulnerable = true;
				if (Map.HitLivingUnits((MonoBehaviour)(object)__instance, ((NetworkedUnit)__instance).playerNum, 3, (DamageType)4, __instance.squashRange, ((BroforceObject)__instance).X, ((BroforceObject)__instance).Y + 2f, ((Component)__instance).transform.localScale.x * 100f, 30f, false, true, true, false))
				{
					((TestVanDammeAnim)__instance).PlaySpecialAttackSound(0.25f);
					((BroforceObject)__instance).yI = 160f;
				}
				((Unit)__instance).invulnerable = false;
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(TestVanDammeAnim), "CheckForCheckPoints")]
	private static class TestVanDammeAnim_CheckForCheckPoints_Patch
	{
		public static bool Prefix(TestVanDammeAnim __instance)
		{
			if (!Main.enabled || !Main.settings.competitiveModeEnabled)
			{
				return true;
			}
			if (((Object)__instance).name == "c")
			{
				return false;
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(Map), "CallInTransport_RPC")]
	private static class Map_CallInTransport_RPC_Patch
	{
		public static void Prefix(Map __instance, ref bool ArriveByHelicopter)
		{
			if (Main.enabled && Main.settings.competitiveModeEnabled)
			{
				Helicopter_Enter_Patch.helicopterDroppingOff = ArriveByHelicopter;
			}
		}
	}

	[HarmonyPatch(typeof(Helicopter), "Enter")]
	public static class Helicopter_Enter_Patch
	{
		public static bool helicopterDroppingOff;

		public static void Postfix(Helicopter __instance, ref Vector2 Target)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			if (!Main.enabled || !Main.settings.competitiveModeEnabled)
			{
				return;
			}
			if (!helicopterDroppingOff && !Main.openedPortal)
			{
				for (int i = 0; i < 4; i++)
				{
					if (ScoreManager.CanWin(i))
					{
						Main.openedPortal = true;
						Vector2 val = Target;
						val.x += 70f;
						Map.CreateExitPortal(val);
						return;
					}
				}
			}
			helicopterDroppingOff = false;
		}
	}

	[HarmonyPatch(typeof(GiantElevator), "StartMoving")]
	private static class GiantElevator_StartMoving_Patch
	{
		public static bool Prefix(GiantElevator __instance, float ___floorY, bool ___hasDoneVictory)
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			if (!Main.enabled || !Main.settings.competitiveModeEnabled)
			{
				return true;
			}
			if (Main.disableElevatorCounter > 0f)
			{
				return false;
			}
			if (!Main.openedPortal && ___floorY < 0f && !___hasDoneVictory)
			{
				for (int i = 0; i < 4; i++)
				{
					if (ScoreManager.CanWin(i))
					{
						Main.openedPortal = true;
						Main.disableElevatorCounter = 5f;
						Map.CreateExitPortal(new Vector2(((Component)__instance).transform.position.x, ((Component)__instance).transform.position.y + 20f));
						return false;
					}
				}
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(TestVanDammeAnim), "SuckIntoPortal")]
	private static class TestVanDammeAnim_SuckIntoPortal_Patch
	{
		public static void Prefix(TestVanDammeAnim __instance)
		{
			if (Main.enabled && Main.settings.competitiveModeEnabled && ScoreManager.CanWin(((NetworkedUnit)__instance).playerNum))
			{
				Main.anyAttemptingWin = true;
				Main.attemptingWin = ((NetworkedUnit)__instance).playerNum;
			}
		}
	}

	[HarmonyPatch(typeof(GameModeController), "LoadNextScene")]
	private static class GameModeController_LoadNextScene_Patch
	{
		public static void Prefix(GameModeController __instance)
		{
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references