Decompiled source of ACE Tools for REPO v0.0.2

RepoClientTools.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.IO.Compression;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using RepoClientTools.Core;
using RepoClientTools.Features;
using RepoClientTools.Game;
using RepoClientTools.UI;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.InputSystem;
using UnityEngine.InputSystem.Controls;
using UnityEngine.InputSystem.Utilities;
using UnityEngine.Localization;
using UnityEngine.Localization.Settings;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace RepoClientTools
{
	[BepInPlugin("repo.clienttools", "R.E.P.O. Client Tools", "0.0.2")]
	[DefaultExecutionOrder(-500)]
	public sealed class Plugin : BaseUnityPlugin
	{
		internal const string Version = "0.0.2";

		private const string Id = "repo.clienttools";

		private FeatureRegistry features;

		private SettingsMenu menu;

		private FullScreenMap fullMap;

		private Harmony harmony;

		private void Awake()
		{
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Expected O, but got Unknown
			MenuPreferences preferences = new MenuPreferences(((BaseUnityPlugin)this).Config);
			features = new FeatureRegistry(((BaseUnityPlugin)this).Config, ((BaseUnityPlugin)this).Logger);
			PlayerNames.Enabled = features.Add(new PlayerNames());
			features.Add(new ZundamonTextChat((MonoBehaviour)(object)this, ((BaseUnityPlugin)this).Logger, ((BaseUnityPlugin)this).Config));
			features.Add(new EnemyHealthDisplay());
			GrabScroll feature = (GrabScrollPatch.Feature = new GrabScroll(((BaseUnityPlugin)this).Config));
			GrabScrollPatch.Enabled = features.Add(feature);
			GrabScrollPatch.Log = ((BaseUnityPlugin)this).Logger;
			features.Add(new AlwaysVisibleMap(((BaseUnityPlugin)this).Logger));
			features.Add(new RevealRooms());
			features.Add(new TruckRoute());
			features.Add(new EnemyMapMarkers(((BaseUnityPlugin)this).Config, preferences));
			features.Add(new AllyMapMarkers(((BaseUnityPlugin)this).Config));
			features.Add(new ValuableMapMarkers(((BaseUnityPlugin)this).Config));
			bool flag = ((BaseUnityPlugin)this).Config.Bind<bool>("Map", "WeaponMapMarkers", false, (ConfigDescription)null).Value || ((BaseUnityPlugin)this).Config.Bind<bool>("Map", "UtilityItemMapMarkers", false, (ConfigDescription)null).Value;
			((BaseUnityPlugin)this).Config.Bind<bool>("Map", "ItemsMapMarkers", flag, (ConfigDescription)null);
			features.Add(new ItemMapMarkers(((BaseUnityPlugin)this).Config));
			menu = new SettingsMenu(features, preferences);
			fullMap = new FullScreenMap(preferences);
			harmony = new Harmony("repo.clienttools");
			harmony.PatchAll();
			SceneManager.activeSceneChanged += OnSceneChanged;
		}

		private void Update()
		{
			if (fullMap.IsOpen)
			{
				Keyboard current = Keyboard.current;
				if (current == null || !((ButtonControl)current.f4Key).wasPressedThisFrame)
				{
					fullMap.Update();
					return;
				}
				fullMap.Close();
			}
			menu.Update();
			if (!MenuInput.Capturing)
			{
				fullMap.Update();
			}
		}

		private void LateUpdate()
		{
			menu.UpdateSkin();
			fullMap.LateUpdate();
			features.Tick();
		}

		private void OnGUI()
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Invalid comparison between Unknown and I4
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Invalid comparison between Unknown and I4
			if (fullMap.IsOpen)
			{
				fullMap.Draw();
				if (fullMap.IsOpen && (int)Event.current.type == 7)
				{
					menu.DrawMapLegend(fullScreen: true);
				}
				return;
			}
			if ((int)Event.current.type == 7)
			{
				features.Draw();
				menu.DrawMapLegend();
			}
			menu.Draw();
		}

		private void OnSceneChanged(Scene oldScene, Scene newScene)
		{
			fullMap.Close();
			menu.Close();
			menu.ResetSkin();
			features.Reset();
		}

		private void OnDestroy()
		{
			SceneManager.activeSceneChanged -= OnSceneChanged;
			fullMap?.Dispose();
			menu?.Dispose();
			features?.Reset();
			Harmony obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
		}
	}
}
namespace RepoClientTools.UI
{
	internal sealed class FullMapLabels
	{
		private readonly List<(Vector2 Point, string Name, Color Color)> labels = new List<(Vector2, string, Color)>();

		private readonly List<Rect> used = new List<Rect>();

		private GUIStyle style;

		public void Draw(Camera camera, Rect area, Font font)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Invalid comparison between Unknown and I4
			//IL_0021: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_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_0059: Expected O, but got Unknown
			//IL_005e: Expected O, but got Unknown
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			if ((int)Event.current.type != 7)
			{
				return;
			}
			if (style == null)
			{
				style = new GUIStyle(GUI.skin.label)
				{
					alignment = (TextAnchor)4,
					fontSize = 13,
					fontStyle = (FontStyle)1,
					richText = false,
					clipping = (TextClipping)1,
					padding = new RectOffset(5, 5, 1, 1)
				};
			}
			if (Object.op_Implicit((Object)(object)font))
			{
				style.font = font;
			}
			GUI.BeginGroup(area);
			try
			{
				Rect canvas = default(Rect);
				((Rect)(ref canvas))..ctor(0f, 0f, ((Rect)(ref area)).width, ((Rect)(ref area)).height);
				Collect(camera, canvas, Event.current.mousePosition);
				foreach (var label in labels)
				{
					DrawLabel(canvas, label.Point, label.Name, label.Color);
				}
			}
			finally
			{
				GUI.EndGroup();
			}
		}

