Decompiled source of RunicWarrior v1.0.0

ValheimGroundZone.dll

Decompiled 2 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.UI;
using ValheimGroundZone.Configuration;
using ValheimGroundZone.Managers;
using ValheimGroundZone.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("ValheimGroundZone")]
[assembly: AssemblyDescription("Adds a Guardian Power-linked runic zone ability that summons allied creatures.")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("fif11")]
[assembly: AssemblyProduct("ValheimGroundZone")]
[assembly: AssemblyCopyright("Copyright © 2026 fif11")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("85d3b6f8-1d2c-4160-b8a5-cd1c039b4492")]
[assembly: AssemblyFileVersion("2.0.1.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("2.0.1.0")]
namespace ValheimGroundZone
{
	[BepInPlugin("com.fif11.groundzone", "Ground Zone Ability", "2.0.1")]
	public class GroundZonePlugin : BaseUnityPlugin
	{
		public const string GUID = "com.fif11.groundzone";

		public const string ModName = "Ground Zone Ability";

		public const string Version = "2.0.1";

		private Harmony _harmony;

		internal static ManualLogSource Log { get; private set; }

		private void Awake()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			PluginConfig.Init(((BaseUnityPlugin)this).Config);
			Log.LogInfo((object)"[Ground Zone Ability] v2.0.1 — config loaded.");
			GuardianPowerHelper.Init();
			_harmony = new Harmony("com.fif11.groundzone");
			_harmony.PatchAll(typeof(WelcomeMessage));
			_harmony.PatchAll(typeof(GroundZonePlugin).Assembly);
			Log.LogInfo((object)("[Ground Zone Ability] Harmony patches applied. Debug mode: " + (PluginConfig.DebugMode.Value ? "ON" : "OFF")));
		}

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

		internal static void LogDebug(string message)
		{
			if (PluginConfig.DebugMode.Value)
			{
				Log.LogInfo((object)message);
			}
		}

		internal static void LogWarnDebug(string message)
		{
			if (PluginConfig.DebugMode.Value)
			{
				Log.LogWarning((object)message);
			}
		}
	}
}
namespace ValheimGroundZone.UI
{
	public class ZoneHud : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <SetupUI>d__7 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public ZoneHud <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				int num = <>1__state;
				ZoneHud zoneHud = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if ((Object)(object)Hud.instance == (Object)null || (Object)(object)Hud.instance.m_gpRoot == (Object)null)
				{
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				zoneHud.BuildUI();
				return false;
			}

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

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

		private GameObject _uiRoot;

		private Image _cooldownOverlay;

		private Text _nameText;

		private Text _hotkeyText;

		private KeyCode _lastTriggerKey;

		private string _cachedKeyName = string.Empty;

		private void Start()
		{
			((MonoBehaviour)this).StartCoroutine(SetupUI());
		}

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

		private void BuildUI()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: 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_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: 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_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Expected O, but got Unknown
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Expected O, but got Unknown
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_029d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b2: 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_02d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Expected O, but got Unknown
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0365: Unknown result type (might be due to invalid IL or missing references)
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			Transform parent = ((Component)Hud.instance.m_gpRoot).transform.parent;
			_uiRoot = new GameObject("GroundZoneUI");
			RectTransform obj = _uiRoot.AddComponent<RectTransform>();
			_uiRoot.transform.SetParent(parent, false);
			RectTransform component = ((Component)Hud.instance.m_gpRoot).GetComponent<RectTransform>();
			obj.anchorMin = component.anchorMin;
			obj.anchorMax = component.anchorMax;
			obj.pivot = component.pivot;
			obj.anchoredPosition = component.anchoredPosition + new Vector2(110f, 0f);
			obj.sizeDelta = component.sizeDelta;
			GameObject val = new GameObject("Background");
			val.transform.SetParent(_uiRoot.transform, false);
			((Graphic)val.AddComponent<Image>()).color = new Color(0f, 0f, 0f, 0.5f);
			RectTransform component2 = val.GetComponent<RectTransform>();
			component2.anchorMin = Vector2.zero;
			component2.anchorMax = Vector2.one;
			component2.offsetMin = Vector2.zero;
			component2.offsetMax = Vector2.zero;
			GameObject val2 = new GameObject("CooldownOverlay");
			val2.transform.SetParent(_uiRoot.transform, false);
			_cooldownOverlay = val2.AddComponent<Image>();
			((Graphic)_cooldownOverlay).color = new Color(0f, 0f, 0f, 0.6f);
			_cooldownOverlay.type = (Type)3;
			_cooldownOverlay.fillMethod = (FillMethod)4;
			_cooldownOverlay.fillOrigin = 2;
			_cooldownOverlay.fillClockwise = true;
			_cooldownOverlay.fillAmount = 0f;
			RectTransform component3 = val2.GetComponent<RectTransform>();
			component3.anchorMin = Vector2.zero;
			component3.anchorMax = Vector2.one;
			component3.offsetMin = Vector2.zero;
			component3.offsetMax = Vector2.zero;
			Font vanillaFont = GetVanillaFont();
			GameObject val3 = new GameObject("NameText");
			val3.transform.SetParent(_uiRoot.transform, false);
			_nameText = val3.AddComponent<Text>();
			_nameText.text = "Runic Call";
			_nameText.font = vanillaFont;
			_nameText.fontSize = 11;
			_nameText.alignment = (TextAnchor)7;
			((Graphic)_nameText).color = Color.white;
			_nameText.horizontalOverflow = (HorizontalWrapMode)1;
			RectTransform component4 = val3.GetComponent<RectTransform>();
			component4.anchorMin = new Vector2(0f, 0f);
			component4.anchorMax = new Vector2(1f, 0f);
			component4.pivot = new Vector2(0.5f, 0f);
			component4.anchoredPosition = new Vector2(0f, -18f);
			component4.sizeDelta = new Vector2(0f, 20f);
			GameObject val4 = new GameObject("HotkeyText");
			val4.transform.SetParent(_uiRoot.transform, false);
			_hotkeyText = val4.AddComponent<Text>();
			_hotkeyText.font = vanillaFont;
			_hotkeyText.fontSize = 28;
			_hotkeyText.alignment = (TextAnchor)4;
			((Graphic)_hotkeyText).color = new Color(1f, 0.8f, 0f);
			_hotkeyText.horizontalOverflow = (HorizontalWrapMode)1;
			_hotkeyText.verticalOverflow = (VerticalWrapMode)1;
			RectTransform component5 = val4.GetComponent<RectTransform>();
			component5.anchorMin = Vector2.zero;
			component5.anchorMax = Vector2.one;
			component5.offsetMin = Vector2.zero;
			component5.offsetMax = Vector2.zero;
			_uiRoot.SetActive(false);
		}

		private static Font GetVanillaFont()
		{
			Text[] componentsInChildren = ((Component)Hud.instance.m_gpRoot).GetComponentsInChildren<Text>(true);
			foreach (Text val in componentsInChildren)
			{
				if ((Object)(object)val.font != (Object)null)
				{
					return val.font;
				}
			}
			return Resources.GetBuiltinResource<Font>("Arial.ttf");
		}

		private void Update()
		{
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_uiRoot == (Object)null || (Object)(object)Player.m_localPlayer == (Object)null)
			{
				return;
			}
			bool flag = GuardianPowerHelper.IsGuardianPowerActive(Player.m_localPlayer);
			if (_uiRoot.activeSelf != flag)
			{
				_uiRoot.SetActive(flag);
			}
			if (!flag)
			{
				return;
			}
			bool isZoneUsedCurrentCycle = ZoneStateManager.IsZoneUsedCurrentCycle;
			_cooldownOverlay.fillAmount = (isZoneUsedCurrentCycle ? 1f : 0f);
			if (!((Object)(object)_hotkeyText != (Object)null))
			{
				return;
			}
			if (((Component)_hotkeyText).gameObject.activeSelf == isZoneUsedCurrentCycle)
			{
				((Component)_hotkeyText).gameObject.SetActive(!isZoneUsedCurrentCycle);
			}
			if (!isZoneUsedCurrentCycle)
			{
				KeyCode value = PluginConfig.TriggerKey.Value;
				if (value != _lastTriggerKey)
				{
					_lastTriggerKey = value;
					_cachedKeyName = ((object)(KeyCode)(ref value)).ToString();
					_hotkeyText.text = _cachedKeyName;
				}
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)_uiRoot != (Object)null)
			{
				Object.Destroy((Object)(object)_uiRoot);
			}
		}
	}
	public static class WelcomeMessage
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static UnityAction <>9__2_0;

			internal void <ShowWelcomePanel>b__2_0()
			{
				Application.OpenURL("https://discord.com/users/1084209564653727804");
			}
		}

		private static bool _shown = false;

		private static readonly string PREFS_KEY = "VGZ_HideWelcome_v2.0.1";

		[HarmonyPatch(typeof(FejdStartup), "Start")]
		[HarmonyPostfix]
		public static void ShowWelcomePanel()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0218: Unknown result type (might be due to invalid IL or missing references)
			//IL_0227: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0402: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_0420: Unknown result type (might be due to invalid IL or missing references)
			//IL_044d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0479: Unknown result type (might be due to invalid IL or missing references)
			//IL_048e: Unknown result type (might be due to invalid IL or missing references)
			//IL_049d: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0502: Unknown result type (might be due to invalid IL or missing references)
			//IL_050c: Expected O, but got Unknown
			//IL_052b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0543: Unknown result type (might be due to invalid IL or missing references)
			//IL_0552: Unknown result type (might be due to invalid IL or missing references)
			//IL_0561: Unknown result type (might be due to invalid IL or missing references)
			//IL_057e: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05d6: Expected O, but got Unknown
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0332: Expected O, but got Unknown
			if (_shown || PlayerPrefs.GetInt(PREFS_KEY, 0) == 1)
			{
				return;
			}
			_shown = true;
			GameObject canvasGO = new GameObject("WelcomeCanvas_VGZ");
			canvasGO.layer = 5;
			Canvas obj = canvasGO.AddComponent<Canvas>();
			obj.renderMode = (RenderMode)0;
			obj.sortingOrder = 9999;
			canvasGO.AddComponent<CanvasScaler>();
			canvasGO.AddComponent<GraphicRaycaster>();
			Object.DontDestroyOnLoad((Object)(object)canvasGO);
			GameObject val = MakeRect("Background", canvasGO.transform, new Color(0.05f, 0.05f, 0.05f, 0.96f));
			RectTransform component = val.GetComponent<RectTransform>();
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(0.5f, 0.5f);
			component.anchorMax = val2;
			component.anchorMin = val2;
			component.sizeDelta = new Vector2(550f, 480f);
			component.anchoredPosition = Vector2.zero;
			GameObject val3 = MakeRect("Header", val.transform, new Color(0.1f, 0.1f, 0.1f, 1f));
			Stretch(val3, new Vector2(0f, 0.86f), Vector2.one);
			MakeText("Title", val3.transform, "RunicWarrior", 22, new Color(1f, 0.85f, 0.4f), (FontStyle)1);
			Text obj2 = MakeText("Body", val.transform, "Hi! Thank you for using my mod.\nThe mod is in beta, so I'd love to hear any feedback:\nbugs, suggestions, logs - anything.\n\nПривет! Спасибо за использование моего мода.\nМод находится в бете, поэтому я буду рад любым отзывам:\nбагам, предложениям, логам - чему угодно.\n\nMy Discord account / Мой аккаунт Discord:", 15, Color.white, (FontStyle)0);
			obj2.lineSpacing = 1.2f;
			obj2.alignment = (TextAnchor)1;
			SetAnchors(((Component)obj2).gameObject, new Vector2(0f, 0.35f), new Vector2(1f, 0.86f), new Vector2(20f, 0f), new Vector2(-20f, -15f));
			GameObject val4 = MakeRect("Link", val.transform, Color.clear);
			SetAnchors(val4, new Vector2(0f, 0.25f), new Vector2(1f, 0.35f), new Vector2(20f, 0f), new Vector2(-20f, 0f));
			MakeText("LinkText", val4.transform, "https://discord.com/users/1084209564653727804 (skarif_q)", 15, new Color(0.35f, 0.7f, 1f), (FontStyle)0);
			RectTransform component2 = MakeRect("Underline", val4.transform, new Color(0.35f, 0.7f, 1f)).GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(0.05f, 0f);
			component2.anchorMax = new Vector2(0.95f, 0f);
			component2.sizeDelta = new Vector2(0f, 1.5f);
			component2.anchoredPosition = new Vector2(0f, 3f);
			Image component3 = val4.GetComponent<Image>();
			Color highlight = new Color(0.35f, 0.7f, 1f, 0.15f);
			Color pressed = new Color(0.35f, 0.7f, 1f, 0.3f);
			object obj3 = <>c.<>9__2_0;
			if (obj3 == null)
			{
				UnityAction val5 = delegate
				{
					Application.OpenURL("https://discord.com/users/1084209564653727804");
				};
				<>c.<>9__2_0 = val5;
				obj3 = (object)val5;
			}
			MakeButton(val4, component3, highlight, pressed, (UnityAction)obj3);
			MakeSeparator("Sep1", val.transform, 0.22f);
			MakeSeparator("Sep2", val.transform, 0.14f);
			bool dontShow = false;
			SetPivotAnchor(((Component)MakeText("Label", val.transform, "Don't show anymore / Больше не показывать", 13, new Color(0.75f, 0.75f, 0.75f), (FontStyle)0)).gameObject, new Vector2(0.5f, 0f), new Vector2(280f, 30f), new Vector2(20f, 85f));
			GameObject val6 = MakeRect("Box", val.transform, new Color(0.25f, 0.25f, 0.25f, 1f));
			SetPivotAnchor(val6, new Vector2(0.5f, 0f), new Vector2(18f, 18f), new Vector2(-135f, 85f));
			GameObject tickGO = ((Component)MakeText("Tick", val6.transform, "v", 13, new Color(0.35f, 0.7f, 1f), (FontStyle)1)).gameObject;
			tickGO.SetActive(false);
			GameObject obj4 = MakeRect("CheckHit", val.transform, Color.clear);
			SetPivotAnchor(obj4, new Vector2(0.5f, 0f), new Vector2(320f, 30f), new Vector2(0f, 85f));
			Image boxImg = val6.GetComponent<Image>();
			MakeButton(obj4, obj4.GetComponent<Image>(), new Color(1f, 1f, 1f, 0.05f), new Color(1f, 1f, 1f, 0.1f), (UnityAction)delegate
			{
				//IL_005d: 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)
				dontShow = !dontShow;
				tickGO.SetActive(dontShow);
				((Graphic)boxImg).color = (dontShow ? new Color(0.1f, 0.25f, 0.45f, 1f) : new Color(0.25f, 0.25f, 0.25f, 1f));
			});
			GameObject val7 = MakeRect("Close", val.transform, new Color(0.65f, 0.15f, 0.15f, 1f));
			SetPivotAnchor(val7, new Vector2(0.5f, 0f), new Vector2(140f, 34f), new Vector2(0f, 20f));
			MakeText("CloseText", val7.transform, "Close / Закрыть", 15, Color.white, (FontStyle)0);
			MakeButton(val7, val7.GetComponent<Image>(), new Color(0.85f, 0.25f, 0.25f, 1f), new Color(0.45f, 0.08f, 0.08f, 1f), (UnityAction)delegate
			{
				if (dontShow)
				{
					PlayerPrefs.SetInt(PREFS_KEY, 1);
				}
				Object.Destroy((Object)(object)canvasGO);
			});
		}

		private static GameObject MakeRect(string name, Transform parent, Color color)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			GameObject val = new GameObject(name)
			{
				layer = 5
			};
			val.transform.SetParent(parent, false);
			val.AddComponent<RectTransform>();
			((Graphic)val.AddComponent<Image>()).color = color;
			return val;
		}

		private static Text MakeText(string name, Transform parent, string text, int size, Color color, FontStyle style = 0)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.layer = 5;
			val.transform.SetParent(parent, false);
			val.AddComponent<RectTransform>();
			Text obj = val.AddComponent<Text>();
			obj.text = text;
			obj.font = GetFont();
			obj.fontSize = size;
			((Graphic)obj).color = color;
			obj.fontStyle = style;
			obj.alignment = (TextAnchor)4;
			Stretch(val, Vector2.zero, Vector2.one);
			return obj;
		}

		private static void MakeButton(GameObject go, Image target, Color highlight, Color pressed, UnityAction action)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			Button obj = go.AddComponent<Button>();
			((Selectable)obj).targetGraphic = (Graphic)(object)target;
			ColorBlock colors = ((Selectable)obj).colors;
			((ColorBlock)(ref colors)).normalColor = ((Graphic)target).color;
			((ColorBlock)(ref colors)).highlightedColor = highlight;
			((ColorBlock)(ref colors)).pressedColor = pressed;
			((Selectable)obj).colors = colors;
			((UnityEvent)obj.onClick).AddListener(action);
		}

		private static void MakeSeparator(string name, Transform parent, float anchorY)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = MakeRect(name, parent, new Color(1f, 1f, 1f, 0.12f)).GetComponent<RectTransform>();
			component.anchorMin = new Vector2(0f, anchorY);
			component.anchorMax = new Vector2(1f, anchorY);
			component.sizeDelta = new Vector2(0f, 1f);
			component.anchoredPosition = Vector2.zero;
		}

		private static void Stretch(GameObject go, Vector2 min, Vector2 max)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = go.GetComponent<RectTransform>();
			component.anchorMin = min;
			component.anchorMax = max;
			Vector2 offsetMin = (component.offsetMax = Vector2.zero);
			component.offsetMin = offsetMin;
		}

		private static void SetAnchors(GameObject go, Vector2 min, Vector2 max, Vector2 offsetMin, Vector2 offsetMax)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = go.GetComponent<RectTransform>();
			component.anchorMin = min;
			component.anchorMax = max;
			component.offsetMin = offsetMin;
			component.offsetMax = offsetMax;
		}

		private static void SetPivotAnchor(GameObject go, Vector2 anchor, Vector2 size, Vector2 pos)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			RectTransform component = go.GetComponent<RectTransform>();
			Vector2 anchorMin = (component.anchorMax = anchor);
			component.anchorMin = anchorMin;
			component.sizeDelta = size;
			component.anchoredPosition = pos;
		}

		private static Font GetFont()
		{
			Font[] array = Resources.FindObjectsOfTypeAll<Font>();
			foreach (Font val in array)
			{
				if ((Object)(object)val != (Object)null && ((Object)val).name.Contains("Averia"))
				{
					return val;
				}
			}
			return Resources.GetBuiltinResource<Font>("Arial.ttf");
		}
	}
}
namespace ValheimGroundZone.Patches
{
	[HarmonyPatch(typeof(Hud), "Awake")]
	public static class Hud_Awake_Patch
	{
		private static void Postfix(Hud __instance)
		{
			if ((Object)(object)((Component)__instance).GetComponent<ZoneHud>() == (Object)null)
			{
				((Component)__instance).gameObject.AddComponent<ZoneHud>();
			}
			if ((Object)(object)((Component)__instance).GetComponent<ZoneInputManager>() == (Object)null)
			{
				((Component)__instance).gameObject.AddComponent<ZoneInputManager>();
			}
		}
	}
	[HarmonyPatch(typeof(MonsterAI), "UpdateAI")]
	public static class MonsterAI_UpdateAI_Patch
	{
		private static bool Prefix(MonsterAI __instance, float dt)
		{
			ZoneMinionController component = ((Component)__instance).GetComponent<ZoneMinionController>();
			if ((Object)(object)component != (Object)null)
			{
				return component.CheckAIControl(dt);
			}
			return true;
		}
	}
}
namespace ValheimGroundZone.Managers
{
	public static class BloodTributeManager
	{
		[HarmonyPatch(typeof(ObjectDB), "Awake")]
		public static class ObjectDB_Awake_Patch
		{
			private static void Postfix(ObjectDB __instance)
			{
				RegisterStatusEffect(__instance);
			}
		}

