Decompiled source of PeakClassModUPDATE v1.0.3

plugins/PeakClassMod.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Peak.Afflictions;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using UnityEngine.UI;
using Zorro.Core;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("PeakClassMod")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("PeakClassMod")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("68e93fcd-af72-447e-8fcc-2e7429a66921")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace PeakClassMod;

[BepInPlugin("com.peakmod.classmod", "PEAK Class Mod", "1.0.3")]
public class PeakClassModPlugin : BaseUnityPlugin
{
	public static PeakClassModPlugin Instance;

	internal static ManualLogSource Log;

	private static Harmony harmony;

	public static bool scoutActive = false;

	public static bool medicActive = false;

	public static bool techPriestActive = false;

	public static bool mushroomancerActive = false;

	public static bool greatEpeeActive = false;

	public static bool rogueActive = false;

	public static bool generalActive = false;

	public static bool astronautActive = false;

	public static string currentClass = "None";

	private GameObject _callbacksGO;

	private static readonly string[] StartBerries = new string[5] { "Shroomberry_Red", "Shroomberry_Yellow", "Shroomberry_Purple", "Shroomberry_Blue", "Shroomberry_Green" };

	private void Awake()
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Expected O, but got Unknown
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Expected O, but got Unknown
		Instance = this;
		Log = ((BaseUnityPlugin)this).Logger;
		harmony = new Harmony("com.peakmod.classmod");
		harmony.PatchAll();
		_callbacksGO = new GameObject("PeakClassModCallbacks");
		Object.DontDestroyOnLoad((Object)(object)_callbacksGO);
		_callbacksGO.AddComponent<PeakClassModCallbacks>();
		ManualLogSource log = Log;
		if (log != null)
		{
			log.LogInfo((object)"[ClassMod] Ready. Version 3.6.0 loaded (Latency Fix).");
		}
	}

	private void OnDestroy()
	{
		try
		{
			Harmony obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
		}
		catch
		{
		}
		if ((Object)(object)_callbacksGO != (Object)null)
		{
			Object.Destroy((Object)(object)_callbacksGO);
		}
	}

	public void EnsureComponent<T>(GameObject go) where T : Component
	{
		if ((Object)(object)go.GetComponent<T>() == (Object)null)
		{
			go.AddComponent<T>();
		}
	}

	public static List<string> BuildStartItemsByHatName(string hatName)
	{
		List<string> list = new List<string>();
		if (string.IsNullOrEmpty(hatName))
		{
			return list;
		}
		switch (hatName)
		{
		case "Hat_Mushroom":
		{
			for (int i = 0; i < 3; i++)
			{
				list.Add(StartBerries[Random.Range(0, StartBerries.Length)]);
			}
			break;
		}
		case "Hat_Medic":
			list.Add("FirstAidKit");
			list.Add("Cure-All");
			break;
		case "Hat_Crab":
			list.Add("ChainShooter");
			list.Add("ChainShooter");
			break;
		case "Hat_NinjaHeadband":
			list.Add("RopeSpool");
			list.Add("RopeSpool");
			break;
		case "Hat_Astronaut":
			list.Add("BalloonBunch");
			break;
		}
		return list;
	}
}
public class ClassModNetwork : MonoBehaviourPun
{
	[CompilerGenerated]
	private sealed class <HostGiveItemsRoutine>d__9 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public string hatName;

		public Player requestor;

		public ClassModNetwork <>4__this;

		private List<string> <itemsToGive>5__1;

		private Character <targetChar>5__2;

		private int <actorNumber>5__3;

		private Character <cachedChar>5__4;

		private int <itemsGiven>5__5;

		private List<Character>.Enumerator <>s__6;

		private Character <ch>5__7;

		private List<string>.Enumerator <>s__8;

		private string <itemName>5__9;