		private void Collect(Camera camera, Rect canvas, Vector2 mouse)
		{
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: 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_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: 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)
			labels.Clear();
			used.Clear();
			Vector2 val2 = default(Vector2);
			foreach (MapOverlayFloor item2 in MapOverlayFloor.Active)
			{
				if (Object.op_Implicit((Object)(object)item2) && Object.op_Implicit((Object)(object)item2.Sprite) && ((Renderer)item2.Sprite).enabled && Object.op_Implicit((Object)(object)item2.Caption) && ((Component)item2.Caption).gameObject.activeInHierarchy && !string.IsNullOrWhiteSpace(item2.Caption.text))
				{
					Vector3 val = camera.WorldToViewportPoint(((Component)item2.Sprite).transform.position);
					((Vector2)(ref val2))..ctor(val.x * ((Rect)(ref canvas)).width, (1f - val.y) * ((Rect)(ref canvas)).height);
					if (!(val.z <= 0f) && ((Rect)(ref canvas)).Contains(val2))
					{
						Color color = item2.Sprite.color;
						Color item = (Color)(((??)item2.CaptionTint) ?? Color.Lerp(new Color(color.r, color.g, color.b), Color.white, 0.6f));
						labels.Add((val2, item2.Caption.text, item));
						used.Add(new Rect(val2.x - 4f, val2.y - 4f, 8f, 8f));
					}
				}
			}
			Vector2 focus = (((Rect)(ref canvas)).Contains(mouse) ? mouse : ((Rect)(ref canvas)).center);
			labels.Sort(delegate((Vector2 Point, string Name, Color Color) left, (Vector2 Point, string Name, Color Color) right)
			{
				//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_000c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_0028: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				Vector2 val3 = left.Point - focus;
				float sqrMagnitude = ((Vector2)(ref val3)).sqrMagnitude;
				val3 = right.Point - focus;
				return sqrMagnitude.CompareTo(((Vector2)(ref val3)).sqrMagnitude);
			});
		}

		private void DrawLabel(Rect canvas, Vector2 point, string name, Color color)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_000e: 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_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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_00c3: 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_00e3: 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_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: 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)
			GUIContent val = new GUIContent(name);
			float num = Mathf.Min(style.CalcSize(val).x + 4f, 174f);
			for (int i = 0; i < 4; i++)
			{
				Rect val2 = (Rect)(i switch
				{
					0 => new Rect(point.x + 7f, point.y - 10f, num, 20f), 
					1 => new Rect(point.x - 7f - num, point.y - 10f, num, 20f), 
					2 => new Rect(point.x - num / 2f, point.y - 7f - 20f, num, 20f), 
					_ => new Rect(point.x - num / 2f, point.y + 7f, num, 20f), 
				});
				if (Fits(canvas, val2))
				{
					used.Add(new Rect(((Rect)(ref val2)).x - 2f, ((Rect)(ref val2)).y - 2f, ((Rect)(ref val2)).width + 4f, ((Rect)(ref val2)).height + 4f));
					style.normal.textColor = color;
					GUI.DrawTexture(val2, (Texture)(object)Texture2D.whiteTexture, (ScaleMode)0, true, 0f, new Color(0.018f, 0.029f, 0.043f, 0.94f), 0f, 4f);
					GUI.Label(val2, val, style);
					break;
				}
			}
		}

		private bool Fits(Rect canvas, Rect box)
		{
			//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)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			if (((Rect)(ref box)).xMin < 2f || ((Rect)(ref box)).yMin < 2f || ((Rect)(ref box)).xMax > ((Rect)(ref canvas)).width - 2f || ((Rect)(ref box)).yMax > ((Rect)(ref canvas)).height - 2f)
			{
				return false;
			}
			foreach (Rect item in used)
			{
				if (((Rect)(ref box)).Overlaps(item))
				{
					return false;
				}
			}
			return true;
		}
	}
	internal sealed class FullScreenMap
	{
		private static readonly Color Background = new Color(0.026f, 0.043f, 0.062f);

		private static readonly Color Panel = new Color(0.063f, 0.086f, 0.119f);

		private static readonly Color Border = new Color(0.15f, 0.2f, 0.28f);

		private static readonly Color Accent = new Color(0.32f, 0.84f, 0.95f);

		private readonly MenuPreferences preferences;

		private readonly ModalCursor cursor = new ModalCursor();

		private readonly FullMapLabels labels = new FullMapLabels();

		private readonly List<MapLayer> floors = new List<MapLayer>();

		private Map map;

		private Camera camera;

		private RenderTexture texture;

		private FullMapRenderView renderView;

		private bool forcedMap;

		private bool dragging;

		private int floor;

		private int playerFloor;

		private float nextCameraCheck;

		private float zoom = 2f;

		private float fitZoom = 2f;

		private Vector2 center;

		private Font font;

		private GUIStyle heading;

		private GUIStyle button;

		private GUIStyle info;

		public bool IsOpen { get; private set; }

		private Rect MapRect => new Rect(24f, 66f, Mathf.Max(1f, (float)Screen.width - 48f), Mathf.Max(1f, (float)Screen.height - 142f));

		public FullScreenMap(MenuPreferences preferences)
		{
			this.preferences = preferences;
		}

		public void Update()
		{
			//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_001a: 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)
			Keyboard current = Keyboard.current;
			Key value = preferences.FullMapKey.Value;
			bool flag = current != null && (int)value != 0 && ((ButtonControl)current[value]).wasPressedThisFrame;
			if (IsOpen)
			{
				if (!Object.op_Implicit((Object)(object)map) || (Object)(object)map != (Object)(object)Map.Instance || !LocalGame.InLevel || !LocalGame.IsAlive(LocalGame.Player) || flag || (current != null && ((ButtonControl)current.escapeKey).wasPressedThisFrame) || (Object.op_Implicit((Object)(object)InputManager.instance) && SemiFunc.InputDown((InputKey)7)))
				{
					Close();
					return;
				}
				cursor.Refresh();
				EnsureMapActive();
				if (map.PlayerLayer != playerFloor)
				{
					playerFloor = map.PlayerLayer;
					FitFloor(playerFloor);
				}
			}
			else if (flag && Application.isFocused && SemiFunc.NoTextInputsActive() && LocalGame.InLevel && LocalGame.IsAlive(LocalGame.Player) && Object.op_Implicit((Object)(object)Map.Instance))
			{
				Open(Map.Instance);
			}
		}

		private void Open(Map owner)
		{
			map = owner;
			IsOpen = true;
			EnsureMapActive();
			cursor.Open();
			playerFloor = map.PlayerLayer;
			FitFloor(playerFloor);
		}

		private void EnsureMapActive()
		{
			if (!map.Active)
			{
				forcedMap = true;
				map.ActiveSet(true);
			}
		}

		public void LateUpdate()
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Expected O, but got Unknown
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			if (!IsOpen || !Object.op_Implicit((Object)(object)map))
			{
				return;
			}
			EnsureMapActive();
			if (!Object.op_Implicit((Object)(object)camera) && Time.unscaledTime >= nextCameraCheck)
			{
				nextCameraCheck = Time.unscaledTime + 0.4f;
				Camera val = MapAccess.FindCamera(map);
				if (Object.op_Implicit((Object)(object)val))
				{
					CreateCamera(val);
				}
			}
			if (Object.op_Implicit((Object)(object)camera))
			{
				Rect mapRect = MapRect;
				float num = ((Rect)(ref mapRect)).width / ((Rect)(ref mapRect)).height;
				int num2 = Mathf.Clamp(Mathf.RoundToInt(((Rect)(ref mapRect)).width), 320, 1920);
				int num3 = Mathf.Clamp(Mathf.RoundToInt((float)num2 / num), 128, 1440);
				if (!Object.op_Implicit((Object)(object)texture) || ((Texture)texture).width != num2 || ((Texture)texture).height != num3)
				{
					ReleaseTexture();
					texture = new RenderTexture(num2, num3, 24)
					{
						name = "Client Tools full map",
						filterMode = (FilterMode)1
					};
					RenderTextureDescriptor descriptor = texture.descriptor;
					((RenderTextureDescriptor)(ref descriptor)).msaaSamples = 4;
					texture.antiAliasing = SystemInfo.GetRenderTextureSupportedMSAASampleCount(descriptor);
					texture.Create();
					camera.targetTexture = texture;
				}
				camera.aspect = num;
				camera.orthographicSize = zoom;
				((Component)camera).transform.SetPositionAndRotation(new Vector3(center.x, ((Component)map).transform.position.y + 24f, center.y), Quaternion.Euler(90f, 0f, 0f));
			}
		}

		private void CreateCamera(Camera source)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("Client Tools full map camera");
			val.transform.SetParent(((Component)map).transform, false);
			camera = val.AddComponent<Camera>();
			camera.CopyFrom(source);
			camera.targetTexture = null;
			camera.clearFlags = (CameraClearFlags)2;
			camera.backgroundColor = Background;
			camera.orthographic = true;
			camera.nearClipPlane = 0.05f;
			camera.farClipPlane = 70f;
			camera.allowHDR = false;
			camera.allowMSAA = true;
			camera.allowDynamicResolution = false;
			camera.useOcclusionCulling = false;
			camera.depth = source.depth + 2f;
			camera.ResetProjectionMatrix();
			renderView = val.AddComponent<FullMapRenderView>();
			renderView.Configure(camera, source);
		}

		private void RefreshFloors()
		{
			floors.Clear();
			foreach (MapLayer layer in map.Layers)
			{
				if (Object.op_Implicit((Object)(object)layer) && Object.op_Implicit((Object)(object)((Component)layer).GetComponentInChildren<MapObject>(true)))
				{
					floors.Add(layer);
				}
			}
			floors.Sort((MapLayer left, MapLayer right) => left.layer.CompareTo(right.layer));
		}

		private void FitFloor(int requested)
		{
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: 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_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			RefreshFloors();
			floor = requested;
			MapLayer val = floors.Find((MapLayer item) => item.layer == floor);
			if (!Object.op_Implicit((Object)(object)val) && floors.Count != 0)
			{
				val = floors[0];
				foreach (MapLayer floor in floors)
				{
					if (Mathf.Abs(floor.layer - requested) < Mathf.Abs(val.layer - requested))
					{
						val = floor;
					}
				}
				this.floor = val.layer;
			}
			Vector3 val2 = MapAccess.ToMapPosition(map, ((Component)LocalGame.Player).transform.position);
			center = new Vector2(val2.x, val2.z);
			fitZoom = 2f;
			if (Object.op_Implicit((Object)(object)val) && TryBounds(val, out var bounds))
			{
				center = new Vector2(((Bounds)(ref bounds)).center.x, ((Bounds)(ref bounds)).center.z);
				Rect mapRect = MapRect;
				fitZoom = Mathf.Max(1f, Mathf.Max(((Bounds)(ref bounds)).extents.z, ((Bounds)(ref bounds)).extents.x * ((Rect)(ref mapRect)).height / ((Rect)(ref mapRect)).width) * 1.08f);
			}
			zoom = fitZoom;
		}

		private static bool TryBounds(MapLayer layer, out Bounds bounds)
		{
			//IL_0001: 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_003f: 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)
			bounds = default(Bounds);
			bool flag = false;
			MapObject[] componentsInChildren = ((Component)layer).GetComponentsInChildren<MapObject>(true);
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				Renderer componentInChildren = ((Component)componentsInChildren[i]).GetComponentInChildren<Renderer>(true);
				if (Object.op_Implicit((Object)(object)componentInChildren))
				{
					if (flag)
					{
						((Bounds)(ref bounds)).Encapsulate(componentInChildren.bounds);
					}
					else
					{
						bounds = componentInChildren.bounds;
					}
					flag = true;
				}
			}
			return flag;
		}

		private void CenterPlayer()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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)
			playerFloor = map.PlayerLayer;
			FitFloor(playerFloor);
			Vector3 val = MapAccess.ToMapPosition(map, ((Component)LocalGame.Player).transform.position);
			center = new Vector2(val.x, val.z);
			zoom = Mathf.Min(fitZoom, 3f);
		}

		public void Draw()
		{
			//IL_0010: 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_0017: 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_0038: 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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: 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_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Invalid comparison between Unknown and I4
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_01af: Unknown result type (might be due to invalid IL or missing references)
			//IL_027f: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0328: Unknown result type (might be due to invalid IL or missing references)
			if (!IsOpen)
			{
				return;
			}
			EnsureStyles();
			Rect mapRect = MapRect;
			HandlePointer(mapRect);
			Paint(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), Background);
			Paint(new Rect(0f, 0f, (float)Screen.width, 54f), Panel);
			Paint(new Rect(0f, 54f, (float)Screen.width, 1f), Border);
			Paint(new Rect(0f, (float)Screen.height - 63f, (float)Screen.width, 63f), Panel);
			Paint(new Rect(0f, (float)Screen.height - 63f, (float)Screen.width, 1f), Border);
			Paint(new Rect(((Rect)(ref mapRect)).x - 1f, ((Rect)(ref mapRect)).y - 1f, ((Rect)(ref mapRect)).width + 2f, ((Rect)(ref mapRect)).height + 2f), Border, 9f);
			if (Object.op_Implicit((Object)(object)texture))
			{
				GUI.DrawTexture(mapRect, (Texture)(object)texture, (ScaleMode)0, false, 0f, Color.white, 0f, 8f);
				labels.Draw(camera, mapRect, font);
				if (floor == playerFloor && (int)Event.current.type == 7)
				{
					MapPlayerPointer.Draw(map, camera, mapRect, 26f);
				}
			}
			bool japanese = preferences.Japanese;
			Paint(new Rect(24f, 18f, 3f, 18f), Accent, 1.5f);
			GUI.Label(new Rect(37f, 0f, 145f, 54f), japanese ? "全画面マップ" : "Full map", heading);
			float num = (float)Screen.width - 24f;
			if (DrawButton(new Rect(num - 80f, 11f, 80f, 32f), japanese ? "閉じる" : "Close", close: true))
			{
				Close();
				return;
			}
			if (DrawButton(new Rect(num - 164f, 11f, 76f, 32f), japanese ? "全体" : "Fit"))
			{
				FitFloor(floor);
			}
			if (DrawButton(new Rect(num - 270f, 11f, 98f, 32f), japanese ? "現在地" : "Player"))
			{
				CenterPlayer();
			}
			GUI.Label(new Rect(24f, (float)(Screen.height - 28), (float)(Screen.width - 48), 24f), japanese ? "ホイールで拡大・縮小   /   ドラッグで移動" : "Scroll to zoom   /   Drag to pan", info);
			if (!Object.op_Implicit((Object)(object)texture))
			{
				GUI.Label(mapRect, japanese ? "マップを読み込み中…" : "Loading map…", info);
			}
		}

		private void HandlePointer(Rect area)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Invalid comparison between Unknown and I4
			//IL_001f: 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_0051: Invalid comparison between Unknown and I4
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Invalid comparison between Unknown and I4
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: 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_0124: 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_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			Event current = Event.current;
			if ((int)current.type == 1 && current.button == 0)
			{
				dragging = false;
			}
			if ((int)current.type == 0 && current.button == 0 && ((Rect)(ref area)).Contains(current.mousePosition))
			{
				dragging = true;
				current.Use();
			}
			if ((int)current.type == 3 && dragging)
			{
				float num = 2f * zoom / ((Rect)(ref area)).height;
				center += new Vector2((0f - current.delta.x) * num, current.delta.y * num);
				current.Use();
			}
			if ((int)current.type == 6 && ((Rect)(ref area)).Contains(current.mousePosition))
			{
				float num2 = Mathf.Clamp(zoom * Mathf.Pow(1.13f, current.delta.y), 0.75f, Mathf.Max(4f, fitZoom * 3f));
				Vector2 val = current.mousePosition - ((Rect)(ref area)).center;
				center += new Vector2(val.x, 0f - val.y) * (2f * (zoom - num2) / ((Rect)(ref area)).height);
				zoom = num2;
				current.Use();
			}
		}

		private void EnsureStyles()
		{
			//IL_003f: 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_004b: 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_005f: Expected O, but got Unknown
			//IL_006a: 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_0077: 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_008a: Expected O, but got Unknown
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Expected O, but got Unknown
			if (heading == null)
			{
				font = Font.CreateDynamicFontFromOSFont(new string[3] { "Yu Gothic UI", "Meiryo", "Arial" }, 21);
				heading = new GUIStyle(GUI.skin.label)
				{
					alignment = (TextAnchor)3,
					fontSize = 21,
					fontStyle = (FontStyle)1
				};
				button = new GUIStyle(GUI.skin.label)
				{
					fontSize = 14,
					alignment = (TextAnchor)4,
					fontStyle = (FontStyle)1
				};
				info = new GUIStyle(GUI.skin.label)
				{
					alignment = (TextAnchor)4,
					fontSize = 14
				};
				if (Object.op_Implicit((Object)(object)font))
				{
					GUIStyle obj = heading;
					GUIStyle obj2 = button;
					Font val = (info.font = font);
					Font val3 = (obj2.font = val);
					obj.font = val3;
				}
			}
		}

		private bool DrawButton(Rect rect, string text, bool close = false)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			bool flag = ((Rect)(ref rect)).Contains(Event.current.mousePosition);
			Paint(rect, (Color)(flag ? Border : new Color(0.092f, 0.127f, 0.181f)), 7f);
			button.normal.textColor = (Color)(close ? Accent : new Color(0.87f, 0.92f, 0.98f));
			GUI.Label(rect, text, button);
			return GUI.Button(rect, GUIContent.none, GUIStyle.none);
		}

		private static void Paint(Rect area, Color tint, float radius = 0f)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			GUI.DrawTexture(area, (Texture)(object)Texture2D.whiteTexture, (ScaleMode)0, true, 0f, tint, 0f, radius);
		}

		private void ReleaseTexture()
		{
			if (Object.op_Implicit((Object)(object)texture))
			{
				if (Object.op_Implicit((Object)(object)camera))
				{
					camera.targetTexture = null;
				}
				texture.Release();
				Object.Destroy((Object)(object)texture);
				texture = null;
			}
		}

		public void Close()
		{
			if (IsOpen)
			{
				IsOpen = false;
				dragging = false;
				cursor.Close();
				if (Object.op_Implicit((Object)(object)camera))
				{
					((Behaviour)camera).enabled = false;
				}
				ReleaseTexture();
				if (Object.op_Implicit((Object)(object)camera))
				{
					Object.Destroy((Object)(object)((Component)camera).gameObject);
				}
				if (forcedMap && Object.op_Implicit((Object)(object)map) && !MapAccess.IsHandheldOpen)
				{
					map.ActiveSet(false);
				}
				forcedMap = false;
				camera = null;
				renderView = null;
				map = null;
				floors.Clear();
				nextCameraCheck = 0f;
			}
		}

		public void Dispose()
		{
			Close();
			if (Object.op_Implicit((Object)(object)font))
			{
				Object.Destroy((Object)(object)font);
			}
		}
	}
	internal sealed class SettingsMenu
	{
		private const string Settings = "Settings";

		private const string ItemList = "Item List";

		private const string PlayerList = "Skin Copy";

		private PurchasedItems.Category itemCategory = PurchasedItems.Category.Items;

		private readonly SkinPreview skin = new SkinPreview();

		private const string Credit = "CREDIT";

		private const string DiscordInvite = "https://discord.gg/J8NqZAZJMV";

		private static readonly Color Ink = new Color(0.91f, 0.94f, 0.98f);

		private static readonly Color Muted = new Color(0.63f, 0.69f, 0.76f);

		private static readonly Color Cyan = new Color(0.26f, 0.82f, 0.94f);

		private static readonly Color Panel = new Color(0.075f, 0.09f, 0.12f);

		private static readonly Color Surface = new Color(0.107f, 0.128f, 0.163f);

		private static readonly Color Border = new Color(0.19f, 0.23f, 0.28f);

		private readonly FeatureRegistry features;

		private readonly ConfigEntry<MenuLanguage> language;

		private string category;

		private Feature featureSettings;

		private Vector2 settingsScroll;

		private Vector2 scroll;

		private readonly ModalCursor cursor = new ModalCursor();

		private readonly MenuPreferences preferences;

		private bool changingMapKey;

		private Font japaneseFont;

		private GUIStyle title;

		private GUIStyle section;

		private GUIStyle label;

		private GUIStyle small;

		private GUIStyle detail;

		private GUIStyle centered;

		private bool Japanese => language.Value == MenuLanguage.Japanese;

		public SettingsMenu(FeatureRegistry features, MenuPreferences preferences)
		{
			this.features = features;
			this.preferences = preferences;
			language = preferences.Language;
		}

		public void Update()
		{
			Keyboard current = Keyboard.current;
			if (changingMapKey)
			{
				ReadMapKey(current);
				cursor.Refresh();
				return;
			}
			if (current != null && ((ButtonControl)current.f4Key).wasPressedThisFrame)
			{
				if (MenuInput.Capturing)
				{
					Close();
				}
				else if (Application.isFocused && SemiFunc.NoTextInputsActive())
				{
					Open();
				}
			}
			else if (MenuInput.Capturing && ((current != null && ((ButtonControl)current.escapeKey).wasPressedThisFrame) || (Object.op_Implicit((Object)(object)InputManager.instance) && SemiFunc.InputDown((InputKey)7))))
			{
				Close();
			}
			if (MenuInput.Capturing)
			{
				cursor.Refresh();
			}
		}

		private void ReadMapKey(Keyboard keyboard)
		{
			//IL_001a: 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_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Invalid comparison between Unknown and I4
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			if (keyboard == null)
			{
				return;
			}
			if (((ButtonControl)keyboard.escapeKey).wasPressedThisFrame)
			{
				changingMapKey = false;
				return;
			}
			Enumerator<KeyControl> enumerator = keyboard.allKeys.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					KeyControl current = enumerator.Current;
					if (((ButtonControl)current).wasPressedThisFrame && (int)current.keyCode != 97)
					{
						preferences.FullMapKey.Value = current.keyCode;
						changingMapKey = false;
						break;
					}
				}
			}
			finally
			{
				((IDisposable)enumerator/*cast due to .constrained prefix*/).Dispose();
			}
		}

		private void Open()
		{
			cursor.Open();
		}

		public void Close()
		{
			changingMapKey = false;
			cursor.Close();
		}

		public void Dispose()
		{
			Close();
			ResetSkin();
			if (Object.op_Implicit((Object)(object)japaneseFont))
			{
				Object.Destroy((Object)(object)japaneseFont);
			}
		}

		public void Draw()
		{
			//IL_00f7: 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_004a: 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_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			if (!MenuInput.Capturing)
			{
				return;
			}
			EnsureStyles();
			int depth = GUI.depth;
			GUI.depth = -100;
			Fill(new Rect(0f, 0f, (float)Screen.width, (float)Screen.height), new Color(0.016f, 0.026f, 0.041f, 0.62f));
			float num = 0.9f * Mathf.Min(new float[3]
			{
				(float)Screen.width / 718f,
				(float)Screen.height / 418f,
				1.25f
			});
			Matrix4x4 matrix = GUI.matrix;
			GUI.matrix = matrix * Matrix4x4.TRS(new Vector3(((float)Screen.width - 690f * num) / 2f, ((float)Screen.height - 390f * num) / 2f), Quaternion.identity, new Vector3(num, num, 1f));
			try
			{
				DrawPanel(690f, 390f);
			}
			finally
			{
				GUI.matrix = matrix;
				GUI.depth = depth;
			}
		}

		public void DrawMapLegend(bool fullScreen = false)
		{
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_023d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_032a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0286: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: 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_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			if ((!fullScreen && MenuInput.Capturing) || !Object.op_Implicit((Object)(object)Map.Instance) || !Map.Instance.Active || !LocalGame.InLevel || !LocalGame.IsAlive(LocalGame.Player))
			{
				return;
			}
			bool flag = IsOn<TruckRoute>();
			bool flag2 = IsOn<EnemyMapMarkers>();
			bool flag3 = IsOn<ValuableMapMarkers>();
			bool flag4 = IsOn<ItemMapMarkers>();
			bool flag5 = IsOn<AllyMapMarkers>();
			int num = (flag ? 1 : 0) + (flag2 ? 1 : 0) + (flag3 ? 1 : 0) + (flag4 ? 3 : 0) + (flag5 ? 1 : 0);
			if (num == 0)
			{
				return;
			}
			EnsureStyles();
			float num2 = Mathf.Min(105f, ((float)Screen.width - 24f) / (float)num);
			float num3 = (float)num * num2 + 8f;
			Rect rect = default(Rect);
			((Rect)(ref rect))..ctor(((float)Screen.width - num3) / 2f, fullScreen ? ((float)Screen.height - 59f) : 18f, num3, 27f);
			Fill(rect, Panel, 7f);
			float num4 = ((Rect)(ref rect)).x + 12f;
			if (flag)
			{
				for (int i = 0; i < 3; i++)
				{
					Fill(new Rect(num4 + (float)(5 * i), ((Rect)(ref rect)).y + 12f, 3f, 3f), TruckRoute.RouteColor, 1.5f);
				}
				Text(new Rect(num4 + 20f, ((Rect)(ref rect)).y, 79f, ((Rect)(ref rect)).height), Japanese ? "トラック" : "Truck route", label, Ink);
				num4 += num2;
			}
			if (flag2)
			{
				Fill(new Rect(num4 + 3f, ((Rect)(ref rect)).y + 10f, 8f, 8f), EnemyMapMarkers.MarkerColor, 4f);
				Text(new Rect(num4 + 20f, ((Rect)(ref rect)).y, 79f, ((Rect)(ref rect)).height), Japanese ? "敵" : "Enemies", label, Ink);
				num4 += num2;
			}
			if (flag5)
			{
				Fill(new Rect(num4 + 3f, ((Rect)(ref rect)).y + 10f, 8f, 8f), AllyMapMarkers.MarkerColor, 4f);
				Text(new Rect(num4 + 20f, ((Rect)(ref rect)).y, 79f, ((Rect)(ref rect)).height), Japanese ? "味方" : "Teammates", label, Ink);
				num4 += num2;
			}
			if (flag3)
			{
				Fill(new Rect(num4 + 3f, ((Rect)(ref rect)).y + 10f, 8f, 8f), ValuableMapMarkers.MarkerColor, 4f);
				Text(new Rect(num4 + 20f, ((Rect)(ref rect)).y, 79f, ((Rect)(ref rect)).height), Japanese ? "貴重品" : "Valuables", label, Ink);
				num4 += num2;
			}
			if (flag4)
			{
				DrawItemLegend(num4, ((Rect)(ref rect)).y, num2, Color.white, Japanese ? "アイテム" : "Items");
				DrawItemLegend(num4 + num2, ((Rect)(ref rect)).y, num2, ItemMapMarkers.CartColor, Japanese ? "カート" : "Carts");
				DrawItemLegend(num4 + num2 * 2f, ((Rect)(ref rect)).y, num2, ItemMapMarkers.OrbColor, Japanese ? "オーブ" : "Orbs");
			}
		}

		private void DrawItemLegend(float x, float y, float width, Color color, string name)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: 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)
			Fill(new Rect(x + 3f, y + 10f, 8f, 8f), color, 4f);
			Text(new Rect(x + 17f, y, width - 19f, 27f), name, label, Ink);
		}

		private bool IsOn<T>() where T : Feature
		{
			return features.Entries.Any((FeatureRegistry.Entry entry) => entry.Feature is T && entry.Enabled.Value && !entry.Faulted);
		}

		private void DrawPanel(float width, float height)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: 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_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
			Fill(new Rect(0f, 6f, width, height), new Color(0f, 0f, 0f, 0.45f), 16f);
			Fill(new Rect(0f, 0f, width, height), Border, 16f);
			Fill(new Rect(1f, 1f, width - 2f, height - 2f), Panel, 15f);
			Fill(new Rect(25f, 28f, 4f, 22f), Cyan, 2f);
			Text(new Rect(41f, 14f, 440f, 50f), "R.E.P.O. Client Tools", title, Ink);
			Rect rect = new Rect(width - 101f, 23f, 76f, 32f);
			Fill(rect, Hover(rect) ? Border : Surface, 7f);
			Text(rect, "F4   ×", centered, Ink);
			if (Hit(rect))
			{
				Close();
				return;
			}
			Fill(new Rect(24f, 73f, width - 48f, 1f), Border);
			Fill(new Rect(190f, 89f, 1f, height - 114f), Border);
			string[] source = features.Entries.Select((FeatureRegistry.Entry entry) => entry.Feature.Category).Distinct().ToArray();
			if (category == null)
			{
				category = source.FirstOrDefault() ?? "Settings";
			}
			int num = 0;
			foreach (string item in source.Append("Item List").Append("Skin Copy").Append("Settings")
				.Append("CREDIT"))
			{
				DrawTab(item, num++);
			}
			string value = ((featureSettings == null) ? CategoryName(category) : (Japanese ? featureSettings.JapaneseLabel : featureSettings.Label));
			Text(new Rect(211f, 89f, width - (float)((featureSettings == null) ? 236 : 324), 34f), value, section, Ink);
			if (featureSettings != null)
			{
				DrawFeatureSettings(width, height);
			}
			else if (category == "Item List")
			{
				DrawItemList(width, height);
			}
			else if (category == "Skin Copy")
			{
				DrawPlayerList(width, height);
			}
			else if (category == "Settings")
			{
				DrawSettings(width, height);
			}
			else if (category == "CREDIT")
			{
				DrawCredit(width, height);
			}
			else
			{
				DrawFeatures(width, height);
			}
		}

		private void DrawTab(string item, int index)
		{
			//IL_0036: 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_0050: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = default(Rect);
			((Rect)(ref rect))..ctor(24f, (float)(92 + index * 41), 142f, 36f);
			bool flag = item == category;
			if (flag || Hover(rect))
			{
				Fill(rect, (Color)(flag ? new Color(0.13f, 0.22f, 0.27f) : Surface), 7f);
			}
			if (flag)
			{
				Fill(new Rect(((Rect)(ref rect)).x + 1f, ((Rect)(ref rect)).y + 9f, 3f, 21f), Cyan, 2f);
			}
			Text(new Rect(((Rect)(ref rect)).x + 13f, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width - 16f, ((Rect)(ref rect)).height), CategoryName(item), (item == "CREDIT") ? detail : label, flag ? Cyan : Ink);
			if (Hit(rect) && (!flag || featureSettings != null))
			{
				featureSettings = null;
				changingMapKey = false;
				category = item;
				scroll = Vector2.zero;
			}
		}

		private void DrawFeatures(float width, float height)
		{
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_030e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_0348: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0358: Unknown result type (might be due to invalid IL or missing references)
			//IL_0351: 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_03fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0367: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_043b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0385: Unknown result type (might be due to invalid IL or missing references)
			//IL_038a: Unknown result type (might be due to invalid IL or missing references)
			//IL_045e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0479: Unknown result type (might be due to invalid IL or missing references)
			FeatureRegistry.Entry[] array = features.Entries.Where((FeatureRegistry.Entry entry2) => entry2.Feature.Category == category).ToArray();
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(211f, 133f, width - 235f, height - 153f);
			float num = array.Sum((FeatureRegistry.Entry entry2) => (!entry2.Enabled.Value || entry2.Feature.Option == null) ? 62 : 103);
			float num2 = ((Rect)(ref val)).width - ((num > ((Rect)(ref val)).height) ? 16f : 0f);
			scroll = GUI.BeginScrollView(val, scroll, new Rect(0f, 0f, num2, num));
			float num3 = 0f;
			Rect val2 = default(Rect);
			Rect rect = default(Rect);
			Rect rect2 = default(Rect);
			Rect rect3 = default(Rect);
			foreach (FeatureRegistry.Entry entry in array)
			{
				((Rect)(ref val2))..ctor(0f, num3, num2 - 1f, 53f);
				FeatureOption option = entry.Feature.Option;
				bool num5 = entry.Enabled.Value && option != null;
				((Rect)(ref rect))..ctor(((Rect)(ref val2)).xMax - 61f, ((Rect)(ref val2)).y + 15f, 44f, 23f);
				bool flag = entry.Feature.Sliders.Count > 0;
				((Rect)(ref rect2))..ctor(((Rect)(ref val2)).xMax - 105f, ((Rect)(ref val2)).y + 10f, 34f, 34f);
				Fill(val2, Hover(val2) ? Border : Surface, 9f);
				string value = (Japanese ? entry.Feature.JapaneseLabel : entry.Feature.Label);
				string value2 = (entry.Enabled.Value ? entry.Feature.Status(Japanese) : null);
				float num6 = (string.IsNullOrEmpty(value2) ? ((Rect)(ref val2)).height : 30f);
				Text(new Rect(14f, ((Rect)(ref val2)).y, ((Rect)(ref val2)).width - (float)(flag ? 120 : 88), num6), value, label, Ink);
				if (!string.IsNullOrEmpty(value2))
				{
					Text(new Rect(14f, ((Rect)(ref val2)).y + 25f, ((Rect)(ref val2)).width - 88f, 22f), value2, detail, Muted);
				}
				if (entry.Faulted)
				{
					Text(new Rect(((Rect)(ref val2)).xMax - 116f, ((Rect)(ref val2)).y, 51f, ((Rect)(ref val2)).height), Japanese ? "エラー" : "Error", small, new Color(1f, 0.62f, 0.54f));
				}
				DrawSwitch(rect, entry.Enabled.Value);
				if (Hit((Rect)(flag ? new Rect(((Rect)(ref val2)).x, ((Rect)(ref val2)).y, ((Rect)(ref rect2)).x - ((Rect)(ref val2)).x - 4f, ((Rect)(ref val2)).height) : val2)) || (flag && Hit(rect)))
				{
					entry.Enabled.Value = !entry.Enabled.Value;
				}
				if (flag)
				{
					Fill(rect2, Hover(rect2) ? Border : Panel, 6f);
					DrawGear(rect2);
					if (Hit(rect2))
					{
						featureSettings = entry.Feature;
						settingsScroll = Vector2.zero;
					}
				}
				num3 += 62f;
				if (num5)
				{
					((Rect)(ref rect3))..ctor(15f, ((Rect)(ref val2)).yMax + 2f, ((Rect)(ref val2)).width - 15f, 37f);
					Rect rect4 = new Rect(((Rect)(ref rect3)).xMax - 55f, ((Rect)(ref rect3)).y + 8f, 38f, 21f);
					Fill(rect3, Hover(rect3) ? Border : Surface, 6f);
					Text(new Rect(((Rect)(ref rect3)).x + 13f, ((Rect)(ref rect3)).y, ((Rect)(ref rect3)).width - 78f, ((Rect)(ref rect3)).height), Japanese ? option.JapaneseLabel : option.Label, label, Muted);
					DrawSwitch(rect4, option.Value.Value);
					if (Hit(rect3))
					{
						option.Value.Value = !option.Value.Value;
					}
					num3 += 41f;
				}
			}
			GUI.EndScrollView();
		}

		private static void DrawGear(Rect rect)
		{
			//IL_0002: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			float x = ((Rect)(ref rect)).center.x;
			float y = ((Rect)(ref rect)).center.y;
			for (int i = 0; i < 8; i++)
			{
				float num = (float)i * MathF.PI / 4f;
				Fill(new Rect(x + Mathf.Cos(num) * 7f - 1.5f, y + Mathf.Sin(num) * 7f - 1.5f, 3f, 3f), Ink, 1f);
			}
			Fill(new Rect(x - 6.5f, y - 6.5f, 13f, 13f), Ink, 6.5f);
			Fill(new Rect(x - 2.7f, y - 2.7f, 5.4f, 5.4f), Panel, 2.7f);
		}

		private void DrawFeatureSettings(float width, float height)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_020a: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = new Rect(width - 101f, 91f, 76f, 29f);
			Fill(rect, Hover(rect) ? Border : Surface, 6f);
			Text(rect, Japanese ? "戻る" : "Back", centered, Ink);
			if (Hit(rect))
			{
				featureSettings = null;
				return;
			}
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(211f, 131f, width - 235f, height - 147f);
			IReadOnlyList<FeatureSlider> sliders = featureSettings.Sliders;
			float num = ((Rect)(ref val)).width - (((float)(sliders.Count * 47 + 38) > ((Rect)(ref val)).height) ? 16f : 0f);
			settingsScroll = GUI.BeginScrollView(val, settingsScroll, new Rect(0f, 0f, num, (float)(sliders.Count * 47 + 38)));
			for (int i = 0; i < sliders.Count; i++)
			{
				FeatureSlider featureSlider = sliders[i];
				float num2 = 47 * i;
				Fill(new Rect(0f, num2, num - 1f, 41f), Surface, 6f);
				Text(new Rect(12f, num2, 153f, 41f), Japanese ? featureSlider.JapaneseLabel : featureSlider.Label, label, Ink);
				float num3 = GUI.HorizontalSlider(new Rect(169f, num2 + 15f, num - 259f, 16f), featureSlider.Value.Value, featureSlider.Min, featureSlider.Max);
				if (!Mathf.Approximately(num3, featureSlider.Value.Value))
				{
					featureSlider.Value.Value = Mathf.Round(num3 * 20f) / 20f;
				}
				Text(new Rect(num - 78f, num2, 70f, 41f), featureSlider.FormatValue(), centered, Cyan);
			}
			string value = (Japanese ? featureSettings.JapaneseSettingsHint : featureSettings.SettingsHint);
			if (!string.IsNullOrEmpty(value))
			{
				Text(new Rect(2f, (float)(47 * sliders.Count), num - 4f, 30f), value, small, Muted);
			}
			GUI.EndScrollView();
		}

		private void DrawItemList(float width, float height)
		{
			//IL_0078: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_02be: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
			string[] array = ((!Japanese) ? new string[3] { "Weapons", "Items", "Upgrades" } : new string[3] { "武器", "アイテム", "アップグレード" });
			float num = (width - 235f) / (float)array.Length;
			for (int i = 0; i < array.Length; i++)
			{
				Rect rect = new Rect(211f + (float)i * num, 129f, num - 5f, 30f);
				PurchasedItems.Category category = (PurchasedItems.Category)i;
				bool flag = itemCategory == category;
				Fill(rect, flag ? Border : Surface, 6f);
				Text(rect, array[i], centered, flag ? Cyan : Ink);
				if (Hit(rect) && !flag)
				{
					itemCategory = category;
					scroll = Vector2.zero;
				}
			}
			var array2 = (from row in PurchasedItems.Read(Japanese)
				where PurchasedItems.CategoryOf(row.Key) == itemCategory
				group row by row.Key into @group
				select new
				{
					Name = @group.First().Name,
					Count = @group.Sum((PurchasedItems.Row row) => row.Quantity),
					States = (from row in @group
						group row by (Owner: row.Owner, Status: row.Status, Detail: row.Detail, BatteryBars: row.BatteryBars, BatteryFilled: row.BatteryFilled) into state
						select (State: state.Key, Count: state.Sum((PurchasedItems.Row row) => row.Quantity))).ToArray()
				}).ToArray();
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(211f, 168f, width - 235f, height - 188f);
			if (array2.Length == 0)
			{
				Text(val, Japanese ? "購入済みアイテムなし" : "No purchased items", detail, Muted);
				return;
			}
			float num2 = array2.Sum(anon2 => 30f + (float)anon2.States.Length * 22f);
			float num3 = ((Rect)(ref val)).width - ((num2 > ((Rect)(ref val)).height) ? 16f : 0f);
			scroll = GUI.BeginScrollView(val, scroll, new Rect(0f, 0f, num3, num2));
			float num4 = 0f;
			var array3 = array2;
			foreach (var anon in array3)
			{
				float num6 = 30f + (float)anon.States.Length * 22f;
				Fill(new Rect(0f, num4, num3 - 1f, num6 - 5f), Surface, 7f);
				string value = ((anon.Count > 1) ? $"{anon.Name} ×{anon.Count}" : anon.Name);
				Text(new Rect(12f, num4 + 2f, num3 - 24f, 22f), value, label, Ink);
				float num7 = num4 + 23f;
				((string, string, string, int, int), int)[] states = anon.States;
				for (int num8 = 0; num8 < states.Length; num8++)
				{
					((string, string, string, int, int), int) tuple = states[num8];
					(string, string, string, int, int) item = tuple.Item1;
					int item2 = tuple.Item2;
					string text = (string.IsNullOrEmpty(item.Item1) ? item.Item2 : (item.Item2 + " · " + item.Item1));
					if (anon.States.Length > 1)
					{
						text = $"×{item2}  {text}";
					}
					Text(new Rect(12f, num7, num3 - 111f, 20f), text, detail, Muted);
					if (item.Item4 > 0)
					{
						DrawBattery(new Rect(num3 - 94f, num7 + 1f, 78f, 17f), item.Item4, item.Item5);
					}
					else
					{
						Text(new Rect(num3 - 97f, num7, 87f, 20f), item.Item3 ?? "", small, Cyan);
					}
					num7 += 22f;
				}
				num4 += num6;
			}
			GUI.EndScrollView();
		}

		public void UpdateSkin()
		{
			skin.Update();
		}

		public void ResetSkin()
		{
			skin.Reset();
		}

		private void DrawPlayerList(float width, float height)
		{
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bd: 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_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: 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_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: 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_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: 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_028b: Unknown result type (might be due to invalid IL or missing references)
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0291: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b0: 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)
			//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			PlayerAvatar local = LocalGame.Player;
			Rect val = default(Rect);
			((Rect)(ref val))..ctor(211f, 133f, width - 235f, height - 178f);
			PlayerAvatar[] array = ((Object.op_Implicit((Object)(object)local) && Object.op_Implicit((Object)(object)GameDirector.instance)) ? (from player in SemiFunc.PlayerGetList()
				where Object.op_Implicit((Object)(object)player) && (Object)(object)player != (Object)(object)local
				select player).ToArray() : Array.Empty<PlayerAvatar>());
			if (skin.Active)
			{
				Rect rect = new Rect(width - 157f, 93f, 133f, 28f);
				Fill(rect, Hover(rect) ? Border : Surface, 6f);
				Text(rect, Japanese ? "元のスキンに戻す" : "Restore skin", centered, Cyan);
				if (Hit(rect))
				{
					skin.QueueRestore();
				}
			}
			string result = skin.Result;
			if (result != null)
			{
				string text = ((!(result == "copied")) ? (Japanese ? "スキンを読み込めませんでした" : "Could not load skin") : (Japanese ? "所持しているコスメに着替えました" : "Owned cosmetics equipped"));
				string value = text;
				Text(new Rect(211f, height - 39f, width - 235f, 20f), value, detail, Cyan);
			}
			if (array.Length == 0)
			{
				Text(val, Japanese ? "同じマップに他のプレイヤーはいません" : "No other players on this map", detail, Muted);
				return;
			}
			float num = ((Rect)(ref val)).width - (((float)array.Length * 47f > ((Rect)(ref val)).height) ? 16f : 0f);
			scroll = GUI.BeginScrollView(val, scroll, new Rect(0f, 0f, num, (float)array.Length * 47f));
			Rect rect2 = default(Rect);
			for (int num2 = 0; num2 < array.Length; num2++)
			{
				PlayerAvatar val2 = array[num2];
				float num3 = (float)num2 * 47f;
				Fill(new Rect(0f, num3, num, 42f), Surface, 6f);
				Text(new Rect(12f, num3, num - 154f, 42f), LocalGame.Name(val2) ?? "", label, Ink);
				((Rect)(ref rect2))..ctor(num - 131f, num3 + 6f, 123f, 30f);
				bool flag = SkinPreview.CanCopy(local, val2);
				Fill(rect2, (flag && Hover(rect2)) ? Border : Panel, 6f);
				Text(rect2, (!flag) ? (Japanese ? "共通コスメなし" : "No shared cosmetics") : (Japanese ? "スキンをマネする" : "Copy skin"), centered, flag ? Cyan : Muted);
				if (flag && Hit(rect2))
				{
					skin.QueueCopy(local, val2);
				}
			}
			GUI.EndScrollView();
		}

		private static void DrawBattery(Rect rect, int count, int filled)
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_0039: 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_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_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			bool num = filled * 2 <= count;
			Color val = (num ? new Color(1f, 0.25f, 0.18f) : new Color(0.94f, 0.96f, 1f));
			Color val2 = (Color)(num ? new Color(1f, 0.53f, 0.19f) : val);
			Fill(new Rect(((Rect)(ref rect)).xMax, ((Rect)(ref rect)).y + 5f, 3f, 7f), val);
			Fill(rect, val, 2f);
			Fill(new Rect(((Rect)(ref rect)).x + 2f, ((Rect)(ref rect)).y + 2f, ((Rect)(ref rect)).width - 4f, ((Rect)(ref rect)).height - 4f), Panel);
			float num2 = (((Rect)(ref rect)).width - 8f) / (float)count;
			for (int i = 0; i < count; i++)
			{
				Fill(new Rect(((Rect)(ref rect)).x + 4f + (float)i * num2, ((Rect)(ref rect)).y + 4f, num2 - 2f, ((Rect)(ref rect)).height - 8f), (i < filled) ? val2 : Border, 1f);
			}
		}

		private void DrawCredit(float width, float height)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: 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_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: 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_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0192: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			Rect rect = default(Rect);
			((Rect)(ref rect))..ctor(211f, 137f, width - 236f, 119f);
			Fill(rect, Surface, 9f);
			Text(new Rect(((Rect)(ref rect)).x + 15f, ((Rect)(ref rect)).y + 7f, ((Rect)(ref rect)).width - 30f, 27f), Japanese ? "公式サポートDiscordサーバー" : "Official Support Discord Server", label, Ink);
			Text(new Rect(((Rect)(ref rect)).x + 15f, ((Rect)(ref rect)).y + 35f, ((Rect)(ref rect)).width - 30f, 24f), Japanese ? "開発者Discord : @24san_org" : "Developer Discord : @24san_org", detail, Muted);
			Rect rect2 = new Rect(((Rect)(ref rect)).x + 15f, ((Rect)(ref rect)).y + 68f, ((Rect)(ref rect)).width - 30f, 35f);
			Fill(rect2, (Color)(Hover(rect2) ? Border : new Color(0.13f, 0.25f, 0.3f)), 7f);
			Text(rect2, Japanese ? "Discord サーバーに参加する" : "Join the Discord server", centered, Cyan);
			if (Hit(rect2))
			{
				Application.OpenURL("https://discord.gg/J8NqZAZJMV");
			}
			Text(new Rect(211f, 266f, width - 236f, 26f), "© Team ace. All rights reserved.", centered, Muted);
			Text(new Rect(((Rect)(ref rect)).x, height - 30f, ((Rect)(ref rect)).width, 22f), "team-ace.jp", centered, Ink);
		}

		private void DrawSettings(float width, float height)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: 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_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_017a: 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_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0223: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: 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_0233: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_0290: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f0: Unknown result type (might be due to invalid IL or missing references)
			string value = (Japanese ? "バージョン 0.0.2" : "Version 0.0.2");
			Text(new Rect(211f, height - 43f, width - 235f, 23f), value, detail, Muted);
			Rect rect = default(Rect);
			((Rect)(ref rect))..ctor(211f, 133f, width - 236f, 64f);
			Fill(rect, Surface, 9f);
			Text(new Rect(((Rect)(ref rect)).x + 14f, ((Rect)(ref rect)).y, 170f, ((Rect)(ref rect)).height), Japanese ? "表示言語" : "Menu language", label, Ink);
			DrawLanguage(new Rect(((Rect)(ref rect)).xMax - 200f, ((Rect)(ref rect)).y + 14f, 90f, 36f), "English", MenuLanguage.English);
			DrawLanguage(new Rect(((Rect)(ref rect)).xMax - 102f, ((Rect)(ref rect)).y + 14f, 88f, 36f), "日本語", MenuLanguage.Japanese);
			Rect rect2 = default(Rect);
			((Rect)(ref rect2))..ctor(((Rect)(ref rect)).x, ((Rect)(ref rect)).yMax + 10f, ((Rect)(ref rect)).width, 64f);
			Fill(rect2, Surface, 9f);
			Text(new Rect(((Rect)(ref rect2)).x + 14f, ((Rect)(ref rect2)).y, 210f, ((Rect)(ref rect2)).height), Japanese ? "全画面マップのキー" : "Full map shortcut", label, Ink);
			Rect rect3 = default(Rect);
			((Rect)(ref rect3))..ctor(((Rect)(ref rect2)).xMax - 82f, ((Rect)(ref rect2)).y + 14f, 68f, 36f);
			Rect rect4 = default(Rect);
			((Rect)(ref rect4))..ctor(((Rect)(ref rect3)).x - 161f, ((Rect)(ref rect3)).y, 153f, 36f);
			Fill(rect4, (Color)(changingMapKey ? new Color(0.13f, 0.25f, 0.3f) : (Hover(rect4) ? Border : Panel)), 7f);
			Fill(rect3, Hover(rect3) ? Border : Panel, 7f);
			string value2 = ((object)preferences.FullMapKey.Value/*cast due to .constrained prefix*/).ToString();
			if (changingMapKey)
			{
				value2 = (Japanese ? "キーを押す · Escで取消" : "Press a key · Esc cancels");
			}
			Text(rect4, value2, centered, changingMapKey ? Cyan : Ink);
			Text(rect3, Japanese ? "初期値" : "Reset", centered, Ink);
			if (Hit(rect4))
			{
				changingMapKey = !changingMapKey;
			}
			if (Hit(rect3))
			{
				preferences.FullMapKey.Value = (Key)27;
				changingMapKey = false;
			}
		}

		private void DrawLanguage(Rect rect, string text, MenuLanguage value)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_0063: Unknown result type (might be due to invalid IL or missing references)
			bool flag = value == language.Value;
			Fill(rect, (Color)(flag ? new Color(0.13f, 0.25f, 0.3f) : (Hover(rect) ? Border : Panel)), 7f);
			Text(rect, text, centered, flag ? Cyan : Ink);
			if (Hit(rect))
			{
				language.Value = value;
			}
		}

		private static void DrawSwitch(Rect rect, bool enabled)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: 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)
			Fill(rect, (Color)(enabled ? Cyan : new Color(0.32f, 0.37f, 0.44f)), ((Rect)(ref rect)).height / 2f);
			Fill(new Rect(enabled ? (((Rect)(ref rect)).xMax - 19f) : (((Rect)(ref rect)).x + 4f), ((Rect)(ref rect)).y + 4f, 15f, 15f), (Color)(enabled ? Color.white : new Color(0.91f, 0.94f, 0.97f)), 7.5f);
		}

		private string CategoryName(string item)
		{
			if (!Japanese)
			{
				return item;
			}
			return item switch
			{
				"Utility" => "便利系", 
				"Map" => "マップ系", 
				"Settings" => "設定", 
				"CREDIT" => "クレジット", 
				"Item List" => "アイテム一覧", 
				"Skin Copy" => "スキン変身", 
				_ => item, 
			};
		}

		private void EnsureStyles()
		{
			if (title == null)
			{
				japaneseFont = Font.CreateDynamicFontFromOSFont(new string[4] { "Yu Gothic UI", "Meiryo", "MS Gothic", "Arial" }, 16);
				title = MakeStyle(24, (FontStyle)1, (TextAnchor)3);
				section = MakeStyle(20, (FontStyle)1, (TextAnchor)3);
				label = MakeStyle(15, (FontStyle)0, (TextAnchor)3);
				small = MakeStyle(12, (FontStyle)0, (TextAnchor)4);
				detail = MakeStyle(12, (FontStyle)0, (TextAnchor)3);
				centered = MakeStyle(14, (FontStyle)1, (TextAnchor)4);
			}
		}

		private GUIStyle MakeStyle(int size, FontStyle weight, TextAnchor alignment)
		{
			//IL_000a: 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_0034: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			return new GUIStyle(GUI.skin.label)
			{
				font = (Object.op_Implicit((Object)(object)japaneseFont) ? japaneseFont : GUI.skin.font),
				fontSize = size,
				fontStyle = weight,
				alignment = alignment,
				padding = new RectOffset(),
				richText = false,
				clipping = (TextClipping)1
			};
		}

		private static bool Hover(Rect rect)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			return ((Rect)(ref rect)).Contains(Event.current.mousePosition);
		}

		private static bool Hit(Rect rect)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			return GUI.Button(rect, GUIContent.none, GUIStyle.none);
		}

		private static void Fill(Rect rect, Color color, float radius = 0f)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			GUI.DrawTexture(rect, (Texture)(object)Texture2D.whiteTexture, (ScaleMode)0, true, 0f, color, 0f, radius);
		}

		private static void Text(Rect rect, string value, GUIStyle style, Color color)
		{
			//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)
			style.normal.textColor = color;
			GUI.Label(rect, value, style);
		}
	}
}
namespace RepoClientTools.Game
{
	internal static class ClientEnemyHealth
	{
		private sealed class Estimate
		{
			public int Remaining;

