Decompiled source of REPORoles Classic v2.1.4

Repo_Roles.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
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.IgnoreSymbolStoreSequencePoints)]
[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.1.4")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("2.1.4.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");

		private float origMoveSpeed;

		private float origSprintSpeed;

		private float origCrouchSpeed;

		private float speedMultiplier;

		private int origPlayerHealth;

		private int origMaxPlayerHealth;

		private float origJumpForce;

		private float origMaxEnergy;

		private float origGrabStrength;

		private float origGrabRange;

		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 ClassManager()
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			origMoveSpeed = PlayerController.instance.MoveSpeed;
			origSprintSpeed = PlayerController.instance.SprintSpeed;
			origCrouchSpeed = PlayerController.instance.CrouchSpeed;
			speedMultiplier = 1.5f;
			origJumpForce = PlayerController.instance.JumpForce;
			origPlayerHealth = (int)AccessTools.Field(typeof(PlayerHealth), "health").GetValue(PlayerAvatar.instance.playerHealth);
			origMaxPlayerHealth = (int)AccessTools.Field(typeof(PlayerHealth), "maxHealth").GetValue(PlayerAvatar.instance.playerHealth);
			origMaxEnergy = PlayerController.instance.EnergyStart;
			origGrabStrength = PhysGrabber.instance.grabStrength;
			origGrabRange = PhysGrabber.instance.grabRange;
		}

		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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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 });
			}
		}

		public void assignRole(int roleId, PlayerController __instance)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_0454: Unknown result type (might be due to invalid IL or missing references)
			//IL_0459: Unknown result type (might be due to invalid IL or missing references)
			//IL_0477: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0613: Unknown result type (might be due to invalid IL or missing references)
			//IL_0636: Unknown result type (might be due to invalid IL or missing references)
			//IL_063b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b33: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b38: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b56: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b88: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b8d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c73: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c78: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c96: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cc8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ccd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0dd3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0df1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e14: Unknown result type (might be due to invalid IL or missing references)
			//IL_0e19: Unknown result type (might be due to invalid IL or missing references)
			//IL_115b: Unknown result type (might be due to invalid IL or missing references)
			//IL_1160: Unknown result type (might be due to invalid IL or missing references)
			//IL_117e: Unknown result type (might be due to invalid IL or missing references)
			//IL_11b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_11b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_12a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_12aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_12cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_12f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_1327: Unknown result type (might be due to invalid IL or missing references)
			//IL_132c: Unknown result type (might be due to invalid IL or missing references)
			//IL_1422: Unknown result type (might be due to invalid IL or missing references)
			//IL_1427: Unknown result type (might be due to invalid IL or missing references)
			//IL_1445: Unknown result type (might be due to invalid IL or missing references)
			//IL_1468: Unknown result type (might be due to invalid IL or missing references)
			//IL_146d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f8a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0f8f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fbb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0fda: Unknown result type (might be due to invalid IL or missing references)
			//IL_1010: Unknown result type (might be due to invalid IL or missing references)
			//IL_1015: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_09df: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a08: Unknown result type (might be due to invalid IL or missing references)
			RepoRoles.Update_ManaRegeneration();
			RepoRoles.Update_ScoutCooldown();
			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 key = SemiFunc.PlayerGetSteamID(PlayerAvatar.instance);
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			int num4 = 0;
			int num5 = 0;
			if (StatsManager.instance.playerUpgradeHealth.TryGetValue(key, out var value))
			{
				num = value;
			}
			if (StatsManager.instance.playerUpgradeSpeed.TryGetValue(key, out var value2))
			{
				num2 = value2;
			}
			if (StatsManager.instance.playerUpgradeStamina.TryGetValue(key, out var value3))
			{
				num3 = value3;
			}
			if (StatsManager.instance.playerUpgradeStrength.TryGetValue(key, out var value4))
			{
				num4 = value4;
			}
			if (StatsManager.instance.playerUpgradeRange.TryGetValue(key, out var value5))
			{
				num5 = value5;
			}
			stackKills = 0;
			__instance.CrouchSpeed = origCrouchSpeed;
			__instance.MoveSpeed = origMoveSpeed;
			__instance.SprintSpeed = origSprintSpeed + (float)num2 * 1f;
			__instance.JumpForce = origJumpForce;
			__instance.EnergyStart = origMaxEnergy + (float)num3 * 10f;
			__instance.EnergyCurrent = origMaxEnergy + (float)num3 * 10f;
			PlayerAvatar.instance.physGrabber.grabRange = origGrabRange + 1f * (float)num5;
			modifyStrength(PlayerController.instance.playerSteamID, origGrabStrength + (float)num4 * 0.2f);
			int num6 = origMaxPlayerHealth + num * 20;
			int health = (int)AccessTools.Field(typeof(PlayerHealth), "health").GetValue(PlayerAvatar.instance.playerHealth);
			if ((int)AccessTools.Field(typeof(PlayerHealth), "health").GetValue(PlayerAvatar.instance.playerHealth) > num6)
			{
				setHealth(PlayerController.instance.playerSteamID, num6, num6);
			}
			else
			{
				setHealth(PlayerController.instance.playerSteamID, num6, health);
			}
			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 = origCrouchSpeed * speedMultiplier;
				__instance.MoveSpeed = origMoveSpeed * speedMultiplier;
				__instance.SprintSpeed = origSprintSpeed * speedMultiplier + (float)num2 * 1f;
				__instance.EnergyStart = (origMaxEnergy + (float)num3 * 10f) * 1.2f;
				__instance.EnergyCurrent = (origMaxEnergy + (float)num3 * 10f) * 1.2f;
				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 + "."));
				int num7 = (int)AccessTools.Field(typeof(PlayerHealth), "maxHealth").GetValue(PlayerAvatar.instance.playerHealth);
				int num8 = (int)AccessTools.Field(typeof(PlayerHealth), "health").GetValue(PlayerAvatar.instance.playerHealth);
				setHealth(PlayerController.instance.playerSteamID, num7 * 2, num8 * 2);
				__instance.CrouchSpeed = origCrouchSpeed * 0.9f;
				__instance.MoveSpeed = origMoveSpeed * 0.9f;
				__instance.SprintSpeed = (origSprintSpeed + (float)num2 * 1f) * 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 = origCrouchSpeed * 1.3f;
					__instance.MoveSpeed = origMoveSpeed * 1.3f;
					__instance.SprintSpeed = origSprintSpeed + (float)num2 * 1.3f;
				}
				else if ((int)array[1] == 1)
				{
					__instance.EnergyStart = (origMaxEnergy + (float)num3 * 10f) * 1.8f;
					__instance.EnergyCurrent = (origMaxEnergy + (float)num3 * 10f) * 1.8f;
				}
				else if ((int)array[1] == 2)
				{
					int num9 = (int)AccessTools.Field(typeof(PlayerHealth), "maxHealth").GetValue(PlayerAvatar.instance.playerHealth);
					int num10 = (int)AccessTools.Field(typeof(PlayerHealth), "health").GetValue(PlayerAvatar.instance.playerHealth);
					setHealth(PlayerController.instance.playerSteamID, (int)((double)num9 * 1.8), (int)((double)num10 * 1.8));
				}
				else if ((int)array[1] == 3)
				{
					modifyStrength(PlayerController.instance.playerSteamID, (origGrabStrength + (float)num4 * 0.2f) * 1.3f);
				}
				else if ((int)array[1] == 4)
				{
					__instance.JumpForce *= 1.5f;
				}
				if ((int)array[2] == 0)
				{
					__instance.CrouchSpeed = origCrouchSpeed;
					__instance.MoveSpeed = origMoveSpeed;
					__instance.SprintSpeed = origSprintSpeed + (float)num2 * 0.8f;
				}
				else if ((int)array[2] == 1)
				{
					__instance.EnergyStart = (origMaxEnergy + (float)num3 * 10f) * 0.8f;
					__instance.EnergyCurrent = (origMaxEnergy + (float)num3 * 10f) * 0.8f;
				}
				else if ((int)array[2] == 2)
				{
					int num11 = (int)AccessTools.Field(typeof(PlayerHealth), "maxHealth").GetValue(PlayerAvatar.instance.playerHealth);
					int num12 = (int)AccessTools.Field(typeof(PlayerHealth), "health").GetValue(PlayerAvatar.instance.playerHealth);
					setHealth(PlayerController.instance.playerSteamID, (int)((double)num11 * 0.8), (int)((double)num12 * 0.8));
				}
				else if ((int)array[2] == 3)
				{
					modifyStrength(PlayerController.instance.playerSteamID, (origGrabStrength + (float)num4 * 0.2f) * 0.8f);
				}
				else if ((int)array[2] == 4)
				{
					__instance.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: " + PhysGrabber.instance.grabStrength));
				modifyStrength(PlayerController.instance.playerSteamID, (origGrabStrength + (float)num4 * 0.2f) * 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 + "."));
				PhysGrabber.instance.grabRange = (origGrabRange + (float)num5 * 1f) * 2.5f;
				modifyStrength(PlayerController.instance.playerSteamID, (origGrabStrength + (float)num4 * 0.2f) * 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, (origGrabStrength + (float)num4 * 0.2f) * 1.3f);
				__instance.EnergyStart = origMaxEnergy + (float)num3 * 10f + 20f;
				__instance.EnergyCurrent = origMaxEnergy + (float)num3 * 10f + 20f;
				__instance.JumpForce = origJumpForce + 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;
				}
				guiManager.ResetManaUI();
				RepoRoles.Logger.LogInfo((object)"Resetting Mana UI.");
				RepoRoles.Logger.LogMessage((object)("Assigning role " + RepoRoles.customRoleNameMage.Value + "."));
				guiManager.isMage = true;
				guiManager.aviableMana = 8;
				ManaHelper.CreateUI();
				guiManager.manaTicks = 0;
				int num15 = (int)AccessTools.Field(typeof(PlayerHealth), "maxHealth").GetValue(PlayerAvatar.instance.playerHealth);
				int num16 = (int)AccessTools.Field(typeof(PlayerHealth), "health").GetValue(PlayerAvatar.instance.playerHealth);
				if ((double)num16 * 0.5 > 0.0)
				{
					setHealth(PlayerController.instance.playerSteamID, (int)((double)num15 * 0.5), (int)((double)num16 * 0.5));
				}
				else
				{
					setHealth(PlayerController.instance.playerSteamID, (int)((double)num15 * 0.5), num16);
				}
				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);
				int num13 = (int)AccessTools.Field(typeof(PlayerHealth), "maxHealth").GetValue(PlayerAvatar.instance.playerHealth);
				int num14 = (int)AccessTools.Field(typeof(PlayerHealth), "health").GetValue(PlayerAvatar.instance.playerHealth);
				setHealth(PlayerController.instance.playerSteamID, (int)((double)num13 * 1.5), (int)((double)num14 * 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 = (origMaxEnergy + (float)num3 * 10f) * 2f;
				__instance.EnergyCurrent = (origMaxEnergy + (float)num3 * 10f) * 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 = origCrouchSpeed;
				__instance.MoveSpeed = origMoveSpeed;
				__instance.SprintSpeed = origSprintSpeed + (float)num2 * 1f;
				__instance.JumpForce = origJumpForce;
				__instance.EnergyStart = origMaxEnergy + (float)num3 * 10f;
				__instance.EnergyCurrent = origMaxEnergy + (float)num3 * 10f;
				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 killerSteamID = (((Object)(object)PlayerController.instance != (Object)null) ? PlayerController.instance.playerSteamID : string.Empty);
			if (PhotonNetwork.IsMasterClient)
			{
				string[] masterReapers = ReaperEventListener.GetMasterReapers();
				if (masterReapers != null && masterReapers.Length != 0)
				{
					ReaperEvents.RaiseApplyBuffs(killerSteamID, masterReapers);
				}
			}
			else
			{
				ReaperEvents.RaiseRequestApplyBuffs(killerSteamID);
			}
		}

		[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_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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();
			}
		}

		public override void OnLeftRoom()
		{
			lock (masterReapers)
			{
				masterReapers.Clear();
			}
		}

		public override void OnMasterClientSwitched(Player newMasterClient)
		{
			lock (masterReapers)
			{
				masterReapers.Clear();
			}
		}

		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 text3 = (((array4 != null) ? array4[0] : null) as string) ?? string.Empty;
					string[] array5 = (((array4 != null) ? array4[1] : null) as string[]) ?? new string[0];
					string[] array6 = array5;
					foreach (string text4 in array6)
					{
						PlayerAvatar val = SemiFunc.PlayerAvatarGetFromSteamID(text4);
						if ((Object)(object)val == (Object)null)
						{
							RepoRoles.Logger.LogWarning((object)("[RpEsLr] giveReaperStatsRPC: cannot find avatar for steamID=" + text4 + " on this client"));
							continue;
						}
						ReaperManager component = ((Component)val).GetComponent<ReaperManager>();
						if ((Object)(object)component == (Object)null)
						{
							RepoRoles.Logger.LogWarning((object)("[RpEsLr] giveReaperStatsRPC: avatar " + text4 + " 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 {text4} is dead (health={num}) - skipping");
							continue;
						}
						if (component.enemyDeathTimer > 0)
						{
							RepoRoles.Logger.LogInfo((object)$"[RpEsLr] giveReaperStatsRPC: avatar {text4} 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;
					}
				}
				catch (Exception arg)
				{
					RepoRoles.Logger.LogError((object)$"[RpEsLr]: Event handler exception: {arg}");
				}
			}
		}
	}
	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_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: 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)
			if (reaperSteamIDs != null && reaperSteamIDs.Length != 0 && PhotonNetwork.IsConnected && PhotonNetwork.InRoom)
			{
				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);
			}
		}

		public static void RaiseReaperStatusChange(string steamID, bool isReaper)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: 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);
			}
		}

		public static void RaiseRequestApplyBuffs(string killerSteamID)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			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);
		}
	}
	public class ReaperManager : MonoBehaviourPun
	{
		public bool isReaper;

		public int kills;

		public int enemyDeathTimer;

		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;
				}
			}
			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);
			}
		}

		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);
				}
			}
		}

		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);
				}
				else
				{
					ReaperEvents.RaiseRequestApplyBuffs(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)
			{
				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
	{
		public static bool showGUI = true;

		public static bool isMage = false;

		private static bool showSpells = false;

		private bool isDead;

		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;

		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;

		private int overchargeTicker;

		private bool jumpActive;

		private float jumpOriginal;

		private int jumpTicker;

		private int neededJumpTicker = 1800;

		private int neededSpeedTicker = 1800;

		private int manaUsageTicker;

		private bool showManaUsage;

		private Texture2D textureRunner;

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

		private bool fontLoaded;

		private bool RunnerTextureLoaded;

		private int passiveTankRegenTicker;

		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_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: 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_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Expected O, but got Unknown
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Expected O, but got Unknown
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_0260: Expected O, but got Unknown
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0306: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0352: Unknown result type (might be due to invalid IL or missing references)
			//IL_0378: Unknown result type (might be due to invalid IL or missing references)
			//IL_039e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03be: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_0417: Expected O, but got Unknown
			//IL_0439: Unknown result type (might be due to invalid IL or missing references)
			//IL_043f: Expected O, but got Unknown
			//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a8: Expected O, but got Unknown
			//IL_04d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04fe: Expected O, but got Unknown
			//IL_0505: Unknown result type (might be due to invalid IL or missing references)
			//IL_053d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0562: Unknown result type (might be due to invalid IL or missing references)
			//IL_0587: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0624: Unknown result type (might be due to invalid IL or missing references)
			//IL_064c: Unknown result type (might be due to invalid IL or missing references)
			//IL_066e: Unknown result type (might be due to invalid IL or missing references)
			//IL_097b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0982: Expected O, but got Unknown
			//IL_09b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d8: Expected O, but got Unknown
			//IL_09df: 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)
			//IL_0a32: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a51: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a70: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a90: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ac6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ae3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b00: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b1d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b3d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b5d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b7d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b9d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bb7: Unknown result type (might be due to invalid IL or missing references)
			//IL_06ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b8: Expected O, but got Unknown
			//IL_06df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0705: Unknown result type (might be due to invalid IL or missing references)
			//IL_0725: Unknown result type (might be due to invalid IL or missing references)
			//IL_074b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0771: Unknown result type (might be due to invalid IL or missing references)
			//IL_0797: Unknown result type (might be due to invalid IL or missing references)
			//IL_07bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0811: Unknown result type (might be due to invalid IL or missing references)
			//IL_083f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0867: Unknown result type (might be due to invalid IL or missing references)
			//IL_0895: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c3: 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_091f: Unknown result type (might be due to invalid IL or missing references)
			//IL_094d: 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())
			{
				GUIStyle val9 = new GUIStyle();
				val9.fontSize = 40;
				val9.fontStyle = (FontStyle)1;
				val9.richText = true;
				val9.normal.textColor = new Color(0f, 0.384f, 1f);
				val9.alignment = (TextAnchor)4;
				val9.font = customFont;
				GUIStyle val10 = new GUIStyle(val9);
				val10.normal.textColor = Color.black;
				val10.alignment = (TextAnchor)4;
				val10.font = customFont;
				string text = "<size=65>SPELLS</size>\n[" + ((object)RepoRoles.healKey.Value).ToString() + "] Heal yourself for 5 health (1 Mana)\n\n[" + ((object)RepoRoles.staminaKey.Value).ToString() + "] Regenerate your stamina to full (3 Mana)\n\n[" + ((object)RepoRoles.speedKey.Value).ToString() + "] Become faster for 30 seconds (2 Mana)\n\n[" + ((object)RepoRoles.overchargeKey.Value).ToString() + "] Boost the effectivity of spells used in the next 20 seconds (3 Mana)\n\n[" + ((object)RepoRoles.jumpKey.Value).ToString() + "] Jump higher for 30 seconds (2 Mana)";
				float num10 = 2f;
				GUI.Label(new Rect(num - num10, num2, 200f, 50f), text, val10);
				GUI.Label(new Rect(num + num10, num2, 200f, 50f), text, val10);
				GUI.Label(new Rect(num, num2 - num10, 200f, 50f), text, val10);
				GUI.Label(new Rect(num, num2 + num10, 200f, 50f), text, val10);
				GUI.Label(new Rect(num - num10, num2 - num10, 200f, 50f), text, val10);
				GUI.Label(new Rect(num - num10, num2 + num10, 200f, 50f), text, val10);
				GUI.Label(new Rect(num + num10, num2 - num10, 200f, 50f), text, val10);
				GUI.Label(new Rect(num + num10, num2 + num10, 200f, 50f), text, val10);
				GUI.Label(new Rect(num, num2, 200f, 50f), text, val9);
			}
		}

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

		private void updateMana()
		{
			if (isMage)
			{
				if ((Object)(object)ManaHelper.val2 == (Object)null || (Object)(object)ManaHelper.val2.GetComponent<ManaUI>() == (Object)null)
				{
					RepoRoles.Logger.LogWarning((object)"Mana UI missing or destroyed. Recreating...");
					ManaHelper.CreateUI();
				}
				ManaHelper.val2.GetComponent<ManaUI>().SetMana(aviableMana, 8f);
			}
		}

		private void Update()
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Expected O, but got Unknown
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: 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_03de: 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_0537: Unknown result type (might be due to invalid IL or missing references)
			//IL_05dd: Unknown result type (might be due to invalid IL or missing references)
			if (SemiFunc.RunIsLevel() && (int)AccessTools.Field(typeof(PlayerHealth), "health").GetValue(PlayerAvatar.instance.playerHealth) <= 0)
			{
				isDead = true;
			}
			if (RepoRoles.mageTopManaBool && isMage && (Object)ManaHelper.val != (Object)null && (Object)ManaHelper.val2 != (Object)null && ManaHelper.val2.activeInHierarchy)
			{
				ManaHelper.val2.SetActive(false);
			}
			else if (!RepoRoles.mageTopManaBool && isMage && (Object)ManaHelper.val != (Object)null && (Object)ManaHelper.val2 != (Object)null && !ManaHelper.val2.activeInHierarchy)
			{
				ManaHelper.val2.SetActive(true);
				((Behaviour)((SemiUI)ManaHelper.val2.gameObject.GetComponent<ManaUI>()).uiText).enabled = 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)";
							updateMana();
						}
					}
					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)";
						updateMana();
					}
				}
				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)";
						updateMana();
						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)";
					updateMana();
				}
				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)";
						updateMana();
						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)";
					updateMana();
				}
			}
			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;
			}
		}

		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;
				updateMana();
			}
		}
	}
	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_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)val2 != (Object)null)
			{
				Object.Destroy((Object)(object)val2);
				val2 = null;
				manaUI = null;
			}
			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);
			EnergyUI component = val2.GetComponent<EnergyUI>();
			if ((Object)(object)component != (Object)null)
			{
				Object.DestroyImmediate((Object)(object)component);
			}
			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);
				}
			}
			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 = val2.GetComponentInChildren<Image>(true);
				if ((Object)(object)componentInChildren != (Object)null)
				{
					componentInChildren.sprite = sprite;
					((Graphic)componentInChildren).color = Color.white;
				}
				else
				{
					RepoRoles.Logger.LogWarning((object)"Mana UI Image component not found.");
				}
			}
			else
			{
				RepoRoles.Logger.LogWarning((object)"guiManager.manaTexture is null!");
			}
			manaUI = val2.AddComponent<ManaUI>();
			manaUI.SetMana(8f, 8f);
		}
	}
	public class ManaUI : SemiUI
	{
		public TextMeshProUGUI textMana;

		public TextMeshProUGUI textManaMax;

		public static ManaUI instance;

		public override void Start()
		{
			((SemiUI)this).Start();
			instance = this;
			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((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 || (Object)(object)textManaMax == (Object)null)
				{
					RepoRoles.Logger.LogWarning((object)"ManaUI.SetMana called but UI references are null.");
					return;
				}
			}
			((TMP_Text)textMana).text = Mathf.Ceil(mana).ToString();
			((TMP_Text)textManaMax).text = $"<b>/</b>{Mathf.Ceil(maxMana)}";
		}
	}
	[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];
			if (!dictionary.TryGetValue(steamId, out var value))
			{
				return 0;
			}
			return value;
		}

		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.1.4";
	}
	[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.1.4")]
	[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> 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 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;
		}

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

		private void Awake()
		{
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Expected O, but got Unknown
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Expected O, but got Unknown
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: 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);
			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_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Expected O, but got Unknown
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				//IL_0078: Expected O, but got Unknown
				//IL_0085: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: Expected O, but got Unknown
				//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ba: Expected O, but got Unknown
				//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d1: Expected O, but got Unknown
				if ((Object)configPage == (Object)null)
				{
					configPage = MenuAPI.CreateREPOPopupPage("REPO Roles", (PresetSide)0, true, true, 1.5f);
				}
				buttonOpen = MenuAPI.CreateREPOButton("REPO Roles Config", (Action)delegate
				{
					configPage.OpenPage(false);
				}, parent, new Vector2(500f, 10f));
				configPage.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform scrollView)
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_0011: Expected O, but got Unknown
					//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
					if ((Object)slider == (Object)null)
					{
						slider = MenuAPI.CreateREPOSlider("REPO Roles", "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_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_0011: Expected O, but got Unknown
					//IL_0030: 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_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_0011: Expected O, but got Unknown
					//IL_0030: Unknown result type (might be due to invalid IL or missing references)
					if ((Object)mageTopMana == (Object)null)
					{
						mageTopMana = MenuAPI.CreateREPOToggle("Mage Mana Position", (Action<bool>)delegate(bool b)
						{
							mageManaFunc(b);
						}, scrollView, new Vector2(0f, 0f), "TOP", "LEFT", mageTopManaConf.Value);
					}
					return ((REPOElement)mageTopMana).rectTransform;
				}, 0f, 0f);
				configPage.AddElement((BuilderDelegate)delegate(Transform val)
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_0011: Expected O, but got Unknown
					//IL_0026: Unknown result type (might be due to invalid IL or missing references)
					if ((Object)buttonClose == (Object)null)
					{
						buttonClose = MenuAPI.CreateREPOButton("Back", (Action)delegate
						{
							configPage.ClosePage(false);
						}, val, Vector2.zero);
					}
				});
			});
			MenuAPI.AddElementToLobbyMenu((BuilderDelegate)delegate(Transform parent)
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				buttonOpenLobby = MenuAPI.CreateREPOButton("REPO Roles Config", (Action)delegate
				{
					configPage.OpenPage(false);
				}, parent, new Vector2(500f, 500f));
			});
			if ((Object)Instance == (Object)null)
			{
				Instance = this;
			}
			harmony.PatchAll(typeof(RepoRoles));
			harmony.PatchAll(typeof(Sender));
			Logger.LogInfo((object)"Plugin REPO Roles Classic v2.1.4 loaded successfully.");
			SceneManager.sceneLoaded += delegate
			{
				//IL_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0013: Expected O, but got Unknown
				//IL_0032: Unknown result type (might be due to invalid IL or missing references)
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0047: Expected O, but got Unknown
				if ((Object)(object)GUIinstance == (Object)null)
				{
					GameObject val4 = new GameObject();
					GUIinstance = val4.AddComponent<guiManager>();
					GUIinstance.text = "";
					GUIinstance.color = Color.cyan;
					Object.DontDestroyOnLoad((Object)val4);
				}
			};
			toggleKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>(def, (KeyCode)114, (ConfigDescription)null);
			showSpellsKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>(showSpellsDef, (KeyCode)109, (ConfigDescription)null);
			healKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>(healDef, (KeyCode)104, (ConfigDescription)null);
			speedKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>(speedDef, (KeyCode)106, (ConfigDescription)null);
			overchargeKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>(overchargeDef, (KeyCode)111, (ConfigDescription)null);
			jumpKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>(jumpDef, (KeyCode)107, (ConfigDescription)null);
			staminaKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>(staminaDef, (KeyCode)110, (ConfigDescription)null);
			customRoleNameRunner = ((BaseUnityPlugin)this).Config.Bind<string>(customRoleNameRunnerDef, "Runner", (ConfigDescription)null);
			customRoleNameTank = ((BaseUnityPlugin)this).Config.Bind<string>(customRoleNameTankDef, "Tank", (ConfigDescription)null);
			customRoleNameGambler = ((BaseUnityPlugin)this).Config.Bind<string>(customRoleNameGamblerDef, "Gambler", (ConfigDescription)null);
			customRoleNameStrongman = ((BaseUnityPlugin)this).Config.Bind<string>(customRoleNameStrongmanDef, "Strongman", (ConfigDescription)null);
			customRoleNameRL = ((BaseUnityPlugin)this).Config.Bind<string>(customRoleNameRLDef, "Ranged Looter", (ConfigDescription)null);
			customRoleNameAthletic = ((BaseUnityPlugin)this).Config.Bind<string>(customRoleNameAthleticDef, "Athletic", (ConfigDescription)null);
			customRoleNameMage = ((BaseUnityPlugin)this).Config.Bind<string>(customRoleNameMageDef, "Mage", (ConfigDescription)null);
			customRoleNameReaper = ((BaseUnityPlugin)this).Config.Bind<string>(customRoleNameReaperDef, "Reaper", (ConfigDescription)null);
			customRoleNameScout = ((BaseUnityPlugin)this).Config.Bind<string>(customRoleNameScoutDef, "Scout", (ConfigDescription)null);
			customRoleNameRegular = ((BaseUnityPlugin)this).Config.Bind<string>(customRoleNameRegularDef, "Regular", (ConfigDescription)null);
			customRoleDecRunner = ((BaseUnityPlugin)this).Config.Bind<string>(customRoleDesRunnerDef, "You have more stamina and run much faster than everyone else!", (ConfigDescription)null);
			customRoleDecTank = ((BaseUnityPlugin)this).Config.Bind<string>(customRoleDesTankDef, "You walk slower but your hp is doubled!", (ConfigDescription)null);
			customRoleDecGambler = ((BaseUnityPlugin)this).Config.Bind<string>(customRoleDesGamblerDef, "You rolled random effects:", (ConfigDescription)null);
			customRoleDecStrongman = ((BaseUnityPlugin)this).Config.Bind<string>(customRoleDesStrongmanDef, "You\u00b4re incredibly strong!", (ConfigDescription)null);
			customRoleDecRL = ((BaseUnityPlugin)this).Config.Bind<string>(customRoleDesRLDef, "You can reach objects from far away!", (ConfigDescription)null);
			customRoleDecAthletic = ((BaseUnityPlugin)this).Config.Bind<string>(customRoleDesAthleticDef, "You have more stamina, strength and can jump higher", (ConfigDescription)null);
			customRoleDecMage = ((BaseUnityPlugin)this).Config.Bind<string>(customRoleDesMageDef, "You are able to use your mana to become incredibly strong!", (ConfigDescription)null);
			customRoleDecReaper = ((BaseUnityPlugin)this).Config.Bind<string>(customRoleDesReaperDef, "For each enemy you and your friends kill, you become stronger!", (ConfigDescription)null);
			customRoleDecScout = ((BaseUnityPlugin)this).Config.Bind<string>(customRoleDesScoutDef, "Your stamina is more efficient and by pressing [G] you can see all enemies around you.", (ConfigDescription)null);
			customRoleDecRegular = ((BaseUnityPlugin)this).Config.Bind<string>(customRoleDesRegularDef, "You are just a regular Semibot. Nothing special.", (ConfigDescription)null);
			scoutKey = ((BaseUnityPlugin)this).Config.Bind<KeyCode>(scoutButtonDef, (KeyCode)103, (ConfigDescription)null);
			harmony.PatchAll(typeof(PunManagerPatch));
			harmony.PatchAll(typeof(PlayerAvatarPatch));
			harmony.PatchAll(typeof(StatsManagerPatch));
			harmony.PatchAll(typeof(EnemyHealthPatch));
			BundleLoader.LoadBundle(getPath(), (Action<AssetBundle>)delegate(AssetBundle assetBundle)
			{
				Item val2 = assetBundle.LoadAsset<Item>("Mana Regeneration Upgrade");
				Items.RegisterItem(val2);
				Item val3 = assetBundle.LoadAsset<Item>("Scout Cooldown Upgrade");
				Items.RegisterItem(val3);
			}, false);
		}

		public static void Update_ManaRegeneration()
		{
			if (LevelGenerator.Instance.Generated && !SemiFunc.MenuLevel())
			{
				int stat = Upgrader.GetStat(PlayerAvatar.instance.steamID, "playerUpgradeManaRegeneration");
				guiManager.manaRegenRate = Upgrader.GetStat(PlayerAvatar.instance.steamID, "playerUpgradeManaRegeneration");
			}
		}

		public static void Update_ScoutCooldown()
		{
			if (LevelGenerator.Instance.Generated && !SemiFunc.MenuLevel())
			{
				int stat = Upgrader.GetStat(PlayerAvatar.instance.steamID, "playerUpgradeScoutCooldownReduction");
				ScoutMarker.reductionUpgrades = Upgrader.GetStat(PlayerAvatar.instance.steamID, "playerUpgradeScoutCooldownReduction");
			}
		}
	}
	public class ScoutMarker : MonoBehaviour
	{
		private int cooldownTicker;

		private int activeTicker = 250;

		private bool isActive;

		private bool onCooldown = true;

		public static int reductionUpgrades;

		private void OnGUI()
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)