		private Item <item>5__10;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <HostGiveItemsRoutine>d__9(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			int num = <>1__state;
			if (num == -3 || num == 1)
			{
				try
				{
				}
				finally
				{
					<>m__Finally1();
				}
			}
			<itemsToGive>5__1 = null;
			<targetChar>5__2 = null;
			<cachedChar>5__4 = null;
			<>s__6 = default(List<Character>.Enumerator);
			<ch>5__7 = null;
			<>s__8 = default(List<string>.Enumerator);
			<itemName>5__9 = null;
			<item>5__10 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0299: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a3: Expected O, but got Unknown
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Expected O, but got Unknown
			try
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
				{
					<>1__state = -1;
					<itemsToGive>5__1 = PeakClassModPlugin.BuildStartItemsByHatName(hatName);
					if (<itemsToGive>5__1.Count == 0)
					{
						return false;
					}
					<targetChar>5__2 = null;
					<actorNumber>5__3 = requestor.ActorNumber;
					if (_characterCache.TryGetValue(<actorNumber>5__3, out <cachedChar>5__4) && (Object)(object)<cachedChar>5__4 != (Object)null)
					{
						<targetChar>5__2 = <cachedChar>5__4;
					}
					else
					{
						<>s__6 = Character.AllCharacters.GetEnumerator();
						try
						{
							while (<>s__6.MoveNext())
							{
								<ch>5__7 = <>s__6.Current;
								if (((MonoBehaviourPun)<ch>5__7).photonView.Owner == requestor)
								{
									<targetChar>5__2 = <ch>5__7;
									_characterCache[<actorNumber>5__3] = <ch>5__7;
									break;
								}
								<ch>5__7 = null;
							}
						}
						finally
						{
							((IDisposable)<>s__6).Dispose();
						}
						<>s__6 = default(List<Character>.Enumerator);
					}
					if ((Object)(object)<targetChar>5__2 == (Object)null || (Object)(object)<targetChar>5__2.player == (Object)null)
					{
						return false;
					}
					ManualLogSource log = PeakClassModPlugin.Log;
					if (log != null)
					{
						log.LogInfo((object)$"[ClassMod] Host giving {<itemsToGive>5__1.Count} items to ActorNumber {requestor.ActorNumber}...");
					}
					<itemsGiven>5__5 = 0;
					<>s__8 = <itemsToGive>5__1.GetEnumerator();
					<>1__state = -3;
					goto IL_02c5;
				}
				case 1:
					<>1__state = -3;
					<item>5__10 = null;
					<itemName>5__9 = null;
					goto IL_02c5;
				case 2:
					{
						<>1__state = -1;
						break;
					}
					IL_02c5:
					if (<>s__8.MoveNext())
					{
						<itemName>5__9 = <>s__8.Current;
						<item>5__10 = ItemCache.Get(<itemName>5__9);
						if ((Object)(object)<item>5__10 != (Object)null && <targetChar>5__2.player.HasEmptySlot(<item>5__10.itemID))
						{
							ItemSlot val = default(ItemSlot);
							<targetChar>5__2.player.AddItem(<item>5__10.itemID, (ItemInstanceData)null, ref val);
							<itemsGiven>5__5++;
							ManualLogSource log2 = PeakClassModPlugin.Log;
							if (log2 != null)
							{
								log2.LogInfo((object)("[ClassMod] Host gave " + <itemName>5__9));
							}
						}
						<>2__current = (object)new WaitForSeconds(0.02f);
						<>1__state = 1;
						return true;
					}
					<>m__Finally1();
					<>s__8 = default(List<string>.Enumerator);
					if (<itemsGiven>5__5 > 0)
					{
						<>2__current = (object)new WaitForSeconds(0.1f);
						<>1__state = 2;
						return true;
					}
					break;
				}
				return false;
			}
			catch
			{
				//try-fault
				((IDisposable)this).Dispose();
				throw;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		private void <>m__Finally1()
		{
			<>1__state = -1;
			((IDisposable)<>s__8).Dispose();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <RequestItemsRoutine>d__7 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public ClassModNetwork <>4__this;

		private float <timeout>5__1;

		private bool <inventoryReady>5__2;

		private string <myHatName>5__3;

		private string <detectedHat>5__4;

		private string <myHatName>5__5;

		private string <detectedHat>5__6;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <RequestItemsRoutine>d__7(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<myHatName>5__3 = null;
			<detectedHat>5__4 = null;
			<myHatName>5__5 = null;
			<detectedHat>5__6 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Expected O, but got Unknown
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(0.3f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				goto IL_0078;
			case 2:
				<>1__state = -1;
				goto IL_0078;
			case 3:
				<>1__state = -1;
				goto IL_0190;
			case 4:
				{
					<>1__state = -1;
					if ((Object)(object)<>4__this._character != (Object)null && (Object)(object)<>4__this._character.player != (Object)null)
					{
						<myHatName>5__5 = "None";
						if (HatUtils.TryGetHatName(<>4__this._character, out <detectedHat>5__6))
						{
							<myHatName>5__5 = <detectedHat>5__6;
						}
						ManualLogSource log = PeakClassModPlugin.Log;
						if (log != null)
						{
							log.LogInfo((object)("[ClassMod] Retry requesting items for Hat: " + <myHatName>5__5));
						}
						((MonoBehaviourPun)<>4__this).photonView.RPC("RPC_HostGiveItems", (RpcTarget)2, new object[1] { <myHatName>5__5 });
						<myHatName>5__5 = null;
						<detectedHat>5__6 = null;
					}
					break;
				}
				IL_0190:
				if (<timeout>5__1 > 0f)
				{
					if (!((Object)(object)<>4__this._character != (Object)null) || !((Object)(object)<>4__this._character.player != (Object)null) || <>4__this._character.player.itemSlots == null || <>4__this._character.player.itemSlots.Length == 0 || <>4__this._character.player.itemSlots[0].IsEmpty())
					{
						<timeout>5__1 -= 0.1f;
						<>2__current = (object)new WaitForSeconds(0.1f);
						<>1__state = 3;
						return true;
					}
					<inventoryReady>5__2 = true;
				}
				if (<inventoryReady>5__2)
				{
					<myHatName>5__3 = "None";
					if (HatUtils.TryGetHatName(<>4__this._character, out <detectedHat>5__4))
					{
						<myHatName>5__3 = <detectedHat>5__4;
					}
					ManualLogSource log2 = PeakClassModPlugin.Log;
					if (log2 != null)
					{
						log2.LogInfo((object)("[ClassMod] Requesting items for Hat: " + <myHatName>5__3));
					}
					((MonoBehaviourPun)<>4__this).photonView.RPC("RPC_HostGiveItems", (RpcTarget)2, new object[1] { <myHatName>5__3 });
					<myHatName>5__3 = null;
					<detectedHat>5__4 = null;
					break;
				}
				<>2__current = (object)new WaitForSeconds(1f);
				<>1__state = 4;
				return true;
				IL_0078:
				if (!PhotonNetwork.InRoom)
				{
					<>2__current = null;
					<>1__state = 2;
					return true;
				}
				if ((Object)(object)<>4__this._character == (Object)null)
				{
					<>4__this._character = ((Component)<>4__this).GetComponent<Character>();
				}
				<timeout>5__1 = 5f;
				<inventoryReady>5__2 = false;
				goto IL_0190;
			}
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	private Character _character;

	private bool _hasRequestedItems = false;

	private static Dictionary<int, float> _hostGiveCooldown = new Dictionary<int, float>();

	private static Dictionary<int, Character> _characterCache = new Dictionary<int, Character>();

	private void Awake()
	{
		ClassModNetwork[] components = ((Component)this).GetComponents<ClassModNetwork>();
		if (components.Length > 1)
		{
			Object.Destroy((Object)(object)this);
		}
		else
		{
			_character = ((Component)this).GetComponent<Character>();
		}
	}

	private void Start()
	{
		if (((MonoBehaviourPun)this).photonView.IsMine && !_hasRequestedItems)
		{
			_hasRequestedItems = true;
			((MonoBehaviour)this).StartCoroutine(RequestItemsRoutine());
		}
	}

	private void OnDestroy()
	{
		if ((Object)(object)_character != (Object)null && (Object)(object)((MonoBehaviourPun)_character).photonView != (Object)null && ((MonoBehaviourPun)_character).photonView.Owner != null)
		{
			_characterCache.Remove(((MonoBehaviourPun)_character).photonView.Owner.ActorNumber);
		}
	}

	[IteratorStateMachine(typeof(<RequestItemsRoutine>d__7))]
	private IEnumerator RequestItemsRoutine()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <RequestItemsRoutine>d__7(0)
		{
			<>4__this = this
		};
	}

	[PunRPC]
	public void RPC_HostGiveItems(string clientHatName, PhotonMessageInfo info)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		if (PhotonNetwork.IsMasterClient)
		{
			Player sender = info.Sender;
			int actorNumber = sender.ActorNumber;
			if (!_hostGiveCooldown.TryGetValue(actorNumber, out var value) || !(Time.time - value < 2f))
			{
				_hostGiveCooldown[actorNumber] = Time.time;
				((MonoBehaviour)this).StartCoroutine(HostGiveItemsRoutine(clientHatName, sender));
			}
		}
	}

	[IteratorStateMachine(typeof(<HostGiveItemsRoutine>d__9))]
	private IEnumerator HostGiveItemsRoutine(string hatName, Player requestor)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <HostGiveItemsRoutine>d__9(0)
		{
			<>4__this = this,
			hatName = hatName,
			requestor = requestor
		};
	}

	[PunRPC]
	public void ShowMedicHealEffectRPC(int remainingHeals)
	{
		ManualLogSource log = PeakClassModPlugin.Log;
		if (log != null)
		{
			log.LogInfo((object)$"[ClassMod] Medic heal used! Remaining: {remainingHeals}");
		}
	}

	[PunRPC]
	public void RPC_SyncClassActivation(string className, int actorNumber)
	{
		ManualLogSource log = PeakClassModPlugin.Log;
		if (log != null)
		{
			log.LogInfo((object)$"[ClassMod] Player {actorNumber} activated class: {className}");
		}
	}
}
public class PeakClassModCallbacks : MonoBehaviourPunCallbacks
{
}
internal static class HatUtils
{
	private static string _lastLocalHatName;