			public Estimate(EnemyHealth health)
			{
				Remaining = health.health;
			}
		}

		[HarmonyPatch(typeof(EnemyHealth), "OnSpawn")]
		private static class Spawn
		{
			private static void Postfix(EnemyHealth __instance)
			{
				Estimates.Remove(__instance);
			}
		}

		[HarmonyPatch(typeof(EnemyHealth), "HurtRPC")]
		private static class Damage
		{
			private static void Postfix(EnemyHealth __instance, int _damage, PhotonMessageInfo _info)
			{
				//IL_0004: Unknown result type (might be due to invalid IL or missing references)
				if (_damage > 0 && Observe(_info))
				{
					Estimate estimate = GetEstimate(__instance);
					if (estimate.Remaining > 0)
					{
						estimate.Remaining = Mathf.Max(1, estimate.Remaining - _damage);
					}
				}
			}
		}

		[HarmonyPatch(typeof(EnemyHealth), "DeathRPC")]
		private static class Death
		{
			private static void Postfix(EnemyHealth __instance, PhotonMessageInfo _info)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				if (Observe(_info))
				{
					GetEstimate(__instance).Remaining = 0;
				}
			}
		}

		private static readonly ConditionalWeakTable<EnemyHealth, Estimate> Estimates = new ConditionalWeakTable<EnemyHealth, Estimate>();