		[HarmonyPatch(typeof(Character), "OnDeath")]
		public static class Character_OnDeath_Patch
		{
			private static void Postfix(Character __instance)
			{
				OnCreatureDied(__instance);
			}
		}

		public const string SE_NAME = "SE_GroundZone_BloodTribute";

		public const string SE_ANIM_EV = "";

		public const float SE_DURATION = 5f;

		public const float SPEED_BONUS = 0.15f;

		public const float REGEN_BONUS = 0.2f;

		private static SE_Stats _bloodTributeSE;

		private static int _seHashCode;

		public static void RegisterStatusEffect(ObjectDB objectDB)
		{
			if ((Object)(object)objectDB == (Object)null)
			{
				return;
			}
			int stableHashCode = StringExtensionMethods.GetStableHashCode("SE_GroundZone_BloodTribute");
			if ((Object)(object)objectDB.GetStatusEffect(stableHashCode) != (Object)null)
			{
				if ((Object)(object)_bloodTributeSE == (Object)null)
				{
					StatusEffect statusEffect = objectDB.GetStatusEffect(stableHashCode);
					_bloodTributeSE = (SE_Stats)(object)((statusEffect is SE_Stats) ? statusEffect : null);
					_seHashCode = stableHashCode;
				}
				return;
			}
			SE_Stats val = ScriptableObject.CreateInstance<SE_Stats>();
			((Object)val).name = "SE_GroundZone_BloodTribute";
			((StatusEffect)val).m_name = "Blood Tribute";
			((StatusEffect)val).m_tooltip = "Кровь врагов питает зону.\n" + $"Скорость +{15.000001f:0}%  |  " + $"Регенерация здоровья +{20f:0}%";
			((StatusEffect)val).m_ttl = 5f;
			val.m_speedModifier = 0.15f;
			val.m_healthRegenMultiplier = 1.2f;
			((StatusEffect)val).m_icon = TryGetIcon(objectDB, "GP_Bonemass", "SE_Burning", "GP_Eikthyr", "SE_Rested");
			objectDB.m_StatusEffects.Add((StatusEffect)(object)val);
			_bloodTributeSE = val;
			_seHashCode = stableHashCode;
			GroundZonePlugin.Log.LogInfo((object)("[BloodTribute] StatusEffect 'SE_GroundZone_BloodTribute' зарегистрирован. Icon: " + (((Object)(object)((StatusEffect)val).m_icon != (Object)null) ? ((Object)((StatusEffect)val).m_icon).name : "none")));
		}