	internal static void SetLastLocalHatName(string hatName)
	{
		if (!string.IsNullOrEmpty(hatName))
		{
			_lastLocalHatName = hatName;
		}
	}

	public static bool TryGetHatName(Character ch, out string hatName)
	{
		hatName = null;
		if ((Object)(object)ch == (Object)null)
		{
			return false;
		}
		PersistentPlayerDataService service = GameHandler.GetService<PersistentPlayerDataService>();
		PersistentPlayerData val = null;
		if ((Object)(object)((MonoBehaviourPun)ch).photonView != (Object)null && ((MonoBehaviourPun)ch).photonView.Owner != null)
		{
			val = ((service != null) ? service.GetPlayerData(((MonoBehaviourPun)ch).photonView.Owner) : null);
		}
		if (val == null && ch.IsLocal && PhotonNetwork.LocalPlayer != null)
		{
			val = ((service != null) ? service.GetPlayerData(PhotonNetwork.LocalPlayer) : null);
		}
		if (val != null)
		{
			CustomizationOption[] array = Singleton<Customization>.Instance?.hats;
			int currentHat = val.customizationData.currentHat;
			if (array != null && currentHat >= 0 && currentHat < array.Length && (Object)(object)array[currentHat] != (Object)null)
			{
				hatName = ((Object)array[currentHat]).name;
				return !string.IsNullOrEmpty(hatName);
			}
		}
		if (ch.IsLocal && !string.IsNullOrEmpty(_lastLocalHatName))
		{
			hatName = _lastLocalHatName;
			return true;
		}
		return false;
	}

	public static bool HasHat(Character ch, string expected)
	{
		string hatName;
		return TryGetHatName(ch, out hatName) && string.Equals(hatName, expected, StringComparison.OrdinalIgnoreCase);
	}

	public static bool HasAnyHat(Character ch, params string[] names)
	{
		if (!TryGetHatName(ch, out var hatName))
		{
			return false;
		}
		return names.Contains<string>(hatName, StringComparer.OrdinalIgnoreCase);
	}
}
internal static class ClassCheckUtil
{
	public static bool IsGeneral(Character ch)
	{
		return HatUtils.HasAnyHat(ch, "Hat_Bandana");
	}

	public static bool IsTechPriest(Character ch)
	{
		return HatUtils.HasHat(ch, "Hat_Crab");
	}

	public static bool IsMedicHat(Character ch)
	{
		return HatUtils.HasAnyHat(ch, "Hat_Medic");
	}

	public static bool IsMushroom(Character ch)
	{
		return HatUtils.HasHat(ch, "Hat_Mushroom");
	}

	public static bool IsRogueHat(Character ch)
	{
		return HatUtils.HasHat(ch, "Hat_NinjaHeadband");
	}

	public static bool IsGreatEpeeHat(Character ch)
	{
		return HatUtils.HasHat(ch, "Hat_Propeller");
	}

	public static bool IsAstronaut(Character ch)
	{
		return HatUtils.HasHat(ch, "Hat_Astronaut");
	}
}
internal static class ItemCache
{
	private static Dictionary<string, Item> _byName;

	private static float _lastRefreshTime;

	public static void Refresh()
	{
		_byName = null;
		EnsureCache();
	}

	private static void EnsureCache()
	{
		if (_byName != null && Time.time - _lastRefreshTime < 60f)
		{
			return;
		}
		_byName = new Dictionary<string, Item>(StringComparer.OrdinalIgnoreCase);
		Item[] array = Resources.FindObjectsOfTypeAll<Item>();
		foreach (Item val in array)
		{
			if ((Object)(object)val != (Object)null && !string.IsNullOrEmpty(((Object)val).name) && !_byName.ContainsKey(((Object)val).name))
			{
				_byName[((Object)val).name] = val;
			}
		}
		_lastRefreshTime = Time.time;
	}

	public static Item Get(string name)
	{
		EnsureCache();
		_byName.TryGetValue(name, out var value);
		return value;
	}
}
[HarmonyPatch(typeof(Character), "Start")]
public class Character_Start_AddNetComp_Patch
{
	private static void Postfix(Character __instance)
	{
		if ((Object)(object)__instance != (Object)null)
		{
			PeakClassModPlugin.Instance.EnsureComponent<ClassModNetwork>(((Component)__instance).gameObject);
			PeakClassModPlugin.Instance.EnsureComponent<AstronautStatHandler>(((Component)__instance).gameObject);
			PeakClassModPlugin.Instance.EnsureComponent<MedicStatHandler>(((Component)__instance).gameObject);
			PeakClassModPlugin.Instance.EnsureComponent<TechPriestWeightEnforcer>(((Component)__instance).gameObject);
		}
	}
}
public static class ClassManager
{
	[CompilerGenerated]
	private sealed class <GreatEpeePermanentEffects>d__22 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public Character character;

		private bool <hasFaster>5__1;

		private List<Affliction> <afflictionList>5__2;

		private int <i>5__3;