		public static int Get(EnemyHealth health)
		{
			return GetEstimate(health).Remaining;
		}

		private static Estimate GetEstimate(EnemyHealth health)
		{
			return Estimates.GetValue(health, (EnemyHealth enemy) => new Estimate(enemy));
		}

		private static bool Observe(PhotonMessageInfo info)
		{
			//IL_000e: 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)
			if (GameManager.Multiplayer() && !PhotonNetwork.IsMasterClient && info.Sender != null)
			{
				return info.Sender == PhotonNetwork.MasterClient;
			}
			return false;
		}
	}
	internal static class EmbeddedVoicevox
	{
		private sealed class Synthesizer
		{
			private readonly IntPtr library;

			private readonly IntPtr instance;

			private readonly QueryDelegate createQuery;

			private readonly TtsDelegate synthesize;

			private readonly DeleteDelegate freeJson;

			private static readonly Regex SpeedScale = new Regex("(?<=\"speedScale\":)\\s*[0-9]+(?:\\.[0-9]+)?");

			private readonly DeleteDelegate freeBytes;

			private readonly ErrorDelegate error;

			public Synthesizer(string root)
			{
				library = LoadLibraryEx(Path.Combine(root, "voicevox_core.dll"), IntPtr.Zero, 4352u);
				if (library == IntPtr.Zero)
				{
					throw new Win32Exception(Marshal.GetLastWin32Error(), "Could not load the bundled VOICEVOX Core.");
				}
				error = Get<ErrorDelegate>("voicevox_error_result_to_message");
				createQuery = Get<QueryDelegate>("voicevox_synthesizer_create_audio_query");
				synthesize = Get<TtsDelegate>("voicevox_synthesizer_synthesis");
				freeJson = Get<DeleteDelegate>("voicevox_string_free");
				freeBytes = Get<DeleteDelegate>("voicevox_bytes_free");
				IntPtr intPtr = Marshal.StringToCoTaskMemUTF8(Path.Combine(root, "voicevox_onnxruntime.dll"));
				IntPtr runtime;
				try
				{
					Check(Get<LoadRuntimeDelegate>("voicevox_onnxruntime_load_once")(intPtr, out runtime), "load ONNX Runtime");
				}
				finally
				{
					Marshal.FreeCoTaskMem(intPtr);
				}
				Check(Get<OpenDelegate>("voicevox_open_jtalk_rc_new")(Path.Combine(root, "dictionary"), out var handle), "open dictionary");
				try
				{
					InitializeOptions options = new InitializeOptions
					{
						AccelerationMode = 1,
						CpuThreads = 2
					};
					Check(Get<CreateDelegate>("voicevox_synthesizer_new")(runtime, handle, options, out instance), "create synthesizer");
					try
					{
						Check(Get<OpenDelegate>("voicevox_voice_model_file_open")(Path.Combine(root, "0.vvm"), out var handle2), "open voice model");
						try
						{
							int options2 = Get<ModelOptionsDelegate>("voicevox_make_default_load_voice_model_options")();
							Check(Get<LoadModelDelegate>("voicevox_synthesizer_load_voice_model")(instance, handle2, options2), "load voice model");
						}
						finally
						{
							Get<DeleteDelegate>("voicevox_voice_model_file_delete")(handle2);
						}
					}
					catch
					{
						Get<DeleteDelegate>("voicevox_synthesizer_delete")(instance);
						throw;
					}
				}
				finally
				{
					Get<DeleteDelegate>("voicevox_open_jtalk_rc_delete")(handle);
				}
			}

			public byte[] Speak(string text, float speed)
			{
				Check(createQuery(instance, text, 3u, out var query), "create audio query");
				string text2;
				try
				{
					text2 = SpeedScale.Replace(Marshal.PtrToStringUTF8(query), speed.ToString("0.00", CultureInfo.InvariantCulture), 1);
				}
				finally
				{
					freeJson(query);
				}
				Check(synthesize(instance, text2, 3u, 1, out var length, out var wave), "synthesize speech");
				try
				{
					ulong num = length.ToUInt64();
					if (num < 44 || num > 4000000)
					{
						throw new InvalidDataException("Unexpected size for synthesized audio.");
					}
					byte[] array = new byte[(uint)num];
					Marshal.Copy(wave, array, 0, array.Length);
					return array;
				}
				finally
				{
					freeBytes(wave);
				}
			}

			private T Get<T>(string name) where T : Delegate
			{
				IntPtr procAddress = GetProcAddress(library, name);
				if (procAddress == IntPtr.Zero)
				{
					throw new EntryPointNotFoundException(name);
				}
				return Marshal.GetDelegateForFunctionPointer<T>(procAddress);
			}

			private void Check(int result, string action)
			{
				if (result != 0)
				{
					throw new InvalidOperationException($"VOICEVOX could not {action}: {Marshal.PtrToStringUTF8(error(result))} ({result}).");
				}
			}
		}

		private struct InitializeOptions
		{
			public int AccelerationMode;

			public ushort CpuThreads;
		}

		[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
		private delegate int LoadRuntimeDelegate(IntPtr filename, out IntPtr runtime);

		[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
		private delegate int OpenDelegate([MarshalAs(UnmanagedType.LPUTF8Str)] string path, out IntPtr handle);

		[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
		private delegate int CreateDelegate(IntPtr runtime, IntPtr dictionary, InitializeOptions options, out IntPtr synth);

		[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
		private delegate int ModelOptionsDelegate();

		[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
		private delegate int LoadModelDelegate(IntPtr synth, IntPtr model, int options);

		[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
		private delegate int QueryDelegate(IntPtr synth, [MarshalAs(UnmanagedType.LPUTF8Str)] string text, uint style, out IntPtr query);

		[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
		private delegate int TtsDelegate(IntPtr synth, [MarshalAs(UnmanagedType.LPUTF8Str)] string text, uint style, byte options, out UIntPtr length, out IntPtr wave);

		[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
		private delegate void DeleteDelegate(IntPtr value);

		[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
		private delegate IntPtr ErrorDelegate(int result);

		private const string ArchiveName = "RepoClientTools.Voice.zip";

		private const string RuntimeFolder = "RepoClientTools.Voice.0.17.1";

		private const uint ZundamonNormal = 3u;

		private static readonly Lazy<Synthesizer> Engine = new Lazy<Synthesizer>(() => new Synthesizer(PrepareRuntime()));

		private static readonly object SynthesisGate = new object();

		public static Task WarmUp(CancellationToken cancellation)
		{
			return Task.Run(delegate
			{
				cancellation.ThrowIfCancellationRequested();
				_ = Engine.Value;
			}, cancellation);
		}

		public static Task<byte[]> Speak(string text, CancellationToken cancellation, float speed = 1f)
		{
			return Task.Run(delegate
			{
				lock (SynthesisGate)
				{
					cancellation.ThrowIfCancellationRequested();
					byte[] result = Engine.Value.Speak(text, speed);
					cancellation.ThrowIfCancellationRequested();
					return result;
				}
			}, cancellation);
		}

		private static string PrepareRuntime()
		{
			string? directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			string text = Path.Combine(directoryName, "RepoClientTools.Voice.zip");
			string text2 = Path.Combine(directoryName, "RepoClientTools.Voice.0.17.1");
			if (Directory.Exists(text2))
			{
				return text2;
			}
			if (!File.Exists(text))
			{
				throw new FileNotFoundException("The bundled VOICEVOX runtime is missing.", text);
			}
			string text3 = text2 + "." + Guid.NewGuid().ToString("N");
			try
			{
				ZipFile.ExtractToDirectory(text, text3);
				try
				{
					Directory.Move(text3, text2);
				}
				catch (IOException) when (Directory.Exists(text2))
				{
				}
			}
			finally
			{
				if (Directory.Exists(text3))
				{
					Directory.Delete(text3, recursive: true);
				}
			}
			return text2;
		}

		[DllImport("kernel32.dll", CharSet = CharSet.Unicode, EntryPoint = "LoadLibraryExW", SetLastError = true)]
		private static extern IntPtr LoadLibraryEx(string file, IntPtr reserved, uint flags);

		[DllImport("kernel32.dll", ExactSpelling = true, SetLastError = true)]
		private static extern IntPtr GetProcAddress(IntPtr module, string name);
	}
	internal static class EnemyAccess
	{
		private sealed class DisplayNames
		{
			public string English;

			public string Japanese;
		}

		private static readonly FieldRef<EnemyParent, Enemy> EnemyRef = AccessTools.FieldRefAccess<EnemyParent, Enemy>("Enemy");

		private static readonly FieldRef<EnemyParent, bool> Spawned = AccessTools.FieldRefAccess<EnemyParent, bool>("Spawned");

		private static readonly FieldRef<Enemy, EnemyHealth> HealthRef = AccessTools.FieldRefAccess<Enemy, EnemyHealth>("Health");

		private static readonly FieldRef<EnemyHealth, int> Current = AccessTools.FieldRefAccess<EnemyHealth, int>("healthCurrent");

		private static readonly FieldRef<EnemyHealth, bool> Dead = AccessTools.FieldRefAccess<EnemyHealth, bool>("dead");

		private static readonly FieldRef<Enemy, EnemyParent> Parent = AccessTools.FieldRefAccess<Enemy, EnemyParent>("EnemyParent");

		private static readonly ConditionalWeakTable<EnemyParent, DisplayNames> Names = new ConditionalWeakTable<EnemyParent, DisplayNames>();

		public static string Name(Enemy enemy, bool japanese)
		{
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			EnemyParent val = Parent.Invoke(enemy);
			if (!Object.op_Implicit((Object)(object)val))
			{
				return ((Object)enemy).name;
			}
			if (!Object.op_Implicit((Object)(object)val.enemyNameLocalized))
			{
				return val.enemyName;
			}
			DisplayNames value = Names.GetValue(val, (EnemyParent _) => new DisplayNames());
			string text = (japanese ? value.Japanese : value.English);
			if (text != null)
			{
				return text;
			}
			ILocalesProvider availableLocales = LocalizationSe