Decompiled source of RideOnTroll v1.0.2

RideOnTroll.dll

Decompiled 14 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using GUIFramework;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using TMPro;
using TrollBuildingMod;
using TrollTamerMod;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Rendering;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("RideOnTroll")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+d26daa67307e106ea0bec841fa024f03f366b5b5")]
[assembly: AssemblyProduct("RideOnTroll")]
[assembly: AssemblyTitle("RideOnTroll")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace TrollTamerMod
{
	public enum GatherType
	{
		None,
		Wood,
		FineWood,
		CoreWood,
		Stone,
		Copper
	}
	public static class TrollMenuState
	{
		public static bool IsOpen;

		public static ZDOID TrollID;

		internal static bool RouteBypass;
	}
	internal static class TrollResourceMatcher
	{
		private static readonly Dictionary<string, string[]> s_dropCache = new Dictionary<string, string[]>();

		private static readonly Dictionary<string, bool> s_matchCache = new Dictionary<string, bool>();

		private static readonly Type s_treeLogType = FindTypeByName("TreeLog");

		private static readonly Type s_treeSyncType = FindTypeByName("TreeSync");

		private static readonly HashSet<string> FallbackWood = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
		{
			"Beech1", "Beech_small1", "Beech_small2", "Beech_Stub", "beech_log", "beech_log_half", "BirchStub", "OakStub", "Pinetree_01", "Pinetree_01_Stub",
			"PineTree_log", "PineTree_log_half", "FirTree", "FirTree_small", "FirTree_small_dead", "FirTree_Stub", "FirTree_log", "FirTree_log_half", "AshlandsTreeStump1", "AshlandsTreeStump2",
			"AshlandsTreeStump3"
		};

		private static readonly HashSet<string> FallbackFine = new HashSet<string>(StringComparer.OrdinalIgnoreCase) { "Birch1", "Birch1_aut", "Birch2", "Birch2_aut", "Birch_log", "Birch_log_half", "Oak1" };

		private static readonly HashSet<string> FallbackCore = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
		{
			"Pinetree_01", "Pinetree_01_Stub", "PineTree_log", "PineTree_log_half", "FirTree", "FirTree_Stub", "FirTree_log", "FirTree_log_half", "FirTree_big", "FirTree_Big_log",
			"FirTree_big_log_half", "FirTree_Big_plantable_Stub"
		};

		private static readonly HashSet<string> FallbackStone = new HashSet<string>(StringComparer.OrdinalIgnoreCase)
		{
			"rock1_mountain", "rock2_heath", "rock2_mountain", "rock3_mountain", "rock4_coast", "rock4_forest", "rock4_heath", "MineRock_Stone", "Rock_3", "Rock_4",
			"Rock_4_plains", "Rock_7", "BigRock", "rock_mistlands1"
		};

		public static void ClearCache()
		{
			s_matchCache.Clear();
			s_dropCache.Clear();
		}

		private static Type FindTypeByName(string name)
		{
			try
			{
				Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
				foreach (Assembly assembly in assemblies)
				{
					Type type = assembly.GetType(name, throwOnError: false);
					if (type != null && typeof(MonoBehaviour).IsAssignableFrom(type))
					{
						return type;
					}
				}
			}
			catch
			{
			}
			return null;
		}

		public static string ItemTokenFor(GatherType type)
		{
			return type switch
			{
				GatherType.Wood => "$item_wood", 
				GatherType.FineWood => "$item_finewood", 
				GatherType.CoreWood => "$item_corewood", 
				GatherType.Stone => "$item_stone", 
				GatherType.Copper => "$item_copperore", 
				_ => "", 
			};
		}

		public static MonoBehaviour FindDestructible(Collider c)
		{
			Component componentInParent = (Component)(object)((Component)c).GetComponentInParent<TreeBase>();
			if ((Object)(object)componentInParent == (Object)null && s_treeLogType != null)
			{
				componentInParent = ((Component)c).GetComponentInParent(s_treeLogType);
			}
			if ((Object)(object)componentInParent == (Object)null && s_treeSyncType != null)
			{
				componentInParent = ((Component)c).GetComponentInParent(s_treeSyncType);
			}
			if ((Object)(object)componentInParent == (Object)null)
			{
				componentInParent = (Component)(object)((Component)c).GetComponentInParent<MineRock>();
			}
			if ((Object)(object)componentInParent == (Object)null)
			{
				componentInParent = (Component)(object)((Component)c).GetComponentInParent<MineRock5>();
			}
			if ((Object)(object)componentInParent == (Object)null)
			{
				componentInParent = (Component)(object)((Component)c).GetComponentInParent<Destructible>();
			}
			MonoBehaviour val = (MonoBehaviour)(object)((componentInParent is MonoBehaviour) ? componentInParent : null);
			if (val != null && componentInParent is IDestructible)
			{
				return val;
			}
			return null;
		}

		public static string GetRootPrefabName(Component c)
		{
			try
			{
				ZNetView componentInParent = c.GetComponentInParent<ZNetView>();
				if ((Object)(object)componentInParent != (Object)null && componentInParent.IsValid() && componentInParent.GetZDO() != null && (Object)(object)ZNetScene.instance != (Object)null)
				{
					GameObject prefab = ZNetScene.instance.GetPrefab(componentInParent.GetZDO().GetPrefab());
					if ((Object)(object)prefab != (Object)null)
					{
						return ((Object)prefab).name;
					}
				}
			}
			catch
			{
			}
			return Utils.GetPrefabName(c.gameObject);
		}

		public static bool TargetMatches(MonoBehaviour destr, GatherType type)
		{
			try
			{
				string text = GetRootPrefabName((Component)(object)destr) ?? "";
				int num = (int)type;
				string key = num + "|" + text;
				if (s_matchCache.TryGetValue(key, out var value))
				{
					return value;
				}
				bool flag = ComputeMatch(destr, text, type);
				s_matchCache[key] = flag;
				return flag;
			}
			catch
			{
				return false;
			}
		}

		private static bool ComputeMatch(MonoBehaviour destr, string prefab, GatherType type)
		{
			string text = ItemTokenFor(type);
			if (string.IsNullOrEmpty(text))
			{
				return false;
			}
			string[] dropNames = GetDropNames(prefab, destr);
			if (dropNames != null)
			{
				string[] array = dropNames;
				foreach (string a in array)
				{
					if (string.Equals(a, text, StringComparison.OrdinalIgnoreCase))
					{
						return true;
					}
				}
			}
			if (FallbackNameMatch(prefab, type))
			{
				return true;
			}
			return FallbackByDamageType(destr, type);
		}

		private static string[] GetDropNames(string prefab, MonoBehaviour sample)
		{
			if (s_dropCache.ContainsKey(prefab))
			{
				return s_dropCache[prefab];
			}
			HashSet<string> hashSet = new HashSet<string>();
			HashSet<object> visited = new HashSet<object>();
			try
			{
				DropOnDestroyed[] componentsInChildren = ((Component)sample).GetComponentsInChildren<DropOnDestroyed>(true);
				foreach (DropOnDestroyed val in componentsInChildren)
				{
					CollectFromValue(val, hashSet, visited, 0);
				}
				CollectFromValue(sample, hashSet, visited, 0);
			}
			catch (Exception)
			{
			}
			string[] array = ((hashSet.Count > 0) ? hashSet.ToArray() : null);
			s_dropCache[prefab] = array;
			return array;
		}

		private static void CollectFromValue(object val, HashSet<string> names, HashSet<object> visited, int depth)
		{
			if (val == null || depth > 5 || names.Count > 32)
			{
				return;
			}
			ItemDrop val2 = (ItemDrop)((val is ItemDrop) ? val : null);
			if (val2 != null)
			{
				if (val2.m_itemData != null && val2.m_itemData.m_shared != null)
				{
					names.Add(val2.m_itemData.m_shared.m_name);
				}
				return;
			}
			GameObject val3 = (GameObject)((val is GameObject) ? val : null);
			if (val3 != null)
			{
				ItemDrop component = val3.GetComponent<ItemDrop>();
				if ((Object)(object)component != (Object)null && component.m_itemData != null && component.m_itemData.m_shared != null)
				{
					names.Add(component.m_itemData.m_shared.m_name);
				}
			}
			else
			{
				if (depth > 0 && val is Object)
				{
					return;
				}
				Type type = val.GetType();
				if (type.IsPrimitive || type == typeof(string) || type.IsEnum || (!type.IsValueType && !visited.Add(val)))
				{
					return;
				}
				if (val is IEnumerable enumerable)
				{
					{
						foreach (object item in enumerable)
						{
							CollectFromValue(item, names, visited, depth + 1);
						}
						return;
					}
				}
				FieldInfo[] fields = type.GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				foreach (FieldInfo fieldInfo in fields)
				{
					if (names.Count > 32)
					{
						break;
					}
					try
					{
						CollectFromValue(fieldInfo.GetValue(val), names, visited, depth + 1);
					}
					catch
					{
					}
				}
			}
		}

		private static bool WorksOn(DamageModifier m)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Invalid comparison between Unknown and I4
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Invalid comparison between Unknown and I4
			return (int)m != 3 && (int)m != 4;
		}

		private static bool FallbackByDamageType(MonoBehaviour destr, GatherType type)
		{
			//IL_001e: 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)
			Destructible val = (Destructible)(object)((destr is Destructible) ? destr : null);
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			bool flag = WorksOn(val.m_damages.m_chop);
			bool flag2 = WorksOn(val.m_damages.m_pickaxe);
			return type switch
			{
				GatherType.Wood => flag, 
				GatherType.Stone => flag2 && !flag, 
				_ => false, 
			};
		}

		private static bool FallbackNameMatch(string prefab, GatherType type)
		{
			if (string.IsNullOrEmpty(prefab))
			{
				return false;
			}
			return type switch
			{
				GatherType.Wood => FallbackWood.Contains(prefab), 
				GatherType.FineWood => FallbackFine.Contains(prefab), 
				GatherType.CoreWood => FallbackCore.Contains(prefab), 
				GatherType.Stone => FallbackStone.Contains(prefab) || prefab.IndexOf("rock", StringComparison.OrdinalIgnoreCase) >= 0, 
				GatherType.Copper => prefab.IndexOf("copper", StringComparison.OrdinalIgnoreCase) >= 0, 
				_ => false, 
			};
		}
	}
	public class TrollGatherController : MonoBehaviour
	{
		private Character m_character;

		private ZNetView m_nview;

		private MonsterAI m_ai;

		private ZSyncAnimation m_zanim;

		public const string ZDO_GATHER_KEY = "TrollGather_Type";

		public static readonly int HashGatherKey = StringExtensionMethods.GetStableHashCode("TrollGather_Type");

		private MonoBehaviour m_target;

		private Collider[] m_targetCols;

		private Vector3 m_surfacePoint;

		private Vector3 m_hitDir = Vector3.forward;

		private GatherType m_type;

		private float m_searchCooldown;

		private float m_attackTimer;

		private float m_colsRefreshTimer;

		private float m_noSurfaceTime;

		private int m_searchFailCount;

		private int m_abandonCount;

		private bool m_hitThisTarget;

		private float m_progressCheckTimer;

		private float m_lastSurfaceDist = float.MaxValue;

		private int m_noProgressCount;

		private int m_drySwings;

		private float m_lastMsgTime = -30f;

		private bool m_hasCellCols;

		private int m_orbitDir;

		private int m_orbitSteps;

		private float m_orbitStepTimer;

		private const float OrbitStandoff = 2.2f;

		private const float OrbitStepTime = 1.2f;

		private const int MaxOrbitSteps = 10;

		private const float SearchCooldown = 2f;

		private const float SearchRadius = 60f;

		private const float AttackRange = 3.2f;

		private const float AttackInterval = 1.4f;

		private const float AttackDamage = 140f;

		private const int AttackToolTier = 4;

		private const float SwingPointInward = 0.3f;

		private const float SweepRadius = 1.6f;

		private const int MaxSweepTargets = 3;

		private const float ProgressWindow = 4f;

		private const float ProgressMinGain = 1f;

		private const int MaxAbandons = 6;

		private const int MaxSearchFails = 8;

		private const float BlacklistTime = 60f;

		private const float BlacklistRadius = 2.5f;

		private const float ChestHeight = 2.2f;

		private const int VeinDrySwings = 8;

		private const int GenericDrySwings = 25;

		private static readonly Dictionary<ZDOID, float> s_exhaustedIds = new Dictionary<ZDOID, float>();

		private static readonly List<Vector3> s_exhaustedFallbackPos = new List<Vector3>();

		private static readonly List<float> s_exhaustedFallbackTime = new List<float>();

		private const float ExhaustedMemory = 600f;

		private const float ExhaustedFallbackRadius = 1.5f;

		private static readonly int s_searchMask = LayerMask.GetMask(new string[5] { "Default", "static_solid", "Default_small", "piece", "terrain" });

		private static readonly Collider[] s_overlap = (Collider[])(object)new Collider[2048];

		private static readonly Collider[] s_sweep = (Collider[])(object)new Collider[48];

		private static readonly MethodInfo s_moveTo = AccessTools.Method(typeof(BaseAI), "MoveTo", (Type[])null, (Type[])null);

		private static readonly MethodInfo s_lookAt = AccessTools.Method(typeof(BaseAI), "LookAt", (Type[])null, (Type[])null);

		private static readonly MethodInfo s_havePath = AccessTools.Method(typeof(BaseAI), "HavePath", (Type[])null, (Type[])null);

		private static readonly MethodInfo s_wakeup = AccessTools.Method(typeof(MonsterAI), "Wakeup", (Type[])null, (Type[])null);

		internal static bool IsApplyingDamage;

		private readonly List<Vector3> m_blackPos = new List<Vector3>();

		private readonly List<float> m_blackTime = new List<float>();

		internal bool IsAttackingTarget(GameObject go)
		{
			return (Object)(object)m_target != (Object)null && (Object)(object)go != (Object)null && (Object)(object)((Component)m_target).gameObject == (Object)(object)go;
		}

		private void Awake()
		{
			m_character = ((Component)this).GetComponent<Character>();
			m_nview = ((Component)this).GetComponent<ZNetView>();
			m_ai = ((Component)this).GetComponent<MonsterAI>();
			m_zanim = ((Component)this).GetComponent<ZSyncAnimation>();
		}

		private void Update()
		{
			try
			{
				Tick(Time.deltaTime);
			}
			catch (Exception)
			{
			}
		}

		private float PlatformProtrusion()
		{
			try
			{
				TrollPiecesContainer component = ((Component)this).GetComponent<TrollPiecesContainer>();
				if ((Object)(object)component == (Object)null || component.PieceCount == 0)
				{
					return 0f;
				}
				return Mathf.Clamp(component.Navigator.FootprintRadius - 1.8f, 0f, 3f);
			}
			catch
			{
				return 0f;
			}
		}

		private void Tick(float dt)
		{
			//IL_05c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05c7: 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_05f6: 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_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0779: Unknown result type (might be due to invalid IL or missing references)
			//IL_0780: Unknown result type (might be due to invalid IL or missing references)
			//IL_0785: Unknown result type (might be due to invalid IL or missing references)
			//IL_078a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_07b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_033d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c8: 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_0445: Unknown result type (might be due to invalid IL or missing references)
			//IL_0446: Unknown result type (might be due to invalid IL or missing references)
			//IL_0448: 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_03e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0470: Unknown result type (might be due to invalid IL or missing references)
			//IL_0472: Unknown result type (might be due to invalid IL or missing references)
			//IL_0474: 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_0414: Unknown result type (might be due to invalid IL or missing references)
			//IL_040b: Unknown result type (might be due to invalid IL or missing references)
			//IL_04bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_0421: Unknown result type (might be due to invalid IL or missing references)
			//IL_0546: Unknown result type (might be due to invalid IL or missing references)
			//IL_0547: Unknown result type (might be due to invalid IL or missing references)
			//IL_054b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0550: Unknown result type (might be due to invalid IL or missing references)
			//IL_0555: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_04ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_0558: Unknown result type (might be due to invalid IL or missing references)
			//IL_055a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0523: Unknown result type (might be due to invalid IL or missing references)
			//IL_0524: Unknown result type (might be due to invalid IL or missing references)
			//IL_052d: Unknown result type (might be due to invalid IL or missing references)
			//IL_052f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0536: Unknown result type (might be due to invalid IL or missing references)
			//IL_053b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0540: Unknown result type (might be due to invalid IL or missing references)
			//IL_0514: Unknown result type (might be due to invalid IL or missing references)
			//IL_0519: Unknown result type (might be due to invalid IL or missing references)
			//IL_063c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0649: Unknown result type (might be due to invalid IL or missing references)
			//IL_0673: Unknown result type (might be due to invalid IL or missing references)
			//IL_0664: Unknown result type (might be due to invalid IL or missing references)
			//IL_0666: Unknown result type (might be due to invalid IL or missing references)
			//IL_066b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0599: Unknown result type (might be due to invalid IL or missing references)
			//IL_070a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)m_nview == (Object)null || !m_nview.IsValid() || !m_nview.IsOwner())
			{
				return;
			}
			if ((Object)(object)m_character == (Object)null || m_character.IsDead())
			{
				StopGather();
			}
			else
			{
				if (TrollTamePatches.IsFrozenTroll(m_character))
				{
					return;
				}
				int num = m_nview.GetZDO().GetInt(HashGatherKey, 0);
				if (num <= 0)
				{
					StopGather();
					return;
				}
				m_type = (GatherType)num;
				if ((Object)(object)m_ai != (Object)null && ((Object)(object)((BaseAI)m_ai).GetTargetCreature() != (Object)null || (Object)(object)m_ai.GetStaticTarget() != (Object)null))
				{
					return;
				}
				if ((Object)(object)m_ai != (Object)null && ((BaseAI)m_ai).IsSleeping())
				{
					try
					{
						s_wakeup?.Invoke(m_ai, null);
						return;
					}
					catch
					{
						return;
					}
				}
				if (!((Object)(object)m_target != (Object)null) || !((Component)m_target).gameObject.activeInHierarchy)
				{
					m_target = null;
					m_targetCols = null;
					m_lastSurfaceDist = float.MaxValue;
					if (m_searchCooldown > 0f)
					{
						m_searchCooldown -= dt;
						MonsterAI ai = m_ai;
						if (ai != null)
						{
							((BaseAI)ai).StopMoving();
						}
					}
					else
					{
						m_searchCooldown = 2f;
						FindTarget(m_type);
					}
					return;
				}
				Vector3 point;
				float dist;
				bool flag = ComputeSurfaceInfo(out point, out dist);
				m_surfacePoint = point;
				if (!flag)
				{
					m_noSurfaceTime += dt;
					if (m_noSurfaceTime > 2f)
					{
						if (m_target is MineRock || m_target is MineRock5)
						{
							BlacklistPosition(((Component)m_target).transform.position);
							MarkExhausted(m_target);
							Notify(TrollWalkLoc.T("Vein depleted: accessible parts mined out, the rest is buried", "Жила выработана: доступные части разобраны, остатки под землёй", "Жилу вичерпано: доступні частини розібрано, решта під землею", "Veta agotada: partes accesibles extraídas, el resto está enterrado"));
						}
						m_target = null;
						m_targetCols = null;
						m_searchCooldown = 0f;
						return;
					}
				}
				else
				{
					m_noSurfaceTime = 0f;
				}
				float num2 = 3.2f + PlatformProtrusion();
				if (!flag || dist > num2)
				{
					m_attackTimer = 0f;
					if (!((Object)(object)m_ai != (Object)null))
					{
						return;
					}
					bool flag2 = m_target is MineRock || m_target is MineRock5;
					Vector3 position = ((Component)this).transform.position;
					Vector3 position2 = ((Component)m_target).transform.position;
					bool flag3 = Utils.DistanceXZ(position2, position) > 20f;
					if (!flag)
					{
						try
						{
							s_moveTo?.Invoke(m_ai, new object[4] { dt, position2, 2f, flag3 });
							return;
						}
						catch
						{
							return;
						}
					}
					if (flag2 && position.y > point.y + 1.2f && Utils.DistanceXZ(position, position2) < 7f)
					{
						Vector3 val = position - position2;
						val.y = 0f;
						Vector3 val2 = ((((Vector3)(ref val)).sqrMagnitude > 0.01f) ? ((Vector3)(ref val)).normalized : ((Component)this).transform.forward);
						((BaseAI)m_ai).MoveTowards(val2, false);
						m_lastSurfaceDist = float.MaxValue;
						m_progressCheckTimer = 0f;
						return;
					}
					Vector3 val3 = point - position2;
					val3.y = 0f;
					if (((Vector3)(ref val3)).sqrMagnitude < 0.01f)
					{
						val3 = position - position2;
						val3.y = 0f;
					}
					if (((Vector3)(ref val3)).sqrMagnitude < 0.01f)
					{
						val3 = ((Component)this).transform.forward;
					}
					((Vector3)(ref val3)).Normalize();
					float num3 = 2.2f + PlatformProtrusion();
					Vector3 val5;
					if (Utils.DistanceXZ(point, position) > Utils.DistanceXZ(position2, position) + 0.5f)
					{
						Vector3 val4 = position - position2;
						val4.y = 0f;
						if (((Vector3)(ref val4)).sqrMagnitude < 0.01f)
						{
							val4 = ((Component)this).transform.forward;
						}
						((Vector3)(ref val4)).Normalize();
						float num4 = Utils.DistanceXZ(point, position2);
						val5 = position2 + val4 * (num4 + num3);
					}
					else
					{
						val5 = point + val3 * num3;
					}
					float num5 = Utils.DistanceXZ(val5, position);
					if (num5 > 1.3f)
					{
						try
						{
							s_moveTo?.Invoke(m_ai, new object[4] { dt, val5, 0.9f, flag3 });
						}
						catch
						{
							Vector3 val6 = val5 - position;
							val6.y = 0f;
							if (((Vector3)(ref val6)).sqrMagnitude > 0.01f)
							{
								((BaseAI)m_ai).MoveTowards(((Vector3)(ref val6)).normalized, flag3);
							}
						}
						TrackProgress(num5, dt);
						return;
					}
					if (m_orbitDir == 0)
					{
						m_orbitDir = ((Random.value < 0.5f) ? 1 : (-1));
					}
					Vector3 val7 = default(Vector3);
					((Vector3)(ref val7))..ctor(0f - val3.z, 0f, val3.x);
					if (m_orbitDir < 0)
					{
						val7 = -val7;
					}
					((BaseAI)m_ai).MoveTowards(val7, false);
					m_lastSurfaceDist = float.MaxValue;
					m_progressCheckTimer = 0f;
					m_orbitStepTimer += dt;
					if (!(m_orbitStepTimer >= 1.2f))
					{
						return;
					}
					m_orbitStepTimer = 0f;
					m_orbitSteps++;
					if (m_orbitSteps > 10)
					{
						m_orbitSteps = 0;
						m_orbitDir = -m_orbitDir;
						m_abandonCount++;
						BlacklistPosition(position2);
						m_target = null;
						m_targetCols = null;
						m_searchCooldown = 0f;
						if (m_abandonCount >= 6)
						{
							Notify(TrollWalkLoc.T("The troll cannot reach the resources", "Тролль не может добраться до ресурсов", "Троль не може дістатися до ресурсів", "El trol no puede alcanzar los recursos"));
							StopGather();
						}
					}
					return;
				}
				m_orbitStepTimer = 0f;
				Vector3 hitDir = point - ((Component)this).transform.position;
				hitDir.y = 0f;
				if (((Vector3)(ref hitDir)).sqrMagnitude > 0.01f)
				{
					((Vector3)(ref hitDir)).Normalize();
					m_hitDir = hitDir;
					try
					{
						s_lookAt?.Invoke(m_ai, new object[1] { point });
					}
					catch
					{
					}
				}
				MonsterAI ai2 = m_ai;
				if (ai2 != null)
				{
					((BaseAI)ai2).StopMoving();
				}
				m_attackTimer += dt;
				if (m_attackTimer >= 1.4f)
				{
					m_attackTimer = 0f;
					PerformSwing();
				}
			}
		}

		private static bool IsCellUnderground(Collider c)
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: 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_002d: 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)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: 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_00a7: 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_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)c == (Object)null)
			{
				return false;
			}
			Bounds bounds = c.bounds;
			float x = ((Bounds)(ref bounds)).center.x;
			bounds = c.bounds;
			float y = ((Bounds)(ref bounds)).max.y;
			bounds = c.bounds;
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(x, y, ((Bounds)(ref bounds)).center.z);
			int mask = LayerMask.GetMask(new string[1] { "terrain" });
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(val + Vector3.up * 12f, Vector3.down, ref val2, 24f, mask))
			{
				float y2 = ((RaycastHit)(ref val2)).point.y;
				bounds = c.bounds;
				return y2 > ((Bounds)(ref bounds)).max.y + 0.1f;
			}
			if ((Object)(object)ZoneSystem.instance != (Object)null)
			{
				ZoneSystem instance = ZoneSystem.instance;
				bounds = c.bounds;
				float num = default(float);
				if (instance.GetGroundHeight(((Bounds)(ref bounds)).center, ref num))
				{
					bounds = c.bounds;
					return ((Bounds)(ref bounds)).max.y < num - 0.15f;
				}
			}
			return false;
		}

		private static bool HasExposedSurfaces(MonoBehaviour destr)
		{
			if (!(destr is MineRock) && !(destr is MineRock5))
			{
				return true;
			}
			Collider[] componentsInChildren = ((Component)destr).GetComponentsInChildren<Collider>(false);
			if (componentsInChildren == null || componentsInChildren.Length == 0)
			{
				return false;
			}
			bool flag = false;
			foreach (Collider val in componentsInChildren)
			{
				if (!((Object)(object)val == (Object)null) && val.enabled && !val.isTrigger && ((Object)((Component)val).gameObject).name.IndexOf("_cell", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					flag = true;
					if (!IsCellUnderground(val))
					{
						return true;
					}
				}
			}
			if (flag)
			{
				return false;
			}
			foreach (Collider val2 in componentsInChildren)
			{
				if (!((Object)(object)val2 == (Object)null) && val2.enabled && !val2.isTrigger && !IsCellUnderground(val2))
				{
					return true;
				}
			}
			return false;
		}

		private bool ComputeSurfaceInfo(out Vector3 point, out float dist)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02af: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_032b: 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_0338: Unknown result type (might be due to invalid IL or missing references)
			//IL_033f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0381: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_036b: Unknown result type (might be due to invalid IL or missing references)
			//IL_036d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0303: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: 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_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_0297: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: 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_028d: Unknown result type (might be due to invalid IL or missing references)
			point = ((Component)m_target).transform.position;
			dist = float.MaxValue;
			m_colsRefreshTimer -= Time.deltaTime;
			if (m_targetCols == null || m_targetCols.Length == 0 || m_colsRefreshTimer <= 0f)
			{
				m_targetCols = ((Component)m_target).GetComponentsInChildren<Collider>(true);
				m_colsRefreshTimer = 3f;
				m_hasCellCols = ScanCellCols();
			}
			Vector3 val = ((Component)this).transform.position + Vector3.up * 2.2f;
			bool flag = m_target is MineRock || m_target is MineRock5;
			Vector3 val2 = Vector3.zero;
			Vector3 val3 = Vector3.zero;
			float num = float.MaxValue;
			float num2 = float.MaxValue;
			RaycastHit val7 = default(RaycastHit);
			float num3 = default(float);
			for (int i = 0; i < m_targetCols.Length; i++)
			{
				Collider val4 = m_targetCols[i];
				if ((Object)(object)val4 == (Object)null || !val4.enabled || !((Component)val4).gameObject.activeInHierarchy || val4.isTrigger || (m_hasCellCols && ((Object)((Component)val4).gameObject).name.IndexOf("_cell", StringComparison.OrdinalIgnoreCase) < 0) || (flag && IsCellUnderground(val4)))
				{
					continue;
				}
				MeshCollider val5 = (MeshCollider)(object)((val4 is MeshCollider) ? val4 : null);
				Bounds bounds;
				Vector3 val8;
				if ((Object)(object)val5 != (Object)null && !val5.convex)
				{
					bounds = ((Collider)val5).bounds;
					Vector3 center = ((Bounds)(ref bounds)).center;
					float y = val.y;
					bounds = ((Collider)val5).bounds;
					float y2 = ((Bounds)(ref bounds)).min.y;
					bounds = ((Collider)val5).bounds;
					center.y = Mathf.Clamp(y, y2, ((Bounds)(ref bounds)).max.y);
					Vector3 val6 = center - val;
					if (((Vector3)(ref val6)).sqrMagnitude < 0.04f || !Physics.Raycast(val, ((Vector3)(ref val6)).normalized, ref val7, ((Vector3)(ref val6)).magnitude + 1.5f, s_searchMask, (QueryTriggerInteraction)2) || ((Object)(object)((RaycastHit)(ref val7)).transform.root != (Object)(object)((Component)m_target).transform.root && !((RaycastHit)(ref val7)).transform.IsChildOf(((Component)m_target).transform)))
					{
						continue;
					}
					val8 = ((RaycastHit)(ref val7)).point;
				}
				else
				{
					try
					{
						val8 = val4.ClosestPoint(val);
					}
					catch
					{
						bounds = val4.bounds;
						val8 = ((Bounds)(ref bounds)).ClosestPoint(val);
					}
				}
				if (flag && (Object)(object)ZoneSystem.instance != (Object)null && ZoneSystem.instance.GetGroundHeight(val8, ref num3))
				{
					if (val8.y < num3 - 0.35f)
					{
						continue;
					}
					if (val8.y < num3 + 0.15f)
					{
						val8.y = num3 + 0.15f;
					}
				}
				float num4 = Vector3.Distance(val8, val);
				if ((!flag || val8.y <= val.y + 2f) && num4 < num)
				{
					num = num4;
					val2 = val8;
				}
				if (num4 < num2)
				{
					num2 = num4;
					val3 = val8;
				}
			}
			if (num < float.MaxValue)
			{
				dist = num;
				point = val2;
				return true;
			}
			if (num2 < float.MaxValue)
			{
				dist = num2;
				point = val3;
				return true;
			}
			return false;
		}

		private bool ScanCellCols()
		{
			if (m_targetCols == null)
			{
				return false;
			}
			for (int i = 0; i < m_targetCols.Length; i++)
			{
				Collider val = m_targetCols[i];
				if (!((Object)(object)val == (Object)null) && ((Object)((Component)val).gameObject).name.IndexOf("_cell", StringComparison.OrdinalIgnoreCase) >= 0)
				{
					return true;
				}
			}
			return false;
		}

		private int CountVeinCells()
		{
			if (m_targetCols == null)
			{
				return 0;
			}
			int num = 0;
			for (int i = 0; i < m_targetCols.Length; i++)
			{
				Collider val = m_targetCols[i];
				if (!((Object)(object)val == (Object)null) && ((Object)((Component)val).gameObject).name.IndexOf("_cell", StringComparison.OrdinalIgnoreCase) >= 0 && ((Component)val).gameObject.activeInHierarchy && val.enabled && !val.isTrigger)
				{
					num++;
				}
			}
			return num;
		}

		private void FindTarget(GatherType type)
		{
			//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_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_0027: 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_00e5: 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_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: 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_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			CleanupBlacklist();
			Vector3 val = ((Component)this).transform.position + Vector3.up * 2f;
			int num = Physics.OverlapSphereNonAlloc(val, 60f, s_overlap, s_searchMask, (QueryTriggerInteraction)2);
			MonoBehaviour val2 = null;
			float num2 = float.MaxValue;
			HashSet<Object> hashSet = new HashSet<Object>();
			int num3 = 0;
			for (int i = 0; i < num; i++)
			{
				Collider val3 = s_overlap[i];
				if ((Object)(object)val3 == (Object)null)
				{
					continue;
				}
				MonoBehaviour val4 = TrollResourceMatcher.FindDestructible(val3);
				if ((Object)(object)val4 == (Object)null || !hashSet.Add((Object)(object)val4) || ((Component)val4).transform.IsChildOf(((Component)this).transform) || !TrollResourceMatcher.TargetMatches(val4, type) || IsBlacklisted(((Component)val4).transform.position) || IsExhausted(val4))
				{
					continue;
				}
				if (!HasExposedSurfaces(val4))
				{
					if (val4 is MineRock || val4 is MineRock5)
					{
						MarkExhausted(val4);
					}
					continue;
				}
				float num4 = Utils.DistanceXZ(((Component)val4).transform.position, ((Component)this).transform.position);
				if (num4 > 10f)
				{
					Vector3 val5 = ((Component)this).transform.position - ((Component)val4).transform.position;
					val5.y = 0f;
					Vector3 val6 = ((Component)val4).transform.position;
					if (((Vector3)(ref val5)).sqrMagnitude > 0.01f)
					{
						((Vector3)(ref val5)).Normalize();
						float num5 = ((val4 is MineRock || val4 is MineRock5) ? 2.5f : 2f);
						val6 += val5 * num5;
					}
					if (!HavePath(val6))
					{
						num3++;
						continue;
					}
				}
				if (num4 < num2)
				{
					num2 = num4;
					val2 = val4;
				}
			}
			if ((Object)(object)val2 != (Object)null)
			{
				m_target = val2;
				m_targetCols = null;
				m_colsRefreshTimer = 0f;
				m_lastSurfaceDist = float.MaxValue;
				m_progressCheckTimer = 0f;
				m_noProgressCount = 0;
				m_searchFailCount = 0;
				m_hitThisTarget = false;
				m_drySwings = 0;
				m_orbitSteps = 0;
				m_orbitStepTimer = 0f;
				m_orbitDir = 0;
			}
			else
			{
				m_searchFailCount++;
				m_searchCooldown = Mathf.Min(2f + (float)m_searchFailCount * 2f, 30f);
				if (m_searchFailCount >= 8)
				{
					Notify(TrollWalkLoc.T("No suitable resources nearby — the troll is waiting", "Рядом нет подходящих ресурсов — тролль ждёт", "Поруч немає відповідних ресурсів — троль чекає", "No hay recursos adecuados cerca — el trol está esperando"));
					m_searchFailCount = 4;
				}
			}
		}

		private bool HavePath(Vector3 pos)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)m_ai == (Object)null || s_havePath == null)
			{
				return true;
			}
			try
			{
				object obj = s_havePath.Invoke(m_ai, new object[1] { pos });
				if (obj == null)
				{
					return true;
				}
				return (bool)obj;
			}
			catch
			{
				return true;
			}
		}

		private void TrackProgress(float dist, float dt)
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			m_progressCheckTimer += dt;
			if (m_progressCheckTimer < 4f)
			{
				return;
			}
			m_progressCheckTimer = 0f;
			float num;
			if (!((Object)(object)m_character != (Object)null))
			{
				num = 0f;
			}
			else
			{
				Vector3 velocity = m_character.GetVelocity();
				num = ((Vector3)(ref velocity)).magnitude;
			}
			float num2 = num;
			float num3 = m_lastSurfaceDist - dist;
			if (m_lastSurfaceDist != float.MaxValue && num3 < 1f && num2 < 0.5f)
			{
				m_noProgressCount++;
				if (m_noProgressCount >= 2)
				{
					m_noProgressCount = 0;
					if ((m_target is MineRock || m_target is MineRock5) && m_hitThisTarget && HasExposedSurfaces(m_target))
					{
						m_progressCheckTimer = 0f;
						m_lastSurfaceDist = float.MaxValue;
						m_targetCols = null;
						m_colsRefreshTimer = 0f;
						return;
					}
					m_abandonCount++;
					BlacklistPosition(((Component)m_target).transform.position);
					m_target = null;
					m_targetCols = null;
					m_searchCooldown = 0f;
					if (m_abandonCount >= 6)
					{
						Notify(TrollWalkLoc.T("The troll cannot reach the resources", "Тролль не может добраться до ресурсов", "Троль не може дістатися до ресурсів", "El trol no puede alcanzar los recursos"));
						StopGather();
					}
				}
			}
			else
			{
				m_noProgressCount = 0;
			}
			m_lastSurfaceDist = dist;
		}

		private void PerformSwing()
		{
			//IL_00d0: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			MonoBehaviour target = m_target;
			if ((Object)(object)target == (Object)null || !((Component)target).gameObject.activeInHierarchy)
			{
				return;
			}
			bool flag = (target is MineRock || target is MineRock5) && m_hasCellCols;
			int num = (flag ? CountVeinCells() : (-1));
			bool flag2 = false;
			try
			{
				if (!m_character.InAttack())
				{
					flag2 = m_character.StartAttack((Character)null, false);
				}
			}
			catch
			{
			}
			if (!flag2 && !m_character.InAttack() && (Object)(object)m_zanim != (Object)null)
			{
				try
				{
					m_zanim.SetTrigger("attack");
				}
				catch
				{
				}
			}
			bool flag3 = ApplyDamage(target, m_surfacePoint, m_hitDir);
			if (flag3)
			{
				ApplySweep(target, m_surfacePoint, m_hitDir);
			}
			m_progressCheckTimer = 0f;
			m_lastSurfaceDist = float.MaxValue;
			m_noProgressCount = 0;
			m_colsRefreshTimer = 0f;
			if (flag)
			{
				if (num <= 0)
				{
					MarkExhausted(target);
					Notify(TrollWalkLoc.T("Vein depleted", "Жила выработана", "Жилу вичерпано", "Veta agotada"));
					m_target = null;
					m_targetCols = null;
					m_searchCooldown = 0f;
					return;
				}
				int num2 = CountVeinCells();
				if (num2 < num)
				{
					m_drySwings = 0;
					m_hitThisTarget = true;
					return;
				}
				m_drySwings++;
				if (m_drySwings >= 8)
				{
					ResolveStuckTarget(target, "замахи не дают эффекта");
				}
			}
			else
			{
				if (flag3)
				{
					m_hitThisTarget = true;
				}
				m_drySwings++;
				if (m_drySwings >= 25)
				{
					ResolveStuckTarget(target, "цель не разрушается");
				}
			}
		}

		private void ResolveStuckTarget(MonoBehaviour mb, string reason)
		{
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			m_drySwings = 0;
			m_targetCols = null;
			if ((mb is MineRock || mb is MineRock5) && !HasExposedSurfaces(mb))
			{
				MarkExhausted(mb);
				Notify(TrollWalkLoc.T("Vein depleted or unreachable — looking for the next one", "Жила выработана или недоступна — ищу следующую", "Жилу вичерпано або вона недоступна — шукаю наступну", "Veta agotada o inaccesible — buscando la siguiente"));
				m_target = null;
				m_searchCooldown = 0f;
				return;
			}
			m_abandonCount++;
			BlacklistPosition(((Component)mb).transform.position);
			m_target = null;
			m_searchCooldown = 0f;
			if (m_abandonCount >= 6)
			{
				Notify(TrollWalkLoc.T("The troll cannot reach the resources", "Тролль не может добраться до ресурсов", "Троль не може дістатися до ресурсів", "El trol no puede alcanzar los recursos"));
				StopGather();
			}
		}

		private bool ApplyDamage(MonoBehaviour mb, Vector3 point, Vector3 dir, Collider hitCollider = null)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//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_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: 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)
			if ((Object)(object)mb == (Object)null || !((Component)mb).gameObject.activeInHierarchy)
			{
				return false;
			}
			IDestructible val = (IDestructible)(object)((mb is IDestructible) ? mb : null);
			if (val == null)
			{
				return false;
			}
			try
			{
				HitData val2 = new HitData();
				val2.m_damage.m_damage = 140f;
				val2.m_damage.m_pickaxe = 140f;
				val2.m_damage.m_chop = 140f;
				val2.m_toolTier = 4;
				val2.SetAttacker(m_character);
				if (mb is MineRock || mb is MineRock5)
				{
					hitCollider = FindZoneCollider(mb, point);
				}
				if ((mb is MineRock || mb is MineRock5) && (Object)(object)hitCollider == (Object)null)
				{
					return false;
				}
				if ((Object)(object)hitCollider != (Object)null)
				{
					val2.m_hitCollider = hitCollider;
					Bounds bounds = hitCollider.bounds;
					val2.m_point = ((Bounds)(ref bounds)).center;
				}
				else
				{
					val2.m_point = point + dir * 0.3f + Vector3.up * 0.1f;
				}
				val2.m_dir = dir;
				val2.m_hitType = (HitType)1;
				IsApplyingDamage = true;
				try
				{
					val.Damage(val2);
				}
				finally
				{
					IsApplyingDamage = false;
				}
				return true;
			}
			catch (Exception)
			{
				return false;
			}
		}

		private Collider FindZoneCollider(MonoBehaviour target, Vector3 nearPoint)
		{
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: 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)
			if (m_targetCols == null || m_targetCols.Length == 0)
			{
				return null;
			}
			m_colsRefreshTimer -= Time.deltaTime;
			if (m_colsRefreshTimer <= 0f)
			{
				m_targetCols = ((Component)target).GetComponentsInChildren<Collider>(true);
				m_colsRefreshTimer = 3f;
				m_hasCellCols = ScanCellCols();
			}
			Collider result = null;
			float num = float.MaxValue;
			for (int i = 0; i < m_targetCols.Length; i++)
			{
				Collider val = m_targetCols[i];
				if (!((Object)(object)val == (Object)null) && val.enabled && ((Component)val).gameObject.activeInHierarchy && !val.isTrigger && (!m_hasCellCols || ((Object)((Component)val).gameObject).name.IndexOf("_cell", StringComparison.OrdinalIgnoreCase) >= 0) && !IsCellUnderground(val))
				{
					Bounds bounds = val.bounds;
					float num2 = Vector3.Distance(((Bounds)(ref bounds)).center, nearPoint);
					bounds = val.bounds;
					Vector3 size = ((Bounds)(ref bounds)).size;
					float magnitude = ((Vector3)(ref size)).magnitude;
					float num3 = num2 + magnitude * 0.5f;
					if (num3 < num)
					{
						num = num3;
						result = val;
					}
				}
			}
			return result;
		}

		private void ApplySweep(MonoBehaviour main, Vector3 point, Vector3 dir)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			int num = Physics.OverlapSphereNonAlloc(point, 1.6f, s_sweep, s_searchMask, (QueryTriggerInteraction)2);
			if (num <= 0)
			{
				return;
			}
			HashSet<MonoBehaviour> hashSet = new HashSet<MonoBehaviour> { main };
			int num2 = 0;
			for (int i = 0; i < num; i++)
			{
				if (num2 >= 3)
				{
					break;
				}
				Collider val = s_sweep[i];
				if ((Object)(object)val == (Object)null || !val.enabled || !((Component)val).gameObject.activeInHierarchy)
				{
					continue;
				}
				MonoBehaviour val2 = TrollResourceMatcher.FindDestructible(val);
				if (!((Object)(object)val2 == (Object)null) && !((Component)val2).transform.IsChildOf(((Component)this).transform) && TrollResourceMatcher.TargetMatches(val2, m_type) && hashSet.Add(val2))
				{
					Vector3 val3;
					if (!(val2 is MineRock) && !(val2 is MineRock5))
					{
						val3 = SafeClosestPoint(val, point);
					}
					else
					{
						Bounds bounds = val.bounds;
						val3 = ((Bounds)(ref bounds)).center;
					}
					Vector3 point2 = val3;
					ApplyDamage(val2, point2, dir);
					num2++;
				}
			}
		}

		private static Vector3 SafeClosestPoint(Collider c, Vector3 to)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: 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_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_0023: 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_002b: 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_0031: Unknown result type (might be due to invalid IL or missing references)
			Bounds bounds;
			try
			{
				MeshCollider val = (MeshCollider)(object)((c is MeshCollider) ? c : null);
				if ((Object)(object)val != (Object)null && !val.convex)
				{
					bounds = c.bounds;
					return ((Bounds)(ref bounds)).ClosestPoint(to);
				}
				return c.ClosestPoint(to);
			}
			catch
			{
				bounds = c.bounds;
				return ((Bounds)(ref bounds)).ClosestPoint(to);
			}
		}

		private void BlacklistPosition(Vector3 p)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			if (!IsBlacklisted(p))
			{
				m_blackPos.Add(p);
				m_blackTime.Add(Time.time);
				if (m_blackPos.Count > 32)
				{
					m_blackPos.RemoveAt(0);
					m_blackTime.RemoveAt(0);
				}
			}
		}

		private bool IsBlacklisted(Vector3 p)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < m_blackPos.Count; i++)
			{
				if (Utils.DistanceSqr(m_blackPos[i], p) < 6.25f)
				{
					return true;
				}
			}
			return false;
		}

		private void CleanupBlacklist()
		{
			for (int num = m_blackPos.Count - 1; num >= 0; num--)
			{
				if (Time.time - m_blackTime[num] > 60f)
				{
					m_blackPos.RemoveAt(num);
					m_blackTime.RemoveAt(num);
				}
			}
		}

		private static ZDOID GetObjectId(MonoBehaviour destr)
		{
			//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)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				ZNetView val = (((Object)(object)destr != (Object)null) ? ((Component)destr).GetComponentInParent<ZNetView>() : null);
				if ((Object)(object)val != (Object)null && val.IsValid() && val.GetZDO() != null)
				{
					return val.GetZDO().m_uid;
				}
			}
			catch
			{
			}
			return ZDOID.None;
		}

		private static void MarkExhausted(MonoBehaviour destr)
		{
			//IL_0012: 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_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: 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_00c0: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)destr == (Object)null)
			{
				return;
			}
			ZDOID objectId = GetObjectId(destr);
			if (objectId != ZDOID.None)
			{
				s_exhaustedIds[objectId] = Time.time;
				if (s_exhaustedIds.Count > 128)
				{
					PurgeExhausted(forceAll: false);
				}
				return;
			}
			Vector3 position = ((Component)destr).transform.position;
			for (int i = 0; i < s_exhaustedFallbackPos.Count; i++)
			{
				if (Utils.DistanceSqr(s_exhaustedFallbackPos[i], position) < 2.25f)
				{
					s_exhaustedFallbackTime[i] = Time.time;
					return;
				}
			}
			s_exhaustedFallbackPos.Add(position);
			s_exhaustedFallbackTime.Add(Time.time);
			if (s_exhaustedFallbackPos.Count > 64)
			{
				s_exhaustedFallbackPos.RemoveAt(0);
				s_exhaustedFallbackTime.RemoveAt(0);
			}
		}

		private static bool IsExhausted(MonoBehaviour destr)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)destr == (Object)null)
			{
				return false;
			}
			ZDOID objectId = GetObjectId(destr);
			if (objectId != ZDOID.None)
			{
				if (s_exhaustedIds.TryGetValue(objectId, out var value))
				{
					if (!(Time.time - value > 600f))
					{
						return true;
					}
					s_exhaustedIds.Remove(objectId);
				}
				return false;
			}
			Vector3 position = ((Component)destr).transform.position;
			for (int num = s_exhaustedFallbackPos.Count - 1; num >= 0; num--)
			{
				if (Time.time - s_exhaustedFallbackTime[num] > 600f)
				{
					s_exhaustedFallbackPos.RemoveAt(num);
					s_exhaustedFallbackTime.RemoveAt(num);
				}
				else if (Utils.DistanceSqr(s_exhaustedFallbackPos[num], position) < 2.25f)
				{
					return true;
				}
			}
			return false;
		}

		private static void PurgeExhausted(bool forceAll)
		{
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			List<ZDOID> list = null;
			foreach (KeyValuePair<ZDOID, float> s_exhaustedId in s_exhaustedIds)
			{
				if (forceAll || Time.time - s_exhaustedId.Value > 600f)
				{
					(list ?? (list = new List<ZDOID>())).Add(s_exhaustedId.Key);
				}
			}
			if (list == null)
			{
				return;
			}
			foreach (ZDOID item in list)
			{
				s_exhaustedIds.Remove(item);
			}
		}

		public static void ClearSessionCaches()
		{
			s_exhaustedIds.Clear();
			s_exhaustedFallbackPos.Clear();
			s_exhaustedFallbackTime.Clear();
			TrollResourceMatcher.ClearCache();
		}

		private void StopGather()
		{
			try
			{
				if ((Object)(object)m_nview != (Object)null && m_nview.IsValid() && m_nview.GetZDO() != null && m_nview.IsOwner())
				{
					m_nview.GetZDO().Set(HashGatherKey, 0, false);
				}
			}
			catch
			{
			}
			Object.Destroy((Object)(object)this);
		}

		private void Notify(string msg)
		{
			if (!(Time.time - m_lastMsgTime < 10f))
			{
				m_lastMsgTime = Time.time;
				Player localPlayer = Player.m_localPlayer;
				if (localPlayer != null)
				{
					((Character)localPlayer).Message((MessageType)1, msg, 0, (Sprite)null, false);
				}
			}
		}

		public static void Start(ZNetView trollNview, GatherType type)
		{
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)trollNview == (Object)null || !trollNview.IsValid())
			{
				return;
			}
			if (!trollNview.IsOwner())
			{
				trollNview.ClaimOwnership();
			}
			ZDO zDO = trollNview.GetZDO();
			if (zDO == null)
			{
				return;
			}
			zDO.Set(TrollWalkConstants.HashActive, false);
			TrollWalkManager.Instance?.CancelRoute(zDO.m_uid, notify: false);
			int num = zDO.GetInt(HashGatherKey, 0);
			if (num == (int)type)
			{
				zDO.Set(HashGatherKey, 0, false);
				Player localPlayer = Player.m_localPlayer;
				if (localPlayer != null)
				{
					((Character)localPlayer).Message((MessageType)2, TrollWalkLoc.T("Gathering stopped", "Добыча остановлена", "Видобуток зупинено", "Recolección detenida"), 0, (Sprite)null, false);
				}
				return;
			}
			zDO.Set(HashGatherKey, (int)type, false);
			TrollResourceMatcher.ClearCache();
			MonsterAI component = ((Component)trollNview).GetComponent<MonsterAI>();
			if ((Object)(object)component != (Object)null)
			{
				try
				{
					component.SetFollowTarget((GameObject)null);
					((BaseAI)component).ResetPatrolPoint();
					zDO.Set(ZDOVars.s_follow, "");
				}
				catch
				{
				}
			}
			TrollGatherController trollGatherController = ((Component)trollNview).GetComponent<TrollGatherController>();
			if ((Object)(object)trollGatherController == (Object)null)
			{
				trollGatherController = ((Component)trollNview).gameObject.AddComponent<TrollGatherController>();
			}
			trollGatherController.m_target = null;
			trollGatherController.m_targetCols = null;
			trollGatherController.m_searchCooldown = 0f;
			trollGatherController.m_searchFailCount = 0;
			trollGatherController.m_abandonCount = 0;
			trollGatherController.m_lastSurfaceDist = float.MaxValue;
			trollGatherController.m_noSurfaceTime = 0f;
			trollGatherController.m_hitThisTarget = false;
			trollGatherController.m_drySwings = 0;
			trollGatherController.m_blackPos.Clear();
			trollGatherController.m_orbitSteps = 0;
			trollGatherController.m_orbitStepTimer = 0f;
			trollGatherController.m_orbitDir = 0;
			string[] array = new string[6] { "", "wood", "fine wood", "core wood", "stone", "copper" };
			string[] array2 = new string[6] { "", "древесину", "качественную древесину", "цельную древесину", "камень", "медь" };
			string[] array3 = new string[6] { "", "деревину", "якісну деревину", "цільну деревину", "камінь", "мідь" };
			string[] array4 = new string[6] { "", "madera", "madera noble", "madera de pino", "piedra", "cobre" };
			Player localPlayer2 = Player.m_localPlayer;
			if (localPlayer2 != null)
			{
				((Character)localPlayer2).Message((MessageType)2, TrollWalkLoc.T("Troll gathers: " + array[(int)type], "Тролль добывает: " + array2[(int)type], "Троль видобуває: " + array3[(int)type], "El trol recolecta: " + array4[(int)type]), 0, (Sprite)null, false);
			}
		}

		public static void CancelWork(Character troll)
		{
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)troll == (Object)null)
			{
				return;
			}
			try
			{
				ZNetView component = ((Component)troll).GetComponent<ZNetView>();
				if ((Object)(object)component == (Object)null || !component.IsValid() || component.GetZDO() == null)
				{
					return;
				}
				ZDO zDO = component.GetZDO();
				if (zDO.GetInt(HashGatherKey, 0) > 0 || zDO.GetBool(TrollWalkConstants.HashActive, false))
				{
					if (!component.IsOwner())
					{
						component.ClaimOwnership();
					}
					zDO.Set(HashGatherKey, 0, false);
					zDO.Set(TrollWalkConstants.HashActive, false);
					zDO.Set(TrollWalkConstants.HashArrivedFlag, false);
					TrollWalkManager.Instance?.CancelRoute(zDO.m_uid, notify: false);
					TrollGatherController component2 = ((Component)troll).GetComponent<TrollGatherController>();
					if ((Object)(object)component2 != (Object)null)
					{
						Object.Destroy((Object)(object)component2);
					}
					if ((Object)(object)Player.m_localPlayer != (Object)null)
					{
						((Character)Player.m_localPlayer).Message((MessageType)1, TrollWalkLoc.T("Troll recalled from work", "Тролль отозван с задания", "Троля відкликано із завдання", "Trol retirado del trabajo"), 0, (Sprite)null, false);
					}
				}
			}
			catch (Exception)
			{
			}
		}
	}
	public class TrollRadialMenu : MonoBehaviour
	{
		private class MenuItem
		{
			public string Name;

			public string Description;

			public Sprite Icon;

			public Action OnSelect;

			public float Angle;

			public bool IsSubItem;

			public string GroupId;

			public bool Visible;

			public GameObject Root;

			public Image GlowImage;

			public Image FillImage;

			public Image BorderImage;

			public Image IconImage;

			public Text LabelText;
		}

		private const float ItemRadius = 265f;

		private const float MainButtonSize = 108f;

		private const float SubButtonSize = 84f;

		private const float LabelOffset = 76f;

		private const float DeadZone = 35f;

		private const float OpenGrace = 0.3f;

		private const float ExpandDelay = 0.15f;

		private const float CollapseDelay = 0.35f;

		private readonly List<MenuItem> m_allItems = new List<MenuItem>();

		private MenuItem m_selected;

		private MenuItem m_stopItem;

		private bool m_active;

		private float m_openedAt = -10f;

		private Canvas m_canvas;

		private Text m_titleText;

		private Text m_descText;

		private Text m_hintText;

		private bool m_hasActiveWork;

		private float m_workCheckTimer;

		private float m_forestHover;

		private float m_stoneHover;

		private float m_forestCollapse;

		private float m_stoneCollapse;

		private bool m_forestExpanded;

		private bool m_stoneExpanded;

		private static readonly Color GoldColor = new Color(1f, 0.83f, 0.35f, 1f);

		private static readonly Color BorderIdle = new Color(0.78f, 0.75f, 0.68f, 0.55f);

		private static readonly Color FillColor = new Color(0.04f, 0.04f, 0.04f, 0.88f);

		private static readonly Color LabelIdle = new Color(0.93f, 0.91f, 0.86f, 0.92f);

		private static readonly Color GlowIdle = new Color(1f, 1f, 1f, 0.16f);

		private static readonly Color GlowSel = new Color(1f, 0.83f, 0.35f, 0.55f);

		private static readonly Color StopFill = new Color(0.34f, 0.05f, 0.05f, 0.92f);

		private static readonly Color StopBorder = new Color(0.95f, 0.32f, 0.32f, 0.9f);

		private static readonly Color StopBorderSel = new Color(1f, 0.5f, 0.5f, 1f);

		private static readonly Color StopX = new Color(1f, 0.5f, 0.5f, 0.95f);

		private const float TitleYNormal = 40f;

		private const float DescYNormal = -42f;

		private const float TitleYStop = 150f;

		private const float DescYStop = -165f;

		private static Font s_font;

		private static Sprite s_circle;

		private static Sprite s_ring;

		private static Sprite s_glow;

		private static Sprite s_vignette;

		private static Sprite s_white;

		public static TrollRadialMenu Instance { get; private set; }

		public static bool IsOpen => (Object)(object)Instance != (Object)null && Instance.m_active;

		private static Sprite CircleSprite
		{
			get
			{
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Expected O, but got Unknown
				//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: 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_009c: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)s_circle != (Object)null)
				{
					return s_circle;
				}
				int num = 256;
				float num2 = (float)(num - 1) * 0.5f;
				Texture2D val = new Texture2D(num, num, (TextureFormat)4, false);
				Color32[] array = (Color32[])(object)new Color32[num * num];
				for (int i = 0; i < num; i++)
				{
					for (int j = 0; j < num; j++)
					{
						float num3 = Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(num2, num2)) - num2;
						float num4 = Mathf.Clamp01(1.5f - num3);
						array[i * num + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num4 * 255f));
					}
				}
				val.SetPixels32(array);
				val.Apply();
				((Texture)val).wrapMode = (TextureWrapMode)1;
				s_circle = Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f), (float)num);
				return s_circle;
			}
		}

		private static Sprite RingSprite
		{
			get
			{
				//IL_0039: Unknown result type (might be due to invalid IL or missing references)
				//IL_003f: Expected O, but got Unknown
				//IL_012c: Unknown result type (might be due to invalid IL or missing references)
				//IL_013b: 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_0067: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)s_ring != (Object)null)
				{
					return s_ring;
				}
				int num = 256;
				float num2 = (float)(num - 1) * 0.5f;
				float num3 = 10f;
				Texture2D val = new Texture2D(num, num, (TextureFormat)4, false);
				Color32[] array = (Color32[])(object)new Color32[num * num];
				for (int i = 0; i < num; i++)
				{
					for (int j = 0; j < num; j++)
					{
						float num4 = Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(num2, num2)) - num2;
						float num5 = Mathf.Clamp01(1.5f - Mathf.Abs(num4 + num3 * 0.5f)) + Mathf.Clamp01(1.5f - Mathf.Abs(num4 - num3 * 0.5f));
						array[i * num + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(Mathf.Clamp01(num5) * 255f));
					}
				}
				val.SetPixels32(array);
				val.Apply();
				((Texture)val).wrapMode = (TextureWrapMode)1;
				s_ring = Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f), (float)num);
				return s_ring;
			}
		}

		private static Sprite GlowSprite
		{
			get
			{
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Expected O, but got Unknown
				//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
				//IL_0106: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: 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)
				//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)s_glow != (Object)null)
				{
					return s_glow;
				}
				int num = 128;
				float num2 = (float)(num - 1) * 0.5f;
				Texture2D val = new Texture2D(num, num, (TextureFormat)4, false);
				Color32[] array = (Color32[])(object)new Color32[num * num];
				for (int i = 0; i < num; i++)
				{
					for (int j = 0; j < num; j++)
					{
						float num3 = Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(num2, num2)) / num2;
						float num4 = Mathf.Clamp01(1f - num3);
						num4 = num4 * num4 * num4;
						array[i * num + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)(num4 * 255f));
					}
				}
				val.SetPixels32(array);
				val.Apply();
				((Texture)val).wrapMode = (TextureWrapMode)1;
				s_glow = Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f), (float)num);
				return s_glow;
			}
		}

		private static Sprite VignetteSprite
		{
			get
			{
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: Expected O, but got Unknown
				//IL_00e8: 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_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0095: Unknown result type (might be due to invalid IL or missing references)
				//IL_009a: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)s_vignette != (Object)null)
				{
					return s_vignette;
				}
				int num = 128;
				float num2 = (float)(num - 1) * 0.5f;
				Texture2D val = new Texture2D(num, num, (TextureFormat)4, false);
				Color32[] array = (Color32[])(object)new Color32[num * num];
				for (int i = 0; i < num; i++)
				{
					for (int j = 0; j < num; j++)
					{
						float num3 = Vector2.Distance(new Vector2((float)j, (float)i), new Vector2(num2, num2)) / num2;
						float num4 = Mathf.SmoothStep(0.25f, 1f, num3) * 0.5f;
						array[i * num + j] = new Color32((byte)0, (byte)0, (byte)0, (byte)(num4 * 255f));
					}
				}
				val.SetPixels32(array);
				val.Apply();
				((Texture)val).wrapMode = (TextureWrapMode)1;
				s_vignette = Sprite.Create(val, new Rect(0f, 0f, (float)num, (float)num), new Vector2(0.5f, 0.5f), (float)num);
				return s_vignette;
			}
		}

		private static Sprite WhiteSprite
		{
			get
			{
				//IL_001f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0025: Expected O, but got Unknown
				//IL_0049: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0092: 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 ((Object)(object)s_white != (Object)null)
				{
					return s_white;
				}
				Texture2D val = new Texture2D(4, 4, (TextureFormat)4, false);
				Color32[] array = (Color32[])(object)new Color32[16];
				for (int i = 0; i < array.Length; i++)
				{
					array[i] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, byte.MaxValue);
				}
				val.SetPixels32(array);
				val.Apply();
				((Texture)val).wrapMode = (TextureWrapMode)1;
				s_white = Sprite.Create(val, new Rect(0f, 0f, 4f, 4f), new Vector2(0.5f, 0.5f), 100f);
				return s_white;
			}
		}

		private static Font GetFont()
		{
			if ((Object)(object)s_font != (Object)null)
			{
				return s_font;
			}
			try
			{
				s_font = Resources.GetBuiltinResource<Font>("LegacyRuntime.ttf");
			}
			catch
			{
				try
				{
					s_font = Resources.GetBuiltinResource<Font>("Arial.ttf");
				}
				catch
				{
				}
			}
			return s_font ?? Font.CreateDynamicFontFromOSFont("Arial", 14);
		}

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

		private void OnDestroy()
		{
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
		}

		public static void Show(ZDOID trollID)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_003f: 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)
			if ((Object)(object)Instance == (Object)null)
			{
				GameObject val = new GameObject("TrollRadialMenuSystem");
				Object.DontDestroyOnLoad((Object)(object)val);
				val.AddComponent<TrollRadialMenu>();
			}
			if (!((Object)(object)Instance == (Object)null))
			{
				TrollMenuState.TrollID = trollID;
				TrollMenuState.IsOpen = true;
				Instance.m_active = true;
				Instance.m_openedAt = Time.unscaledTime;
				Instance.m_hasActiveWork = false;
				Instance.m_workCheckTimer = 0f;
				Instance.m_forestExpanded = (Instance.m_stoneExpanded = false);
				Instance.m_forestHover = (Instance.m_stoneHover = 0f);
				Instance.ResetSelection();
				Instance.ApplyVisibility();
				Instance.SetCenterTextLayout(stopMode: false);
				((Component)Instance).gameObject.SetActive(true);
			}
		}

		public static void Close()
		{
			if (!((Object)(object)Instance == (Object)null))
			{
				Instance.m_active = false;
				((Component)Instance).gameObject.SetActive(false);
				TrollMenuState.IsOpen = false;
			}
		}

		private void BuildUI()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0065: 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)
			//IL_007d: 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_00a4: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: 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_0150: 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_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Unknown result type (might be due to invalid IL or missing references)
			//IL_022f: Unknown result type (might be due to invalid IL or missing references)
			//IL_023e: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Unknown result type (might be due to invalid IL or missing references)
			//IL_0323: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Root");
			val.AddComponent<RectTransform>();
			val.transform.SetParent(((Component)this).transform, false);
			m_canvas = val.AddComponent<Canvas>();
			m_canvas.renderMode = (RenderMode)0;
			m_canvas.sortingOrder = 500;
			val.AddComponent<CanvasScaler>().uiScaleMode = (ScaleMode)0;
			RectTransform component = val.GetComponent<RectTransform>();
			component.anchorMin = Vector2.zero;
			component.anchorMax = Vector2.one;
			component.offsetMin = Vector2.zero;
			component.offsetMax = Vector2.zero;
			Image val2 = MakeImage(val.transform, "Vignette", VignetteSprite, Color.white);
			StretchFull(((Graphic)val2).rectTransform);
			Image val3 = MakeImage(val.transform, "Disc", CircleSprite, new Color(0.02f, 0.02f, 0.02f, 0.92f));
			Place(((Graphic)val3).rectTransform, Vector2.zero, new Vector2(460f, 460f));
			Image val4 = MakeImage(val.transform, "DiscEdge", RingSprite, new Color(1f, 1f, 1f, 0.12f));
			Place(((Graphic)val4).rectTransform, Vector2.zero, new Vector2(466f, 466f));
			Image val5 = MakeImage(val.transform, "Ring", RingSprite, new Color(1f, 1f, 1f, 0.16f));
			Place(((Graphic)val5).rectTransform, Vector2.zero, new Vector2(780f, 780f));
			Image val6 = MakeImage(val.transform, "Ring2", RingSprite, new Color(1f, 0.83f, 0.35f, 0.1f));
			Place(((Graphic)val6).rectTransform, Vector2.zero, new Vector2(660f, 660f));
			m_titleText = MakeText(val.transform, "Title", 27, Color.white);
			Place(((Graphic)m_titleText).rectTransform, new Vector2(0f, 40f), new Vector2(400f, 38f));
			m_descText = MakeText(val.transform, "Desc", 16, new Color(0.86f, 0.86f, 0.86f, 0.95f));
			Place(((Graphic)m_descText).rectTransform, new Vector2(0f, -42f), new Vector2(400f, 66f));
			m_hintText = MakeText(val.transform, "Hint", 13, new Color(0.7f, 0.7f, 0.7f, 0.75f));
			m_hintText.text = TrollWalkLoc.T("LMB — select   •   RMB / Y — close", "ЛКМ — выбрать   •   ПКМ / Y — закрыть", "ЛКМ — вибрати   •   ПКМ / Y — закрити", "Clic Izq — seleccionar   •   Clic Der / Y — cerrar");
			Place(((Graphic)m_hintText).rectTransform, new Vector2(0f, -112f), new Vector2(420f, 22f));
			BuildItems();
			BuildStopItem();
		}

		private static Image MakeImage(Transform parent, string name, Sprite sprite, Color color)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.AddComponent<RectTransform>();
			val.transform.SetParent(parent, false);
			Image val2 = val.AddComponent<Image>();
			val2.sprite = sprite;
			((Graphic)val2).color = color;
			((Graphic)val2).raycastTarget = false;
			return val2;
		}

		private static Text MakeText(Transform parent, string name, int size, Color color)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.AddComponent<RectTransform>();
			val.transform.SetParent(parent, false);
			Text val2 = val.AddComponent<Text>();
			val2.font = GetFont();
			val2.fontSize = size;
			((Graphic)val2).color = color;
			val2.alignment = (TextAnchor)4;
			((Graphic)val2).raycastTarget = false;
			val2.horizontalOverflow = (HorizontalWrapMode)0;
			val2.verticalOverflow = (VerticalWrapMode)1;
			return val2;
		}

		private static void Place(RectTransform rt, Vector2 pos, Vector2 size)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: 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)
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(0.5f, 0.5f);
			rt.pivot = val;
			Vector2 anchorMin = (rt.anchorMax = val);
			rt.anchorMin = anchorMin;
			rt.anchoredPosition = pos;
			rt.sizeDelta = size;
		}

		private static void StretchFull(RectTransform rt)
		{
			//IL_0002: 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_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: 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)
			rt.anchorMin = Vector2.zero;
			rt.anchorMax = Vector2.one;
			Vector2 offsetMin = (rt.offsetMax = Vector2.zero);
			rt.offsetMin = offsetMin;
		}

		private void BuildItems()
		{
			AddItem("Freeze", 90f, isSub: false, null, TrollWalkLoc.T("Freeze", "Не двигаться", "Не рухатися", "Congelar"), TrollWalkLoc.T("Immovable mode: on/off", "Режим неподвижности: вкл/выкл", "Режим нерухомості: увімк/вимк", "Modo inmóvil: act/desact"), LoadEmbeddedIcon("freeze.png"), OnFreeze);
			AddItem("Forest", 180f, isSub: false, "forest", TrollWalkLoc.T("Forest", "Лес", "Ліс", "Bosque"), TrollWalkLoc.T("Hover to pick wood type", "Наведите, чтобы выбрать древесину", "Наведіть, щоб вибрати деревину", "Pasa el cursor para elegir tipo de madera"), LoadEmbeddedIcon("forest.png"), null);
			AddItem("Stone", 0f, isSub: false, "stone", TrollWalkLoc.T("Stone", "Камень", "Камінь", "Piedra"), TrollWalkLoc.T("Hover to pick material", "Наведите, чтобы выбрать материал", "Наведіть, щоб вибрати матеріал", "Pasa el cursor para elegir material"), LoadEmbeddedIcon("stone.png", "stone"), null);
			AddItem("Map", 270f, isSub: false, null, TrollWalkLoc.T("Route", "Маршрут", "Маршрут", "Ruta"), TrollWalkLoc.T("Send the troll on a map route", "Отправить тролля по карте", "Відправити троля по карті", "Enviar al trol por una ruta en el mapa"), LoadEmbeddedIcon("map.png"), OnMap);
			AddItem("CoreWood", 150f, isSub: true, "forest", TrollWalkLoc.T("Core wood", "Цельная древесина", "Цільна деревина", "Madera de pino"), TrollWalkLoc.T("Pine, fir", "Сосна, пихта", "Сосна, ялиця", "Pino, abeto"), LoadEmbeddedIcon("CoreWood.png"), delegate
			{
				OnGather(GatherType.CoreWood);
			});
			AddItem("FineWood", 180f, isSub: true, "forest", TrollWalkLoc.T("Fine wood", "Качественная древесина", "Якісна деревина", "Madera noble"), TrollWalkLoc.T("Birch, oak, birch logs", "Берёза, дуб, брёвна берёзы", "Береза, дуб, колоди берези", "Abedul, roble, troncos de abedul"), LoadEmbeddedIcon("fineWood.png"), delegate
			{
				OnGather(GatherType.FineWood);
			});
			AddItem("Wood", 210f, isSub: true, "forest", TrollWalkLoc.T("Wood", "Древесина", "Деревина", "Madera"), TrollWalkLoc.T("Beech, stumps, logs", "Бук, пни, брёвна", "Бук, пеньки, колоди", "Haya, tocones, troncos"), LoadEmbeddedIcon("Wood.png"), delegate
			{
				OnGather(GatherType.Wood);
			});
			AddItem("StoneRes", 20f, isSub: true, "stone", TrollWalkLoc.T("Stone", "Камень", "Камінь", "Piedra"), TrollWalkLoc.T("Boulders and rock nodes", "Валуны и каменные глыбы", "Валуни та кам'яні брили", "Rocas y depósitos de piedra"), LoadEmbeddedIcon("stone1.png", "stone1"), delegate
			{
				OnGather(GatherType.Stone);
			});
			AddItem("Copper", -20f, isSub: true, "stone", TrollWalkLoc.T("Copper", "Медь", "Мідь", "Cobre"), TrollWalkLoc.T("Copper veins and deposits", "Медные жилы и месторождения", "Мідні жили та родовища", "Vetas y yacimientos de cobre"), LoadEmbeddedIcon("copper.png"), delegate
			{
				OnGather(GatherType.Copper);
			});
			ApplyVisibility();
		}

		private void BuildStopItem()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0031: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: 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)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00c7: 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_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Item_StopWork");
			val.AddComponent<RectTransform>();
			val.transform.SetParent(((Component)m_canvas).transform, false);
			Place(val.GetComponent<RectTransform>(), Vector2.zero, Vector2.zero);
			Image val2 = MakeImage(val.transform, "Fill", CircleSprite, StopFill);
			Place(((Graphic)val2).rectTransform, Vector2.zero, new Vector2(92f, 92f));
			Image val3 = MakeImage(val.transform, "Border", RingSprite, StopBorder);
			Place(((Graphic)val3).rectTransform, Vector2.zero, new Vector2(92f, 92f));
			Image val4 = MakeImage(val.transform, "X1", WhiteSprite, StopX);
			Place(((Graphic)val4).rectTransform, Vector2.zero, new Vector2(42.32f, 9.2f));
			((Transform)((Graphic)val4).rectTransform).localRotation = Quaternion.Euler(0f, 0f, 45f);
			Image val5 = MakeImage(val.transform, "X2", WhiteSprite, StopX);
			Place(((Graphic)val5).rectTransform, Vector2.zero, new Vector2(42.32f, 9.2f));
			((Transform)((Graphic)val5).rectTransform).localRotation = Quaternion.Euler(0f, 0f, -45f);
			m_stopItem = new MenuItem
			{
				Name = TrollWalkLoc.T("Stop work", "Остановить работу", "Зупинити роботу", "Detener trabajo"),
				Description = TrollWalkLoc.T("Cancel route and gathering", "Отменить маршрут и добычу", "Скасувати маршрут і видобуток", "Cancelar ruta y recolección"),
				Icon = null,
				OnSelect = OnStopWork,
				Angle = -9999f,
				IsSubItem = false,
				GroupId = null,
				Visible = true,
				Root = val,
				GlowImage = null,
				FillImage = val2,
				BorderImage = val3,
				IconImage = null,
				LabelText = null
			};
			val.SetActive(false);
		}

		private void AddItem(string id, float angle, bool isSub, string group, string name, string desc, Sprite icon, Action onSelect)
		{
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Expected O, but got Unknown
			//IL_00ac: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: 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_0148: 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_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			MenuItem menuItem = new MenuItem
			{
				Name = name,
				Description = desc,
				Icon = icon,
				OnSelect = onSelect,
				Angle = angle,
				IsSubItem = isSub,
				GroupId = group,
				Visible = !isSub
			};
			float num = (isSub ? 84f : 108f);
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(Mathf.Cos(angle * (MathF.PI / 180f)), Mathf.Sin(angle * (MathF.PI / 180f)));
			GameObject val2 = new GameObject("Item_" + id);
			val2.AddComponent<RectTransform>();
			val2.transform.SetParent(((Component)m_canvas).transform, false);
			Place(val2.GetComponent<RectTransform>(), val * 265f, Vector2.zero);
			Image val3 = MakeImage(val2.transform, "Glow", GlowSprite, GlowIdle);
			Place(((Graphic)val3).rectTransform, Vector2.zero, new Vector2(num * 1.6f, num * 1.6f));
			Image val4 = MakeImage(val2.transform, "Fill", CircleSprite, FillColor);
			Place(((Graphic)val4).rectTransform, Vector2.zero, new Vector2(num, num));
			Image val5 = MakeImage(val2.transform, "Border", RingSprite, BorderIdle);
			Place(((Graphic)val5).rectTransform, Vector2.zero, new Vector2(num, num));
			Image val6 = MakeImage(val2.transform, "Icon", icon, Color.white);
			val6.preserveAspect = true;
			Place(((Graphic)val6).rectTransform, Vector2.zero, new Vector2(num * 0.62f, num * 0.62f));
			Text val7 = MakeText(val2.transform, "Label", isSub ? 13 : 17, LabelIdle);
			val7.text = name;
			Place(((Graphic)val7).rectTransform, new Vector2(0f, -76f), new Vector2(210f, 30f));
			menuItem.Root = val2;
			menuItem.GlowImage = val3;
			menuItem.FillImage = val4;
			menuItem.BorderImage = val5;
			menuItem.IconImage = val6;
			menuItem.LabelText = val7;
			m_allItems.Add(menuItem);
		}

		private void Update()
		{
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: 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)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			if (!m_active)
			{
				return;
			}
			Player localPlayer = Player.m_localPlayer;
			if ((Object)(object)localPlayer == (Object)null || ((Character)localPlayer).IsDead())
			{
				Close();
				return;
			}
			if (Time.unscaledTime - m_openedAt > 0.3f && (Input.GetKeyDown((KeyCode)121) || Input.GetKeyDown((KeyCode)27) || Input.GetMouseButtonDown(1)))
			{
				Close();
				return;
			}
			UpdateWorkState();
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor((float)Screen.width / 2f, (float)Screen.height / 2f);
			Vector2 diff = Vector2.op_Implicit(Input.mousePosition) - val;
			HandleSelection(diff);
			UpdateGroupExpansion(Time.deltaTime);
			if (Input.GetMouseButtonDown(0) && m_selected != null)
			{
				ConfirmSelection();
			}
		}

		private void UpdateWorkState()
		{
			m_workCheckTimer -= Time.unscaledDeltaTime;
			if (!(m_workCheckTimer > 0f))
			{
				m_workCheckTimer = 0.25f;
				m_hasActiveWork = false;
				ZNetView val = FindTrollNView();
				if ((Object)(object)val != (Object)null && val.IsValid() && val.GetZDO() != null)
				{
					ZDO zDO = val.GetZDO();
					m_hasActiveWork = zDO.GetBool(TrollWalkConstants.HashActive, false) || zDO.GetInt(TrollGatherController.HashGatherKey, 0) > 0;
				}
				if (!m_hasActiveWork && m_selected == m_stopItem)
				{
					ResetSelection();
				}
			}
		}