		private Affliction_FasterBoi <fb>5__4;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <GreatEpeePermanentEffects>d__22(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<afflictionList>5__2 = null;
			<fb>5__4 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Expected O, but got Unknown
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				break;
			case 1:
				<>1__state = -1;
				<afflictionList>5__2 = null;
				break;
			}
			if (PeakClassModPlugin.greatEpeeActive && (Object)(object)character != (Object)null && character.IsLocal)
			{
				<hasFaster>5__1 = false;
				<afflictionList>5__2 = character.refs.afflictions.afflictionList;
				<i>5__3 = 0;
				while (<i>5__3 < <afflictionList>5__2.Count)
				{
					if (((object)<afflictionList>5__2[<i>5__3]).GetType().Name.Contains("FasterBoi"))
					{
						<hasFaster>5__1 = true;
						break;
					}
					<i>5__3++;
				}
				if (!<hasFaster>5__1)
				{
					<fb>5__4 = new Affliction_FasterBoi
					{
						totalTime = 99999f
					};
					character.refs.afflictions.AddAffliction((Affliction)(object)<fb>5__4, false);
					<fb>5__4 = null;
				}
				<>2__current = (object)new WaitForSeconds(2f);
				<>1__state = 1;
				return true;
			}
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <GreatEpeeStaminaRoutine>d__23 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public Character character;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <GreatEpeeStaminaRoutine>d__23(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				break;
			case 1:
				<>1__state = -1;
				character.refs.afflictions.AddStatus((STATUSTYPE)6, 1f, false, true);
				break;
			}
			if (PeakClassModPlugin.greatEpeeActive && (Object)(object)character != (Object)null && character.IsLocal)
			{
				<>2__current = (object)new WaitForSeconds(Random.Range(45f, 150f));
				<>1__state = 1;
				return true;
			}
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <MushroomancerLocalStaminaWatch>d__20 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public Character character;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <MushroomancerLocalStaminaWatch>d__20(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			if ((Object)(object)character != (Object)null && PeakClassModPlugin.mushroomancerActive && character.IsLocal && character.data.currentStamina <= 0.001f && !character.data.fullyPassedOut)
			{
				TryActivateStaminaZeroMechanic(character);
			}
			<>2__current = (object)new WaitForSeconds(0.05f);
			<>1__state = 1;
			return true;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

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

	private static readonly string[] ZeroStaminaFungi = new string[3] { "ShelfShroom", "BounceShroom", "CloudFungus" };

	public static void ResetAllFlags()
	{
		PeakClassModPlugin.scoutActive = false;
		PeakClassModPlugin.medicActive = false;
		PeakClassModPlugin.techPriestActive = false;
		PeakClassModPlugin.mushroomancerActive = false;
		PeakClassModPlugin.greatEpeeActive = false;
		PeakClassModPlugin.rogueActive = false;
		PeakClassModPlugin.generalActive = false;
		PeakClassModPlugin.astronautActive = false;
		PeakClassModPlugin.currentClass = "None";
	}

	public static void ActivateScoutClass()
	{
		ResetAllFlags();
		PeakClassModPlugin.scoutActive = true;
		PeakClassModPlugin.currentClass = "Scout";
	}

	public static void ActivateMedicClass()
	{
		ResetAllFlags();
		PeakClassModPlugin.medicActive = true;
		PeakClassModPlugin.currentClass = "Medic";
	}

	public static void ActivateTechPriestClass()
	{
		ResetAllFlags();
		PeakClassModPlugin.techPriestActive = true;
		PeakClassModPlugin.currentClass = "Tech-Priest";
	}

	public static void ActivateMushroomancerClass()
	{
		ResetAllFlags();
		PeakClassModPlugin.mushroomancerActive = true;
		PeakClassModPlugin.currentClass = "Mushroomancer";
	}

	public static void ActivateGreatEpeeClass()
	{
		ResetAllFlags();
		PeakClassModPlugin.greatEpeeActive = true;
		PeakClassModPlugin.currentClass = "GreatEpee";
	}

	public static void ActivateRogueClass()
	{
		ResetAllFlags();
		PeakClassModPlugin.rogueActive = true;
		PeakClassModPlugin.currentClass = "Rogue";
		if ((Object)(object)Character.localCharacter != (Object)null)
		{
			Character.localCharacter.data.jumpsRemaining = 2;
		}
	}

	public static void ActivateGeneralClass()
	{
		ResetAllFlags();
		PeakClassModPlugin.generalActive = true;
		PeakClassModPlugin.currentClass = "General";
	}

	public static void ActivateAstronautClass()
	{
		ResetAllFlags();
		PeakClassModPlugin.astronautActive = true;
		PeakClassModPlugin.currentClass = "Astronaut";
	}

	public static void DeactivateAllClasses()
	{
		ResetAllFlags();
		if ((Object)(object)Character.localCharacter != (Object)null)
		{
			Character.localCharacter.data.jumpsRemaining = 1;
		}
	}

	public static bool IsScoutActive()
	{
		return PeakClassModPlugin.scoutActive;
	}

	public static bool IsMedicActive()
	{
		return PeakClassModPlugin.medicActive;
	}

	public static bool IsTechPriestActive()
	{
		return PeakClassModPlugin.techPriestActive;
	}

	public static bool IsMushroomancerActive()
	{
		return PeakClassModPlugin.mushroomancerActive;
	}

	public static bool IsGreatEpeeActive()
	{
		return PeakClassModPlugin.greatEpeeActive;
	}

	public static bool IsRogueActive()
	{
		return PeakClassModPlugin.rogueActive;
	}

	public static bool IsGeneralActive()
	{
		return PeakClassModPlugin.generalActive;
	}

	public static bool IsAstronautActive()
	{
		return PeakClassModPlugin.astronautActive;
	}

	[IteratorStateMachine(typeof(<MushroomancerLocalStaminaWatch>d__20))]
	public static IEnumerator MushroomancerLocalStaminaWatch(Character character)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <MushroomancerLocalStaminaWatch>d__20(0)
		{
			character = character
		};
	}

	public static void TryActivateStaminaZeroMechanic(Character character)
	{
		if ((Object)(object)character == (Object)null)
		{
			return;
		}
		PhotonView photonView = ((MonoBehaviourPun)character).photonView;
		if (((photonView != null) ? photonView.Owner : null) == null)
		{
			return;
		}
		int actorNumber = ((MonoBehaviourPun)character).photonView.Owner.ActorNumber;
		if (lastStaminaZeroTime.TryGetValue(actorNumber, out var value) && Time.time - value < 2f)
		{
			return;
		}
		string name = ZeroStaminaFungi[Random.Range(0, ZeroStaminaFungi.Length)];
		Item val = ItemCache.Get(name);
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		ushort itemID = val.itemID;
		if ((Object)(object)character.player != (Object)null && character.player.HasEmptySlot(itemID))
		{
			lastStaminaZeroTime[actorNumber] = Time.time;
			CharacterRefs refs = character.refs;
			if (refs != null)
			{
				CharacterAfflictions afflictions = refs.afflictions;
				if (afflictions != null)
				{
					afflictions.AddStatus((STATUSTYPE)5, 0.02f, false, true);
				}
			}
			ItemSlot val2 = default(ItemSlot);
			character.player.AddItem(itemID, (ItemInstanceData)null, ref val2);
		}
		else
		{
			lastStaminaZeroTime[actorNumber] = Time.time;
		}
	}

