Decompiled source of ProtectiveWards v1.1.13

ProtectiveWards.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using JetBrains.Annotations;
using Microsoft.CodeAnalysis;
using ServerSync;
using TMPro;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("ProtectiveWards")]
[assembly: AssemblyDescription("")]
[assembly: TargetFramework(".NETFramework,Version=v4.6.2", FrameworkDisplayName = ".NET Framework 4.6.2")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyProduct("ProtectiveWards")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("f71912b8-9b1c-4181-911a-1550f4ec2889")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyCompany("")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace ProtectiveWards
{
	internal class FullProtection
	{
		[HarmonyPatch(typeof(Character), "AddFireDamage")]
		public static class Character_AddFireDamage_IndirectFireDamageProtection
		{
			private static void Prefix(Character __instance, ref float damage)
			{
				//IL_0045: Unknown result type (might be due to invalid IL or missing references)
				if (ProtectiveWards.modEnabled.Value && ProtectiveWards.boarsHensProtection.Value && __instance.IsTamed() && ProtectiveWards._boarsHensProtectionGroupList.Contains(__instance.m_group.ToLower()) && ProtectiveWards.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_0045: Unknown result type (might be due to invalid IL or missing references)
				if (ProtectiveWards.modEnabled.Value && ProtectiveWards.boarsHensProtection.Value && __instance.IsTamed() && ProtectiveWards._boarsHensProtectionGroupList.Contains(__instance.m_group.ToLower()) && ProtectiveWards.InsideEnabledPlayersArea(((Component)__instance).transform.position))
				{
					dt = 0f;
				}
			}
		}

		[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_003e: Unknown result type (might be due to invalid IL or missing references)
				if (ProtectiveWards.modEnabled.Value && ProtectiveWards.wardRainProtection.Value && !((Object)(object)___m_nview == (Object)null) && ___m_nview.IsValid() && ProtectiveWards.InsideEnabledPlayersArea(((Component)__instance).transform.position))
				{
					__state = ___m_noRoofWear;
					___m_noRoofWear = false;
				}
			}

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

		[HarmonyPatch(typeof(Ship), "UpdateUpsideDmg")]
		public static class Ship_UpdateUpsideDmg_PreventShipDamage
		{
			private static bool Prefix(Ship __instance)
			{
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				if (!ProtectiveWards.modEnabled.Value)
				{
					return true;
				}
				if (ProtectiveWards.wardShipProtection.Value == ProtectiveWards.ShipDamageType.Off)
				{
					return true;
				}
				return !ProtectiveWards.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_002d: Unknown result type (might be due to invalid IL or missing references)
				if (ProtectiveWards.modEnabled.Value && ProtectiveWards.wardShipProtection.Value != 0 && ProtectiveWards.InsideEnabledPlayersArea(((Component)__instance).transform.position))
				{
					__state = ___m_waterImpactDamage;
					___m_waterImpactDamage = 0f;
				}
			}

			private static void Postfix(Ship __instance, ref float ___m_waterImpactDamage, float __state)
			{
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				if (ProtectiveWards.modEnabled.Value && ProtectiveWards.wardShipProtection.Value != 0 && ProtectiveWards.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_0049: Unknown result type (might be due to invalid IL or missing references)
				if (!ProtectiveWards.modEnabled.Value)
				{
					return true;
				}
				if (!ProtectiveWards.wardTrapProtection.Value)
				{
					return true;
				}
				Player componentInParent = ((Component)collider).GetComponentInParent<Player>();
				if ((Object)(object)componentInParent == (Object)null)
				{
					return true;
				}
				return !ProtectiveWards.InsideEnabledPlayersArea(((Component)componentInParent).transform.position);
			}
		}

		[HarmonyPatch(typeof(Destructible), "Damage")]
		public static class Destructible_Damage_PlantProtection
		{
			private static void ModifyHitDamage(HitData hit, float value)
			{
				((DamageTypes)(ref hit.m_damage)).Modify(Math.Max(value, 0f));
			}

			private static void Prefix(Destructible __instance, ZNetView ___m_nview, bool ___m_destroyed, HitData hit)
			{
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Invalid comparison between Unknown and I4
				//IL_008d: Unknown result type (might be due to invalid IL or missing references)
				if (!ProtectiveWards.modEnabled.Value || !ProtectiveWards.wardPlantProtection.Value || !___m_nview.IsValid() || !___m_nview.IsOwner() || ___m_destroyed || (int)__instance.GetDestructibleType() != 1 || __instance.m_health != 1f || !hit.HaveAttacker() || !ProtectiveWards.InsideEnabledPlayersArea(((Component)__instance).transform.position, out var area))
				{
					return;
				}
				Pickable val = default(Pickable);
				if ((Object)(object)((Component)__instance).GetComponent<Plant>() != (Object)null)
				{
					ModifyHitDamage(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 (ProtectiveWards._wardPlantProtectionList.Contains(shared.m_name.ToLower()))
					{
						ModifyHitDamage(hit, 0f);
						area.FlashShield(false);
					}
				}
			}
		}
	}
	internal class Multipliers
	{
		[HarmonyPatch(typeof(SEMan), "ModifyFallDamage")]
		public static class SEMan_ModifyFallDamage_FallDamageMultiplier
		{
			private static void Postfix(Character ___m_character, ZNetView ___m_nview, ref float damage)
			{
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				if (ProtectiveWards.modEnabled.Value && !((Object)(object)___m_nview == (Object)null) && ProtectiveWards.InsideEnabledPlayersArea(((Component)___m_character).transform.position))
				{
					damage *= Math.Max(ProtectiveWards.fallDamageTakenMultiplier.Value, 0f);
				}
			}
		}

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

		[HarmonyPatch(typeof(WearNTear), "Damage")]
		public static class WearNTear_Damage_DamageTakenMultiplier
		{
			private static void Prefix(WearNTear __instance, ref HitData hit, ZNetView ___m_nview)
			{
				//IL_0026: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0054: Invalid comparison between Unknown and I4
				//IL_008b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0091: Invalid comparison between Unknown and I4
				if (ProtectiveWards.modEnabled.Value && !((Object)(object)___m_nview == (Object)null) && ProtectiveWards.InsideEnabledPlayersArea(((Component)__instance).transform.position))
				{
					if (ProtectiveWards.fireplaceProtection.Value && (int)hit.m_hitType == 14 && (Object)(object)((Component)__instance).GetComponent<Fireplace>() != (Object)null)
					{
						ModifyHitDamage(ref hit, 0f);
					}
					else if (ProtectiveWards.wardShipProtection.Value == ProtectiveWards.ShipDamageType.AnyButPlayerDamage && (int)hit.m_hitType != 2 && (Object)(object)((Component)__instance).GetComponent<Ship>() != (Object)null)
					{
						ModifyHitDamage(ref hit, 0f);
					}
					else if (ProtectiveWards.wardShipProtection.Value == ProtectiveWards.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, ProtectiveWards.structureDamageTakenMultiplier.Value);
					}
				}
			}
		}

		[HarmonyPatch(typeof(Player), "UpdateFood")]
		public static class Player_UpdateFood_FoodDrainMultiplier
		{
			private static void Prefix(Player __instance, float dt, bool forceUpdate)
			{
				//IL_0064: Unknown result type (might be due to invalid IL or missing references)
				if (!ProtectiveWards.modEnabled.Value || ProtectiveWards.foodDrainMultiplier.Value == 1f || (Object)(object)__instance == (Object)null || !(dt + __instance.m_foodUpdateTimer >= 1f || forceUpdate) || !ProtectiveWards.InsideEnabledPlayersArea(((Component)__instance).transform.position))
				{
					return;
				}
				foreach (Food food in __instance.m_foods)
				{
					food.m_time += 1f - Math.Max(0f, ProtectiveWards.foodDrainMultiplier.Value);
				}
			}
		}

		[HarmonyPatch(typeof(Player), "UseStamina")]
		public static class Player_UseStamina_StaminaDrainMultiplier
		{
			private static void Prefix(Player __instance, ref float v)
			{
				//IL_003e: Unknown result type (might be due to invalid IL or missing references)
				if (ProtectiveWards.modEnabled.Value && ProtectiveWards.staminaDrainMultiplier.Value != 1f && !((Object)(object)__instance == (Object)null) && ProtectiveWards.InsideEnabledPlayersArea(((Component)__instance).transform.position))
				{
					v *= Math.Max(0f, ProtectiveWards.staminaDrainMultiplier.Value);
				}
			}
		}

		[HarmonyPatch(typeof(Player), "UpdatePlacement")]
		public static class Player_UseStamina_HammerDurabilityDrainMultiplier
		{
			private static void Prefix(Player __instance, ref float __state)
			{
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				if (ProtectiveWards.modEnabled.Value && ProtectiveWards.hammerDurabilityDrainMultiplier.Value != 1f && !((Object)(object)__instance == (Object)null) && ((Character)__instance).InPlaceMode() && ProtectiveWards.InsideEnabledPlayersArea(((Component)__instance).transform.position))
				{
					ItemData rightItem = ((Humanoid)__instance).GetRightItem();
					__state = rightItem.m_shared.m_useDurabilityDrain;
					SharedData shared = rightItem.m_shared;
					shared.m_useDurabilityDrain *= Math.Max(0f, ProtectiveWards.hammerDurabilityDrainMultiplier.Value);
				}
			}

			private static void Postfix(Player __instance, float __state)
			{
				if (__state != 0f)
				{
					ItemData rightItem = ((Humanoid)__instance).GetRightItem();
					rightItem.m_shared.m_useDurabilityDrain = __state;
				}
			}
		}

		[HarmonyPatch(typeof(Player), "Repair")]
		public static class Player_Repair_HammerDurabilityDrainMultiplier
		{
			private static void Prefix(Player __instance, ItemData toolItem, ref float __state)
			{
				//IL_0050: Unknown result type (might be due to invalid IL or missing references)
				if (ProtectiveWards.modEnabled.Value && ProtectiveWards.hammerDurabilityDrainMultiplier.Value != 1f && !((Object)(object)__instance == (Object)null) && ((Character)__instance).InPlaceMode() && ProtectiveWards.InsideEnabledPlayersArea(((Component)__instance).transform.position))
				{
					__state = toolItem.m_shared.m_useDurabilityDrain;
					SharedData shared = toolItem.m_shared;
					shared.m_useDurabilityDrain *= Math.Max(0f, ProtectiveWards.hammerDurabilityDrainMultiplier.Value);
				}
			}

			private static void Postfix(Player __instance, ItemData toolItem, float __state)
			{
				if (__state != 0f)
				{
					toolItem.m_shared.m_useDurabilityDrain = __state;
				}
			}
		}

		[HarmonyPatch(typeof(Skills), "LowerAllSkills")]
		private static class Skills_OnDeath_SkillDrainMultiplier
		{
			private static void Prefix(ref float factor, Player ___m_player)
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				if (ProtectiveWards.modEnabled.Value && !((Object)(object)___m_player == (Object)null) && ProtectiveWards.InsideEnabledPlayersArea(((Component)___m_player).transform.position))
				{
					factor *= Math.Max(0f, ProtectiveWards.skillsDrainMultiplier.Value);
				}
			}
		}

		[HarmonyPatch(typeof(Fireplace), "GetTimeSinceLastUpdate")]
		private static class Fireplace_GetTimeSinceLastUpdate_FireplaceDrainMultiplier
		{
			private static void Postfix(Fireplace __instance, ref double __result)
			{
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				if (ProtectiveWards.modEnabled.Value && ProtectiveWards.fireplaceDrainMultiplier.Value != 1f && ProtectiveWards.InsideEnabledPlayersArea(((Component)__instance).transform.position))
				{
					__result *= Math.Max(0f, ProtectiveWards.fireplaceDrainMultiplier.Value);
				}
			}
		}

		[HarmonyPatch(typeof(Smelter), "GetDeltaTime")]
		private static class Smelter_GetDeltaTime_FireplaceDrainMultiplier_SmeltingSpeedMultiplier
		{
			private static void Postfix(Smelter __instance, ref double __result)
			{
				//IL_0051: Unknown result type (might be due to invalid IL or missing references)
				if (ProtectiveWards.modEnabled.Value)
				{
					float num = ((__instance.m_name == "$piece_bathtub") ? ProtectiveWards.fireplaceDrainMultiplier.Value : ProtectiveWards.smeltingSpeedMultiplier.Value);
					if (num != 1f && ProtectiveWards.InsideEnabledPlayersArea(((Component)__instance).transform.position))
					{
						__result *= Math.Max(0f, num);
					}
				}
			}
		}

		[HarmonyPatch(typeof(CookingStation), "GetDeltaTime")]
		private static class CookingStation_GetDeltaTime_CookingSpeedMultiplier
		{
			private static void Postfix(Smelter __instance, ref float __result)
			{
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				if (ProtectiveWards.modEnabled.Value && ProtectiveWards.cookingSpeedMultiplier.Value != 1f && ProtectiveWards.InsideEnabledPlayersArea(((Component)__instance).transform.position))
				{
					__result *= Math.Max(0f, ProtectiveWards.cookingSpeedMultiplier.Value);
				}
			}
		}

		[HarmonyPatch(typeof(CookingStation), "UpdateFuel")]
		private static class CookingStation_UpdateFuel_FireplaceDrainMultiplier
		{
			private static void Prefix(Smelter __instance, ref float dt, ref float __state)
			{
				//IL_0048: Unknown result type (might be due to invalid IL or missing references)
				if (ProtectiveWards.modEnabled.Value && (ProtectiveWards.fireplaceDrainMultiplier.Value != 1f || ProtectiveWards.cookingSpeedMultiplier.Value != 1f) && ProtectiveWards.InsideEnabledPlayersArea(((Component)__instance).transform.position))
				{
					__state = dt;
					dt *= Math.Max(0f, ProtectiveWards.fireplaceDrainMultiplier.Value);
					if (ProtectiveWards.cookingSpeedMultiplier.Value > 0f)
					{
						dt /= ProtectiveWards.cookingSpeedMultiplier.Value;
					}
				}
			}

			private static void Postfix(Smelter __instance, ref float dt, float __state)
			{
				if (__state != 0f)
				{
					dt = __state;
				}
			}
		}

		[HarmonyPatch(typeof(Fermenter), "GetFermentationTime")]
		private static class Fermenter_GetFermentationTime_FermentingSpeedMultiplier
		{
			private static void Postfix(Fermenter __instance, ref double __result)
			{
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				if (ProtectiveWards.modEnabled.Value && ProtectiveWards.fermentingSpeedMultiplier.Value != 1f && ProtectiveWards.InsideEnabledPlayersArea(((Component)__instance).transform.position))
				{
					__result *= Math.Max(0f, ProtectiveWards.fermentingSpeedMultiplier.Value);
				}
			}
		}

		[HarmonyPatch(typeof(SapCollector), "GetTimeSinceLastUpdate")]
		private static class SapCollector_GetTimeSinceLastUpdate_SapCollectingSpeedMultiplier
		{
			private static void Postfix(SapCollector __instance, ref float __result)
			{
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				if (ProtectiveWards.modEnabled.Value && ProtectiveWards.sapCollectingSpeedMultiplier.Value != 1f && ProtectiveWards.InsideEnabledPlayersArea(((Component)__instance).transform.position))
				{
					__result *= Math.Max(0f, ProtectiveWards.sapCollectingSpeedMultiplier.Value);
				}
			}
		}

		[HarmonyPatch(typeof(Turret), "IsCoolingDown")]
		private static class Turret_IsCoolingDown_turretFireRateMultiplier
		{
			private static void Prefix(Turret __instance, ref float ___m_attackCooldown, ref float __state)
			{
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				if (ProtectiveWards.modEnabled.Value && ProtectiveWards.turretFireRateMultiplier.Value != 1f && ProtectiveWards.InsideEnabledPlayersArea(((Component)__instance).transform.position))
				{
					__state = ___m_attackCooldown;
					___m_attackCooldown *= Math.Max(0f, ProtectiveWards.turretFireRateMultiplier.Value);
				}
			}

			private static void Postfix(ref float ___m_attackCooldown, float __state)
			{
				if (ProtectiveWards.modEnabled.Value && __state > 0f)
				{
					___m_attackCooldown = __state;
				}
			}
		}

		private static void ModifyHitDamage(ref HitData hit, float value)
		{
			((DamageTypes)(ref hit.m_damage)).Modify(Math.Max(value, 0f));
		}
	}
	internal class RaidProtection
	{
		[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_0066: Unknown result type (might be due to invalid IL or missing references)
				if (ProtectiveWards.modEnabled.Value && ProtectiveWards.sittingRaidProtection.Value && ___m_baseValueUpdateTimer == 0f && ___m_baseValue >= 3 && ((Character)__instance).IsSitting() && __instance.m_attached && ((Character)__instance).m_seman.HaveStatusEffect(Player.s_statusEffectCampFire) && ProtectiveWards.InsideEnabledPlayersArea(((Component)__instance).transform.position))
				{
					___m_baseValue = ProtectiveWards.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_0027: 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_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				if (ProtectiveWards.modEnabled.Value && ProtectiveWards.sittingRaidProtection.Value && __result && player.baseValue == ProtectiveWards.baseValueProtected)
				{
					ProtectiveWards.LogInfo($"Player at {player.position.x} {player.position.z} is in raid protected state.");
					__result = false;
				}
			}
		}
	}
	internal class WardOfferings
	{
		[HarmonyPatch(typeof(PrivateArea), "UseItem")]
		public static class PrivateArea_UseItem_Offerings
		{
			private static void Postfix(PrivateArea __instance, Humanoid user, ItemData item, ref bool __result)
			{
				//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b0: Invalid comparison between Unknown and I4
				//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f5: Invalid comparison between Unknown and I4
				if (!__instance.IsEnabled())
				{
					return;
				}
				Player val = (Player)(object)((user is Player) ? user : null);
				if (!Object.op_Implicit((Object)(object)val))
				{
					ProtectiveWards.LogInfo("UseItem user not a player");
					return;
				}
				bool flag = item.m_shared.m_name == "$item_blackcore" && ProtectiveWards.offeringAugmenting.Value;
				bool flag2 = flag || (item.m_shared.m_name == "$item_surtlingcore" && ProtectiveWards.offeringActiveRepair.Value);
				bool flag3 = (ProtectiveWards.offeringFood.Value || ProtectiveWards.offeringMead.Value) && (int)item.m_shared.m_itemType == 2;
				bool flag4 = ProtectiveWards.offeringThundertone.Value && item.m_shared.m_name == "$item_thunderstone";
				bool flag5 = ProtectiveWards.offeringTrophy.Value && (int)item.m_shared.m_itemType == 13;
				bool flag6 = ProtectiveWards.offeringEitr.Value && item.m_shared.m_name == "$item_eitr";
				bool flag7 = (ProtectiveWards.offeringYmirRemains.Value && item.m_shared.m_name == "$item_ymirremains") || flag6;
				bool flag8 = item.m_shared.m_name == "$item_dragonegg" && ZoneSystem.instance.GetGlobalKey((GlobalKeys)33);
				bool flag9 = ProtectiveWards.offeringTaxi.Value && (item.m_shared.m_name == "$item_coins" || item.m_shared.m_name == "$item_trophy_eikthyr" || item.m_shared.m_name == "$item_trophy_elder" || item.m_shared.m_name == "$item_trophy_bonemass" || item.m_shared.m_name == "$item_trophy_dragonqueen" || item.m_shared.m_name == "$item_trophy_goblinking" || item.m_shared.m_name == "$item_trophy_seekerqueen" || item.m_shared.m_name == "$item_goblintotem" || item.m_shared.m_name == "$item_chest_hildir1" || item.m_shared.m_name == "$item_chest_hildir2" || item.m_shared.m_name == "$item_chest_hildir3");
				if (flag2 || flag3 || flag4 || flag5 || flag7 || flag8 || flag9)
				{
					if (flag2)
					{
						RepairNearestStructures(flag, __instance, val, item);
					}
					if (flag3)
					{
						ApplyConsumableEffectToNearestPlayers(__instance, item, val);
					}
					if (flag4)
					{
						ApplyThunderstrikeOnNearbyEnemies(__instance, item, val);
					}
					if (flag5)
					{
						ApplyTrophyEffectOnNearbyEnemies(__instance, item, val);
					}
					if (flag7)
					{
						ApplyInstantGrowthEffectOnNearbyPlants(__instance, item, val, !flag6);
					}
					if (flag8)
					{
						ApplyModerPowerEffectToNearbyPlayers(__instance, item, val);
					}
					if (flag9)
					{
						TaxiToLocation(item, val);
					}
					__result = true;
				}
			}
		}

		[HarmonyPatch(typeof(Player), "SetIntro")]
		public static class Player_SetIntro_Taxi
		{
			private static void Postfix(Player __instance)
			{
				//IL_003c: Unknown result type (might be due to invalid IL or missing references)
				if (ProtectiveWards.modEnabled.Value && !((Character)__instance).InIntro())
				{
					if (ProtectiveWards.taxiReturnBack && ProtectiveWards.canTravel)
					{
						ProtectiveWards.isTravelingPlayer = __instance;
						((MonoBehaviour)__instance).StartCoroutine(ReturnPlayerToPosition(__instance, ProtectiveWards.taxiPlayerPositionToReturn, 120));
					}
					else
					{
						ProtectiveWards.isTravelingPlayer = null;
					}
				}
			}
		}

		[HarmonyPatch(typeof(Valkyrie), "Awake")]
		public static class Valkyrie_Awake_Taxi
		{
			private static bool Prefix(Valkyrie __instance)
			{
				//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
				//IL_0107: Unknown result type (might be due to invalid IL or missing references)
				//IL_010c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0111: Unknown result type (might be due to invalid IL or missing references)
				//IL_0120: Unknown result type (might be due to invalid IL or missing references)
				//IL_0125: Unknown result type (might be due to invalid IL or missing references)
				//IL_0138: Unknown result type (might be due to invalid IL or missing references)
				//IL_013d: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
				//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
				//IL_0229: Unknown result type (might be due to invalid IL or missing references)
				//IL_0234: Unknown result type (might be due to invalid IL or missing references)
				//IL_023a: Unknown result type (might be due to invalid IL or missing references)
				//IL_023f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0256: Unknown result type (might be due to invalid IL or missing references)
				//IL_025c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0261: Unknown result type (might be due to invalid IL or missing references)
				//IL_0266: Unknown result type (might be due to invalid IL or missing references)
				//IL_027e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0283: Unknown result type (might be due to invalid IL or missing references)
				//IL_028b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0290: Unknown result type (might be due to invalid IL or missing references)
				//IL_0295: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_02df: Unknown result type (might be due to invalid IL or missing references)
				//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
				if (!ProtectiveWards.modEnabled.Value)
				{
					return true;
				}
				if (!ProtectiveWards.offeringTaxi.Value)
				{
					return true;
				}
				if ((Object)(object)ProtectiveWards.isTravelingPlayer == (Object)null)
				{
					return true;
				}
				if (ProtectiveWards.isTravelingPlayer.m_firstSpawn)
				{
					return true;
				}
				Valkyrie.m_instance = __instance;
				__instance.m_nview = ((Component)__instance).GetComponent<ZNetView>();
				__instance.m_animator = ((Component)__instance).GetComponentInChildren<Animator>();
				if (!__instance.m_nview.IsOwner())
				{
					((Behaviour)__instance).enabled = false;
					return false;
				}
				__instance.m_startPause = 2f;
				__instance.m_startAltitude = 30f;
				__instance.m_textDuration = 0f;
				__instance.m_descentAltitude = 150f;
				__instance.m_attachOffset = new Vector3(-0.1f, 1.5f, 0.1f);
				__instance.m_targetPoint = ProtectiveWards.taxiTargetPosition + new Vector3(0f, __instance.m_dropHeight, 0f);
				Vector3 position = ((Component)ProtectiveWards.isTravelingPlayer).transform.position;
				position.y += __instance.m_startAltitude;
				float num = (__instance.m_startDistance = Vector3.Distance(__instance.m_targetPoint, position));
				__instance.m_startDescentDistance = Math.Min(200f, num / 5f);
				__instance.m_speed = Math.Max(Math.Min(num / 90f, Math.Min(30f, ProtectiveWards.maxTaxiSpeed.Value)), 10f);
				if (__instance.m_speed <= 15f)
				{
					EnvMan.instance.m_introEnvironment = EnvMan.instance.m_currentEnv.m_name;
				}
				else
				{
					EnvMan.instance.m_introEnvironment = "ThunderStorm";
				}
				ProtectiveWards.isTravelingPlayer.m_intro = true;
				((Component)__instance).transform.position = position;
				float num2 = Utils.DistanceXZ(__instance.m_targetPoint, ((Component)__instance).transform.position);
				float num3 = Math.Max(__instance.m_descentAltitude / num2, Math.Min(__instance.m_descentAltitude * 2f / num2, 0.2f));
				__instance.m_descentStart = Vector3.Lerp(__instance.m_targetPoint, ((Component)__instance).transform.position, num3);
				__instance.m_descentStart.y = __instance.m_descentAltitude;
				Vector3 val = __instance.m_targetPoint - __instance.m_descentStart;
				val.y = 0f;
				((Vector3)(ref val)).Normalize();
				__instance.m_flyAwayPoint = __instance.m_targetPoint + val * __instance.m_startDescentDistance;
				__instance.m_flyAwayPoint.y += 100f;
				__instance.SyncPlayer(true);
				Vector3 val2 = ((Component)__instance).transform.position;
				string? text = ((object)(Vector3)(ref val2)).ToString();
				val2 = ZNet.instance.GetReferencePosition();
				ProtectiveWards.LogInfo("Setting up valkyrie " + text + "   " + ((object)(Vector3)(ref val2)).ToString());
				return false;
			}
		}

		[HarmonyPatch(typeof(Valkyrie), "LateUpdate")]
		public static class Valkyrie_LateUpdate_Taxi
		{
			private static void Prefix(Valkyrie __instance)
			{
				if (ProtectiveWards.modEnabled.Value && ProtectiveWards.offeringTaxi.Value && ((ZInput.GetButton("Use") && ZInput.GetButton("AltPlace")) || (ZInput.GetButton("JoyUse") && ZInput.GetButton("JoyAltPlace"))))
				{
					__instance.DropPlayer(false);
				}
			}
		}

		[HarmonyPatch(typeof(Valkyrie), "DropPlayer")]
		public static class Valkyrie_DropPlayer_Taxi
		{
			private static void Postfix()
			{
				if (ProtectiveWards.modEnabled.Value && ProtectiveWards.offeringTaxi.Value)
				{
					ProtectiveWards.playerDropped = true;
					if (!((Character)Player.m_localPlayer).m_seman.HaveStatusEffect("SlowFall"))
					{
						ProtectiveWards.castSlowFall = true;
						((Character)Player.m_localPlayer).m_seman.AddStatusEffect(StringExtensionMethods.GetStableHashCode("SlowFall"), false, 0, 0f);
						ProtectiveWards.LogInfo("Cast slow fall");
					}
				}
			}
		}

		[HarmonyPatch(typeof(Player), "Update")]
		public static class Player_Update_Taxi
		{
			private static void Postfix(Player __instance)
			{
				if (ProtectiveWards.modEnabled.Value && ProtectiveWards.offeringTaxi.Value && !((Object)(object)Player.m_localPlayer != (Object)(object)__instance) && ProtectiveWards.playerDropped && ProtectiveWards.castSlowFall && ((Character)__instance).IsOnGround())
				{
					ProtectiveWards.castSlowFall = false;
					ProtectiveWards.playerDropped = false;
					if (((Character)__instance).m_seman.HaveStatusEffect("SlowFall"))
					{
						((Character)__instance).m_seman.RemoveStatusEffect(StringExtensionMethods.GetStableHashCode("SlowFall"), true);
					}
					ProtectiveWards.LogInfo("Remove slow fall");
				}
			}
		}

		[HarmonyPatch(typeof(Valkyrie), "OnDestroy")]
		public static class Valkyrie_OnDestroy_Taxi
		{
			private static void Postfix()
			{
				if (ProtectiveWards.modEnabled.Value)
				{
					ProtectiveWards.canTravel = true;
				}
			}
		}

		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 (!ProtectiveWards.wardIsHealing.TryGetValue(ward, out var secondsLeft))
				{
					yield break;
				}
				if (secondsLeft <= 0)
				{
					break;
				}
				ProtectiveWards.wardIsHealing[ward] -= seconds;
				List<Player> players = new List<Player>();
				List<Character> characters = new List<Character>();
				ProtectiveWards.ConnectedAreas(ward).ForEach(delegate(PrivateArea area)
				{
					//IL_0007: Unknown result type (might be due to invalid IL or missing references)
					//IL_0024: 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 player in players.Distinct().ToList())
				{
					((Character)player).Heal(amount * (float)seconds, true);
				}
				foreach (Character character in characters.Distinct().ToList())
				{
					if (character.IsTamed())
					{
						character.Heal(amount * (float)seconds, true);
					}
				}
				yield return (object)new WaitForSecondsRealtime((float)seconds);
			}
			ProtectiveWards.wardIsHealing.Remove(ward);
			ProtectiveWards.LogInfo("Passive healing stopped");
		}

		public static IEnumerator LightningStrikeEffect(PrivateArea ward)
		{
			if ((Object)(object)ward == (Object)null)
			{
				yield break;
			}
			List<Player> players = new List<Player>();
			ProtectiveWards.ConnectedAreas(ward).ForEach(delegate(PrivateArea area)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				Player.GetPlayersInRange(((Component)area).transform.position, area.m_radius, players);
			});
			foreach (Player player in players.Distinct().ToList())
			{
				ProtectiveWards.preLightning.Create(((Component)player).transform.position, ((Component)player).transform.rotation, (Transform)null, 1f, -1);
			}
			ProtectiveWards.LogInfo("Thor is preparing his strike");
			yield return (object)new WaitForSeconds(Random.Range(5f, 7f));
			if (Game.IsPaused())
			{
				yield return (object)new WaitForSeconds(1f);
			}
			List<Character> characters = new List<Character>();
			ProtectiveWards.ConnectedAreas(ward).ForEach(delegate(PrivateArea area)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				Character.GetCharactersInRange(((Component)area).transform.position, area.m_radius, characters);
			});
			foreach (Character character in characters.Distinct().ToList())
			{
				if (character.IsMonsterFaction(Time.time))
				{
					Object.Instantiate<GameObject>(ProtectiveWards.lightningAOE, ((Component)character).transform.position, ((Component)character).transform.rotation);
				}
			}
		}

		public static IEnumerator InstantGrowthEffect(PrivateArea ward, List<Plant> plants)
		{
			if ((Object)(object)ward == (Object)null)
			{
				yield break;
			}
			ProtectiveWards.LogInfo("Instant growth started");
			yield return (object)new WaitForSeconds(1f);
			foreach (Plant plant in plants.Distinct().ToList())
			{
				if (plant.m_nview.IsOwner())
				{
					if ((int)plant.m_status > 0)
					{
						plant.UpdateHealth(0.0);
					}
					plant.Grow();
					yield return (object)new WaitForSeconds(0.25f);
				}
			}
			ProtectiveWards.LogInfo("Instant growth ended");
		}

		public static IEnumerator ReturnPlayerToPosition(Player player, Vector3 position, int seconds)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)player == (Object)null))
			{
				ProtectiveWards.canTravel = false;
				ProtectiveWards.LogInfo("Timer of player returnal started");
				for (int i = seconds; i >= 0; i--)
				{
					((Character)player).Message((MessageType)((i > 15) ? 1 : 2), Localization.instance.Localize("$button_return") + " " + TimeSpan.FromSeconds(i).ToString("m\\:ss"), 0, (Sprite)null);
					yield return (object)new WaitForSeconds(1f);
				}
				ProtectiveWards.LogInfo("Timer of player returnal ended");
				((MonoBehaviour)player).StartCoroutine(TaxiToPosition(player, position));
			}
		}

		private static void RepairNearestStructures(bool augment, PrivateArea ward, Player initiator, ItemData item)
		{
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			int num2 = 0;
			List<Piece> pieces = new List<Piece>();
			ProtectiveWards.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);
			});
			foreach (Piece item2 in pieces)
			{
				if (!item2.IsPlacedByPlayer())
				{
					continue;
				}
				WearNTear component = ((Component)item2).GetComponent<WearNTear>();
				if (Object.op_Implicit((Object)(object)component))
				{
					if (component.Repair())
					{
						num++;
						item2.m_placeEffect.Create(((Component)item2).transform.position, ((Component)item2).transform.rotation, (Transform)null, 1f, -1);
					}
					if (augment && (Object)(object)component.m_nview != (Object)null && component.m_nview.IsValid() && component.m_nview.IsOwner() && component.m_nview.GetZDO().GetFloat(ZDOVars.s_health, component.m_health) < component.m_health * 2f)
					{
						component.m_nview.GetZDO().Set(ZDOVars.s_health, component.m_health * 2f);
						component.m_nview.InvokeRPC(ZNetView.Everybody, "WNTHealthChanged", new object[1] { component.m_health * 2f });
						num2++;
					}
				}
			}
			if (num + num2 > 0)
			{
				((Humanoid)initiator).GetInventory().RemoveOneItem(item);
			}
			if (num2 > 0)
			{
				((Character)initiator).Message((MessageType)2, Localization.instance.Localize("$msg_offerdone"), 0, (Sprite)null);
				if (num > 0)
				{
					((Character)initiator).Message((MessageType)1, Localization.instance.Localize("$msg_repaired", new string[1] { num.ToString() }), 0, (Sprite)null);
				}
			}
			else if (num > 0)
			{
				((Character)initiator).Message((MessageType)2, Localization.instance.Localize("$msg_repaired", new string[1] { num.ToString() }), 0, (Sprite)null);
			}
			else if (augment)
			{
				((Character)initiator).Message((MessageType)2, Localization.instance.Localize("$msg_cantoffer"), 0, (Sprite)null);
			}
			else
			{
				string text = Localization.instance.Localize("$msg_doesnotneedrepair");
				((Character)initiator).Message((MessageType)2, char.ToUpper(text[0]) + text.Substring(1), 0, (Sprite)null);
			}
		}

		private static void GetPlantsInRange(Vector3 point, float radius, List<Plant> plants, bool growableOnly)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Invalid comparison between Unknown and I4
			List<SlowUpdate> allInstaces = SlowUpdate.GetAllInstaces();
			float num = radius * radius;
			Plant val = default(Plant);
			foreach (SlowUpdate item in allInstaces)
			{
				if (((Component)item).TryGetComponent<Plant>(ref val) && Utils.DistanceSqr(((Component)item).transform.position, point) < num && val.m_nview.IsOwner() && (!growableOnly || (int)val.m_status == 0))
				{
					plants.Add(val);
				}
			}
		}

		private static void ApplyTrophyEffectOnNearbyEnemies(PrivateArea ward, ItemData item, Player initiator)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
			ProtectiveWards.trophyTargets = Resources.FindObjectsOfTypeAll<Turret>().FirstOrDefault().m_configTargets;
			bool flag = false;
			foreach (TrophyTarget trophyTarget in ProtectiveWards.trophyTargets)
			{
				if (!(item.m_shared.m_name == trophyTarget.m_item.m_itemData.m_shared.m_name))
				{
					continue;
				}
				List<Character> characters = new List<Character>();
				ProtectiveWards.ConnectedAreas(ward).ForEach(delegate(PrivateArea area)
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					Character.GetCharactersInRange(((Component)area).transform.position, area.m_radius, characters);
				});
				foreach (Character item2 in characters.Distinct().ToList())
				{
					if (!item2.IsMonsterFaction(Time.time))
					{
						continue;
					}
					foreach (Character target in trophyTarget.m_targets)
					{
						if (item2.m_name == target.m_name)
						{
							item2.SetHealth(0f);
							flag = true;
						}
					}
				}
			}
			if (flag)
			{
				((Humanoid)initiator).GetInventory().RemoveOneItem(item);
				((Character)initiator).Message((MessageType)2, Localization.instance.Localize("$msg_offerdone"), 0, (Sprite)null);
			}
			else
			{
				((Character)initiator).Message((MessageType)2, Localization.instance.Localize("$msg_offerwrong"), 0, (Sprite)null);
			}
		}

		private static void ApplyThunderstrikeOnNearbyEnemies(PrivateArea ward, ItemData item, Player initiator)
		{
			Incinerator val = Resources.FindObjectsOfTypeAll<Incinerator>().FirstOrDefault();
			ProtectiveWards.lightningAOE = val.m_lightingAOEs;
			ProtectiveWards.preLightning = val.m_leverEffects;
			((MonoBehaviour)ProtectiveWards.instance).StartCoroutine(LightningStrikeEffect(ward));
			((Humanoid)initiator).GetInventory().RemoveOneItem(item);
			((Character)initiator).Message((MessageType)2, Localization.instance.Localize("$piece_incinerator_conversion"), 0, (Sprite)null);
		}

		private static void ApplyConsumableEffectToNearestPlayers(PrivateArea ward, ItemData item, Player initiator)
		{
			if (item.m_shared.m_food > 0f)
			{
				if (ProtectiveWards.wardIsHealing.ContainsKey(ward))
				{
					((Character)initiator).Message((MessageType)2, Localization.instance.Localize("$msg_offerwrong"), 0, (Sprite)null);
					return;
				}
				ProtectiveWards.wardIsHealing.Add(ward, 180);
				((MonoBehaviour)ProtectiveWards.instance).StartCoroutine(PassiveHealingEffect(ward, item.m_shared.m_foodRegen / 2f, 1));
				ProtectiveWards.LogInfo("Passive healing begins");
				((Humanoid)initiator).GetInventory().RemoveOneItem(item);
				((Character)initiator).Message((MessageType)2, Localization.instance.Localize("$msg_consumed"), 0, (Sprite)null);
			}
			else
			{
				if (!Object.op_Implicit((Object)(object)item.m_shared.m_consumeStatusEffect))
				{
					return;
				}
				ProtectiveWards.LogInfo("Consumable effect offered");
				List<Player> players = new List<Player>();
				ProtectiveWards.ConnectedAreas(ward).ForEach(delegate(PrivateArea area)
				{
					//IL_0006: Unknown result type (might be due to invalid IL or missing references)
					Player.GetPlayersInRange(((Component)area).transform.position, area.m_radius, players);
				});
				bool flag = false;
				foreach (Player item2 in players.Distinct().ToList())
				{
					if (((Humanoid)item2).CanConsumeItem(item, false))
					{
						_ = item.m_shared.m_consumeStatusEffect;
						((Character)item2).m_seman.AddStatusEffect(item.m_shared.m_consumeStatusEffect, true, 0, 0f);
						flag = true;
					}
				}
				if (!flag)
				{
					((Character)initiator).Message((MessageType)2, Localization.instance.Localize("$msg_cantoffer"), 0, (Sprite)null);
					return;
				}
				((Humanoid)initiator).GetInventory().RemoveOneItem(item);
				((Character)initiator).Message((MessageType)2, Localization.instance.Localize("$msg_offerdone"), 0, (Sprite)null);
			}
		}

		private static void ApplyInstantGrowthEffectOnNearbyPlants(PrivateArea ward, ItemData item, Player initiator, bool growableOnly = true)
		{
			List<Plant> plants = new List<Plant>();
			ProtectiveWards.ConnectedAreas(ward).ForEach(delegate(PrivateArea area)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				GetPlantsInRange(((Component)area).transform.position, area.m_radius, plants, growableOnly);
			});
			if (plants.Count == 0)
			{
				((Character)initiator).Message((MessageType)2, Localization.instance.Localize("$msg_cantoffer"), 0, (Sprite)null);
				return;
			}
			Inventory inventory = ((Humanoid)initiator).GetInventory();
			if (item.m_shared.m_name == "$item_eitr" && inventory.CountItems("$item_eitr", -1, true) < 5)
			{
				((Character)initiator).Message((MessageType)2, Localization.instance.Localize("$msg_incompleteoffering"), 0, (Sprite)null);
				return;
			}
			((MonoBehaviour)ward).StartCoroutine(InstantGrowthEffect(ward, plants));
			if (item.m_shared.m_name == "$item_eitr")
			{
				((Humanoid)initiator).GetInventory().RemoveItem("$item_eitr", 5, -1, true);
				ProtectiveWards.LogInfo("Offered " + item.m_shared.m_name + " x5");
			}
			else
			{
				((Humanoid)initiator).GetInventory().RemoveOneItem(item);
				ProtectiveWards.LogInfo("Offered " + item.m_shared.m_name);
			}
			((Character)initiator).Message((MessageType)2, Localization.instance.Localize("$msg_offerdone"), 0, (Sprite)null);
		}

		private static void ApplyModerPowerEffectToNearbyPlayers(PrivateArea ward, ItemData item, Player initiator)
		{
			ProtectiveWards.LogInfo("Dragon egg offered");
			List<Player> players = new List<Player>();
			ProtectiveWards.ConnectedAreas(ward).ForEach(delegate(PrivateArea area)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				Player.GetPlayersInRange(((Component)area).transform.position, area.m_radius, players);
			});
			foreach (Player item2 in players.Distinct().ToList())
			{
				int stableHashCode = StringExtensionMethods.GetStableHashCode("GP_Moder");
				StatusEffect statusEffect = ObjectDB.instance.GetStatusEffect(stableHashCode);
				((Character)item2).GetSEMan().AddStatusEffect(statusEffect.NameHash(), true, 0, 0f);
			}
			((Humanoid)initiator).GetInventory().RemoveOneItem(item);
		}

		private static void TaxiToLocation(ItemData item, Player initiator)
		{
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0279: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0412: Unknown result type (might be due to invalid IL or missing references)
			//IL_0413: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e7: Unknown result type (might be due to invalid IL or missing references)
			if (((Character)initiator).IsEncumbered())
			{
				((Character)initiator).Message((MessageType)2, Localization.instance.Localize("$se_encumbered_start"), 0, (Sprite)null);
				return;
			}
			if (!IsTeleportable(initiator))
			{
				((Character)initiator).Message((MessageType)2, Localization.instance.Localize("$msg_noteleport"), 0, (Sprite)null);
				return;
			}
			if (!ProtectiveWards.canTravel)
			{
				((Character)initiator).Message((MessageType)2, Localization.instance.Localize("$msg_cantoffer"), 0, (Sprite)null);
				return;
			}
			List<LocationInstance> list = new List<LocationInstance>();
			bool flag = false;
			LocationInstance val = default(LocationInstance);
			if (item.m_shared.m_name == "$item_coins")
			{
				if (!ZoneSystem.instance.FindLocations("Vendor_BlackForest", ref list))
				{
					return;
				}
				if (list.Count == 1)
				{
					val = list[0];
					ProtectiveWards.LogInfo("Found 1 location Vendor_BlackForest");
				}
				else
				{
					ZoneSystem.instance.FindClosestLocation("Vendor_BlackForest", ((Component)initiator).transform.position, ref val);
					flag = true;
					ProtectiveWards.LogInfo("Targeting closest location Vendor_BlackForest");
				}
			}
			else if (item.m_shared.m_name == "$item_trophy_eikthyr" || item.m_shared.m_name == "$item_trophy_elder" || item.m_shared.m_name == "$item_trophy_bonemass" || item.m_shared.m_name == "$item_trophy_dragonqueen" || item.m_shared.m_name == "$item_trophy_goblinking" || item.m_shared.m_name == "$item_trophy_seekerqueen")
			{
				if (!ZoneSystem.instance.FindClosestLocation("StartTemple", ((Component)initiator).transform.position, ref val))
				{
					return;
				}
			}
			else
			{
				if ((!(item.m_shared.m_name == "$item_goblintotem") && !(item.m_shared.m_name == "$item_chest_hildir1") && !(item.m_shared.m_name == "$item_chest_hildir2") && !(item.m_shared.m_name == "$item_chest_hildir3")) || !ZoneSystem.instance.FindLocations("Hildir_camp", ref list))
				{
					return;
				}
				if (list.Count == 1)
				{
					val = list[0];
					ProtectiveWards.LogInfo("Found 1 location Hildir_camp");
				}
				else
				{
					ZoneSystem.instance.FindClosestLocation("Hildir_camp", ((Component)initiator).transform.position, ref val);
					flag = true;
					ProtectiveWards.LogInfo("Targeting closest location Hildir_camp");
				}
			}
			if (Utils.DistanceXZ(((Component)initiator).transform.position, val.m_position) < 300f)
			{
				((Character)initiator).Message((MessageType)2, Localization.instance.Localize("$msg_wontwork"), 0, (Sprite)null);
				return;
			}
			if (item.m_shared.m_name == "$item_goblintotem" || item.m_shared.m_name == "$item_coins")
			{
				if (item.m_shared.m_name == "$item_goblintotem")
				{
					((Humanoid)initiator).GetInventory().RemoveOneItem(item);
				}
				else if (item.m_shared.m_name == "$item_coins")
				{
					int num = (flag ? 2000 : 500);
					if (((Humanoid)initiator).GetInventory().CountItems("$item_coins", -1, true) < num)
					{
						((Character)initiator).Message((MessageType)2, Localization.instance.Localize("$msg_incompleteoffering"), 0, (Sprite)null);
						((Character)Player.m_localPlayer).SetLookDir(val.m_position - ((Component)initiator).transform.position, 3.5f);
						return;
					}
					((Humanoid)initiator).GetInventory().RemoveItem("$item_coins", num, -1, true);
				}
			}
			((MonoBehaviour)initiator).StartCoroutine(TaxiToPosition(initiator, val.m_position, returnBack: true, 10));
		}

		public static bool IsTeleportable(Player player)
		{
			if (((Humanoid)player).IsTeleportable())
			{
				return true;
			}
			foreach (ItemData item in ((Humanoid)player).GetInventory().m_inventory)
			{
				if (item.m_shared.m_name == "$item_chest_hildir1" || item.m_shared.m_name == "$item_chest_hildir2" || item.m_shared.m_name == "$item_chest_hildir3" || item.m_shared.m_teleportable)
				{
					continue;
				}
				return false;
			}
			return true;
		}

		private static IEnumerator TaxiToPosition(Player player, Vector3 position, bool returnBack = false, int waitSeconds = 0)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			ProtectiveWards.canTravel = false;
			ProtectiveWards.isTravelingPlayer = player;
			if (waitSeconds > 0)
			{
				for (int i = waitSeconds; i > 0; i--)
				{
					((Character)player).Message((MessageType)2, Localization.instance.Localize("$npc_dvergrmage_random_goodbye5") + " " + TimeSpan.FromSeconds(i).ToString("m\\:ss"), 0, (Sprite)null);
					yield return (object)new WaitForSeconds(1f);
				}
			}
			DateTime flightInitiated = DateTime.Now;
			if ((Object)(object)Valkyrie.m_instance == (Object)null)
			{
				bool playerShouldExit = ((Character)player).IsAttachedToShip() || ((Character)player).IsAttached() || ((Character)player).IsDead() || ((Character)player).IsRiding() || player.IsSleeping() || ((Character)player).IsTeleporting() || ((Character)player).InPlaceMode() || ((Character)player).InBed() || ((Character)player).InCutscene() || ((Character)player).InInterior();
				while (playerShouldExit || ((Character)player).IsEncumbered() || !((Humanoid)player).IsTeleportable())
				{
					string timeSpent = (DateTime.Now - flightInitiated).ToString("m\\:ss");
					if (playerShouldExit)
					{
						((Character)player).Message((MessageType)1, Localization.instance.Localize("$location_exit") + " " + timeSpent, 0, (Sprite)null);
					}
					else
					{
						((Character)player).Message((MessageType)2, Localization.instance.Localize(((Character)player).IsEncumbered() ? "$se_encumbered_start" : "$msg_noteleport") + " " + timeSpent, 0, (Sprite)null);
					}
					yield return (object)new WaitForSeconds(1f);
					playerShouldExit = ((Character)player).IsAttachedToShip() || ((Character)player).IsAttached() || ((Character)player).IsDead() || ((Character)player).IsRiding() || player.IsSleeping() || ((Character)player).IsTeleporting() || ((Character)player).InPlaceMode() || ((Character)player).InBed() || ((Character)player).InCutscene() || ((Character)player).InInterior();
				}
				((Character)player).Message((MessageType)2, Localization.instance.Localize("$npc_dvergrmage_random_goodbye5"), 0, (Sprite)null);
				ProtectiveWards.taxiTargetPosition = position;
				ProtectiveWards.taxiReturnBack = returnBack;
				ProtectiveWards.taxiPlayerPositionToReturn = ((Component)player).transform.position;
				ProtectiveWards.playerDropped = false;
				GameObject prefab = ZNetScene.instance.GetPrefab("Valkyrie");
				Object.Instantiate<GameObject>(prefab, ((Component)player).transform.position, Quaternion.identity);
			}
			ProtectiveWards.canTravel = true;
		}
	}
	[BepInPlugin("shudnal.ProtectiveWards", "Protective Wards", "1.1.13")]
	public class ProtectiveWards : BaseUnityPlugin
	{
		public enum ShipDamageType
		{
			Off,
			WaterDamage,
			AnyButPlayerDamage,
			AnyDamage
		}

		[HarmonyPatch(typeof(Door), "Interact")]
		public static class Door_SetState_AutoClose
		{
			public static void Postfix(Door __instance, ZNetView ___m_nview, bool __result)
			{
				//IL_0058: Unknown result type (might be due to invalid IL or missing references)
				if (!modEnabled.Value || 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;
					LogInfo(value.Count);
					if (wardIsClosing.ContainsKey(area))
					{
						wardIsClosing[area] = Math.Max(autoCloseDoorsTime.Value, 2);
						LogInfo($"Doors closing reset to {wardIsClosing[area]} seconds");
					}
					else
					{
						wardIsClosing[area] = Math.Max(autoCloseDoorsTime.Value, 2);
						((MonoBehaviour)area).StartCoroutine(AutoClosingDoors(area));
						LogInfo("Doors closing started");
					}
				}
			}
		}

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

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

		[HarmonyPatch(typeof(PrivateArea), "AddUserList")]
		public static class PrivateArea_AddUserList_WardAltActionCaption
		{
			public static void Postfix(PrivateArea __instance, ref StringBuilder text)
			{
				if (!modEnabled.Value || !__instance.IsEnabled())
				{
					return;
				}
				string[] array = text.ToString().Split(new char[1] { '\n' }, StringSplitOptions.None);
				int num = 0;
				string[] array2 = array;
				foreach (string text2 in array2)
				{
					num += text2.Length;
					if (text2.Contains("$KEY_Use"))
					{
						break;
					}
					num++;
				}
				List<string> list = new List<string>();
				if (wardIsRepairing.TryGetValue(__instance, out var value))
				{
					list.Add($"$hud_repair {value}");
				}
				else if (num < text.Length && wardPassiveRepair.Value)
				{
					string text3 = "$menu_start " + Localization.instance.Localize("$piece_repair").ToLower();
					if (!ZInput.IsNonClassicFunctionality() || !ZInput.IsGamepadActive())
					{
						text.Insert(num, "\n[<color=yellow><b>$KEY_AltPlace + $KEY_Use</b></color>] " + text3);
					}
					else
					{
						text.Insert(num, "\n[<color=yellow><b>$KEY_JoyAltKeys + $KEY_Use</b></color>] " + text3);
					}
				}
				if (wardIsHealing.TryGetValue(__instance, out var value2))
				{
					list.Add("$item_food_regen " + TimeSpan.FromSeconds(value2).ToString("m\\:ss"));
				}
				if (list.Count > 0)
				{
					text.Append("\n$guardianstone_hook_power_activate: ");
					text.Append(string.Join(", ", list.ToArray()));
				}
				if (!showOfferingsInHover.Value)
				{
					return;
				}
				List<string> list2 = new List<string>();
				if (offeringActiveRepair.Value && Player.m_localPlayer.IsMaterialKnown("$item_surtlingcore"))
				{
					list2.Add("$item_surtlingcore");
				}
				if (offeringAugmenting.Value && Player.m_localPlayer.IsMaterialKnown("$item_blackcore"))
				{
					list2.Add("$item_blackcore");
				}
				if (offeringFood.Value)
				{
					list2.Add("$item_food");
				}
				if (offeringMead.Value)
				{
					list2.Add("$se_mead_name");
				}
				if (offeringThundertone.Value && Player.m_localPlayer.IsMaterialKnown("$item_thunderstone"))
				{
					list2.Add("$item_thunderstone");
				}
				if (offeringTrophy.Value)
				{
					list2.Add("$inventory_trophies");
				}
				if (offeringYmirRemains.Value && Player.m_localPlayer.IsMaterialKnown("$item_ymirremains"))
				{
					list2.Add("$item_ymirremains");
				}
				if (offeringEitr.Value && Player.m_localPlayer.IsMaterialKnown("$item_eitr"))
				{
					list2.Add("$item_eitr");
				}
				if (offeringDragonEgg.Value && Player.m_localPlayer.IsMaterialKnown("$item_dragonegg") && ZoneSystem.instance.GetGlobalKey((GlobalKeys)33))
				{
					list2.Add("$item_dragonegg");
				}
				if (offeringTaxi.Value)
				{
					if (Player.m_localPlayer.IsMaterialKnown("$item_coins"))
					{
						list2.Add("$item_coins");
					}
					if (Player.m_localPlayer.IsMaterialKnown("$item_goblintotem"))
					{
						list2.Add("$item_goblintotem");
					}
					if (Player.m_localPlayer.IsMaterialKnown("$item_chest_hildir1"))
					{
						list2.Add("$piece_chestwood");
					}
					else if (Player.m_localPlayer.IsMaterialKnown("$item_chest_hildir2"))
					{
						list2.Add("$piece_chestwood");
					}
					else if (Player.m_localPlayer.IsMaterialKnown("$item_chest_hildir3"))
					{
						list2.Add("$piece_chestwood");
					}
				}
				if (list2.Count > 0)
				{
					text.Append("\n\n$piece_offerbowl_offeritem: ");
					text.Append(string.Join(", ", list2.ToArray()));
				}
			}
		}

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

		[HarmonyPatch(typeof(PrivateArea), "Interact")]
		public static class PrivateArea_Interact_PassiveEffectWardRepair
		{
			private static bool Prefix(PrivateArea __instance, Humanoid human, bool hold, bool alt, Faction ___m_ownerFaction)
			{
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_005d: Invalid comparison between Unknown and I4
				if (!modEnabled.Value)
				{
					return true;
				}
				if (!alt)
				{
					areaCache.Clear();
				}
				if (!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;
				}
				LogInfo("Passive repairing begins");
				((MonoBehaviour)instance).StartCoroutine(PassiveRepairEffect(__instance, (Player)(object)((human is Player) ? human : null)));
				return false;
			}

			private static void Postfix(PrivateArea __instance)
			{
				if (modEnabled.Value && setWardRange.Value)
				{
					if (__instance.m_radius != wardRange.Value)
					{
						SetWardRange(__instance);
					}
					SetWardPlayerBase(__instance);
				}
			}
		}

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

			private static void Postfix(PrivateArea __instance, ZNetView ___m_nview)
			{
				if (!modEnabled.Value)
				{
					return;
				}
				if (setWardRange.Value)
				{
					SetWardRange(__instance);
					SetWardPlayerBase(__instance);
				}
				if (showAreaMarker.Value)
				{
					((Component)__instance.m_areaMarker).gameObject.SetActive(true);
				}
				if (!((Object)(object)___m_nview == (Object)null) && ___m_nview.IsValid())
				{
					if ((Object)(object)forceField != (Object)null)
					{
						GameObject val = Object.Instantiate<GameObject>(forceField, ((Component)__instance).transform);
						((Object)val).name = "ForceField";
						InitBubbleState(__instance, val, ___m_nview);
					}
					if ((Object)(object)forceFieldDemister != (Object)null)
					{
						GameObject val2 = Object.Instantiate<GameObject>(forceFieldDemister, ((Component)__instance).transform);
						((Object)val2).name = "Particle System Force Field";
						InitDemisterState(__instance, val2, ___m_nview);
					}
				}
			}
		}

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

		[HarmonyPatch(typeof(ZoneSystem), "Start")]
		public static class ZoneSystem_Start_InitWardBubble
		{
			private static void Postfix(ZoneSystem __instance)
			{
				//IL_004c: 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_00ae: Expected O, but got Unknown
				ZoneLocation val = __instance.m_locations.Find((ZoneLocation loc) => loc.m_prefabName == "Vendor_BlackForest");
				if (val != null && val.m_prefab.IsValid)
				{
					val.m_prefab.Load();
					Transform obj = val.m_prefab.Asset.transform.Find("ForceField");
					forceField = Object.Instantiate<GameObject>((obj != null) ? ((Component)obj).gameObject : null);
					((Object)forceField).name = "ProtectiveWards_bubble";
					MeshRenderer component = forceField.GetComponent<MeshRenderer>();
					((Renderer)component).sharedMaterial = new Material(((Renderer)component).sharedMaterial);
					val.m_prefab.Release();
				}
			}
		}

		[HarmonyPatch(typeof(ZNetScene), "Awake")]
		internal static class ZNetScene_Awake_DemisterForceField
		{
			private static void Postfix(ZNetScene __instance)
			{
				GameObject prefab = __instance.GetPrefab("Demister");
				object forceFieldDemister;
				if (prefab == null)
				{
					forceFieldDemister = null;
				}
				else
				{
					Transform obj = prefab.transform.Find("Particle System Force Field");
					forceFieldDemister = ((obj != null) ? ((Component)obj).gameObject : null);
				}
				ProtectiveWards.forceFieldDemister = (GameObject)forceFieldDemister;
			}
		}

		[HarmonyPatch(typeof(PrivateArea), "RPC_ToggleEnabled")]
		public static class PrivateArea_RPC_ToggleEnabled_InitWardBubble
		{
			private static void Postfix(PrivateArea __instance, ZNetView ___m_nview, Piece ___m_piece)
			{
				//IL_0070: Unknown result type (might be due to invalid IL or missing references)
				//IL_007f: Unknown result type (might be due to invalid IL or missing references)
				//IL_008e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0098: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
				ZDO zDO = ___m_nview.GetZDO();
				if (zDO != null)
				{
					if (___m_piece.IsCreator())
					{
						zDO.Set(s_bubbleEnabled, wardBubbleShow.Value);
						zDO.Set(s_bubbleRefractionIntensity, wardBubbleRefractionIntensity.Value);
						zDO.Set(s_bubbleWaveVel, wardBubbleWaveIntensity.Value);
						zDO.Set(s_bubbleColor, new Vector3(wardBubbleColor.Value.r, wardBubbleColor.Value.g, wardBubbleColor.Value.b));
						zDO.Set(s_bubbleColorAlpha, wardBubbleColor.Value.a);
					}
					Transform obj = ((Component)__instance).transform.Find("ForceField");
					InitBubbleState(__instance, (obj != null) ? ((Component)obj).gameObject : null, ___m_nview);
					Transform obj2 = ((Component)__instance).transform.Find("Particle System Force Field");
					InitDemisterState(__instance, (obj2 != null) ? ((Component)obj2).gameObject : null, ___m_nview);
				}
			}
		}

		private const string pluginID = "shudnal.ProtectiveWards";

		private const string pluginName = "Protective Wards";

		private const string pluginVersion = "1.1.13";

		private Harmony _harmony;

		internal static readonly ConfigSync configSync = new ConfigSync("shudnal.ProtectiveWards")
		{
			DisplayName = "Protective Wards",
			CurrentVersion = "1.1.13",
			MinimumRequiredVersion = "1.1.13"
		};

		public static ConfigEntry<bool> modEnabled;

		public static ConfigEntry<bool> configLocked;

		public static ConfigEntry<bool> disableFlash;

		public static ConfigEntry<bool> showAreaMarker;

		public static ConfigEntry<bool> loggingEnabled;

		public static ConfigEntry<int> refreshingTime;

		public static ConfigEntry<bool> showOfferingsInHover;

		public static ConfigEntry<float> maxTaxiSpeed;

		public static ConfigEntry<bool> offeringActiveRepair;

		public static ConfigEntry<bool> offeringAugmenting;

		public static ConfigEntry<bool> offeringFood;

		public static ConfigEntry<bool> offeringMead;

		public static ConfigEntry<bool> offeringThundertone;

		public static ConfigEntry<bool> offeringTrophy;

		public static ConfigEntry<bool> offeringYmirRemains;

		public static ConfigEntry<bool> offeringEitr;

		public static ConfigEntry<bool> offeringDragonEgg;

		public static ConfigEntry<bool> offeringTaxi;

		public static ConfigEntry<bool> wardPassiveRepair;

		public static ConfigEntry<int> autoCloseDoorsTime;

		public static ConfigEntry<bool> setWardRange;

		public static ConfigEntry<float> wardRange;

		public static ConfigEntry<bool> supressSpawnInRange;

		public static ConfigEntry<bool> permitEveryone;

		public static ConfigEntry<float> playerDamageDealtMultiplier;

		public static ConfigEntry<float> playerDamageTakenMultiplier;

		public static ConfigEntry<float> tamedDamageTakenMultiplier;

		public static ConfigEntry<float> structureDamageTakenMultiplier;

		public static ConfigEntry<float> fallDamageTakenMultiplier;

		public static ConfigEntry<float> turretFireRateMultiplier;

		public static ConfigEntry<float> foodDrainMultiplier;

		public static ConfigEntry<float> staminaDrainMultiplier;

		public static ConfigEntry<float> skillsDrainMultiplier;

		public static ConfigEntry<float> fireplaceDrainMultiplier;

		public static ConfigEntry<float> hammerDurabilityDrainMultiplier;

		public static ConfigEntry<float> smeltingSpeedMultiplier;

		public static ConfigEntry<float> cookingSpeedMultiplier;

		public static ConfigEntry<float> fermentingSpeedMultiplier;

		public static ConfigEntry<float> sapCollectingSpeedMultiplier;

		public static ConfigEntry<bool> wardBubbleShow;

		public static ConfigEntry<Color> wardBubbleColor;

		public static ConfigEntry<float> wardBubbleRefractionIntensity;

		public static ConfigEntry<float> wardBubbleWaveIntensity;

		public static ConfigEntry<bool> wardDemisterEnabled;

		public static ConfigEntry<bool> boarsHensProtection;

		public static ConfigEntry<bool> wardRainProtection;

		public static ConfigEntry<ShipDamageType> wardShipProtection;

		public static ConfigEntry<bool> wardPlantProtection;

		public static ConfigEntry<bool> fireplaceProtection;

		public static ConfigEntry<bool> sittingRaidProtection;

		public static ConfigEntry<bool> wardTrapProtection;

		public static ConfigEntry<string> wardPlantProtectionList;

		public static ConfigEntry<string> boarsHensProtectionGroupList;

		internal static ProtectiveWards instance;

		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 GameObject lightningAOE;

		internal static EffectList preLightning;

		internal static List<TrophyTarget> trophyTargets;

		internal static int baseValueProtected = 999;

		internal static GameObject forceField;

		internal const string forceFieldName = "ForceField";

		internal static GameObject forceFieldDemister;

		internal const string forceFieldDemisterName = "Particle System Force Field";

		internal static bool taxiReturnBack = false;

		internal static Vector3 taxiPlayerPositionToReturn;

		internal static Vector3 taxiTargetPosition;

		internal static bool canTravel = true;

		internal static Player isTravelingPlayer;

		internal static bool playerDropped = false;

		internal static bool castSlowFall;

		internal static HashSet<string> _wardPlantProtectionList;

		internal static HashSet<string> _boarsHensProtectionGroupList;

		public static readonly int s_bubbleEnabled = StringExtensionMethods.GetStableHashCode("bubble_enabled");

		public static readonly int s_bubbleColor = StringExtensionMethods.GetStableHashCode("bubble_color");

		public static readonly int s_bubbleColorAlpha = StringExtensionMethods.GetStableHashCode("bubble_color_alpha");

		public static readonly int s_bubbleWaveVel = StringExtensionMethods.GetStableHashCode("bubble_wave");

		public static readonly int s_bubbleRefractionIntensity = StringExtensionMethods.GetStableHashCode("bubble_refraction");

		private static readonly MaterialPropertyBlock s_matBlock = new MaterialPropertyBlock();

		private void Awake()
		{
			_harmony = Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), "shudnal.ProtectiveWards");
			instance = this;
			ConfigInit();
			configSync.AddLockingConfigEntry<bool>(configLocked);
		}

		private void OnDestroy()
		{
			((BaseUnityPlugin)this).Config.Save();
			Harmony harmony = _harmony;
			if (harmony != null)
			{
				harmony.UnpatchSelf();
			}
		}

		public static void LogInfo(object data)
		{
			if (loggingEnabled.Value)
			{
				((BaseUnityPlugin)instance).Logger.LogInfo(data);
			}
		}

		private void ConfigInit()
		{
			//IL_04cd: Unknown result type (might be due to invalid IL or missing references)
			config("General", "NexusID", 2450, "Nexus mod ID for updates", synchronizedSetting: false);
			modEnabled = config("General", "Enabled", defaultValue: true, "Enable the mod. Every option requires being in the zone of the active Ward.");
			configLocked = config("General", "Lock Configuration", defaultValue: true, "Configuration is locked and can be changed by server admins only.");
			disableFlash = config("Misc", "Disable flash", defaultValue: false, "Disable flash on hit [Not Synced with Server]", synchronizedSetting: false);
			showAreaMarker = config("Misc", "Always show radius", defaultValue: false, "Always show ward radius. Hover the ward for changes to take effect. [Not Synced with Server]", synchronizedSetting: false);
			refreshingTime = config("Misc", "Ward protected status check time", 30, "Set how many seconds the \"inside the protected zone\" status is reset. [Not Synced with Server]\nSetting more seconds can be helpful for fps for base with many objects and static untoggled wards. \nDoesn't affect moving objects.", synchronizedSetting: false);
			loggingEnabled = config("Misc", "Enable logging", defaultValue: false, "Enable logging for ward events. [Not Synced with Server]", synchronizedSetting: false);
			showOfferingsInHover = config("Misc", "Show offerings in hover", defaultValue: true, "Show offerings list in hover text. [Not Synced with Server]", synchronizedSetting: false);
			maxTaxiSpeed = config("Misc", "Maximum taxi speed", 30f, "Reduce maximum taxi speed if it is laggy. [Not Synced with Server]", synchronizedSetting: false);
			playerDamageDealtMultiplier = config("Modifiers damage", "Creatures damage taken multiplier", 1f, "Basically it means damage dealt by any creatures (players and tames included) to any creatures (players and tames excluded)");
			playerDamageTakenMultiplier = config("Modifiers damage", "Player damage taken multiplier", 1f, "Damage taken by players from creatures");
			fallDamageTakenMultiplier = config("Modifiers damage", "Player fall damage taken multiplier", 1f, "Player fall damage taken");
			structureDamageTakenMultiplier = config("Modifiers damage", "Structure damage taken multiplier", 1f, "Structures (and ships) damage taken");
			tamedDamageTakenMultiplier = config("Modifiers damage", "Tamed damage taken multiplier", 1f, "Damage taken by tamed from creatures (players included)");
			turretFireRateMultiplier = config("Modifiers damage", "Turret fire rate multiplier", 1f, "Basically time between shots");
			foodDrainMultiplier = config("Modifiers drain", "Food drain multiplier", 1f, "Speed of food drain, more - faster, less - slower");
			staminaDrainMultiplier = config("Modifiers drain", "Stamina drain multiplier", 1f, "Multiplier of stamina needed for actions");
			skillsDrainMultiplier = config("Modifiers drain", "Skills drain on death multiplier", 1f, "Multiplier of how much skill points you lose on death. Accumulated scale will be lost anyway");
			fireplaceDrainMultiplier = config("Modifiers drain", "Fireplace fuel drain multiplier", 1f, "Speed of fuel spent for fireplaces (including bathtub, torches and braziers)");
			hammerDurabilityDrainMultiplier = config("Modifiers drain", "Hammer durability drain multiplier", 1f, "Multiplier of how much hammer's durability will be spent on building and repairing");
			smeltingSpeedMultiplier = config("Modifiers speed", "Smelting speed multiplier", 1f, "Speed of smelting for all smelting stations (excluding bathtub)");
			cookingSpeedMultiplier = config("Modifiers speed", "Cooking speed multiplier", 1f, "Speed of cooking for all cooking stations (that also means faster burn)");
			fermentingSpeedMultiplier = config("Modifiers speed", "Fermenting speed multiplier", 1f, "Speed of fermenting");
			sapCollectingSpeedMultiplier = config("Modifiers speed", "Sap collecting speed multiplier", 1f, "Speed of sap collecting");
			offeringActiveRepair = config("Offerings", "1 - Repair all pieces by surtling core offering", defaultValue: true, "Offer surtling core to ward to instantly repair all pieces in all connected areas\nCore will NOT be wasted if there is no piece to repair");
			offeringAugmenting = config("Offerings", "2 - Augment all pieces by black core offering", defaultValue: true, "Offer black core to ward to double the health of every structural piece in all connected areas\nCore will NOT be wasted if there is no piece to repair");
			offeringFood = config("Offerings", "3 - Heal all allies for 3 min by food offering", defaultValue: true, "Offer food to ward to activate healing for 3 minutes in all connected areas. Better food means better heal.\nYou can offer one food to one ward until 3 minutes are gone. But nothing stops you from offering food to several wards.");
			offeringMead = config("Offerings", "4 - Share mead effect to all players by mead offering", defaultValue: true, "Offer mead to ward to share the effect to all players in all connected areas. \nMead will NOT be wasted if no one can have effect.");
			offeringThundertone = config("Offerings", "5 - Call the wrath of the Thor upon your enemies by thunderstone offering", defaultValue: true, "Offer thunderstone to ward to call the Thor's wrath upon your enemies in all connected areas\nThunderstone WILL be wasted even if no one gets hurt");
			offeringTrophy = config("Offerings", "6 - Kill all enemies of the same type by trophy offering", defaultValue: true, "Offer trophy to ward to kill all enemies with type of the offered trophy in all connected areas\nTrophy will NOT be wasted if no one gets hurt");
			offeringYmirRemains = config("Offerings", "7 - Grow all plants by Ymir flesh offering", defaultValue: true, "Offer Ymir flesh to instantly grow every plant in all connected areas\nYmir flesh will NOT be wasted if there is no plant to grow");
			offeringEitr = config("Offerings", "8 - Grow all plants regardless the requirements by Eitr x5 offering", defaultValue: true, "Offer 5 Eitr to instantly grow every plant regardless the requirements in all connected areas\nEitr will NOT be wasted if there is no plant to grow");
			offeringDragonEgg = config("Offerings", "9 - Activate Moder power by dragon egg offering", defaultValue: true, "Offer dragon egg to activate Moder power on all players in all connected areas.");
			offeringTaxi = config("Offerings", "10 - Fly back and forth to distant point by different items offering", defaultValue: true, "Offer boss trophy to travel to start temple (initial spawn point). Boss trophy will NOT be consumed.\nOffer coins to travel to Haldor (x2000 if you didn't find him yet. x500 otherwise). Coins will be consumed.\nOffer Hildir's chest to travel to Hildir for free. Chest will NOT be consumed. Totem WILL be consumed.\nOffer Fuling totem to travel to Hildir. Totem WILL be consumed.");
			wardPassiveRepair = config("Passive", "Activatable passive repair", defaultValue: true, "Interact with a ward to start passive repair process of all pieces in all connected areas\nWard will repair one piece every 10 seconds until all pieces are healthy. Then the process will stop.");
			autoCloseDoorsTime = config("Passive", "Auto close doors after", 0, "Automatically close doors after a specified number of seconds. 0 to disable. 5 recommended");
			setWardRange = config("Range", "Change Ward range", defaultValue: false, "Change ward range.");
			wardRange = config("Range", "Ward range", 10f, "Ward range. Toggle ward protection for changes to take effect");
			supressSpawnInRange = config("Range", "Supress spawn in ward area", defaultValue: true, "Vanilla behavior is true. Set false if you want creatures and raids spawn in ward radius. Toggle ward protection for changes to take effect");
			permitEveryone = config("Range", "Grant permittance to everyone", defaultValue: false, "Grant permittance to every player. There still will be permittance list on ward but it won't take any effect.");
			wardBubbleShow = config("Ward Bubble", "Show bubble", defaultValue: false, "Show ward bubble like trader's one [Not Synced with Server]", synchronizedSetting: false);
			wardBubbleColor = config<Color>("Ward Bubble", "Bubble color", Color.black, "Bubble color. Toggle ward protection to change color [Not Synced with Server]", synchronizedSetting: false);
			wardBubbleRefractionIntensity = config("Ward Bubble", "Refraction intensity", 0.005f, "Intensity of light refraction caused by bubble. Toggle ward protection for changes to take effect [Not Synced with Server]", synchronizedSetting: false);
			wardBubbleWaveIntensity = config("Ward Bubble", "Wave intensity", 40f, "Bubble light distortion speed. Toggle ward protection for changes to take effect [Not Synced with Server]", synchronizedSetting: false);
			wardDemisterEnabled = config("Ward Demister", "Enable demister", defaultValue: false, "Ward will push out the mist");
			boarsHensProtection = config("Ward protects", "Boars and hens from damage", defaultValue: true, "Set whether an active Ward will protect nearby boars and hens from taken damage (players excluded)");
			wardRainProtection = config("Ward protects", "Structures from rain damage", defaultValue: true, "Set whether an active Ward will protect nearby structures from rain and water damage");
			wardShipProtection = config("Ward protects", "Ship from damage", ShipDamageType.WaterDamage, "Set whether an active Ward will protect nearby ships from damage (waves and upsidedown for water damage option or any structural damage)");
			wardPlantProtection = config("Ward protects", "Plants from any damage", defaultValue: true, "Set whether an active Ward will protect nearby plants from taking damage");
			fireplaceProtection = config("Ward protects", "Fireplace from step damage", defaultValue: true, "Set whether an active Ward will protect nearby fire sources from taking damage from stepping on them");
			wardTrapProtection = config("Ward protects", "Players from their traps", defaultValue: true, "Set whether an active Ward will protect players from stepping on traps");
			sittingRaidProtection = config("Ward protects", "Players from raids when sitting on something near the fire (not floor)", defaultValue: true, "Set whether an active Ward will protect nearby players from raids when sitting next to an active fire\nDo you want to go AFK in your base? Find a warm chair, bench, stool, throne whatever to sit on and go\nIf the fire does not burn - you are vulnerable");
			wardPlantProtectionList = config("Ward protects", "Plants from list", "$item_carrot, $item_turnip, $item_onion, $item_carrotseeds, $item_turnipseeds, $item_onionseeds, $item_jotunpuffs, $item_magecap", "List of plants to be protected from damage");
			boarsHensProtectionGroupList = config("Ward protects", "Boars and hens from list", "boar, chicken", "List of tamed groups to be protected from damage");
			wardPlantProtectionList.SettingChanged += delegate
			{
				FillWardProtectionLists();
			};
			boarsHensProtectionGroupList.SettingChanged += delegate
			{
				FillWardProtectionLists();
			};
			FillWardProtectionLists();
		}

		private ConfigEntry<T> config<T>(string group, string name, T defaultValue, ConfigDescription description, bool synchronizedSetting = true)
		{
			ConfigEntry<T> val = ((BaseUnityPlugin)this).Config.Bind<T>(group, name, defaultValue, description);
			SyncedConfigEntry<T> syncedConfigEntry = configSync.AddConfigEntry<T>(val);
			syncedConfigEntry.SynchronizedConfig = synchronizedSetting;
			return val;
		}

		private ConfigEntry<T> config<T>(string group, string name, T defaultValue, string description, bool synchronizedSetting = true)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			return config(group, name, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()), synchronizedSetting);
		}

		public static bool InsideEnabledPlayersArea(Vector3 point)
		{
			//IL_0001: 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 == 0)
			{
				startTimeCached = time.Ticks;
			}
			if ((time - new DateTime(startTimeCached)).TotalSeconds > (double)refreshingTime.Value)
			{
				areaCache.Clear();
				startTimeCached = time.Ticks;
			}
		}

		public static bool InsideEnabledPlayersArea(Vector3 point, out PrivateArea area)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			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 ApplyRangeEffect(Component parent, Type includedTypes, float newRadius)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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;
				}
			}
		}

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

		private static void SetWardPlayerBase(PrivateArea __instance)
		{
			//IL_005b: 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(wardRange.Value, 1f));
				if (supressSpawnInRange.Value)
				{
					num = 1f;
				}
				val.localScale = new Vector3(num, num, num);
			}
		}

		private static void FillWardProtectionLists()
		{
			_wardPlantProtectionList = new HashSet<string>((from p in wardPlantProtectionList.Value.Split(new char[1] { ',' })
				select p.Trim().ToLower() into p
				where !string.IsNullOrWhiteSpace(p)
				select p).ToList());
			_boarsHensProtectionGroupList = new HashSet<string>((from p in boarsHensProtectionGroupList.Value.Split(new char[1] { ',' })
				select p.Trim().ToLower() into p
				where !string.IsNullOrWhiteSpace(p)
				select p).ToList());
		}

		public static IEnumerator PassiveRepairEffect(PrivateArea ward, Player initiator)
		{
			WearNTear val = default(WearNTear);
			WearNTear WNT = 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> piecesToRepair = (from piece in pieces.Distinct().ToList()
					where piece.IsPlacedByPlayer() && ((Component)piece).TryGetComponent<WearNTear>(ref val) && val.GetHealthPercentage() < 1f
					select piece).ToList();
				if (piecesToRepair.Count == 0)
				{
					break;
				}
				wardIsRepairing[ward] = piecesToRepair.Count;
				foreach (Piece piece2 in piecesToRepair)
				{
					if (((Component)piece2).TryGetComponent<WearNTear>(ref WNT) && WNT.Repair())
					{
						piece2.m_placeEffect.Create(((Component)piece2).transform.position, ((Component)piece2).transform.rotation, (Transform)null, 1f, -1);
						wardIsRepairing.TryGetValue(ward, out var toRepair);
						wardIsRepairing[ward] = Math.Max(toRepair - 1, 0);
						if (initiator != null)
						{
							((Character)initiator).Message((MessageType)1, Localization.instance.Localize("$piece_repair"), 0, (Sprite)null);
						}
						break;
					}
					WNT = null;
				}
				yield return (object)new WaitForSecondsRealtime(10f);
			}
			LogInfo("Passive repairing stopped");
			wardIsRepairing.Remove(ward);
			if ((Object)(object)initiator != (Object)null)
			{
				string str = Localization.instance.Localize("$msg_doesnotneedrepair");
				((Character)initiator).Message((MessageType)1, char.ToUpper(str[0]) + str.Substring(1), 0, (Sprite)null);
			}
		}

		public static IEnumerator AutoClosingDoors(PrivateArea ward)
		{
			List<Door> doors;
			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 secondsToClose) || !doorsToClose.TryGetValue(ward, out doors))
				{
					yield break;
				}
				if (secondsToClose <= 0)
				{
					break;
				}
				wardIsClosing[ward]--;
				yield return (object)new WaitForSeconds(1f);
				doors = null;
			}
			if (doors.Count > 0)
			{
				LogInfo($"Closed {doors.Count} doors");
				doors.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);
			LogInfo("Doors closing stopped");
		}

		public 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 void InitBubbleState(PrivateArea ward, GameObject bubble, ZNetView m_nview)
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)bubble == (Object)null)
			{
				return;
			}
			ZDO zDO = m_nview.GetZDO();
			if (zDO == null)
			{
				bubble.SetActive(false);
				return;
			}
			bubble.SetActive(zDO.GetBool(s_bubbleEnabled, wardBubbleShow.Value) && ward.IsEnabled());
			bubble.transform.localScale = Vector3.one * wardRange.Value * 2f;
			Transform val = bubble.transform.Find("NoMonsterArea");
			if ((Object)(object)val != (Object)null)
			{
				Object.Destroy((Object)(object)((Component)val).gameObject);
			}
			MeshRenderer component = bubble.GetComponent<MeshRenderer>();
			Vector3 vec = zDO.GetVec3(s_bubbleColor, new Vector3(wardBubbleColor.Value.r, wardBubbleColor.Value.g, wardBubbleColor.Value.b));
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(vec.x, vec.y, vec.z, zDO.GetFloat(s_bubbleColorAlpha, 0f));
			s_matBlock.Clear();
			s_matBlock.SetColor("_Color", val2);
			s_matBlock.SetFloat("_RefractionIntensity", zDO.GetFloat(s_bubbleRefractionIntensity, wardBubbleRefractionIntensity.Value));
			s_matBlock.SetFloat("_WaveVel", zDO.GetFloat(s_bubbleWaveVel, wardBubbleWaveIntensity.Value));
			((Renderer)component).SetPropertyBlock(s_matBlock);
		}

		public static void InitDemisterState(PrivateArea ward, GameObject demister, ZNetView m_nview)
		{
			if (!((Object)(object)demister == (Object)null))
			{
				ZDO zDO = m_nview.GetZDO();
				if (zDO == null)
				{
					demister.SetActive(false);
					return;
				}
				demister.SetActive(wardDemisterEnabled.Value && ward.IsEnabled());
				demister.GetComponent<ParticleSystemForceField>().endRange = wardRange.Value;
			}
		}
	}
}
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	[CompilerGenerated]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ServerSync
{
	[PublicAPI]
	internal abstract class OwnConfigEntryBase
	{
		public object? LocalBaseValue;

		public bool SynchronizedConfig = true;

		public abstract ConfigEntryBase BaseConfig { get; }
	}
	[PublicAPI]
	internal class SyncedConfigEntry<T> : OwnConfigEntryBase
	{
		public readonly ConfigEntry<T> SourceConfig;

		public override ConfigEntryBase BaseConfig => (ConfigEntryBase)(object)SourceConfig;

		public T Value
		{
			get
			{
				return SourceConfig.Value;
			}
			set
			{
				SourceConfig.Value = value;
			}
		}

		public SyncedConfigEntry(ConfigEntry<T> sourceConfig)
		{
			SourceConfig = sourceConfig;
		}

		public void AssignLocalValue(T value)
		{
			if (LocalBaseValue == null)
			{
				Value = value;
			}
			else
			{
				LocalBaseValue = value;
			}
		}
	}
	internal abstract class CustomSyncedValueBase
	{
		public object? LocalBaseValue;

		public readonly string Identifier;

		public readonly Type Type;

		private object? boxedValue;

		protected bool localIsOwner;

		public readonly int Priority;

		public object? BoxedValue
		{
			get
			{
				return boxedValue;
			}
			set
			{
				boxedValue = value;
				this.ValueChanged?.Invoke();
			}
		}

		public event Action? ValueChanged;

		protected CustomSyncedValueBase(ConfigSync configSync, string identifier, Type type, int priority)
		{
			Priority = priority;
			Identifier = identifier;
			Type = type;
			configSync.AddCustomValue(this);
			localIsOwner = configSync.IsSourceOfTruth;
			configSync.SourceOfTruthChanged += delegate(bool truth)
			{
				localIsOwner = truth;
			};
		}
	}
	[PublicAPI]
	internal sealed class CustomSyncedValue<T> : CustomSyncedValueBase
	{
		public T Value
		{
			get
			{
				return (T)base.BoxedValue;
			}
			set
			{
				base.BoxedValue = value;
			}
		}

		public CustomSyncedValue(ConfigSync configSync, string identifier, T value = default(T), int priority = 0)
			: base(configSync, identifier, typeof(T), priority)
		{
			Value = value;
		}

		public void AssignLocalValue(T value)
		{
			if (localIsOwner)
			{
				Value = value;
			}
			else
			{
				LocalBaseValue = value;
			}
		}
	}
	internal class ConfigurationManagerAttributes
	{
		[UsedImplicitly]
		public bool? ReadOnly = false;
	}
	[PublicAPI]
	internal class ConfigSync
	{
		[HarmonyPatch(typeof(ZRpc), "HandlePackage")]
		private static class SnatchCurrentlyHandlingRPC
		{
			public static ZRpc? currentRpc;

			[HarmonyPrefix]
			private static void Prefix(ZRpc __instance)
			{
				currentRpc = __instance;
			}
		}

		[HarmonyPatch(typeof(ZNet), "Awake")]
		internal static class RegisterRPCPatch
		{
			[HarmonyPostfix]
			private static void Postfix(ZNet __instance)
			{
				isServer = __instance.IsServer();
				foreach (ConfigSync configSync2 in configSyncs)
				{
					ZRoutedRpc.instance.Register<ZPackage>(configSync2.Name + " ConfigSync", (Action<long, ZPackage>)configSync2.RPC_FromOtherClientConfigSync);
					if (isServer)
					{
						configSync2.InitialSyncDone = true;
						Debug.Log((object)("Registered '" + configSync2.Name + " ConfigSync' RPC - waiting for incoming connections"));
					}
				}
				if (isServer)
				{
					((MonoBehaviour)__instance).StartCoroutine(WatchAdminListChanges());
				}
				static void SendAdmin(List<ZNetPeer> peers, bool isAdmin)
				{
					ZPackage package = ConfigsToPackage(null, null, new PackageEntry[1]
					{
						new PackageEntry
						{
							section = "Internal",
							key = "lockexempt",
							type = typeof(bool),
							value = isAdmin
						}
					});
					ConfigSync configSync = configSyncs.First();
					if (configSync != null)
					{
						((MonoBehaviour)ZNet.instance).StartCoroutine(configSync.sendZPackage(peers, package));
					}
				}
				static IEnumerator WatchAdminListChanges()
				{
					SyncedList adminList = (SyncedList)AccessTools.DeclaredField(typeof(ZNet), "m_adminList").GetValue(ZNet.instance);
					List<string> CurrentList = new List<string>(adminList.GetList());
					while (true)
					{
						yield return (object)new WaitForSeconds(30f);
						if (!adminList.GetList().SequenceEqual(CurrentList))
						{
							CurrentList = new List<string>(adminList.GetList());
							List<ZNetPeer> adminPeer = (from p in ZNet.instance.GetPeers()
								where adminList.Contains(p.m_rpc.GetSocket().GetHostName())
								select p).ToList();
							List<ZNetPeer> nonAdminPeer = ZNet.instance.GetPeers().Except(adminPeer).ToList();
							SendAdmin(nonAdminPeer, isAdmin: false);
							SendAdmin(adminPeer, isAdmin: true);
						}
					}
				}
			}
		}

		[HarmonyPatch(typeof(ZNet), "OnNewConnection")]
		private static class RegisterClientRPCPatch
		{
			[HarmonyPostfix]
			private static void Postfix(ZNet __instance, ZNetPeer peer)
			{
				if (__instance.IsServer())
				{
					return;
				}
				foreach (ConfigSync configSync in configSyncs)
				{
					peer.m_rpc.Register<ZPackage>(configSync.Name + " ConfigSync", (Action<ZRpc, ZPackage>)configSync.RPC_FromServerConfig