Decompiled source of LycansSheriff v1.2.1

plugins/LycansSheriff.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Cryptography;
using System.Security.Permissions;
using System.Text;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Fusion;
using Helpers.Collections;
using LycansSheriff;
using LycansSheriff.Hooks;
using LycansSheriff.Hooks.Config;
using LycansSheriff.Hooks._GameState;
using LycansSheriff.Hooks._LocalizationSettings;
using LycansSheriff.Hooks._PlayerController;
using LycansSheriff.Hooks._UI;
using LycansSheriff.Mods;
using LycansSheriff.Services;
using Managers;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using On;
using Root;
using TMPro;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.Localization;
using UnityEngine.Localization.Components;
using UnityEngine.Localization.Settings;
using UnityEngine.Localization.Tables;
using UnityEngine.Scripting;
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(".NETFramework,Version=v4.6.2", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("LycansSheriff")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+39b7ddc1179c60a41404e2255609235f198d0ceb")]
[assembly: AssemblyProduct("LycansSheriff")]
[assembly: AssemblyTitle("LycansSheriff")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Root
{
	[BepInPlugin("Knard.LycansSheriff", "LycansSheriff", "1.0.0")]
	[BepInProcess("Lycans.exe")]
	public class LycanSheriff : BaseUnityPlugin
	{
		public const string PLUGIN_GUID = "Knard.LycansSheriff";

		public const string PLUGIN_AUTHOR = "Knard";

		public const string PLUGIN_NAME = "LycansSheriff";

		public const string PLUGIN_VERSION = "1.0.0";

		private const string ROOM_CONFIG_URL = "https://lycansmods.goneworlds.ovh/api/roomcode/";

		private static float _lastColorSwitcherHintLogTime = -30f;

		private TranslationManager translationManager { get; set; }

		public static LycanSheriff instance { get; private set; }

		public static NetworkObject SheriffNetworkObject { get; set; }

		private void Awake()
		{
			instance = this;
			Log.Init(((BaseUnityPlugin)this).Logger);
			translationManager = new TranslationManager();
			new GameManagerHook();
			deleayedLoading();
			Log.Info("Mod Started : LycansSheriff by Knard(1.0.0)");
		}

		public void Spawned()
		{
			deleayedLoading();
		}

		public async void deleayedLoading()
		{
			await Task.Delay(3000);
			translationManager.populateTranslations();
			LanguageService.Instance.PopulateStringDatabase();
			Sheriff.FightPosition = ((Component)GameManager.Instance.mapSpawns[0]).transform.position;
			new SheriffPerkUI();
			LoadDefaultSheriffConfig();
		}

		public static void _L(string message)
		{
			if (Time.realtimeSinceStartup - _lastColorSwitcherHintLogTime >= 30f)
			{
				Log.Info("[main] L: " + message);
			}
		}

		public void L(string message)
		{
			_L(message);
		}

		private void Update()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			Sheriff.ResolveInstance()?.ServerUpdate();
			PlayerController local = PlayerController.Local;
			if ((Object)(object)local != (Object)null)
			{
				if (!NetworkBool.op_Implicit(local.IsDead))
				{
					local.Hunger = GameManager.Instance.MaxHunger;
				}
				if (((SimulationBehaviour)local).HasStateAuthority)
				{
					if (Input.GetKeyDown((KeyCode)282))
					{
						Log.Info("[main] F1 pressed: fetching Sheriff config from API");
						TryFetchAPI();
					}
					if (Input.GetKeyDown((KeyCode)283))
					{
						Log.Info("[main] F2 pressed: forcing Sheriff config propagation to all clients");
						PushSheriffConfigToAllClients();
					}
				}
			}
			SheriffPerkUI.Instance?.PlayerController_Update();
		}

		private void Start()
		{
			NetworkObjectBootstrap.EnsureAllRegistered();
		}

		private void OnDestroy()
		{
		}

		private static void LoadDefaultSheriffConfig()
		{
			SheriffConfigData? sheriffConfigData = RemoteSheriffConfigLoader.LoadDefaultAsset(Sheriff.GetLastKnownConfig());
			if (!sheriffConfigData.HasValue)
			{
				Log.Warning("[main] LoadDefaultSheriffConfig skipped: default config is empty or invalid");
				return;
			}
			Sheriff.SetLastKnownConfig(sheriffConfigData.Value);
			Sheriff.ResolveInstance()?.ApplyConfig(sheriffConfigData.Value);
		}

		private static void PushSheriffConfigToAllClients()
		{
			try
			{
				NetworkRunner val = ((SimulationBehaviour)(GameManager.Instance?)).Runner;
				if ((Object)(object)val == (Object)null || !val.IsServer)
				{
					Log.Warning("[main] PushSheriffConfigToAllClients skipped: local player is not server");
					return;
				}
				Sheriff.ResolveInstance()?.PushConfigToClients(val);
				Log.Info("[main] Sheriff config pushed to all clients");
			}
			catch (Exception ex)
			{
				Log.Error("[main] PushSheriffConfigToAllClients failed: " + ex);
			}
		}

		public static string getGameCode()
		{
			GameManager obj = GameManager.Instance;
			object result;
			if (obj == null)
			{
				result = null;
			}
			else
			{
				GameUI gameUI = obj.gameUI;
				if (gameUI == null)
				{
					result = null;
				}
				else
				{
					TextMeshProUGUI gameCodeText = gameUI.gameCodeText;
					result = ((gameCodeText != null) ? ((TMP_Text)gameCodeText).text : null);
				}
			}
			return (string)result;
		}

		public static async void TryFetchAPI()
		{
			try
			{
				string code = getGameCode();
				if (string.IsNullOrWhiteSpace(code))
				{
					Log.Warning("[main] TryFetchAPI aborted: room code is empty");
					return;
				}
				code = code.Trim();
				string url = "https://lycansmods.goneworlds.ovh/api/roomcode/" + Uri.EscapeDataString(code);
				Log.Info("[main] TryFetchAPI fetching Sheriff config for roomCode=" + code + " url=" + url);
				SheriffConfigData? config = await RemoteSheriffConfigLoader.LoadAsync(url, Sheriff.GetLastKnownConfig());
				if (!config.HasValue)
				{
					Log.Warning("[main] TryFetchAPI failed: API returned no Sheriff config");
					return;
				}
				Sheriff.SetLastKnownConfig(config.Value);
				Sheriff.ResolveInstance()?.ApplyConfig(config.Value);
				NetworkRunner runner = ((SimulationBehaviour)(GameManager.Instance?)).Runner;
				Sheriff sheriff = Sheriff.ResolveInstance();
				if ((Object)(object)runner != (Object)null && runner.IsServer && (Object)(object)sheriff != (Object)null)
				{
					sheriff.PushConfigToClients(runner);
					Log.Info("[main] TryFetchAPI applied Sheriff config and pushed to all clients");
				}
				else
				{
					Log.Info("[main] TryFetchAPI stored Sheriff config locally (instance or server push unavailable)");
				}
			}
			catch (Exception ex)
			{
				Log.Error("[main] TryFetchAPI failed: " + ex);
			}
		}
	}
}
namespace LycansSheriff
{
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
			if (_logSource != null)
			{
				_logSource.LogDebug(data);
			}
			else
			{
				Debug.Log((object)("[LycansDuckModpackV2][Debug] " + data));
			}
		}

		internal static void Error(object data)
		{
			if (_logSource != null)
			{
				_logSource.LogError(data);
			}
			else
			{
				Debug.LogError((object)("[LycansDuckModpackV2][Error] " + data));
			}
		}

		internal static void Fatal(object data)
		{
			if (_logSource != null)
			{
				_logSource.LogFatal(data);
			}
			else
			{
				Debug.LogError((object)("[LycansDuckModpackV2][Fatal] " + data));
			}
		}

		internal static void Info(object data)
		{
			if (_logSource != null)
			{
				_logSource.LogInfo(data);
			}
			else
			{
				Debug.Log((object)("[LycansDuckModpackV2][Info] " + data));
			}
		}

		internal static void Message(object data)
		{
			if (_logSource != null)
			{
				_logSource.LogMessage(data);
			}
			else
			{
				Debug.Log((object)("[LycansDuckModpackV2][Message] " + data));
			}
		}

		internal static void Warning(object data)
		{
			if (_logSource != null)
			{
				_logSource.LogWarning(data);
			}
			else
			{
				Debug.LogWarning((object)("[LycansDuckModpackV2][Warning] " + data));
			}
		}
	}
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "LycansSheriff";

		public const string PLUGIN_NAME = "LycansSheriff";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace LycansSheriff.Services
{
	internal enum MinimapMode
	{
		Dev,
		Player
	}
	internal sealed class Minimap3DService : IDisposable
	{
		private sealed class ZoneVisual
		{
			public RectTransform Root;

			public Text Label;

			public readonly List<Image> Edges = new List<Image>();

			public ZonePolygonGraphic FillGraphic;
		}

		private enum MinimapZoneType
		{
			Settlement,
			Nature,
			Ruins,
			Coast,
			Fishing
		}

		private struct MinimapZone
		{
			public string Name;

			public MinimapZoneType Type;

			public Vector2[] PolygonXZ;
		}

		private const float FollowHeight = 80f;

		private const float FollowLerpSpeed = 8f;

		private const int RenderTextureSize = 512;

		private const int FullscreenRenderTextureHeight = 1080;

		private static readonly Vector2 CompactPanelSize = new Vector2(260f, 260f);

		private const float MinZoom = 12f;

		private const float MaxZoom = 140f;

		private const float ZoomScrollSpeed = 18f;

		private const float MaxPhysicalHeightNoFog = 40f;

		private const float BaseOrthoSize = 14f;

		private const float HeightToOrthoFactor = 0.42f;

		private const float MinHeight = 5f;

		private const float MaxHeight = 250f;

		private const float HeightAdjustSpeed = 55f;

		private const float MinAngle = 35f;

		private const float MaxAngle = 90f;

		private const float AngleAdjustSpeed = 65f;

		private const float PanSpeed = 60f;

		private const float Map1DefaultTargetX = 160f;

		private const float Map1DefaultTargetY = 22.3f;

		private const float Map1DefaultTargetZ = 176f;

		private const float Map1DefaultHeight = 215f;

		private const float Map1DefaultAngle = 90f;

		private const float Map2DefaultTargetX = 403.6f;

		private const float Map2DefaultTargetY = 23.1f;

		private const float Map2DefaultTargetZ = -121.3f;

		private const float Map2DefaultHeight = 78.1f;

		private const float Map2DefaultAngle = 90f;

		private const KeyCode DebugZonesToggleKey = 287;

		private static readonly MinimapZone[] Map1Zones = new MinimapZone[6]
		{
			new MinimapZone
			{
				Name = "Ferme",
				Type = MinimapZoneType.Settlement,
				PolygonXZ = (Vector2[])(object)new Vector2[7]
				{
					new Vector2(169f, 212.9f),
					new Vector2(148f, 230.6f),
					new Vector2(146.1f, 246.5f),
					new Vector2(143f, 264.5f),
					new Vector2(166f, 273.2f),
					new Vector2(180.2f, 268.5f),
					new Vector2(211.8f, 244.2f)
				}
			},
			new MinimapZone
			{
				Name = "Foret",
				Type = MinimapZoneType.Nature,
				PolygonXZ = (Vector2[])(object)new Vector2[8]
				{
					new Vector2(151.3f, 168.1f),
					new Vector2(156.3f, 191.5f),
					new Vector2(169.3f, 212.5f),
					new Vector2(220.4f, 237.5f),
					new Vector2(236.8f, 208.4f),
					new Vector2(237.7f, 188.4f),
					new Vector2(219.9f, 170.1f),
					new Vector2(182.1f, 148.9f)
				}
			},
			new MinimapZone
			{
				Name = "Ruine",
				Type = MinimapZoneType.Ruins,
				PolygonXZ = (Vector2[])(object)new Vector2[4]
				{
					new Vector2(188f, 184f),
					new Vector2(246f, 174f),
					new Vector2(266f, 226f),
					new Vector2(206f, 244f)
				}
			},
			new MinimapZone
			{
				Name = "Plage",
				Type = MinimapZoneType.Coast,
				PolygonXZ = (Vector2[])(object)new Vector2[4]
				{
					new Vector2(99.7f, 227.6f),
					new Vector2(118.7f, 226.4f),
					new Vector2(139.9f, 250.1f),
					new Vector2(138.6f, 263.5f)
				}
			},
			new MinimapZone
			{
				Name = "Pecheur",
				Type = MinimapZoneType.Fishing,
				PolygonXZ = (Vector2[])(object)new Vector2[9]
				{
					new Vector2(147.3f, 157.3f),
					new Vector2(165.5f, 146f),
					new Vector2(180.3f, 132.3f),
					new Vector2(175.6f, 110.5f),
					new Vector2(174.1f, 107.8f),
					new Vector2(156.4f, 89.2f),
					new Vector2(123.4f, 106f),
					new Vector2(122.6f, 107.6f),
					new Vector2(100.8f, 140.4f)
				}
			},
			new MinimapZone
			{
				Name = "Village",
				Type = MinimapZoneType.Settlement,
				PolygonXZ = (Vector2[])(object)new Vector2[9]
				{
					new Vector2(119f, 210.1f),
					new Vector2(132.1f, 209.9f),
					new Vector2(137.3f, 209.1f),
					new Vector2(140.5f, 206.2f),
					new Vector2(142.1f, 200.6f),
					new Vector2(141.9f, 164.6f),
					new Vector2(89.9f, 164.8f),
					new Vector2(86.3f, 181.6f),
					new Vector2(90.4f, 210.1f)
				}
			}
		};

		private static readonly MinimapZone[] Map2Zones = new MinimapZone[6]
		{
			new MinimapZone
			{
				Name = "Ferme",
				Type = MinimapZoneType.Settlement,
				PolygonXZ = (Vector2[])(object)new Vector2[4]
				{
					new Vector2(374f, -144f),
					new Vector2(432f, -144f),
					new Vector2(436f, -98f),
					new Vector2(370f, -96f)
				}
			},
			new MinimapZone
			{
				Name = "Foret",
				Type = MinimapZoneType.Nature,
				PolygonXZ = (Vector2[])(object)new Vector2[4]
				{
					new Vector2(268f, -122f),
					new Vector2(348f, -138f),
					new Vector2(390f, -60f),
					new Vector2(300f, -36f)
				}
			},
			new MinimapZone
			{
				Name = "Ruine",
				Type = MinimapZoneType.Ruins,
				PolygonXZ = (Vector2[])(object)new Vector2[4]
				{
					new Vector2(414f, -112f),
					new Vector2(486f, -104f),
					new Vector2(498f, -42f),
					new Vector2(432f, -26f)
				}
			},
			new MinimapZone
			{
				Name = "Plage",
				Type = MinimapZoneType.Coast,
				PolygonXZ = (Vector2[])(object)new Vector2[4]
				{
					new Vector2(446f, -204f),
					new Vector2(524f, -196f),
					new Vector2(530f, -132f),
					new Vector2(456f, -126f)
				}
			},
			new MinimapZone
			{
				Name = "Pecheur",
				Type = MinimapZoneType.Fishing,
				PolygonXZ = (Vector2[])(object)new Vector2[4]
				{
					new Vector2(410f, -232f),
					new Vector2(470f, -228f),
					new Vector2(472f, -176f),
					new Vector2(404f, -176f)
				}
			},
			new MinimapZone
			{
				Name = "Village",
				Type = MinimapZoneType.Settlement,
				PolygonXZ = (Vector2[])(object)new Vector2[4]
				{
					new Vector2(334f, -176f),
					new Vector2(414f, -176f),
					new Vector2(416f, -120f),
					new Vector2(336f, -118f)
				}
			}
		};

		private static Minimap3DService _instance;

		private GameObject _panelGO;

		private RectTransform _panelRect;

		private RectTransform _viewportRect;

		private RectTransform _zonesOverlayRect;

		private RawImage _rawImage;

		private AspectRatioFitter _viewportAspectFitter;

		private Text _coordsText;

		private GameObject _cameraGO;

		private Camera _camera;

		private RenderTexture _renderTexture;

		private bool _isVisible;

		private bool _isFullscreen;

		private bool _hasSavedWindowLayout;

		private bool _cursorInteractionEnabled;

		private bool _savedCursorVisible;

		private CursorLockMode _savedCursorLockState;

		private Vector2 _savedAnchorMin;

		private Vector2 _savedAnchorMax;

		private Vector2 _savedPivot;

		private Vector2 _savedSizeDelta;

		private Vector2 _savedAnchoredPosition;

		private Vector2 _panOffset;

		private float _manualZoomOffset;

		private float _followHeight = 80f;

		private float _cameraPitch = 90f;

		private bool _defaultsAppliedForCurrentScene;

		private int _defaultsMapId = -1;

		private float _lastInitFailLogTime = -30f;

		private MinimapMode _mode = MinimapMode.Dev;

		private readonly Dictionary<string, ZoneVisual> _zoneVisuals = new Dictionary<string, ZoneVisual>();

		private bool _debugZonesVisible = true;

		public static Minimap3DService Instance
		{
			get
			{
				if (_instance == null)
				{
					_instance = new Minimap3DService();
				}
				return _instance;
			}
		}

		private Minimap3DService()
		{
		}

		public void Toggle()
		{
			if (EnsureInitialized())
			{
				_isVisible = !_isVisible;
				if (!_isVisible)
				{
					SetFullscreen(enabled: false);
					SetCursorInteraction(enabled: false);
				}
				if ((Object)(object)_panelGO != (Object)null)
				{
					_panelGO.SetActive(_isVisible);
				}
			}
		}

		public void ToggleFullscreen()
		{
			if (EnsureInitialized())
			{
				if (!_isVisible)
				{
					_isVisible = true;
					_panelGO.SetActive(true);
				}
				SetFullscreen(!_isFullscreen);
			}
		}

		public void EnsureDevMode()
		{
			SetMode(MinimapMode.Dev);
		}

		public void EnsurePlayerMode()
		{
			SetMode(MinimapMode.Player);
		}

		public static bool IsInsideNamedZone(Vector3 worldPosition, string zoneName)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			if (string.IsNullOrWhiteSpace(zoneName))
			{
				return false;
			}
			MinimapZone[] zonesForCurrentMap = GetZonesForCurrentMap();
			if (zonesForCurrentMap == null || zonesForCurrentMap.Length == 0)
			{
				return false;
			}
			Vector2 point = default(Vector2);
			((Vector2)(ref point))..ctor(worldPosition.x, worldPosition.z);
			for (int i = 0; i < zonesForCurrentMap.Length; i++)
			{
				if (string.Equals(zonesForCurrentMap[i].Name, zoneName, StringComparison.OrdinalIgnoreCase))
				{
					return IsPointInPolygon(point, zonesForCurrentMap[i].PolygonXZ);
				}
			}
			return false;
		}

		public void Tick()
		{
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: 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)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: 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_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			if (!_isVisible || !EnsureInitialized() || (Object)(object)_camera == (Object)null)
			{
				return;
			}
			PlayerController local = PlayerController.Local;
			if ((Object)(object)local == (Object)null)
			{
				return;
			}
			Vector3 position = ((Component)local).transform.position;
			Vector3 val;
			if (_mode == MinimapMode.Player)
			{
				_panOffset = Vector2.zero;
				_manualZoomOffset = 0f;
				_followHeight = 5f;
				_cameraPitch = 90f;
				val = position;
			}
			else
			{
				ApplySceneDefaultsIfNeeded(local);
				ProcessPanInputs();
				ProcessHeightAndAngleInputs();
				val = position + new Vector3(_panOffset.x, 0f, _panOffset.y);
			}
			float num = Mathf.Min(_followHeight, 40f);
			Vector3 val2 = val + new Vector3(0f, num, 0f);
			((Component)_camera).transform.position = Vector3.Lerp(((Component)_camera).transform.position, val2, Time.deltaTime * 8f);
			((Component)_camera).transform.rotation = Quaternion.Euler(_cameraPitch, 0f, 0f);
			float num2 = Mathf.Clamp(14f + _followHeight * 0.42f + _manualZoomOffset, 12f, 140f);
			_camera.orthographicSize = Mathf.Lerp(_camera.orthographicSize, num2, Time.deltaTime * 8f);
			if ((Object)(object)_coordsText != (Object)null)
			{
				if (_mode == MinimapMode.Player)
				{
					_coordsText.text = "Zone: " + ResolveZoneName(position);
				}
				else
				{
					string zoneName;
					bool flag = TryResolveZoneName(position, out zoneName);
					string text = ResolveZoneName(position);
					_coordsText.text = $"X: {position.x:0.0}   Y: {position.y:0.0}   Z: {position.z:0.0}" + "   Zone: " + (flag ? zoneName : ("ECHEC -> " + text));
				}
			}
			if (_mode == MinimapMode.Dev && (Object)(object)_panelRect != (Object)null && RectTransformUtility.RectangleContainsScreenPoint(_panelRect, Vector2.op_Implicit(Input.mousePosition)))
			{
				float axis = Input.GetAxis("Mouse ScrollWheel");
				if (Math.Abs(axis) > 0.0001f)
				{
					_manualZoomOffset = Mathf.Clamp(_manualZoomOffset - axis * 18f, -35f, 65f);
				}
			}
			if (_mode == MinimapMode.Dev && Input.GetKeyDown((KeyCode)287))
			{
				_debugZonesVisible = !_debugZonesVisible;
				Log.Info("[Minimap3DService] debug zones " + (_debugZonesVisible ? "enabled" : "disabled"));
			}
			if (_mode == MinimapMode.Dev && _isFullscreen && _debugZonesVisible)
			{
				UpdateZoneOverlayVisuals();
			}
			else
			{
				HideZoneOverlayVisuals();
			}
		}

		public void Dispose()
		{
			_isVisible = false;
			SetFullscreen(enabled: false);
			SetCursorInteraction(enabled: false);
			if ((Object)(object)_camera != (Object)null)
			{
				_camera.targetTexture = null;
			}
			if ((Object)(object)_renderTexture != (Object)null)
			{
				_renderTexture.Release();
				Object.Destroy((Object)(object)_renderTexture);
				_renderTexture = null;
			}
			if ((Object)(object)_cameraGO != (Object)null)
			{
				Object.Destroy((Object)(object)_cameraGO);
				_cameraGO = null;
				_camera = null;
			}
			if ((Object)(object)_panelGO != (Object)null)
			{
				Object.Destroy((Object)(object)_panelGO);
				_panelGO = null;
				_panelRect = null;
				_viewportRect = null;
				_zonesOverlayRect = null;
				_rawImage = null;
				_viewportAspectFitter = null;
				_coordsText = null;
				_zoneVisuals.Clear();
			}
		}

		private bool EnsureInitialized()
		{
			if ((Object)(object)_panelGO != (Object)null && (Object)(object)_panelRect != (Object)null && (Object)(object)_camera != (Object)null && (Object)(object)_renderTexture != (Object)null)
			{
				return true;
			}
			return TryInitialize();
		}

		private void SetMode(MinimapMode mode)
		{
			if (_mode != mode)
			{
				_mode = mode;
				if (_mode == MinimapMode.Player)
				{
					SetFullscreen(enabled: false);
					SetCursorInteraction(enabled: false);
				}
			}
		}

		private bool TryInitialize()
		{
			if ((Object)(object)GameManager.Instance?.gameUI == (Object)null)
			{
				LogInitFailure("Game UI unavailable");
				return false;
			}
			Transform val = (((Object)(object)GameManager.Instance.gameUI.fixedMenu != (Object)null) ? GameManager.Instance.gameUI.fixedMenu.transform : ((Component)GameManager.Instance.gameUI).transform);
			if ((Object)(object)val == (Object)null)
			{
				LogInitFailure("Could not resolve minimap parent transform");
				return false;
			}
			BuildPanel(val);
			BuildCamera();
			if ((Object)(object)_rawImage != (Object)null)
			{
				_rawImage.texture = (Texture)(object)_renderTexture;
			}
			if ((Object)(object)_panelGO != (Object)null)
			{
				_panelGO.SetActive(false);
			}
			Log.Info("[Minimap3DService] 3D minimap initialized");
			return (Object)(object)_panelGO != (Object)null && (Object)(object)_camera != (Object)null && (Object)(object)_renderTexture != (Object)null;
		}

		private void BuildPanel(Transform parent)
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Expected O, but got Unknown
			//IL_0181: 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_01ad: 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_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Expected O, but got Unknown
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_028a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			_panelGO = new GameObject("LycansDuckMinimapPanel", new Type[3]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image)
			});
			_panelRect = _panelGO.GetComponent<RectTransform>();
			((Transform)_panelRect).SetParent(parent, false);
			_panelRect.anchorMin = new Vector2(1f, 1f);
			_panelRect.anchorMax = new Vector2(1f, 1f);
			_panelRect.pivot = new Vector2(1f, 1f);
			_panelRect.anchoredPosition = new Vector2(-24f, -24f);
			_panelRect.sizeDelta = CompactPanelSize;
			Image component = _panelGO.GetComponent<Image>();
			((Graphic)component).color = new Color(0.05f, 0.08f, 0.12f, 0.68f);
			MinimapPanelDragHandler minimapPanelDragHandler = _panelGO.AddComponent<MinimapPanelDragHandler>();
			minimapPanelDragHandler.Configure(_panelRect);
			GameObject val = new GameObject("Viewport", new Type[3]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(RawImage)
			});
			_viewportRect = val.GetComponent<RectTransform>();
			((Transform)_viewportRect).SetParent(_panelGO.transform, false);
			_viewportRect.anchorMin = Vector2.zero;
			_viewportRect.anchorMax = Vector2.one;
			_viewportRect.offsetMin = new Vector2(8f, 58f);
			_viewportRect.offsetMax = new Vector2(-8f, -8f);
			_rawImage = val.GetComponent<RawImage>();
			((Graphic)_rawImage).color = Color.white;
			_viewportAspectFitter = val.AddComponent<AspectRatioFitter>();
			_viewportAspectFitter.aspectMode = (AspectMode)4;
			_viewportAspectFitter.aspectRatio = 1f;
			GameObject val2 = new GameObject("ZonesOverlay", new Type[1] { typeof(RectTransform) });
			_zonesOverlayRect = val2.GetComponent<RectTransform>();
			((Transform)_zonesOverlayRect).SetParent(_panelGO.transform, false);
			_zonesOverlayRect.anchorMin = Vector2.zero;
			_zonesOverlayRect.anchorMax = Vector2.one;
			_zonesOverlayRect.offsetMin = _viewportRect.offsetMin;
			_zonesOverlayRect.offsetMax = _viewportRect.offsetMax;
			((Transform)_zonesOverlayRect).SetAsLastSibling();
			BuildCoordinatesText();
		}

		private void BuildCamera()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Expected O, but got Unknown
			_cameraGO = new GameObject("LycansDuckMinimapCamera");
			_camera = _cameraGO.AddComponent<Camera>();
			_camera.clearFlags = (CameraClearFlags)2;
			_camera.backgroundColor = new Color(0.02f, 0.03f, 0.05f, 1f);
			_camera.orthographic = true;
			_camera.orthographicSize = 42f;
			_camera.nearClipPlane = 0.3f;
			_camera.farClipPlane = 1200f;
			_camera.cullingMask = -1;
			_camera.depth = -100f;
			_cameraGO.AddComponent<MinimapNoFogCamera>();
			_renderTexture = new RenderTexture(512, 512, 16, (RenderTextureFormat)0)
			{
				name = "LycansDuckMinimapRT"
			};
			_renderTexture.Create();
			_camera.targetTexture = _renderTexture;
			((Behaviour)_camera).enabled = true;
		}

		private void BuildCoordinatesText()
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Expected O, but got Unknown
			//IL_0076: 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_00a2: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Expected O, but got Unknown
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0235: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_panelGO == (Object)null))
			{
				GameObject val = new GameObject("CoordsBackground", new Type[3]
				{
					typeof(RectTransform),
					typeof(CanvasRenderer),
					typeof(Image)
				});
				RectTransform component = val.GetComponent<RectTransform>();
				((Transform)component).SetParent(_panelGO.transform, false);
				component.anchorMin = new Vector2(0.5f, 0f);
				component.anchorMax = new Vector2(0.5f, 0f);
				component.pivot = new Vector2(0.5f, 0f);
				component.anchoredPosition = new Vector2(0f, 18f);
				component.sizeDelta = new Vector2(246f, 28f);
				Image component2 = val.GetComponent<Image>();
				((Graphic)component2).color = new Color(0.03f, 0.05f, 0.08f, 0.82f);
				GameObject val2 = new GameObject("CoordsText", new Type[4]
				{
					typeof(RectTransform),
					typeof(CanvasRenderer),
					typeof(Text),
					typeof(Outline)
				});
				RectTransform component3 = val2.GetComponent<RectTransform>();
				((Transform)component3).SetParent(val.transform, false);
				component3.anchorMin = Vector2.zero;
				component3.anchorMax = Vector2.one;
				component3.offsetMin = new Vector2(6f, 2f);
				component3.offsetMax = new Vector2(-6f, -2f);
				_coordsText = val2.GetComponent<Text>();
				_coordsText.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
				_coordsText.fontSize = 14;
				_coordsText.alignment = (TextAnchor)4;
				((Graphic)_coordsText).color = new Color(0.88f, 0.92f, 0.98f, 1f);
				_coordsText.text = "X: 0.0   Y: 0.0   Z: 0.0";
				Outline component4 = val2.GetComponent<Outline>();
				((Shadow)component4).effectColor = new Color(0f, 0f, 0f, 0.9f);
				((Shadow)component4).effectDistance = new Vector2(1f, -1f);
			}
		}

		private void ProcessHeightAndAngleInputs()
		{
			if (Input.GetKey((KeyCode)264))
			{
				_followHeight += 55f * Time.deltaTime;
			}
			if (Input.GetKey((KeyCode)258))
			{
				_followHeight -= 55f * Time.deltaTime;
			}
			if (Input.GetKey((KeyCode)262))
			{
				_cameraPitch += 65f * Time.deltaTime;
			}
			if (Input.GetKey((KeyCode)260))
			{
				_cameraPitch -= 65f * Time.deltaTime;
			}
			_followHeight = Mathf.Clamp(_followHeight, 5f, 250f);
			_cameraPitch = Mathf.Clamp(_cameraPitch, 35f, 90f);
		}

		private void ProcessPanInputs()
		{
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//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_00b7: Unknown result type (might be due to invalid IL or missing references)
			float num = 0f;
			float num2 = 0f;
			if (Input.GetKey((KeyCode)276))
			{
				num -= 1f;
			}
			if (Input.GetKey((KeyCode)275))
			{
				num += 1f;
			}
			if (Input.GetKey((KeyCode)273))
			{
				num2 += 1f;
			}
			if (Input.GetKey((KeyCode)274))
			{
				num2 -= 1f;
			}
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(num, num2);
			if (((Vector2)(ref val)).sqrMagnitude > 1f)
			{
				((Vector2)(ref val)).Normalize();
			}
			_panOffset += val * (60f * Time.deltaTime);
		}

		private void ApplySceneDefaultsIfNeeded(PlayerController localPlayer)
		{
			int currentMapId = GetCurrentMapId();
			if (_defaultsMapId != currentMapId)
			{
				_defaultsMapId = currentMapId;
				_defaultsAppliedForCurrentScene = false;
			}
			if (!_defaultsAppliedForCurrentScene)
			{
				_defaultsAppliedForCurrentScene = true;
				switch (currentMapId)
				{
				case 1:
					ApplyMapDefaults(localPlayer, "MAP 1", 160f, 22.3f, 176f, 215f, 90f);
					break;
				case 2:
					ApplyMapDefaults(localPlayer, "MAP 2", 403.6f, 23.1f, -121.3f, 78.1f, 90f);
					break;
				}
			}
		}

		private void ApplyMapDefaults(PlayerController localPlayer, string mapLabel, float targetX, float targetY, float targetZ, float height, float angle)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = ((Component)localPlayer).transform.position;
			_panOffset = new Vector2(targetX - position.x, targetZ - position.z);
			_followHeight = height;
			_cameraPitch = angle;
			_manualZoomOffset = 0f;
			Log.Info($"[Minimap3DService] {mapLabel} defaults applied: X={targetX:0.0} Y={targetY:0.0} Z={targetZ:0.0} H={height:0.0} A={angle:0.0}");
		}

		private static string ResolveZoneName(Vector3 playerPosition)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: 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_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			if (TryResolveZoneName(playerPosition, out var zoneName))
			{
				return zoneName;
			}
			MinimapZone[] zonesForCurrentMap = GetZonesForCurrentMap();
			if (zonesForCurrentMap == null || zonesForCurrentMap.Length == 0)
			{
				return "Inconnue";
			}
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(playerPosition.x, playerPosition.z);
			string name = zonesForCurrentMap[0].Name;
			float num = float.MaxValue;
			int num2 = int.MinValue;
			string result = string.Empty;
			for (int i = 0; i < zonesForCurrentMap.Length; i++)
			{
				if (IsPointInPolygon(val, zonesForCurrentMap[i].PolygonXZ))
				{
					int zoneTypePriority = GetZoneTypePriority(zonesForCurrentMap[i].Type);
					if (zoneTypePriority > num2)
					{
						num2 = zoneTypePriority;
						result = zonesForCurrentMap[i].Name;
					}
				}
				Vector2 val2 = ComputePolygonCentroid(zonesForCurrentMap[i].PolygonXZ);
				Vector2 val3 = val - val2;
				float sqrMagnitude = ((Vector2)(ref val3)).sqrMagnitude;
				if (sqrMagnitude < num)
				{
					num = sqrMagnitude;
					name = zonesForCurrentMap[i].Name;
				}
			}
			if (num2 != int.MinValue)
			{
				return result;
			}
			return name;
		}

		private static bool TryResolveZoneName(Vector3 playerPosition, out string zoneName)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			zoneName = string.Empty;
			MinimapZone[] zonesForCurrentMap = GetZonesForCurrentMap();
			if (zonesForCurrentMap == null || zonesForCurrentMap.Length == 0)
			{
				return false;
			}
			Vector2 point = default(Vector2);
			((Vector2)(ref point))..ctor(playerPosition.x, playerPosition.z);
			int num = int.MinValue;
			for (int i = 0; i < zonesForCurrentMap.Length; i++)
			{
				if (IsPointInPolygon(point, zonesForCurrentMap[i].PolygonXZ))
				{
					int zoneTypePriority = GetZoneTypePriority(zonesForCurrentMap[i].Type);
					if (zoneTypePriority > num)
					{
						num = zoneTypePriority;
						zoneName = zonesForCurrentMap[i].Name;
					}
				}
			}
			return num != int.MinValue;
		}

		private static int GetCurrentMapId()
		{
			return ((Object)(object)GameManager.Instance != (Object)null) ? GameManager.Instance._MapID : (-1);
		}

		private static MinimapZone[] GetZonesForCurrentMap()
		{
			return GetCurrentMapId() switch
			{
				1 => Map1Zones, 
				2 => Map2Zones, 
				_ => null, 
			};
		}

		private static bool IsPointInPolygon(Vector2 point, Vector2[] polygon)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			if (polygon == null || polygon.Length < 3)
			{
				return false;
			}
			bool flag = false;
			int num = polygon.Length - 1;
			int num2 = 0;
			while (num2 < polygon.Length)
			{
				if (polygon[num2].y > point.y != polygon[num].y > point.y && point.x < (polygon[num].x - polygon[num2].x) * (point.y - polygon[num2].y) / (polygon[num].y - polygon[num2].y + Mathf.Epsilon) + polygon[num2].x)
				{
					flag = !flag;
				}
				num = num2++;
			}
			return flag;
		}

		private static Vector2 ComputePolygonCentroid(Vector2[] polygon)
		{
			//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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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_0024: 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_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)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			if (polygon == null || polygon.Length == 0)
			{
				return Vector2.zero;
			}
			Vector2 val = Vector2.zero;
			for (int i = 0; i < polygon.Length; i++)
			{
				val += polygon[i];
			}
			return val / (float)polygon.Length;
		}

		private static Color GetZoneBorderColor(MinimapZoneType type)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			return (Color)(type switch
			{
				MinimapZoneType.Settlement => new Color(0.95f, 0.79f, 0.23f, 0.95f), 
				MinimapZoneType.Nature => new Color(0.25f, 0.86f, 0.42f, 0.95f), 
				MinimapZoneType.Ruins => new Color(0.92f, 0.38f, 0.32f, 0.95f), 
				MinimapZoneType.Coast => new Color(0.21f, 0.66f, 0.96f, 0.95f), 
				MinimapZoneType.Fishing => new Color(0.64f, 0.52f, 0.96f, 0.95f), 
				_ => Color.white, 
			});
		}

		private static Color GetZoneFillColor(MinimapZoneType type)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: 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)
			//IL_0015: 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)
			Color zoneBorderColor = GetZoneBorderColor(type);
			zoneBorderColor.a = 0.22f;
			return zoneBorderColor;
		}

		private static int GetZoneTypePriority(MinimapZoneType type)
		{
			return type switch
			{
				MinimapZoneType.Fishing => 5, 
				MinimapZoneType.Ruins => 4, 
				MinimapZoneType.Settlement => 3, 
				MinimapZoneType.Coast => 2, 
				MinimapZoneType.Nature => 1, 
				_ => 0, 
			};
		}

		private void LogInitFailure(string reason)
		{
			if (!(Time.realtimeSinceStartup - _lastInitFailLogTime < 5f))
			{
				_lastInitFailLogTime = Time.realtimeSinceStartup;
				Log.Warning("[Minimap3DService] init failed: " + reason);
			}
		}

		private void SetFullscreen(bool enabled)
		{
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: 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_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: 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_01cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: 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_01a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_panelRect == (Object)null || enabled == _isFullscreen)
			{
				return;
			}
			if (enabled)
			{
				_savedAnchorMin = _panelRect.anchorMin;
				_savedAnchorMax = _panelRect.anchorMax;
				_savedPivot = _panelRect.pivot;
				_savedSizeDelta = _panelRect.sizeDelta;
				_savedAnchoredPosition = _panelRect.anchoredPosition;
				_hasSavedWindowLayout = true;
				_panelRect.anchorMin = Vector2.zero;
				_panelRect.anchorMax = Vector2.one;
				_panelRect.pivot = new Vector2(0.5f, 0.5f);
				_panelRect.anchoredPosition = Vector2.zero;
				_panelRect.offsetMin = new Vector2(16f, 16f);
				_panelRect.offsetMax = new Vector2(-16f, -16f);
				int width = Mathf.Max(640, Mathf.RoundToInt(1080f * ((float)Screen.width / (float)Mathf.Max(1, Screen.height))));
				RecreateRenderTexture(width, 1080);
				_isFullscreen = true;
				SetCursorInteraction(enabled: true);
			}
			else
			{
				if (_hasSavedWindowLayout)
				{
					_panelRect.anchorMin = _savedAnchorMin;
					_panelRect.anchorMax = _savedAnchorMax;
					_panelRect.pivot = _savedPivot;
					_panelRect.sizeDelta = _savedSizeDelta;
					_panelRect.anchoredPosition = _savedAnchoredPosition;
				}
				_isFullscreen = false;
				_panelRect.sizeDelta = CompactPanelSize;
				RecreateRenderTexture(512, 512);
				SetCursorInteraction(enabled: false);
			}
		}

		private void RecreateRenderTexture(int width, int height)
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			if (!((Object)(object)_camera == (Object)null) && width > 0 && height > 0)
			{
				if ((Object)(object)_renderTexture != (Object)null)
				{
					_camera.targetTexture = null;
					_renderTexture.Release();
					Object.Destroy((Object)(object)_renderTexture);
				}
				_renderTexture = new RenderTexture(width, height, 16, (RenderTextureFormat)0)
				{
					name = "LycansDuckMinimapRT"
				};
				_renderTexture.Create();
				_camera.targetTexture = _renderTexture;
				if ((Object)(object)_rawImage != (Object)null)
				{
					_rawImage.texture = (Texture)(object)_renderTexture;
				}
				if ((Object)(object)_viewportAspectFitter != (Object)null)
				{
					_viewportAspectFitter.aspectRatio = (float)width / (float)height;
				}
			}
		}

		private void SetCursorInteraction(bool enabled)
		{
			//IL_0045: 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)
			if (enabled != _cursorInteractionEnabled)
			{
				if (enabled)
				{
					_savedCursorVisible = Cursor.visible;
					_savedCursorLockState = Cursor.lockState;
					Cursor.lockState = (CursorLockMode)0;
					Cursor.visible = true;
					_cursorInteractionEnabled = true;
				}
				else
				{
					Cursor.lockState = _savedCursorLockState;
					Cursor.visible = _savedCursorVisible;
					_cursorInteractionEnabled = false;
				}
			}
		}

		private void UpdateZoneOverlayVisuals()
		{
			//IL_00ab: 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_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: 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_0260: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_0269: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: 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_0307: Unknown result type (might be due to invalid IL or missing references)
			//IL_0317: Unknown result type (might be due to invalid IL or missing references)
			//IL_031c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0320: Unknown result type (might be due to invalid IL or missing references)
			//IL_0325: 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_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0350: Unknown result type (might be due to invalid IL or missing references)
			//IL_0354: Unknown result type (might be due to invalid IL or missing references)
			//IL_0359: Unknown result type (might be due to invalid IL or missing references)
			//IL_035b: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_035f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0364: Unknown result type (might be due to invalid IL or missing references)
			//IL_0366: Unknown result type (might be due to invalid IL or missing references)
			//IL_0368: Unknown result type (might be due to invalid IL or missing references)
			//IL_036a: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0375: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_037c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0396: Unknown result type (might be due to invalid IL or missing references)
			//IL_038d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0491: Unknown result type (might be due to invalid IL or missing references)
			//IL_0496: Unknown result type (might be due to invalid IL or missing references)
			//IL_04cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0528: Unknown result type (might be due to invalid IL or missing references)
			//IL_0404: Unknown result type (might be due to invalid IL or missing references)
			//IL_0413: Unknown result type (might be due to invalid IL or missing references)
			//IL_0415: Unknown result type (might be due to invalid IL or missing references)
			//IL_03db: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_zonesOverlayRect == (Object)null || (Object)(object)_camera == (Object)null)
			{
				return;
			}
			MinimapZone[] zones = GetZonesForCurrentMap();
			if (zones == null || zones.Length == 0)
			{
				HideZoneOverlayVisuals();
				return;
			}
			HashSet<string> hashSet = new HashSet<string>();
			float orthographicSize = _camera.orthographicSize;
			float num = orthographicSize * _camera.aspect;
			if (orthographicSize <= 0f || num <= 0f)
			{
				return;
			}
			Rect rect = _zonesOverlayRect.rect;
			if (((Rect)(ref rect)).width <= 1f || ((Rect)(ref rect)).height <= 1f)
			{
				return;
			}
			List<int> list = new List<int>(zones.Length);
			for (int i = 0; i < zones.Length; i++)
			{
				list.Add(i);
			}
			list.Sort(delegate(int a, int b)
			{
				int zoneTypePriority = GetZoneTypePriority(zones[a].Type);
				int zoneTypePriority2 = GetZoneTypePriority(zones[b].Type);
				return zoneTypePriority.CompareTo(zoneTypePriority2);
			});
			for (int j = 0; j < list.Count; j++)
			{
				int num2 = list[j];
				string text = zones[num2].Name + "_" + num2;
				hashSet.Add(text);
				if (!_zoneVisuals.TryGetValue(text, out var value))
				{
					value = CreateZoneVisual(zones[num2]);
					_zoneVisuals[text] = value;
				}
				Color zoneBorderColor = GetZoneBorderColor(zones[num2].Type);
				Color zoneFillColor = GetZoneFillColor(zones[num2].Type);
				int num3 = ((zones[num2].PolygonXZ != null) ? zones[num2].PolygonXZ.Length : 0);
				if (num3 < 3)
				{
					((Component)value.Root).gameObject.SetActive(false);
					continue;
				}
				EnsureEdgePool(value, num3);
				Vector2 worldXZ = ComputePolygonCentroid(zones[num2].PolygonXZ);
				Vector2 val = WorldToOverlayLocal(worldXZ, ((Component)_camera).transform.position, rect, num, orthographicSize);
				value.Root.anchoredPosition = val;
				((Transform)value.Root).SetSiblingIndex(j);
				value.Label.text = zones[num2].Name;
				((Graphic)value.Label).color = zoneBorderColor;
				Vector2[] array = (Vector2[])(object)new Vector2[num3];
				float num4 = float.MaxValue;
				float num5 = float.MaxValue;
				float num6 = float.MinValue;
				float num7 = float.MinValue;
				for (int k = 0; k < num3; k++)
				{
					int num8 = (k + 1) % num3;
					Vector2 val2 = WorldToOverlayLocal(zones[num2].PolygonXZ[k], ((Component)_camera).transform.position, rect, num, orthographicSize);
					Vector2 val3 = WorldToOverlayLocal(zones[num2].PolygonXZ[num8], ((Component)_camera).transform.position, rect, num, orthographicSize);
					Vector2 val4 = val2 - val;
					Vector2 to = val3 - val;
					array[k] = val4;
					if (val2.x < num4)
					{
						num4 = val2.x;
					}
					if (val2.y < num5)
					{
						num5 = val2.y;
					}
					if (val2.x > num6)
					{
						num6 = val2.x;
					}
					if (val2.y > num7)
					{
						num7 = val2.y;
					}
					Image val5 = value.Edges[k];
					((Component)val5).gameObject.SetActive(true);
					((Graphic)val5).color = zoneBorderColor;
					PositionEdge(((Graphic)val5).rectTransform, val4, to);
				}
				if (value.Edges.Count > num3)
				{
					for (int l = num3; l < value.Edges.Count; l++)
					{
						((Component)value.Edges[l]).gameObject.SetActive(false);
					}
				}
				Rect val6 = Rect.MinMaxRect(num4, num5, num6, num7);
				Rect val7 = Rect.MinMaxRect(-0.75f * ((Rect)(ref rect)).width, -0.75f * ((Rect)(ref rect)).height, 0.75f * ((Rect)(ref rect)).width, 0.75f * ((Rect)(ref rect)).height);
				bool active = ((Rect)(ref val6)).Overlaps(val7, true);
				((Component)value.Root).gameObject.SetActive(active);
				if (((Component)value.Root).gameObject.activeSelf && (Object)(object)value.FillGraphic != (Object)null)
				{
					value.FillGraphic.SetPolygon(array, zoneFillColor);
				}
			}
			foreach (KeyValuePair<string, ZoneVisual> zoneVisual in _zoneVisuals)
			{
				if (!hashSet.Contains(zoneVisual.Key))
				{
					((Component)zoneVisual.Value.Root).gameObject.SetActive(false);
				}
			}
		}

		private ZoneVisual CreateZoneVisual(MinimapZone zone)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: 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_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Expected O, but got Unknown
			//IL_01e0: 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_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cc: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Zone_" + zone.Name, new Type[3]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Image)
			});
			RectTransform component = val.GetComponent<RectTransform>();
			((Transform)component).SetParent((Transform)(object)_zonesOverlayRect, false);
			component.anchorMin = new Vector2(0.5f, 0.5f);
			component.anchorMax = new Vector2(0.5f, 0.5f);
			component.pivot = new Vector2(0.5f, 0.5f);
			component.sizeDelta = new Vector2(18f, 18f);
			Image component2 = val.GetComponent<Image>();
			((Graphic)component2).color = Color.clear;
			GameObject val2 = new GameObject("Fill", new Type[3]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(ZonePolygonGraphic)
			});
			RectTransform component3 = val2.GetComponent<RectTransform>();
			((Transform)component3).SetParent((Transform)(object)component, false);
			component3.anchorMin = new Vector2(0.5f, 0.5f);
			component3.anchorMax = new Vector2(0.5f, 0.5f);
			component3.pivot = new Vector2(0.5f, 0.5f);
			component3.sizeDelta = new Vector2(1f, 1f);
			ZonePolygonGraphic component4 = val2.GetComponent<ZonePolygonGraphic>();
			((Graphic)component4).raycastTarget = false;
			GameObject val3 = new GameObject("Label", new Type[4]
			{
				typeof(RectTransform),
				typeof(CanvasRenderer),
				typeof(Text),
				typeof(Outline)
			});
			RectTransform component5 = val3.GetComponent<RectTransform>();
			((Transform)component5).SetParent((Transform)(object)component, false);
			component5.anchorMin = new Vector2(0.5f, 1f);
			component5.anchorMax = new Vector2(0.5f, 1f);
			component5.pivot = new Vector2(0.5f, 0f);
			component5.anchoredPosition = new Vector2(0f, 6f);
			component5.sizeDelta = new Vector2(140f, 20f);
			Text component6 = val3.GetComponent<Text>();
			component6.font = Resources.GetBuiltinResource<Font>("Arial.ttf");
			component6.fontSize = 14;
			component6.alignment = (TextAnchor)4;
			((Graphic)component6).color = GetZoneBorderColor(zone.Type);
			component6.text = zone.Name;
			Outline component7 = val3.GetComponent<Outline>();
			((Shadow)component7).effectColor = new Color(0f, 0f, 0f, 0.9f);
			((Shadow)component7).effectDistance = new Vector2(1f, -1f);
			return new ZoneVisual
			{
				Root = component,
				Label = component6,
				FillGraphic = component4
			};
		}

		private static void PositionEdge(RectTransform rect, Vector2 from, Vector2 to)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: 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)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			Vector2 val = to - from;
			float num = Mathf.Max(1f, ((Vector2)(ref val)).magnitude);
			rect.anchorMin = new Vector2(0.5f, 0.5f);
			rect.anchorMax = new Vector2(0.5f, 0.5f);
			rect.pivot = new Vector2(0.5f, 0.5f);
			rect.anchoredPosition = (from + to) * 0.5f;
			rect.sizeDelta = new Vector2(num, 2.5f);
			float num2 = Mathf.Atan2(val.y, val.x) * 57.29578f;
			((Transform)rect).localRotation = Quaternion.Euler(0f, 0f, num2);
		}

		private static Vector2 WorldToOverlayLocal(Vector2 worldXZ, Vector3 cameraPosition, Rect overlayRect, float halfWidth, float halfHeight)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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)
			float num = 0.5f + (worldXZ.x - cameraPosition.x) / (2f * halfWidth);
			float num2 = 0.5f + (worldXZ.y - cameraPosition.z) / (2f * halfHeight);
			return new Vector2((num - 0.5f) * ((Rect)(ref overlayRect)).width, (num2 - 0.5f) * ((Rect)(ref overlayRect)).height);
		}

		private static bool IsLocalPointNearOverlay(Vector2 localPoint, Rect overlayRect, float marginRatio)
		{
			//IL_0041: 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_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			float num = (-0.5f - marginRatio) * ((Rect)(ref overlayRect)).width;
			float num2 = (0.5f + marginRatio) * ((Rect)(ref overlayRect)).width;
			float num3 = (-0.5f - marginRatio) * ((Rect)(ref overlayRect)).height;
			float num4 = (0.5f + marginRatio) * ((Rect)(ref overlayRect)).height;
			return localPoint.x >= num && localPoint.x <= num2 && localPoint.y >= num3 && localPoint.y <= num4;
		}

		private static void EnsureEdgePool(ZoneVisual visual, int required)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			while (visual.Edges.Count < required)
			{
				GameObject val = new GameObject("Edge", new Type[3]
				{
					typeof(RectTransform),
					typeof(CanvasRenderer),
					typeof(Image)
				});
				RectTransform component = val.GetComponent<RectTransform>();
				((Transform)component).SetParent((Transform)(object)visual.Root, false);
				Image component2 = val.GetComponent<Image>();
				((Graphic)component2).raycastTarget = false;
				visual.Edges.Add(component2);
			}
		}

		private void HideZoneOverlayVisuals()
		{
			foreach (KeyValuePair<string, ZoneVisual> zoneVisual in _zoneVisuals)
			{
				if (zoneVisual.Value != null && (Object)(object)zoneVisual.Value.Root != (Object)null)
				{
					((Component)zoneVisual.Value.Root).gameObject.SetActive(false);
				}
			}
		}
	}
	internal sealed class ZonePolygonGraphic : Graphic
	{
		private readonly List<Vector2> _vertices = new List<Vector2>();

		private readonly List<int> _triangles = new List<int>();

		public void SetPolygon(Vector2[] vertices, Color fillColor)
		{
			//IL_0074: 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)
			_vertices.Clear();
			_triangles.Clear();
			if (vertices != null)
			{
				for (int i = 0; i < vertices.Length; i++)
				{
					_vertices.Add(vertices[i]);
				}
			}
			if (_vertices.Count >= 3)
			{
				Triangulate(_vertices, _triangles);
			}
			((Graphic)this).color = fillColor;
			((Graphic)this).SetVerticesDirty();
		}

		protected override void OnPopulateMesh(VertexHelper vh)
		{
			//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_0045: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: 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)
			vh.Clear();
			if (_vertices.Count >= 3 && _triangles.Count >= 3)
			{
				for (int i = 0; i < _vertices.Count; i++)
				{
					UIVertex simpleVert = UIVertex.simpleVert;
					simpleVert.position = Vector2.op_Implicit(_vertices[i]);
					simpleVert.color = Color32.op_Implicit(((Graphic)this).color);
					vh.AddVert(simpleVert);
				}
				for (int j = 0; j + 2 < _triangles.Count; j += 3)
				{
					vh.AddTriangle(_triangles[j], _triangles[j + 1], _triangles[j + 2]);
				}
			}
		}

		private static void Triangulate(List<Vector2> polygon, List<int> result)
		{
			//IL_00d6: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: 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_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)
			result.Clear();
			int count = polygon.Count;
			if (count < 3)
			{
				return;
			}
			List<int> list = new List<int>(count);
			if (SignedArea(polygon) > 0f)
			{
				for (int i = 0; i < count; i++)
				{
					list.Add(i);
				}
			}
			else
			{
				for (int num = count - 1; num >= 0; num--)
				{
					list.Add(num);
				}
			}
			int num2 = 0;
			while (list.Count > 2 && num2 < 1024)
			{
				num2++;
				bool flag = false;
				for (int j = 0; j < list.Count; j++)
				{
					int num3 = list[(j - 1 + list.Count) % list.Count];
					int num4 = list[j];
					int num5 = list[(j + 1) % list.Count];
					if (!IsConvex(polygon[num3], polygon[num4], polygon[num5]))
					{
						continue;
					}
					bool flag2 = false;
					for (int k = 0; k < list.Count; k++)
					{
						int num6 = list[k];
						if (num6 != num3 && num6 != num4 && num6 != num5 && PointInTriangle(polygon[num6], polygon[num3], polygon[num4], polygon[num5]))
						{
							flag2 = true;
							break;
						}
					}
					if (!flag2)
					{
						result.Add(num3);
						result.Add(num4);
						result.Add(num5);
						list.RemoveAt(j);
						flag = true;
						break;
					}
				}
				if (!flag)
				{
					result.Clear();
					for (int l = 1; l < count - 1; l++)
					{
						result.Add(0);
						result.Add(l);
						result.Add(l + 1);
					}
					break;
				}
			}
		}

		private static float SignedArea(List<Vector2> polygon)
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			float num = 0f;
			for (int i = 0; i < polygon.Count; i++)
			{
				int index = (i + 1) % polygon.Count;
				num += polygon[i].x * polygon[index].y - polygon[index].x * polygon[i].y;
			}
			return num * 0.5f;
		}

		private static bool IsConvex(Vector2 a, Vector2 b, Vector2 c)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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)
			float num = (b.x - a.x) * (c.y - a.y) - (b.y - a.y) * (c.x - a.x);
			return num > 0f;
		}

		private static bool PointInTriangle(Vector2 p, Vector2 a, Vector2 b, Vector2 c)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: 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_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			float num = Sign(p, a, b);
			float num2 = Sign(p, b, c);
			float num3 = Sign(p, c, a);
			bool flag = num < 0f || num2 < 0f || num3 < 0f;
			bool flag2 = num > 0f || num2 > 0f || num3 > 0f;
			return !(flag && flag2);
		}

		private static float Sign(Vector2 p1, Vector2 p2, Vector2 p3)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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)
			return (p1.x - p3.x) * (p2.y - p3.y) - (p2.x - p3.x) * (p1.y - p3.y);
		}
	}
	internal sealed class MinimapNoFogCamera : MonoBehaviour
	{
		private bool _previousFogState;

		private void OnPreRender()
		{
			_previousFogState = RenderSettings.fog;
			RenderSettings.fog = false;
		}

		private void OnPostRender()
		{
			RenderSettings.fog = _previousFogState;
		}
	}
	internal sealed class MinimapPanelDragHandler : MonoBehaviour, IBeginDragHandler, IEventSystemHandler, IDragHandler
	{
		private RectTransform _targetRect;

		private Canvas _canvas;

		public void Configure(RectTransform targetRect)
		{
			_targetRect = targetRect;
			_canvas = ((Component)targetRect).GetComponentInParent<Canvas>();
		}

		public void OnBeginDrag(PointerEventData eventData)
		{
			if ((Object)(object)_targetRect == (Object)null)
			{
				ref RectTransform targetRect = ref _targetRect;
				Transform transform = ((Component)this).transform;
				targetRect = (RectTransform)(object)((transform is RectTransform) ? transform : null);
			}
			if ((Object)(object)_canvas == (Object)null && (Object)(object)_targetRect != (Object)null)
			{
				_canvas = ((Component)_targetRect).GetComponentInParent<Canvas>();
			}
		}

		public void OnDrag(PointerEventData eventData)
		{
			//IL_004e: 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_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)_targetRect == (Object)null))
			{
				float num = (((Object)(object)_canvas != (Object)null && _canvas.scaleFactor > 0f) ? _canvas.scaleFactor : 1f);
				RectTransform targetRect = _targetRect;
				targetRect.anchoredPosition += eventData.delta / num;
			}
		}
	}
	internal static class NetworkObjectBootstrap
	{
		private static readonly string SheriffKey = "Knard.LycansSheriff.Sheriff";

		private static NetworkObject _sheriffPrefab;

		public static void EnsureAllRegistered()
		{
			EnsureSheriffRegistered();
		}

		public static void EnsureSheriffRegistered()
		{
			if (!((Object)(object)_sheriffPrefab != (Object)null))
			{
				_sheriffPrefab = RegisterRuntimePrefabIfNeeded(SheriffKey, "SheriffNetworkObject", delegate(GameObject prefab)
				{
					prefab.AddComponent<Sheriff>();
				});
			}
		}

		public static NetworkPrefabId GetSheriffPrefabId()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: 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)
			EnsureSheriffRegistered();
			return NetworkObjectService.Instance.GetNetworkObject(SheriffKey);
		}

		public static NetworkObject GetSheriffPrefab()
		{
			EnsureSheriffRegistered();
			return _sheriffPrefab;
		}

		private static NetworkObject RegisterRuntimePrefabIfNeeded(string uniqueKey, string objectName, Action<GameObject> configure)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Expected O, but got Unknown
			if (NetworkObjectService.Instance.NetworkObjectExist(uniqueKey))
			{
				Log.Info("[NetworkObjectBootstrap] Runtime prefab already registered: " + uniqueKey);
				NetworkObject networkObjectPrefab = NetworkObjectService.Instance.GetNetworkObjectPrefab(uniqueKey);
				if ((Object)(object)networkObjectPrefab != (Object)null)
				{
					return networkObjectPrefab;
				}
				Log.Warning("[NetworkObjectBootstrap] Registered prefab reference was destroyed, recreating: " + uniqueKey);
			}
			Log.Info("[NetworkObjectBootstrap] Registering runtime prefab: " + uniqueKey);
			GameObject val = new GameObject(objectName);
			NetworkObject result = val.AddComponent<NetworkObject>();
			configure(val);
			Object.DontDestroyOnLoad((Object)(object)val);
			try
			{
				NetworkObjectService.Instance.RegisterNetworkObject(val, uniqueKey);
				Log.Info("[NetworkObjectBootstrap] Runtime prefab registered successfully: " + uniqueKey);
				return result;
			}
			catch (Exception ex)
			{
				Log.Error("[NetworkObjectBootstrap] Failed to register runtime prefab " + uniqueKey + ": " + ex);
				throw;
			}
		}
	}
	internal static class StringExtensions
	{
		public static Guid ToGuid(this string value)
		{
			MD5 mD = MD5.Create();
			byte[] b = mD.ComputeHash(Encoding.UTF8.GetBytes(value));
			return new Guid(b);
		}
	}
	internal class NetworkObjectService
	{
		private static NetworkObjectService _instance;

		private Dictionary<string, NetworkPrefabId> _prefabs;

		private Dictionary<string, NetworkObject> _prefabObjects;

		public static NetworkObjectService Instance
		{
			get
			{
				if (_instance == null)
				{
					_instance = new NetworkObjectService();
				}
				return _instance;
			}
		}

		private NetworkObjectService()
		{
			_prefabs = new Dictionary<string, NetworkPrefabId>();
			_prefabObjects = new Dictionary<string, NetworkObject>();
		}

		public void RegisterNetworkObject(GameObject prefab, string uniqueKey)
		{
			//IL_0129: 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_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Expected O, but got Unknown
			//IL_014b: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0185: Unknown result type (might be due to invalid IL or missing references)
			Log.Info("[NetworkObjectService] RegisterNetworkObject start key=" + uniqueKey + ", prefabNull=" + ((Object)(object)prefab == (Object)null));
			if (string.IsNullOrWhiteSpace(uniqueKey))
			{
				throw new ArgumentException("uniqueKey cannot be null or whitespace", "uniqueKey");
			}
			if ((Object)(object)prefab == (Object)null)
			{
				throw new ArgumentNullException("prefab");
			}
			if (_prefabs.ContainsKey(uniqueKey))
			{
				NetworkObject val = default(NetworkObject);
				if (prefab.TryGetComponent<NetworkObject>(ref val))
				{
					val.NetworkedBehaviours = prefab.GetComponents<NetworkBehaviour>();
					val.NetworkGuid = new NetworkObjectGuid(uniqueKey.ToGuid().ToString());
					_prefabObjects[uniqueKey] = val;
				}
				Log.Info("[NetworkObjectService] RegisterNetworkObject skipped duplicate key=" + uniqueKey);
				return;
			}
			NetworkObject val2 = default(NetworkObject);
			if (!prefab.TryGetComponent<NetworkObject>(ref val2))
			{
				Log.Error("[NetworkObjectService] RegisterNetworkObject missing NetworkObject component key=" + uniqueKey);
				throw new MissingComponentException("Prefab is missing 'NetworkObject' component!");
			}
			Object.DontDestroyOnLoad((Object)(object)prefab);
			val2.NetworkedBehaviours = prefab.GetComponents<NetworkBehaviour>();
			val2.NetworkGuid = new NetworkObjectGuid(uniqueKey.ToGuid().ToString());
			NetworkPrefabSourceStatic val3 = new NetworkPrefabSourceStatic
			{
				PrefabReference = val2
			};
			NetworkPrefabId value = default(NetworkPrefabId);
			if (!NetworkProjectConfig.Global.PrefabTable.TryAdd(val2.NetworkGuid, (INetworkPrefabSource)(object)val3, ref value))
			{
				Log.Error("[NetworkObjectService] RegisterNetworkObject failed to add prefab in table key=" + uniqueKey);
				throw new ApplicationException("Could not add prefab to registered prefabs, was it already present?");
			}
			_prefabs.Add(uniqueKey, value);
			_prefabObjects.Add(uniqueKey, val2);
			Log.Info("[NetworkObjectService] RegisterNetworkObject success key=" + uniqueKey + ", totalRegistered=" + _prefabs.Count);
		}

		public NetworkPrefabId GetNetworkObject(string uniqueKey)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: 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)
			Log.Info("[NetworkObjectService] GetNetworkObject key=" + uniqueKey);
			if (_prefabs.TryGetValue(uniqueKey, out var value))
			{
				Log.Info("[NetworkObjectService] GetNetworkObject hit key=" + uniqueKey);
				return value;
			}
			Log.Error("[NetworkObjectService] GetNetworkObject miss key=" + uniqueKey + ", registeredCount=" + _prefabs.Count);
			throw new KeyNotFoundException("No prefab registered with '" + uniqueKey + "' as identifier!");
		}

		public NetworkObject GetNetworkObjectPrefab(string uniqueKey)
		{
			Log.Info("[NetworkObjectService] GetNetworkObjectPrefab key=" + uniqueKey);
			if (_prefabObjects.TryGetValue(uniqueKey, out var value))
			{
				if ((Object)(object)value == (Object)null)
				{
					Log.Warning("[NetworkObjectService] GetNetworkObjectPrefab stale Unity-null reference key=" + uniqueKey);
					_prefabObjects.Remove(uniqueKey);
					return null;
				}
				Log.Info("[NetworkObjectService] GetNetworkObjectPrefab hit key=" + uniqueKey);
				return value;
			}
			Log.Error("[NetworkObjectService] GetNetworkObjectPrefab miss key=" + uniqueKey + ", registeredCount=" + _prefabObjects.Count);
			throw new KeyNotFoundException("No prefab registered with '" + uniqueKey + "' as identifier!");
		}

		public bool NetworkObjectExist(string uniqueKey)
		{
			bool result = _prefabs.ContainsKey(uniqueKey);
			Log.Info("[NetworkObjectService] NetworkObjectExist key=" + uniqueKey + ", exists=" + result);
			return result;
		}
	}
	internal class LanguageService
	{
		private static LanguageService _instance;

		private readonly Dictionary<string, string> _translationDict = new Dictionary<string, string>();

		public static LanguageService Instance
		{
			get
			{
				if (_instance == null)
				{
					_instance = new LanguageService();
				}
				return _instance;
			}
		}

		private LanguageService()
		{
		}

		public void AddEntry(string key, string value)
		{
			_translationDict[key] = value;
		}

		public void HookLocalization()
		{
			Log.Info("[LanguageService] HookLocalization start");
			PopulateStringDatabase();
			LocalizationSettings.SelectedLocaleChanged += SelectedLocaleChanged;
			Log.Info("[LanguageService] HookLocalization complete");
		}

		private void SelectedLocaleChanged(Locale locale)
		{
			//IL_0017: 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)
			object obj;
			if (!((Object)(object)locale != (Object)null))
			{
				obj = "null";
			}
			else
			{
				LocaleIdentifier identifier = locale.Identifier;
				obj = ((LocaleIdentifier)(ref identifier)).Code;
			}
			Log.Info("[LanguageService] SelectedLocaleChanged locale=" + (string?)obj);
			PopulateStringDatabase();
		}

		public void PopulateStringDatabase()
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			Log.Info("[LanguageService] PopulateStringDatabase start entries=" + _translationDict.Count);
			StringTable table = ((LocalizedDatabase<StringTable, StringTableEntry>)(object)LocalizationSettings.StringDatabase).GetTable(TableReference.op_Implicit("UI Text"), (Locale)null);
			if ((Object)(object)table == (Object)null)
			{
				return;
			}
			int num = 0;
			foreach (KeyValuePair<string, string> item in _translationDict)
			{
				((DetailedLocalizationTable<StringTableEntry>)(object)table).AddEntry(item.Key, item.Value);
				num++;
			}
			Log.Info("[LanguageService] PopulateStringDatabase complete added=" + num);
		}
	}
	public class TranslationManager : MonoBehaviour
	{
		private Dictionary<string, string> translations = new Dictionary<string, string>();

		private Dictionary<string, Dictionary<string, string>> Alltranslations = null;

		private string languageCode;

		public static TranslationManager Instance { get; private set; }

		public TranslationManager()
		{
			languageCode = GetLanguageCode();
			Log.Info("[TranslationManager] ctor languageCode=" + languageCode);
			LoadTranslations();
			Instance = this;
		}

		private string GetLanguageCode()
		{
			int @int = PlayerPrefs.GetInt("SETTINGS_LANGUAGE");
			string text = ((@int == 0) ? "en" : "fr");
			Log.Info("[TranslationManager] GetLanguageCode setting=" + @int + " => " + text);
			return text;
		}

		private void LoadTranslations()
		{
			Log.Info("[TranslationManager] LoadTranslations start");
			if (Alltranslations != null)
			{
				Log.Info("[TranslationManager] Using cached translations languages=" + Alltranslations.Count);
				if (Alltranslations.ContainsKey(GetLanguageCode()))
				{
					translations = Alltranslations[GetLanguageCode()];
					Log.Info("[TranslationManager] Loaded cached language=" + GetLanguageCode() + " entries=" + translations.Count);
				}
			}
			else
			{
				string text = "LycansSheriff.Assets.Translations.translations.json";
				Assembly executingAssembly = Assembly.GetExecutingAssembly();
				Log.Info("[TranslationManager] Loading embedded resource=" + text);
				try
				{
					using Stream stream = executingAssembly.GetManifestResourceStream(text);
					if (stream != null)
					{
						using StreamReader streamReader = new StreamReader(stream);
						string text2 = streamReader.ReadToEnd();
						Dictionary<string, Dictionary<string, string>> alltranslations = JsonConvert.DeserializeObject<Dictionary<string, Dictionary<string, string>>>(text2);
						Alltranslations = alltranslations;
						Log.Info("[TranslationManager] JSON parsed languages=" + ((Alltranslations != null) ? Alltranslations.Count : 0));
						if (Alltranslations.ContainsKey(GetLanguageCode()))
						{
							translations = Alltranslations[GetLanguageCode()];
							Log.Info("[TranslationManager] Loaded language=" + GetLanguageCode() + " entries=" + translations.Count);
						}
					}
					else
					{
						Log.Error("[TranslationManager] Translations resource not found: " + text);
					}
				}
				catch (Exception ex)
				{
					Log.Error("[TranslationManager] LoadTranslations failed: " + ex);
				}
			}
			Log.Info("[TranslationManager] LoadTranslations complete activeEntries=" + ((translations != null) ? translations.Count : 0));
		}

		public string GetTranslation(string key)
		{
			if (translations.TryGetValue(key, out var value))
			{
				return value;
			}
			return key;
		}

		internal void populateTranslations()
		{
			Log.Info("[TranslationManager] populateTranslations start");
			LanguageService instance = LanguageService.Instance;
			if (Alltranslations == null)
			{
				return;
			}
			string text = GetLanguageCode();
			if (!Alltranslations.ContainsKey(text))
			{
				return;
			}
			translations = Alltranslations[text];
			Log.Info("[TranslationManager] populateTranslations language=" + text + " entries=" + translations.Count);
			int num = 0;
			foreach (KeyValuePair<string, string> translation in translations)
			{
				instance.AddEntry(translation.Key, translation.Value);
				num++;
			}
			Log.Info("[TranslationManager] populateTranslations complete pushed=" + num);
		}
	}
	internal class UIToggle
	{
		public GameObject ToggleGO { get; set; } = null;


		public LocalizeStringEvent LocalizeString { get; set; } = null;


		public Toggle UnityToggle { get; set; } = null;

	}
	public class UIButton
	{
		public GameObject ButtonGO { get; set; } = null;


		public LocalizeStringEvent LocalizeString { get; set; } = null;


		public TextMeshProUGUI TMPText { get; set; } = null;


		public Button UnityButton { get; set; } = null;


		public void attachToGameSettingsMenu()
		{
			ButtonGO.transform.SetParent((Transform)null);
			ButtonGO.transform.SetParent(GameManager.Instance.gameUI.gameSettingsMenu.transform.Find("LayoutGroup/Footer/LayoutGroup"));
		}

		public static UIButton cloneFromSource(string localisation)
		{
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: 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)
			Transform val = GameManager.Instance.gameUI.settingsMenu.transform.Find("LayoutGroup/Footer/LayoutGroup/SettingsButton");
			if ((Object)(object)val == (Object)null)
			{
				Log.Error("Could not get a Button copy to duplicate!");
				return null;
			}
			Transform val2 = Object.Instantiate<Transform>(val, val.parent);
			LocalizeStringEvent componentInChildren = ((Component)val2).GetComponentInChildren<LocalizeStringEvent>();
			TextMeshProUGUI componentInChildren2 = ((Component)val2).GetComponentInChildren<TextMeshProUGUI>();
			if ((Object)(object)componentInChildren == (Object)null || (Object)(object)componentInChildren2 == (Object)null)
			{
				if ((Object)(object)componentInChildren == (Object)null)
				{
					Log.Error(((Object)((Component)val2).gameObject).name + " does not contain LocalizeStringEvent component");
				}
				if ((Object)(object)componentInChildren2 == (Object)null)
				{
					Log.Error(((Object)((Component)val2).gameObject).name + " does not contain TextMeshProUGUI component");
				}
				Log.Error("Copied object does not contains required text or localized string");
				Object.Destroy((Object)(object)((Component)val2).gameObject);
				return null;
			}
			val2.parent = null;
			Button component = ((Component)val2).GetComponent<Button>();
			((UnityEventBase)component.onClick).RemoveAllListeners();
			((LocalizedReference)componentInChildren.StringReference).TableEntryReference = TableEntryReference.op_Implicit(localisation);
			((TMP_Text)componentInChildren2).text = LocalizationSettings.StringDatabase.GetLocalizedString(TableReference.op_Implicit("UI Text"), TableEntryReference.op_Implicit(localisation), (Locale)null, (FallbackBehavior)0, Array.Empty<object>());
			return new UIButton
			{
				ButtonGO = ((Component)val2).gameObject,
				LocalizeString = componentInChildren,
				TMPText = componentInChildren2,
				UnityButton = component
			};
		}

		public static UIButton cloneFromSourceWithoutLocalization(Transform parent)
		{
			Transform val = GameManager.Instance.gameUI.settingsMenu.transform.Find("LayoutGroup/Footer/LayoutGroup/SettingsButton");
			if ((Object)(object)val == (Object)null)
			{
				Log.Error("Could not get a Button copy to duplicate!");
				return null;
			}
			Transform val2 = (((Object)(object)parent == (Object)null) ? val.parent : parent);
			Transform val3 = Object.Instantiate<Transform>(val, val2);
			TextMeshProUGUI componentInChildren = ((Component)val3).GetComponentInChildren<TextMeshProUGUI>();
			LocalizeStringEvent componentInChildren2 = ((Component)val3).GetComponentInChildren<LocalizeStringEvent>();
			if ((Object)(object)componentInChildren == (Object)null)
			{
				Log.Error(((Object)((Component)val3).gameObject).name + " does not contain TextMeshProUGUI component");
				Object.Destroy((Object)(object)((Component)val3).gameObject);
				return null;
			}
			if ((Object)(object)parent == (Object)null)
			{
				val3.parent = null;
			}
			Button component = ((Component)val3).GetComponent<Button>();
			((UnityEventBase)component.onClick).RemoveAllListeners();
			return new UIButton
			{
				ButtonGO = ((Component)val3).gameObject,
				LocalizeString = componentInChildren2,
				TMPText = componentInChildren,
				UnityButton = component
			};
		}
	}
	public class UIDropdown
	{
		public GameObject SelectGO { get; set; } = null;


		public LocalizeStringEvent LocalizeString { get; set; } = null;


		public TMP_Dropdown TMP_Dropdown { get; set; } = null;


		public bool isVisible()
		{
			return SelectGO.activeSelf;
		}
	}
	internal class UITitle
	{
		public GameObject TitleGO { get; set; } = null;


		public LocalizeStringEvent LocalizeString { get; set; } = null;


		public TMP_Text TMP_TextObj { get; set; } = null;

	}
	internal class UIText
	{
		public GameObject TextGO { get; set; } = null;


		public LocalizeStringEvent LocalizeString { get; set; } = null;


		public TextMeshProUGUI TMPText { get; set; } = null;

	}
	internal class UIService
	{
		private static UIService? _instance;

		public static UIService Instance
		{
			get
			{
				if (_instance == null)
				{
					_instance = new UIService();
				}
				return _instance;
			}
		}

		public UIButton BaseButton { get; set; } = null;


		private UIService()
		{
		}

		public UIToggle AddToggleToGameSettings(string localizationEntry, UnityAction<bool> onValueChanged)
		{
			UIToggle uIToggle = CreateGameSettingsToggleClone() ?? throw new Exception("Could not create Toggle element");
			uIToggle.LocalizeString.SetEntry(localizationEntry);
			((UnityEvent<bool>)(object)uIToggle.UnityToggle.onValueChanged).AddListener(onValueChanged);
			return uIToggle;
		}

		public UIText AddTextToMainUI(string localizationEntry, Color? textColor = null)
		{
			//IL_003e: 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)
			UIText uIText = CreateGameTextClone() ?? throw new Exception("Could not create Text element");
			uIText.LocalizeString.SetEntry(localizationEntry);
			((Graphic)uIText.TMPText).color = (Color)(((??)textColor) ?? Color.white);
			return uIText;
		}

		public UIDropdown AddDropdownToGameSettings(string localizationEntry, UnityAction<int> onValueChanged, List<OptionData> options)
		{
			UIDropdown uIDropdown = CreateGameSettingsDropdownClone(options) ?? throw new Exception("Could not create Dropdown element");
			uIDropdown.LocalizeString.SetEntry(localizationEntry);
			((UnityEvent<int>)(object)uIDropdown.TMP_Dropdown.onValueChanged).AddListener(onValueChanged);
			return uIDropdown;
		}

		private UIToggle? CreateGameSettingsToggleClone()
		{
			Transform val = GameManager.Instance.gameUI.gameSettingsMenu.transform.Find("LayoutGroup/Body/TaskPanel/Holder/LayoutGroup/ShowAllySetting");
			if ((Object)(object)val == (Object)null)
			{
				Log.Error("Could not get a Toggle copy to duplicate!");
				return null;
			}
			Transform val2 = Object.Instantiate<Transform>(val, val.parent);
			Transform obj = val2.Find("LayoutGroup/SettingNameText");
			LocalizeStringEvent val3 = ((obj != null) ? ((Component)obj).GetComponent<LocalizeStringEvent>() : null);
			Transform obj2 = val2.Find("LayoutGroup/ToggleContainer/Toggle");
			Toggle val4 = ((obj2 != null) ? ((Component)obj2).GetComponent<Toggle>() : null);
			if ((Object)(object)val3 == (Object)null || (Object)(object)val4 == (Object)null)
			{
				Log.Error("Copied object does not contains required text or toggle");
				Object.Destroy((Object)(object)((Component)val2).gameObject);
				return null;
			}
			for (int i = 0; i < ((UnityEventBase)val4.onValueChanged).GetPersistentEventCount(); i++)
			{
				((UnityEventBase)val4.onValueChanged).SetPersistentListenerState(i, (UnityEventCallState)0);
			}
			val4.SetIsOnWithoutNotify(false);
			return new UIToggle
			{
				ToggleGO = ((Component)val2).gameObject,
				LocalizeString = val3,
				UnityToggle = val4
			};
		}

		public void PrintChildNames(GameObject parent)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			foreach (Transform item in parent.transform)
			{
				Transform val = item;
				Debug.Log((object)((Object)val).name);
				PrintChildNames(((Component)val).gameObject);
			}
		}

		private UIDropdown? CreateGameSettingsDropdownClone(List<OptionData> options)
		{
			Transform val = GameManager.Instance.gameUI.gameSettingsMenu.transform.Find("LayoutGroup/Body/TaskPanel/Holder/LayoutGroup/TransformationTimeSetting");
			if ((Object)(object)val != (Object)null)
			{
				Transform val2 = Object.Instantiate<Transform>(val, val.parent);
				Transform obj = val2.Find("LayoutGroup/SettingNameText");
				LocalizeStringEvent val3 = ((obj != null) ? ((Component)obj).GetComponent<LocalizeStringEvent>() : null);
				Transform obj2 = val2.Find("LayoutGroup/SettingValues/SettingDropdown");
				TMP_Dropdown val4 = ((obj2 != null) ? ((Component)obj2).GetComponent<TMP_Dropdown>() : null);
				if ((Object)(object)val3 != (Object)null && (Object)(object)val4 != (Object)null)
				{
					for (int i = 0; i < ((UnityEventBase)val4.onValueChanged).GetPersistentEventCount(); i++)
					{
						((UnityEventBase)val4.onValueChanged).SetPersistentListenerState(i, (UnityEventCallState)0);
					}
					val4.options.Clear();
					val4.AddOptions(options);
					val4.SetValueWithoutNotify(0);
					return new UIDropdown
					{
						SelectGO = ((Component)val2).gameObject,
						LocalizeString = val3,
						TMP_Dropdown = val4
					};
				}
				Object.Destroy((Object)(object)((Component)val2).gameObject);
			}
			return null;
		}

		private UITitle? CreateSettingsTitleClone()
		{
			Transform val = GameManager.Instance.gameUI.settingsMenu.transform.Find("LayoutGroup/Header/Body/TaskPanel/Holder/SettingsGroup/GraphicsTitle");
			Log.Info("Orig set");
			if ((Object)(object)val != (Object)null)
			{
				Log.Info("Orig Found");
				Transform val2 = Object.Instantiate<Transform>(val, val.parent);
				LocalizeStringEvent component = ((Component)val2).GetComponent<LocalizeStringEvent>();
				TMP_Text component2 = ((Component)val2).GetComponent<TMP_Text>();
				if ((Object)(object)component != (Object)null)
				{
					return new UITitle
					{
						TitleGO = ((Component)val2).gameObject,
						LocalizeString = component,
						TMP_TextObj = component2
					};
				}
				Object.Destroy((Object)(object)((Component)val2).gameObject);
			}
			return null;
		}

		public UITitle AddTitleToSettings(string localizationEntry)
		{
			UITitle uITitle = CreateSettingsTitleClone() ?? throw new Exception("Could not create Title element");
			uITitle.LocalizeString.SetEntry(localizationEntry);
			uITitle.TMP_TextObj.text = localizationEntry;
			return uITitle;
		}

		private UIText? CreateGameTextClone()
		{
			Transform val = ((Component)GameManager.Instance.gameUI).transform.Find("Canvas/Game/Role");
			if ((Object)(object)val == (Object)null)
			{
				Log.Error("Could not get a Text copy to duplicate!");
				return null;
			}
			Transform val2 = Object.Instantiate<Transform>(val, GameManager.Instance.gameUI