Decompiled source of Weedheim v1.8.3

plugins/Weedheim.dll

Decompiled 6 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using HarmonyLib;
using Jotunn;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using RecipeCustomisation;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.PostProcessing;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("Weedheim")]
[assembly: AssemblyDescription("https://discord.gg/khjfYmQ4fX")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("MagicMike")]
[assembly: AssemblyProduct("Weedheim")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("e3243d22-4307-4008-ba36-9f326008cde5")]
[assembly: AssemblyFileVersion("1.8.3")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.8.3.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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;
		}
	}
}
public class WH_LokiBelt : SE_Stats
{
	public bool m_enablePing;

	public EffectList m_pingEffectNear = new EffectList();

	public EffectList m_pingEffectMed = new EffectList();

	public EffectList m_pingEffectFar = new EffectList();

	public float m_closerTriggerDistance = 4f;

	public float m_furtherTriggerDistance = 6f;

	public float m_closeFrequency = 0.5f;

	public float m_distantFrequency = 3f;

	private float m_updateBeaconTimer;

	private float m_pingTimer;

	private Beacon m_beacon;

	private float m_lastDistance;

	public override void UpdateStatusEffect(float dt)
	{
		//IL_003c: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Unknown result type (might be due to invalid IL or missing references)
		if (!m_enablePing)
		{
			return;
		}
		m_updateBeaconTimer += dt;
		if (m_updateBeaconTimer > 1f)
		{
			m_updateBeaconTimer = 0f;
			Beacon val = Beacon.FindClosestBeaconInRange(((Component)((StatusEffect)this).m_character).transform.position);
			if ((Object)(object)val != (Object)(object)m_beacon)
			{
				m_beacon = val;
				if (Object.op_Implicit((Object)(object)m_beacon))
				{
					m_lastDistance = Utils.DistanceXZ(((Component)((StatusEffect)this).m_character).transform.position, ((Component)m_beacon).transform.position);
					m_pingTimer = 0f;
				}
			}
		}
		if (!((Object)(object)m_beacon != (Object)null))
		{
			return;
		}
		float num = Utils.DistanceXZ(((Component)((StatusEffect)this).m_character).transform.position, ((Component)m_beacon).transform.position);
		float num2 = Mathf.Clamp01(num / m_beacon.m_range);
		float num3 = Mathf.Lerp(m_closeFrequency, m_distantFrequency, num2);
		m_pingTimer += dt;
		if (m_pingTimer > num3)
		{
			m_pingTimer = 0f;
			if (num2 < 0.2f)
			{
				m_pingEffectNear.Create(((Component)((StatusEffect)this).m_character).transform.position, ((Component)((StatusEffect)this).m_character).transform.rotation, ((Component)((StatusEffect)this).m_character).transform, 1f, -1);
			}
			else if (num2 < 0.6f)
			{
				m_pingEffectMed.Create(((Component)((StatusEffect)this).m_character).transform.position, ((Component)((StatusEffect)this).m_character).transform.rotation, ((Component)((StatusEffect)this).m_character).transform, 1f, -1);
			}
			else
			{
				m_pingEffectFar.Create(((Component)((StatusEffect)this).m_character).transform.position, ((Component)((StatusEffect)this).m_character).transform.rotation, ((Component)((StatusEffect)this).m_character).transform, 1f, -1);
			}
			m_lastDistance = num;
		}
	}
}
namespace RecipeCustomisation
{
	internal class RecipeData
	{
		public string name;

		public int originalAmount;

		public string craftingStation;

		public int minStationLevel;

		public int amount;