	[IteratorStateMachine(typeof(<GreatEpeePermanentEffects>d__22))]
	public static IEnumerator GreatEpeePermanentEffects(Character character)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <GreatEpeePermanentEffects>d__22(0)
		{
			character = character
		};
	}

	[IteratorStateMachine(typeof(<GreatEpeeStaminaRoutine>d__23))]
	public static IEnumerator GreatEpeeStaminaRoutine(Character character)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <GreatEpeeStaminaRoutine>d__23(0)
		{
			character = character
		};
	}
}
public class TechPriestWeightEnforcer : MonoBehaviour
{
	private Character _character;

	private CharacterAfflictions _afflictions;

	private bool _isActive;

	private int _weightIndex;

	private void Start()
	{
		_character = ((Component)this).GetComponent<Character>();
		_isActive = ClassCheckUtil.IsTechPriest(_character);
		_weightIndex = 7;
		if ((Object)(object)_character != (Object)null && _character.refs != null)
		{
			_afflictions = _character.refs.afflictions;
		}
	}

	private void LateUpdate()
	{
		if (!_isActive || !ClassManager.IsTechPriestActive())
		{
			if (Time.frameCount % 120 == 0 && (Object)(object)_character != (Object)null)
			{
				_isActive = ClassCheckUtil.IsTechPriest(_character);
				if (_isActive && _character.refs != null)
				{
					_afflictions = _character.refs.afflictions;
				}
			}
		}
		else if ((Object)(object)_afflictions != (Object)null && _afflictions.currentStatuses[_weightIndex] > 0f)
		{
			_afflictions.currentStatuses[_weightIndex] = 0f;
		}
	}
}
public class AstronautStatHandler : MonoBehaviour
{
	[CompilerGenerated]
	private sealed class <ApplyWindWalkDelayed>d__13 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public AstronautStatHandler <>4__this;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <ApplyWindWalkDelayed>d__13(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(1f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				if (ClassManager.IsAstronautActive() && (Object)(object)<>4__this._character != (Object)null && !<>4__this._character.data.isGrounded)
				{
					<>4__this.TriggerWindWalk();
				}
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	private Character _character;

	private CharacterMovement _movement;

	private Traverse _travMove;

	private float _defJump = 400f;

	private float _defSprintMult = 2f;

	private bool _defaultsCaptured = false;

	private bool _isModified = false;

	private Traverse _jumpImpulseField;

	private Traverse _sprintMultiplierField;

	private Traverse _velocityField;

	private bool _fieldsInitialized = false;

	private void Start()
	{
		_character = ((Component)this).GetComponent<Character>();
		_movement = ((Component)this).GetComponent<CharacterMovement>();
	}

	private void Update()
	{
		if (!((Object)(object)_character == (Object)null) && _character.IsLocal && ClassManager.IsAstronautActive() && _character.input.jumpWasPressed && _character.data.isGrounded)
		{
			((MonoBehaviour)this).StopAllCoroutines();
			((MonoBehaviour)this).StartCoroutine(ApplyWindWalkDelayed());
		}
	}

	[IteratorStateMachine(typeof(<ApplyWindWalkDelayed>d__13))]
	private IEnumerator ApplyWindWalkDelayed()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <ApplyWindWalkDelayed>d__13(0)
		{
			<>4__this = this
		};
	}

	private void TriggerWindWalk()
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Expected O, but got Unknown
		try
		{
			_character.refs.afflictions.AddAffliction((Affliction)new Affliction_LowGravity(3, 3f), true);
		}
		catch (Exception ex)
		{
			ManualLogSource log = PeakClassModPlugin.Log;
			if (log != null)
			{
				log.LogError((object)("[Astronaut] WindWalk Error: " + ex.Message));
			}
		}
	}

	private void InitializeFields()
	{
		if (!_fieldsInitialized && _travMove != null)
		{
			_jumpImpulseField = _travMove.Field("jumpImpulse");
			_sprintMultiplierField = _travMove.Field("sprintMultiplier");
			_velocityField = _travMove.Field("velocity");
			_fieldsInitialized = true;
		}
	}

	private void FixedUpdate()
	{
		//IL_026f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0274: Unknown result type (might be due to invalid IL or missing references)
		//IL_0278: Unknown result type (might be due to invalid IL or missing references)
		//IL_0284: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02be: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_character == (Object)null || !_character.IsLocal || (Object)(object)_movement == (Object)null)
		{
			return;
		}
		if (_travMove == null)
		{
			_travMove = Traverse.Create((object)_movement);
			_fieldsInitialized = false;
		}
		if (!_fieldsInitialized)
		{
			InitializeFields();
		}
		if (ClassManager.IsAstronautActive())
		{
			if (!_defaultsCaptured && !_isModified)
			{
				Traverse jumpImpulseField = _jumpImpulseField;
				float? num = ((jumpImpulseField != null) ? new float?(jumpImpulseField.GetValue<float>()) : null);
				if (num.HasValue && num.Value > 0f)
				{
					_defJump = num.Value;
				}
				Traverse sprintMultiplierField = _sprintMultiplierField;
				float? num2 = ((sprintMultiplierField != null) ? new float?(sprintMultiplierField.GetValue<float>()) : null);
				if (num2.HasValue)
				{
					_defSprintMult = num2.Value;
				}
				_defaultsCaptured = true;
			}
			Traverse jumpImpulseField2 = _jumpImpulseField;
			if (jumpImpulseField2 != null)
			{
				jumpImpulseField2.SetValue((object)1200f);
			}
			Traverse sprintMultiplierField2 = _sprintMultiplierField;
			if (sprintMultiplierField2 != null)
			{
				sprintMultiplierField2.SetValue((object)1.7f);
			}
			if (_character.data.isGrounded)
			{
				List<Affliction> afflictionList = _character.refs.afflictions.afflictionList;
				bool flag = false;
				for (int i = 0; i < afflictionList.Count; i++)
				{
					if (afflictionList[i] is Affliction_LowGravity)
					{
						flag = true;
						break;
					}
				}
				if (flag)
				{
					for (int num3 = afflictionList.Count - 1; num3 >= 0; num3--)
					{
						if (afflictionList[num3] is Affliction_LowGravity)
						{
							_character.refs.afflictions.RemoveAffliction(afflictionList[num3], false, true);
						}
					}
				}
			}
			if (!_character.data.isSprinting && _velocityField != null && _velocityField.FieldExists())
			{
				Vector3 value = _velocityField.GetValue<Vector3>();
				Vector3 val = default(Vector3);
				((Vector3)(ref val))..ctor(value.x, 0f, value.z);
				if (((Vector3)(ref val)).magnitude > 1.6f)
				{
					Vector3 val2 = ((Vector3)(ref val)).normalized * 1.6f;
					_velocityField.SetValue((object)new Vector3(val2.x, value.y, val2.z));
				}
			}
			_isModified = true;
		}
		else if (_isModified)
		{
			Traverse jumpImpulseField3 = _jumpImpulseField;
			if (jumpImpulseField3 != null)
			{
				jumpImpulseField3.SetValue((object)_defJump);
			}
			Traverse sprintMultiplierField3 = _sprintMultiplierField;
			if (sprintMultiplierField3 != null)
			{
				sprintMultiplierField3.SetValue((object)_defSprintMult);
			}
			_isModified = false;
			_defaultsCaptured = false;
		}
	}
}
public class MedicStatHandler : MonoBehaviour
{
	private Character _character;

