Decompiled source of PeakClassModUPDATE v1.2.1

Mod_Peak_2026.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Peak;
using Peak.Afflictions;
using PeakClassMod.Handlers;
using PeakClassMod.Patches;
using PeakClassMod.Utils;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.UI;
using Zorro.Core;
using Zorro.Core.Serizalization;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Mod_Peak_2026")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("Mod_Peak_2026")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("6f7cd0cf-eafa-4617-93d2-7739adc5a0a0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace PeakClassMod
{
	public static class ClassBalance
	{
		public const string BLOWGUN = "HealingDart Variant";

		public const float GOBELIN_SIZE = 0.5f;

		public const float GOBELIN_CURSE_PER_SHOT = 0.05f;

		public const float ASTRONAUT_JUMP_IMPULSE = 1200f;

		public const float ASTRONAUT_SPRINT_MULT = 1.7f;

		public const float ASTRONAUT_HUNGER_MULT = 1.3f;

		public const float ASTRONAUT_MAX_WALK_SPEED = 1.6f;

		public const float ASTRONAUT_LOW_GRAV_DURATION = 1.8f;

		public const float GENERAL_CURSE_MIN = 0.35f;

		public const float GENERAL_HUNGER_MULT = 2f;

		public const float GENERAL_WEIGHT_MULT = 2f;

		public const float GENERAL_SPEED_MULT = 0.75f;

		public const float MEDIC_CURSE = 0.15f;

		public const int MEDIC_MAX_HEALS = 10;

		public const float MEDIC_HEAL_AMOUNT = 0.1f;

		public const float MEDIC_HEAL_COOLDOWN = 1f;

		public const float SCOUT_STAMINA_MULT = 0.8f;

		public const float SCOUT_HUNGER_MULT = 1.7f;

		public const float SCOUT_WEIGHT_MULT = 0.5f;

		public const float ROGUE_STAMINA_MULT = 1.7f;

		public const int ROGUE_EXTRA_JUMPS = 2;

		public const float GREATEPEE_SLEEP_MIN = 30f;

		public const float GREATEPEE_SLEEP_MAX = 60f;

		public const float GREATEPEE_EFFECT_DURATION = 99999f;

		public const float MUSHROOM_STAMINA_COOLDOWN = 10f;

		public const float MUSHROOM_CURSE_AMOUNT = 0.02f;

		public const float ITEM_REQUEST_DELAY = 0.3f;

		public const float ITEM_GIVE_COOLDOWN = 2f;

		public const float ITEM_CACHE_DURATION = 300f;

		public const float SIZE_CHECK_INTERVAL = 0.5f;

		public const float TECH_PRIEST_HUNGER_MULT = 1.5f;

		public const float WOLF_CLIMB_SPEED_MULT = 1.3f;

		public const float WOLF_SPRINT_SPEED_MULT = 1.3f;

		public const float WOLF_HUNGER_MULT = 1.3f;

		public const float WOLF_EFFECT_TICK_INTERVAL = 3f;

		public const float COOK_HUNGER_MULT = 1.3f;

		public const float COOK_STAMINA_BONUS = 0.25f;

		public const float JESTER_COOLDOWN = 60f;

		public const float JESTER_COIN_COOLDOWN = 120f;

		public const float JESTER_COIN_BUFF_DURATION = 7f;

		public const float JESTER_DAMAGE_TAKEN_MULT = 1.2f;

		public const float JESTER_ROLL_STAMINA_COST = 0.4f;

		public const float JESTER_ROLL_HUNGER_COST = 0.1f;
	}
	public static class ClassManager
	{
		private static readonly Dictionary<int, float> lastStaminaZeroTime = new Dictionary<int, float>();

		private static Coroutine _mushroomCoroutine;

		private static Coroutine _greatEpeeEffectsCoroutine;

		private static Coroutine _greatEpeeStaminaCoroutine;

		private static bool _greatEpeeNeedsRecovery = false;

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

		public static void ResetAllFlags()
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			Character localCharacter = Character.localCharacter;
			if ((Object)(object)localCharacter != (Object)null)
			{
				if (_mushroomCoroutine != null)
				{
					((MonoBehaviour)localCharacter).StopCoroutine(_mushroomCoroutine);
					_mushroomCoroutine = null;
				}
				if (_greatEpeeEffectsCoroutine != null)
				{
					((MonoBehaviour)localCharacter).StopCoroutine(_greatEpeeEffectsCoroutine);
					_greatEpeeEffectsCoroutine = null;
				}
				if (_greatEpeeStaminaCoroutine != null)
				{
					((MonoBehaviour)localCharacter).StopCoroutine(_greatEpeeStaminaCoroutine);
					_greatEpeeStaminaCoroutine = null;
				}
				RemoveFasterBoi(localCharacter);
				((Component)localCharacter).transform.localScale = Vector3.one;
				if ((Object)(object)localCharacter.data != (Object)null)
				{
					localCharacter.data.extraJumps = 0;
					localCharacter.data.jumpsRemaining = 1;
				}
				if ((Object)(object)localCharacter.refs?.afflictions != (Object)null)
				{
					localCharacter.refs.afflictions.totalExtraJumps = 0;
				}
			}
			_greatEpeeNeedsRecovery = false;
			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.gobelinActive = false;
			PeakClassModPlugin.wolfActive = false;
			PeakClassModPlugin.cookActive = false;
			PeakClassModPlugin.jesterActive = 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 ActivateGobelinClass()
		{
			ResetAllFlags();
			PeakClassModPlugin.gobelinActive = true;
			PeakClassModPlugin.currentClass = "Gobelin";
		}

		public static void ActivateWolfClass()
		{
			ResetAllFlags();
			PeakClassModPlugin.wolfActive = true;
			PeakClassModPlugin.currentClass = "Wolf";
		}

		public static void ActivateCookClass()
		{
			ResetAllFlags();
			PeakClassModPlugin.cookActive = true;
			PeakClassModPlugin.currentClass = "Cook";
		}

		public static void ActivateJesterClass()
		{
			ResetAllFlags();
			PeakClassModPlugin.jesterActive = true;
			PeakClassModPlugin.currentClass = "Jester";
		}

		public static void DeactivateAllClasses()
		{
			ResetAllFlags();
			if ((Object)(object)Character.localCharacter != (Object)null)
			{
				if ((Object)(object)Character.localCharacter.data != (Object)null)
				{
					Character.localCharacter.data.extraJumps = 0;
					Character.localCharacter.data.jumpsRemaining = 1;
				}
				if ((Object)(object)Character.localCharacter.refs?.afflictions != (Object)null)
				{
					Character.localCharacter.refs.afflictions.totalExtraJumps = 0;
				}
			}
		}

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

		public static bool IsGobelinActive()
		{
			return PeakClassModPlugin.gobelinActive;
		}

		public static bool IsWolfActive()
		{
			return PeakClassModPlugin.wolfActive;
		}

		public static bool IsCookActive()
		{
			return PeakClassModPlugin.cookActive;
		}

		public static bool IsJesterActive()
		{
			return PeakClassModPlugin.jesterActive;
		}

		public static void StartMushroomancerWatch(Character character)
		{
			if ((Object)(object)character != (Object)null && _mushroomCoroutine == null)
			{
				_mushroomCoroutine = ((MonoBehaviour)character).StartCoroutine(MushroomancerLocalStaminaWatch(character));
			}
		}

		public static void StartGreatEpeeRoutines(Character character)
		{
			if ((Object)(object)character != (Object)null)
			{
				if (_greatEpeeEffectsCoroutine == null)
				{
					_greatEpeeEffectsCoroutine = ((MonoBehaviour)character).StartCoroutine(GreatEpeePermanentEffects(character));
				}
				if (_greatEpeeStaminaCoroutine == null)
				{
					_greatEpeeStaminaCoroutine = ((MonoBehaviour)character).StartCoroutine(GreatEpeeStaminaRoutine(character));
				}
			}
		}

		public static ushort GetFungusItemID(string fungusName)
		{
			Item val = ItemCache.Get(fungusName);
			if ((Object)(object)val != (Object)null)
			{
				ushort databaseID = ItemCache.GetDatabaseID(val);
				if (databaseID > 0)
				{
					return databaseID;
				}
			}
			if (ItemDatabase.TryGetItem(fungusName, ref val) && (Object)(object)val != (Object)null)
			{
				ushort databaseID2 = ItemCache.GetDatabaseID(val);
				if (databaseID2 > 0)
				{
					return databaseID2;
				}
			}
			ItemDatabase instance = SingletonAsset<ItemDatabase>.Instance;
			if ((Object)(object)instance != (Object)null && instance.itemLookup != null)
			{
				foreach (KeyValuePair<ushort, Item> item in instance.itemLookup)
				{
					if ((Object)(object)item.Value != (Object)null && ((Object)item.Value).name.IndexOf(fungusName, StringComparison.OrdinalIgnoreCase) >= 0)
					{
						return item.Key;
					}
				}
			}
			Item[] array = Resources.FindObjectsOfTypeAll<Item>();
			foreach (Item val2 in array)
			{
				if ((Object)(object)val2 != (Object)null && ((Object)val2).name.IndexOf(fungusName, StringComparison.OrdinalIgnoreCase) >= 0)
				{
					ushort databaseID3 = ItemCache.GetDatabaseID(val2);
					if (databaseID3 > 0)
					{
						return databaseID3;
					}
					return val2.itemID;
				}
			}
			return 0;
		}

		public static IEnumerator MushroomancerLocalStaminaWatch(Character character)
		{
			yield return (object)new WaitForSeconds(3f);
			bool wasAboveThreshold = false;
			float gracePeriodEnd = Time.time + 10f;
			while ((Object)(object)character != (Object)null && PeakClassModPlugin.mushroomancerActive && character.IsLocal)
			{
				if (character.inAirport)
				{
					wasAboveThreshold = false;
					gracePeriodEnd = Time.time + 10f;
					yield return (object)new WaitForSeconds(0.5f);
					continue;
				}
				if (Time.time < gracePeriodEnd || Time.timeSinceLevelLoad < 10f)
				{
					wasAboveThreshold = false;
					yield return (object)new WaitForSeconds(0.5f);
					continue;
				}
				bool num = (Object)(object)character.data != (Object)null && (character.data.passedOut || character.data.fullyPassedOut || character.data.dead);
				float num2 = (((Object)(object)character.data != (Object)null) ? character.data.currentStamina : 0f);
				if (num2 > 0.6f)
				{
					wasAboveThreshold = true;
				}
				if (!num && wasAboveThreshold && num2 <= 0.05f)
				{
					wasAboveThreshold = false;
					TryActivateStaminaZeroMechanic(character);
				}
				yield return (object)new WaitForSeconds(0.1f);
			}
		}

		public static void TryActivateStaminaZeroMechanic(Character character)
		{
			if ((Object)(object)character == (Object)null || character.inAirport || Time.timeSinceLevelLoad < 10f)
			{
				return;
			}
			PhotonView photonView = ((MonoBehaviourPun)character).photonView;
			int key = ((((photonView != null) ? photonView.Owner : null) != null) ? ((MonoBehaviourPun)character).photonView.Owner.ActorNumber : 0);
			if (lastStaminaZeroTime.TryGetValue(key, out var value) && Time.time - value < 2.5f)
			{
				return;
			}
			lastStaminaZeroTime[key] = Time.time;
			CharacterRefs refs = character.refs;
			if (refs != null)
			{
				CharacterAfflictions afflictions = refs.afflictions;
				if (afflictions != null)
				{
					afflictions.AddStatus((STATUSTYPE)5, 0.02f, false, true, true, false);
				}
			}
			string text = ZeroStaminaFungi[Random.Range(0, ZeroStaminaFungi.Length)];
			ushort fungusItemID = GetFungusItemID(text);
			if (fungusItemID == 0)
			{
				ManualLogSource log = PeakClassModPlugin.Log;
				if (log != null)
				{
					log.LogWarning((object)("[Mushroomancer] Could not resolve item ID for fungus: " + text));
				}
			}
			else
			{
				((MonoBehaviour)character).StartCoroutine(MushroomancerGiveItemDelayed(character, fungusItemID));
			}
		}

		private static IEnumerator MushroomancerGiveItemDelayed(Character character, ushort itemId)
		{
			if ((Object)(object)character == (Object)null || character.inAirport)
			{
				yield break;
			}
			float timeout = 2f;
			while ((Object)(object)character != (Object)null && (Object)(object)character.data != (Object)null && (!character.data.isGrounded || character.data.isSprinting) && timeout > 0f)
			{
				timeout -= 0.1f;
				yield return (object)new WaitForSeconds(0.1f);
			}
			if (!((Object)(object)((character != null) ? character.player : null) != (Object)null) || character.player.itemSlots == null)
			{
				yield break;
			}
			bool flag = false;
			int num = Mathf.Min(3, character.player.itemSlots.Length);
			for (int i = 0; i < num; i++)
			{
				if (character.player.itemSlots[i] != null && character.player.itemSlots[i].IsEmpty())
				{
					flag = true;
					break;
				}
			}
			if (flag && character.player.HasEmptySlot(itemId))
			{
				ClassModNetwork.GiveItemNetworkSafe(character, itemId);
				yield break;
			}
			try
			{
				Vector3 val = ((Component)character).transform.position + ((Component)character).transform.forward * 0.8f + Vector3.up * 0.2f;
				Item val2 = default(Item);
				ItemDatabase.TryGetItem(itemId, ref val2);
				if ((Object)(object)val2 != (Object)null)
				{
					PhotonNetwork.InstantiateRoomObject(((Object)((Component)val2).gameObject).name, val, Random.rotation, (byte)0, (object[])null);
				}
			}
			catch
			{
			}
		}

		public static void RemoveFasterBoi(Character character)
		{
			try
			{
				List<Affliction> list = character.refs?.afflictions?.afflictionList;
				if (list == null)
				{
					return;
				}
				for (int num = list.Count - 1; num >= 0; num--)
				{
					if (list[num] != null && ((object)list[num]).GetType().Name.Contains("FasterBoi"))
					{
						list.RemoveAt(num);
					}
				}
			}
			catch
			{
			}
		}

		public static IEnumerator GreatEpeePermanentEffects(Character character)
		{
			while (PeakClassModPlugin.greatEpeeActive && (Object)(object)character != (Object)null && character.IsLocal)
			{
				CharacterRefs refs = character.refs;
				float? obj;
				if (refs == null)
				{
					obj = null;
				}
				else
				{
					CharacterAfflictions afflictions = refs.afflictions;
					obj = ((afflictions != null) ? new float?(afflictions.GetCurrentStatus((STATUSTYPE)6)) : ((float?)null));
				}
				float? num = obj;
				float valueOrDefault = num.GetValueOrDefault();
				if (!_greatEpeeNeedsRecovery && (!((Object)(object)character.data != (Object)null) || (!character.data.passedOut && !character.data.fullyPassedOut)) && !(valueOrDefault > 0.2f))
				{
					bool flag = false;
					List<Affliction> list = character.refs?.afflictions?.afflictionList;
					if (list != null)
					{
						for (int i = 0; i < list.Count; i++)
						{
							if (list[i] != null && ((object)list[i]).GetType().Name.Contains("FasterBoi"))
							{
								flag = true;
								break;
							}
						}
					}
					if (!flag && (Object)(object)character.refs?.afflictions != (Object)null)
					{
						character.refs.afflictions.AddAffliction((Affliction)new Affliction_FasterBoi
						{
							moveSpeedMod = 0.5f,
							climbSpeedMod = 1f,
							totalTime = 99999f
						}, false);
					}
				}
				else
				{
					RemoveFasterBoi(character);
				}
				yield return (object)new WaitForSeconds(0.4f);
			}
		}

		public static IEnumerator GreatEpeeStaminaRoutine(Character character)
		{
			yield return (object)new WaitForSeconds(5f);
			while (PeakClassModPlugin.greatEpeeActive && (Object)(object)character != (Object)null && character.IsLocal)
			{
				float num = Random.Range(30f, 60f);
				yield return (object)new WaitForSeconds(num);
				if (!PeakClassModPlugin.greatEpeeActive || (Object)(object)character == (Object)null || (Object)(object)character.refs?.afflictions == (Object)null)
				{
					break;
				}
				_greatEpeeNeedsRecovery = true;
				RemoveFasterBoi(character);
				character.refs.afflictions.AddStatus((STATUSTYPE)6, 1f, false, true, true, false);
				yield return (object)new WaitForSeconds(0.5f);
				if ((Object)(object)character != (Object)null && (Object)(object)character.data != (Object)null && !character.data.dead)
				{
					character.data.passedOut = true;
					character.data.fullyPassedOut = true;
				}
				while ((Object)(object)character != (Object)null && (Object)(object)character.data != (Object)null && (character.data.passedOut || character.data.fullyPassedOut))
				{
					yield return (object)new WaitForSeconds(0.5f);
				}
				while ((Object)(object)character != (Object)null && (Object)(object)character.refs?.afflictions != (Object)null && character.refs.afflictions.GetCurrentStatus((STATUSTYPE)6) > 0.2f)
				{
					yield return (object)new WaitForSeconds(0.2f);
				}
				_greatEpeeNeedsRecovery = false;
				yield return (object)new WaitForSeconds(1f);
			}
		}
	}
	[BepInPlugin("com.peakmod.classmod", "PEAK Class Mod", "5.3.0")]
	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 bool gobelinActive = false;

		public static bool wolfActive = false;

		public static bool cookActive = false;

		public static bool jesterActive = 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_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: 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 5.3.0 loaded.");
			}
		}

		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 != (Object)null && (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;
			}
			if (hatName.IndexOf("Mushroom", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				for (int i = 0; i < 3; i++)
				{
					list.Add(StartBerries[Random.Range(0, StartBerries.Length)]);
				}
			}
			else if (hatName.IndexOf("Medic", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				list.Add("FirstAidKit");
				list.Add("Cure-All");
			}
			else if (hatName.IndexOf("Crab", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				list.Add("ChainShooter");
				list.Add("ChainShooter");
			}
			else if (hatName.IndexOf("Ninja", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				list.Add("RopeSpool");
				list.Add("RopeSpool");
			}
			else if (hatName.IndexOf("Astronaut", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				list.Add("BalloonBunch");
			}
			else if (hatName.IndexOf("Midsummer", StringComparison.OrdinalIgnoreCase) >= 0 || hatName.IndexOf("Gobelin", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				list.Add("HealingDart Variant");
				list.Add("MagicBean");
			}
			else if (hatName.IndexOf("Chef", StringComparison.OrdinalIgnoreCase) >= 0 || hatName.IndexOf("Cook", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				list.Add("portablestovetopitem");
			}
			else if (hatName.IndexOf("Jester", StringComparison.OrdinalIgnoreCase) >= 0 || hatName.IndexOf("Clown", StringComparison.OrdinalIgnoreCase) >= 0)
			{
				list.Add("PandorasBox");
			}
			return list;
		}
	}
}
namespace PeakClassMod.Utils
{
	public static class ClassCheckUtil
	{
		public static bool IsGeneral(Character ch)
		{
			if (!((Object)(object)ch != (Object)null) || !ch.IsLocal || !ClassManager.IsGeneralActive())
			{
				return HatUtils.HasAnyHat(ch, "Hat_Bandana", "Hat_Captain", "Bandana", "Captain");
			}
			return true;
		}

		public static bool IsTechPriest(Character ch)
		{
			if (!((Object)(object)ch != (Object)null) || !ch.IsLocal || !ClassManager.IsTechPriestActive())
			{
				return HatUtils.HasAnyHat(ch, "Hat_10_Crab", "Hat_Crab", "Crab Hat", "Crab");
			}
			return true;
		}

		public static bool IsMedicHat(Character ch)
		{
			if (!((Object)(object)ch != (Object)null) || !ch.IsLocal || !ClassManager.IsMedicActive())
			{
				return HatUtils.HasAnyHat(ch, "Hat_Medic", "MedicHelmet", "Medic");
			}
			return true;
		}

		public static bool IsMushroom(Character ch)
		{
			if (!((Object)(object)ch != (Object)null) || !ch.IsLocal || !ClassManager.IsMushroomancerActive())
			{
				return HatUtils.HasAnyHat(ch, "Hat_Mushroom", "Mushroom");
			}
			return true;
		}

		public static bool IsRogueHat(Character ch)
		{
			if (!((Object)(object)ch != (Object)null) || !ch.IsLocal || !ClassManager.IsRogueActive())
			{
				return HatUtils.HasAnyHat(ch, "Hat_NinjaHeadband", "NinjaHeadband", "Ninja", "Headband");
			}
			return true;
		}

		public static bool IsGreatEpeeHat(Character ch)
		{
			if (!((Object)(object)ch != (Object)null) || !ch.IsLocal || !ClassManager.IsGreatEpeeActive())
			{
				return HatUtils.HasAnyHat(ch, "Hat_Propeller", "Propeller");
			}
			return true;
		}

		public static bool IsAstronaut(Character ch)
		{
			if (!((Object)(object)ch != (Object)null) || !ch.IsLocal || !ClassManager.IsAstronautActive())
			{
				return HatUtils.HasAnyHat(ch, "Hat_Astronaut", "Astronaut");
			}
			return true;
		}

		public static bool IsGobelin(Character ch)
		{
			if (!((Object)(object)ch != (Object)null) || !ch.IsLocal || !ClassManager.IsGobelinActive())
			{
				return HatUtils.HasAnyHat(ch, "Hat_Midsummer", "Midsummer", "Gobelin", "FlowerCrown");
			}
			return true;
		}

		public static bool IsScout(Character ch)
		{
			if (!((Object)(object)ch != (Object)null) || !ch.IsLocal || !ClassManager.IsScoutActive())
			{
				return HatUtils.HasAnyHat(ch, "Hat_Scoutmaster", "Scoutmaster", "Scout");
			}
			return true;
		}

		public static bool IsWolf(Character ch)
		{
			if (!((Object)(object)ch != (Object)null) || !ch.IsLocal || !ClassManager.IsWolfActive())
			{
				return HatUtils.HasAnyHat(ch, "Hat_WolfEars", "WolfEars", "Wolf");
			}
			return true;
		}

		public static bool IsCook(Character ch)
		{
			if (!((Object)(object)ch != (Object)null) || !ch.IsLocal || !ClassManager.IsCookActive())
			{
				return HatUtils.HasAnyHat(ch, "Hat_Chef", "Chef", "Cook");
			}
			return true;
		}

		public static bool IsJester(Character ch)
		{
			if (!((Object)(object)ch != (Object)null) || !ch.IsLocal || !ClassManager.IsJesterActive())
			{
				return HatUtils.HasAnyHat(ch, "Hat_Jester", "JesterHat", "Jester", "Clown");
			}
			return true;
		}
	}
	public static class DaySegmentUtils
	{
		public static bool IsDay()
		{
			if ((Object)(object)DayNightManager.instance == (Object)null)
			{
				return true;
			}
			string text = DayNightManager.instance.TimeOfDayString();
			if (text != "night")
			{
				return text != "evening";
			}
			return false;
		}
	}
	public static class GobelinDiet
	{
		private static readonly HashSet<string> NaturalItemNames = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
		{
			"Shroomberry_Red", "Shroomberry_Yellow", "Shroomberry_Purple", "Shroomberry_Blue", "Shroomberry_Green", "ShelfShroom", "BounceShroom", "CloudFungus", "HealingPuffShroom", "PoisonShroom",
			"MagicBean", "HealingDart Variant", "HealingDart", "BalloonBunch", "RopeSpool", "ChainShooter"
		};

		private static readonly string[] NaturalKeywords = new string[29]
		{
			"shroom", "mushroom", "berry", "shroomberry", "insect", "bug", "raw", "fish", "meat", "plant",
			"herb", "puff", "spore", "healingpuff", "bean", "magicbean", "worm", "fly", "centipede", "beetle",
			"grub", "root", "seed", "fern", "flower", "cactus", "aloe", "bird", "egg"
		};

		private static readonly string[] PackagedKeywords = new string[45]
		{
			"packaged", "bar", "energybar", "granola", "can", "canned", "chips", "cracker", "ration", "soda",
			"cola", "candy", "chocolate", "cookie", "marshmallow", "pie", "drink", "snack", "soup", "tuna",
			"sardine", "noodles", "mre", "bread", "energydrink", "popcorn", "crisps", "pastry", "meatpie", "peanuts",
			"nuts", "jerky", "beef", "cheese", "sausage", "bacon", "sandwich", "burger", "hotdog", "pizza",
			"pasta", "ramen", "cereal", "gum", "cake"
		};

		public static bool IsNaturalFood(Item item)
		{
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)item == (Object)null)
			{
				return false;
			}
			string text = (((Object)item).name ?? "").Replace("(Clone)", "").Trim().ToLowerInvariant();
			string text2 = (item.UIData?.itemName ?? "").ToLowerInvariant();
			if (NaturalItemNames.Contains(((Object)item).name) || NaturalItemNames.Contains(text))
			{
				return true;
			}
			if ((item.itemTags & 4) != 0 || (item.itemTags & 8) != 0 || (item.itemTags & 0x80) != 0)
			{
				return true;
			}
			string[] naturalKeywords = NaturalKeywords;
			foreach (string value in naturalKeywords)
			{
				if (text.Contains(value) || text2.Contains(value))
				{
					return true;
				}
			}
			return false;
		}

		public static bool IsMedicalItem(Item item)
		{
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Invalid comparison between Unknown and I4
			if ((Object)(object)item == (Object)null)
			{
				return false;
			}
			string text = (((Object)item).name ?? "").ToLowerInvariant();
			string text2 = (item.UIData?.itemName ?? "").ToLowerInvariant();
			string[] array = new string[10] { "bandage", "firstaid", "medkit", "kit", "salve", "splint", "pill", "cure", "healingpuff", "puff" };
			foreach (string value in array)
			{
				if (text.Contains(value) || text2.Contains(value))
				{
					return true;
				}
			}
			Action_ModifyStatus[] components = ((Component)item).GetComponents<Action_ModifyStatus>();
			foreach (Action_ModifyStatus val in components)
			{
				if ((int)val.statusType == 0 || (int)val.statusType == 3)
				{
					return true;
				}
			}
			if ((Object)(object)((Component)item).GetComponent<Action_ClearAllStatus>() != (Object)null)
			{
				return true;
			}
			return false;
		}

		public static bool IsFood(Item item)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Invalid comparison between Unknown and I4
			if ((Object)(object)item == (Object)null)
			{
				return false;
			}
			if (IsMedicalItem(item))
			{
				return false;
			}
			if ((item.itemTags & 2) != 0)
			{
				return true;
			}
			Action_PlayAnimation component = ((Component)item).GetComponent<Action_PlayAnimation>();
			if ((Object)(object)component != (Object)null && !string.IsNullOrEmpty(component.animationName))
			{
				string text = component.animationName.ToLowerInvariant();
				if (text.Contains("eat") || text.Contains("drink") || text.Contains("consume"))
				{
					return true;
				}
			}
			ItemUseFeedback component2 = ((Component)item).GetComponent<ItemUseFeedback>();
			if ((Object)(object)component2 != (Object)null && !string.IsNullOrEmpty(component2.useAnimation))
			{
				string text2 = component2.useAnimation.ToLowerInvariant();
				if (text2.Contains("eat") || text2.Contains("drink") || text2.Contains("consume"))
				{
					return true;
				}
			}
			Action_ModifyStatus[] components = ((Component)item).GetComponents<Action_ModifyStatus>();
			for (int i = 0; i < components.Length; i++)
			{
				if ((int)components[i].statusType == 1)
				{
					return true;
				}
			}
			if ((Object)(object)((Component)item).GetComponent<Action_RestoreHunger>() != (Object)null)
			{
				return true;
			}
			return false;
		}

		public static bool IsPackagedFood(Item item)
		{
			if ((Object)(object)item == (Object)null)
			{
				return false;
			}
			if (IsMedicalItem(item))
			{
				return false;
			}
			if (IsNaturalFood(item))
			{
				return false;
			}
			if (IsFood(item))
			{
				return true;
			}
			string text = (((Object)item).name ?? "").Replace("(Clone)", "").Trim().ToLowerInvariant();
			string text2 = (item.UIData?.itemName ?? "").ToLowerInvariant();
			string[] packagedKeywords = PackagedKeywords;
			foreach (string value in packagedKeywords)
			{
				if (text.Contains(value) || text2.Contains(value))
				{
					return true;
				}
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(AirportCheckInKiosk), "Start")]
	public class HatSignUtils
	{
		public static GameObject hatSign;

		private static void Postfix()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Expected O, but got Unknown
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)hatSign != (Object)null)
			{
				return;
			}
			hatSign = new GameObject("HatSignPanel");
			hatSign.AddComponent<Canvas>().renderMode = (RenderMode)2;
			hatSign.AddComponent<CanvasScaler>();
			hatSign.AddComponent<GraphicRaycaster>();
			int width = 2048;
			int height = 1349;
			GameObject panelObj = new GameObject("Panel");
			panelObj.transform.SetParent(hatSign.transform, false);
			((Graphic)panelObj.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0f);
			GameObject imageObj = new GameObject("CustomImage");
			imageObj.transform.SetParent(panelObj.transform, false);
			Image img = imageObj.AddComponent<Image>();
			Assembly executingAssembly = Assembly.GetExecutingAssembly();
			string name = "Mod_Peak_2026.assets.image.HatSign.png";
			string text = Path.Combine(Paths.PluginPath, "PeakClassModAssets");
			Directory.CreateDirectory(text);
			string path = Path.Combine(text, "temp_HatSign.png");
			using (Stream stream = executingAssembly.GetManifestResourceStream(name))
			{
				if (stream == null)
				{
					Debug.LogError((object)"Image introuvable dans le DLL !");
					return;
				}
				using FileStream destination = new FileStream(path, FileMode.Create, FileAccess.Write);
				stream.CopyTo(destination);
			}
			if ((Object)(object)ImageLoader.Instance == (Object)null)
			{
				new GameObject("ImageLoader").AddComponent<ImageLoader>();
			}
			ImageLoader.Instance.Load(path, delegate(Texture2D tex)
			{
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_007c: Unknown result type (might be due to invalid IL or missing references)
				//IL_009f: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
				//IL_0118: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)tex == (Object)null)
				{
					Debug.LogError((object)"Texture NULL");
				}
				else
				{
					Sprite sprite = Sprite.Create(tex, new Rect(0f, 0f, (float)((Texture)tex).width, (float)((Texture)tex).height), new Vector2(0.5f, 0.5f));
					img.sprite = sprite;
					((Graphic)img).color = Color.white;
					hatSign.transform.position = new Vector3(-6.4f, 5.15f, 122.5f);
					hatSign.transform.rotation = Quaternion.Euler(0f, 0f, 0f);
					hatSign.transform.localScale = new Vector3(0.038f, 0.035f, 0.035f);
					panelObj.GetComponent<RectTransform>().sizeDelta = new Vector2(400f, 300f);
					RectTransform component = imageObj.GetComponent<RectTransform>();
					float num = 1.1f;
					float num2 = 380f * num;
					float num3 = num2 * ((float)height / (float)width);
					component.sizeDelta = new Vector2(num2, num3);
				}
			});
		}
	}
	public static class HatUtils
	{
		private static string _lastLocalHatName = "None";

		public static void SetLastLocalHatName(string hatName)
		{
			if (!string.IsNullOrEmpty(hatName) && hatName != "Unknown")
			{
				_lastLocalHatName = hatName;
			}
		}

		public static string GetLastLocalHatName()
		{
			return _lastLocalHatName;
		}

		public static bool TryGetHatName(Character ch, out string hatName)
		{
			hatName = null;
			if ((Object)(object)ch == (Object)null)
			{
				return false;
			}
			try
			{
				PersistentPlayerDataService service = GameHandler.GetService<PersistentPlayerDataService>();
				PersistentPlayerData val = null;
				if (ch.refs?.customization?.overridePhotonPlayer != null)
				{
					val = ((service != null) ? service.GetPlayerData(ch.refs.customization.overridePhotonPlayer) : null);
				}
				if (val == null)
				{
					PhotonView photonView = ((MonoBehaviourPun)ch).photonView;
					if (((photonView != null) ? photonView.Owner : null) != 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 && (Object)(object)Singleton<Customization>.Instance != (Object)null)
				{
					CustomizationOption[] hats = Singleton<Customization>.Instance.hats;
					int currentHat = val.customizationData.currentHat;
					if (hats != null && currentHat >= 0 && currentHat < hats.Length && (Object)(object)hats[currentHat] != (Object)null)
					{
						if (hats[currentHat].isBlank)
						{
							hatName = "None";
							if (ch.IsLocal)
							{
								SetLastLocalHatName(hatName);
							}
							return true;
						}
						hatName = ((Object)hats[currentHat]).name;
						if (ch.IsLocal)
						{
							SetLastLocalHatName(hatName);
						}
						return true;
					}
					if (currentHat < 0)
					{
						hatName = "None";
						if (ch.IsLocal)
						{
							SetLastLocalHatName(hatName);
						}
						return true;
					}
				}
			}
			catch
			{
			}
			try
			{
				bool flag = false;
				try
				{
					PersistentPlayerDataService service2 = GameHandler.GetService<PersistentPlayerDataService>();
					PersistentPlayerData val2 = null;
					if (ch.refs?.customization?.overridePhotonPlayer != null)
					{
						val2 = ((service2 != null) ? service2.GetPlayerData(ch.refs.customization.overridePhotonPlayer) : null);
					}
					if (val2 == null)
					{
						PhotonView photonView2 = ((MonoBehaviourPun)ch).photonView;
						if (((photonView2 != null) ? photonView2.Owner : null) != null)
						{
							val2 = ((service2 != null) ? service2.GetPlayerData(((MonoBehaviourPun)ch).photonView.Owner) : null);
						}
					}
					if (val2 == null && ch.IsLocal && PhotonNetwork.LocalPlayer != null)
					{
						val2 = ((service2 != null) ? service2.GetPlayerData(PhotonNetwork.LocalPlayer) : null);
					}
					if (val2 != null && (Object)(object)Singleton<Customization>.Instance != (Object)null)
					{
						int currentOutfit = val2.customizationData.currentOutfit;
						CustomizationOption[] fits = Singleton<Customization>.Instance.fits;
						if (fits != null && currentOutfit >= 0 && currentOutfit < fits.Length && (Object)(object)fits[currentOutfit] != (Object)null && fits[currentOutfit].overrideHat)
						{
							flag = true;
						}
					}
				}
				catch
				{
				}
				if (!flag)
				{
					if (ch.refs?.customization?.refs?.playerHats != null)
					{
						Renderer[] playerHats = ch.refs.customization.refs.playerHats;
						foreach (Renderer val3 in playerHats)
						{
							if ((Object)(object)val3 != (Object)null && (((Component)val3).gameObject.activeSelf || ((Component)val3).gameObject.activeInHierarchy))
							{
								hatName = ((Object)((Component)val3).gameObject).name;
								if (ch.IsLocal)
								{
									SetLastLocalHatName(hatName);
								}
								return true;
							}
						}
					}
					Transform[] componentsInChildren = ((Component)ch).GetComponentsInChildren<Transform>(true);
					foreach (Transform val4 in componentsInChildren)
					{
						if ((Object)(object)val4 == (Object)null || (!((Component)val4).gameObject.activeSelf && !((Component)val4).gameObject.activeInHierarchy))
						{
							continue;
						}
						string name = ((Object)val4).name;
						if (name.StartsWith("Hat_", StringComparison.OrdinalIgnoreCase) || name.Contains("Midsummer") || name.Contains("Helmet") || name.Contains("Bandana") || name.Contains("Ninja") || name.Contains("Headband") || name.Contains("Crab") || name.Contains("Mushroom") || name.Contains("Propeller") || name.Contains("Astronaut") || name.Contains("Chef") || name.Contains("Cook") || name.Contains("Scout") || name.Contains("Jester") || name.Contains("Wolf"))
						{
							hatName = name;
							if (ch.IsLocal)
							{
								SetLastLocalHatName(hatName);
							}
							return true;
						}
					}
				}
			}
			catch
			{
			}
			if (ch.IsLocal && !string.IsNullOrEmpty(_lastLocalHatName) && _lastLocalHatName != "None")
			{
				hatName = _lastLocalHatName;
				return true;
			}
			hatName = "None";
			return false;
		}

		public static bool HasAnyHat(Character ch, params string[] names)
		{
			if (!TryGetHatName(ch, out var name))
			{
				if (!((Object)(object)ch != (Object)null) || !ch.IsLocal || string.IsNullOrEmpty(_lastLocalHatName))
				{
					return false;
				}
				name = _lastLocalHatName;
			}
			return names.Any((string n) => name.IndexOf(n, StringComparison.OrdinalIgnoreCase) >= 0);
		}

		public static bool HasHat(Character ch, string expected)
		{
			return HasAnyHat(ch, expected);
		}
	}
	public class ImageLoader : MonoBehaviour
	{
		public static ImageLoader Instance;

		private void Awake()
		{
			Instance = this;
			Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
		}

		public void Load(string path, Action<Texture2D> callback)
		{
			((MonoBehaviour)this).StartCoroutine(LoadCoroutine(path, callback));
		}

		private IEnumerator LoadCoroutine(string path, Action<Texture2D> callback)
		{
			string text = "file://" + path;
			UnityWebRequest request = UnityWebRequestTexture.GetTexture(text);
			yield return request.SendWebRequest();
			if ((int)request.result != 1)
			{
				Debug.LogError((object)request.error);
				callback(null);
			}
			else
			{
				callback(DownloadHandlerTexture.GetContent(request));
			}
		}
	}
	public static class ItemCache
	{
		private static Dictionary<string, Item> _byName;

		private static float _lastRefreshTime;

		private static string Normalize(string input)
		{
			if (string.IsNullOrEmpty(input))
			{
				return "";
			}
			return input.Replace(" ", "").Replace("-", "").Replace("_", "")
				.Replace("(Clone)", "")
				.Trim()
				.ToLowerInvariant();
		}

		public static void Refresh()
		{
			_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))
				{
					string name = ((Object)val).name;
					string key = name.Replace("(Clone)", "").Trim();
					string key2 = Normalize(name);
					if (!_byName.ContainsKey(name))
					{
						_byName[name] = val;
					}
					if (!_byName.ContainsKey(key))
					{
						_byName[key] = val;
					}
					if (!_byName.ContainsKey(key2))
					{
						_byName[key2] = val;
					}
				}
			}
			_lastRefreshTime = Time.time;
		}

		public static Item Get(string name)
		{
			if (string.IsNullOrEmpty(name))
			{
				return null;
			}
			if (_byName == null || Time.time - _lastRefreshTime > 300f)
			{
				Refresh();
			}
			if (_byName.TryGetValue(name, out var value))
			{
				return value;
			}
			string text = Normalize(name);
			if (_byName.TryGetValue(text, out value))
			{
				return value;
			}
			foreach (KeyValuePair<string, Item> item in _byName)
			{
				string text2 = Normalize(item.Key);
				if (text2.Contains(text) || text.Contains(text2))
				{
					return item.Value;
				}
			}
			return null;
		}

		public static ushort GetDatabaseID(Item item)
		{
			if ((Object)(object)item == (Object)null)
			{
				return 0;
			}
			try
			{
				ItemDatabase instance = SingletonAsset<ItemDatabase>.Instance;
				if ((Object)(object)instance != (Object)null && instance.itemLookup != null)
				{
					foreach (KeyValuePair<ushort, Item> item2 in instance.itemLookup)
					{
						if ((Object)(object)item2.Value == (Object)(object)item || ((Object)(object)item2.Value != (Object)null && ((object)item2.Value).Equals((object?)item)))
						{
							return item2.Key;
						}
					}
					string text = ((Object)((Component)item).gameObject).name.Replace("(Clone)", "").Trim();
					foreach (KeyValuePair<ushort, Item> item3 in instance.itemLookup)
					{
						if ((Object)(object)item3.Value != (Object)null && string.Equals(((Object)((Component)item3.Value).gameObject).name.Replace("(Clone)", "").Trim(), text, StringComparison.OrdinalIgnoreCase))
						{
							return item3.Key;
						}
					}
					string text2 = Normalize(text);
					foreach (KeyValuePair<ushort, Item> item4 in instance.itemLookup)
					{
						if ((Object)(object)item4.Value != (Object)null && Normalize(((Object)((Component)item4.Value).gameObject).name) == text2)
						{
							return item4.Key;
						}
					}
				}
			}
			catch
			{
			}
			return item.itemID;
		}
	}
	internal static class TechPriestBlocker
	{
		private static readonly string[] AllowedKeywords = new string[38]
		{
			"balloon", "ballon", "chainshooter", "launcher", "grapple", "rope", "ropespool", "corde", "compass", "boussole",
			"binoculars", "jumelles", "glider", "parapente", "parasol", "parachute", "flare", "fumigene", "torch", "torche",
			"lantern", "lanterne", "candle", "bougie", "piton", "backpack", "sac", "bugle", "trompette", "horn",
			"frisbee", "basketball", "ball", "portablestovetop", "stove", "radio", "passport", "guidebook"
		};

		private static readonly string[] DrinkAndWaterKeywords = new string[32]
		{
			"water", "eau", "drink", "boire", "boisson", "bottle", "bouteille", "canteen", "gourde", "flask",
			"soda", "can", "canette", "cola", "energy", "juice", "jus", "tea", "the", "coffee",
			"cafe", "beer", "biere", "soup", "soupe", "potage", "broth", "coconut", "coco", "potion",
			"canned", "pop"
		};

		private static readonly string[] FoodKeywords = new string[52]
		{
			"food", "nourriture", "aliment", "manger", "eat", "snack", "bar", "energybar", "granola", "ration",
			"mre", "apple", "pomme", "berry", "baie", "shroom", "mushroom", "champi", "meat", "viande",
			"fish", "poisson", "bread", "pain", "cookie", "biscuit", "candy", "bonbon", "lollipop", "sucette",
			"marshmallow", "cracker", "chips", "crisps", "pasta", "pizza", "burger", "sandwich", "cheese", "fromage",
			"sausage", "saucisse", "bacon", "tuna", "sardine", "noodles", "ramen", "cereal", "pie", "pastry",
			"cake", "hotdog"
		};

		private static readonly string[] HealingKeywords = new string[30]
		{
			"heal", "cure", "cureall", "cure-all", "medicine", "medecine", "restorehealth", "bandage", "bandages", "firstaid",
			"firstaidkit", "medkit", "salve", "splint", "pill", "pilule", "healingpuff", "puff", "trousse", "pansement",
			"soin", "soigner", "aloe", "remedy", "remede", "medicinal", "blessure", "injury", "injuries", "antidote"
		};

		private static readonly string[] StaminaKeywords = new string[10] { "lollipop", "sucette", "candy", "energy", "fasterboi", "stamina", "endurance", "amulet_infinitestam", "infinitestam", "extrastam" };

		private static readonly string[] PromptKeywords = new string[10] { "eat", "manger", "drink", "boire", "consume", "consommer", "heal", "soign", "cure", "nourrir" };

		public static bool ShouldBlock(Item item)
		{
			//IL_031a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0324: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Invalid comparison between Unknown and I4
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Invalid comparison between Unknown and I4
			//IL_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)item == (Object)null)
			{
				return false;
			}
			string text = (((Object)item).name ?? "").ToLowerInvariant();
			string text2 = (item.UIData?.itemName ?? "").ToLowerInvariant();
			string text3 = (item.UIData?.mainInteractPrompt ?? "").ToLowerInvariant();
			string text4 = (item.UIData?.secondaryInteractPrompt ?? "").ToLowerInvariant();
			bool flag = false;
			string[] allowedKeywords = AllowedKeywords;
			foreach (string value in allowedKeywords)
			{
				if (text.Contains(value) || text2.Contains(value))
				{
					flag = true;
					break;
				}
			}
			if (flag && !((Object)(object)((Component)item).GetComponentInChildren<Action_ModifyStatus>(true) != (Object)null) && !((Object)(object)((Component)item).GetComponentInChildren<Action_ClearAllStatus>(true) != (Object)null) && !((Object)(object)((Component)item).GetComponentInChildren<Action_GiveExtraStamina>(true) != (Object)null) && !((Object)(object)((Component)item).GetComponentInChildren<Action_ApplyInfiniteStamina>(true) != (Object)null) && !((Object)(object)((Component)item).GetComponentInChildren<Action_Consume>(true) != (Object)null) && !((Object)(object)((Component)item).GetComponentInChildren<Action_ConsumeAndSpawn>(true) != (Object)null) && !((Object)(object)((Component)item).GetComponentInChildren<Action_RestoreHunger>(true) != (Object)null))
			{
				return false;
			}
			if ((Object)(object)((Component)item).GetComponentInChildren<Action_RestoreHunger>(true) != (Object)null)
			{
				return true;
			}
			if ((Object)(object)((Component)item).GetComponentInChildren<Action_Consume>(true) != (Object)null || (Object)(object)((Component)item).GetComponentInChildren<Action_ConsumeAndSpawn>(true) != (Object)null)
			{
				return true;
			}
			if ((Object)(object)((Component)item).GetComponentInChildren<Action_ClearAllStatus>(true) != (Object)null)
			{
				return true;
			}
			if ((Object)(object)((Component)item).GetComponentInChildren<Action_HealingGem>(true) != (Object)null)
			{
				return true;
			}
			if ((Object)(object)((Component)item).GetComponentInChildren<Action_GiveExtraStamina>(true) != (Object)null || (Object)(object)((Component)item).GetComponentInChildren<Action_ApplyInfiniteStamina>(true) != (Object)null)
			{
				return true;
			}
			Action_ModifyStatus[] componentsInChildren = ((Component)item).GetComponentsInChildren<Action_ModifyStatus>(true);
			if (componentsInChildren != null)
			{
				Action_ModifyStatus[] array = componentsInChildren;
				foreach (Action_ModifyStatus val in array)
				{
					if ((int)val.statusType == 0 || (int)val.statusType == 1 || (int)val.statusType == 3)
					{
						return true;
					}
				}
			}
			ItemUseFeedback[] componentsInChildren2 = ((Component)item).GetComponentsInChildren<ItemUseFeedback>(true);
			if (componentsInChildren2 != null)
			{
				ItemUseFeedback[] array2 = componentsInChildren2;
				foreach (ItemUseFeedback val2 in array2)
				{
					if ((Object)(object)val2 != (Object)null && !string.IsNullOrEmpty(val2.useAnimation))
					{
						string text5 = val2.useAnimation.ToLowerInvariant();
						if (text5.Contains("eat") || text5.Contains("drink") || text5.Contains("heal") || text5.Contains("antidote") || text5.Contains("consume"))
						{
							return true;
						}
					}
				}
			}
			Action_PlayAnimation[] componentsInChildren3 = ((Component)item).GetComponentsInChildren<Action_PlayAnimation>(true);
			if (componentsInChildren3 != null)
			{
				Action_PlayAnimation[] array3 = componentsInChildren3;
				foreach (Action_PlayAnimation val3 in array3)
				{
					if ((Object)(object)val3 != (Object)null && !string.IsNullOrEmpty(val3.animationName))
					{
						string text6 = val3.animationName.ToLowerInvariant();
						if (text6.Contains("eat") || text6.Contains("drink") || text6.Contains("heal") || text6.Contains("consume"))
						{
							return true;
						}
					}
				}
			}
			if ((item.itemTags & 2) != 0 || (item.itemTags & 4) != 0 || (item.itemTags & 8) != 0 || (item.itemTags & 0x80) != 0)
			{
				return true;
			}
			Action_ApplyAffliction[] componentsInChildren4 = ((Component)item).GetComponentsInChildren<Action_ApplyAffliction>(true);
			if (componentsInChildren4 != null)
			{
				Action_ApplyAffliction[] array4 = componentsInChildren4;
				foreach (Action_ApplyAffliction val4 in array4)
				{
					if (!((Object)(object)val4 != (Object)null))
					{
						continue;
					}
					if (val4.affliction != null)
					{
						string text7 = ((object)val4.affliction).GetType().Name.ToLowerInvariant();
						if (text7.Contains("fasterboi") || text7.Contains("stamina") || text7.Contains("energy") || text7.Contains("heal") || text7.Contains("bonus") || text7.Contains("nohunger"))
						{
							return true;
						}
					}
					if (val4.extraAfflictions == null)
					{
						continue;
					}
					Affliction[] extraAfflictions = val4.extraAfflictions;
					foreach (Affliction val5 in extraAfflictions)
					{
						if (val5 != null)
						{
							string text8 = ((object)val5).GetType().Name.ToLowerInvariant();
							if (text8.Contains("fasterboi") || text8.Contains("stamina") || text8.Contains("energy") || text8.Contains("heal") || text8.Contains("bonus") || text8.Contains("nohunger"))
							{
								return true;
							}
						}
					}
				}
			}
			allowedKeywords = DrinkAndWaterKeywords;
			foreach (string value2 in allowedKeywords)
			{
				if (text.Contains(value2) || text2.Contains(value2))
				{
					return true;
				}
			}
			allowedKeywords = FoodKeywords;
			foreach (string value3 in allowedKeywords)
			{
				if (text.Contains(value3) || text2.Contains(value3))
				{
					return true;
				}
			}
			allowedKeywords = HealingKeywords;
			foreach (string value4 in allowedKeywords)
			{
				if (text.Contains(value4) || text2.Contains(value4))
				{
					return true;
				}
			}
			allowedKeywords = StaminaKeywords;
			foreach (string value5 in allowedKeywords)
			{
				if (text.Contains(value5) || text2.Contains(value5))
				{
					return true;
				}
			}
			if (GobelinDiet.IsFood(item) || GobelinDiet.IsNaturalFood(item) || GobelinDiet.IsPackagedFood(item))
			{
				return true;
			}
			allowedKeywords = PromptKeywords;
			foreach (string value6 in allowedKeywords)
			{
				if (text3.Contains(value6) || text4.Contains(value6))
				{
					return true;
				}
			}
			return false;
		}

		public static bool ShouldBlockSelfUse(Item item)
		{
			return ShouldBlock(item);
		}
	}
	internal static class TechPriestItemChecker
	{
		public static bool ShouldBlock(Item item, Character targetChar = null)
		{
			if ((Object)(object)item == (Object)null)
			{
				return false;
			}
			Character val = targetChar ?? item.holderCharacter ?? item.trueHolderCharacter ?? item.overrideHolderCharacter ?? Character.localCharacter;
			if (((Object)(object)val != (Object)null && ((val.IsLocal && ClassManager.IsTechPriestActive()) || ClassCheckUtil.IsTechPriest(val))) || ClassManager.IsTechPriestActive() || ((Object)(object)Character.localCharacter != (Object)null && ClassCheckUtil.IsTechPriest(Character.localCharacter)))
			{
				return TechPriestBlocker.ShouldBlock(item);
			}
			return false;
		}

		public static bool ShouldBlockSelfUse(Item item)
		{
			return ShouldBlock(item);
		}
	}
}
namespace PeakClassMod.Patches
{
	[HarmonyPatch(typeof(Backpack), "Wear")]
	public static class BackpackBlocker
	{
		[HarmonyPrefix]
		public static bool Prefix(Backpack __instance, Character interactor)
		{
			if ((Object)(object)interactor == (Object)null)
			{
				return true;
			}
			if (ClassCheckUtil.IsWolf(interactor) || ClassManager.IsWolfActive())
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Backpack), "Interact")]
	public static class BackpackInteractBlocker
	{
		[HarmonyPrefix]
		public static bool Prefix(Backpack __instance, Character interactor)
		{
			if ((Object)(object)interactor == (Object)null)
			{
				return true;
			}
			if (ClassCheckUtil.IsWolf(interactor) || ClassManager.IsWolfActive())
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(BarAffliction), "ChangeAffliction")]
	public class BarAffliction_Patch
	{
		private static void Postfix(BarAffliction __instance)
		{
		}
	}
	[HarmonyPatch(typeof(Character), "Start")]
	public class Character_Start_AddNetComp_Patch
	{
		private static void Postfix(Character __instance)
		{
			if ((Object)(object)__instance != (Object)null)
			{
				PeakClassModPlugin instance = PeakClassModPlugin.Instance;
				instance.EnsureComponent<ClassModNetwork>(((Component)__instance).gameObject);
				instance.EnsureComponent<ClassWatcherHandler>(((Component)__instance).gameObject);
				instance.EnsureComponent<AstronautStatHandler>(((Component)__instance).gameObject);
				instance.EnsureComponent<MedicStatHandler>(((Component)__instance).gameObject);
				instance.EnsureComponent<TechPriestWeightEnforcer>(((Component)__instance).gameObject);
				instance.EnsureComponent<GobelinSizeHandler>(((Component)__instance).gameObject);
				instance.EnsureComponent<GobelinBlowgunHandler>(((Component)__instance).gameObject);
				instance.EnsureComponent<WolfHandler>(((Component)__instance).gameObject);
				instance.EnsureComponent<RogueMovementHandler>(((Component)__instance).gameObject);
				instance.EnsureComponent<CookHandler>(((Component)__instance).gameObject);
				instance.EnsureComponent<JesterHandler>(((Component)__instance).gameObject);
			}
		}
	}
	[HarmonyPatch(typeof(Character), "UseStamina")]
	public static class Character_UseStamina_Patch
	{
		[HarmonyPrefix]
		public static void Prefix(Character __instance, [HarmonyArgument(0)] ref float stamina)
		{
			if (!((Object)(object)__instance == (Object)null) && __instance.IsLocal)
			{
				if (ClassManager.IsScoutActive() || ClassCheckUtil.IsScout(__instance))
				{
					stamina *= 0.8f;
				}
				else if (ClassManager.IsRogueActive() || ClassCheckUtil.IsRogueHat(__instance))
				{
					stamina *= 1.7f;
				}
			}
		}
	}
	public static class CookFoodHelper
	{
		public static bool IsRawFood(Item item)
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)item == (Object)null)
			{
				return false;
			}
			if (item is Backpack || (Object)(object)((Component)item).GetComponent<Constructable>() != (Object)null || (Object)(object)((Component)item).GetComponent<Action_Spawn>() != (Object)null)
			{
				return false;
			}
			if (!((Object)(object)((Component)item).GetComponent<Action_Consume>() != (Object)null) && !((Object)(object)((Component)item).GetComponent<Action_ConsumeAndSpawn>() != (Object)null) && !((Object)(object)((Component)item).GetComponent<Action_RestoreHunger>() != (Object)null))
			{
				return false;
			}
			int num = 0;
			IntItemData val = default(IntItemData);
			if (item.data != null && item.data.TryGetDataEntry<IntItemData>((DataEntryKey)1, ref val))
			{
				num = val.Value;
			}
			if (num > 0)
			{
				return false;
			}
			ItemCooking component = ((Component)item).GetComponent<ItemCooking>();
			if ((Object)(object)component != (Object)null && component.canBeCooked)
			{
				return true;
			}
			if (((Enum)item.itemTags).HasFlag((Enum)(object)(ItemTags)4) || ((Enum)item.itemTags).HasFlag((Enum)(object)(ItemTags)8))
			{
				return true;
			}
			string text = ((Object)((Component)item).gameObject).name.ToLowerInvariant();
			if (text.Contains("berry") || text.Contains("shroom") || text.Contains("marshmallow") || text.Contains("root") || text.Contains("egg") || text.Contains("meat"))
			{
				return true;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(Item), "CanUsePrimary")]
	public static class Cook_ItemCanUsePrimary_Patch
	{
		[HarmonyPrefix]
		public static bool Prefix(Item __instance, ref bool __result)
		{
			if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.holderCharacter == (Object)null)
			{
				return true;
			}
			if (ClassCheckUtil.IsCook(__instance.holderCharacter) && CookFoodHelper.IsRawFood(__instance))
			{
				__result = false;
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Action_Consume), "RunAction")]
	public static class Cook_ActionConsume_Patch
	{
		[HarmonyPrefix]
		public static bool Prefix(Action_Consume __instance)
		{
			if ((Object)(object)__instance == (Object)null)
			{
				return true;
			}
			Character val = ((Component)__instance).GetComponentInParent<Character>() ?? Character.localCharacter;
			Item component = ((Component)__instance).GetComponent<Item>();
			if ((Object)(object)val != (Object)null && ClassCheckUtil.IsCook(val) && CookFoodHelper.IsRawFood(component))
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Action_ConsumeAndSpawn), "RunAction")]
	public static class Cook_ActionConsumeAndSpawn_Patch
	{
		[HarmonyPrefix]
		public static bool Prefix(Action_ConsumeAndSpawn __instance)
		{
			if ((Object)(object)__instance == (Object)null)
			{
				return true;
			}
			Character val = ((Component)__instance).GetComponentInParent<Character>() ?? Character.localCharacter;
			Item component = ((Component)__instance).GetComponent<Item>();
			if ((Object)(object)val != (Object)null && ClassCheckUtil.IsCook(val) && CookFoodHelper.IsRawFood(component))
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Item), "Consume")]
	public static class Cook_ItemConsume_Patch
	{
		[HarmonyPostfix]
		public static void Postfix(Item __instance, int consumerID)
		{
			if ((Object)(object)__instance == (Object)null)
			{
				return;
			}
			PhotonView photonView = PhotonNetwork.GetPhotonView(consumerID);
			if ((Object)(object)photonView == (Object)null)
			{
				return;
			}
			Character component = ((Component)photonView).GetComponent<Character>();
			if ((Object)(object)component == (Object)null || !ClassCheckUtil.IsCook(component))
			{
				return;
			}
			int num = 0;
			IntItemData val = default(IntItemData);
			if (__instance.data != null && __instance.data.TryGetDataEntry<IntItemData>((DataEntryKey)1, ref val))
			{
				num = val.Value;
			}
			if (num >= 1)
			{
				component.AddExtraStamina(0.25f);
				component.AddStamina(0.25f);
				ManualLogSource log = PeakClassModPlugin.Log;
				if (log != null)
				{
					log.LogInfo((object)("[Cook] " + ((Object)((Component)component).gameObject).name + " consumed cooked food! +25% Stamina bonus granted."));
				}
			}
		}
	}
	[HarmonyPatch(typeof(CharacterAfflictions), "AddStatus")]
	public static class General_AddStatus_Patch
	{
		[HarmonyPrefix]
		public static bool Prefix(CharacterAfflictions __instance, STATUSTYPE statusType, ref float amount, ref bool __result)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Invalid comparison between Unknown and I4
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Invalid comparison between Unknown and I4
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Invalid comparison between Unknown and I4
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Invalid comparison between Unknown and I4
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Invalid comparison between Unknown and I4
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Invalid comparison between Unknown and I4
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Invalid comparison between Unknown and I4
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Invalid comparison between Unknown and I4
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Invalid comparison between Unknown and I4
			Character val = __instance?.character;
			if ((Object)(object)val == (Object)null)
			{
				return true;
			}
			bool isLocal = val.IsLocal;
			if ((int)statusType == 10 && ((isLocal && ClassManager.IsGobelinActive()) || ClassCheckUtil.IsGobelin(val)))
			{
				amount = 0f;
				__result = false;
				return false;
			}
			if ((int)statusType == 3 && ((isLocal && ClassManager.IsMushroomancerActive()) || ClassCheckUtil.IsMushroom(val)))
			{
				amount = 0f;
				__result = false;
				return false;
			}
			if ((int)statusType == 7 && ((isLocal && ClassManager.IsTechPriestActive()) || ClassCheckUtil.IsTechPriest(val)))
			{
				amount = 0f;
				__result = false;
				return false;
			}
			if (isLocal && (int)statusType == 1 && amount > 0f)
			{
				if (ClassCheckUtil.IsAstronaut(val))
				{
					amount *= 1.3f;
				}
				else if (ClassCheckUtil.IsScout(val))
				{
					amount *= 1.7f;
				}
				else if (ClassCheckUtil.IsWolf(val) && !DaySegmentUtils.IsDay())
				{
					amount *= 1.3f;
				}
				else if (ClassCheckUtil.IsTechPriest(val))
				{
					amount *= 1.5f;
				}
				else if (ClassCheckUtil.IsGeneral(val))
				{
					amount *= 2f;
				}
				else if (ClassCheckUtil.IsCook(val))
				{
					amount *= 1.3f;
				}
			}
			if (isLocal && (ClassManager.IsJesterActive() || ClassCheckUtil.IsJester(val)) && ((int)statusType == 0 || (int)statusType == 8 || (int)statusType == 2 || (int)statusType == 3 || (int)statusType == 5 || (int)statusType == 10) && amount > 0f)
			{
				amount *= 1.2f;
			}
			if (isLocal && ClassCheckUtil.IsGeneral(val) && (int)statusType == 5 && amount < 0f)
			{
				float currentStatus = __instance.GetCurrentStatus((STATUSTYPE)5);
				if (currentStatus + amount < 0.35f)
				{
					float num = 0.35f - currentStatus;
					if (num >= 0f)
					{
						__result = false;
						return false;
					}
					amount = num;
				}
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(CharacterAfflictions), "AdjustStatus")]
	public static class General_AdjustStatus_Patch
	{
		[HarmonyPrefix]
		public static bool Prefix(CharacterAfflictions __instance, STATUSTYPE statusType, ref float amount)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Invalid comparison between Unknown and I4
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Invalid comparison between Unknown and I4
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Invalid comparison between Unknown and I4
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Invalid comparison between Unknown and I4
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Invalid comparison between Unknown and I4
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Invalid comparison between Unknown and I4
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Invalid comparison between Unknown and I4
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Invalid comparison between Unknown and I4
			Character val = __instance?.character;
			if ((Object)(object)val == (Object)null)
			{
				return true;
			}
			bool isLocal = val.IsLocal;
			if ((int)statusType == 10 && ((isLocal && ClassManager.IsGobelinActive()) || ClassCheckUtil.IsGobelin(val)))
			{
				amount = 0f;
				return false;
			}
			if ((int)statusType == 3 && ((isLocal && ClassManager.IsMushroomancerActive()) || ClassCheckUtil.IsMushroom(val)))
			{
				amount = 0f;
				return false;
			}
			if ((int)statusType == 7 && ((isLocal && ClassManager.IsTechPriestActive()) || ClassCheckUtil.IsTechPriest(val)))
			{
				amount = 0f;
				return false;
			}
			if (isLocal && (int)statusType == 1 && amount > 0f)
			{
				if (ClassCheckUtil.IsAstronaut(val))
				{
					amount *= 1.3f;
				}
				else if (ClassCheckUtil.IsScout(val))
				{
					amount *= 1.7f;
				}
				else if (ClassCheckUtil.IsWolf(val) && !DaySegmentUtils.IsDay())
				{
					amount *= 1.3f;
				}
				else if (ClassCheckUtil.IsTechPriest(val))
				{
					amount *= 1.5f;
				}
				else if (ClassCheckUtil.IsGeneral(val))
				{
					amount *= 2f;
				}
				else if (ClassCheckUtil.IsCook(val))
				{
					amount *= 1.3f;
				}
			}
			if (isLocal && (ClassManager.IsJesterActive() || ClassCheckUtil.IsJester(val)) && ((int)statusType == 0 || (int)statusType == 8 || (int)statusType == 2 || (int)statusType == 3 || (int)statusType == 5 || (int)statusType == 10) && amount > 0f)
			{
				amount *= 1.2f;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(CharacterAfflictions), "AddPoisonOverTime")]
	public static class General_AddPoisonOverTime_Patch
	{
		[HarmonyPrefix]
		public static bool Prefix(CharacterAfflictions __instance)
		{
			Character val = __instance?.character;
			if ((Object)(object)val == (Object)null)
			{
				return true;
			}
			if ((val.IsLocal && ClassManager.IsMushroomancerActive()) || ClassCheckUtil.IsMushroom(val))
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(CharacterAfflictions), "Update")]
	public static class General_Afflictions_Update_Patch
	{
		[HarmonyPostfix]
		public static void Postfix(CharacterAfflictions __instance)
		{
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Invalid comparison between Unknown and I4
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.character == (Object)null)
			{
				return;
			}
			Character character = __instance.character;
			bool isLocal = character.IsLocal;
			if ((isLocal && ClassManager.IsGobelinActive()) || ClassCheckUtil.IsGobelin(character))
			{
				if (__instance.currentStatuses != null)
				{
					__instance.currentStatuses[10] = 0f;
				}
				if (__instance.afflictionList != null)
				{
					for (int num = __instance.afflictionList.Count - 1; num >= 0; num--)
					{
						Affliction val = __instance.afflictionList[num];
						if (val != null)
						{
							string name = ((object)val).GetType().Name;
							if (val is Affliction_Chaos || (int)val.GetAfflictionType() == 6 || name.Contains("Chaos") || name.Contains("Confus") || name.Contains("Spore") || name.Contains("ZombieBite"))
							{
								__instance.afflictionList.RemoveAt(num);
							}
						}
					}
				}
			}
			if ((!isLocal || !ClassManager.IsMushroomancerActive()) && !ClassCheckUtil.IsMushroom(character))
			{
				return;
			}
			if (__instance.currentStatuses != null)
			{
				__instance.currentStatuses[3] = 0f;
			}
			if (__instance.afflictionList == null)
			{
				return;
			}
			for (int num2 = __instance.afflictionList.Count - 1; num2 >= 0; num2--)
			{
				Affliction val2 = __instance.afflictionList[num2];
				if (val2 != null)
				{
					string name2 = ((object)val2).GetType().Name;
					if (val2 is Affliction_PoisonOverTime || (int)val2.GetAfflictionType() == 0 || name2.Contains("Poison"))
					{
						__instance.afflictionList.RemoveAt(num2);
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(CharacterAfflictions), "SetStatus")]
	public static class General_SetStatus_Patch
	{
		[HarmonyPrefix]
		public static void Prefix(CharacterAfflictions __instance, STATUSTYPE statusType, ref float amount)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Invalid comparison between Unknown and I4
			Character val = __instance?.character;
			if (!((Object)(object)val == (Object)null) && val.IsLocal && (int)statusType == 7)
			{
				if (ClassCheckUtil.IsTechPriest(val))
				{
					amount = 0f;
				}
				else if (ClassCheckUtil.IsScout(val))
				{
					amount *= 0.5f;
				}
				else if (ClassCheckUtil.IsGeneral(val))
				{
					amount *= 2f;
				}
			}
		}
	}
	[HarmonyPatch(typeof(Item), "StartUseSecondary")]
	public class GobelinAntiFeedPatch
	{
		private static bool Prefix(Item __instance)
		{
			if ((Object)(object)__instance == (Object)null)
			{
				return true;
			}
			if (GobelinDiet.IsPackagedFood(__instance))
			{
				Interaction instance = Interaction.instance;
				if ((Object)(object)instance == (Object)null)
				{
					return true;
				}
				MonoBehaviour value = Traverse.Create((object)instance).Field("bestCharacter").GetValue<MonoBehaviour>();
				if ((Object)(object)value != (Object)null)
				{
					Character value2 = Traverse.Create((object)value).Field("character").GetValue<Character>();
					if ((Object)(object)value2 != (Object)null)
					{
						if (ClassCheckUtil.IsGobelin(value2) && GobelinDiet.IsPackagedFood(__instance))
						{
							ManualLogSource log = PeakClassModPlugin.Log;
							if (log != null)
							{
								log.LogInfo((object)"[Anti-Feed] Blocked feeding industrial food to Gobelin!");
							}
							return false;
						}
						if (ClassCheckUtil.IsTechPriest(value2) && TechPriestBlocker.ShouldBlock(__instance))
						{
							ManualLogSource log2 = PeakClassModPlugin.Log;
							if (log2 != null)
							{
								log2.LogInfo((object)"[Anti-Feed] Blocked feeding to Tech-Priest!");
							}
							return false;
						}
					}
				}
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Character), "FeedItem")]
	public class GobelinAntiFeed_Character_Patch
	{
		private static bool Prefix(Character __instance, Item item)
		{
			if ((Object)(object)__instance == (Object)null || (Object)(object)item == (Object)null)
			{
				return true;
			}
			if (ClassCheckUtil.IsGobelin(__instance) || (__instance.IsLocal && ClassManager.IsGobelinActive()))
			{
				if (GobelinDiet.IsPackagedFood(item))
				{
					ManualLogSource log = PeakClassModPlugin.Log;
					if (log != null)
					{
						log.LogInfo((object)("[Anti-Feed] Gobelin refused to be fed " + ((Object)item).name + "!"));
					}
					return false;
				}
			}
			else if ((ClassCheckUtil.IsTechPriest(__instance) || (__instance.IsLocal && ClassManager.IsTechPriestActive())) && TechPriestBlocker.ShouldBlock(item))
			{
				ManualLogSource log2 = PeakClassModPlugin.Log;
				if (log2 != null)
				{
					log2.LogInfo((object)("[Anti-Feed] Tech-Priest refused to be fed " + ((Object)item).name + "!"));
				}
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Item), "Update")]
	public class GobelinBlowgunEnforcer
	{
		public static bool IsBlowgun(Item item)
		{
			if ((Object)(object)item == (Object)null)
			{
				return false;
			}
			if (item.itemID == 70)
			{
				return true;
			}
			string text = ((Object)item).name.ToLowerInvariant();
			if (text.Contains("dart") || text.Contains("blowgun") || text.Contains("healing") || text.Contains("sarbacane"))
			{
				return true;
			}
			if (item.UIData != null && !string.IsNullOrEmpty(item.UIData.itemName))
			{
				string text2 = item.UIData.itemName.ToLowerInvariant();
				if (text2.Contains("dart") || text2.Contains("blowgun") || text2.Contains("healing") || text2.Contains("sarbacane"))
				{
					return true;
				}
			}
			if ((Object)(object)((Component)item).GetComponent<Action_RaycastDart>() != (Object)null || (Object)(object)((Component)item).GetComponentInChildren<Action_RaycastDart>() != (Object)null)
			{
				return true;
			}
			return false;
		}

		private static void Postfix(Item __instance)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null || !IsBlowgun(__instance) || (Object)(object)__instance.holderCharacter == (Object)null || !ClassCheckUtil.IsGobelin(__instance.holderCharacter))
			{
				return;
			}
			Traverse val = Traverse.Create((object)__instance);
			Traverse val2 = val.Field("overrideUsability");
			if (val2.FieldExists())
			{
				val2.SetValue((object)Optionable<bool>.Some(true));
			}
			__instance.totalUses = -1;
			Action_ReduceUses[] components = ((Component)__instance).GetComponents<Action_ReduceUses>();
			foreach (Action_ReduceUses val3 in components)
			{
				if (!((Object)(object)val3 != (Object)null))
				{
					continue;
				}
				val3.consumeOnFullyUsed = false;
				if (!((Behaviour)val3).enabled)
				{
					continue;
				}
				((Behaviour)val3).enabled = false;
				try
				{
					if (__instance.OnPrimaryFinishedCast != null)
					{
						__instance.OnPrimaryFinishedCast = (Action)Delegate.Remove(__instance.OnPrimaryFinishedCast, new Action(((ItemActionBase)val3).RunAction));
					}
				}
				catch
				{
				}
			}
			Action_Consume[] components2 = ((Component)__instance).GetComponents<Action_Consume>();
			foreach (Action_Consume val4 in components2)
			{
				if (!((Object)(object)val4 != (Object)null) || !((Behaviour)val4).enabled)
				{
					continue;
				}
				((Behaviour)val4).enabled = false;
				try
				{
					if (__instance.OnPrimaryFinishedCast != null)
					{
						__instance.OnPrimaryFinishedCast = (Action)Delegate.Remove(__instance.OnPrimaryFinishedCast, new Action(((ItemActionBase)val4).RunAction));
					}
					if (__instance.OnConsumed != null)
					{
						__instance.OnConsumed = (Action)Delegate.Remove(__instance.OnConsumed, new Action(((ItemActionBase)val4).RunAction));
					}
				}
				catch
				{
				}
			}
			Traverse val5 = val.Field("destroyOnUse");
			if (val5.FieldExists())
			{
				val5.SetValue((object)false);
			}
			try
			{
				if (__instance.data != null && __instance.HasData((DataEntryKey)2))
				{
					OptionableIntItemData data = __instance.GetData<OptionableIntItemData>((DataEntryKey)2);
					if (data != null)
					{
						data.HasData = false;
						data.Value = 999;
					}
				}
			}
			catch
			{
			}
		}

		public static void ApplyGobelinCurse(Character ch)
		{
			if ((Object)(object)ch?.refs?.afflictions == (Object)null)
			{
				return;
			}
			ch.refs.afflictions.AddStatus((STATUSTYPE)5, 0.05f, false, true, true, false);
			try
			{
				GUIManager instance = GUIManager.instance;
				if (instance != null)
				{
					StaminaBar bar = instance.bar;
					if (bar != null)
					{
						bar.ChangeBar();
					}
				}
			}
			catch
			{
			}
		}
	}
	[HarmonyPatch(typeof(Item))]
	public class GobelinCurseOnShootPatch
	{
		private static float _lastCurseShootTime;

		[HarmonyPatch("FinishCastPrimary")]
		[HarmonyPostfix]
		private static void FinishCastPostfix(Item __instance)
		{
			TriggerCurse(__instance);
		}

		private static void TriggerCurse(Item __instance)
		{
			if (!((Object)(object)__instance == (Object)null) && !((Object)(object)__instance.holderCharacter == (Object)null))
			{
				Character holderCharacter = __instance.holderCharacter;
				if (holderCharacter.IsLocal && ClassCheckUtil.IsGobelin(holderCharacter) && GobelinBlowgunEnforcer.IsBlowgun(__instance) && Time.time - _lastCurseShootTime > 0.2f)
				{
					_lastCurseShootTime = Time.time;
					GobelinBlowgunEnforcer.ApplyGobelinCurse(holderCharacter);
				}
			}
		}
	}
	[HarmonyPatch(typeof(Item), "StartUsePrimary")]
	[HarmonyPriority(600)]
	public class GobelinFoodBlockerPrimary
	{
		private static bool Prefix(Item __instance)
		{
			if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.holderCharacter == (Object)null)
			{
				return true;
			}
			if (ClassCheckUtil.IsGobelin(__instance.holderCharacter) || (__instance.holderCharacter.IsLocal && ClassManager.IsGobelinActive()))
			{
				if (GobelinDiet.IsPackagedFood(__instance))
				{
					ManualLogSource log = PeakClassModPlugin.Log;
					if (log != null)
					{
						log.LogInfo((object)("[Gobelin] Refused packaged food: " + ((Object)__instance).name));
					}
					return false;
				}
			}
			else if ((ClassCheckUtil.IsTechPriest(__instance.holderCharacter) || (__instance.holderCharacter.IsLocal && ClassManager.IsTechPriestActive())) && TechPriestBlocker.ShouldBlock(__instance))
			{
				ManualLogSource log2 = PeakClassModPlugin.Log;
				if (log2 != null)
				{
					log2.LogInfo((object)("[TechPriest] Refused food/consumable: " + ((Object)__instance).name));
				}
				__instance.CancelUsePrimary();
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Item), "CanUsePrimary")]
	[HarmonyPriority(600)]
	public class GobelinFoodBlockerPrimary_CanUse
	{
		private static bool Prefix(Item __instance, ref bool __result)
		{
			if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.holderCharacter == (Object)null)
			{
				return true;
			}
			if (ClassCheckUtil.IsGobelin(__instance.holderCharacter) || (__instance.holderCharacter.IsLocal && ClassManager.IsGobelinActive()))
			{
				if (GobelinDiet.IsPackagedFood(__instance))
				{
					__result = false;
					return false;
				}
			}
			else if ((ClassCheckUtil.IsTechPriest(__instance.holderCharacter) || (__instance.holderCharacter.IsLocal && ClassManager.IsTechPriestActive())) && TechPriestBlocker.ShouldBlock(__instance))
			{
				__result = false;
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Item), "StartUseSecondary")]
	[HarmonyPriority(600)]
	public class GobelinFoodBlockerSecondary
	{
		private static bool Prefix(Item __instance)
		{
			if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.holderCharacter == (Object)null)
			{
				return true;
			}
			if (ClassCheckUtil.IsGobelin(__instance.holderCharacter) || (__instance.holderCharacter.IsLocal && ClassManager.IsGobelinActive()))
			{
				if (GobelinDiet.IsPackagedFood(__instance))
				{
					return false;
				}
			}
			else if ((ClassCheckUtil.IsTechPriest(__instance.holderCharacter) || (__instance.holderCharacter.IsLocal && ClassManager.IsTechPriestActive())) && ((!__instance.canUseOnFriend && !__instance.mustUseOnFriend) || !((Object)(object)Interaction.instance != (Object)null) || !Interaction.instance.hasValidTargetCharacter) && TechPriestBlocker.ShouldBlock(__instance))
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Item), "CanUseSecondary")]
	[HarmonyPriority(600)]
	public class GobelinFoodBlockerSecondary_CanUse
	{
		private static bool Prefix(Item __instance, ref bool __result)
		{
			if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.holderCharacter == (Object)null)
			{
				return true;
			}
			if (ClassCheckUtil.IsGobelin(__instance.holderCharacter) || (__instance.holderCharacter.IsLocal && ClassManager.IsGobelinActive()))
			{
				if (GobelinDiet.IsPackagedFood(__instance))
				{
					__result = false;
					return false;
				}
			}
			else if ((ClassCheckUtil.IsTechPriest(__instance.holderCharacter) || (__instance.holderCharacter.IsLocal && ClassManager.IsTechPriestActive())) && ((!__instance.canUseOnFriend && !__instance.mustUseOnFriend) || !((Object)(object)Interaction.instance != (Object)null) || !Interaction.instance.hasValidTargetCharacter) && TechPriestBlocker.ShouldBlock(__instance))
			{
				__result = false;
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Player), "EmptySlot")]
	public static class Player_EmptySlot_Patch
	{
		[HarmonyPrefix]
		public static bool Prefix(Player __instance, Optionable<byte> slot)
		{
			if ((Object)(object)__instance == (Object)null || slot.IsNone || (Object)(object)__instance.character == (Object)null)
			{
				return true;
			}
			if (!ClassCheckUtil.IsGobelin(__instance.character))
			{
				return true;
			}
			ItemSlot itemSlot = __instance.GetItemSlot(slot.Value);
			if (itemSlot != null && (Object)(object)itemSlot.prefab != (Object)null && GobelinBlowgunEnforcer.IsBlowgun(itemSlot.prefab))
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Player), "RPCRemoveItemFromSlot")]
	public static class Player_RPCRemoveItemFromSlot_Patch
	{
		[HarmonyPrefix]
		public static bool Prefix(Player __instance, byte slotID)
		{
			if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.character == (Object)null)
			{
				return true;
			}
			if (!ClassCheckUtil.IsGobelin(__instance.character))
			{
				return true;
			}
			ItemSlot itemSlot = __instance.GetItemSlot(slotID);
			if (itemSlot != null && (Object)(object)itemSlot.prefab != (Object)null && GobelinBlowgunEnforcer.IsBlowgun(itemSlot.prefab))
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Action_Consume), "RunAction")]
	public static class Action_Consume_RunAction_Patch
	{
		[HarmonyPrefix]
		public static bool Prefix(Action_Consume __instance)
		{
			if ((Object)(object)__instance == (Object)null)
			{
				return true;
			}
			Item val = Traverse.Create((object)__instance).Field("item").GetValue<Item>() ?? ((Component)__instance).GetComponent<Item>() ?? ((Component)__instance).GetComponentInParent<Item>();
			if ((Object)(object)val != (Object)null && (Object)(object)val.holderCharacter != (Object)null && ClassCheckUtil.IsGobelin(val.holderCharacter) && GobelinBlowgunEnforcer.IsBlowgun(val))
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Action_ReduceUses), "RunAction")]
	public static class Action_ReduceUses_RunAction_Patch
	{
		[HarmonyPrefix]
		public static bool Prefix(Action_ReduceUses __instance)
		{
			if ((Object)(object)__instance == (Object)null)
			{
				return true;
			}
			Item val = Traverse.Create((object)__instance).Field("item").GetValue<Item>() ?? ((Component)__instance).GetComponent<Item>() ?? ((Component)__instance).GetComponentInParent<Item>();
			if ((Object)(object)val != (Object)null && (Object)(object)val.holderCharacter != (Object)null && ClassCheckUtil.IsGobelin(val.holderCharacter) && GobelinBlowgunEnforcer.IsBlowgun(val))
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Action_ReduceUses), "ReduceUsesRPC")]
	public static class Action_ReduceUses_ReduceUsesRPC_Patch
	{
		[HarmonyPrefix]
		public static bool Prefix(Action_ReduceUses __instance)
		{
			if ((Object)(object)__instance == (Object)null)
			{
				return true;
			}
			Item val = Traverse.Create((object)__instance).Field("item").GetValue<Item>() ?? ((Component)__instance).GetComponent<Item>() ?? ((Component)__instance).GetComponentInParent<Item>();
			if ((Object)(object)val != (Object)null && (Object)(object)val.holderCharacter != (Object)null && ClassCheckUtil.IsGobelin(val.holderCharacter) && GobelinBlowgunEnforcer.IsBlowgun(val))
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Item), "ConsumeDelayed")]
	public static class Item_ConsumeDelayed_Patch
	{
		[HarmonyPrefix]
		public static bool Prefix(Item __instance, ref IEnumerator __result)
		{
			if ((Object)(object)__instance != (Object)null && (Object)(object)__instance.holderCharacter != (Object)null && ClassCheckUtil.IsGobelin(__instance.holderCharacter) && GobelinBlowgunEnforcer.IsBlowgun(__instance))
			{
				__result = EmptyRoutine();
				return false;
			}
			return true;
		}

		private static IEnumerator EmptyRoutine()
		{
			yield break;
		}
	}
	[HarmonyPatch(typeof(Item), "Consume", new Type[] { typeof(int) })]
	public static class Item_Consume_Int_Patch
	{
		[HarmonyPrefix]
		public static bool Prefix(Item __instance, int consumerID)
		{
			if ((Object)(object)__instance != (Object)null && (Object)(object)__instance.holderCharacter != (Object)null && ClassCheckUtil.IsGobelin(__instance.holderCharacter) && GobelinBlowgunEnforcer.IsBlowgun(__instance))
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(CharacterItems), "DestroyHeldItemRpc")]
	public static class CharacterItems_DestroyHeldItemRpc_Patch
	{
		[HarmonyPrefix]
		public static bool Prefix(CharacterItems __instance)
		{
			if ((Object)(object)__instance == (Object)null)
			{
				return true;
			}
			Character component = ((Component)__instance).GetComponent<Character>();
			if ((Object)(object)component != (Object)null && ClassCheckUtil.IsGobelin(component) && (Object)(object)component.data != (Object)null && (Object)(object)component.data.currentItem != (Object)null && GobelinBlowgunEnforcer.IsBlowgun(component.data.currentItem))
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(CharacterItems), "DropItemRpc")]
	public static class CharacterItems_DropItemRpc_Patch
	{
		[HarmonyPrefix]
		public static bool Prefix(CharacterItems __instance, byte slotID)
		{
			if ((Object)(object)__instance == (Object)null)
			{
				return true;
			}
			Character val = ((Component)__instance).GetComponent<Character>() ?? ((Component)__instance).GetComponentInParent<Character>();
			if ((Object)(object)val == (Object)null || (Object)(object)val.player == (Object)null)
			{
				return true;
			}
			if (ClassCheckUtil.IsGobelin(val) || (val.IsLocal && ClassManager.IsGobelinActive()))
			{
				ItemSlot itemSlot = val.player.GetItemSlot(slotID);
				if (itemSlot != null && (Object)(object)itemSlot.prefab != (Object)null && GobelinBlowgunEnforcer.IsBlowgun(itemSlot.prefab))
				{
					return false;
				}
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(CharacterItems), "DropItemFromSlotRPC")]
	public static class CharacterItems_DropItemFromSlotRPC_Patch
	{
		[HarmonyPrefix]
		public static bool Prefix(CharacterItems __instance, byte slotID)
		{
			if ((Object)(object)__instance == (Object)null)
			{
				return true;
			}
			Character val = ((Component)__instance).GetComponent<Character>() ?? ((Component)__instance).GetComponentInParent<Character>();
			if ((Object)(object)val == (Object)null || (Object)(object)val.player == (Object)null)
			{
				return true;
			}
			if (ClassCheckUtil.IsGobelin(val) || (val.IsLocal && ClassManager.IsGobelinActive()))
			{
				ItemSlot itemSlot = val.player.GetItemSlot(slotID);
				if (itemSlot != null && (Object)(object)itemSlot.prefab != (Object)null && GobelinBlowgunEnforcer.IsBlowgun(itemSlot.prefab))
				{
					return false;
				}
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Item), "FinishCastPrimary")]
	public static class Item_FinishCastPrimary_Patch
	{
		[HarmonyPostfix]
		public static void Postfix(Item __instance)
		{
			if ((Object)(object)__instance != (Object)null && (Object)(object)__instance.holderCharacter != (Object)null && ClassCheckUtil.IsGobelin(__instance.holderCharacter) && GobelinBlowgunEnforcer.IsBlowgun(__instance))
			{
				__instance.finishedCast = false;
				__instance.isUsingPrimary = false;
				Traverse.Create((object)__instance).Property("castProgress", (object[])null).SetValue((object)0f);
			}
		}
	}
	[HarmonyPatch(typeof(CharacterItems), "DoUsing")]
	public static class CharacterItems_DoUsing_Patch
	{
		[HarmonyPrefix]
		public static bool Prefix(CharacterItems __instance)
		{
			if ((Object)(object)__instance == (Object)null)
			{
				return true;
			}
			Character component = ((Component)__instance).GetComponent<Character>();
			if ((Object)(object)component == (Object)null || (Object)(object)component.data == (Object)null || (Object)(object)component.data.currentItem == (Object)null)
			{
				return true;
			}
			if (ClassCheckUtil.IsGobelin(component))
			{
				if (component.data.currentItem.itemID == 70 || GobelinBlowgunEnforcer.IsBlowgun(component.data.currentItem))
				{
					return false;
				}
				if (GobelinDiet.IsPackagedFood(component.data.currentItem))
				{
					return false;
				}
			}
			else if ((ClassCheckUtil.IsTechPriest(component) || (component.IsLocal && ClassManager.IsTechPriestActive())) && TechPriestBlocker.ShouldBlock(component.data.currentItem))
			{
				if (component.data.currentItem.isUsingPrimary)
				{
					component.data.currentItem.CancelUsePrimary();
				}
				if (component.data.currentItem.isUsingSecondary)
				{
					component.data.currentItem.CancelUseSecondary();
				}
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Item), "StartInteract")]
	public static class GobelinPickupBlocker
	{
		[HarmonyPrefix]
		public static bool Prefix(Item __instance, Character interactor)
		{
			if ((Object)(object)__instance == (Object)null || (Object)(object)interactor == (Object)null)
			{
				return true;
			}
			if ((ClassCheckUtil.IsGobelin(interactor) || (interactor.IsLocal && ClassManager.IsGobelinActive())) && GobelinBlowgunEnforcer.IsBlowgun(__instance) && HasAnyBlowgun(interactor))
			{
				ManualLogSource log = PeakClassModPlugin.Log;
				if (log != null)
				{
					log.LogInfo((object)"[Gobelin] Déjà une sarbacane possédée : ramassage d'une 2ème sarbacane refusé.");
				}
				return false;
			}
			return true;
		}

		[HarmonyPatch(typeof(Item), "CanInteract")]
		[HarmonyPostfix]
		public static void PostfixCanInteract(Item __instance, Character character, ref bool __result)
		{
			if (__result && !((Object)(object)__instance == (Object)null) && !((Object)(object)character == (Object)null) && (ClassCheckUtil.IsGobelin(character) || (character.IsLocal && ClassManager.IsGobelinActive())) && GobelinBlowgunEnforcer.IsBlowgun(__instance) && HasAnyBlowgun(character))
			{
				__result = false;
			}
		}

		private static bool HasAnyBlowgun(Character ch)
		{
			if ((Object)(object)ch == (Object)null)
			{
				return false;
			}
			if ((Object)(object)ch.data != (Object)null && (Object)(object)ch.data.currentItem != (Object)null && GobelinBlowgunEnforcer.IsBlowgun(ch.data.currentItem))
			{
				return true;
			}
			if ((Object)(object)ch.player != (Object)null && ch.player.itemSlots != null)
			{
				ItemSlot[] itemSlots = ch.player.itemSlots;
				foreach (ItemSlot val in itemSlots)
				{
					if (val != null && (Object)(object)val.prefab != (Object)null && GobelinBlowgunEnforcer.IsBlowgun(val.prefab))
					{
						return true;
					}
				}
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(CharacterAfflictions), "AddAffliction")]
	public class GobelinSporeAfflictionPatch
	{
		private static bool Prefix(CharacterAfflictions __instance, Affliction affliction)
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Invalid comparison between Unknown and I4
			if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.character == (Object)null || affliction == null)
			{
				return true;
			}
			Character character = __instance.character;
			if ((character.IsLocal && ClassManager.IsGobelinActive()) || ClassCheckUtil.IsGobelin(character))
			{
				if (affliction is Affliction_Chaos || (int)affliction.GetAfflictionType() == 6)
				{
					ManualLogSource log = PeakClassModPlugin.Log;
					if (log != null)
					{
						log.LogInfo((object)"[Gobelin] Confusion (Chaos) blocked!");
					}
					return false;
				}
				string name = ((object)affliction).GetType().Name;
				if (name.Contains("Chaos") || name.Contains("Confus") || name.Contains("Spore") || name.Contains("ZombieBite"))
				{
					ManualLogSource log2 = PeakClassModPlugin.Log;
					if (log2 != null)
					{
						log2.LogInfo((object)("[Gobelin] Affliction " + name + " blocked!"));
					}
					return false;
				}
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Player), "SyncInventoryRPC")]
	public static class Player_SyncInventoryRPC_Patch
	{
		private static void Postfix(Player __instance)
		{
			try
			{
				if ((Object)(object)__instance != (Object)null && (Object)(object)((MonoBehaviourPun)__instance).photonView != (Object)null && ((MonoBehaviourPun)__instance).photonView.IsMine)
				{
					GUIManager instance = GUIManager.instance;
					if (instance != null)
					{
						instance.UpdateItems();
					}
				}
			}
			catch
			{
			}
		}
	}
	[HarmonyPatch(typeof(CharacterAfflictions), "AddAffliction")]
	public class MushroomancerPoisonAfflictionPatch
	{
		private static bool Prefix(CharacterAfflictions __instance, Affliction affliction)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.character == (Object)null || affliction == null)
			{
				return true;
			}
			Character character = __instance.character;
			if (((character.IsLocal && ClassManager.IsMushroomancerActive()) || ClassCheckUtil.IsMushroom(character)) && (affliction is Affliction_PoisonOverTime || (int)affliction.GetAfflictionType() == 0 || ((object)affliction).GetType().Name.Contains("Poison")))
			{
				ManualLogSource log = PeakClassModPlugin.Log;
				if (log != null)
				{
					log.LogInfo((object)"[Mushroomancer] Poison affliction blocked!");
				}
				return false;
			}
			return true;
		}
	}
	public static class RogueJumpHelper
	{
		public static bool HasRogueStamina(Character ch)
		{
			if ((Object)(object)ch == (Object)null || (Object)(object)ch.data == (Object)null)
			{
				return false;
			}
			if (ch.data.passedOut || ch.data.fullyPassedOut)
			{
				return false;
			}
			if (ch.infiniteStam)
			{
				return true;
			}
			if (ch.data.currentStamina <= 0.005f && ch.data.extraStamina <= 0.001f)
			{
				return false;
			}
			return true;
		}

		public static bool IsRogue(Character ch)
		{
			if ((Object)(object)ch != (Object)null && ch.IsLocal)
			{
				if (!PeakClassModPlugin.rogueActive && !ClassManager.IsRogueActive())
				{
					return ClassCheckUtil.IsRogueHat(ch);
				}
				return true;
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(CharacterAfflictions), "UpdateExtraJumps")]
	public static class RogueUpdateExtraJumpsPatch
	{
		[HarmonyPostfix]
		public static void Postfix(CharacterAfflictions __instance)
		{
			if ((Object)(object)__instance == (Object)null || (Object)(object)__instance.character == (Object)null)
			{
				return;
			}
			Character character = __instance.character;
			if (!RogueJumpHelper.IsRogue(character))
			{
				return;
			}
			if (RogueJumpHelper.HasRogueStamina(character))
			{
				__instance.totalExtraJumps = 99;
				if ((Object)(object)character.data != (Object)null)
				{
					character.data.extraJumps = 99;
				}
			}
			else
			{
				__instance.totalExtraJumps = 0;
				if ((Object)(object)character.data != (Object)null)
				{
					character.data.extraJumps = 0;
				}
			}
		}
	}
	[HarmonyPatch(typeof(CharacterMovement), "TryToJump")]
	public static class RogueTryToJumpPatch
	{
		[HarmonyPrefix]
		public static bool Prefix(CharacterMovement __instance)
		{
			Character val = ((__instance != null) ? ((Component)__instance).GetComponent<Character>() : null) ?? ((__instance != null) ? ((Component)__instance).GetComponentInParent<Character>() : null) ?? Character.localCharacter;
			if (RogueJumpHelper.IsRogue(val))
			{
				if (!RogueJumpHelper.HasRogueStamina(val))
				{
					if ((Object)(object)val.data != (Object)null)
					{
						val.data.extraJumps = 0;
					}
					if ((Object)(object)val.refs?.afflictions != (Object)null)
					{
						val.refs.afflictions.totalExtraJumps = 0;
					}
					return false;
				}
				if ((Object)(object)val.data != (Object)null)
				{
					val.data.extraJumps = 99;
					val.data.chargingJump = false;
					if (val.data.sinceJump < 0.1f)
					{
						val.data.sinceJump = 0.12f;
					}
					if ((Object)(object)val.refs?.afflictions != (Object)null)
					{
						val.refs.afflictions.totalExtraJumps = 99;
					}
				}
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(CharacterMovement), "JumpRpc")]
	public static class RogueJumpRpcPatch
	{
		[HarmonyPrefix]
		public static bool Prefix(CharacterMovement __instance)
		{
			Character ch = ((__instance != null) ? ((Component)__instance).GetComponent<Character>() : null) ?? ((__instance != null) ? ((Component)__instance).GetComponentInParent<Character>() : null) ?? Character.localCharacter;
			if (RogueJumpHelper.IsRogue(ch) && !RogueJumpHelper.HasRogueStamina(ch))
			{
				return false;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(CharacterMovement), "UpdateMovement")]
	public static class RogueUpdateMovementPatch
	{
		[HarmonyPrefix]
		public static void Prefix(CharacterMovement __instance)
		{
			Character val = ((__instance != null) ? ((Component)__instance).GetComponent<Character>() : null) ?? ((__instance != null) ? ((Component)__instance).GetComponentInParent<Character>() : null) ?? Character.localCharacter;
			if (!RogueJumpHelper.IsRogue(val))
			{
				return;
			}
			if (RogueJumpHelper.HasRogueStamina(val))
			{
				if ((Object)(object)val.data != (Object)null)
				{
					val.data.extraJumps = 99;
				}
				if ((Object)(object)val.refs?.afflictions != (O