Decompiled source of REPORoles Classic v2.2.2

Repo_Roles.dll

Decompiled 2 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using MenuLib;
using MenuLib.MonoBehaviors;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using R.E.P.O.Roles;
using R.E.P.O.Roles.patches;
using REPOLib;
using REPOLib.Modules;
using Repo_Roles;
using TMPro;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("REPO Roles Classic")]
[assembly: AssemblyDescription("REPO Roles Mod for R.E.P.O.! Originally developed by KingRobin72, updated by R3 Labs.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("KingRobin72, R3Labs")]
[assembly: AssemblyProduct("REPO Roles Classic")]
[assembly: AssemblyCopyright("")]
[assembly: ComVisible(false)]
[assembly: Guid("b55829e7-8346-4258-b5db-23566f7af06b")]
[assembly: AssemblyFileVersion("2.2.2")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.2.2.0")]
[module: UnverifiableCode]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace R.E.P.O.Roles
{
	public class ClassManager
	{
		private Random rnd = new Random();

		public int chosenRoleId;

		private StrengthManager strManager = new StrengthManager();

		public string chosenRole;

		public int roleAmount = 10;

		public RepoRoles repoRoles = new RepoRoles();

		public ReaperManager rMan;

		public readonly Harmony harmonyPatcher = new Harmony("patches.reporoles.mod");

		public static int stackKills;

		public static bool isTank;

		public static bool isScout;

		private string[] roleNames = new string[11]
		{
			"Random", "Runner", "Tank", "Gambler", "Strongman", "Ranged Looter", "Athletic", "Mage", "Reaper", "Scout",
			"Regular"
		};

		public int genGamblerEffectNr()
		{
			return rnd.Next(0, 5);
		}

		public object[] genGamblerEffects()
		{
			string[] array = new string[5] { "You walk faster", "You have more stamina", "You have more health", "You\u00b4re stronger", "You jump higher" };
			string[] array2 = new string[5] { "you walk slower", "you have less stamina", "you have less health", "you\u00b4re weaker", "you don\u00b4t jump as high" };
			int num = genGamblerEffectNr();
			int num2 = genGamblerEffectNr();
			while (num == num2)
			{
				num = genGamblerEffectNr();
				num2 = genGamblerEffectNr();
			}
			string text = array[num];
			string text2 = array2[num2];
			string text3 = RepoRoles.customRoleDecGambler.Value + " " + text + " but " + text2 + "!";
			return new object[3] { text3, num, num2 };
		}

		public void assignRoleFromConfig(PlayerController __instance)
		{
			string value = RepoRoles.savedRole.Value;
			if (value == "" || value == "Random")
			{
				chosenRoleId = rnd.Next(1, roleAmount + 1);
				RepoRoles.Logger.LogInfo((object)"Rolling random role...");
			}
			else
			{
				chosenRoleId = Array.IndexOf(roleNames, value);
			}
			assignRole(chosenRoleId, __instance);
		}

		private void modifyStrength(string steamID, float newStrength)
		{
			if (!SemiFunc.IsMultiplayer())
			{
				PlayerAvatar.instance.physGrabber.grabStrength = newStrength;
				return;
			}
			PunManager.instance.photonView.RPC("setStrengthRPC", (RpcTarget)0, new object[2] { steamID, newStrength });
		}

		private void setHealth(string steamID, int maxHealth, int health)
		{
			if (!SemiFunc.IsMultiplayer())
			{
				PlayerAvatar.instance.playerHealth.health = health;
				PlayerAvatar.instance.playerHealth.maxHealth = maxHealth;
				return;
			}
			PunManager.instance.photonView.RPC("setHealthRPC", (RpcTarget)0, new object[3] { steamID, maxHealth, health });
		}

		public void setReaperStatus(string steamID, bool isReaper)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			if (!SemiFunc.IsMultiplayer())
			{
				((Component)PlayerAvatar.instance).GetComponent<ReaperManager>().isReaper = isReaper;
			}
			else if ((Object)PlayerAvatar.instance.photonView != (Object)null && !((Object)(object)RunManager.instance == (Object)null) && !((Object)(object)RunManager.instance.levelCurrent == (Object)null) && RunManager.instance.levels.Contains(RunManager.instance.levelCurrent) && (Object)(object)PlayerAvatar.instance != (Object)null && (Object)(object)PlayerAvatar.instance.photonView != (Object)null)
			{
				PlayerAvatar.instance.photonView.RPC("setReaperStatusRPC", (RpcTarget)0, new object[2] { steamID, isReaper });
				RepoRoles.Logger.LogInfo((object)$"[CsMr] setReaperStatus: sent RPC for {steamID}, setTo={isReaper}");
			}
		}

		public void assignRole(int roleId, PlayerController __instance)
		{
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			//IL_036c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0371: Unknown result type (might be due to invalid IL or missing references)
			//IL_038f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0941: Unknown result type (might be due to invalid IL or missing references)
			//IL_0946: Unknown result type (might be due to invalid IL or missing references)
			//IL_0964: Unknown result type (might be due to invalid IL or missing references)
			//IL_0996: Unknown result type (might be due to invalid IL or missing references)
			//IL_099b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a81: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a86: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aa4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ad6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0adb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bc4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bc9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0be7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c0a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c0f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0eed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ef2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f10: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f42: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f47: Unknown result type (might be due to invalid IL or missing references)
			//IL_1031: Unknown result type (might be due to invalid IL or missing references)
			//IL_1036: Unknown result type (might be due to invalid IL or missing references)
			//IL_1059: Unknown result type (might be due to invalid IL or missing references)
			//IL_1081: Unknown result type (might be due to invalid IL or missing references)
			//IL_10b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_10b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_118b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1190: Unknown result type (might be due to invalid IL or missing references)
			//IL_11ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_11d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_11d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d57: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d5c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0d88: Unknown result type (might be due to invalid IL or missing references)
			//IL_0da7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ddd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0de2: Unknown result type (might be due to invalid IL or missing references)
			//IL_07cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0813: Unknown result type (might be due to invalid IL or missing references)
			RepoRoles.Update_ManaRegeneration();
			RepoRoles.Update_ScoutCooldown();
			float moveSpeed = __instance.MoveSpeed;
			float sprintSpeed = __instance.SprintSpeed;
			float crouchSpeed = __instance.CrouchSpeed;
			float jumpForce = __instance.JumpForce;
			float energyStart = __instance.EnergyStart;
			float energyCurrent = __instance.EnergyCurrent;
			float grabStrength = PlayerAvatar.instance.physGrabber.grabStrength;
			float grabRange = PlayerAvatar.instance.physGrabber.grabRange;
			int num = (int)AccessTools.Field(typeof(PlayerHealth), "maxHealth").GetValue(PlayerAvatar.instance.playerHealth);
			int num2 = (int)AccessTools.Field(typeof(PlayerHealth), "health").GetValue(PlayerAvatar.instance.playerHealth);
			if ((Object)((Component)PlayerAvatar.instance).GetComponent<ReaperManager>() != (Object)null)
			{
				rMan = ((Component)PlayerAvatar.instance).GetComponent<ReaperManager>();
			}
			else
			{
				RepoRoles.Logger.LogError((object)"Failed to get Reaper Manager! Please contact the mod developer about this.");
			}
			string text = SemiFunc.PlayerGetName(PlayerAvatar.instance);
			string text2 = SemiFunc.PlayerGetSteamID(PlayerAvatar.instance);
			stackKills = 0;
			guiManager.isMage = false;
			isTank = false;
			setReaperStatus(PlayerController.instance.playerSteamID, isReaper: false);
			isScout = false;
			if (!SemiFunc.RunIsLevel() || SemiFunc.RunIsShop())
			{
				return;
			}
			if (!RepoRoles.enableRunner.Value && !RepoRoles.enableTank.Value && !RepoRoles.enableGambler.Value && !RepoRoles.enableStrongman.Value && !RepoRoles.enableRL.Value && !RepoRoles.enableAthletic.Value && !RepoRoles.enableMage.Value && !RepoRoles.enableReaper.Value && !RepoRoles.enableScout.Value && !RepoRoles.enableRegular.Value)
			{
				RepoRoles.Logger.LogError((object)"WARNING! You disabled all roles in the config file. You will not get any roles until you change it back.");
				return;
			}
			if (RepoRoles.showGUIAtStart.Value)
			{
				guiManager.showGUI = true;
			}
			else
			{
				guiManager.showGUI = false;
			}
			harmonyPatcher.PatchAll(typeof(PunManagerPatch));
			if (roleId <= 0)
			{
				RepoRoles.Logger.LogWarning((object)"Unable to find RoleId! Please contact the mod developer.");
				return;
			}
			switch (roleId)
			{
			case 1:
				if (!RepoRoles.enableRunner.Value)
				{
					assignRole(rnd.Next(1, roleAmount + 1), PlayerController.instance);
					RepoRoles.Logger.LogInfo((object)"You got assigned a new random role because this one was disabled.");
					break;
				}
				guiManager.ResetManaUI();
				RepoRoles.Logger.LogInfo((object)"Resetting Mana UI.");
				RepoRoles.Logger.LogInfo((object)("Assigning role " + RepoRoles.customRoleNameRunner.Value + "."));
				__instance.CrouchSpeed = crouchSpeed * 1.5f;
				__instance.MoveSpeed = moveSpeed * 1.5f;
				__instance.SprintSpeed = sprintSpeed * 1.5f;
				__instance.EnergyStart = energyStart * 1.5f;
				__instance.EnergyCurrent = energyCurrent * 1.5f;
				RepoRoles.GUIinstance.text = RepoRoles.customRoleNameRunner.Value;
				RepoRoles.GUIinstance.color = new Color(0.973f, 1f, 0.196f);
				RepoRoles.GUIinstance.descText = RepoRoles.customRoleDecRunner.Value + "\nPress " + ((object)RepoRoles.toggleKey.Value).ToString() + " to continue";
				RepoRoles.GUIinstance.descColor = new Color(0.973f, 1f, 0.196f);
				break;
			case 2:
				if (!RepoRoles.enableTank.Value)
				{
					assignRole(rnd.Next(1, roleAmount + 1), PlayerController.instance);
					RepoRoles.Logger.LogInfo((object)"You got assigned a new random role because this one was disabled.");
					break;
				}
				guiManager.ResetManaUI();
				RepoRoles.Logger.LogInfo((object)"Resetting Mana UI.");
				RepoRoles.Logger.LogInfo((object)("Assigning role " + RepoRoles.customRoleNameTank.Value + "."));
				setHealth(PlayerController.instance.playerSteamID, num * 2, num2 * 2);
				__instance.CrouchSpeed = crouchSpeed * 0.9f;
				__instance.MoveSpeed = moveSpeed * 0.9f;
				__instance.SprintSpeed = sprintSpeed * 0.9f;
				isTank = true;
				RepoRoles.GUIinstance.text = RepoRoles.customRoleNameTank.Value;
				RepoRoles.GUIinstance.color = Color.gray;
				RepoRoles.GUIinstance.descText = RepoRoles.customRoleDecTank.Value + "\nPress " + ((object)RepoRoles.toggleKey.Value).ToString() + " to continue";
				RepoRoles.GUIinstance.descColor = Color.gray;
				break;
			case 3:
			{
				if (!RepoRoles.enableGambler.Value)
				{
					assignRole(rnd.Next(1, roleAmount + 1), PlayerController.instance);
					RepoRoles.Logger.LogInfo((object)"You got assigned a new random role because this one was disabled.");
					break;
				}
				guiManager.ResetManaUI();
				RepoRoles.Logger.LogInfo((object)"Resetting Mana UI.");
				RepoRoles.Logger.LogInfo((object)("Assigning role " + RepoRoles.customRoleNameGambler.Value + "."));
				object[] array = genGamblerEffects();
				if ((int)array[1] == 0)
				{
					__instance.CrouchSpeed = crouchSpeed * 1.3f;
					__instance.MoveSpeed = moveSpeed * 1.3f;
					__instance.SprintSpeed = sprintSpeed * 1.3f;
				}
				else if ((int)array[1] == 1)
				{
					__instance.EnergyStart = energyStart * 1.8f;
					__instance.EnergyCurrent = energyCurrent * 1.8f;
				}
				else if ((int)array[1] == 2)
				{
					setHealth(PlayerController.instance.playerSteamID, (int)((double)num * 1.8), (int)((double)num2 * 1.8));
				}
				else if ((int)array[1] == 3)
				{
					modifyStrength(PlayerController.instance.playerSteamID, grabStrength * 1.3f);
				}
				else if ((int)array[1] == 4)
				{
					__instance.JumpForce = jumpForce * 1.5f;
				}
				if ((int)array[2] == 0)
				{
					__instance.CrouchSpeed = crouchSpeed * 0.8f;
					__instance.MoveSpeed = moveSpeed * 0.8f;
					__instance.SprintSpeed = sprintSpeed * 0.8f;
				}
				else if ((int)array[2] == 1)
				{
					__instance.EnergyStart = energyStart * 0.8f;
					__instance.EnergyCurrent = energyCurrent * 0.8f;
				}
				else if ((int)array[2] == 2)
				{
					setHealth(PlayerController.instance.playerSteamID, (int)((double)num * 0.8), (int)((double)num2 * 0.8));
				}
				else if ((int)array[2] == 3)
				{
					modifyStrength(PlayerController.instance.playerSteamID, grabStrength * 0.8f);
				}
				else if ((int)array[2] == 4)
				{
					__instance.JumpForce = jumpForce * 0.7f;
				}
				RepoRoles.GUIinstance.text = RepoRoles.customRoleNameGambler.Value;
				RepoRoles.GUIinstance.color = new Color(0.576f, 0f, 0.831f);
				RepoRoles.GUIinstance.descColor = new Color(0.576f, 0f, 0.831f);
				RepoRoles.GUIinstance.descText = array[0]?.ToString() + "\nPress " + ((object)RepoRoles.toggleKey.Value).ToString() + " to continue";
				break;
			}
			case 4:
				if (!RepoRoles.enableStrongman.Value)
				{
					assignRole(rnd.Next(1, roleAmount + 1), PlayerController.instance);
					RepoRoles.Logger.LogInfo((object)"You got assigned a new random role because this one was disabled.");
					break;
				}
				guiManager.ResetManaUI();
				RepoRoles.Logger.LogInfo((object)"Resetting Mana UI.");
				RepoRoles.Logger.LogMessage((object)("Assigning role " + RepoRoles.customRoleNameStrongman.Value + "."));
				RepoRoles.Logger.LogInfo((object)("Strength before: " + grabStrength));
				modifyStrength(PlayerController.instance.playerSteamID, grabStrength * 1.5f + 0.5f);
				RepoRoles.Logger.LogInfo((object)("Strength after: " + PhysGrabber.instance.grabStrength));
				RepoRoles.GUIinstance.text = RepoRoles.customRoleNameStrongman.Value;
				RepoRoles.GUIinstance.color = new Color(0.761f, 0.055f, 0.055f);
				RepoRoles.GUIinstance.descText = RepoRoles.customRoleDecStrongman.Value + "\nPress " + ((object)RepoRoles.toggleKey.Value).ToString() + " to continue";
				RepoRoles.GUIinstance.descColor = new Color(0.761f, 0.055f, 0.055f);
				break;
			case 5:
				if (!RepoRoles.enableRL.Value)
				{
					assignRole(rnd.Next(1, roleAmount + 1), PlayerController.instance);
					RepoRoles.Logger.LogInfo((object)"You got assigned a new random role because this one was disabled.");
					break;
				}
				guiManager.ResetManaUI();
				RepoRoles.Logger.LogInfo((object)"Resetting Mana UI.");
				RepoRoles.Logger.LogMessage((object)("Assigning role " + RepoRoles.customRoleNameRL.Value + "."));
				PlayerAvatar.instance.physGrabber.grabRange = grabRange * 2.5f;
				modifyStrength(PlayerController.instance.playerSteamID, grabStrength * 1.2f);
				RepoRoles.GUIinstance.text = RepoRoles.customRoleNameRL.Value;
				RepoRoles.GUIinstance.color = new Color(0.592f, 0.969f, 0.663f);
				RepoRoles.GUIinstance.descText = RepoRoles.customRoleDecRL.Value + "\nPress " + ((object)RepoRoles.toggleKey.Value).ToString() + " to continue";
				RepoRoles.GUIinstance.descColor = new Color(0.592f, 0.969f, 0.663f);
				break;
			case 6:
				if (!RepoRoles.enableAthletic.Value)
				{
					assignRole(rnd.Next(1, roleAmount + 1), PlayerController.instance);
					RepoRoles.Logger.LogInfo((object)"You got assigned a new random role because this one was disabled.");
					break;
				}
				guiManager.ResetManaUI();
				RepoRoles.Logger.LogInfo((object)"Resetting Mana UI.");
				RepoRoles.Logger.LogMessage((object)("Assigning role " + RepoRoles.customRoleNameAthletic.Value + "."));
				modifyStrength(PlayerController.instance.playerSteamID, grabStrength * 1.4f);
				__instance.EnergyStart = energyStart + 20f;
				__instance.EnergyCurrent = energyCurrent + 20f;
				__instance.JumpForce = jumpForce + 3f;
				RepoRoles.GUIinstance.text = RepoRoles.customRoleNameAthletic.Value;
				RepoRoles.GUIinstance.color = Color.white;
				RepoRoles.GUIinstance.descText = RepoRoles.customRoleDecAthletic.Value + "\nPress " + ((object)RepoRoles.toggleKey.Value).ToString() + " to continue";
				RepoRoles.GUIinstance.descColor = Color.white;
				break;
			case 7:
				if (!RepoRoles.enableMage.Value)
				{
					assignRole(rnd.Next(1, roleAmount + 1), PlayerController.instance);
					RepoRoles.Logger.LogInfo((object)"You got assigned a new random role because this one was disabled.");
					break;
				}
				RepoRoles.Logger.LogMessage((object)("Assigning role " + RepoRoles.customRoleNameMage.Value + "."));
				guiManager.isMage = true;
				guiManager.aviableMana = 8;
				guiManager.manaTicks = 0;
				ManaHelper.CreateUI();
				if ((Object)(object)RepoRoles.GUIinstance != (Object)null)
				{
					RepoRoles.GUIinstance.UpdateManaDisplay();
				}
				if ((double)num2 * 0.5 > 0.0)
				{
					setHealth(PlayerController.instance.playerSteamID, (int)((double)num * 0.5), (int)((double)num2 * 0.5));
				}
				else
				{
					setHealth(PlayerController.instance.playerSteamID, (int)((double)num * 0.5), num2);
				}
				RepoRoles.GUIinstance.text = RepoRoles.customRoleNameMage.Value;
				RepoRoles.GUIinstance.color = new Color(0f, 0.384f, 1f);
				RepoRoles.GUIinstance.descText = RepoRoles.customRoleDecMage.Value + "\nPress " + ((object)RepoRoles.showSpellsKey.Value).ToString() + " to see all your spells and press " + ((object)RepoRoles.toggleKey.Value).ToString() + " to continue";
				RepoRoles.GUIinstance.descColor = new Color(0f, 0.384f, 1f);
				break;
			case 8:
				if (!RepoRoles.enableReaper.Value)
				{
					assignRole(rnd.Next(1, roleAmount + 1), PlayerController.instance);
					RepoRoles.Logger.LogInfo((object)"You got assigned a new random role because this one was disabled.");
					break;
				}
				guiManager.ResetManaUI();
				RepoRoles.Logger.LogInfo((object)"Resetting Mana UI.");
				RepoRoles.Logger.LogMessage((object)("Assigning role " + RepoRoles.customRoleNameReaper.Value + "."));
				harmonyPatcher.PatchAll(typeof(ReaperPatch));
				setReaperStatus(PlayerController.instance.playerSteamID, isReaper: true);
				setHealth(PlayerController.instance.playerSteamID, (int)((double)num * 1.5), (int)((double)num2 * 1.5));
				RepoRoles.GUIinstance.text = RepoRoles.customRoleNameReaper.Value;
				RepoRoles.GUIinstance.color = new Color(0.141f, 0.6f, 0.502f);
				RepoRoles.GUIinstance.descText = RepoRoles.customRoleDecReaper.Value + "\nPress " + ((object)RepoRoles.toggleKey.Value).ToString() + " to continue";
				RepoRoles.GUIinstance.descColor = new Color(0.141f, 0.6f, 0.502f);
				break;
			case 9:
				if (!RepoRoles.enableScout.Value)
				{
					assignRole(rnd.Next(1, roleAmount + 1), PlayerController.instance);
					RepoRoles.Logger.LogInfo((object)"You got assigned a new random role because this one was disabled.");
					break;
				}
				guiManager.ResetManaUI();
				RepoRoles.Logger.LogInfo((object)"Resetting Mana UI.");
				RepoRoles.Logger.LogMessage((object)("Assigning role " + RepoRoles.customRoleNameScout.Value + "."));
				isScout = true;
				__instance.EnergyStart = energyStart * 2f;
				__instance.EnergyCurrent = energyCurrent * 2f;
				__instance.sprintRechargeAmount *= 2f;
				RepoRoles.GUIinstance.text = RepoRoles.customRoleNameScout.Value;
				RepoRoles.GUIinstance.color = new Color(0.902f, 0.733f, 0.11f);
				RepoRoles.GUIinstance.descText = RepoRoles.customRoleDecScout.Value.Replace("[G]", "[" + ((object)RepoRoles.scoutKey.Value).ToString() + "]") + "\nPress " + ((object)RepoRoles.toggleKey.Value).ToString() + " to continue";
				RepoRoles.GUIinstance.descColor = new Color(0.902f, 0.733f, 0.11f);
				break;
			case 10:
				if (!RepoRoles.enableRegular.Value)
				{
					assignRole(rnd.Next(1, roleAmount + 1), PlayerController.instance);
					RepoRoles.Logger.LogInfo((object)"You got assigned a new random role because this one was disabled.");
					break;
				}
				guiManager.ResetManaUI();
				RepoRoles.Logger.LogInfo((object)"Resetting Mana UI.");
				RepoRoles.Logger.LogMessage((object)("Assigning role " + RepoRoles.customRoleNameRegular.Value + "."));
				__instance.CrouchSpeed = crouchSpeed;
				__instance.MoveSpeed = moveSpeed;
				__instance.SprintSpeed = sprintSpeed;
				__instance.JumpForce = jumpForce;
				__instance.EnergyStart = energyStart;
				__instance.EnergyCurrent = energyCurrent;
				RepoRoles.GUIinstance.text = RepoRoles.customRoleNameRegular.Value;
				RepoRoles.GUIinstance.color = Color.white;
				RepoRoles.GUIinstance.descText = RepoRoles.customRoleDecRegular.Value + "\nPress " + ((object)RepoRoles.toggleKey.Value).ToString() + " to continue";
				RepoRoles.GUIinstance.descColor = Color.white;
				break;
			}
		}
	}
	[HarmonyPatch(typeof(EnemyHealth))]
	internal static class EnemyHealthPatch
	{
		private static readonly Dictionary<int, float> processed = new Dictionary<int, float>();

		private const float processedExpiry = 3f;

		[HarmonyPrefix]
		[HarmonyPatch("Hurt")]
		public static void Hurt_Prefix(EnemyHealth __instance, int _damage, Vector3 _hurtDirection)
		{
			if (!SemiFunc.IsMultiplayer())
			{
				return;
			}
			if (processed.Count > 0)
			{
				float time = Time.time;
				List<int> list = new List<int>(processed.Keys);
				foreach (int item in list)
				{
					if (time - processed[item] > 3f)
					{
						processed.Remove(item);
					}
				}
			}
			if ((Object)(object)__instance == (Object)null || __instance.dead)
			{
				return;
			}
			int healthCurrent = __instance.healthCurrent;
			int num = healthCurrent - _damage;
			if (num > 0)
			{
				return;
			}
			PhotonView component = ((Component)__instance).GetComponent<PhotonView>();
			int num2 = (((Object)(object)component != (Object)null) ? component.ViewID : 0);
			if (num2 != 0 && processed.ContainsKey(num2))
			{
				return;
			}
			if (num2 != 0)
			{
				processed[num2] = Time.time;
			}
			string text = (((Object)(object)PlayerController.instance != (Object)null) ? PlayerController.instance.playerSteamID : string.Empty);
			if (PhotonNetwork.IsMasterClient)
			{
				string[] masterReapers = ReaperEventListener.GetMasterReapers();
				RepoRoles.Logger.LogInfo((object)$"[EnHlPch] Master detected lethal hit by {text} pv={num2}");
				if (masterReapers != null && masterReapers.Length != 0)
				{
					ReaperEvents.RaiseApplyBuffs(text, masterReapers);
				}
			}
			else
			{
				RepoRoles.Logger.LogInfo((object)$"[EnHlPch] Client detected lethal hit by {text} pv={num2}, requesting master");
				ReaperEvents.RaiseRequestApplyBuffs(text);
			}
		}

		[HarmonyPostfix]
		[HarmonyPatch("DeathImpulseRPC")]
		public static void DeathImpulseRPC_Postfix(EnemyHealth __instance)
		{
			if (SemiFunc.IsMultiplayer() || (Object)(object)__instance == (Object)null || !__instance.dead)
			{
				return;
			}
			string text = (((Object)(object)PlayerController.instance != (Object)null) ? PlayerController.instance.playerSteamID : string.Empty);
			RepoRoles.Logger.LogInfo((object)("[EnHlPch] Singleplayer enemy death detected by " + text));
			foreach (PlayerAvatar item in SemiFunc.PlayerGetAll())
			{
				if (!((Object)(object)item == (Object)null))
				{
					ReaperManager component = ((Component)item).GetComponent<ReaperManager>();
					if ((Object)(object)component != (Object)null && component.isReaper)
					{
						component.ApplyReaperStats(item);
						component.kills = 0;
						component.enemyDeathTimer = 50;
						RepoRoles.Logger.LogInfo((object)("[EnHlPch] Applied singleplayer buff to " + item.steamID));
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(PlayerAvatar))]
	internal static class PlayerAvatarPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Awake")]
		private static void Awake_Postfix(PlayerAvatar __instance)
		{
			if (!Object.op_Implicit((Object)(object)((Component)__instance).gameObject.GetComponent<ReaperManager>()))
			{
				((Component)__instance).gameObject.AddComponent<ReaperManager>();
				RepoRoles.Logger.LogInfo((object)("[PrArPch]: Added ReaperManager to avatar steamID=" + __instance.steamID + " pv=" + (((Object)(object)__instance.photonView != (Object)null) ? __instance.photonView.ViewID.ToString() : "null")));
			}
			else
			{
				RepoRoles.Logger.LogInfo((object)("[PrArPch]: avatar already has ReaperManager steamID=" + __instance.steamID + " pv=" + (((Object)(object)__instance.photonView != (Object)null) ? __instance.photonView.ViewID.ToString() : "null")));
			}
			ReaperEventListener.Ensure();
		}
	}
	internal class ReaperEventListener : MonoBehaviourPunCallbacks, IOnEventCallback
	{
		private static bool _created;

		private static readonly HashSet<string> masterReapers = new HashSet<string>();

		public static void Ensure()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			if (!_created)
			{
				_created = true;
				GameObject val = new GameObject("RepoRoles_ReaperEventListener");
				Object.DontDestroyOnLoad((Object)(object)val);
				val.AddComponent<ReaperEventListener>();
				RepoRoles.Logger.LogInfo((object)"ReaperEventListener created!");
			}
		}

		public static string[] GetMasterReapers()
		{
			lock (masterReapers)
			{
				string[] array = new string[masterReapers.Count];
				masterReapers.CopyTo(array);
				return array;
			}
		}

		private void OnEnable()
		{
			PhotonNetwork.AddCallbackTarget((object)this);
		}

		private void OnDisable()
		{
			PhotonNetwork.RemoveCallbackTarget((object)this);
		}

		public override void OnJoinedRoom()
		{
			lock (masterReapers)
			{
				masterReapers.Clear();
			}
			RepoRoles.Logger.LogInfo((object)"[RpEsLr] OnJoinedRoom: cleared master registry");
		}

		public override void OnLeftRoom()
		{
			lock (masterReapers)
			{
				masterReapers.Clear();
			}
			RepoRoles.Logger.LogInfo((object)"[RpEsLr] OnLeftRoom: cleared master registry");
		}

		public override void OnMasterClientSwitched(Player newMasterClient)
		{
			lock (masterReapers)
			{
				masterReapers.Clear();
			}
			RepoRoles.Logger.LogInfo((object)"[RpEsLr] OnMasterClientSwitched: cleared master registry (will repopulate by status events)");
		}

		public void OnEvent(EventData photonEvent)
		{
			if (photonEvent.Code == 151)
			{
				if (!(photonEvent.CustomData is object[] array) || array.Length < 2)
				{
					return;
				}
				string text = (array[0] as string) ?? string.Empty;
				bool flag = (bool)array[1];
				if (!PhotonNetwork.IsMasterClient)
				{
					return;
				}
				lock (masterReapers)
				{
					if (flag)
					{
						if (masterReapers.Add(text))
						{
							RepoRoles.Logger.LogInfo((object)("[RpEsLr] Master: Registered reaper " + text));
						}
					}
					else if (masterReapers.Remove(text))
					{
						RepoRoles.Logger.LogInfo((object)("[RpEsLr] Master: Unregistered reaper " + text));
					}
					return;
				}
			}
			if (photonEvent.Code == 152)
			{
				if (PhotonNetwork.IsMasterClient)
				{
					string text2 = ((photonEvent.CustomData is object[] array2 && array2.Length != 0) ? ((array2[0] as string) ?? string.Empty) : string.Empty);
					string[] array3;
					lock (masterReapers)
					{
						array3 = new string[masterReapers.Count];
						masterReapers.CopyTo(array3);
					}
					RepoRoles.Logger.LogInfo((object)$"[RpEsLr] Master: received EV_REQUEST_REAPER_BUFFS for killer={text2} reapersCount={array3.Length}");
					if (array3.Length != 0)
					{
						ReaperEvents.RaiseApplyBuffs(text2, array3);
					}
					else
					{
						RepoRoles.Logger.LogInfo((object)"[RpEsLr] Master: no reapers registered - nothing to broadcast");
					}
				}
			}
			else
			{
				if (photonEvent.Code != 150)
				{
					return;
				}
				try
				{
					object[] array4 = photonEvent.CustomData as object[];
					string arg = (((array4 != null) ? array4[0] : null) as string) ?? string.Empty;
					string[] array5 = (((array4 != null) ? array4[1] : null) as string[]) ?? new string[0];
					RepoRoles.Logger.LogInfo((object)$"[RpEsLr] giveReaperStatsRPC: received via event from killer={arg} reapersCount={array5.Length}");
					string[] array6 = array5;
					foreach (string text3 in array6)
					{
						PlayerAvatar val = SemiFunc.PlayerAvatarGetFromSteamID(text3);
						if ((Object)(object)val == (Object)null)
						{
							RepoRoles.Logger.LogWarning((object)("[RpEsLr] giveReaperStatsRPC: cannot find avatar for steamID=" + text3 + " on this client"));
							continue;
						}
						ReaperManager component = ((Component)val).GetComponent<ReaperManager>();
						if ((Object)(object)component == (Object)null)
						{
							RepoRoles.Logger.LogWarning((object)("[RpEsLr] giveReaperStatsRPC: avatar " + text3 + " has no ReaperManager on this client"));
							continue;
						}
						int num = (int)AccessTools.Field(typeof(PlayerHealth), "health").GetValue(val.playerHealth);
						if (num <= 0)
						{
							RepoRoles.Logger.LogInfo((object)$"[RpEsLr] giveReaperStatsRPC: avatar {text3} is dead (health={num}) - skipping");
							continue;
						}
						if (component.enemyDeathTimer > 0)
						{
							RepoRoles.Logger.LogInfo((object)$"[RpEsLr] giveReaperStatsRPC: avatar {text3} in cooldown (enemyDeathTimer={component.enemyDeathTimer}) - skipping");
							continue;
						}
						int num2 = (int)AccessTools.Field(typeof(PlayerHealth), "maxHealth").GetValue(val.playerHealth);
						int num3 = num;
						int num4 = num2 + 5;
						AccessTools.Field(typeof(PlayerHealth), "maxHealth").SetValue(val.playerHealth, num4);
						if (num3 + 30 > num4)
						{
							val.playerHealth.Heal(num4 - num3, true);
						}
						else
						{
							val.playerHealth.Heal(30, true);
						}
						component.kills = 0;
						component.enemyDeathTimer = 50;
						RepoRoles.Logger.LogInfo((object)string.Format("[RpEsLr] giveReaperStatsRPC: Applied buff to {0} (health {1} -> {2}, max {3} -> {4})", text3, num3, (int)AccessTools.Field(typeof(PlayerHealth), "health").GetValue(val.playerHealth), num2, num4));
					}
				}
				catch (Exception arg2)
				{
					RepoRoles.Logger.LogError((object)$"[RpEsLr]: Event handler exception: {arg2}");
				}
			}
		}
	}
	internal static class ReaperEvents
	{
		public const byte EV_APPLY_REAPER_BUFFS = 150;

		public const byte EV_REAPER_STATUS_CHANGE = 151;

		public const byte EV_REQUEST_REAPER_BUFFS = 152;

		public static void RaiseApplyBuffs(string killerSteamID, string[] reaperSteamIDs)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: 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_0070: Expected O, but got Unknown
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			if (reaperSteamIDs != null && reaperSteamIDs.Length != 0)
			{
				if (!PhotonNetwork.IsConnected || !PhotonNetwork.InRoom)
				{
					RepoRoles.Logger.LogWarning((object)("[RpEs] RaiseApplyBuffs: Not in room - cannot raise event (killer='" + killerSteamID + "')"));
					return;
				}
				object[] array = new object[2]
				{
					killerSteamID ?? string.Empty,
					reaperSteamIDs
				};
				RaiseEventOptions val = new RaiseEventOptions
				{
					Receivers = (ReceiverGroup)1
				};
				SendOptions val2 = default(SendOptions);
				((SendOptions)(ref val2)).Reliability = true;
				SendOptions val3 = val2;
				PhotonNetwork.RaiseEvent((byte)150, (object)array, val, val3);
				RepoRoles.Logger.LogInfo((object)string.Format("[RpEs] Master: Raised EV_APPLY_REAPER_BUFFS for {0} reapers (killer='{1}')", reaperSteamIDs.Length, killerSteamID ?? "unknown"));
			}
		}

		public static void RaiseReaperStatusChange(string steamID, bool isReaper)
		{
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			if (!string.IsNullOrEmpty(steamID))
			{
				if (!PhotonNetwork.IsConnected || !PhotonNetwork.InRoom)
				{
					RepoRoles.Logger.LogWarning((object)$"[RpEs] RaiseReaperStatusChange: Not in room - skipping for {steamID} -> {isReaper}");
					return;
				}
				object[] array = new object[2] { steamID, isReaper };
				RaiseEventOptions val = new RaiseEventOptions
				{
					Receivers = (ReceiverGroup)2
				};
				SendOptions val2 = default(SendOptions);
				((SendOptions)(ref val2)).Reliability = true;
				SendOptions val3 = val2;
				PhotonNetwork.RaiseEvent((byte)151, (object)array, val, val3);
				RepoRoles.Logger.LogInfo((object)$"[RpEs] Raised EV_REAPER_STATUS_CHANGE for {steamID} -> {isReaper}");
			}
		}

		public static void RaiseRequestApplyBuffs(string killerSteamID)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Expected O, but got Unknown
			//IL_005d: 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_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrEmpty(killerSteamID))
			{
				killerSteamID = string.Empty;
			}
			if (!PhotonNetwork.IsConnected || !PhotonNetwork.InRoom)
			{
				RepoRoles.Logger.LogWarning((object)("[RpEs] RaiseRequestApplyBuffs: Not in room - skipping request for killer=" + killerSteamID));
				return;
			}
			object[] array = new object[1] { killerSteamID };
			RaiseEventOptions val = new RaiseEventOptions
			{
				Receivers = (ReceiverGroup)2
			};
			SendOptions val2 = default(SendOptions);
			((SendOptions)(ref val2)).Reliability = true;
			SendOptions val3 = val2;
			PhotonNetwork.RaiseEvent((byte)152, (object)array, val, val3);
			RepoRoles.Logger.LogInfo((object)("[RpEs] Raised EV_REQUEST_REAPER_BUFFS for killer=" + killerSteamID));
		}
	}
	public class ReaperManager : MonoBehaviourPun
	{
		public bool isReaper;

		public int kills;

		public int enemyDeathTimer = 0;

		private void Start()
		{
			ReaperEventListener.Ensure();
		}

		private void OnDestroy()
		{
			try
			{
				if ((Object)(object)((MonoBehaviourPun)this).photonView != (Object)null && ((MonoBehaviourPun)this).photonView.IsMine && ((MonoBehaviourPun)this).photonView.ViewID != 0)
				{
					PhotonNetwork.RemoveRPCs(((MonoBehaviourPun)this).photonView);
				}
			}
			catch (Exception arg)
			{
				RepoRoles.Logger.LogWarning((object)$"[RpMr] OnDestroy: RemoveRPCs exception: {arg}");
			}
		}

		[PunRPC]
		public void setReaperStatusRPC(string steamID, bool isReaper)
		{
			if ((Object)(object)RunManager.instance == (Object)null || (Object)(object)RunManager.instance.levelCurrent == (Object)null)
			{
				RepoRoles.Logger.LogWarning((object)("[RpMr] setReaperStatusRPC: RunManager/level null - ignoring for " + steamID));
				return;
			}
			if (!RunManager.instance.levels.Contains(RunManager.instance.levelCurrent))
			{
				RepoRoles.Logger.LogInfo((object)("[RpMr] setReaperStatusRPC: not a runlevel - ignoring for " + steamID));
				return;
			}
			PlayerAvatar val = SemiFunc.PlayerAvatarGetFromSteamID(steamID);
			if ((Object)(object)val != (Object)null)
			{
				ReaperManager component = ((Component)val).GetComponent<ReaperManager>();
				if ((Object)(object)component != (Object)null && component.isReaper != isReaper)
				{
					RepoRoles.Logger.LogInfo((object)$"[RpMr] setReaperStatusRPC: received for {steamID}, setTo={isReaper}");
					component.isReaper = isReaper;
					RepoRoles.Logger.LogInfo((object)$"[RpMr] setReaperStatusRPC: Applied isReaper={isReaper} to avatar steamID={steamID}");
				}
			}
			if (PhotonNetwork.IsConnected && PhotonNetwork.InRoom)
			{
				ReaperEvents.RaiseReaperStatusChange(steamID, isReaper);
			}
			else
			{
				RepoRoles.Logger.LogWarning((object)("[RpMr] setReaperStatusRPC: Not in room/connected - not notifying master for " + steamID));
			}
		}

		public void OnEnemyKilled(PlayerAvatar killerAvatar)
		{
			if ((Object)(object)killerAvatar == (Object)null)
			{
				return;
			}
			string steamID = killerAvatar.steamID;
			if (PhotonNetwork.IsMasterClient)
			{
				string[] masterReapers = ReaperEventListener.GetMasterReapers();
				RepoRoles.Logger.LogInfo((object)$"[RpMr] Master local kill: broadcasting buffs for {masterReapers.Length} reapers (killer={steamID})");
				if (masterReapers.Length != 0)
				{
					ReaperEvents.RaiseApplyBuffs(steamID, masterReapers);
				}
			}
			else
			{
				ReaperEvents.RaiseRequestApplyBuffs(steamID);
				RepoRoles.Logger.LogInfo((object)("[RpMr] Client requested master to apply buffs for killer=" + steamID));
			}
		}

		internal void ApplyReaperStats(PlayerAvatar avatar)
		{
			if (!((Object)(object)avatar == (Object)null))
			{
				int num = (int)AccessTools.Field(typeof(PlayerHealth), "health").GetValue(avatar.playerHealth);
				int num2 = (int)AccessTools.Field(typeof(PlayerHealth), "maxHealth").GetValue(avatar.playerHealth);
				int num3 = num2 + 5;
				AccessTools.Field(typeof(PlayerHealth), "maxHealth").SetValue(avatar.playerHealth, num3);
				if (num + 30 > num3)
				{
					avatar.playerHealth.Heal(num3 - num, true);
				}
				else
				{
					avatar.playerHealth.Heal(30, true);
				}
				RepoRoles.Logger.LogInfo((object)string.Format("[RpMr] ApplyReaperStats: applied local buff to {0} (health {1} -> {2}, max {3} -> {4})", avatar.steamID, num, (int)AccessTools.Field(typeof(PlayerHealth), "health").GetValue(avatar.playerHealth), num2, num3));
			}
		}

		private void Update()
		{
			if (enemyDeathTimer > 0)
			{
				enemyDeathTimer--;
			}
		}
	}
	[HarmonyPatch(typeof(EnemyHealth))]
	internal static class ReaperPatch
	{
		[HarmonyPatch("Death")]
		[HarmonyPrefix]
		public static void PrefixMethod()
		{
			PlayerAvatar val = SemiFunc.PlayerAvatarGetFromSteamID(PlayerController.instance.playerSteamID);
			if (!((Object)(object)val == (Object)null))
			{
				ReaperManager component = ((Component)val).GetComponent<ReaperManager>();
				if ((Object)(object)component != (Object)null)
				{
					component.kills++;
				}
				if ((Object)(object)component != (Object)null)
				{
					component.OnEnemyKilled(val);
					return;
				}
				ReaperEvents.RaiseRequestApplyBuffs(val.steamID);
				RepoRoles.Logger.LogWarning((object)("[RpPch] PrefixMethod: killer had no ReaperManager, sent request for killer=" + val.steamID));
			}
		}
	}
	public class ReaperSyncManager : MonoBehaviourPunCallbacks
	{
		public override void OnPlayerEnteredRoom(Player newPlayer)
		{
			PlayerAvatar val = SemiFunc.PlayerAvatarGetFromSteamID(PlayerController.instance.playerSteamID);
			ReaperManager component = ((Component)val).GetComponent<ReaperManager>();
			if ((Object)(object)component != (Object)null && component.isReaper && SemiFunc.IsMasterClientOrSingleplayer())
			{
				RepoRoles.Logger.LogWarning((object)("Sending late-joiner Reaper status RPC to " + newPlayer.NickName));
				((MonoBehaviourPun)component).photonView.RPC("setReaperStatusRPC", newPlayer, new object[2]
				{
					PlayerController.instance.playerSteamID,
					true
				});
			}
		}
	}
	[HarmonyPatch(typeof(TruckScreenText))]
	internal static class Sender
	{
		private static bool hasRanOnce;

		public static ClassManager manager = new ClassManager();

		[HarmonyPatch("ArrowPointAtGoalLogic")]
		[HarmonyPrefix]
		private static void PrefixMethod()
		{
			if (!hasRanOnce && !SemiFunc.RunIsShop())
			{
				manager.assignRoleFromConfig(PlayerController.instance);
				RepoRoles.Logger.LogInfo((object)"Successfully rolled role!");
				hasRanOnce = true;
			}
		}

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		private static void StartPrefix()
		{
			hasRanOnce = false;
		}
	}
}
namespace R.E.P.O.Roles.patches
{
	public class guiManager : MonoBehaviour
	{
		private bool lastManaPosition = true;

		public static bool showGUI = true;

		public static bool isMage = false;

		private static bool showSpells = false;

		private bool isDead = false;

		public string text;

		public Color color = Color.white;

		public string descText;

		public Color descColor = Color.white;

		private Texture2D _backgroundTexture;

		public static Texture2D manaTexture;

		public static Font customFont;

		private static AssetBundle fontBundle;

		public static int aviableMana = 0;

		public static int manaRegenRate = 0;

		public int speedTicker = 0;

		public static int manaTicks = 0;

		public bool speedActive;

		private float multiSpeed = 1.4f;

		private float crouchSpeedBefore;

		private float moveSpeedBefore;

		private float sprintSpeedBefore;

		private int overchargeMulti = 1;

		private bool isOvercharged = false;

		private int overchargeTicker = 0;

		private bool jumpActive = false;

		private float jumpOriginal;

		private int jumpTicker = 0;

		private int neededJumpTicker = 1800;

		private int neededSpeedTicker = 1800;

		private int manaUsageTicker = 0;

		private bool showManaUsage = false;

		private Texture2D textureRunner;

		private string manaUsageText = "Used x (- y Mana)";

		private bool fontLoaded = false;

		private bool RunnerTextureLoaded = false;

		private int passiveTankRegenTicker = 0;

		public static AssetBundle LoadAssetBundle(string name)
		{
			AssetBundle val = null;
			string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), name);
			return AssetBundle.LoadFromFile(text);
		}

		public static Texture2D LoadBottleTextureFromFile()
		{
			AssetBundle val = LoadAssetBundle("REPORoles_assets1");
			Texture2D result = val.LoadAsset<Texture2D>("emptyBottle.png");
			val.Unload(false);
			return result;
		}

		public static Texture2D LoadFullBottleTextureFromFile()
		{
			AssetBundle val = LoadAssetBundle("REPORoles_assets1");
			Texture2D result = val.LoadAsset<Texture2D>("filledBottle.png");
			val.Unload(false);
			return result;
		}

		public static Texture2D LoadTextureByName(string bundleName, string assetName)
		{
			AssetBundle val = LoadAssetBundle(bundleName);
			Texture2D result = val.LoadAsset<Texture2D>(assetName);
			val.Unload(false);
			return result;
		}

		public static void loadFont()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Expected O, but got Unknown
			if ((Object)fontBundle == (Object)null)
			{
				fontBundle = LoadAssetBundle("REPORoles_assets1");
				customFont = fontBundle.LoadAsset<Font>("font.ttf");
			}
			if ((Object)fontBundle == (Object)null)
			{
				RepoRoles.Logger.LogError((object)"Missing Assets: Put the assets file next to the dll in your plugins folder. If this does not fix it contact us on our discord (see thunderstore description or README)");
			}
			fontBundle.Unload(false);
		}

		private void Start()
		{
			_backgroundTexture = LoadBottleTextureFromFile();
			_backgroundTexture.Apply();
			manaTexture = LoadFullBottleTextureFromFile();
			manaTexture.Apply();
		}

		private void OnGUI()
		{
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Expected O, but got Unknown
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0237: Expected O, but got Unknown
			//IL_025b: 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: Expected O, but got Unknown
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_030d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0331: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_037f: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			//IL_045a: Expected O, but got Unknown
			//IL_047f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0485: Expected O, but got Unknown
			//IL_04e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f0: Expected O, but got Unknown
			//IL_0522: Unknown result type (might be due to invalid IL or missing references)
			//IL_0545: Unknown result type (might be due to invalid IL or missing references)
			//IL_054c: Expected O, but got Unknown
			//IL_0553: Unknown result type (might be due to invalid IL or missing references)
			//IL_058e: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05da: Unknown result type (might be due to invalid IL or missing references)
			//IL_0600: Unknown result type (might be due to invalid IL or missing references)
			//IL_0629: Unknown result type (might be due to invalid IL or missing references)
			//IL_0652: Unknown result type (might be due to invalid IL or missing references)
			//IL_067b: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0707: Unknown result type (might be due to invalid IL or missing references)
			//IL_0712: Expected O, but got Unknown
			//IL_073f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0766: Unknown result type (might be due to invalid IL or missing references)
			//IL_0787: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_07fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0823: Unknown result type (might be due to invalid IL or missing references)
			//IL_084a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0883: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a66: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a6b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a8a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a8f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ad2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ad7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0af7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0afc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b55: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b5c: Expected O, but got Unknown
			//IL_0b8f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b96: Expected O, but got Unknown
			//IL_0ba1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ba8: Expected O, but got Unknown
			//IL_0baf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bbc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bc3: Expected O, but got Unknown
			//IL_0bca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c5c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c68: Expected O, but got Unknown
			//IL_0cbd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cc9: Expected O, but got Unknown
			//IL_0d8d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dbb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0de9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e17: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e45: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e73: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ea1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ecf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ee0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ee7: Expected O, but got Unknown
			//IL_0efd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f0a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f11: Expected O, but got Unknown
			//IL_0f27: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f32: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f3e: Unknown result type (might be due to invalid IL or missing references)
			//IL_08bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_08f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_092b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0965: Unknown result type (might be due to invalid IL or missing references)
			//IL_099f: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a13: Unknown result type (might be due to invalid IL or missing references)
			float num = Screen.width / 2 - 100;
			float num2 = Screen.height / 2 - 60;
			if (!fontLoaded)
			{
				loadFont();
				fontLoaded = true;
			}
			if (SemiFunc.RunIsLevel() && !SemiFunc.RunIsShop() && showGUI)
			{
				GUIStyle val = new GUIStyle();
				val.fontSize = 60;
				val.fontStyle = (FontStyle)1;
				val.richText = true;
				val.normal.textColor = color;
				val.alignment = (TextAnchor)4;
				val.font = customFont;
				GUIStyle val2 = new GUIStyle(val);
				val2.normal.textColor = Color.black;
				val2.alignment = (TextAnchor)4;
				val2.font = customFont;
				float num3 = 2f;
				GUI.Label(new Rect(num - num3, num2, 200f, 50f), this.text, val2);
				GUI.Label(new Rect(num + num3, num2, 200f, 50f), this.text, val2);
				GUI.Label(new Rect(num, num2 - num3, 200f, 50f), this.text, val2);
				GUI.Label(new Rect(num, num2 + num3, 200f, 50f), this.text, val2);
				GUI.Label(new Rect(num - num3, num2 - num3, 200f, 50f), this.text, val2);
				GUI.Label(new Rect(num - num3, num2 + num3, 200f, 50f), this.text, val2);
				GUI.Label(new Rect(num + num3, num2 - num3, 200f, 50f), this.text, val2);
				GUI.Label(new Rect(num + num3, num2 + num3, 200f, 50f), this.text, val2);
				GUI.Label(new Rect(num, num2, 200f, 50f), this.text, val);
				float num4 = Screen.width / 2 - 100;
				float num5 = Screen.height / 2 + 40;
				GUIStyle val3 = new GUIStyle();
				val3.fontSize = 40;
				val3.fontStyle = (FontStyle)1;
				val3.richText = true;
				val3.normal.textColor = color;
				val3.alignment = (TextAnchor)4;
				val3.font = customFont;
				GUIStyle val4 = new GUIStyle(val3);
				val4.normal.textColor = Color.black;
				val4.alignment = (TextAnchor)4;
				val4.font = customFont;
				float num6 = 2f;
				GUI.Label(new Rect(num4 - num6, num5, 200f, 50f), descText, val4);
				GUI.Label(new Rect(num4 + num6, num5, 200f, 50f), descText, val4);
				GUI.Label(new Rect(num4, num5 - num6, 200f, 50f), descText, val4);
				GUI.Label(new Rect(num4, num5 + num6, 200f, 50f), descText, val4);
				GUI.Label(new Rect(num4 - num6, num5 - num6, 200f, 50f), descText, val4);
				GUI.Label(new Rect(num4 - num6, num5 + num6, 200f, 50f), descText, val4);
				GUI.Label(new Rect(num4 + num6, num5 - num6, 200f, 50f), descText, val4);
				GUI.Label(new Rect(num4 + num6, num5 + num6, 200f, 50f), descText, val4);
				GUI.Label(new Rect(num4, num5, 200f, 50f), descText, val3);
			}
			if (!isMage || !SemiFunc.RunIsLevel() || SemiFunc.RunIsShop() || (int)AccessTools.Field(typeof(PlayerHealth), "health").GetValue(PlayerAvatar.instance.playerHealth) <= 0)
			{
				return;
			}
			GUIStyle val5 = new GUIStyle();
			val5.alignment = (TextAnchor)1;
			val5.normal.background = manaTexture;
			val5.font = customFont;
			GUIStyle val6 = new GUIStyle();
			val6.alignment = (TextAnchor)1;
			val6.normal.background = _backgroundTexture;
			val6.font = customFont;
			if (showManaUsage && SemiFunc.RunIsLevel() && !SemiFunc.RunIsShop() && isMage)
			{
				int num7 = Screen.width / 2 - 100;
				int num8 = Screen.height - 125;
				GUIStyle val7 = new GUIStyle();
				val7.fontSize = 20;
				val7.fontStyle = (FontStyle)1;
				val7.richText = true;
				val7.normal.textColor = new Color(0f, 0.384f, 1f);
				val7.alignment = (TextAnchor)4;
				val7.font = customFont;
				GUIStyle val8 = new GUIStyle(val7);
				val8.normal.textColor = Color.black;
				val8.alignment = (TextAnchor)4;
				val8.font = customFont;
				float num9 = 1.5f;
				GUI.Label(new Rect((float)num7 - num9, (float)num8, 200f, 50f), manaUsageText, val8);
				GUI.Label(new Rect((float)num7 + num9, (float)num8, 200f, 50f), manaUsageText, val8);
				GUI.Label(new Rect((float)num7, (float)num8 - num9, 200f, 50f), manaUsageText, val8);
				GUI.Label(new Rect((float)num7, (float)num8 + num9, 200f, 50f), manaUsageText, val8);
				GUI.Label(new Rect((float)num7 - num9, (float)num8 - num9, 200f, 50f), manaUsageText, val8);
				GUI.Label(new Rect((float)num7 - num9, (float)num8 + num9, 200f, 50f), manaUsageText, val8);
				GUI.Label(new Rect((float)num7 + num9, (float)num8 - num9, 200f, 50f), manaUsageText, val8);
				GUI.Label(new Rect((float)num7 + num9, (float)num8 + num9, 200f, 50f), manaUsageText, val8);
				GUI.Label(new Rect((float)num7, (float)num8, 200f, 50f), manaUsageText, val7);
			}
			if (SemiFunc.RunIsLevel() && !SemiFunc.RunIsShop() && isMage && RepoRoles.mageTopManaBool)
			{
				if ((Object)ManaHelper.val == (Object)null)
				{
					ManaHelper.val = GameObject.Find("Energy");
				}
				GUI.Box(new Rect(num - 100f, 50f, 50f, 50f), GUIContent.none, val6);
				GUI.Box(new Rect(num - 50f, 50f, 50f, 50f), GUIContent.none, val6);
				GUI.Box(new Rect(num, 50f, 50f, 50f), GUIContent.none, val6);
				GUI.Box(new Rect(num + 50f, 50f, 50f, 50f), GUIContent.none, val6);
				GUI.Box(new Rect(num + 100f, 50f, 50f, 50f), GUIContent.none, val6);
				GUI.Box(new Rect(num + 150f, 50f, 50f, 50f), GUIContent.none, val6);
				GUI.Box(new Rect(num + 200f, 50f, 50f, 50f), GUIContent.none, val6);
				GUI.Box(new Rect(num + 250f, 50f, 50f, 50f), GUIContent.none, val6);
				if (aviableMana >= 1)
				{
					GUI.Box(new Rect(num - 100f, 50f, 50f, 50f), GUIContent.none, val5);
				}
				if (aviableMana >= 2)
				{
					GUI.Box(new Rect(num - 50f, 50f, 50f, 50f), GUIContent.none, val5);
				}
				if (aviableMana >= 3)
				{
					GUI.Box(new Rect(num, 50f, 50f, 50f), GUIContent.none, val5);
				}
				if (aviableMana >= 4)
				{
					GUI.Box(new Rect(num + 50f, 50f, 50f, 50f), GUIContent.none, val5);
				}
				if (aviableMana >= 5)
				{
					GUI.Box(new Rect(num + 100f, 50f, 50f, 50f), GUIContent.none, val5);
				}
				if (aviableMana >= 6)
				{
					GUI.Box(new Rect(num + 150f, 50f, 50f, 50f), GUIContent.none, val5);
				}
				if (aviableMana >= 7)
				{
					GUI.Box(new Rect(num + 200f, 50f, 50f, 50f), GUIContent.none, val5);
				}
				if (aviableMana >= 8)
				{
					GUI.Box(new Rect(num + 250f, 50f, 50f, 50f), GUIContent.none, val5);
				}
			}
			if (showSpells && SemiFunc.RunIsLevel() && !SemiFunc.RunIsShop())
			{
				string text = "SPELLS";
				string[] obj = new string[11]
				{
					"[", null, null, null, null, null, null, null, null, null,
					null
				};
				KeyCode value = RepoRoles.healKey.Value;
				obj[1] = ((object)(KeyCode)(ref value)).ToString();
				obj[2] = "] Heal yourself for 5 health (1 Mana)\n[";
				value = RepoRoles.staminaKey.Value;
				obj[3] = ((object)(KeyCode)(ref value)).ToString();
				obj[4] = "] Regenerate your stamina to full (3 Mana)\n[";
				value = RepoRoles.speedKey.Value;
				obj[5] = ((object)(KeyCode)(ref value)).ToString();
				obj[6] = "] Become faster for 30 seconds (2 Mana)\n[";
				value = RepoRoles.overchargeKey.Value;
				obj[7] = ((object)(KeyCode)(ref value)).ToString();
				obj[8] = "] Boost the effectivity of spells used in the next 20 seconds (3 Mana)\n[";
				value = RepoRoles.jumpKey.Value;
				obj[9] = ((object)(KeyCode)(ref value)).ToString();
				obj[10] = "] Jump higher for 30 seconds (2 Mana)";
				string text2 = string.Concat(obj);
				float num10 = (float)Screen.width * 0.5f;
				float num11 = (float)Screen.height * 0.5f;
				float num12 = Mathf.Clamp((float)Screen.width * 0.6f, 260f, 1200f);
				GUIStyle val9 = new GUIStyle();
				val9.richText = true;
				val9.wordWrap = true;
				val9.alignment = (TextAnchor)4;
				val9.font = customFont;
				val9.fontStyle = (FontStyle)1;
				GUIStyle val10 = new GUIStyle(val9);
				val10.wordWrap = true;
				GUIStyle val11 = new GUIStyle(val9);
				val11.normal.textColor = Color.black;
				GUIStyle val12 = new GUIStyle(val10);
				val12.normal.textColor = Color.black;
				int maxSize2 = Mathf.Clamp(Mathf.RoundToInt((float)Screen.height * 0.09f), 24, 120);
				int maxSize3 = Mathf.Clamp(Mathf.RoundToInt((float)Screen.height * 0.045f), 14, 72);
				int num13 = 16;
				int num14 = 12;
				float maxAllowedHeight2 = (float)Screen.height - 60f;
				int num15 = GetFittingFontSize(text, val9, num12, maxSize2, num13, maxAllowedHeight2);
				num15 = (val11.fontSize = (val9.fontSize = Mathf.Max(num13, num15 + 4)));
				float num18 = val9.CalcHeight(new GUIContent(text), num12);
				float maxAllowedHeight3 = Mathf.Max(60f, (float)Screen.height - num18 - 80f);
				int num19 = GetFittingFontSize(text2, val10, num12, maxSize3, num14, maxAllowedHeight3);
				num19 = (val10.fontSize = Mathf.Max(num14, num19 + 4));
				val12.fontSize = num19;
				float num21 = val10.CalcHeight(new GUIContent(text2), num12);
				float num22 = Mathf.Clamp(Mathf.RoundToInt((float)num15 * 0.25f), 4, 14);
				float num23 = num18 + num22 + num21;
				Rect val13 = default(Rect);
				((Rect)(ref val13))..ctor(num10 - num12 * 0.5f, num11 - num23 * 0.5f, num12, num23);
				Rect val14 = default(Rect);
				((Rect)(ref val14))..ctor(((Rect)(ref val13)).x, ((Rect)(ref val13)).y, ((Rect)(ref val13)).width, num18);
				Rect val15 = default(Rect);
				((Rect)(ref val15))..ctor(((Rect)(ref val13)).x, ((Rect)(ref val13)).y + num18 + num22, ((Rect)(ref val13)).width, num21);
				float num24 = Mathf.Clamp((float)Screen.height * 0.0025f, 1f, 3f);
				GUI.Label(new Rect(((Rect)(ref val14)).x - num24, ((Rect)(ref val14)).y, ((Rect)(ref val14)).width, ((Rect)(ref val14)).height), text, val11);
				GUI.Label(new Rect(((Rect)(ref val14)).x + num24, ((Rect)(ref val14)).y, ((Rect)(ref val14)).width, ((Rect)(ref val14)).height), text, val11);
				GUI.Label(new Rect(((Rect)(ref val14)).x, ((Rect)(ref val14)).y - num24, ((Rect)(ref val14)).width, ((Rect)(ref val14)).height), text, val11);
				GUI.Label(new Rect(((Rect)(ref val14)).x, ((Rect)(ref val14)).y + num24, ((Rect)(ref val14)).width, ((Rect)(ref val14)).height), text, val11);
				GUI.Label(new Rect(((Rect)(ref val15)).x - num24, ((Rect)(ref val15)).y, ((Rect)(ref val15)).width, ((Rect)(ref val15)).height), text2, val12);
				GUI.Label(new Rect(((Rect)(ref val15)).x + num24, ((Rect)(ref val15)).y, ((Rect)(ref val15)).width, ((Rect)(ref val15)).height), text2, val12);
				GUI.Label(new Rect(((Rect)(ref val15)).x, ((Rect)(ref val15)).y - num24, ((Rect)(ref val15)).width, ((Rect)(ref val15)).height), text2, val12);
				GUI.Label(new Rect(((Rect)(ref val15)).x, ((Rect)(ref val15)).y + num24, ((Rect)(ref val15)).width, ((Rect)(ref val15)).height), text2, val12);
				GUIStyle val16 = new GUIStyle(val9);
				val16.normal.textColor = new Color(0f, 0.384f, 1f);
				GUIStyle val17 = new GUIStyle(val10);
				val17.normal.textColor = new Color(0f, 0.384f, 1f);
				GUI.Label(val14, text, val16);
				GUI.Label(val15, text2, val17);
			}
			static int GetFittingFontSize(string s, GUIStyle style, float width, int maxSize, int minSize, float maxAllowedHeight)
			{
				//IL_0010: Unknown result type (might be due to invalid IL or missing references)
				//IL_001b: Expected O, but got Unknown
				for (int num25 = maxSize; num25 >= minSize; num25--)
				{
					style.fontSize = num25;
					float num26 = style.CalcHeight(new GUIContent(s), width);
					if (num26 <= maxAllowedHeight)
					{
						return num25;
					}
				}
				return minSize;
			}
		}

		public void InitializeMageDisplay()
		{
			if (isMage)
			{
				if ((Object)(object)ManaHelper.val2 != (Object)null)
				{
					Object.Destroy((Object)(object)ManaHelper.val2);
					ManaHelper.val2 = null;
					ManaHelper.manaUI = null;
				}
				lastManaPosition = !RepoRoles.mageTopManaBool;
				UpdateManaDisplay();
				if (!RepoRoles.mageTopManaBool && (Object)(object)ManaHelper.manaUI != (Object)null)
				{
					ManaHelper.manaUI.SetMana(aviableMana, 8f);
				}
			}
		}

		public static void ResetManaUI()
		{
			if ((Object)(object)ManaHelper.val2 != (Object)null)
			{
				Object.Destroy((Object)(object)ManaHelper.val2);
				ManaHelper.val2 = null;
			}
			ManaHelper.manaUI = null;
		}

		public void UpdateManaDisplay()
		{
			if (isMage)
			{
				if ((Object)(object)ManaHelper.val2 == (Object)null)
				{
					ManaHelper.CreateUI();
				}
				if (RepoRoles.mageTopManaBool)
				{
					ManaHelper.ShowUI(show: false);
					return;
				}
				ManaHelper.ShowUI(show: true);
				ManaHelper.UpdateManaValue();
			}
		}

		private void updateMana()
		{
			if (isMage && !RepoRoles.mageTopManaBool)
			{
				ManaHelper.UpdateManaValue();
			}
		}

		private void Update()
		{
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0553: Unknown result type (might be due to invalid IL or missing references)
			//IL_0616: Unknown result type (might be due to invalid IL or missing references)
			if (isMage && lastManaPosition != RepoRoles.mageTopManaBool)
			{
				UpdateManaDisplay();
				lastManaPosition = RepoRoles.mageTopManaBool;
			}
			if (SemiFunc.RunIsLevel() && (int)AccessTools.Field(typeof(PlayerHealth), "health").GetValue(PlayerAvatar.instance.playerHealth) <= 0)
			{
				isDead = true;
			}
			if (!SemiFunc.RunIsLevel())
			{
				isMage = false;
				if (Sender.manager != null && (Object)PlayerAvatar.instance != (Object)null)
				{
					Sender.manager.setReaperStatus(PlayerController.instance.playerSteamID, isReaper: false);
				}
				ClassManager.isTank = false;
				isDead = false;
			}
			if (!RepoRoles.afterDeathNewRole)
			{
				isDead = false;
			}
			if (isDead && (int)AccessTools.Field(typeof(PlayerHealth), "health").GetValue(PlayerAvatar.instance.playerHealth) > 0 && RepoRoles.afterDeathNewRole)
			{
				Sender.manager.assignRoleFromConfig(PlayerController.instance);
				RepoRoles.Logger.LogInfo((object)"Assigning new role on respawn!");
				isDead = false;
			}
			if (Input.GetKeyDown(RepoRoles.toggleKey.Value) && !ChatManager.instance.chatActive)
			{
				showGUI = !showGUI;
			}
			if ((int)AccessTools.Field(typeof(PlayerHealth), "health").GetValue(PlayerAvatar.instance.playerHealth) > 0 && isMage && !ChatManager.instance.chatActive)
			{
				if (Input.GetKeyDown(RepoRoles.showSpellsKey.Value))
				{
					showSpells = !showSpells;
				}
				if (Input.GetKeyDown(RepoRoles.healKey.Value))
				{
					if ((int)AccessTools.Field(typeof(PlayerHealth), "health").GetValue(PlayerAvatar.instance.playerHealth) + 5 * overchargeMulti < (int)AccessTools.Field(typeof(PlayerHealth), "maxHealth").GetValue(PlayerAvatar.instance.playerHealth))
					{
						if (aviableMana >= 1)
						{
							PlayerAvatar.instance.playerHealth.Heal(5 * overchargeMulti, true);
							aviableMana--;
							showManaUsage = true;
							manaUsageTicker = 0;
							manaUsageText = "Used Heal (-1 Mana)";
							UpdateManaDisplay();
						}
					}
					else if ((int)AccessTools.Field(typeof(PlayerHealth), "health").GetValue(PlayerAvatar.instance.playerHealth) != (int)AccessTools.Field(typeof(PlayerHealth), "maxHealth").GetValue(PlayerAvatar.instance.playerHealth) && aviableMana >= 1)
					{
						PlayerAvatar.instance.playerHealth.Heal((int)AccessTools.Field(typeof(PlayerHealth), "maxHealth").GetValue(PlayerAvatar.instance.playerHealth) - (int)AccessTools.Field(typeof(PlayerHealth), "health").GetValue(PlayerAvatar.instance.playerHealth), true);
						aviableMana--;
						showManaUsage = true;
						manaUsageTicker = 0;
						manaUsageText = "Used Heal (-1 Mana)";
						UpdateManaDisplay();
					}
				}
				if (Input.GetKeyDown(RepoRoles.speedKey.Value) && !speedActive)
				{
					crouchSpeedBefore = PlayerController.instance.CrouchSpeed;
					moveSpeedBefore = PlayerController.instance.MoveSpeed;
					sprintSpeedBefore = PlayerController.instance.SprintSpeed;
					if (aviableMana >= 2)
					{
						speedTicker = 0;
						speedActive = true;
						PlayerController.instance.CrouchSpeed = crouchSpeedBefore * multiSpeed;
						PlayerController.instance.MoveSpeed = moveSpeedBefore * multiSpeed;
						PlayerController.instance.SprintSpeed = sprintSpeedBefore * multiSpeed;
						aviableMana -= 2;
						showManaUsage = true;
						manaUsageTicker = 0;
						manaUsageText = "Used Speed (-2 Mana)";
						UpdateManaDisplay();
						if (isOvercharged)
						{
							neededSpeedTicker = 3600;
						}
						else
						{
							neededSpeedTicker = 1800;
						}
					}
				}
				if (Input.GetKeyDown(RepoRoles.overchargeKey.Value) && !isOvercharged && aviableMana >= 3)
				{
					aviableMana -= 3;
					isOvercharged = true;
					overchargeMulti = 2;
					overchargeTicker = 0;
					showManaUsage = true;
					manaUsageTicker = 0;
					manaUsageText = "Used Overcharge (-3 Mana)";
					UpdateManaDisplay();
				}
				if (Input.GetKeyDown(RepoRoles.jumpKey.Value) && !jumpActive)
				{
					jumpOriginal = PlayerController.instance.JumpForce;
					if (aviableMana >= 2)
					{
						jumpTicker = 0;
						jumpActive = true;
						PlayerController.instance.JumpForce = jumpOriginal + 3f;
						aviableMana -= 2;
						showManaUsage = true;
						manaUsageTicker = 0;
						manaUsageText = "Used Jump Boost (-2 Mana)";
						UpdateManaDisplay();
						if (isOvercharged)
						{
							neededJumpTicker = 3600;
						}
						else
						{
							neededJumpTicker = 1800;
						}
					}
				}
				if (Input.GetKeyDown(RepoRoles.staminaKey.Value) && PlayerController.instance.EnergyCurrent < PlayerController.instance.EnergyStart && aviableMana >= 3)
				{
					PlayerController.instance.EnergyCurrent = PlayerController.instance.EnergyStart;
					aviableMana -= 3;
					showManaUsage = true;
					manaUsageTicker = 0;
					manaUsageText = "Used Stamina Refill (-3 Mana)";
					UpdateManaDisplay();
				}
			}
			if (speedActive && speedTicker >= neededSpeedTicker)
			{
				PlayerController.instance.CrouchSpeed = crouchSpeedBefore;
				PlayerController.instance.MoveSpeed = moveSpeedBefore;
				PlayerController.instance.SprintSpeed = sprintSpeedBefore;
				speedActive = false;
			}
			if (jumpActive && jumpTicker >= neededJumpTicker)
			{
				PlayerController.instance.JumpForce = jumpOriginal;
				jumpActive = false;
			}
			if (!isMage && (Object)(object)ManaHelper.val2 != (Object)null)
			{
				Object.Destroy((Object)(object)ManaHelper.val2);
				ManaHelper.val2 = null;
				ManaHelper.manaUI = null;
			}
		}

		private void setHealth(string steamID, int maxHealth, int health)
		{
			if (!SemiFunc.IsMultiplayer())
			{
				PlayerAvatar.instance.playerHealth.health = health;
				PlayerAvatar.instance.playerHealth.maxHealth = maxHealth;
				return;
			}
			PunManager.instance.photonView.RPC("setHealthRPC", (RpcTarget)0, new object[3] { steamID, maxHealth, health });
		}

		private void FixedUpdate()
		{
			if (passiveTankRegenTicker < 250 && ClassManager.isTank && SemiFunc.RunIsLevel() && !SemiFunc.RunIsShop() && !isDead)
			{
				passiveTankRegenTicker++;
			}
			if (passiveTankRegenTicker >= 250 && SemiFunc.RunIsLevel() && !SemiFunc.RunIsShop() && ClassManager.isTank)
			{
				passiveTankRegenTicker = 0;
				int num = (int)AccessTools.Field(typeof(PlayerHealth), "maxHealth").GetValue(PlayerAvatar.instance.playerHealth);
				int num2 = (int)AccessTools.Field(typeof(PlayerHealth), "health").GetValue(PlayerAvatar.instance.playerHealth);
				if (num2 < num)
				{
					setHealth(PlayerController.instance.playerSteamID, num, num2 + 1);
				}
			}
			if (overchargeTicker >= 1200)
			{
				isOvercharged = false;
				overchargeMulti = 1;
			}
			if (isOvercharged)
			{
				overchargeTicker++;
			}
			manaUsageTicker++;
			speedTicker++;
			jumpTicker++;
			if (manaUsageTicker >= 420)
			{
				showManaUsage = false;
			}
			if (aviableMana < 8)
			{
				manaTicks++;
			}
			if (manaTicks >= 1300 - manaRegenRate * 120 && isMage && aviableMana < 8)
			{
				aviableMana++;
				manaTicks = 0;
				UpdateManaDisplay();
			}
		}
	}
	public class HealthManager : MonoBehaviour
	{
		internal PhotonView photonView;

		private void Start()
		{
			photonView = ((Component)this).GetComponent<PhotonView>();
		}

		[PunRPC]
		internal void setHealthRPC(string steamID, int maxHealth, int health)
		{
			PlayerAvatar val = SemiFunc.PlayerAvatarGetFromSteamID(steamID);
			if ((Object)(object)val != (Object)null)
			{
				val.playerHealth.maxHealth = maxHealth;
				val.playerHealth.health = health;
			}
		}
	}
	public class ManaHelper : MonoBehaviour
	{
		public static GameObject val;

		public static GameObject val2;

		public static ManaUI manaUI;

		public static void CreateUI()
		{
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: 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)
			if ((Object)(object)val2 != (Object)null)
			{
				return;
			}
			ManaHelper.val = GameObject.Find("Energy");
			if ((Object)(object)ManaHelper.val == (Object)null)
			{
				RepoRoles.Logger.LogError((object)"Could not find base 'Energy' UI. Mana UI cannot be created.");
				return;
			}
			val2 = Object.Instantiate<GameObject>(ManaHelper.val, ManaHelper.val.transform.parent);
			if ((Object)(object)val2 == (Object)null)
			{
				RepoRoles.Logger.LogError((object)"Failed to instantiate Mana UI.");
				return;
			}
			((Object)val2).name = "Mana";
			Transform transform = val2.transform;
			transform.localPosition -= new Vector3(0f, 33f, 0f);
			RemoveProblematicComponents(val2);
			TextMeshProUGUI[] componentsInChildren = val2.GetComponentsInChildren<TextMeshProUGUI>(true);
			foreach (TextMeshProUGUI val in componentsInChildren)
			{
				if ((Object)(object)val != (Object)null)
				{
					((Graphic)val).color = new Color(0f, 0.384f, 1f);
				}
			}
			SetManaIcon(val2);
			manaUI = val2.AddComponent<ManaUI>();
			val2.SetActive(false);
			RepoRoles.Logger.LogInfo((object)"Mana UI created successfully");
		}

		private static void RemoveProblematicComponents(GameObject uiObject)
		{
			EnergyUI component = uiObject.GetComponent<EnergyUI>();
			if ((Object)(object)component != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)component);
			}
			SemiUI component2 = uiObject.GetComponent<SemiUI>();
			if ((Object)(object)component2 != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)component2);
			}
		}

		private static void SetManaIcon(GameObject uiObject)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			Texture2D manaTexture = guiManager.manaTexture;
			if (!((Object)(object)manaTexture == (Object)null))
			{
				Sprite sprite = Sprite.Create(manaTexture, new Rect(0f, 0f, (float)((Texture)manaTexture).width, (float)((Texture)manaTexture).height), new Vector2(0.5f, 0.5f));
				Image componentInChildren = uiObject.GetComponentInChildren<Image>(true);
				if ((Object)(object)componentInChildren != (Object)null)
				{
					componentInChildren.sprite = sprite;
					((Graphic)componentInChildren).color = Color.white;
				}
			}
		}

		public static void ShowUI(bool show)
		{
			if ((Object)(object)val2 != (Object)null)
			{
				val2.SetActive(show);
			}
		}

		public static void UpdateManaValue()
		{
			if ((Object)(object)manaUI != (Object)null && guiManager.isMage)
			{
				manaUI.SetMana(guiManager.aviableMana, 8f);
			}
		}
	}
	public class ManaUI : MonoBehaviour
	{
		public TextMeshProUGUI textMana;

		public TextMeshProUGUI textManaMax;

		public static ManaUI instance;

		private RectTransform rectTransform;

		private Image manaImage;

		private void Start()
		{
			instance = this;
			rectTransform = ((Component)this).GetComponent<RectTransform>();
			textMana = ((Component)this).GetComponentInChildren<TextMeshProUGUI>();
			Transform val = ((Component)this).transform.Find("EnergyMax");
			if ((Object)(object)val != (Object)null)
			{
				textManaMax = ((Component)val).GetComponent<TextMeshProUGUI>();
			}
			else
			{
				TextMeshProUGUI[] componentsInChildren = ((Component)this).GetComponentsInChildren<TextMeshProUGUI>();
				if (componentsInChildren.Length > 1)
				{
					textManaMax = componentsInChildren[1];
				}
			}
			manaImage = ((Component)this).GetComponentInChildren<Image>();
			if (guiManager.isMage)
			{
				SetMana(guiManager.aviableMana, 8f);
			}
			RepoRoles.Logger.LogInfo((object)"ManaUI initialized successfully");
		}

		private void Update()
		{
			if (guiManager.isMage && (Object)(object)textMana != (Object)null)
			{
				((TMP_Text)textMana).text = Mathf.Ceil((float)guiManager.aviableMana).ToString();
			}
		}

		public void SetMana(float mana, float maxMana)
		{
			if ((Object)(object)textMana == (Object)null || (Object)(object)textManaMax == (Object)null)
			{
				textMana = ((Component)this).GetComponentInChildren<TextMeshProUGUI>();
				Transform val = ((Component)this).transform.Find("EnergyMax");
				if ((Object)(object)val != (Object)null)
				{
					textManaMax = ((Component)val).GetComponent<TextMeshProUGUI>();
				}
			}
			if ((Object)(object)textMana != (Object)null)
			{
				((TMP_Text)textMana).text = Mathf.Ceil(mana).ToString();
			}
			if ((Object)(object)textManaMax != (Object)null)
			{
				((TMP_Text)textManaMax).text = $"<b>/</b>{Mathf.Ceil(maxMana)}";
			}
		}
	}
	[HarmonyPatch(typeof(ShopManager))]
	public static class ShopManagerPatch
	{
		[HarmonyPatch("GetAllItemsFromStatsManager")]
		[HarmonyPostfix]
		private static void GetAllItemsFromStatsManagerPostfix(ShopManager __instance)
		{
			try
			{
				if (!SemiFunc.IsMultiplayer() || SemiFunc.IsMasterClientOrSingleplayer())
				{
					RepoRoles.Logger.LogInfo((object)$"ShopManagerPatch: Filtering upgrades (Master: {SemiFunc.IsMasterClientOrSingleplayer()})");
					List<Item> allValidUpgrades = GetAllValidUpgrades(__instance);
					FilterAndMaintainUpgradeCount(__instance.potentialItemUpgrades, allValidUpgrades);
					__instance.potentialItems.RemoveAll((Item item) => (Object)(object)item != (Object)null && item.itemName != null && IsDisabledUpgrade(item));
				}
			}
			catch (Exception arg)
			{
				RepoRoles.Logger.LogError((object)$"Error in ShopManager patch: {arg}");
			}
		}

		private static List<Item> GetAllValidUpgrades(ShopManager shopManager)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Invalid comparison between Unknown and I4
			List<Item> list = new List<Item>();
			foreach (Item item in shopManager.potentialItems.Concat(shopManager.potentialItemUpgrades))
			{
				if (!((Object)(object)item == (Object)null) && item.itemName != null && (int)item.itemType == 3 && !IsDisabledUpgrade(item))
				{
					list.Add(item);
				}
			}
			return list.Distinct().ToList();
		}

		private static void FilterAndMaintainUpgradeCount(List<Item> upgradeList, List<Item> validUpgradesPool)
		{
			if (upgradeList == null)
			{
				return;
			}
			List<Item> list = new List<Item>();
			foreach (Item upgrade in upgradeList)
			{
				if ((Object)(object)upgrade == (Object)null || upgrade.itemName == null)
				{
					list.Add(upgrade);
				}
				else if (IsDisabledUpgrade(upgrade))
				{
					if (validUpgradesPool.Count > 0)
					{
						int index = Random.Range(0, validUpgradesPool.Count);
						list.Add(validUpgradesPool[index]);
						RepoRoles.Logger.LogInfo((object)("Replaced " + upgrade.itemName + " with " + validUpgradesPool[index].itemName));
					}
				}
				else
				{
					list.Add(upgrade);
				}
			}
			upgradeList.Clear();
			upgradeList.AddRange(list);
		}

		private static bool IsDisabledUpgrade(Item item)
		{
			if ((Object)(object)item == (Object)null || item.itemName == null)
			{
				return false;
			}
			bool flag = item.itemName.Contains("Mana Regeneration Upgrade");
			bool flag2 = item.itemName.Contains("Scout Cooldown Upgrade");
			if (!flag && !flag2)
			{
				return false;
			}
			if (!RepoRoles.enableRoleUpgrades.Value)
			{
				return true;
			}
			if (flag && !RepoRoles.enableMage.Value)
			{
				return true;
			}
			if (flag2 && !RepoRoles.enableScout.Value)
			{
				return true;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(StatsManager))]
	internal static class StatsManagerPatch
	{
		[HarmonyPrefix]
		[HarmonyPatch("Start")]
		private static void StatsPrefix(StatsManager __instance)
		{
			__instance.dictionaryOfDictionaries.Add("playerUpgradeManaRegeneration", new Dictionary<string, int>());
			__instance.dictionaryOfDictionaries.Add("playerUpgradeScoutCooldownReduction", new Dictionary<string, int>());
		}
	}
	public class StrengthManager : MonoBehaviour
	{
		internal PhotonView photonView;

		private void Start()
		{
			photonView = ((Component)this).GetComponent<PhotonView>();
		}

		[PunRPC]
		internal void setStrengthRPC(string steamID, float newStrength)
		{
			PlayerAvatar val = SemiFunc.PlayerAvatarGetFromSteamID(steamID);
			if ((Object)(object)val != (Object)null)
			{
				val.physGrabber.grabStrength = newStrength;
			}
		}
	}
	public class Upgrader : MonoBehaviour
	{
		public ItemToggle _itemToggle;

		private void Start()
		{
			_itemToggle = ((Component)this).GetComponent<ItemToggle>();
		}

		public static void UpdateStat(int amount, string steamId, string stat)
		{
			Dictionary<string, int> dictionary = StatsManager.instance.dictionaryOfDictionaries[stat];
			if (!dictionary.ContainsKey(steamId))
			{
				dictionary[steamId] = 0;
			}
			dictionary[steamId] += amount;
		}

		public static int GetStat(string steamId, string upgradeName)
		{
			Dictionary<string, int> dictionary = StatsManager.instance.dictionaryOfDictionaries[upgradeName];
			int value;
			return dictionary.TryGetValue(steamId, out value) ? value : 0;
		}

		public void upgradeManaRegen()
		{
			string steamId = SemiFunc.PlayerGetSteamID(SemiFunc.PlayerAvatarGetFromPhotonID(_itemToggle.playerTogglePhotonID));
			RepoRoles.Logger.LogInfo((object)("Your Mana Regen before: " + GetStat(steamId, "playerUpgradeManaRegeneration")));
			UpdateStat(1, steamId, "playerUpgradeManaRegeneration");
			RepoRoles.Update_ManaRegeneration();
			RepoRoles.Logger.LogInfo((object)("Your Mana Regen after: " + GetStat(steamId, "playerUpgradeManaRegeneration")));
		}

		public void upgradeScoutCooldown()
		{
			string steamId = SemiFunc.PlayerGetSteamID(SemiFunc.PlayerAvatarGetFromPhotonID(_itemToggle.playerTogglePhotonID));
			RepoRoles.Logger.LogInfo((object)("Your Scout Cooldown Upgrades before: " + GetStat(steamId, "playerUpgradeScoutCooldownReduction")));
			UpdateStat(1, steamId, "playerUpgradeScoutCooldownReduction");
			RepoRoles.Update_ScoutCooldown();
			RepoRoles.Logger.LogInfo((object)("Your Scout Cooldown Upgrades after: " + GetStat(steamId, "playerUpgradeScoutCooldownReduction")));
		}
	}
}
namespace Repo_Roles
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "R3Labs.Repo_Roles.Classic";

		public const string PLUGIN_NAME = "REPO Roles Classic";

		public const string PLUGIN_VERSION = "2.2.2";
	}
	[HarmonyPatch(typeof(PunManager))]
	internal static class PunManagerPatch
	{
		[HarmonyPostfix]
		[HarmonyPatch("Start")]
		private static void Start_Postfix(PunManager __instance)
		{
			if ((Object)(object)ComponentHolderProtocol.GetComponent<StrengthManager>((Object)(object)__instance) == (Object)null)
			{
				ComponentHolderProtocol.AddComponent<StrengthManager>((Object)(object)__instance);
			}
			if ((Object)(object)ComponentHolderProtocol.GetComponent<HealthManager>((Object)(object)__instance) == (Object)null)
			{
				ComponentHolderProtocol.AddComponent<HealthManager>((Object)(object)__instance);
			}
			if ((Object)(object)ComponentHolderProtocol.GetComponent<ScoutMarker>((Object)(object)__instance) == (Object)null)
			{
				ComponentHolderProtocol.AddComponent<ScoutMarker>((Object)(object)__instance);
			}
		}
	}
	[BepInPlugin("R3Labs.Repo_Roles.Classic", "REPO Roles Classic", "2.2.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class RepoRoles : BaseUnityPlugin
	{
		public readonly Harmony harmony = new Harmony("Repo_Roles");

		public static Font newFont;

		public static guiManager GUIinstance;

		public static ConfigEntry<KeyCode> toggleKey;

		public static ConfigEntry<KeyCode> showSpellsKey;

		public static ConfigEntry<KeyCode> healKey;

		public static ConfigEntry<KeyCode> speedKey;

		public static ConfigEntry<KeyCode> overchargeKey;

		public static ConfigEntry<KeyCode> jumpKey;

		public static ConfigEntry<KeyCode> staminaKey;

		public static ConfigEntry<KeyCode> scoutKey;

		public static ConfigEntry<string> customRoleNameRunner;

		public static ConfigEntry<string> customRoleNameTank;

		public static ConfigEntry<string> customRoleNameGambler;

		public static ConfigEntry<string> customRoleNameStrongman;

		public static ConfigEntry<string> customRoleNameRL;

		public static ConfigEntry<string> customRoleNameAthletic;

		public static ConfigEntry<string> customRoleNameMage;

		public static ConfigEntry<string> customRoleNameReaper;

		public static ConfigEntry<string> customRoleNameScout;

		public static ConfigEntry<string> customRoleNameRegular;

		public static ConfigEntry<string> customRoleDecRunner;

		public static ConfigEntry<string> customRoleDecTank;

		public static ConfigEntry<string> customRoleDecGambler;

		public static ConfigEntry<string> customRoleDecStrongman;

		public static ConfigEntry<string> customRoleDecRL;

		public static ConfigEntry<string> customRoleDecAthletic;

		public static ConfigEntry<string> customRoleDecMage;

		public static ConfigEntry<string> customRoleDecReaper;

		public static ConfigEntry<string> customRoleDecScout;

		public static ConfigEntry<string> customRoleDecRegular;

		public static ConfigEntry<string> savedRole;

		public static ConfigEntry<bool> enableRoleUpgrades;

		public static ConfigEntry<bool> assignRoleAfterRevive;

		public static ConfigEntry<bool> mageTopManaConf;

		public static ConfigEntry<bool> showGUIAtStart;

		public ConfigDefinition showGUIAtStartDef = new ConfigDefinition("GUI", "Show GUI when being assigned a role");

		public ConfigDefinition mageTopManaDef = new ConfigDefinition("Role", "Place where mana is shown");

		public ConfigDefinition def = new ConfigDefinition("GUI", "GUI Toggle Key");

		public ConfigDefinition scoutButtonDef = new ConfigDefinition("GUI", "Activate Scout Ability");

		public ConfigDefinition customRoleNameRunnerDef = new ConfigDefinition("Role Names", "Runner Name");

		public ConfigDefinition customRoleNameTankDef = new ConfigDefinition("Role Names", "Tank Name");

		public ConfigDefinition customRoleNameGamblerDef = new ConfigDefinition("Role Names", "Gambler Name");

		public ConfigDefinition customRoleNameStrongmanDef = new ConfigDefinition("Role Names", "Strongman Name");

		public ConfigDefinition customRoleNameRLDef = new ConfigDefinition("Role Names", "Ranged Looter Name");

		public ConfigDefinition customRoleNameAthleticDef = new ConfigDefinition("Role Names", "Athletic Name");

		public ConfigDefinition customRoleNameMageDef = new ConfigDefinition("Role Names", "Mage Name");

		public ConfigDefinition customRoleNameReaperDef = new ConfigDefinition("Role Names", "Reaper Name");

		public ConfigDefinition customRoleNameScoutDef = new ConfigDefinition("Role Names", "Scout Name");

		public ConfigDefinition customRoleNameRegularDef = new ConfigDefinition("Role Names", "Regular Name");

		public ConfigDefinition customRoleDesRunnerDef = new ConfigDefinition("Role Descriptions", "Runner Description");

		public ConfigDefinition customRoleDesTankDef = new ConfigDefinition("Role Descriptions", "Tank Description");

		public ConfigDefinition customRoleDesGamblerDef = new ConfigDefinition("Role Descriptions", "Gambler Description");

		public ConfigDefinition customRoleDesStrongmanDef = new ConfigDefinition("Role Descriptions", "Strongman Description");

		public ConfigDefinition customRoleDesRLDef = new ConfigDefinition("Role Descriptions", "Ranged Looter Description");

		public ConfigDefinition customRoleDesAthleticDef = new ConfigDefinition("Role Descriptions", "Athletic Description");

		public ConfigDefinition customRoleDesMageDef = new ConfigDefinition("Role Descriptions", "Mage Description");

		public ConfigDefinition customRoleDesReaperDef = new ConfigDefinition("Role Descriptions", "Reaper Description");

		public ConfigDefinition customRoleDesScoutDef = new ConfigDefinition("Role Descriptions", "Scout Description");

		public ConfigDefinition customRoleDesRegularDef = new ConfigDefinition("Role Descriptions", "Regular Description");

		public ConfigDefinition showSpellsDef = new ConfigDefinition("Mage", "Show Spells");

		public ConfigDefinition healDef = new ConfigDefinition("Mage", "Healing Spell");

		public ConfigDefinition speedDef = new ConfigDefinition("Mage", "Speed Spell");

		public ConfigDefinition overchargeDef = new ConfigDefinition("Mage", "Overcharge Spell");

		public ConfigDefinition jumpDef = new ConfigDefinition("Mage", "Jump Boost Spell");

		public ConfigDefinition staminaDef = new ConfigDefinition("Mage", "Stamina Refill Spell");

		public ConfigDefinition roleUpgrades = new ConfigDefinition("Upgrades", "Enable Role Upgrades in Shop");

		public ConfigDefinition selectedRoleDef = new ConfigDefinition("Role", "Your selected role");

		public ConfigDefinition afterDeathRoleDef = new ConfigDefinition("Role", "Reaasign roles after being revived");

		public static ConfigEntry<bool> enableRunner;

		public static ConfigEntry<bool> enableTank;

		public static ConfigEntry<bool> enableGambler;

		public static ConfigEntry<bool> enableStrongman;

		public static ConfigEntry<bool> enableRL;

		public static ConfigEntry<bool> enableAthletic;

		public static ConfigEntry<bool> enableMage;

		public static ConfigEntry<bool> enableReaper;

		public static ConfigEntry<bool> enableScout;

		public static ConfigEntry<bool> enableRegular;

		public ConfigDefinition enableRunnerDef = new ConfigDefinition("Role", "Enable Runner");

		public ConfigDefinition enableTankDef = new ConfigDefinition("Role", "Enable Tank");

		public ConfigDefinition enableGamblerDef = new ConfigDefinition("Role", "Enable Gambler");

		public ConfigDefinition enableStrongmanDef = new ConfigDefinition("Role", "Enable Strongman");

		public ConfigDefinition enableRLDef = new ConfigDefinition("Role", "Enable Ranged Looter");

		public ConfigDefinition enableAthleticDef = new ConfigDefinition("Role", "Enable Athletic");

		public ConfigDefinition enableMageDef = new ConfigDefinition("Role", "Enable Mage");

		public ConfigDefinition enableReaperDef = new ConfigDefinition("Role", "Enable Reaper");

		public ConfigDefinition enableScoutDef = new ConfigDefinition("Role", "Enable Scout");

		public ConfigDefinition enableRegularDef = new ConfigDefinition("Role", "Enable Regular");

		private REPOSlider slider;

		private REPOPopupPage configPage;

		private REPOButton buttonOpen;

		private REPOButton buttonOpenLobby;

		private REPOButton buttonClose;

		private REPOToggle afterDeathRoleToggle;

		private REPOToggle mageTopMana;

		public static bool afterDeathNewRole = false;

		public static bool mageTopManaBool;

		public static string chosenRoleName = "Random";

		public static RepoRoles Instance { get; private set; }

		internal static ManualLogSource Logger { get; private set; }

		public void sliderConf(string a)
		{
			savedRole.Value = a;
			chosenRoleName = a;
		}

		public void aDRC(bool a)
		{
			assignRoleAfterRevive.Value = a;
			afterDeathNewRole = a;
		}

		public void mageManaFunc(bool a)
		{
			mageTopManaConf.Value = a;
			mageTopManaBool = a;
			((BaseUnityPlugin)this).Config.Save();
			if (guiManager.isMage && (Object)(object)GUIinstance != (Object)null)
			{
				GUIinstance.UpdateManaDisplay();
			}
		}

		public static string getPath()
		{
			return Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "REPORoles_assets2");
		}

		private void Awake()
		{
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a0: Expected O, but got Unknown
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Expected O, but got Unknown
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Expected O, but got Unknown
			Instance = this;
			Logger = ((BaseUnityPlugin)this).Logger;
			savedRole = ((BaseUnityPlugin)this).Config.Bind<string>(selectedRoleDef, "Random", (ConfigDescription)null);
			assignRoleAfterRevive = ((BaseUnityPlugin)this).Config.Bind<bool>(afterDeathRoleDef, false, (ConfigDescription)null);
			mageTopManaConf = ((BaseUnityPlugin)this).Config.Bind<bool>(mageTopManaDef, true, (ConfigDescription)null);
			mageTopManaBool = mageTopManaConf.Value;
			showGUIAtStart = ((BaseUnityPlugin)this).Config.Bind<bool>(showGUIAtStartDef, true, (ConfigDescription)null);
			enableRoleUpgrades = ((BaseUnityPlugin)this).Config.Bind<bool>(roleUpgrades, true, (ConfigDescription)null);
			enableRunner = ((BaseUnityPlugin)this).Config.Bind<bool>(enableRunnerDef, true, (ConfigDescription)null);
			enableTank = ((BaseUnityPlugin)this).Config.Bind<bool>(enableTankDef, true, (ConfigDescription)null);
			enableGambler = ((BaseUnityPlugin)this).Config.Bind<bool>(enableGamblerDef, true, (ConfigDescription)null);
			enableStrongman = ((BaseUnityPlugin)this).Config.Bind<bool>(enableStrongmanDef, true, (ConfigDescription)null);
			enableRL = ((BaseUnityPlugin)this).Config.Bind<bool>(enableRLDef, true, (ConfigDescription)null);
			enableAthletic = ((BaseUnityPlugin)this).Config.Bind<bool>(enableAthleticDef, true, (ConfigDescription)null);
			enableMage = ((BaseUnityPlugin)this).Config.Bind<bool>(enableMageDef, true, (ConfigDescription)null);
			enableReaper = ((BaseUnityPlugin)this).Config.Bind<bool>(enableReaperDef, true, (ConfigDescription)null);
			enableScout = ((BaseUnityPlugin)this).Config.Bind<bool>(enableScoutDef, true, (ConfigDescription)null);
			enableRegular = ((BaseUnityPlugin)this).Config.Bind<bool>(enableRegularDef, true, (ConfigDescription)null);
			MenuAPI.AddElementToSettingsMenu((BuilderDelegate)delegate(Transform parent)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				//IL_0012: Expected O, but got Unknown
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0069: Unknown result type (might be due to invalid IL or missing references)
				//IL_007d: Expected O, but got Unknown
				//IL_008b: Unknown result type (might be due to invalid IL or missing references)
				//IL_009f: Expected O, but got Unknown
				//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c1: Expected O, but got Unknown
				//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d9: Expected O, but got Unknown
				if ((Object)configPage == (Object)null)
				{
					configPage = MenuAPI.CreateREPOPopupPage("REPORoles Classic", (PresetSide)0, true, true, 1.5f);
				}
				buttonOpen = MenuAPI.CreateREPOButton("REPORoles Classic Config", (Action)delegate
				{
					configPage.OpenPage(false);
				}, parent, new Vector2(500f, 10f));
				configPage.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform scrollView)
				{
					//IL_0007: Unknown result type (might be due to invalid IL or missing references)
					//IL_0012: Expected O, but got Unknown
					//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
					if ((Object)slider == (Object)null)
					{
						slider = MenuAPI.CreateREPOSlider("REPORoles Classic", "Choose your role", (Action<string>)delegate(string s)
						{
							sliderConf(s);
						}, scrollView, new string[11]
						{
							"Random", "Runner", "Tank", "Gambler", "Strongman", "Ranged Looter", "Athletic", "Mage", "Reaper", "Scout",
							"Regular"
						}, savedRole.Value, new Vector2(0f, 0f), "", "", (BarBehavior)0);
					}
					return ((REPOElement)slider).rectTransform;
				}, 0f, 0f);
				configPage.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform scrollView)
				{
					//IL_0007: Unknown result type (might be due to invalid IL or missing references)
					//IL_0012: Expected O, but got Unknown
					//IL_0034: Unknown result type (might be due to invalid IL or missing references)
					if ((Object)afterDeathRoleToggle == (Object)null)
					{
						afterDeathRoleToggle = MenuAPI.CreateREPOToggle("Reassign role on respawn", (Action<bool>)delegate(bool b)
						{
							aDRC(b);
						}, scrollView, new Vector2(0f, 0f), "ON", "OFF", assignRoleAfterRevive.Value);
					}
					return ((REPOElement)afterDeathRoleToggle).rectTransform;
				}, 0f, 0f);
				configPage.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform scrollView)
				{
					//IL_0007: Unknown result type (might be due to invalid IL or missing references)
					//IL_0012: Expected O, but got Unknown
					//I