	private ClassModNetwork _network;

	private CharacterAfflictions _afflictions;

	private int _healsRemaining = 10;

	private float _lastHealTime = 0f;

	private void Start()
	{
		_character = ((Component)this).GetComponent<Character>();
		_network = ((Component)this).GetComponent<ClassModNetwork>();
		_healsRemaining = 10;
		if ((Object)(object)_character != (Object)null && _character.refs != null)
		{
			_afflictions = _character.refs.afflictions;
		}
	}

	private void Update()
	{
		if ((Object)(object)_character == (Object)null || !_character.IsLocal)
		{
			return;
		}
		if (ClassManager.IsMedicActive())
		{
			if (Input.GetKeyDown((KeyCode)104) && Time.time - _lastHealTime > 1f)
			{
				TrySelfHeal();
			}
		}
		else if (_healsRemaining < 10)
		{
			_healsRemaining = 10;
		}
	}

	private void TrySelfHeal()
	{
		if (_healsRemaining <= 0)
		{
			return;
		}
		if ((Object)(object)_afflictions == (Object)null && _character.refs != null)
		{
			_afflictions = _character.refs.afflictions;
		}
		if ((Object)(object)_afflictions != (Object)null && _afflictions.GetCurrentStatus((STATUSTYPE)0) > 0f)
		{
			_healsRemaining--;
			_lastHealTime = Time.time;
			_afflictions.SubtractStatus((STATUSTYPE)0, 0.1f, false, false);
			if ((Object)(object)_network != (Object)null && (Object)(object)((MonoBehaviourPun)_network).photonView != (Object)null)
			{
				((MonoBehaviourPun)_network).photonView.RPC("ShowMedicHealEffectRPC", (RpcTarget)0, new object[1] { _healsRemaining });
			}
		}
	}
}
[HarmonyPatch(typeof(CharacterCustomization), "SetCharacterHat")]
public class SetHat_Patch
{
	private static void Postfix(int index)
	{
		CustomizationOption[] array = Singleton<Customization>.Instance?.hats;
		object obj;
		if (array == null || index < 0 || index >= array.Length)
		{
			obj = "Unknown";
		}
		else
		{
			CustomizationOption obj2 = array[index];
			obj = ((obj2 != null) ? ((Object)obj2).name : null);
		}
		string text = (string)obj;
		HatUtils.SetLastLocalHatName(text);
		if (index == 12)
		{
			ClassManager.ActivateScoutClass();
		}
		else if (text == "Hat_Medic" || text == "MedicHelmet")
		{
			ClassManager.ActivateMedicClass();
		}
		else
		{
			switch (text)
			{
			case "Hat_Crab":
				ClassManager.ActivateTechPriestClass();
				break;
			case "Hat_Mushroom":
				ClassManager.ActivateMushroomancerClass();
				break;
			case "Hat_Propeller":
				ClassManager.ActivateGreatEpeeClass();
				break;
			case "Hat_NinjaHeadband":
				ClassManager.ActivateRogueClass();
				break;
			default:
				if (!(text == "Hat_Captain"))
				{
					if (text == "Hat_Astronaut")
					{
						ClassManager.ActivateAstronautClass();
					}
					else
					{
						ClassManager.DeactivateAllClasses();
					}
					break;
				}
				goto case "Hat_Bandana";
			case "Hat_Bandana":
				ClassManager.ActivateGeneralClass();
				break;
			}
		}
		if ((Object)(object)Character.localCharacter != (Object)null && (Object)(object)GUIManager.instance?.bar != (Object)null)
		{
			GUIManager.instance.bar.ChangeBar();
		}
	}
}
[HarmonyPatch(typeof(RunManager), "StartRun")]
public class RunManager_StartRun_Patch
{
	[CompilerGenerated]
	private sealed class <AddEffectsDelayed>d__1 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		private Character <lc>5__1;

		private float <currentCurse>5__2;