		public List<string> reqs = new List<string>();
	}
}
namespace Weedheim
{
	internal class CampingPatches
	{
		[HarmonyPatch(typeof(Bed), "CheckExposure")]
		public static class Tent_NoRoof_Patch
		{
			private static bool Prefix(Bed __instance, ref bool __result)
			{
				if (((Object)((Component)__instance).gameObject).name.Contains("mm_piece_sleeping_bag_new") && MainConfig.campsiteCheckExposure.Value)
				{
					__result = true;
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Bed), "CheckWet")]
		public static class Tent_NoWet_Patch
		{
			private static bool Prefix(Bed __instance, ref bool __result)
			{
				if (((Object)((Component)__instance).gameObject).name.Contains("mm_piece_sleeping_bag_new") && MainConfig.campsiteCheckWet.Value)
				{
					__result = true;
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Bed), "CheckEnemies")]
		public static class Tent_NoMonster_Patch
		{
			private static bool Prefix(Bed __instance, ref bool __result)
			{
				if (((Object)((Component)__instance).gameObject).name.Contains("mm_piece_sleeping_bag_new") && MainConfig.campsiteCheckEnemies.Value)
				{
					__result = true;
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Bed), "CheckFire")]
		public static class Tent_NoFire_Patch
		{
			private static bool Prefix(Bed __instance, ref bool __result)
			{
				if (((Object)((Component)__instance).gameObject).name.Contains("mm_piece_sleeping_bag_new") && MainConfig.campsiteCheckFire.Value)
				{
					__result = true;
					return false;
				}
				return true;
			}
		}
	}
	public static class InventoryHelper
	{
		public static string PrefabName(this ItemData item)
		{
			if (Object.op_Implicit((Object)(object)item.m_dropPrefab))
			{
				return ((Object)item.m_dropPrefab).name;
			}
			Logger.LogWarning((object)("Item has missing prefab " + item.m_shared.m_name));
			return item.m_shared.m_name;
		}
	}
	internal class EffectPatches
	{
		[HarmonyPatch(typeof(Player), "Update")]
		private class DruggedEffect
		{
			private static void Postfix(ref Player __instance)
			{
				//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
				//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
				//IL_0307: Unknown result type (might be due to invalid IL or missing references)
				//IL_030c: Unknown result type (might be due to invalid IL or missing references)
				//IL_05d3: Unknown result type (might be due to invalid IL or missing references)
				//IL_05fd: Unknown result type (might be due to invalid IL or missing references)
				//IL_0612: Unknown result type (might be due to invalid IL or missing references)
				//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
				//IL_04a6: Unknown result type (might be due to invalid IL or missing references)
				if (!((Character)__instance).m_nview.IsValid() || !((Character)__instance).m_nview.IsOwner() || __instance.GetPlayerID() != Player.m_localPlayer.GetPlayerID())
				{
					return;
				}
				PostProcessingBehaviour component = ((Component)GameCamera.instance).gameObject.GetComponent<PostProcessingBehaviour>();
				if (!((Object)(object)component != (Object)null) || MainConfig.modEnabled.Value != MainConfig.Toggle.On)
				{
					return;
				}
				bool flag = false;
				bool flag2 = false;
				if (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("FlyagaricStatusEffect")) || ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("LibertyStatusEffect")))
				{
					if (MainConfig.trippingVFX.Value != MainConfig.Toggle.On)
					{
						return;
					}
					flag = true;
				}
				if (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("WeedPieStatusEffect")) || ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SmoothieStatusEffect")) || ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BadgerStatusEffect")) || ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("KushStatusEffect")) || ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("MysticStatusEffect")) || ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("CherryStatusEffect")) || ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("WidowStatusEffect")) || ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BongStatusEffect")) || ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("HookahStatusEffect")) || ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BrownieStatusEffect")) || ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("DesireStatusEffect")) || ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("LightsStatusEffect")) || ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("PoisonStatusEffect")) || ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("PipeStatusEffect")) || ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("DabStatusEffect")) || ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("MossyStatusEffect")) || ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("LeechStatusEffect")) || (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("TickStatusEffect")) && !((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("FlyagaricStatusEffect")) && !((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("LibertyStatusEffect"))))
				{
					if (MainConfig.stonedVFX.Value != MainConfig.Toggle.On)
					{
						return;
					}
					flag2 = true;
				}
				if (flag)
				{
					flag2 = false;
					((PostProcessingModel)((PostProcessingComponent<VignetteModel>)(object)component.m_Vignette).model).enabled = true;
					((PostProcessingComponent<VignetteModel>)(object)component.m_Vignette).model.m_Settings.color = Color.Lerp(rainbowcolors[rainbowcurrent], rainbowcolors[rainbownext], rainbowtimer / rainbowchangeevery);
					((PostProcessingComponent<VignetteModel>)(object)component.m_Vignette).model.m_Settings.intensity = Mathf.Min(0.2f, ((PostProcessingComponent<VignetteModel>)(object)component.m_Vignette).model.m_Settings.intensity + 0.01f);
					rainbowtimer += Time.deltaTime;
					if (rainbowtimer > rainbowchangeevery)
					{
						rainbowcurrent = (rainbowcurrent + 1) % rainbowcolors.Length;
						rainbownext = (rainbowcurrent + 1) % rainbowcolors.Length;
						rainbowtimer = 0f;
					}
					((PostProcessingModel)((PostProcessingComponent<ChromaticAberrationModel>)(object)component.m_ChromaticAberration).model).enabled = true;
					((PostProcessingComponent<ChromaticAberrationModel>)(object)component.m_ChromaticAberration).model.m_Settings.intensity = Mathf.Min(2f, ((PostProcessingComponent<ChromaticAberrationModel>)(object)component.m_ChromaticAberration).model.m_Settings.intensity + 0.5f);
					if (((PostProcessingComponent<ColorGradingModel>)(object)component.m_ColorGrading).model.m_Settings.basic.saturation == 2f)
					{
						return;
					}
					((PostProcessingComponent<ColorGradingModel>)(object)component.m_ColorGrading).model.m_Settings.basic.saturation = Mathf.Min(2f, ((PostProcessingComponent<ColorGradingModel>)(object)component.m_ColorGrading).model.m_Settings.basic.saturation + 0.05f);
					((PostProcessingComponent<ColorGradingModel>)(object)component.m_ColorGrading).model.isDirty = true;
				}
				else if (flag2)
				{
					if (!flag)
					{
						((PostProcessingModel)((PostProcessingComponent<VignetteModel>)(object)component.m_Vignette).model).enabled = true;
						((PostProcessingComponent<VignetteModel>)(object)component.m_Vignette).model.m_Settings.color = new Color(5f, 0f, 0f, 0.1f);
						((PostProcessingComponent<VignetteModel>)(object)component.m_Vignette).model.m_Settings.intensity = Mathf.Min(0.4f, ((PostProcessingComponent<VignetteModel>)(object)component.m_Vignette).model.m_Settings.intensity + 0.01f);
						((PostProcessingModel)((PostProcessingComponent<ChromaticAberrationModel>)(object)component.m_ChromaticAberration).model).enabled = true;
						((PostProcessingComponent<ChromaticAberrationModel>)(object)component.m_ChromaticAberration).model.m_Settings.intensity = Mathf.Min(1f, ((PostProcessingComponent<ChromaticAberrationModel>)(object)component.m_ChromaticAberration).model.m_Settings.intensity + 0.01f);
						if (((PostProcessingComponent<ColorGradingModel>)(object)component.m_ColorGrading).model.m_Settings.basic.saturation == 2f)
						{
							return;
						}
						((PostProcessingComponent<ColorGradingModel>)(object)component.m_ColorGrading).model.m_Settings.basic.saturation = Mathf.Min(1f, ((PostProcessingComponent<ColorGradingModel>)(object)component.m_ColorGrading).model.m_Settings.basic.saturation + 0.01f);
						((PostProcessingComponent<ColorGradingModel>)(object)component.m_ColorGrading).model.isDirty = true;
					}
				}
				else
				{
					((PostProcessingComponent<ColorGradingModel>)(object)component.m_ColorGrading).model.m_Settings.basic.saturation = 2f;
					((PostProcessingComponent<VignetteModel>)(object)component.m_Vignette).model.settings = defaultVignetteSettings;
					((PostProcessingModel)((PostProcessingComponent<VignetteModel>)(object)component.m_Vignette).model).enabled = defaultVignetteEnabled;
					((PostProcessingComponent<ChromaticAberrationModel>)(object)component.m_ChromaticAberration).model.settings = defaultCASettings;
					((PostProcessingComponent<ColorGradingModel>)(object)component.m_ColorGrading).model.settings = defaultColorGradingSettings;
				}
				if (((Character)__instance).IsDead() || ((Character)__instance).InCutscene() || __instance.IsSleeping())
				{
					LastSpliffTime = DateTime.MinValue;
					LastPipeTime = DateTime.MinValue;
					LastDabTime = DateTime.MinValue;
					LastShroomTime = DateTime.MinValue;
					LastBrownieTime = DateTime.MinValue;
					LastPieTime = DateTime.MinValue;
					LastSmoothieTime = DateTime.MinValue;
					LastCocaineTime = DateTime.MinValue;
					lastEitrTime = DateTime.MinValue;
					lastHealthTime = DateTime.MinValue;
					lastStaminaTime = DateTime.MinValue;
				}
			}
		}

		[HarmonyPatch(typeof(Player), "FixedUpdate")]
		private class CheckRested
		{
			private static void Postfix(ref Player __instance)
			{
				if (MainConfig.hookahRested.Value && ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("Rested")) && ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("WH_Rested")))
				{
					float remaningTime = ((Character)__instance).GetSEMan().GetStatusEffect(StringExtensionMethods.GetStableHashCode("Rested")).GetRemaningTime();
					float remaningTime2 = ((Character)__instance).GetSEMan().GetStatusEffect(StringExtensionMethods.GetStableHashCode("WH_Rested")).GetRemaningTime();
					if (remaningTime > remaningTime2)
					{
						((Character)__instance).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("WH_Rested"), true);
					}
					else
					{
						((Character)__instance).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("Rested"), true);
					}
				}
				if (MainConfig.dabRested.Value && ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("Rested")) && ((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("WH_Rested_Dab")))
				{
					float remaningTime3 = ((Character)__instance).GetSEMan().GetStatusEffect(StringExtensionMethods.GetStableHashCode("Rested")).GetRemaningTime();
					float remaningTime4 = ((Character)__instance).GetSEMan().GetStatusEffect(StringExtensionMethods.GetStableHashCode("WH_Rested_Dab")).GetRemaningTime();
					if (remaningTime3 > remaningTime4)
					{
						((Character)__instance).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("WH_Rested_Dab"), true);
					}
					else
					{
						((Character)__instance).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("Rested"), true);
					}
				}
			}
		}

		[HarmonyPatch(typeof(PostProcessingBehaviour), "OnEnable")]
		private static class PostProcessingBehaviour_OnEnable_Patch
		{
			private static void Prefix(PostProcessingBehaviour __instance)
			{
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Unknown result type (might be due to invalid IL or missing references)
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_005f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)__instance.profile != (Object)null && !defaultPostProcessingSet)
				{
					defaultVignetteSettings = __instance.profile.vignette.settings;
					defaultVignetteEnabled = ((PostProcessingModel)__instance.profile.vignette).enabled;
					defaultCASettings = __instance.profile.chromaticAberration.settings;
					defaultColorGradingSettings = __instance.profile.colorGrading.settings;
					defaultPostProcessingSet = true;
				}
			}
		}

		[HarmonyPatch(typeof(StatusEffect), "Setup")]
		private static class StatusEffectSetUpPatch
		{
			private static void Postfix(StatusEffect __instance)
			{
				if (((Object)__instance).name == "PipeStatusEffect")
				{
					LastPipeTime = DateTime.Now;
				}
				if (((Object)__instance).name == "DabStatusEffect")
				{
					LastDabTime = DateTime.Now;
				}
				if (((Object)__instance).name == "BadgerStatusEffect" || ((Object)__instance).name == "KushStatusEffect" || ((Object)__instance).name == "MysticStatusEffect" || ((Object)__instance).name == "CherryStatusEffect" || ((Object)__instance).name == "WidowStatusEffect" || ((Object)__instance).name == "DesireStatusEffect" || ((Object)__instance).name == "LightsStatusEffect" || ((Object)__instance).name == "PoisonStatusEffect" || ((Object)__instance).name == "BongStatusEffect")
				{
					LastSpliffTime = DateTime.Now;
				}
				if (((Object)__instance).name == "FlyagaricStatusEffect" || ((Object)__instance).name == "LibertyStatusEffect")
				{
					LastShroomTime = DateTime.Now;
				}
				if (((Object)__instance).name == "BrownieStatusEffect")
				{
					LastBrownieTime = DateTime.Now;
				}
				if (((Object)__instance).name == "WeedPieStatusEffect")
				{
					LastPieTime = DateTime.Now;
				}
				if (((Object)__instance).name == "SmoothieStatusEffect")
				{
					LastSmoothieTime = DateTime.Now;
				}
				if (((Object)__instance).name == "CocaineStatusEffect")
				{
					LastCocaineTime = DateTime.Now;
				}
			}
		}

		[HarmonyPatch(typeof(Player), "ConsumeItem")]
		private static class Player_ConsumeItem_Patch
		{
			private static bool Prefix(Player __instance, ItemData item)
			{
				if (!IsConsumable(((Object)item.m_dropPrefab).name) || (Object)(object)Player.m_localPlayer == (Object)null || item == null)
				{
					return true;
				}
				if (((Object)item.m_dropPrefab).name == "LokisSpecialBlend")
				{
					if (((Humanoid)__instance).m_visEquipment.m_rightItem != "LokisMagicalPipe")
					{
						return false;
					}
					if ((int)((double)(MainConfig.pipeCooldown.Value + MainConfig.pipeDuration.Value) - (DateTime.Now - LastPipeTime).TotalSeconds) >= 0)
					{
						((Character)Player.m_localPlayer).Message((MessageType)2, string.Format(Localization.instance.Localize("$cooldown_pipe"), (int)((double)(MainConfig.pipeCooldown.Value + MainConfig.pipeDuration.Value) - (DateTime.Now - LastPipeTime).TotalSeconds)), 0, (Sprite)null);
						return false;
					}
				}
				if (((Object)item.m_dropPrefab).name == "PotentDab")
				{
					if (((Humanoid)__instance).m_visEquipment.m_rightItem != "mighty_dab_rig")
					{
						return false;
					}
					if (!((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("WH_Rested")) && !((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("WH_Rested_Dab")))
					{
						((Character)Player.m_localPlayer).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("WH_Rested_Dab"), true, 0, 0f);
					}
					if ((int)((double)(MainConfig.dabCooldown.Value + MainConfig.dabDuration.Value) - (DateTime.Now - LastDabTime).TotalSeconds) >= 0)
					{
						((Character)Player.m_localPlayer).Message((MessageType)2, string.Format(Localization.instance.Localize("$cooldown_dab"), (int)((double)(MainConfig.dabCooldown.Value + MainConfig.dabDuration.Value) - (DateTime.Now - LastDabTime).TotalSeconds)), 0, (Sprite)null);
						return false;
					}
				}
				if (((Object)item.m_dropPrefab).name == "flyagaric_wine")
				{
					if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BrownieStatusEffect")) || ((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("CocaineStatusEffect")))
					{
						if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BrownieStatusEffect")))
						{
							((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("BrownieStatusEffect"), true);
						}
						if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("CocaineStatusEffect")))
						{
							((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("CocaineStatusEffect"), true);
						}
						((Character)Player.m_localPlayer).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("Puke"), true, 0, 0f);
						return false;
					}
					if ((int)((double)(MainConfig.flyagaricCooldown.Value + MainConfig.flyagaricDuration.Value) - (DateTime.Now - LastShroomTime).TotalSeconds) >= 0)
					{
						((Character)Player.m_localPlayer).Message((MessageType)2, string.Format(Localization.instance.Localize("$cooldown_mushroom"), (int)((double)(MainConfig.flyagaricCooldown.Value + MainConfig.flyagaricDuration.Value) - (DateTime.Now - LastShroomTime).TotalSeconds)), 0, (Sprite)null);
						return false;
					}
				}
				if (((Object)item.m_dropPrefab).name == "mushroom_brew")
				{
					if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BrownieStatusEffect")) || ((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("CocaineStatusEffect")))
					{
						if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BrownieStatusEffect")))
						{
							((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("BrownieStatusEffect"), true);
						}
						if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("CocaineStatusEffect")))
						{
							((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("CocaineStatusEffect"), true);
						}
						((Character)Player.m_localPlayer).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("Puke"), true, 0, 0f);
						return false;
					}
					if ((int)((double)(MainConfig.libertyCooldown.Value + MainConfig.libertyDuration.Value) - (DateTime.Now - LastShroomTime).TotalSeconds) >= 0)
					{
						((Character)Player.m_localPlayer).Message((MessageType)2, string.Format(Localization.instance.Localize("$cooldown_mushroom"), (int)((double)(MainConfig.libertyCooldown.Value + MainConfig.libertyDuration.Value) - (DateTime.Now - LastShroomTime).TotalSeconds)), 0, (Sprite)null);
						return false;
					}
				}
				if (MainConfig.mushroomConsumable.Value == MainConfig.Toggle.On)
				{
					if (((Object)item.m_dropPrefab).name == "FlyagaricMushroom")
					{
						if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BrownieStatusEffect")) || ((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("CocaineStatusEffect")))
						{
							if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BrownieStatusEffect")))
							{
								((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("BrownieStatusEffect"), true);
							}
							if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("CocaineStatusEffect")))
							{
								((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("CocaineStatusEffect"), true);
							}
							((Character)Player.m_localPlayer).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("Puke"), true, 0, 0f);
							return false;
						}
						if ((int)((double)(MainConfig.flyagaricCooldown.Value + MainConfig.flyagaricDuration.Value) - (DateTime.Now - LastShroomTime).TotalSeconds) >= 0)
						{
							((Character)Player.m_localPlayer).Message((MessageType)2, string.Format(Localization.instance.Localize("$cooldown_mushroom"), (int)((double)(MainConfig.flyagaricCooldown.Value + MainConfig.flyagaricDuration.Value) - (DateTime.Now - LastShroomTime).TotalSeconds)), 0, (Sprite)null);
							return false;
						}
					}
					if (((Object)item.m_dropPrefab).name == "MagicMushrooms")
					{
						if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BrownieStatusEffect")) || ((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("CocaineStatusEffect")))
						{
							if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BrownieStatusEffect")))
							{
								((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("BrownieStatusEffect"), true);
							}
							if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("CocaineStatusEffect")))
							{
								((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("CocaineStatusEffect"), true);
							}
							((Character)Player.m_localPlayer).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("Puke"), true, 0, 0f);
							return false;
						}
						if ((int)((double)(MainConfig.libertyCooldown.Value + MainConfig.libertyDuration.Value) - (DateTime.Now - LastShroomTime).TotalSeconds) >= 0)
						{
							((Character)Player.m_localPlayer).Message((MessageType)2, string.Format(Localization.instance.Localize("$cooldown_mushroom"), (int)((double)(MainConfig.libertyCooldown.Value + MainConfig.libertyDuration.Value) - (DateTime.Now - LastShroomTime).TotalSeconds)), 0, (Sprite)null);
							return false;
						}
					}
				}
				if (((Object)item.m_dropPrefab).name == "jointbadger" && (int)((double)(MainConfig.jointCooldownBadger.Value + MainConfig.jointDurationBadger.Value) - (DateTime.Now - LastSpliffTime).TotalSeconds) >= 0)
				{
					((Character)Player.m_localPlayer).Message((MessageType)2, string.Format(Localization.instance.Localize("$cooldown_spliff"), (int)((double)(MainConfig.jointCooldownBadger.Value + MainConfig.jointDurationBadger.Value) - (DateTime.Now - LastSpliffTime).TotalSeconds)), 0, (Sprite)null);
					return false;
				}
				if (((Object)item.m_dropPrefab).name == "jointcherry" && (int)((double)(MainConfig.jointCooldownCherry.Value + MainConfig.jointDurationCherry.Value) - (DateTime.Now - LastSpliffTime).TotalSeconds) >= 0)
				{
					((Character)Player.m_localPlayer).Message((MessageType)2, string.Format(Localization.instance.Localize("$cooldown_spliff"), (int)((double)(MainConfig.jointCooldownCherry.Value + MainConfig.jointDurationCherry.Value) - (DateTime.Now - LastSpliffTime).TotalSeconds)), 0, (Sprite)null);
					return false;
				}
				if (((Object)item.m_dropPrefab).name == "jointkush" && (int)((double)(MainConfig.jointCooldownKush.Value + MainConfig.jointDurationKush.Value) - (DateTime.Now - LastSpliffTime).TotalSeconds) >= 0)
				{
					((Character)Player.m_localPlayer).Message((MessageType)2, string.Format(Localization.instance.Localize("$cooldown_spliff"), (int)((double)(MainConfig.jointCooldownKush.Value + MainConfig.jointDurationKush.Value) - (DateTime.Now - LastSpliffTime).TotalSeconds)), 0, (Sprite)null);
					return false;
				}
				if (((Object)item.m_dropPrefab).name == "jointmystic" && (int)((double)(MainConfig.jointCooldownMystic.Value + MainConfig.jointDurationMystic.Value) - (DateTime.Now - LastSpliffTime).TotalSeconds) >= 0)
				{
					((Character)Player.m_localPlayer).Message((MessageType)2, string.Format(Localization.instance.Localize("$cooldown_spliff"), (int)((double)(MainConfig.jointCooldownMystic.Value + MainConfig.jointDurationMystic.Value) - (DateTime.Now - LastSpliffTime).TotalSeconds)), 0, (Sprite)null);
					return false;
				}
				if (((Object)item.m_dropPrefab).name == "jointwidow" && (int)((double)(MainConfig.jointCooldownWidow.Value + MainConfig.jointDurationWidow.Value) - (DateTime.Now - LastSpliffTime).TotalSeconds) >= 0)
				{
					((Character)Player.m_localPlayer).Message((MessageType)2, string.Format(Localization.instance.Localize("$cooldown_spliff"), (int)((double)(MainConfig.jointCooldownWidow.Value + MainConfig.jointDurationWidow.Value) - (DateTime.Now - LastSpliffTime).TotalSeconds)), 0, (Sprite)null);
					return false;
				}
				if (((Object)item.m_dropPrefab).name == "jointdesire" && (int)((double)(MainConfig.jointCooldownDesire.Value + MainConfig.jointDurationDesire.Value) - (DateTime.Now - LastSpliffTime).TotalSeconds) >= 0)
				{
					((Character)Player.m_localPlayer).Message((MessageType)2, string.Format(Localization.instance.Localize("$cooldown_spliff"), (int)((double)(MainConfig.jointCooldownDesire.Value + MainConfig.jointDurationDesire.Value) - (DateTime.Now - LastSpliffTime).TotalSeconds)), 0, (Sprite)null);
					return false;
				}
				if (((Object)item.m_dropPrefab).name == "jointlights" && (int)((double)(MainConfig.jointCooldownLights.Value + MainConfig.jointDurationLights.Value) - (DateTime.Now - LastSpliffTime).TotalSeconds) >= 0)
				{
					((Character)Player.m_localPlayer).Message((MessageType)2, string.Format(Localization.instance.Localize("$cooldown_spliff"), (int)((double)(MainConfig.jointCooldownLights.Value + MainConfig.jointDurationLights.Value) - (DateTime.Now - LastSpliffTime).TotalSeconds)), 0, (Sprite)null);
					return false;
				}
				if (((Object)item.m_dropPrefab).name == "jointpoison" && (int)((double)(MainConfig.jointCooldownPoison.Value + MainConfig.jointDurationPoison.Value) - (DateTime.Now - LastSpliffTime).TotalSeconds) >= 0)
				{
					((Character)Player.m_localPlayer).Message((MessageType)2, string.Format(Localization.instance.Localize("$cooldown_spliff"), (int)((double)(MainConfig.jointCooldownPoison.Value + MainConfig.jointDurationPoison.Value) - (DateTime.Now - LastSpliffTime).TotalSeconds)), 0, (Sprite)null);
					return false;
				}
				if (((Object)item.m_dropPrefab).name == "WeedBrownie")
				{
					if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("FlyagaricStatusEffect")) || ((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("LibertyStatusEffect")))
					{
						if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("FlyagaricStatusEffect")))
						{
							((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("FlyagaricStatusEffect"), true);
						}
						if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("LibertyStatusEffect")))
						{
							((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("LibertyStatusEffect"), true);
						}
						((Character)Player.m_localPlayer).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("Puke"), true, 0, 0f);
						return false;
					}
					if ((int)((double)(MainConfig.brownieCooldown.Value + MainConfig.brownieDuration.Value) - (DateTime.Now - LastBrownieTime).TotalSeconds) >= 0)
					{
						((Character)Player.m_localPlayer).GetSEMan().RemoveAllStatusEffects(false);
						((Character)Player.m_localPlayer).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("Puke"), true, 0, 0f);
						return false;
					}
				}
				if (((Object)item.m_dropPrefab).name == "LoxWeedPie")
				{
					if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("FlyagaricStatusEffect")) || ((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("LibertyStatusEffect")))
					{
						if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("FlyagaricStatusEffect")))
						{
							((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("FlyagaricStatusEffect"), true);
						}
						if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("LibertyStatusEffect")))
						{
							((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("LibertyStatusEffect"), true);
						}
						((Character)Player.m_localPlayer).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("Puke"), true, 0, 0f);
						return false;
					}
					if ((int)((double)(MainConfig.weedPieCooldown.Value + MainConfig.weedPieDuration.Value) - (DateTime.Now - LastPieTime).TotalSeconds) >= 0)
					{
						((Character)Player.m_localPlayer).GetSEMan().RemoveAllStatusEffects(false);
						((Character)Player.m_localPlayer).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("Puke"), true, 0, 0f);
						return false;
					}
				}
				if (((Object)item.m_dropPrefab).name == "WeedSmoothie")
				{
					if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("FlyagaricStatusEffect")) || ((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("LibertyStatusEffect")))
					{
						if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("FlyagaricStatusEffect")))
						{
							((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("FlyagaricStatusEffect"), true);
						}
						if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("LibertyStatusEffect")))
						{
							((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("LibertyStatusEffect"), true);
						}
						((Character)Player.m_localPlayer).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("Puke"), true, 0, 0f);
						return false;
					}
					if ((int)((double)(MainConfig.weedSmoothieCooldown.Value + MainConfig.weedSmoothieDuration.Value) - (DateTime.Now - LastSmoothieTime).TotalSeconds) >= 0)
					{
						((Character)Player.m_localPlayer).GetSEMan().RemoveAllStatusEffects(false);
						((Character)Player.m_localPlayer).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("Puke"), true, 0, 0f);
						return false;
					}
				}
				if (((Object)item.m_dropPrefab).name == "cocaine_wrap")
				{
					if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("FlyagaricStatusEffect")) || ((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("LibertyStatusEffect")))
					{
						if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("FlyagaricStatusEffect")))
						{
							((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("FlyagaricStatusEffect"), true);
						}
						if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("LibertyStatusEffect")))
						{
							((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("LibertyStatusEffect"), true);
						}
						((Character)Player.m_localPlayer).GetSEMan().AddStatusEffect(StringExtensionMethods.GetStableHashCode("Puke"), true, 0, 0f);
						return false;
					}
					if ((int)((double)(MainConfig.cocaineCooldown.Value + MainConfig.cocaineDuration.Value) - (DateTime.Now - LastCocaineTime).TotalSeconds) >= 0)
					{
						((Character)Player.m_localPlayer).Message((MessageType)2, string.Format(Localization.instance.Localize("$cooldown_cocaine"), (int)((double)(MainConfig.cocaineCooldown.Value + MainConfig.cocaineDuration.Value) - (DateTime.Now - LastCocaineTime).TotalSeconds)), 0, (Sprite)null);
						return false;
					}
				}
				if (((Object)item.m_dropPrefab).name == "healing_tincture")
				{
					return FillHealth(MainConfig.healthRestore.Value);
				}
				if (((Object)item.m_dropPrefab).name == "eitr_tincture")
				{
					return FillEitr(MainConfig.eitrRestore.Value);
				}
				if (((Object)item.m_dropPrefab).name == "stamina_tincture")
				{
					return FillStamina(MainConfig.staminaRestore.Value);
				}
				if (((Object)item.m_dropPrefab).name == "CBDPotion")
				{
					if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BadgerStatusEffect")))
					{
						((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("BadgerStatusEffect"), true);
					}
					if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("KushStatusEffect")))
					{
						((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("KushStatusEffect"), true);
					}
					if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("MysticStatusEffect")))
					{
						((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("MysticStatusEffect"), true);
					}
					if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("CherryStatusEffect")))
					{
						((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("CherryStatusEffect"), true);
					}
					if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("WidowStatusEffect")))
					{
						((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("WidowStatusEffect"), true);
					}
					if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BongStatusEffect")))
					{
						((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("BongStatusEffect"), true);
					}
					if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("HookahStatusEffect")))
					{
						((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("HookahStatusEffect"), true);
						if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("WH_Rested")))
						{
							((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("WH_Rested"), true);
						}
					}
					if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BrownieStatusEffect")))
					{
						((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("BrownieStatusEffect"), true);
					}
					if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("WeedPieStatusEffect")))
					{
						((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("WeedPieStatusEffect"), true);
					}
					if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SmoothieStatusEffect")))
					{
						((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("SmoothieStatusEffect"), true);
					}
					if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("PipeStatusEffect")))
					{
						((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("PipeStatusEffect"), true);
					}
					if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("DabStatusEffect")))
					{
						((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("DabStatusEffect"), true);
						if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("WH_Rested_Dab")))
						{
							((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("WH_Rested_Dab"), true);
						}
					}
					if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("MossyStatusEffect")))
					{
						((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("MossyStatusEffect"), true);
					}
					if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("LeechStatusEffect")))
					{
						((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("LeechStatusEffect"), true);
					}
					if (((Character)Player.m_localPlayer).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("TickStatusEffect")))
					{
						((Character)Player.m_localPlayer).GetSEMan().RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("TickStatusEffect"), true);
					}
					((Character)Player.m_localPlayer).Message((MessageType)2, Localization.instance.Localize("$wh_effect_stop"), 0, (Sprite)null);
					LastSpliffTime = DateTime.MinValue;
					LastBrownieTime = DateTime.MinValue;
					LastPipeTime = DateTime.MinValue;
					LastDabTime = DateTime.MinValue;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Player), "UpdateFood")]
		private static class UpdateFood_Patch
		{
			private static void Prefix(Player __instance, float dt, bool forceUpdate, ref float ___m_foodRegenTimer)
			{
				if (MainConfig.modEnabled.Value != MainConfig.Toggle.On || forceUpdate)
				{
					return;
				}
				if (MainConfig.mushroomConsumable.Value == MainConfig.Toggle.On)
				{
					if (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("FlyagaricStatusEffect")))
					{
						___m_foodRegenTimer += dt / MainConfig.flyagaricHealthRegenVal.Value - dt;
					}
					if (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("LibertyStatusEffect")))
					{
						___m_foodRegenTimer += dt / MainConfig.libertyHealthRegenVal.Value - dt;
					}
				}
				if (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BrownieStatusEffect")))
				{
					___m_foodRegenTimer += dt / MainConfig.brownieHealthRegenVal.Value - dt;
				}
				if (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("WeedPieStatusEffect")))
				{
					___m_foodRegenTimer += dt / MainConfig.weedPieHealthRegenVal.Value - dt;
				}
				if (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SmoothieStatusEffect")))
				{
					___m_foodRegenTimer += dt / MainConfig.weedSmoothieHealthRegenVal.Value - dt;
				}
			}
		}

		[HarmonyPatch(typeof(Player), "UpdateStats", new Type[] { typeof(float) })]
		private static class UpdateStats_Patch
		{
			private static void Prefix(Player __instance, ref float __state, float ___m_stamina, ref float ___m_staminaRegenTimer, ref float ___m_eiterRegen)
			{
				if (MainConfig.modEnabled.Value != MainConfig.Toggle.On)
				{
					return;
				}
				if (MainConfig.mushroomConsumable.Value == MainConfig.Toggle.On)
				{
					if (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("FlyagaricStatusEffect")))
					{
						___m_eiterRegen = MainConfig.flyagaricEitrRegenVal.Value;
						__state = ___m_stamina;
					}
					if (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("LibertyStatusEffect")))
					{
						___m_eiterRegen = MainConfig.libertyEitrRegenVal.Value;
						__state = ___m_stamina;
					}
				}
				if (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BrownieStatusEffect")))
				{
					__state = ___m_stamina;
				}
				if (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("WeedPieStatusEffect")))
				{
					__state = ___m_stamina;
				}
				if (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SmoothieStatusEffect")))
				{
					__state = ___m_stamina;
				}
			}

			private static void Postfix(Player __instance, float __state, ref float ___m_stamina)
			{
				if (MainConfig.modEnabled.Value != MainConfig.Toggle.On || !(__state > 0f) || !(___m_stamina > __state))
				{
					return;
				}
				if (MainConfig.mushroomConsumable.Value == MainConfig.Toggle.On)
				{
					if (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("FlyagaricStatusEffect")))
					{
						___m_stamina = Mathf.Max(0f, __state + (___m_stamina - __state) * MainConfig.flyagaricStamRegenVal.Value);
					}
					if (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("LibertyStatusEffect")))
					{
						___m_stamina = Mathf.Max(0f, __state + (___m_stamina - __state) * MainConfig.libertyStamRegenVal.Value);
					}
				}
				if (((Character)__instance).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BrownieStatusEffect")))
				{
					___m_stamina = Mathf.Max(0f, __state + (___m_stamina - __state) * MainConfig.brownieStamRegenVal.Value);
				}
			}
		}

		[HarmonyPatch(typeof(Character), "Heal")]
		private static class Heal_Patch
		{
			private static void Prefix(Character __instance, ref float hp)
			{
				if (MainConfig.modEnabled.Value != MainConfig.Toggle.On || !__instance.IsPlayer())
				{
					return;
				}
				if (MainConfig.mushroomConsumable.Value == MainConfig.Toggle.On)
				{
					if (__instance.GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("FlyagaricStatusEffect")))
					{
						hp *= MainConfig.flyagaricHealthRegenVal.Value;
					}
					if (__instance.GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("LibertyStatusEffect")))
					{
						hp *= MainConfig.libertyHealthRegenVal.Value;
					}
				}
				if (__instance.GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("BrownieStatusEffect")))
				{
					hp *= MainConfig.brownieHealthRegenVal.Value;
				}
				if (__instance.GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("WeedPieStatusEffect")))
				{
					hp *= MainConfig.weedPieHealthRegenVal.Value;
				}
				if (__instance.GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode("SmoothieStatusEffect")))
				{
					hp *= MainConfig.weedSmoothieHealthRegenVal.Value;
				}
			}
		}

		private static bool defaultPostProcessingSet = false;

		private static bool defaultVignetteEnabled;

		private static Settings defaultVignetteSettings;

		private static Settings defaultCASettings;

		private static Settings defaultColorGradingSettings;

		private static Color[] rainbowcolors = (Color[])(object)new Color[8]
		{
			new Color(5f, 0f, 0f, 1f),
			new Color(5f, 2f, 0f, 1f),
			new Color(5f, 5f, 0f, 1f),
			new Color(0f, 5f, 0f, 1f),
			new Color(0f, 3f, 2f, 1f),
			new Color(0f, 0f, 5f, 1f),
			new Color(3f, 0f, 5f, 1f),
			new Color(4f, 0f, 2f, 1f)
		};

		private static int rainbowcurrent = 0;

		private static int rainbownext = 1;

		private static float rainbowtimer = 0f;

		private static float rainbowchangeevery = 0.5f;

		private static readonly HashSet<string> consumableNames = new HashSet<string>
		{
			"jointbadger", "jointcherry", "jointkush", "jointmystic", "jointwidow", "jointdesire", "jointlights", "jointpoison", "WeedBrownie", "LoxWeedPie",
			"WeedSmoothie", "cocaine_wrap", "mushroom_brew", "flyagaric_wine", "MagicMushrooms", "FlyagaricMushroom", "eitr_tincture", "healing_tincture", "stamina_tincture", "LoxWeedPie",
			"WeedSmoothie", "CBDPotion", "LokisSpecialBlend", "PotentDab"
		};

		internal static DateTime LastSpliffTime = DateTime.MinValue;

		internal static DateTime LastPipeTime = DateTime.MinValue;

		internal static DateTime LastDabTime = DateTime.MinValue;

		internal static DateTime LastShroomTime = DateTime.MinValue;

		internal static DateTime LastBrownieTime = DateTime.MinValue;

		internal static DateTime LastPieTime = DateTime.MinValue;

		internal static DateTime LastSmoothieTime = DateTime.MinValue;

		internal static DateTime LastCocaineTime = DateTime.MinValue;

		internal static DateTime lastEitrTime = DateTime.MinValue;

		internal static DateTime lastHealthTime = DateTime.MinValue;

		internal static DateTime lastStaminaTime = DateTime.MinValue;

		private static bool IsConsumable(string name)
		{
			return consumableNames.Contains(name);
		}

		public static bool FillHealth(float amount)
		{
			if ((Object)(object)Player.m_localPlayer == (Object)null)
			{
				return false;
			}
			if ((DateTime.Now - lastHealthTime).TotalSeconds <= (double)MainConfig.healthTimeout.Value)
			{
				((Character)Player.m_localPlayer).Message((MessageType)2, string.Format(Localization.instance.Localize("$cooldown_health"), (int)((double)MainConfig.healthTimeout.Value - (DateTime.Now - lastHealthTime).TotalSeconds)), 0, (Sprite)null);
				return false;
			}
			float maxHealth = ((Character)Player.m_localPlayer).GetMaxHealth();
			float num = maxHealth / 100f * amount;
			float num2 = ((Character)Player.m_localPlayer).GetHealth() + num;
			if (num2 < 0f)
			{
				num2 = 20f;
			}
			else if (num2 > maxHealth)
			{
				num2 = maxHealth;
			}
			((Character)Player.m_localPlayer).SetHealth(num2);
			((Character)Player.m_localPlayer).Message((MessageType)2, string.Format(Localization.instance.Localize("$message_health"), MainConfig.healthRestore.Value), 0, (Sprite)null);
			lastHealthTime = DateTime.Now;
			return true;
		}

		public static bool FillEitr(float amount)
		{
			if ((Object)(object)Player.m_localPlayer == (Object)null)
			{
				return false;
			}
			if ((DateTime.Now - lastEitrTime).TotalSeconds <= (double)MainConfig.eitrTimeout.Value)
			{
				((Character)Player.m_localPlayer).Message((MessageType)2, string.Format(Localization.instance.Localize("$cooldown_eitr"), (int)((double)MainConfig.eitrTimeout.Value - (DateTime.Now - lastEitrTime).TotalSeconds)), 0, (Sprite)null);
				return false;
			}
			float num = ((Character)Player.m_localPlayer).GetMaxEitr();
			if (num == 0f)
			{
				num = 1f;
			}
			float num2 = num / 100f * amount;
			if (num2 > num)
			{
				num2 = num - num2;
			}
			((Character)Player.m_localPlayer).AddEitr(num2);
			((Character)Player.m_localPlayer).Message((MessageType)2, string.Format(Localization.instance.Localize("$message_eitr"), MainConfig.eitrRestore.Value), 0, (Sprite)null);
			lastEitrTime = DateTime.Now;
			return true;
		}

		public static bool FillStamina(float amount)
		{
			if ((Object)(object)Player.m_localPlayer == (Object)null)
			{
				return false;
			}
			if ((DateTime.Now - lastStaminaTime).TotalSeconds <= (double)MainConfig.staminaTimeout.Value)
			{
				((Character)Player.m_localPlayer).Message((MessageType)2, string.Format(Localization.instance.Localize("$cooldown_stamina"), (int)((double)MainConfig.staminaTimeout.Value - (DateTime.Now - lastStaminaTime).TotalSeconds)), 0, (Sprite)null);
				return false;
			}
			float num = ((Character)Player.m_localPlayer).GetMaxStamina() / 100f * amount;
			((Character)Player.m_localPlayer).AddStamina(num);
			((Character)Player.m_localPlayer).Message((MessageType)2, string.Format(Localization.instance.Localize("$message_stamina"), MainConfig.staminaRestore.Value), 0, (Sprite)null);
			lastStaminaTime = DateTime.Now;
			return true;
		}
	}
	internal class CrystalWardPatches
	{
		[HarmonyPatch(typeof(Door), "Interact")]
		public static class Door_SetState_AutoClose
		{
			public static void Postfix(Door __instance, ZNetView ___m_nview, bool __result)
			{
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				if (!MainConfig.enableCrystalWard.Value || MainConfig.autoCloseDoorsTime.Value == 0 || !___m_nview.IsValid() || !__result || !InsideEnabledPlayersArea(((Component)__instance).transform.position, out var area))
				{
					return;
				}
				if (!doorsToClose.TryGetValue(area, out var value))
				{
					value = new List<Door>();
				}
				int @int = ___m_nview.GetZDO().GetInt(ZDOVars.s_state, 0);
				if (@int == 0)
				{
					value.Remove(__instance);
				}
				else if (!value.Contains(__instance))
				{
					value.Add(__instance);
				}
				if (value.Count == 0)
				{
					wardIsClosing.Remove(area);
					doorsToClose.Remove(area);
				}
				else if (@int != 0)
				{
					doorsToClose[area] = value;
					Logger.LogInfo((object)value.Count);
					if (wardIsClosing.ContainsKey(area))
					{
						wardIsClosing[area] = Math.Max(MainConfig.autoCloseDoorsTime.Value, 2);
						Logger.LogInfo((object)$"Doors closing reset to {wardIsClosing[area]} seconds");
					}
					else
					{
						wardIsClosing[area] = Math.Max(MainConfig.autoCloseDoorsTime.Value, 2);
						((MonoBehaviour)area).StartCoroutine(AutoClosingDoors(area));
						Logger.LogInfo((object)"Doors closing started");
					}
				}
			}
		}

		[HarmonyPatch(typeof(PrivateArea), "Awake")]
		public static class PrivateArea_Awake_SetWardRange
		{
			private static void Prefix(ref PrivateArea __instance)
			{
				if (MainConfig.enableCrystalWard.Value)
				{
					SetWardRange(ref __instance);
					SetWardPlayerBase(ref __instance);
				}
			}

			private static void Postfix(ref PrivateArea __instance)
			{
				if (MainConfig.enableCrystalWard.Value)
				{
					SetWardRange(ref __instance);
					SetWardPlayerBase(ref __instance);
					if (MainConfig.showAreaMarker.Value)
					{
						((Component)__instance.m_areaMarker).gameObject.SetActive(true);
					}
				}
			}
		}

		[HarmonyPatch(typeof(PrivateArea), "OnDestroy")]
		public static class PrivateArea_OnDestroy_ClearStatus
		{
			public static void Prefix(PrivateArea __instance)
			{
				if (MainConfig.enableCrystalWard.Value)
				{
					areaCache.Clear();
					wardIsHealing.Remove(__instance);
					wardIsRepairing.Remove(__instance);
					wardIsClosing.Remove(__instance);
				}
			}
		}

		[HarmonyPatch(typeof(PrivateArea), "IsPermitted")]
		public static class PrivateArea_AddUserList_PermittanceToEveryone
		{
			public static bool Prefix(PrivateArea __instance, ref bool __result)
			{
				if (!MainConfig.enableCrystalWard.Value)
				{
					return true;
				}
				if (!MainConfig.permitEveryone.Value)
				{
					return true;
				}
				__result = true;
				return false;
			}
		}

		[HarmonyPatch(typeof(Player), "UpdateBaseValue")]
		public static class Player_UpdateBaseValue_SittingRaidProtection
		{
			public static void Postfix(Player __instance, float ___m_baseValueUpdateTimer, ref int ___m_baseValue, ZNetView ___m_nview)
			{
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				if (MainConfig.enableCrystalWard.Value && MainConfig.sittingRaidProtection.Value && ___m_baseValueUpdateTimer == 0f && ___m_baseValue >= 3 && ((Character)__instance).IsSitting() && __instance.m_attached && ((Character)__instance).GetSEMan().HaveStatusEffect(SEMan.s_statusEffectCampFire) && InsideEnabledPlayersArea(((Component)__instance).transform.position))
				{
					___m_baseValue = baseValueProtected;
					ZNet.instance.m_serverSyncedPlayerData["baseValue"] = ___m_baseValue.ToString();
					___m_nview.GetZDO().Set(ZDOVars.s_baseValue, ___m_baseValue, false);
				}
			}
		}

		[HarmonyPatch(typeof(RandEventSystem), "CheckBase")]
		public static class RandEventSystem_CheckBase_SittingRaidProtection
		{
			public static void Postfix(PlayerEventData player, ref bool __result)
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: Unknown result type (might be due to invalid IL or missing references)
				if (MainConfig.enableCrystalWard.Value && MainConfig.sittingRaidProtection.Value && __result && player.baseValue == baseValueProtected)
				{
					Logger.LogInfo((object)$"Player at {player.position.x} {player.position.z} is in raid protected state.");
					__result = false;
				}
			}
		}

		[HarmonyPatch(typeof(Character), "Damage")]
		public static class Character_Damage_DamageMultipliers
		{
			private static void Prefix(Character __instance, ref HitData hit, ZNetView ___m_nview)
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				if (!MainConfig.enableCrystalWard.Value || (Object)(object)___m_nview == (Object)null || !InsideEnabledPlayersArea(((Component)__instance).transform.position, out var area) || (hit.HaveAttacker() && hit.GetAttacker().IsBoss()))
				{
					return;
				}
				if (__instance.IsPlayer())
				{
					ModifyHitDamage(ref hit, 0f);
				}
				else if (__instance.IsTamed())
				{
					ModifyHitDamage(ref hit, 0f);
					if (MainConfig.tamedProtection.Value && (__instance.m_group == "boar" || __instance.m_group == "chicken" || __instance.m_group == "stonedcreatures") && (!hit.HaveAttacker() || !hit.GetAttacker().IsPlayer()))
					{
						if (hit.GetTotalDamage() != hit.m_damage.m_fire)
						{
							area.FlashShield(false);
						}
						ModifyHitDamage(ref hit, 0f);
					}
				}
				else
				{
					ModifyHitDamage(ref hit, 1f);
				}
			}
		}

		[HarmonyPatch(typeof(Character), "AddFireDamage")]
		public static class Character_AddFireDamage_IndirectFireDamageProtection
		{
			private static void Prefix(Character __instance, ref float damage)
			{
				//IL_005d: Unknown result type (might be due to invalid IL or missing references)
				if (MainConfig.enableCrystalWard.Value && MainConfig.tamedProtection.Value && __instance.IsTamed() && (__instance.m_group == "boar" || __instance.m_group == "chicken" || __instance.m_group == "stonedcreatures") && InsideEnabledPlayersArea(((Component)__instance).transform.position))
				{
					damage = 0f;
				}
			}
		}

		[HarmonyPatch(typeof(Character), "UpdateSmoke")]
		public static class Character_UpdateSmoke_IndirectSmokeDamageProtection
		{
			private static void Prefix(Character __instance, ref float dt)
			{
				//IL_005d: Unknown result type (might be due to invalid IL or missing references)
				if (MainConfig.enableCrystalWard.Value && MainConfig.tamedProtection.Value && __instance.IsTamed() && (__instance.m_group == "boar" || __instance.m_group == "chicken" || __instance.m_group == "stonedcreatures") && InsideEnabledPlayersArea(((Component)__instance).transform.position))
				{
					dt = 0f;
				}
			}
		}

		[HarmonyPatch(typeof(WearNTear), "Damage")]
		public static class WearNTear_Damage_DamageTakenMultiplier
		{
			private static void Prefix(WearNTear __instance, ref HitData hit, ZNetView ___m_nview)
			{
				//IL_001c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_003e: Invalid comparison between Unknown and I4
				if (MainConfig.enableCrystalWard.Value && !((Object)(object)___m_nview == (Object)null) && InsideEnabledPlayersArea(((Component)__instance).transform.position))
				{
					if (MainConfig.wardShipProtection.Value == MainConfig.ShipDamageType.AnyButPlayerDamage && (int)hit.m_hitType != 2 && (Object)(object)((Component)__instance).GetComponent<Ship>() != (Object)null)
					{
						ModifyHitDamage(ref hit, 0f);
					}
					else if (MainConfig.wardShipProtection.Value == MainConfig.ShipDamageType.AnyDamage && (Object)(object)((Component)__instance).GetComponent<Ship>() != (Object)null)
					{
						ModifyHitDamage(ref hit, 0f);
					}
					else if ((Object)(object)((Component)__instance).GetComponent<Piece>() != (Object)null && (!hit.HaveAttacker() || !hit.GetAttacker().IsBoss()))
					{
						ModifyHitDamage(ref hit, 0f);
					}
				}
			}
		}

		[HarmonyPatch(typeof(Destructible), "Damage")]
		public static class Destructible_RPC_Damage_PlantProtection
		{
			private static void Prefix(Destructible __instance, ZNetView ___m_nview, bool ___m_destroyed, ref HitData hit)
			{
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: Invalid comparison between Unknown and I4
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				if (!MainConfig.enableCrystalWard.Value || !MainConfig.wardPlantProtection.Value || !___m_nview.IsValid() || !___m_nview.IsOwner() || ___m_destroyed || (int)__instance.GetDestructibleType() != 1 || __instance.m_health != 1f || !hit.HaveAttacker() || !InsideEnabledPlayersArea(((Component)__instance).transform.position, out var area))
				{
					return;
				}
				Pickable val = default(Pickable);
				if ((Object)(object)((Component)__instance).GetComponent<Plant>() != (Object)null)
				{
					ModifyHitDamage(ref hit, 0f);
					area.FlashShield(false);
				}
				else if (((Component)__instance).TryGetComponent<Pickable>(ref val))
				{
					SharedData shared = val.m_itemPrefab.GetComponent<ItemDrop>().m_itemData.m_shared;
					if (shared.m_name == "$item_carrot" || shared.m_name == "$item_turnip" || shared.m_name == "$item_onion" || shared.m_name == "$item_carrotseeds" || shared.m_name == "$item_turnipseeds" || shared.m_name == "$item_onionseeds" || shared.m_name == "$item_jotunpuffs" || shared.m_name == "$item_magecap")
					{
						ModifyHitDamage(ref hit, 0f);
						area.FlashShield(false);
					}
				}
			}
		}

		[HarmonyPatch(typeof(WearNTear), "UpdateWear")]
		public static class WearNTear_UpdateWear_RainProtection
		{
			private static void Prefix(WearNTear __instance, ZNetView ___m_nview, ref bool ___m_noRoofWear, ref bool __state)
			{
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				if (MainConfig.enableCrystalWard.Value && MainConfig.wardRainProtection.Value && !((Object)(object)___m_nview == (Object)null) && ___m_nview.IsValid() && InsideEnabledPlayersArea(((Component)__instance).transform.position))
				{
					__state = ___m_noRoofWear;
					___m_noRoofWear = false;
				}
			}

			private static void Postfix(ref bool ___m_noRoofWear, bool __state)
			{
				if (MainConfig.enableCrystalWard.Value && MainConfig.wardRainProtection.Value && __state)
				{
					___m_noRoofWear = __state;
				}
			}
		}

		[HarmonyPatch(typeof(Ship), "UpdateUpsideDmg")]
		public static class Ship_UpdateUpsideDmg_PreventShipDamage
		{
			private static bool Prefix(Ship __instance)
			{
				//IL_0022: Unknown result type (might be due to invalid IL or missing references)
				if (!MainConfig.enableCrystalWard.Value)
				{
					return true;
				}
				if (MainConfig.wardShipProtection.Value == MainConfig.ShipDamageType.Off)
				{
					return true;
				}
				return !InsideEnabledPlayersArea(((Component)__instance).transform.position);
			}
		}

		[HarmonyPatch(typeof(Ship), "UpdateWaterForce")]
		public static class Ship_UpdateWaterForce_PreventShipDamage
		{
			private static void Prefix(Ship __instance, ref float ___m_waterImpactDamage, ref float __state)
			{
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				if (MainConfig.enableCrystalWard.Value && MainConfig.wardShipProtection.Value != 0 && InsideEnabledPlayersArea(((Component)__instance).transform.position))
				{
					__state = ___m_waterImpactDamage;
					___m_waterImpactDamage = 0f;
				}
			}

			private static void Postfix(Ship __instance, ref float ___m_waterImpactDamage, float __state)
			{
				//IL_0020: Unknown result type (might be due to invalid IL or missing references)
				if (MainConfig.enableCrystalWard.Value && MainConfig.wardShipProtection.Value != 0 && InsideEnabledPlayersArea(((Component)__instance).transform.position))
				{
					___m_waterImpactDamage = __state;
				}
			}
		}

		[HarmonyPatch(typeof(Trap), "OnTriggerEnter")]
		private static class Trap_OnTriggerEnter_TrapProtection
		{
			private static bool Prefix(Collider collider)
			{
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				if (!MainConfig.enableCrystalWard.Value)
				{
					return true;
				}
				if (!MainConfig.wardTrapProtection.Value)
				{
					return true;
				}
				Player componentInParent = ((Component)collider).GetComponentInParent<Player>();
				if ((Object)(object)componentInParent == (Object)null)
				{
					return true;
				}
				if (!InsideEnabledPlayersArea(((Component)componentInParent).transform.position))
				{
					return true;
				}
				return false;
			}
		}

		[HarmonyPatch(typeof(PrivateArea), "HideMarker")]
		public static class PrivateArea_HideMarker_showAreaMarker
		{
			public static bool Prefix()
			{
				if (!MainConfig.enableCrystalWard.Value)
				{
					return true;
				}
				return !MainConfig.showAreaMarker.Value;
			}
		}

		[HarmonyPatch(typeof(PrivateArea), "Interact")]
		public static class PrivateArea_Interact_PassiveEffectWardRange
		{
			private static bool Prefix(PrivateArea __instance, Humanoid human, bool hold, bool alt, Faction ___m_ownerFaction)
			{
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				WeedheimMod.ConfigUpdate();
				if (!MainConfig.enableCrystalWard.Value)
				{
					return true;
				}
				if (!alt)
				{
					areaCache.Clear();
				}
				if (!MainConfig.wardPassiveRepair.Value)
				{
					return true;
				}
				if (!alt)
				{
					return true;
				}
				if (hold)
				{
					return true;
				}
				if ((int)___m_ownerFaction != 0)
				{
					return true;
				}
				if (!__instance.IsEnabled())
				{
					return true;
				}
				if (wardIsRepairing.ContainsKey(__instance))
				{
					return true;
				}
				Logger.LogInfo((object)"Passive repairing begins");
				((MonoBehaviour)WeedheimMod.plugininstance).StartCoroutine(PassiveRepairEffect(__instance, (Player)(object)((human is Player) ? human : null)));
				return false;
			}

			private static void Postfix(ref PrivateArea __instance)
			{
				if (MainConfig.enableCrystalWard.Value)
				{
					if (__instance.m_radius != MainConfig.wardRange.Value)
					{
						SetWardRange(ref __instance);
					}
					SetWardPlayerBase(ref __instance);
				}
			}
		}

		[HarmonyPatch(typeof(PrivateArea), "RPC_FlashShield")]
		public static class PrivateArea_RPC_FlashShield_StopFlashShield
		{
			private static bool Prefix(PrivateArea __instance)
			{
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				if (!MainConfig.enableCrystalWard.Value)
				{
					return true;
				}
				if ((int)__instance.m_ownerFaction == 0)
				{
					return !MainConfig.disableFlash.Value;
				}
				return true;
			}
		}

		internal static long startTimeCached;

		internal static Dictionary<Vector3, PrivateArea> areaCache = new Dictionary<Vector3, PrivateArea>();

		internal static Dictionary<PrivateArea, int> wardIsRepairing = new Dictionary<PrivateArea, int>();

		internal static Dictionary<PrivateArea, int> wardIsHealing = new Dictionary<PrivateArea, int>();

		internal static Dictionary<PrivateArea, int> wardIsClosing = new Dictionary<PrivateArea, int>();

		internal static Dictionary<PrivateArea, List<Door>> doorsToClose = new Dictionary<PrivateArea, List<Door>>();

		internal static int baseValueProtected = 999;

		internal static void ApplyRangeEffect(Component parent, Type includedTypes, float newRadius)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)parent == (Object)null)
			{
				return;
			}
			EffectArea componentInChildren = parent.GetComponentInChildren<EffectArea>();
			if (!((Object)(object)componentInChildren == (Object)null) && componentInChildren.m_type == includedTypes)
			{
				SphereCollider component = ((Component)componentInChildren).GetComponent<SphereCollider>();
				if (!((Object)(object)component == (Object)null))
				{
					component.radius = newRadius;
				}
			}
		}

		internal static void SetWardRange(ref PrivateArea __instance)
		{
			float num = Math.Max(MainConfig.wardRange.Value, 0f);
			__instance.m_radius = num;
			__instance.m_areaMarker.m_radius = num;
			ApplyRangeEffect((Component)(object)__instance, (Type)4, num);
		}

		internal static void SetWardPlayerBase(ref PrivateArea __instance)
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			Transform val = ((Component)__instance).transform.Find("PlayerBase");
			if ((Object)(object)val != (Object)null)
			{
				float num = Math.Min(1f, 10f / Math.Max(MainConfig.wardRange.Value, 1f));
				if (MainConfig.supressSpawnInRange.Value)
				{
					num = 1f;
				}
				val.localScale = new Vector3(num, num, num);
			}
		}

		public static bool InsideEnabledPlayersArea(Vector3 point)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			PrivateArea area;
			return InsideEnabledPlayersArea(point, out area);
		}

		internal static void UpdateCache()
		{
			DateTime time = ZNet.instance.GetTime();
			if (startTimeCached == 0L)
			{
				startTimeCached = time.Ticks;
			}
			if ((time - new DateTime(startTimeCached)).TotalSeconds > (double)MainConfig.refreshingTime.Value)
			{
				areaCache.Clear();
				startTimeCached = time.Ticks;
			}
		}

		public static bool InsideEnabledPlayersArea(Vector3 point, out PrivateArea area)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			UpdateCache();
			if (areaCache.TryGetValue(point, out area))
			{
				return (Object)(object)area != (Object)null;
			}
			foreach (PrivateArea allArea in PrivateArea.m_allAreas)
			{
				if (allArea.IsEnabled() && (int)allArea.m_ownerFaction == 0 && allArea.IsInside(point, 0f))
				{
					area = allArea;
					areaCache.Add(point, area);
					return true;
				}
			}
			areaCache.Add(point, area);
			return false;
		}

		private static void ModifyHitDamage(ref HitData hit, float value)
		{
			((DamageTypes)(ref hit.m_damage)).Modify(Math.Max(value, 0f));
		}

		private static List<PrivateArea> ConnectedAreas(PrivateArea ward)
		{
			List<PrivateArea> connectedAreas = ward.GetConnectedAreas(false);
			connectedAreas.Add(ward);
			return connectedAreas.Where((PrivateArea area) => area.IsEnabled()).Distinct().ToList();
		}

		public static IEnumerator PassiveRepairEffect(PrivateArea ward, Player initiator)
		{
			WearNTear val2 = default(WearNTear);
			WearNTear val = default(WearNTear);
			while (true)
			{
				if ((Object)(object)ward == (Object)null || !Object.op_Implicit((Object)(object)ZNetScene.instance))
				{
					yield break;
				}
				if (Game.IsPaused())
				{
					yield return (object)new WaitForSeconds(2f);
				}
				List<Piece> pieces = new List<Piece>();
				ConnectedAreas(ward).ForEach(delegate(PrivateArea area)
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					Piece.GetAllPiecesInRadius(((Component)area).transform.position, area.m_radius, pieces);
				});
				List<Piece> list = (from piece in pieces.Distinct().ToList()
					where piece.IsPlacedByPlayer() && ((Component)piece).TryGetComponent<WearNTear>(ref val2) && val2.GetHealthPercentage() < 1f
					select piece).ToList();
				if (list.Count == 0)
				{
					break;
				}
				wardIsRepairing[ward] = list.Count;
				foreach (Piece item in list)
				{
					if (((Component)item).TryGetComponent<WearNTear>(ref val) && val.Repair())
					{
						item.m_placeEffect.Create(((Component)item).transform.position, ((Component)item).transform.rotation, (Transform)null, 1f, -1);
						wardIsRepairing.TryGetValue(ward, out var value);
						wardIsRepairing[ward] = Math.Max(value - 1, 0);
						if ((Object)(object)initiator != (Object)null)
						{
							((Character)initiator).Message((MessageType)1, Localization.instance.Localize("$piece_repair"), 0, (Sprite)null);
						}
						break;
					}
				}
				yield return (object)new WaitForSecondsRealtime(10f);
			}
			Logger.LogInfo((object)"Passive repairing stopped");
			wardIsRepairing.Remove(ward);
			if ((Object)(object)initiator != (Object)null)
			{
				string text = Localization.instance.Localize("$msg_doesnotneedrepair");
				((Character)initiator).Message((MessageType)1, char.ToUpper(text[0]) + text.Substring(1), 0, (Sprite)null);
			}
		}

		public static IEnumerator PassiveHealingEffect(PrivateArea ward, float amount, int seconds)
		{
			while (true)
			{
				if ((Object)(object)ward == (Object)null)
				{
					yield break;
				}
				if (Game.IsPaused())
				{
					yield return (object)new WaitForSeconds(2f);
				}
				if (!wardIsHealing.TryGetValue(ward, out var value))
				{
					yield break;
				}
				if (value <= 0)
				{
					break;
				}
				wardIsHealing[ward] -= seconds;
				List<Player> players = new List<Player>();
				List<Character> characters = new List<Character>();
				ConnectedAreas(ward).ForEach(delegate(PrivateArea area)
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					//IL_0022: Unknown result type (might be due to invalid IL or missing references)
					Player.GetPlayersInRange(((Component)area).transform.position, area.m_radius, players);
					Character.GetCharactersInRange(((Component)area).transform.position, area.m_radius, characters);
				});
				foreach (Player item in players.Distinct().ToList())
				{
					((Character)item).Heal(amount * (float)seconds, true);
				}
				foreach (Character item2 in characters.Distinct().ToList())
				{
					if (item2.IsTamed())
					{
						item2.Heal(amount * (float)seconds, true);
					}
				}
				yield return (object)new WaitForSecondsRealtime((float)seconds);
			}
			wardIsHealing.Remove(ward);
			Logger.LogInfo((object)"Passive healing stopped");
		}

		public static IEnumerator AutoClosingDoors(PrivateArea ward)
		{
			List<Door> value2;
			while (true)
			{
				if ((Object)(object)ward == (Object)null)
				{
					yield break;
				}
				if (Game.IsPaused())
				{
					yield return (object)new WaitForSeconds(2f);
				}
				if (!wardIsClosing.TryGetValue(ward, out var value) || !doorsToClose.TryGetValue(ward, out value2))
				{
					yield break;
				}
				if (value <= 0)
				{
					break;
				}
				wardIsClosing[ward]--;
				yield return (object)new WaitForSeconds(1f);
			}
			if (value2.Count > 0)
			{
				Logger.LogInfo((object)$"Closed {value2.Count} doors");
				value2.ForEach(delegate(Door door)
				{
					if (door.m_nview.IsValid())
					{
						door.m_nview.GetZDO().Set(ZDOVars.s_state, 0, false);
						door.UpdateState();
					}
				});
			}
			wardIsClosing.Remove(ward);
			doorsToClose.Remove(ward);
			Logger.LogInfo((object)"Doors closing stopped");
		}
	}
	internal class StonerPortalPatches
	{
		[HarmonyPatch(typeof(Game), "Awake")]
		private static class GameAwakePatch
		{
			private static void Prefix(Game __instance)
			{
				if (MainConfig.enableStonerPortal.Value)
				{
					GameObject prefab = Cache.GetPrefab<GameObject>("Stoner_Portal");
					__instance.m_portalPrefabs.Add(prefab);
					GameObject prefab2 = Cache.GetPrefab<GameObject>("Portal_Doorway");
					__instance.m_portalPrefabs.Add(prefab2);
				}
			}
		}

		[HarmonyPatch(typeof(TeleportWorld), "Interact")]
		private class InteractPatch
		{
			private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				List<CodeInstruction> source = new List<CodeInstruction>(instructions);
				if (!MainConfig.enableStonerPortal.Value)
				{
					return source.AsEnumerable();
				}
				foreach (CodeInstruction item in source.Where((CodeInstruction t) => t.opcode == OpCodes.Ldc_I4_S))
				{
					item.operand = 127;
				}
				return source.AsEnumerable();
			}
		}

		[HarmonyPatch(typeof(Hud))]
		private static class Hud_Patches
		{
			[HarmonyPatch("GetFadeDuration")]
			[HarmonyPrefix]
			private static bool GetFadeDuration_Prefix(Hud __instance, ref float __result, Player player)
			{
				if (!MainConfig.enableStonerPortal.Value)
				{
					return true;
				}
				if (player != null && ((Character)player).IsTeleporting())
				{
					__result = MainConfig.portalFadeTime.Value;
					return false;
				}
				return true;
			}
		}

		[HarmonyPatch(typeof(Player))]
		private static class Player_Patches
		{
			[HarmonyPatch("UpdateTeleport")]
			[HarmonyTranspiler]
			private static IEnumerable<CodeInstruction> UpdateTeleport_Transpiler(IEnumerable<CodeInstruction> instructions)
			{
				foreach (CodeInstruction instruction in instructions)
				{
					if (instruction.opcode == OpCodes.Ldc_R4 && MainConfig.enableStonerPortal.Value)
					{
						float num = (float)instruction.operand;
						if (num == 2f)
						{
							instruction.operand = MainConfig.portalFadeTime.Value;
						}
						else if (num == 8f)
						{
							instruction.operand = MainConfig.portalFadeTime.Value + MainConfig.minPortalTime.Value;
						}
						else if (num == 15f)
						{
							instruction.operand = MainConfig.portalFadeTime.Value + MainConfig.minPortalTime.Value + 0.5f;
						}
					}
					yield return instruction;
				}
			}
		}

		[HarmonyPatch(typeof(EffectFade), "Update")]
		public static class EffectFade_Update_Patch
		{
			private static void Prefix(EffectFade __instance, ref float ___m_baseVolume)
			{
				if (MainConfig.enableStonerPortal.Value && ((Object)__instance).name == "_target_found_red")
				{
					___m_baseVolume = (float)MainConfig.stonerPortalVolume.Value / 100f;
				}
			}
		}
	}
	internal class PlantingPatches
	{
		[HarmonyPatch(typeof(Pickable), "Awake")]
		public class DropYields
		{
			private static void Postfix(Pickable __instance)
			{
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
				//IL_0121: Unknown result type (might be due to invalid IL or missing references)
				//IL_0165: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_0226: Unknown result type (might be due to invalid IL or missing references)
				//IL_02a3: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_0364: Unknown result type (might be due to invalid IL or missing references)
				//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_0425: Unknown result type (might be due to invalid IL or missing references)
				//IL_0469: Unknown result type (might be due to invalid IL or missing references)
				//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
				//IL_052a: Unknown result type (might be due to invalid IL or missing references)
				//IL_05a7: Unknown result type (might be due to invalid IL or missing references)
				//IL_05eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_0673: Unknown result type (might be due to invalid IL or missing references)
				//IL_06b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_073f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0783: Unknown result type (might be due to invalid IL or missing references)
				ZNetView nview = __instance.m_nview;
				if (((nview != null) ? nview.GetZDO() : null) != null)
				{
					GameObject prefab = Cache.GetPrefab<GameObject>("HempLeaf");
					if (((Object)((Component)__instance).gameObject).name.Contains("Pickable_Honey_Badger"))
					{
						__instance.m_amount = MainConfig.budYieldDropBadger.Value;
						__instance.m_dontScale = true;
						__instance.m_extraDrops.m_drops.Add(new DropData
						{
							m_item = prefab,
							m_stackMin = MainConfig.leafYieldDropBadger.Value,
							m_stackMax = MainConfig.leafYieldDropBadger.Value,
							m_weight = 0.01f,
							m_dontScale = true
						});
						__instance.m_extraDrops.m_dropMin = 1;
						__instance.m_extraDrops.m_dropMax = 1;
						__instance.m_extraDrops.m_dropChance = 1f;
						__instance.m_respawnTimeMinutes = MainConfig.respawnTimeBadger.Value;
					}
					if (((Object)((Component)__instance).gameObject).name.Contains("Pickable_Blue_Mystic"))
					{
						__instance.m_amount = MainConfig.budYieldDropMystic.Value;
						__instance.m_dontScale = true;
						__instance.m_extraDrops.m_drops.Add(new DropData
						{
							m_item = prefab,
							m_stackMin = MainConfig.leafYieldDropMystic.Value,
							m_stackMax = MainConfig.leafYieldDropMystic.Value,
							m_weight = 0.01f,
							m_dontScale = true
						});
						__instance.m_extraDrops.m_dropMin = 1;
						__instance.m_extraDrops.m_dropMax = 1;
						__instance.m_extraDrops.m_dropChance = 1f;
						__instance.m_respawnTimeMinutes = MainConfig.respawnTimeMystic.Value;
					}
					if (((Object)((Component)__instance).gameObject).name.Contains("Pickable_Purple_Kush"))
					{
						__instance.m_amount = MainConfig.budYieldDropKush.Value;
						__instance.m_dontScale = true;
						__instance.m_extraDrops.m_drops.Add(new DropData
						{
							m_item = prefab,
							m_stackMin = MainConfig.leafYieldDropKush.Value,
							m_stackMax = MainConfig.leafYieldDropKush.Value,
							m_weight = 0.01f,
							m_dontScale = true
						});
						__instance.m_extraDrops.m_dropMin = 1;
						__instance.m_extraDrops.m_dropMax = 1;
						__instance.m_extraDrops.m_dropChance = 1f;
						__instance.m_respawnTimeMinutes = MainConfig.respawnTimeKush.Value;
					}
					if (((Object)((Component)__instance).gameObject).name.Contains("Pickable_Black_Cherry"))
					{
						__instance.m_amount = MainConfig.budYieldDropCherry.Value;
						__instance.m_dontScale = true;
						__instance.m_extraDrops.m_drops.Add(new DropData
						{
							m_item = prefab,
							m_stackMin = MainConfig.leafYieldDropCherry.Value,
							m_stackMax = MainConfig.leafYieldDropCherry.Value,
							m_weight = 0.01f,
							m_dontScale = true
						});
						__instance.m_extraDrops.m_dropMin = 1;
						__instance.m_extraDrops.m_dropMax = 1;
						__instance.m_extraDrops.m_dropChance = 1f;
						__instance.m_respawnTimeMinutes = MainConfig.respawnTimeCherry.Value;
					}
					if (((Object)((Component)__instance).gameObject).name.Contains("Pickable_White_Widow"))
					{
						__instance.m_amount = MainConfig.budYieldDropWidow.Value;
						__instance.m_dontScale = true;
						__instance.m_extraDrops.m_drops.Add(new DropData
						{
							m_item = prefab,
							m_stackMin = MainConfig.leafYieldDropWidow.Value,
							m_stackMax = MainConfig.leafYieldDropWidow.Value,
							m_weight = 0.01f,
							m_dontScale = true
						});
						__instance.m_extraDrops.m_dropMin = 1;
						__instance.m_extraDrops.m_dropMax = 1;
						__instance.m_extraDrops.m_dropChance = 1f;
						__instance.m_respawnTimeMinutes = MainConfig.respawnTimeWidow.Value;
					}
					if (((Object)((Component)__instance).gameObject).name.Contains("Pickable_Burning_Desire"))
					{
						__instance.m_amount = MainConfig.budYieldDropDesire.Value;
						__instance.m_dontScale = true;
						__instance.m_extraDrops.m_drops.Add(new DropData
						{
							m_item = prefab,
							m_stackMin = MainConfig.leafYieldDropDesire.Value,
							m_stackMax = MainConfig.leafYieldDropDesire.Value,
							m_weight = 0.01f,
							m_dontScale = true
						});
						__instance.m_extraDrops.m_dropMin = 1;
						__instance.m_extraDrops.m_dropMax = 1;
						__instance.m_extraDrops.m_dropChance = 1f;
						__instance.m_respawnTimeMinutes = MainConfig.respawnTimeDesire.Value;
					}
					if (((Object)((Component)__instance).gameObject).name.Contains("Pickable_Northern_Lights"))
					{
						__instance.m_amount = MainConfig.budYieldDropLights.Value;
						__instance.m_dontScale = true;
						__instance.m_extraDrops.m_drops.Add(new DropData
						{
							m_item = prefab,
							m_stackMin = MainConfig.leafYieldDropLights.Value,
							m_stackMax = MainConfig.leafYieldDropLights.Value,
							m_weight = 0.01f,
							m_dontScale = true
						});
						__instance.m_extraDrops.m_dropMin = 1;
						__instance.m_extraDrops.m_dropMax = 1;
						__instance.m_extraDrops.m_dropChance = 1f;
						__instance.m_respawnTimeMinutes = MainConfig.respawnTimeLights.Value;
					}
					if (((Object)((Component)__instance).gameObject).name.Contains("Pickable_Durban_Poison"))
					{
						__instance.m_amount = MainConfig.budYieldDropPoison.Value;
						__instance.m_dontScale = true;
						__instance.m_extraDrops.m_drops.Add(new DropData
						{
							m_item = prefab,
							m_stackMin = MainConfig.leafYieldDropPoison.Value,
							m_stackMax = MainConfig.leafYieldDropPoison.Value,
							m_weight = 0.01f,
							m_dontScale = true
						});
						__instance.m_extraDrops.m_dropMin = 1;
						__instance.m_extraDrops.m_dropMax = 1;
						__instance.m_extraDrops.m_dropChance = 1f;
						__instance.m_respawnTimeMinutes = MainConfig.respawnTimePoison.Value;
					}
					if (((Object)((Component)__instance).gameObject).name.Contains("Pickable_Flyagaric"))
					{
						GameObject prefab2 = Cache.GetPrefab<GameObject>("FlyagaricSpores");
						__instance.m_amount = MainConfig.flyagaricYieldDrop.Value;
						__instance.m_dontScale = true;
						__instance.m_extraDrops.m_drops.Add(new DropData
						{
							m_item = prefab2,
							m_stackMin = MainConfig.flyagaricSporeDrop.Value,
							m_stackMax = MainConfig.flyagaricSporeDrop.Value,
							m_weight = 0.01f,
							m_dontScale = true
						});
						__instance.m_extraDrops.m_dropMin = 1;
						__instance.m_extraDrops.m_dropMax = 1;
						__instance.m_extraDrops.m_dropChance = 1f;
						__instance.m_respawnTimeMinutes = MainConfig.respawnTimeFlyagaric.Value;
					}
					if (((Object)((Component)__instance).gameObject).name.Contains("Pickable_LibertyCaps"))
					{
						GameObject prefab3 = Cache.GetPrefab<GameObject>("MushroomSpores");
						__instance.m_amount = MainConfig.libertyYieldDrop.Value;
						__instance.m_dontScale = true;
						__instance.m_extraDrops.m_drops.Add(new DropData
						{
							m_item = prefab3,
							m_stackMin = MainConfig.libertySporeDrop.Value,
							m_stackMax = MainConfig.libertySporeDrop.Value,
							m_weight = 0.01f,
							m_dontScale = true
						});
						__instance.m_extraDrops.m_dropMin = 1;
						__instance.m_extraDrops.m_dropMax = 1;
						__instance.m_extraDrops.m_dropChance = 1f;
						__instance.m_respawnTimeMinutes = MainConfig.respawnTimeLiberty.Value;
					}
				}
			}
		}

		[HarmonyPatch(typeof(ZNetScene), "Awake")]
		private static class ZNetScenePickablePatch
		{
			private static void Postfix(ZNetScene __instance)
			{
				Pickable component = ZNetScene.instance.GetPrefab("Pickable_Honey_Badger").GetComponent<Pickable>();
				Pickable component2 = ZNetScene.instance.GetPrefab("Pickable_Purple_Kush").GetComponent<Pickable>();
				Pickable component3 = ZNetScene.instance.GetPrefab("Pickable_Blue_Mystic").GetComponent<Pickable>();
				Pickable component4 = ZNetScene.instance.GetPrefab("Pickable_Black_Cherry").GetComponent<Pickable>();
				Pickable component5 = ZNetScene.instance.GetPrefab("Pickable_White_Widow").GetComponent<Pickable>();
				Pickable component6 = ZNetScene.instance.GetPrefab("Pickable_Burning_Desire").GetComponent<Pickable>();
				Pickable component7 = ZNetScene.instance.GetPrefab("Pickable_Northern_Lights").GetComponent<Pickable>();
				Pickable component8 = ZNetScene.instance.GetPrefab("Pickable_Durban_Poison").GetComponent<Pickable>();
				Pickable component9 = ZNetScene.instance.GetPrefab("Pickable_Flyagaric").GetComponent<Pickable>();
				Pickable component10 = ZNetScene.instance.GetPrefab("Pickable_LibertyCaps").GetComponent<Pickable>();
				try
				{
					component.m_amount = MainConfig.budYieldDropBadger.Value;
					component.m_extraDrops.m_dropMin = MainConfig.leafYieldDropBadger.Value;
					component.m_extraDrops.m_dropMax = MainConfig.leafYieldDropBadger.Value;
					component.m_respawnTimeMinutes = MainConfig.respawnTimeBadger.Value;
					component2.m_amount = MainConfig.budYieldDropKush.Value;
					component2.m_extraDrops.m_dropMin = MainConfig.leafYieldDropKush.Value;
					component2.m_extraDrops.m_dropMax = MainConfig.leafYieldDropKush.Value;
					component2.m_respawnTimeMinutes = MainConfig.respawnTimeKush.Value;
					component3.m_amount = MainConfig.budYieldDropMystic.Value;
					component3.m_extraDrops.m_dropMin = MainConfig.leafYieldDropMystic.Value;
					component3.m_extraDrops.m_dropMax = MainConfig.leafYieldDropMystic.Value;
					component3.m_respawnTimeMinutes = MainConfig.respawnTimeMystic.Value;
					component4.m_amount = MainConfig.budYieldDropCherry.Value;
					component4.m_extraDrops.m_dropMin = MainConfig.leafYieldDropCherry.Value;
					component4.m_extraDrops.m_dropMax = MainConfig.leafYieldDropCherry.Value;
					component4.m_respawnTimeMinutes = MainConfig.respawnTimeCherry.Value;
					component5.m_amount = MainConfig.budYieldDropWidow.Value;
					component5.m_extraDrops.m_dropMin = MainConfig.leafYieldDropWidow.Value;
					component5.m_extraDrops.m_dropMax = MainConfig.leafYieldDropWidow.Value;
					component5.m_respawnTimeMinutes = MainConfig.respawnTimeWidow.Value;
					component6.m_amount = MainConfig.budYieldDropDesire.Value;
					component6.m_extraDrops.m_dropMin = MainConfig.leafYieldDropDesire.Value;
					component6.m_extraDrops.m_dropMax = MainConfig.leafYieldDropDesire.Value;
					component6.m_respawnTimeMinutes = MainConfig.respawnTimeDesire.Value;
					component7.m_amount = MainConfig.budYieldDropLights.Value;
					component7.m_extraDrops.m_dropMin = MainConfig.leafYieldDropLights.Value;
					component7.m_extraDrops.m_dropMax = MainConfig.leafYieldDropLights.Value;
					component7.m_respawnTimeMinutes = MainConfig.respawnTimeLights.Value;
					component8.m_amount = MainConfig.budYieldDropPoison.Value;
					component8.m_extraDrops.m_dropMin = MainConfig.leafYieldDropPoison.Value;
					component8.m_extraDrops.m_dropMax = MainConfig.leafYieldDropPoison.Value;
					component8.m_respawnTimeMinutes = MainConfig.respawnTimePoison.Value;
					component9.m_amount = MainConfig.flyagaricYieldDrop.Value;
					component9.m_extraDrops.m_dropMin = MainConfig.flyagaricSporeDrop.Value;
					component9.m_extraDrops.m_dropMax = MainConfig.flyagaricSporeDrop.Value;
					component9.m_respawnTimeMinutes = MainConfig.respawnTimeFlyagaric.Value;
					component10.m_amount = MainConfig.libertyYieldDrop.Value;
					component10.m_extraDrops.m_dropMin = MainConfig.libertySporeDrop.Value;
					component10.m_extraDrops.m_dropMax = MainConfig.libertySporeDrop.Value;
					component10.m_respawnTimeMinutes = MainConfig.respawnTimeLiberty.Value;
				}
				catch
				{
					Logger.LogError((object)"Error with ZNetScenePickablePatch!");
				}
			}
		}

		[HarmonyPatch(typeof(ZNetScene), "Awake")]
		private static class ZNetScenePlantPatch
		{
			[HarmonyAfter(new string[] { "advize.PlantEverything" })]
			private static void Postfix(ZNetScene __instance)
			{
				Plant component = __instance.GetPrefab("sapling_flyagaric").GetComponent<Plant>();
				Plant component2 = __instance.GetPrefab("sapling_liberty_cap").GetComponent<Plant>();
				try
				{
					if (MainConfig.needCultivated.Value == MainConfig.Toggle.On)
					{
						component.m_needCultivatedGround = true;
						component2.m_needCultivatedGround = true;
					}
					else
					{
						component.m_needCultivatedGround = false;
						component2.m_needCultivatedGround = false;
					}
				}
				catch
				{
					Logger.LogError((object)"Error with ZNetScenePlantPatch!");
				}
			}
		}

		[HarmonyPatch(typeof(ZNetScene), "Awake")]
		private static class ZNetScenePlantPiecePatch
		{
			[HarmonyAfter(new string[] { "advize.PlantEverything" })]
			private static void Postfix(ZNetScene __instance)
			{
				Piece component = __instance.GetPrefab("sapling_flyagaric").GetComponent<Piece>();
				Piece component2 = __instance.GetPrefab("sapling_liberty_cap").GetComponent<Piece>();
				try
				{
					if (MainConfig.needCultivated.Value == MainConfig.Toggle.On)
					{
						component.m_cultivatedGroundOnly = true;
						component2.m_cultivatedGroundOnly = true;
					}
					else
					{
						component.m_cultivatedGroundOnly = false;
						component2.m_cultivatedGroundOnly = false;
					}
				}
				catch
				{
					Logger.LogError((object)"Error with ZNetScenePlantPiecePatch!");
				}
			}
		}

		[HarmonyPatch(typeof(Pickable), "GetHoverText")]
		public static class PickableHoverText
		{
			[HarmonyPostfix]
			public static void Postfix(Pickable __instance, ref string __result)
			{
				if (MainConfig.enableGrowTimer.Value == MainConfig.Toggle.On && __instance.m_picked && __instance.m_nview.GetZDO() != null)
				{
					if (((Object)((Component)__instance).gameObject).name.Contains("Pickable_Honey_Badger"))
					{
						float growthTime = MainConfig.respawnTimeBadger.Value * 60;
						DateTime placedTime = new DateTime(__instance.m_nview.GetZDO().GetLong(ZDOVars.s_pickedTime, 0L));
						string text = FormatTimeString(growthTime, placedTime);
						__result = Localization.instance.Localize(__instance.GetHoverName()) + "\n" + text;
					}
					if (((Object)((Component)__instance).gameObject).name.Contains("Pickable_Purple_Kush"))
					{
						float growthTime2 = MainConfig.respawnTimeKush.Value * 60;
						DateTime placedTime2 = new DateTime(__instance.m_nview.GetZDO().GetLong(ZDOVars.s_pickedTime, 0L));
						string text2 = FormatTimeString(growthTime2, placedTime2);
						__result = Localization.instance.Localize(__instance.GetHoverName()) + "\n" + text2;
					}
					if (((Object)((Component)__instance).gameObject).name.Contains("Pickable_Blue_Mystic"))
					{
						float growthTime3 = MainConfig.respawnTimeMystic.Value * 60;
						DateTime placedTime3 = new DateTime(__instance.m_nview.GetZDO().GetLong(ZDOVars.s_pickedTime, 0L));
						string text3 = FormatTimeString(growthTime3, placedTime3);
						__result = Localization.instance.Localize(__instance.GetHoverName()) + "\n" + text3;
					}
					if (((Object)((Component)__instance).gameObject).name.Contains("Pickable_Black_Cherry"))
					{
						float growthTime4 = MainConfig.respawnTimeCherry.Value * 60;
						DateTime placedTime4 = new DateTime(__instance.m_nview.GetZDO().GetLong(ZDOVars.s_pickedTime, 0L));
						string text4 = FormatTimeString(growthTime4, placedTime4);
						__result = Localization.instance.Localize(__instance.GetHoverName()) + "\n" + text4;
					}
					if (((Object)((Component)__instance).gameObject).name.Contains("Pickable_White_Widow"))
					{
						float growthTime5 = MainConfig.respawnTimeWidow.Value * 60;
						DateTime placedTime5 = new DateTime(__instance.m_nview.GetZDO().GetLong(ZDOVars.s_pickedTime, 0L));
						string text5 = FormatTimeString(growthTime5, placedTime5);
						__result = Localization.instance.Localize(__instance.GetHoverName()) + "\n" + text5;
					}
					if (((Object)((Component)__instance).gameObject).name.Contains("Pickable_Burning_Desire"))
					{
						float growthTime6 = MainConfig.respawnTimeWidow.Value * 60;
						DateTime placedTime6 = new DateTime(__instance.m_nview.GetZDO().GetLong(ZDOVars.s_pickedTime, 0L));
						string text6 = FormatTimeString(growthTime6, placedTime6);
						__result = Localization.instance.Localize(__instance.GetHoverName()) + "\n" + text6;
					}
					if (((Object)((Component)__instance).gameObject).name.Contains("Pickable_Northern_Lights"))
					{
						float growthTime7 = MainConfig.respawnTimeWidow.Value * 60;
						DateTime placedTime7 = new DateTime(__instance.m_nview.GetZDO().GetLong(ZDOVars.s_pickedTime, 0L));
						string text7 = FormatTimeString(growthTime7, placedTime7);
						__result = Localization.instance.Localize(__instance.GetHoverName()) + "\n" + text7;
					}
					if (((Object)((Component)__instance).gameObject).name.Contains("Pickable_Durban_Poison"))
					{
						float growthTime8 = MainConfig.respawnTimeWidow.Value * 60;
						DateTime placedTime8 = new DateTime(__instance.m_nview.GetZDO().GetLong(ZDOVars.s_pickedTime, 0L));
						string text8 = FormatTimeString(growthTime8, placedTime8);
						__result = Localization.instance.Localize(__instance.GetHoverName()) + "\n" + text8;
					}
					if (((Object)((Component)__instance).gameObject).name.Contains("Pickable_Flyagaric"))
					{
						float growthTime9 = MainConfig.respawnTimeFlyagaric.Value * 60;
						DateTime placedTime9 = new DateTime(__instance.m_nview.GetZDO().GetLong(ZDOVars.s_pickedTime, 0L));
						string text9 = FormatTimeString(growthTime9, placedTime9);
						__result = Localization.instance.Localize(__instance.GetHoverName()) + "\n" + text9;
					}
					if (((Object)((Component)__instance).gameObject).name.Contains("Pickable_LibertyCaps"))
					{
						float growthTime10 = MainConfig.respawnTimeLiberty.Value * 60;
						DateTime placedTime10 = new DateTime(__instance.m_nview.GetZDO().GetLong(ZDOVars.s_pickedTime, 0L));
						string text10 = FormatTimeString(growthTime10, placedTime10);
						__result = Localization.instance.Localize(__instance.GetHoverName()) + "\n" + text10;
					}
				}
			}
		}

		[HarmonyPatch(typeof(Plant), "GetHoverText")]
		public static class PlantHoverText
		{
			[HarmonyPostfix]
			public static void Postfix(Plant __instance, ref string __result)
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				if (MainConfig.enableGrowTimer.Value == MainConfig.Toggle.On && (int)__instance.m_status == 0 && __instance.m_nview.GetZDO() != null && (((Object)((Component)__instance).gameObject).name.Contains("sapling_blue_mystic") || ((Object)((Component)__instance).gameObject).name.Contains("sapling_honey_badger") || ((Object)((Component)__instance).gameObject).name.Contains("sapling_purple_kush") || ((Object)((Component)__instance).gameObject).name.Contains