		private static Sprite TryGetIcon(ObjectDB db, params string[] seName)
		{
			foreach (string text in seName)
			{
				StatusEffect statusEffect = db.GetStatusEffect(StringExtensionMethods.GetStableHashCode(text));
				if ((Object)(object)statusEffect != (Object)null && (Object)(object)statusEffect.m_icon != (Object)null)
				{
					return statusEffect.m_icon;
				}
			}
			return null;
		}

		public static void ApplyTribute(Player player)
		{
			if (!((Object)(object)player == (Object)null) && !((Object)(object)_bloodTributeSE == (Object)null))
			{
				((Character)player).GetSEMan().AddStatusEffect(_seHashCode, true, 0, 0f);
			}
		}

		public static void OnCreatureDied(Character creature)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)creature == (Object)null || creature.IsPlayer() || creature.IsTamed() || (int)creature.m_faction == 0)
			{
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null)
			{
				return;
			}
			Vector3 position = ((Component)creature).transform.position;
			GroundZone[] array = GroundZone.AllInstances.ToArray();
			foreach (GroundZone groundZone in array)
			{
				if (!((Object)(object)groundZone == (Object)null))
				{
					Vector3 val = position - ((Component)groundZone).transform.position;
					float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
					float num = groundZone.Radius * groundZone.Radius;
					if (sqrMagnitude <= num)
					{
						GroundZonePlugin.LogDebug("[BloodTribute] Бафф применён: существо '" + ((Object)creature).name + "' в зоне.");
						ApplyTribute(localPlayer);
						break;
					}
				}
			}
		}
	}
	public static class GuardianPowerHelper
	{
		private static FieldInfo _guardianSEField;

		public static void Init()
		{
			_guardianSEField = typeof(Player).GetField("m_guardianSE", BindingFlags.Instance | BindingFlags.NonPublic);
			if (_guardianSEField == null)
			{
				GroundZonePlugin.Log.LogError((object)"[GuardianPowerHelper] Field m_guardianSE not found in Player. Assembly-CSharp.dll override. The zone will not activate.");
			}
			else
			{
				GroundZonePlugin.Log.LogInfo((object)"[GuardianPowerHelper] m_guardianSE successfully cached.");
			}
		}

		public static bool IsGuardianPowerActive(Player player)
		{
			if ((Object)(object)player == (Object)null || _guardianSEField == null)
			{
				return false;
			}
			object? value = _guardianSEField.GetValue(player);
			StatusEffect val = (StatusEffect)((value is StatusEffect) ? value : null);
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			return ((Character)player).GetSEMan().HaveStatusEffect(StringExtensionMethods.GetStableHashCode(((Object)val).name));
		}
	}
	public static class MonsterAIHelper
	{
		private static MethodInfo _setTarget;

		private static MethodInfo _setAlerted;

		private static MethodInfo _moveTo;

		private static MethodInfo _stopMoving;

		static MonsterAIHelper()
		{
			_setTarget = typeof(MonsterAI).GetMethod("SetTarget", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(Character) }, null);
			_setAlerted = typeof(MonsterAI).GetMethod("SetAlerted", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[1] { typeof(bool) }, null);
			_moveTo = typeof(BaseAI).GetMethod("MoveTo", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic, null, new Type[4]
			{
				typeof(float),
				typeof(Vector3),
				typeof(float),
				typeof(bool)
			}, null);
			_stopMoving = typeof(BaseAI).GetMethod("StopMoving", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
			if (_setTarget == null)
			{
				ManualLogSource log = GroundZonePlugin.Log;
				if (log != null)
				{
					log.LogError((object)"[MonsterAIHelper] Method 'SetTarget' not found.");
				}
			}
			if (_setAlerted == null)
			{
				ManualLogSource log2 = GroundZonePlugin.Log;
				if (log2 != null)
				{
					log2.LogError((object)"[MonsterAIHelper] Method 'SetAlerted' not found.");
				}
			}
			if (_moveTo == null)
			{
				ManualLogSource log3 = GroundZonePlugin.Log;
				if (log3 != null)
				{
					log3.LogError((object)"[MonsterAIHelper] Method 'MoveTo' not found.");
				}
			}
			if (_stopMoving == null)
			{
				ManualLogSource log4 = GroundZonePlugin.Log;
				if (log4 != null)
				{
					log4.LogError((object)"[MonsterAIHelper] Method 'StopMoving' not found.");
				}
			}
		}

		public static void ClearTarget(MonsterAI ai)
		{
			_setTarget?.Invoke(ai, new object[1]);
		}

		public static void SetAlerted(MonsterAI ai, bool alerted)
		{
			_setAlerted?.Invoke(ai, new object[1] { alerted });
		}

		public static void MoveTo(MonsterAI ai, float dt, Vector3 target, float dist = 0f, bool run = true)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			_moveTo?.Invoke(ai, new object[4] { dt, target, dist, run });
		}

		public static void StopMoving(MonsterAI ai)
		{
			_stopMoving?.Invoke(ai, null);
		}
	}
	public static class ZoneStateManager
	{
		public static bool IsZoneUsedCurrentCycle { get; private set; }

		public static void MarkUsed()
		{
			IsZoneUsedCurrentCycle = true;
		}

		public static void Reset()
		{
			IsZoneUsedCurrentCycle = false;
		}
	}
	public class ZoneInputManager : MonoBehaviour
	{
		private void Update()
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null || Console.IsVisible() || Chat.instance.HasFocus() || Menu.IsVisible())
			{
				return;
			}
			if (!GuardianPowerHelper.IsGuardianPowerActive(localPlayer))
			{
				if (ZoneStateManager.IsZoneUsedCurrentCycle)
				{
					ZoneStateManager.Reset();
				}
			}
			else if (Input.GetKeyDown(PluginConfig.TriggerKey.Value))
			{
				if (ZoneStateManager.IsZoneUsedCurrentCycle)
				{
					TryDismissActiveZone(localPlayer);
				}
				else
				{
					AttemptSpawnZone(localPlayer);
				}
			}
		}

		private static void AttemptSpawnZone(Player p)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)ZNet.instance == (Object)null)
			{
				GroundZonePlugin.LogWarnDebug("[ZoneInputManager] ZNet.instance == null when trying to spawn a zone.");
				return;
			}
			ZoneStateManager.MarkUsed();
			ZoneSpawner.RequestSpawn(((Component)p).transform.position, ZNet.GetUID());
			((Character)p).Message((MessageType)2, "The runes responded!", 0, (Sprite)null);
		}

		private static void TryDismissActiveZone(Player p)
		{
			if ((Object)(object)ZNet.instance == (Object)null)
			{
				return;
			}
			long uID = ZNet.GetUID();
			bool flag = false;
			GroundZone[] array = GroundZone.AllInstances.ToArray();
			foreach (GroundZone groundZone in array)
			{
				if ((Object)(object)groundZone != (Object)null && groundZone.OwnerID == uID)
				{
					flag = true;
					break;
				}
			}
			if (!flag)
			{
				ZoneStateManager.Reset();
				return;
			}
			ZoneSpawner.RequestDismiss(uID);
			((Character)p).Message((MessageType)2, "The rune is scattered!", 0, (Sprite)null);
		}
	}
	public static class ZoneSpawner
	{
		[HarmonyPatch(typeof(Game), "Start")]
		public static class GameStartPatch
		{
			private static void Postfix()
			{
				if (ZRoutedRpc.instance == null)
				{
					GroundZonePlugin.Log.LogWarning((object)"[ZoneSpawner] ZRoutedRpc.instance == null at Game.Start - RPCs are not registered.");
					return;
				}
				ZRoutedRpc.instance.Register<Vector3, long>("RPC_GroundZone_Request_v2", (Action<long, Vector3, long>)RPC_ServerHandleRequest);
				ZRoutedRpc.instance.Register<Vector3, long>("RPC_GroundZone_Spawn_v2", (Action<long, Vector3, long>)RPC_ClientSpawn);
				ZRoutedRpc.instance.Register<long>("RPC_GroundZone_Dismiss_v2", (Action<long, long>)RPC_AllClientsDismiss);
				GroundZonePlugin.Log.LogInfo((object)"[ZoneSpawner] RPCs registered (spawn + dismiss).");
			}
		}

		private const string RPC_RequestZone = "RPC_GroundZone_Request_v2";

		private const string RPC_SpawnZone = "RPC_GroundZone_Spawn_v2";

		private const string RPC_DismissZone = "RPC_GroundZone_Dismiss_v2";

		public static void RequestSpawn(Vector3 position, long ownerID)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			if (ZRoutedRpc.instance != null)
			{
				ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "RPC_GroundZone_Request_v2", new object[2] { position, ownerID });
				GroundZonePlugin.LogDebug($"[ZoneSpawner] RequestSpawn sent: pos={position}, owner={ownerID}");
			}
		}

		private static void RPC_ServerHandleRequest(long sender, Vector3 position, long ownerID)
		{
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)ZNet.instance == (Object)null || !ZNet.instance.IsServer())
			{
				return;
			}
			foreach (ZNetPeer peer in ZNet.instance.GetPeers())
			{
				ZRoutedRpc.instance.InvokeRoutedRPC(peer.m_uid, "RPC_GroundZone_Spawn_v2", new object[2] { position, ownerID });
			}
			if (!ZNet.instance.IsDedicated())
			{
				CreateZoneObject(position, ownerID);
			}
		}

		private static void RPC_ClientSpawn(long sender, Vector3 position, long ownerID)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			CreateZoneObject(position, ownerID);
		}

		private static void CreateZoneObject(Vector3 center, long ownerID)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)ZoneSystem.instance == (Object)null)
			{
				GroundZonePlugin.LogWarnDebug("[ZoneSpawner] ZoneSystem.instance == null — zone not created.");
				return;
			}
			GameObject val = new GameObject("GroundZone");
			val.transform.position = center;
			val.AddComponent<MeshFilter>();
			val.AddComponent<MeshRenderer>();
			val.AddComponent<GroundZone>().Initialize(PluginConfig.ZoneRadius.Value, ownerID);
			GroundZonePlugin.LogDebug($"[ZoneSpawner] Zone created: center={center}, owner={ownerID}");
		}

		public static void RequestDismiss(long ownerID)
		{
			if (ZRoutedRpc.instance != null)
			{
				ZRoutedRpc.instance.InvokeRoutedRPC(ZRoutedRpc.Everybody, "RPC_GroundZone_Dismiss_v2", new object[1] { ownerID });
				GroundZonePlugin.LogDebug($"[ZoneSpawner] RequestDismiss sent for owner={ownerID}");
			}
		}

		private static void RPC_AllClientsDismiss(long sender, long ownerID)
		{
			GroundZone[] array = GroundZone.AllInstances.ToArray();
			foreach (GroundZone groundZone in array)
			{
				if ((Object)(object)groundZone != (Object)null && groundZone.OwnerID == ownerID)
				{
					groundZone.DismissEarly();
					break;
				}
			}
		}
	}
	public class GroundZone : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <AnimateRunesFall>d__47 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public GroundZone <>4__this;

			private Mesh <mesh>5__2;

			private float <duration>5__3;

			private float <startH>5__4;

			private float <t>5__5;

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

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

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

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

			private bool MoveNext()
			{
				//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00da: Unknown result type (might be due to invalid IL or missing references)
				//IL_00df: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				GroundZone groundZone = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<mesh>5__2 = groundZone._filter.mesh;
					<duration>5__3 = 1.5f;
					<startH>5__4 = 30f;
					<t>5__5 = 0f;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (<t>5__5 < <duration>5__3 + 0.5f)
				{
					if ((Object)(object)<mesh>5__2 == (Object)null)
					{
						return false;
					}
					<t>5__5 += Time.deltaTime;
					for (int i = 0; i < groundZone._currentVertices.Length; i++)
					{
						float num2 = Mathf.Clamp01((<t>5__5 - groundZone._fallDelays[i]) / <duration>5__3);
						float num3 = 1f - Mathf.Pow(1f - num2, 3f);
						groundZone._currentVertices[i] = groundZone._targetVertices[i] + Vector3.up * (<startH>5__4 * (1f - num3));
					}
					<mesh>5__2.vertices = groundZone._currentVertices;
					<mesh>5__2.RecalculateBounds();
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				<mesh>5__2.vertices = groundZone._targetVertices;
				<mesh>5__2.RecalculateBounds();
				return false;
			}

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

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

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

			private object <>2__current;

			public GroundZone <>4__this;

			private Mesh <mesh>5__2;

			private float <duration>5__3;

			private float <riseH>5__4;

			private float <t>5__5;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0105: Unknown result type (might be due to invalid IL or missing references)
				//IL_010a: 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_012a: Unknown result type (might be due to invalid IL or missing references)
				//IL_01af: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				GroundZone groundZone = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					if ((Object)(object)groundZone._filter == (Object)null)
					{
						return false;
					}
					<mesh>5__2 = groundZone._filter.mesh;
					<duration>5__3 = 2f;
					<riseH>5__4 = 15f;
					<t>5__5 = 0f;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (<t>5__5 < <duration>5__3)
				{
					if ((Object)(object)<mesh>5__2 == (Object)null || (Object)(object)groundZone._filter == (Object)null)
					{
						return false;
					}
					<t>5__5 += Time.deltaTime;
					float num2 = <t>5__5 / <duration>5__3;
					float num3 = Mathf.Pow(num2, 2f);
					for (int i = 0; i < groundZone._currentVertices.Length; i++)
					{
						float num4 = Mathf.PerlinNoise(groundZone._targetVertices[i].x * 0.1f, groundZone._targetVertices[i].z * 0.1f + <t>5__5);
						groundZone._currentVertices[i] = groundZone._targetVertices[i] + Vector3.up * (<riseH>5__4 * num3 + num4 * 2f);
					}
					<mesh>5__2.vertices = groundZone._currentVertices;
					if ((Object)(object)groundZone._materialInstance != (Object)null && groundZone._colorPropertyName != null)
					{
						Color val = default(Color);
						((Color)(ref val))..ctor(groundZone._baseColor.r, groundZone._baseColor.g, groundZone._baseColor.b, Mathf.Lerp(1f, 0f, num2));
						groundZone._materialInstance.SetColor(groundZone._colorPropertyName, val);
					}
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				if ((Object)(object)groundZone._renderer != (Object)null)
				{
					((Renderer)groundZone._renderer).enabled = false;
				}
				return false;
			}

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

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

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

			private object <>2__current;

			public GroundZone <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0077: Expected O, but got Unknown
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				GroundZone groundZone = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
				{
					<>1__state = -1;
					if (groundZone._minionSlots == null)
					{
						return false;
					}
					Character[] minionSlots = groundZone._minionSlots;
					foreach (Character val2 in minionSlots)
					{
						if ((Object)(object)val2 != (Object)null && !val2.IsDead())
						{
							groundZone.SpawnVFX(((Component)val2).transform.position);
						}
					}
					<>2__current = (object)new WaitForSeconds(0.1f);
					<>1__state = 1;
					return true;
				}
				case 1:
				{
					<>1__state = -1;
					for (int i = 0; i < groundZone._minionSlots.Length; i++)
					{
						Character val = groundZone._minionSlots[i];
						if ((Object)(object)val != (Object)null)
						{
							ZNetView component = ((Component)val).GetComponent<ZNetView>();
							if ((Object)(object)component != (Object)null && component.IsValid())
							{
								component.Destroy();
							}
							else if ((Object)(object)val != (Object)null)
							{
								Object.Destroy((Object)(object)((Component)val).gameObject);
							}
						}
						groundZone._minionSlots[i] = null;
					}
					return false;
				}
				}
			}

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

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

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

			private object <>2__current;

			public GroundZone <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				int num = <>1__state;
				GroundZone groundZone = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = ((MonoBehaviour)groundZone).StartCoroutine(groundZone.AnimateRunesRiseAndFade());
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (groundZone._isOwner && groundZone._minionSlots != null)
					{
						<>2__current = ((MonoBehaviour)groundZone).StartCoroutine(groundZone.DespawnAllMinionsCoroutine());
						<>1__state = 2;
						return true;
					}
					break;
				case 2:
					<>1__state = -1;
					break;
				}
				groundZone.CleanupAndDestroy();
				return false;
			}

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

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

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

			private object <>2__current;

			public GroundZone <>4__this;

			private int <rings>5__2;

			private int <segs>5__3;

			private float <off>5__4;

			private int <lm>5__5;

			private List<Vector3> <verts>5__6;

			private List<int> <tris>5__7;

			private List<Vector2> <uvs>5__8;

			private int <processed>5__9;

			private int <r>5__10;

			private float <cr>5__11;

			private int <s>5__12;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<verts>5__6 = null;
				<tris>5__7 = null;
				<uvs>5__8 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_014c: Unknown result type (might be due to invalid IL or missing references)
				//IL_015a: Unknown result type (might be due to invalid IL or missing references)
				//IL_015f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0164: Unknown result type (might be due to invalid IL or missing references)
				//IL_0328: Unknown result type (might be due to invalid IL or missing references)
				//IL_032d: Unknown result type (might be due to invalid IL or missing references)
				//IL_033a: Expected O, but got Unknown
				//IL_01af: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_017f: Unknown result type (might be due to invalid IL or missing references)
				//IL_018f: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				GroundZone groundZone = <>4__this;
				if (num != 0)
				{
					if (num != 1)
					{
						return false;
					}
					<>1__state = -1;
					goto IL_022a;
				}
				<>1__state = -1;
				<rings>5__2 = Mathf.Max(PluginConfig.GridDensity.Value / 2, 10);
				<segs>5__3 = Mathf.Max(PluginConfig.GridDensity.Value * 2, 64);
				<off>5__4 = Mathf.Max(PluginConfig.TerrainOffset.Value, 0.15f);
				<lm>5__5 = LayerMask.GetMask(new string[1] { "terrain" });
				int capacity = (<rings>5__2 + 1) * (<segs>5__3 + 1);
				int capacity2 = <rings>5__2 * <segs>5__3 * 6;
				<verts>5__6 = new List<Vector3>(capacity);
				<tris>5__7 = new List<int>(capacity2);
				<uvs>5__8 = new List<Vector2>(capacity);
				<processed>5__9 = 0;
				<r>5__10 = 0;
				goto IL_025f;
				IL_025f:
				if (<r>5__10 <= <rings>5__2)
				{
					<cr>5__11 = (float)<r>5__10 / (float)<rings>5__2 * groundZone._radius;
					<s>5__12 = 0;
					goto IL_023c;
				}
				for (int i = 0; i < <rings>5__2; i++)
				{
					for (int j = 0; j < <segs>5__3; j++)
					{
						int num2 = i * (<segs>5__3 + 1);
						int num3 = (i + 1) * (<segs>5__3 + 1);
						<tris>5__7.Add(num2 + j);
						<tris>5__7.Add(num3 + j);
						<tris>5__7.Add(num2 + j + 1);
						<tris>5__7.Add(num2 + j + 1);
						<tris>5__7.Add(num3 + j);
						<tris>5__7.Add(num3 + j + 1);
					}
				}
				Mesh val = new Mesh
				{
					name = "RuneZoneMesh"
				};
				if (<verts>5__6.Count > 65535)
				{
					val.indexFormat = (IndexFormat)1;
				}
				val.SetVertices(<verts>5__6);
				val.SetTriangles(<tris>5__7, 0);
				val.SetUVs(0, <uvs>5__8);
				val.RecalculateNormals();
				val.RecalculateBounds();
				groundZone._targetVertices = <verts>5__6.ToArray();
				groundZone._filter.mesh = val;
				return false;
				IL_022a:
				<s>5__12++;
				goto IL_023c;
				IL_023c:
				if (<s>5__12 <= <segs>5__3)
				{
					float num4 = (float)<s>5__12 / (float)<segs>5__3 * (float)Math.PI * 2f;
					float num5 = Mathf.Cos(num4) * <cr>5__11;
					float num6 = Mathf.Sin(num4) * <cr>5__11;
					float num7 = 0f;
					RaycastHit val2 = default(RaycastHit);
					if (Physics.Raycast(((Component)groundZone).transform.position + new Vector3(num5, 500f, num6), Vector3.down, ref val2, 1000f, <lm>5__5))
					{
						num7 = ((RaycastHit)(ref val2)).point.y - ((Component)groundZone).transform.position.y + <off>5__4;
					}
					<verts>5__6.Add(new Vector3(num5, num7, num6));
					<uvs>5__8.Add(new Vector2(num5 / groundZone._radius * 0.5f + 0.5f, num6 / groundZone._radius * 0.5f + 0.5f));
					<processed>5__9++;
					if (<processed>5__9 % 128 == 0)
					{
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					goto IL_022a;
				}
				<r>5__10++;
				goto IL_025f;
			}

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

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

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

			private object <>2__current;

			public GroundZone <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				int num = <>1__state;
				GroundZone groundZone = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = ((MonoBehaviour)groundZone).StartCoroutine(groundZone.GenerateRadialMeshAsync());
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					groundZone.SetupRuneMaterial();
					groundZone.PrepareIntroAnimation();
					groundZone._meshReady = true;
					groundZone._lifecycleCoroutine = ((MonoBehaviour)groundZone).StartCoroutine(groundZone.LifecycleLoop());
					return false;
				}
			}

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

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

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

			private object <>2__current;

			public GroundZone <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0078: Unknown result type (might be due to invalid IL or missing references)
				//IL_0082: Expected O, but got Unknown
				int num = <>1__state;
				GroundZone groundZone = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = ((MonoBehaviour)groundZone).StartCoroutine(groundZone.AnimateRunesFall());
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (groundZone._isOwner)
					{
						groundZone._spawnCoroutine = ((MonoBehaviour)groundZone).StartCoroutine(groundZone.SpawnLoop());
					}
					<>2__current = (object)new WaitForSeconds(PluginConfig.ZoneDuration.Value);
					<>1__state = 2;
					return true;
				case 2:
					<>1__state = -1;
					groundZone._isActive = false;
					if (groundZone._isOwner)
					{
						if (groundZone._spawnCoroutine != null)
						{
							((MonoBehaviour)groundZone).StopCoroutine(groundZone._spawnCoroutine);
						}
						groundZone.DismissMinions();
					}
					<>2__current = ((MonoBehaviour)groundZone).StartCoroutine(groundZone.AnimateRunesRiseAndFade());
					<>1__state = 3;
					return true;
				case 3:
					<>1__state = -1;
					if (groundZone._isOwner && groundZone._minionSlots != null)
					{
						<>2__current = ((MonoBehaviour)groundZone).StartCoroutine(groundZone.DespawnAllMinionsCoroutine());
						<>1__state = 4;
						return true;
					}
					break;
				case 4:
					<>1__state = -1;
					break;
				}
				groundZone.CleanupAndDestroy();
				return false;
			}

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

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

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

			private object <>2__current;

			public GroundZone <>4__this;

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

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

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

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

			private bool MoveNext()
			{
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Expected O, but got Unknown
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_0072: Expected O, but got Unknown
				int num = <>1__state;
				GroundZone groundZone = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					break;
				case 2:
					<>1__state = -1;
					break;
				}
				if (groundZone._isActive)
				{
					int freeSlotIndex = groundZone.GetFreeSlotIndex();
					if (freeSlotIndex != -1)
					{
						groundZone.SpawnAlly(freeSlotIndex);
					}
					<>2__current = (object)new WaitForSeconds(PluginConfig.SpawnInterval.Value);
					<>1__state = 2;
					return true;
				}
				return false;
			}

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

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

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

			private object <>2__current;

			public ZNetView nview;

			public long ownerID;

			public double expiresAt;

			public Vector3 center;

			public float radius;

			private float <waited>5__2;

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

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

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

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

			private bool MoveNext()
			{
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<waited>5__2 = 0f;
					break;
				case 1:
					<>1__state = -1;
					break;
				}
				if (!nview.IsOwner() && <waited>5__2 < 2f)
				{
					<waited>5__2 += Time.deltaTime;
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				if ((Object)(object)nview == (Object)null || !nview.IsValid() || !nview.IsOwner())
				{
					GroundZonePlugin.LogWarnDebug("[GroundZone] WriteZDOTags: IsOwner not received, no tags written.");
					return false;
				}
				ZDO zDO = nview.GetZDO();
				zDO.Set(ZDO_OWNER, ownerID);
				zDO.Set(ZDO_EXPIRES, (long)(expiresAt * 1000.0));
				zDO.Set(ZDO_CENTER_X, center.x);
				zDO.Set(ZDO_CENTER_Y, center.y);
				zDO.Set(ZDO_CENTER_Z, center.z);
				zDO.Set(ZDO_RADIUS, radius);
				GroundZonePlugin.LogDebug($"[GroundZone] ZDO write: owner={ownerID}, expires={expiresAt:F0}");
				return false;
			}

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

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

		public static readonly int ZDO_OWNER = StringExtensionMethods.GetStableHashCode("GZ_ZoneOwner");

		public static readonly int ZDO_EXPIRES = StringExtensionMethods.GetStableHashCode("GZ_ExpiresAt");

		public static readonly int ZDO_CENTER_X = StringExtensionMethods.GetStableHashCode("GZ_CenterX");

		public static readonly int ZDO_CENTER_Y = StringExtensionMethods.GetStableHashCode("GZ_CenterY");

		public static readonly int ZDO_CENTER_Z = StringExtensionMethods.GetStableHashCode("GZ_CenterZ");

		public static readonly int ZDO_RADIUS = StringExtensionMethods.GetStableHashCode("GZ_Radius");

		public static readonly List<GroundZone> AllInstances = new List<GroundZone>();

		private float _radius;

		private long _ownerID;

		private bool _isOwner;

		private double _expiresAt;

		private MeshFilter _filter;

		private MeshRenderer _renderer;

		private Vector3[] _patrolPoints;

		private Character[] _minionSlots;

		private Coroutine _spawnCoroutine;

		private Coroutine _lifecycleCoroutine;

		private bool _isActive = true;

		private Vector3[] _targetVertices;

		private Vector3[] _currentVertices;

		private float[] _fallDelays;

		private Color _baseColor;

		private Material _materialInstance;

		private string _colorPropertyName;

		private bool _meshReady;

		private static readonly int VFX_SPAWN_SMALL_HASH = StringExtensionMethods.GetStableHashCode("vfx_spawn_small");

		public float Radius => _radius;

		public long OwnerID => _ownerID;

		public void Initialize(float radius, long ownerID)
		{
			_radius = radius;
			_ownerID = ownerID;
			_isOwner = (Object)(object)ZNet.instance != (Object)null && ZNet.GetUID() == ownerID;
			_expiresAt = (((Object)(object)ZNet.instance != (Object)null) ? (ZNet.instance.GetTimeSeconds() + (double)PluginConfig.ZoneDuration.Value) : 0.0);
			_filter = ((Component)this).GetComponent<MeshFilter>();
			_renderer = ((Component)this).GetComponent<MeshRenderer>();
			if (_isOwner)
			{
				InitializePatrolPoints();
			}
			AllInstances.Add(this);
			((MonoBehaviour)this).StartCoroutine(InitializeAsync());
		}

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

		public void DismissEarly()
		{
			if (_isActive)
			{
				_isActive = false;
				((MonoBehaviour)this).StopAllCoroutines();
				if (_isOwner && _minionSlots != null)
				{
					DismissMinions();
				}
				if (_meshReady)
				{
					((MonoBehaviour)this).StartCoroutine(EarlyDismissSequence());
				}
				else
				{
					CleanupAndDestroy();
				}
			}
		}

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

		private void CleanupAndDestroy()
		{
			AllInstances.Remove(this);
			if (_isOwner)
			{
				ZoneStateManager.Reset();
			}
			if ((Object)(object)_materialInstance != (Object)null)
			{
				if ((Object)(object)_materialInstance.mainTexture != (Object)null)
				{
					Object.Destroy((Object)(object)_materialInstance.mainTexture);
				}
				Object.Destroy((Object)(object)_materialInstance);
				_materialInstance = null;
			}
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

		private void InitializePatrolPoints()
		{
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_021c: Unknown result type (might be due to invalid IL or missing references)
			int value = PluginConfig.MaxMinions.Value;
			if ((Object)(object)Player.m_localPlayer != (Object)null)
			{
				switch (Player.m_localPlayer.GetGuardianPowerName())
				{
				case "GP_Eikthyr":
					value = PluginConfig.MaxMinionsEikthyr.Value;
					break;
				case "GP_TheElder":
					value = PluginConfig.MaxMinionsTheElder.Value;
					break;
				case "GP_Bonemass":
					value = PluginConfig.MaxMinionsBonemass.Value;
					break;
				case "GP_Moder":
					value = PluginConfig.MaxMinionsModer.Value;
					break;
				case "GP_Yagluth":
					value = PluginConfig.MaxMinionsYagluth.Value;
					break;
				case "GP_Queen":
					value = PluginConfig.MaxMinionsQueen.Value;
					break;
				case "GP_Fader":
					value = PluginConfig.MaxMinionsFader.Value;
					break;
				}
			}
			_patrolPoints = (Vector3[])(object)new Vector3[value];
			_minionSlots = (Character[])(object)new Character[value];
			float num = Mathf.Min(15f, _radius * 0.7f);
			for (int i = 0; i < value; i++)
			{
				Vector2 val = Random.insideUnitCircle * num;
				Vector3 val2 = ((Component)this).transform.position + new Vector3(val.x, 0f, val.y);
				val2.y = (((Object)(object)ZoneSystem.instance != (Object)null) ? ZoneSystem.instance.GetGroundHeight(val2) : ((Component)this).transform.position.y);
				_patrolPoints[i] = val2;
			}
		}

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

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

		private int GetFreeSlotIndex()
		{
			for (int i = 0; i < _minionSlots.Length; i++)
			{
				if ((Object)(object)_minionSlots[i] == (Object)null || _minionSlots[i].IsDead())
				{
					return i;
				}
			}
			return -1;
		}

		private void SpawnAlly(int slotIndex)
		{
			//IL_0063: 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)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: 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_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: 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)
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null || (Object)(object)ZNetScene.instance == (Object)null)
			{
				return;
			}
			string prefabByPower = GetPrefabByPower(localPlayer.GetGuardianPowerName());
			if (string.IsNullOrEmpty(prefabByPower))
			{
				return;
			}
			GameObject prefab = ZNetScene.instance.GetPrefab(StringExtensionMethods.GetStableHashCode(prefabByPower));
			if ((Object)(object)prefab == (Object)null)
			{
				return;
			}
			Vector3 val = Quaternion.Euler(0f, (float)Random.Range(0, 360), 0f) * Vector3.forward;
			Vector3 val2 = ((Component)this).transform.position + val * PluginConfig.SpawnDistance.Value;
			val2.y = (((Object)(object)ZoneSystem.instance != (Object)null) ? (ZoneSystem.instance.GetGroundHeight(val2) + 0.5f) : ((Component)this).transform.position.y);
			SpawnVFX(val2);
			GameObject val3 = Object.Instantiate<GameObject>(prefab, val2, Quaternion.identity);
			Character component = val3.GetComponent<Character>();
			if ((Object)(object)component == (Object)null)
			{
				Object.Destroy((Object)(object)val3);
				return;
			}
			_minionSlots[slotIndex] = component;
			ZNetView component2 = val3.GetComponent<ZNetView>();
			if ((Object)(object)component2 != (Object)null)
			{
				((MonoBehaviour)this).StartCoroutine(WriteZDOTags(component2, ((Component)this).transform.position, _radius, _ownerID, _expiresAt));
			}
			val3.AddComponent<ZoneMinionController>().Initialize(((Component)this).transform.position, _patrolPoints[slotIndex], _radius);
		}

		private void SpawnVFX(Vector3 position)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)ZNetScene.instance == (Object)null))
			{
				GameObject prefab = ZNetScene.instance.GetPrefab(VFX_SPAWN_SMALL_HASH);
				if (!((Object)(object)prefab == (Object)null))
				{
					Object.Instantiate<GameObject>(prefab, position, Quaternion.identity);
				}
			}
		}

		[IteratorStateMachine(typeof(<WriteZDOTags>d__41))]
		public static IEnumerator WriteZDOTags(ZNetView nview, Vector3 center, float radius, long ownerID, double expiresAt)
		{
			//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)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <WriteZDOTags>d__41(0)
			{
				nview = nview,
				center = center,
				radius = radius,
				ownerID = ownerID,
				expiresAt = expiresAt
			};
		}

		private void DismissMinions()
		{
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			if (_minionSlots == null)
			{
				return;
			}
			Character[] minionSlots = _minionSlots;
			foreach (Character val in minionSlots)
			{
				if ((Object)(object)val == (Object)null || val.IsDead())
				{
					continue;
				}
				ZoneMinionController component = ((Component)val).GetComponent<ZoneMinionController>();
				if (Object.op_Implicit((Object)(object)component))
				{
					Object.Destroy((Object)(object)component);
				}
				MonsterAI component2 = ((Component)val).GetComponent<MonsterAI>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.SetFollowTarget((GameObject)null);
					MonsterAIHelper.ClearTarget(component2);
					Vector3 val2 = ((Component)val).transform.position - ((Component)this).transform.position;
					Vector3 val3 = ((Vector3)(ref val2)).normalized;
					if (val3 == Vector3.zero)
					{
						val3 = Vector3.forward;
					}
					MonsterAIHelper.MoveTo(component2, Time.deltaTime, ((Component)val).transform.position + val3 * 30f);
				}
			}
		}

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

		private static string GetPrefabByPower(string p)
		{
			switch (p)
			{
			case "GP_Eikthyr":
				return "Neck";
			case "GP_TheElder":
				return "Greydwarf";
			case "GP_Bonemass":
				if (!(Random.value < 0.3f))
				{
					return "Draugr";
				}
				return "Draugr_Ranged";
			case "GP_Moder":
				return "Hatchling";
			case "GP_Yagluth":
				if (!(Random.value < 0.4f))
				{
					return "Goblin";
				}
				return "GoblinArcher";
			case "GP_Queen":
				return "Seeker";
			case "GP_Fader":
				if (Random.value < 0.2f)
				{
					return GetRandomDvergerMage();
				}
				return "Dverger";
			default:
				GroundZonePlugin.Log.LogWarning((object)("[GroundZone] Unknown power of Guardian '" + p + "', spawn Boar."));
				return "Boar";
			}
		}

		private static string GetRandomDvergerMage()
		{
			float value = Random.value;
			if (value < 0.25f)
			{
				return "DvergerMage";
			}
			if (value < 0.5f)
			{
				return "DvergerMageFire";
			}
			if (value < 0.75f)
			{
				return "DvergerMageIce";
			}
			return "DvergerMageSupport";
		}

		private void PrepareIntroAnimation()
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			_currentVertices = (Vector3[])(object)new Vector3[_targetVertices.Length];
			_fallDelays = new float[_targetVertices.Length];
			for (int i = 0; i < _targetVertices.Length; i++)
			{
				_currentVertices[i] = _targetVertices[i] + Vector3.up * 30f;
				_fallDelays[i] = Random.Range(0f, 0.5f);
			}
			_filter.mesh.vertices = _currentVertices;
		}

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

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

		private void SetupRuneMaterial()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			Shader val = Shader.Find("Legacy Shaders/Particles/Alpha Blended") ?? Shader.Find("Particles/Standard Surface") ?? Shader.Find("UI/Default");
			if ((Object)(object)val == (Object)null)
			{
				GroundZonePlugin.Log.LogWarning((object)"[GroundZone] Shader not found - zone visual will not be displayed.");
				return;
			}
			_materialInstance = new Material(val);
			_baseColor = PluginConfig.ZoneColor.Value;
			_materialInstance.mainTexture = (Texture)(object)GenerateProceduralRunes();
			if (_materialInstance.HasProperty("_TintColor"))
			{
				_colorPropertyName = "_TintColor";
			}
			else if (_materialInstance.HasProperty("_Color"))
			{
				_colorPropertyName = "_Color";
			}
			else
			{
				_colorPropertyName = null;
			}
			if (_colorPropertyName != null)
			{
				_materialInstance.SetColor(_colorPropertyName, _baseColor);
			}
			_materialInstance.SetInt("_SrcBlend", 5);
			_materialInstance.SetInt("_DstBlend", 10);
			_materialInstance.SetInt("_ZWrite", 0);
			_materialInstance.renderQueue = 3000;
			((Renderer)_renderer).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)_renderer).receiveShadows = false;
			((Renderer)_renderer).material = _materialInstance;
		}

		private Texture2D GenerateProceduralRunes()
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Expected O, but got Unknown
			//IL_013b: 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_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			int num = 512;
			Color[] array = (Color[])(object)new Color[num * num];
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor((float)num / 2f, (float)num / 2f);
			float num2 = (float)num / 2f * 0.85f;
			Random random = new Random(12345);
			Vector2 val2 = default(Vector2);
			for (int i = 0; i < 24; i++)
			{
				float num3 = (float)i / 24f * (float)Math.PI * 2f;
				((Vector2)(ref val2))..ctor(Mathf.Cos(num3), Mathf.Sin(num3));
				Vector2 val3 = val + val2 * num2;
				Vector2 val4 = val2 * 40f;
				Vector2 val5 = new Vector2(0f - val2.y, val2.x) * 24f;
				DrawLine(array, num, val3 - val4, val3 + val4, Color.white);
				int num4 = random.Next(1, 4);
				for (int j = 0; j < num4; j++)
				{
					float num5 = (float)(random.NextDouble() * 1.6 - 0.8);
					float num6 = num5 + (float)(random.NextDouble() - 0.5);
					float num7 = ((random.NextDouble() > 0.5) ? 1f : (-1f));
					DrawLine(array, num, val3 + val4 * num5, val3 + val4 * num6 + val5 * num7, Color.white);
				}
			}
			Texture2D val6 = new Texture2D(num, num);
			val6.SetPixels(array);
			val6.Apply();
			return val6;
		}

		private static void DrawLine(Color[] px, int size, Vector2 p1, Vector2 p2, Color col)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			float num = Vector2.Distance(p1, p2);
			if (num < 0.01f)
			{
				return;
			}
			float num2 = 1f / num;
			float num3 = 0f;
			int num4 = (int)(num * 2f) + 10;
			int num5 = 0;
			Vector2 val = p1;
			while (num5 < num4 && ((int)val.x != (int)p2.x || (int)val.y != (int)p2.y))
			{
				val = Vector2.Lerp(p1, p2, num3);
				num3 += num2;
				num5++;
				for (int i = -1; i <= 1; i++)
				{
					for (int j = -1; j <= 1; j++)
					{
						int num6 = (int)val.x + i;
						int num7 = (int)val.y + j;
						if (num6 >= 0 && num6 < size && num7 >= 0 && num7 < size)
						{
							px[num7 * size + num6] = col;
						}
					}
				}
			}
		}

		[IteratorStateMachine(typeof(<GenerateRadialMeshAsync>d__52))]
		private IEnumerator GenerateRadialMeshAsync()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <GenerateRadialMeshAsync>d__52(0)
			{
				<>4__this = this
			};
		}
	}
	public class ZoneMinionController : MonoBehaviour
	{
		private MonsterAI _ai;

		private Character _character;

		private ZNetView _nview;

		private Vector3 _zoneCenter;

		private Vector3 _patrolTarget;

		private float _zoneRadius;

		private float _sqrZoneRadius;

		private float _sqrSafeDistance;

		private bool _isOutsideZone;

		private bool _initialized;

		private float _currentSafeThreshold = 0.95f;

		private const float SafeThresholdMin = 0.7f;

		private const float SafeThresholdMax = 0.95f;

		public void Initialize(Vector3 zoneCenter, Vector3 patrolTarget, float radius)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			_ai = ((Component)this).GetComponent<MonsterAI>();
			_character = ((Component)this).GetComponent<Character>();
			_nview = ((Component)this).GetComponent<ZNetView>();
			_zoneCenter = zoneCenter;
			_patrolTarget = patrolTarget;
			_zoneRadius = radius;
			_sqrZoneRadius = radius * radius;
			UpdateSqrSafeDistance();
			_initialized = true;
			if ((Object)(object)_character != (Object)null)
			{
				if ((Object)(object)((Component)_character).GetComponent<Tameable>() == (Object)null)
				{
					Tameable obj = ((Component)_character).gameObject.AddComponent<Tameable>();
					obj.m_fedDuration = float.MaxValue;
					obj.m_tamingTime = 0f;
					obj.m_commandable = false;
				}
				_character.SetTamed(true);
				_character.m_faction = (Faction)0;
				CharacterDrop component = ((Component)_character).GetComponent<CharacterDrop>();
				if ((Object)(object)component != (Object)null)
				{
					component.m_drops.Clear();
				}
			}
		}

		private void UpdateSqrSafeDistance()
		{
			float num = _zoneRadius * _currentSafeThreshold;
			_sqrSafeDistance = num * num;
		}

		public bool CheckAIControl(float dt)
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			if (!_initialized || (Object)(object)_ai == (Object)null)
			{
				return true;
			}
			if ((Object)(object)_character == (Object)null || _character.IsDead())
			{
				return true;
			}
			if ((Object)(object)_nview == (Object)null || !_nview.IsValid())
			{
				return true;
			}
			Vector3 val = ((Component)this).transform.position - _zoneCenter;
			float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
			bool flag = sqrMagnitude > _sqrZoneRadius;
			bool flag2 = sqrMagnitude < _sqrSafeDistance;
			if (_isOutsideZone)
			{
				if (!flag2)
				{
					MonsterAIHelper.MoveTo(_ai, dt, _patrolTarget);
					return false;
				}
				_isOutsideZone = false;
				MonsterAIHelper.StopMoving(_ai);
				return true;
			}
			if (flag)
			{
				_isOutsideZone = true;
				_currentSafeThreshold = Random.Range(0.7f, 0.95f);
				UpdateSqrSafeDistance();
				_ai.SetFollowTarget((GameObject)null);
				MonsterAIHelper.ClearTarget(_ai);
				MonsterAIHelper.SetAlerted(_ai, alerted: false);
				MonsterAIHelper.MoveTo(_ai, dt, _patrolTarget);
				return false;
			}
			return true;
		}
	}
	public static class ZoneMinionCleanup
	{
		[HarmonyPatch(typeof(ZNet), "Start")]
		public static class ZNet_Start_Patch
		{
			private static void Postfix(ZNet __instance)
			{
				((MonoBehaviour)__instance).StartCoroutine(RunCleanup());
			}
		}

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

			private object <>2__current;

			public double delay;

			public ZDO zdo;

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

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

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

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

			private bool MoveNext()
			{
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0029: Expected O, but got Unknown
				//IL_0055: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds((float)delay);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (ZDOMan.instance == null || zdo == null)
					{
						return false;
					}
					GroundZonePlugin.LogDebug($"[ZoneMinionCleanup] DelayedDestroy running uid={zdo.m_uid}");
					DestroyMinion(zdo);
					return false;
				}
			}

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

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

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

			private object <>2__current;

			private float <timeout>5__2;

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

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

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

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

			private bool MoveNext()
			{
				//IL_007f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0089: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<timeout>5__2 = 0f;
					goto IL_005c;
				case 1:
					<>1__state = -1;
					goto IL_005c;
				case 2:
					<>1__state = -1;
					<>2__current = ScanAndClean();
					<>1__state = 3;
					return true;
				case 3:
					{
						<>1__state = -1;
						return false;
					}
					IL_005c:
					if (ZDOMan.instance == null && <timeout>5__2 < 30f)
					{
						<timeout>5__2 += Time.deltaTime;
						<>2__current = null;
						<>1__state = 1;
						return true;
					}
					if (ZDOMan.instance == null)
					{
						return false;
					}
					<>2__current = (object)new WaitForSeconds(3f);
					<>1__state = 2;
					return true;
				}
			}

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

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

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

			private object <>2__current;

			private double <now>5__2;

			private Dictionary<ZDOID, ZDO> <dict>5__3;

			private int <removed>5__4;

			private int <found>5__5;

			private List<ZDO> <toDestroy>5__6;

			private List<(ZDO zdo, double delay)> <toDelayedDestroy>5__7;

			private List<ZDOID>.Enumerator <>7__wrap7;

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

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

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

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				int num = <>1__state;
				if (num == -3 || num == 1)
				{
					try
					{
					}
					finally
					{
						<>m__Finally1();
					}
				}
				<dict>5__3 = null;
				<toDestroy>5__6 = null;
				<toDelayedDestroy>5__7 = null;
				<>7__wrap7 = default(List<ZDOID>.Enumerator);
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0141: Unknown result type (might be due to invalid IL or missing references)
				//IL_0146: Unknown result type (might be due to invalid IL or missing references)
				//IL_014e: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b3: 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)
				try
				{
					switch (<>1__state)
					{
					default:
						return false;
					case 0:
					{
						<>1__state = -1;
						if ((Object)(object)ZNet.instance == (Object)null || ZDOMan.instance == null)
						{
							return false;
						}
						<now>5__2 = ZNet.instance.GetTimeSeconds();
						GroundZonePlugin.LogDebug($"[ZoneMinionCleanup] Scanning. Time: {<now>5__2:F0}");
						FieldInfo field = typeof(ZDOMan).GetField("m_objectsByID", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
						if (field == null)
						{
							GroundZonePlugin.Log.LogError((object)"[ZoneMinionCleanup] Field m_objectsByID not found!");
							return false;
						}
						<dict>5__3 = field.GetValue(ZDOMan.instance) as Dictionary<ZDOID, ZDO>;
						if (<dict>5__3 == null)
						{
							GroundZonePlugin.Log.LogError((object)"[ZoneMinionCleanup] m_objectsByID == null");
							return false;
						}
						GroundZonePlugin.LogDebug($"[ZoneMinionCleanup] Total ZDOs: {<dict>5__3.Count}");
						<removed>5__4 = 0;
						<found>5__5 = 0;
						<toDestroy>5__6 = new List<ZDO>();
						<toDelayedDestroy>5__7 = new List<(ZDO, double)>();
						List<ZDOID> list = new List<ZDOID>(<dict>5__3.Keys);
						<>7__wrap7 = list.GetEnumerator();
						<>1__state = -3;
						break;
					}
					case 1:
						<>1__state = -3;
						break;
					}
					while (<>7__wrap7.MoveNext())
					{
						ZDOID current = <>7__wrap7.Current;
						if (<dict>5__3.TryGetValue(current, out var value) && value != null && value.GetLong(GroundZone.ZDO_OWNER, 0L) != 0L)
						{
							double num = (double)value.GetLong(GroundZone.ZDO_EXPIRES, 0L) / 1000.0;
							double num2 = num - <now>5__2;
							<found>5__5++;
							GroundZonePlugin.LogDebug($"[ZoneMinionCleanup] find uid={current}, expires={num:F0}, "