		private float <currentCurse>5__3;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <AddEffectsDelayed>d__1(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<lc>5__1 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>2__current = (object)new WaitForSeconds(1.5f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<lc>5__1 = Character.localCharacter;
				if ((Object)(object)<lc>5__1 == (Object)null)
				{
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 2;
					return true;
				}
				break;
			case 2:
				<>1__state = -1;
				<lc>5__1 = Character.localCharacter;
				if ((Object)(object)<lc>5__1 == (Object)null)
				{
					return false;
				}
				break;
			}
			if (ClassCheckUtil.IsMushroom(<lc>5__1))
			{
				ClassManager.ActivateMushroomancerClass();
				((MonoBehaviour)<lc>5__1).StartCoroutine(ClassManager.MushroomancerLocalStaminaWatch(<lc>5__1));
			}
			else if (ClassCheckUtil.IsGeneral(<lc>5__1))
			{
				ClassManager.ActivateGeneralClass();
				CharacterRefs refs = <lc>5__1.refs;
				float? obj;
				if (refs == null)
				{
					obj = null;
				}
				else
				{
					CharacterAfflictions afflictions = refs.afflictions;
					obj = ((afflictions != null) ? new float?(afflictions.GetCurrentStatus((STATUSTYPE)5)) : null);
				}
				float? num = obj;
				<currentCurse>5__2 = num.GetValueOrDefault();
				if (<currentCurse>5__2 < 0.3f)
				{
					CharacterRefs refs2 = <lc>5__1.refs;
					if (refs2 != null)
					{
						CharacterAfflictions afflictions2 = refs2.afflictions;
						if (afflictions2 != null)
						{
							afflictions2.SetStatus((STATUSTYPE)5, 0.35f, true);
						}
					}
				}
			}
			else if (ClassCheckUtil.IsGreatEpeeHat(<lc>5__1))
			{
				ClassManager.ActivateGreatEpeeClass();
				((MonoBehaviour)<lc>5__1).StartCoroutine(ClassManager.GreatEpeePermanentEffects(<lc>5__1));
				((MonoBehaviour)<lc>5__1).StartCoroutine(ClassManager.GreatEpeeStaminaRoutine(<lc>5__1));
			}
			else if (ClassCheckUtil.IsMedicHat(<lc>5__1))
			{
				ClassManager.ActivateMedicClass();
				CharacterRefs refs3 = <lc>5__1.refs;
				float? obj2;
				if (refs3 == null)
				{
					obj2 = null;
				}
				else
				{
					CharacterAfflictions afflictions3 = refs3.afflictions;
					obj2 = ((afflictions3 != null) ? new float?(afflictions3.GetCurrentStatus((STATUSTYPE)5)) : null);
				}
				float? num = obj2;
				<currentCurse>5__3 = num.GetValueOrDefault();
				if (<currentCurse>5__3 < 0.3f)
				{
					CharacterRefs refs4 = <lc>5__1.refs;
					if (refs4 != null)
					{
						CharacterAfflictions afflictions4 = refs4.afflictions;
						if (afflictions4 != null)
						{
							afflictions4.SetStatus((STATUSTYPE)5, 0.15f, true);
						}
					}
				}
			}
			else if (ClassCheckUtil.IsAstronaut(<lc>5__1))
			{
				ClassManager.ActivateAstronautClass();
			}
			else if (ClassCheckUtil.IsTechPriest(<lc>5__1))
			{
				ClassManager.ActivateTechPriestClass();
			}
			else if (ClassCheckUtil.IsRogueHat(<lc>5__1))
			{
				ClassManager.ActivateRogueClass();
			}
			else if (HatUtils.HasHat(<lc>5__1, "Hat_Scout"))
			{
				ClassManager.ActivateScoutClass();
			}
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	private static void Postfix()
	{
		((MonoBehaviour)PeakClassModPlugin.Instance).StartCoroutine(AddEffectsDelayed());
	}

	[IteratorStateMachine(typeof(<AddEffectsDelayed>d__1))]
	public static IEnumerator AddEffectsDelayed()
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <AddEffectsDelayed>d__1(0);
	}
}
[HarmonyPatch(typeof(CharacterAfflictions), "AddStatus")]
public class General_AddStatus_Patch
{
	private static bool Prefix(CharacterAfflictions __instance, STATUSTYPE statusType, ref float amount)
	{
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Invalid comparison between Unknown and I4
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Invalid comparison between Unknown and I4
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Invalid comparison between Unknown and I4
		//IL_004a: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Invalid comparison between Unknown and I4
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c9: Invalid comparison between Unknown and I4
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Invalid comparison between Unknown and I4
		Character character = __instance.character;
		if ((Object)(object)character == (Object)null)
		{
			return true;
		}
		if (character.IsLocal)
		{
			if (ClassManager.IsAstronautActive() && (int)statusType == 1)
			{
				amount *= 1.3f;
			}
			if (ClassManager.IsScoutActive() && (int)statusType == 1)
			{
				amount *= 1.7f;
			}
			if (ClassManager.IsGeneralActive() && (int)statusType == 1)
			{
				amount *= 2f;
			}
		}
		if ((int)statusType == 1 && ClassCheckUtil.IsTechPriest(character) && ClassManager.IsTechPriestActive())
		{
			amount = 0f;
		}
		if ((int)statusType == 7 && ClassCheckUtil.IsTechPriest(character) && ClassManager.IsTechPriestActive())
		{
			amount = 0f;
			return false;
		}
		if ((int)statusType == 3 && ClassCheckUtil.IsMushroom(character))
		{
			amount = 0f;
		}
		return true;
	}
}
[HarmonyPatch(typeof(BarAffliction), "ChangeAffliction")]
public class BarAffliction_Patch
{
	private static void Postfix(BarAffliction __instance)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Invalid comparison between Unknown and I4
		if ((Object)(object)Character.localCharacter == (Object)null || (int)__instance.afflictionType != 7)
		{
			return;
		}
		if (ClassManager.IsScoutActive())
		{
			__instance.size *= 0.5f;
		}
		if (ClassManager.IsGeneralActive())
		{
			__instance.size *= 2f;
		}
		if (ClassManager.IsTechPriestActive() && ClassCheckUtil.IsTechPriest(Character.localCharacter))
		{
			__instance.size = 0f;
			Image component = ((Component)__instance).GetComponent<Image>();
			if ((Object)(object)component != (Object)null)
			{
				((Behaviour)component).enabled = false;
			}
		}
	}
}
[HarmonyPatch(typeof(CharacterAfflictions), "get_statusSum")]
public class StatusSum_Patch
{
	private static void Postfix(CharacterAfflictions __instance, ref float __result)
	{
		if (!((Object)(object)__instance.character == (Object)null) && __instance.character.IsLocal)
		{
			float currentStatus = __instance.GetCurrentStatus((STATUSTYPE)7);
			if (ClassManager.IsScoutActive())
			{
				__result = __result - currentStatus + currentStatus * 0.5f;
			}
			if (ClassManager.IsGeneralActive())
			{
				__result = __result - currentStatus + currentStatus * 2f;
			}
			if (ClassManager.IsTechPriestActive() && ClassCheckUtil.IsTechPriest(__instance.character))
			{
				__result -= currentStatus;
			}
		}
	}
}
[HarmonyPatch(typeof(CharacterAfflictions), "UpdateNormalStatuses")]
public class UpdateStatus_TechPriest_Patch
{
	private static void Postfix(CharacterAfflictions __instance)
	{
		if (ClassCheckUtil.IsTechPriest(__instance.character) && ClassManager.IsTechPriestActive())
		{
			__instance.currentStatuses[1] = 0f;
			__instance.currentStatuses[7] = 0f;
		}
	}
}
internal static class TechPriestBlocker
{
	private static Dictionary<int, bool> _blockCache = new Dictionary<int, bool>();

	public static bool ShouldBlockItem(Item item)
	{
		if ((Object)(object)item == (Object)null)
		{
			return false;
		}
		int instanceID = ((Object)item).GetInstanceID();
		if (_blockCache.TryGetValue(instanceID, out var value))
		{
			return value;
		}
		bool flag = false;
		if ((Object)(object)((Component)item).GetComponent<Action_RestoreHunger>() != (Object)null || (Object)(object)((Component)item).GetComponent<Action_GiveExtraStamina>() != (Object)null)
		{
			flag = true;
		}
		if (!flag)
		{
			string text = ((Object)item).name.Replace("(Clone)", "").Trim().ToLower();
			if (text.Contains("bandage") || text.Contains("firstaid") || text.Contains("medkit") || text.Contains("cure") || text.Contains("marshmallow"))
			{
				flag = true;
			}
		}
		if (!flag)
		{
			MonoBehaviour[] components = ((Component)item).GetComponents<MonoBehaviour>();
			foreach (MonoBehaviour val in components)
			{
				if (!((Object)(object)val == (Object)null))
				{
					string text2 = ((object)val).GetType().Name.ToLower();
					if (text2.Contains("heal") || text2.Contains("cure") || text2.Contains("medicine") || text2.Contains("restorehealth"))
					{
						flag = true;
						break;
					}
				}
			}
		}
		_blockCache[instanceID] = flag;
		return flag;
	}

	public static void ClearCache()
	{
		_blockCache.Clear();
	}
}
[HarmonyPatch(typeof(Item), "StartUsePrimary")]
public class TechPriestConsumablePatch1
{
	private static bool Prefix(Item __instance)
	{
		if (ClassCheckUtil.IsTechPriest((__instance != null) ? __instance.holderCharacter : null))
		{
			if (TechPriestBlocker.ShouldBlockItem(__instance))
			{
				return false;
			}
			Action_ApplyAffliction component = ((Component)__instance).GetComponent<Action_ApplyAffliction>();
			if ((Object)(object)component != (Object)null && component.affliction != null && ((object)component.affliction).GetType().Name.Contains("FasterBoi"))
			{
				return false;
			}
		}
		return true;
	}
}
[HarmonyPatch(typeof(Item), "StartUseSecondary")]
public class TechPriestConsumablePatch2
{
	private static bool Prefix(Item __instance)
	{
		if (ClassCheckUtil.IsTechPriest((__instance != null) ? __instance.holderCharacter : null))
		{
			if (TechPriestBlocker.ShouldBlockItem(__instance))
			{
				return false;
			}
			Action_ApplyAffliction component = ((Component)__instance).GetComponent<Action_ApplyAffliction>();
			if ((Object)(object)component != (Object)null && component.affliction != null && ((object)component.affliction).GetType().Name.Contains("FasterBoi"))
			{
				return false;
			}
		}
		return true;
	}
}
[HarmonyPatch(typeof(Affliction_FasterBoi), "OnApplied")]
public class TechPriestFasterBoiBlock
{
	private static bool Prefix(Affliction_FasterBoi __instance)
	{
		return !ClassCheckUtil.IsTechPriest(((Affliction)__instance).character);
	}
}
[HarmonyPatch(typeof(Character), "AddExtraStamina")]
public class TechPriestStaminaPatch1
{
	private static bool Prefix(Character __instance)
	{
		return !ClassCheckUtil.IsTechPriest(__instance);
	}
}
[HarmonyPatch(typeof(Affliction_InfiniteStamina), "OnApplied")]
public class TechPriestStaminaPatch2
{
	private static bool Prefix(Affliction_InfiniteStamina __instance)
	{
		return !ClassCheckUtil.IsTechPriest(((Affliction)__instance).character);
	}
}
[HarmonyPatch(typeof(Affliction_InfiniteStamina), "UpdateEffect")]
public class TechPriestStaminaPatch2_Update
{
	private static bool Prefix(Affliction_InfiniteStamina __instance)
	{
		return !ClassCheckUtil.IsTechPriest(((Affliction)__instance).character);
	}
}
[HarmonyPatch(typeof(Affliction_PoisonOverTime), "OnApplied")]
public class PoisonPatch
{
	private static bool Prefix(Affliction_PoisonOverTime __instance)
	{
		return !ClassCheckUtil.IsMushroom(((Affliction)__instance).character);
	}
}
[HarmonyPatch(typeof(CharacterMovement), "EvaluateGroundChecks")]
public class RogueJumpPatch
{
	private static void Postfix(CharacterMovement __instance)
	{
		Character component = ((Component)__instance).GetComponent<Character>();
		if ((Object)(object)component != (Object)null && component.IsLocal && PeakClassModPlugin.rogueActive)
		{
			component.data.jumpsRemaining = 2;
		}
	}
}
[HarmonyPatch(typeof(CharacterMovement), "TryToJump")]
public class RogueJumpRPCPatch
{
	private static bool Prefix(CharacterMovement __instance)
	{
		Character component = ((Component)__instance).GetComponent<Character>();
		if ((Object)(object)component != (Object)null && component.IsLocal && PeakClassModPlugin.rogueActive && component.data.jumpsRemaining > 0 && component.data.currentStamina > 0.005f)
		{
			CharacterData data = component.data;
			data.jumpsRemaining--;
			component.data.chargingJump = true;
			component.refs.view.RPC("JumpRpc", (RpcTarget)0, new object[1] { false });
			return false;
		}
		return true;
	}
}
[HarmonyPatch(typeof(Character), "UseStamina")]
public class Character_UseStamina_Patch
{
	private static void Prefix(Character __instance, ref float usage)
	{
		if (ClassManager.IsScoutActive())
		{
			usage *= 0.8f;
		}
		if (ClassManager.IsRogueActive())
		{
			usage *= 2f;
		}
	}
}
[HarmonyPatch(typeof(Character), "ShowMedicHealEffectRPC")]
public class MedicRPC_Patch
{
	private static void Postfix()
	{
	}
}