Decompiled source of UltraRus v1.3.18

plugins/UltrakULL/UltrakULL.dll

Decompiled a day ago
using System;
using System.CodeDom.Compiler;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Net.Http.Headers;
using System.Reflection;
using System.Reflection.Emit;
using System.Resources;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
using ArabicSupportUnity;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using Discord;
using Emgu.CV;
using Emgu.CV.CvEnum;
using Emgu.Util;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using Sandbox;
using ScriptableObjects;
using SettingsMenu.Components;
using TMPro;
using UltrakULL.Harmony_Patches;
using UltrakULL.Harmony_Patches.AudioSwaps;
using UltrakULL.Harmony_Patches.Subtitles;
using UltrakULL.audio;
using UltrakULL.json;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.Events;
using UnityEngine.InputSystem;
using UnityEngine.Networking;
using UnityEngine.SceneManagement;
using UnityEngine.TextCore.LowLevel;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("UltrakULL")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("UltrakULL")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("a4a60eef-e5f3-4a77-b125-236fbf44cca4")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
}
[HarmonyPatch(typeof(IntroViolenceScreen))]
public static class IntroViolenceScreenPatch
{
	private static GameObject textObject1;

	private static GameObject textObject2;

	[HarmonyPatch("Start")]
	[HarmonyPostfix]
	private static void StartPatch(IntroViolenceScreen __instance)
	{
		Transform parent = ((Component)__instance).transform.parent;
		if (!((Object)(object)parent == (Object)null))
		{
			Transform val = parent.Find("Image");
			Transform val2 = parent.Find("ImageRed");
			if ((Object)(object)val != (Object)null)
			{
				ReplaceImage(val, "violence1.png");
				textObject1 = AddTextToImage(val, LanguageManager.CurrentLanguage.misc.violenceScreenText1, 0f);
			}
			if ((Object)(object)val2 != (Object)null)
			{
				ReplaceImage(val2, "violence2.png");
				textObject2 = AddTextToImage(val2, LanguageManager.CurrentLanguage.misc.violenceScreenText2, 0f);
			}
		}
	}

	[HarmonyPatch("Update")]
	[HarmonyPostfix]
	private static void UpdatePatch(IntroViolenceScreen __instance)
	{
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)textObject1 == (Object)null) && !((Object)(object)textObject2 == (Object)null))
		{
			float value = Traverse.Create((object)__instance).Field("fadeAmount").GetValue<float>();
			float value2 = Traverse.Create((object)__instance).Field("targetAlpha").GetValue<float>();
			bool value3 = Traverse.Create((object)__instance).Field("fade").GetValue<bool>();
			Color color = ((Graphic)Traverse.Create((object)__instance).Field("red").GetValue<Image>()).color;
			if (value3 && value2 == 1f)
			{
				UpdateTextAlpha(textObject1, value);
			}
			if (color.a > 0f)
			{
				UpdateTextAlpha(textObject1, 0f);
				UpdateTextAlpha(textObject2, value);
			}
		}
	}

	private static GameObject AddTextToImage(Transform imageTransform, string text, float startAlpha)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: 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_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: 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_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Expected O, but got Unknown
		GameObject val = new GameObject("Text");
		val.transform.SetParent(imageTransform, false);
		TextMeshProUGUI __instance = val.AddComponent<TextMeshProUGUI>();
		((TMP_Text)__instance).text = text;
		((TMP_Text)__instance).enableAutoSizing = true;
		((TMP_Text)__instance).fontSizeMin = 10f;
		((TMP_Text)__instance).fontSizeMax = 100f;
		((TMP_Text)__instance).alignment = (TextAlignmentOptions)514;
		((TMP_Text)__instance).overflowMode = (TextOverflowModes)0;
		((Graphic)__instance).color = new Color(1f, 1f, 1f, startAlpha);
		((TMP_Text)__instance).enableWordWrapping = false;
		TextMeshProFontSwap.SwapTMPFont(ref __instance);
		RectTransform component = val.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(0.5f, 0.5f);
		component.anchorMax = new Vector2(0.5f, 0.5f);
		component.pivot = new Vector2(0.5f, 0.5f);
		component.anchoredPosition = Vector2.zero;
		float num = Mathf.Min((float)Screen.width * 0.9f, 800f);
		float num2 = Mathf.Min((float)Screen.height * 0.45f, 300f);
		component.sizeDelta = new Vector2(num, num2);
		return val;
	}

	private static void UpdateTextAlpha(GameObject textObj, float alpha)
	{
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		TextMeshProUGUI component = textObj.GetComponent<TextMeshProUGUI>();
		((Graphic)component).color = new Color(((Graphic)component).color.r, ((Graphic)component).color.g, ((Graphic)component).color.b, alpha);
	}

	private static void ReplaceImage(Transform imageTransform, string ImageName)
	{
		Image component = ((Component)imageTransform).GetComponent<Image>();
		if (!((Object)(object)component == (Object)null))
		{
			Sprite val = LoadPNG(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\IntroViolenceScreen", ImageName));
			if ((Object)(object)val != (Object)null)
			{
				component.sprite = val;
			}
		}
	}

	private static Sprite LoadPNG(string filePath)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Expected O, but got Unknown
		//IL_003b: 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)
		if (!File.Exists(filePath))
		{
			return null;
		}
		byte[] array = File.ReadAllBytes(filePath);
		Texture2D val = new Texture2D(2, 2);
		if (ImageConversion.LoadImage(val, array))
		{
			return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
		}
		return null;
	}
}
internal enum IsolatedArabicLetters
{
	Hamza = 65152,
	Alef = 65165,
	AlefHamza = 65155,
	WawHamza = 65157,
	AlefMaksoor = 65159,
	AlefMaksora = 64508,
	HamzaNabera = 65161,
	Ba = 65167,
	Ta = 65173,
	Tha2 = 65177,
	Jeem = 65181,
	H7aa = 65185,
	Khaa2 = 65189,
	Dal = 65193,
	Thal = 65195,
	Ra2 = 65197,
	Zeen = 65199,
	Seen = 65201,
	Sheen = 65205,
	S9a = 65209,
	Dha = 65213,
	T6a = 65217,
	T6ha = 65221,
	Ain = 65225,
	Gain = 65229,
	Fa = 65233,
	Gaf = 65237,
	Kaf = 65241,
	Lam = 65245,
	Meem = 65249,
	Noon = 65253,
	Ha = 65257,
	Waw = 65261,
	Ya = 65265,
	AlefMad = 65153,
	TaMarboota = 65171,
	PersianPe = 64342,
	PersianChe = 64378,
	PersianZe = 64394,
	PersianGaf = 64402,
	PersianGaf2 = 64398,
	PersianYeh = 64508
}
internal enum GeneralArabicLetters
{
	Hamza = 1569,
	Alef = 1575,
	AlefHamza = 1571,
	WawHamza = 1572,
	AlefMaksoor = 1573,
	AlefMagsora = 1609,
	HamzaNabera = 1574,
	Ba = 1576,
	Ta = 1578,
	Tha2 = 1579,
	Jeem = 1580,
	H7aa = 1581,
	Khaa2 = 1582,
	Dal = 1583,
	Thal = 1584,
	Ra2 = 1585,
	Zeen = 1586,
	Seen = 1587,
	Sheen = 1588,
	S9a = 1589,
	Dha = 1590,
	T6a = 1591,
	T6ha = 1592,
	Ain = 1593,
	Gain = 1594,
	Fa = 1601,
	Gaf = 1602,
	Kaf = 1603,
	Lam = 1604,
	Meem = 1605,
	Noon = 1606,
	Ha = 1607,
	Waw = 1608,
	Ya = 1610,
	AlefMad = 1570,
	TaMarboota = 1577,
	PersianPe = 1662,
	PersianChe = 1670,
	PersianZe = 1688,
	PersianGaf = 1711,
	PersianGaf2 = 1705,
	PersianYeh = 1740
}
internal struct ArabicMapping
{
	public int from;

	public int to;

	public ArabicMapping(int from, int to)
	{
		this.from = from;
		this.to = to;
	}
}
internal class ArabicTable
{
	private static ArabicMapping[] mapList;

	private static ArabicTable arabicMapper;

	internal static ArabicTable ArabicMapper
	{
		get
		{
			if (arabicMapper == null)
			{
				arabicMapper = new ArabicTable();
			}
			return arabicMapper;
		}
	}

	private ArabicTable()
	{
		mapList = new ArabicMapping[42]
		{
			new ArabicMapping(1569, 65152),
			new ArabicMapping(1575, 65165),
			new ArabicMapping(1571, 65155),
			new ArabicMapping(1572, 65157),
			new ArabicMapping(1573, 65159),
			new ArabicMapping(1609, 64508),
			new ArabicMapping(1574, 65161),
			new ArabicMapping(1576, 65167),
			new ArabicMapping(1578, 65173),
			new ArabicMapping(1579, 65177),
			new ArabicMapping(1580, 65181),
			new ArabicMapping(1581, 65185),
			new ArabicMapping(1582, 65189),
			new ArabicMapping(1583, 65193),
			new ArabicMapping(1584, 65195),
			new ArabicMapping(1585, 65197),
			new ArabicMapping(1586, 65199),
			new ArabicMapping(1587, 65201),
			new ArabicMapping(1588, 65205),
			new ArabicMapping(1589, 65209),
			new ArabicMapping(1590, 65213),
			new ArabicMapping(1591, 65217),
			new ArabicMapping(1592, 65221),
			new ArabicMapping(1593, 65225),
			new ArabicMapping(1594, 65229),
			new ArabicMapping(1601, 65233),
			new ArabicMapping(1602, 65237),
			new ArabicMapping(1603, 65241),
			new ArabicMapping(1604, 65245),
			new ArabicMapping(1605, 65249),
			new ArabicMapping(1606, 65253),
			new ArabicMapping(1607, 65257),
			new ArabicMapping(1608, 65261),
			new ArabicMapping(1610, 65265),
			new ArabicMapping(1570, 65153),
			new ArabicMapping(1577, 65171),
			new ArabicMapping(1662, 64342),
			new ArabicMapping(1670, 64378),
			new ArabicMapping(1688, 64394),
			new ArabicMapping(1711, 64402),
			new ArabicMapping(1705, 64398),
			new ArabicMapping(1740, 64508)
		};
	}

	internal int Convert(int toBeConverted)
	{
		for (int i = 0; i < mapList.Length; i++)
		{
			ArabicMapping arabicMapping = mapList[i];
			if (arabicMapping.from == toBeConverted)
			{
				return arabicMapping.to;
			}
		}
		return toBeConverted;
	}
}
internal class TashkeelLocation
{
	public char tashkeel;

	public int position;

	public TashkeelLocation(char tashkeel, int position)
	{
		this.tashkeel = tashkeel;
		this.position = position;
	}
}
internal class ArabicFixerTool
{
	internal static bool showTashkeel = true;

	internal static bool combineTashkeel = true;

	internal static bool useHinduNumbers = true;

	internal static StringBuilder internalStringBuilder = new StringBuilder();

	internal static void RemoveTashkeel(ref string str, out List<TashkeelLocation> tashkeelLocation)
	{
		tashkeelLocation = new List<TashkeelLocation>();
		int lastSplitIndex = 0;
		internalStringBuilder.Clear();
		internalStringBuilder.EnsureCapacity(str.Length);
		int num = 0;
		for (int j = 0; j < str.Length; j++)
		{
			if (str[j] == '\u064b')
			{
				tashkeelLocation.Add(new TashkeelLocation('\u064b', j));
				num++;
				IncrementSB(ref str, j);
			}
			else if (str[j] == '\u064c')
			{
				tashkeelLocation.Add(new TashkeelLocation('\u064c', j));
				num++;
				IncrementSB(ref str, j);
			}
			else if (str[j] == '\u064d')
			{
				tashkeelLocation.Add(new TashkeelLocation('\u064d', j));
				num++;
				IncrementSB(ref str, j);
			}
			else if (str[j] == '\u064e')
			{
				if (num > 0 && combineTashkeel && tashkeelLocation[num - 1].tashkeel == '\u0651')
				{
					tashkeelLocation[num - 1].tashkeel = 'ﱠ';
					IncrementSB(ref str, j);
				}
				else
				{
					tashkeelLocation.Add(new TashkeelLocation('\u064e', j));
					num++;
					IncrementSB(ref str, j);
				}
			}
			else if (str[j] == '\u064f')
			{
				if (num > 0 && combineTashkeel && tashkeelLocation[num - 1].tashkeel == '\u0651')
				{
					tashkeelLocation[num - 1].tashkeel = 'ﱡ';
					IncrementSB(ref str, j);
				}
				else
				{
					tashkeelLocation.Add(new TashkeelLocation('\u064f', j));
					num++;
					IncrementSB(ref str, j);
				}
			}
			else if (str[j] == '\u0650')
			{
				if (num > 0 && combineTashkeel && tashkeelLocation[num - 1].tashkeel == '\u0651')
				{
					tashkeelLocation[num - 1].tashkeel = 'ﱢ';
					IncrementSB(ref str, j);
				}
				else
				{
					tashkeelLocation.Add(new TashkeelLocation('\u0650', j));
					num++;
					IncrementSB(ref str, j);
				}
			}
			else if (str[j] == '\u0651')
			{
				if (num > 0 && combineTashkeel)
				{
					if (tashkeelLocation[num - 1].tashkeel == '\u064e')
					{
						tashkeelLocation[num - 1].tashkeel = 'ﱠ';
						IncrementSB(ref str, j);
						continue;
					}
					if (tashkeelLocation[num - 1].tashkeel == '\u064f')
					{
						tashkeelLocation[num - 1].tashkeel = 'ﱡ';
						IncrementSB(ref str, j);
						continue;
					}
					if (tashkeelLocation[num - 1].tashkeel == '\u0650')
					{
						tashkeelLocation[num - 1].tashkeel = 'ﱢ';
						IncrementSB(ref str, j);
						continue;
					}
				}
				tashkeelLocation.Add(new TashkeelLocation('\u0651', j));
				num++;
				IncrementSB(ref str, j);
			}
			else if (str[j] == '\u0652')
			{
				tashkeelLocation.Add(new TashkeelLocation('\u0652', j));
				num++;
				IncrementSB(ref str, j);
			}
			else if (str[j] == '\u0653')
			{
				tashkeelLocation.Add(new TashkeelLocation('\u0653', j));
				num++;
				IncrementSB(ref str, j);
			}
			else if (str[j] == 'ﱠ')
			{
				IncrementSB(ref str, j);
			}
			else if (str[j] == 'ﱡ')
			{
				IncrementSB(ref str, j);
			}
			else if (str[j] == 'ﱢ')
			{
				IncrementSB(ref str, j);
			}
		}
		if (lastSplitIndex != 0)
		{
			IncrementSB(ref str, str.Length);
			str = internalStringBuilder.ToString();
		}
		void IncrementSB(ref string str2, int i)
		{
			if (i - lastSplitIndex > 0)
			{
				internalStringBuilder.Append(str2, lastSplitIndex, i - lastSplitIndex);
			}
			lastSplitIndex = i + 1;
		}
	}

	internal static void ReturnTashkeel(ref char[] letters, List<TashkeelLocation> tashkeelLocation)
	{
		Array.Resize(ref letters, letters.Length + tashkeelLocation.Count);
		for (int i = 0; i < tashkeelLocation.Count; i++)
		{
			TashkeelLocation tashkeelLocation2 = tashkeelLocation[i];
			for (int num = letters.Length - 1; num > tashkeelLocation2.position; num--)
			{
				letters[num] = letters[num - 1];
			}
			letters[tashkeelLocation2.position] = tashkeelLocation2.tashkeel;
		}
	}

	internal static string FixLine(string str)
	{
		RemoveTashkeel(ref str, out var tashkeelLocation);
		char[] array = new char[str.Length];
		char[] letters = str.ToCharArray();
		for (int i = 0; i < array.Length; i++)
		{
			array[i] = (char)ArabicTable.ArabicMapper.Convert(str[i]);
		}
		for (int j = 0; j < array.Length; j++)
		{
			bool flag = false;
			if (array[j] == 'ﻝ' && j < array.Length - 1)
			{
				if (array[j + 1] == 'ﺇ')
				{
					array[j] = 'ﻷ';
					letters[j + 1] = '\uffff';
					flag = true;
				}
				else if (array[j + 1] == 'ﺍ')
				{
					array[j] = 'ﻹ';
					letters[j + 1] = '\uffff';
					flag = true;
				}
				else if (array[j + 1] == 'ﺃ')
				{
					array[j] = 'ﻵ';
					letters[j + 1] = '\uffff';
					flag = true;
				}
				else if (array[j + 1] == 'ﺁ')
				{
					array[j] = 'ﻳ';
					letters[j + 1] = '\uffff';
					flag = true;
				}
			}
			if (!IsIgnoredCharacter(array[j]))
			{
				if (IsMiddleLetter(array, j))
				{
					letters[j] = (char)(array[j] + 3);
				}
				else if (IsFinishingLetter(array, j))
				{
					letters[j] = (char)(array[j] + 1);
				}
				else if (IsLeadingLetter(array, j))
				{
					letters[j] = (char)(array[j] + 2);
				}
			}
			if (flag)
			{
				j++;
			}
			letters[j] = (char)HandleInduNumber(array[j], letters[j]);
		}
		if (showTashkeel && tashkeelLocation.Count > 0)
		{
			ReturnTashkeel(ref letters, tashkeelLocation);
		}
		internalStringBuilder.Clear();
		internalStringBuilder.EnsureCapacity(letters.Length);
		List<char> numberList = null;
		for (int num = letters.Length - 1; num >= 0; num--)
		{
			if (char.IsPunctuation(letters[num]) && num > 0 && num < letters.Length - 1 && (char.IsPunctuation(letters[num - 1]) || char.IsPunctuation(letters[num + 1])))
			{
				if (letters[num] != '\uffff')
				{
					internalStringBuilder.Append(letters[num]);
				}
			}
			else if (letters[num] == ' ' && num > 0 && num < letters.Length - 1 && (char.IsLower(letters[num - 1]) || char.IsUpper(letters[num - 1]) || char.IsNumber(letters[num - 1])) && (char.IsLower(letters[num + 1]) || char.IsUpper(letters[num + 1]) || char.IsNumber(letters[num + 1])))
			{
				AddNumber(letters[num]);
			}
			else if (char.IsNumber(letters[num]) || char.IsLower(letters[num]) || char.IsUpper(letters[num]) || char.IsSymbol(letters[num]) || char.IsPunctuation(letters[num]))
			{
				AddNumber(letters[num]);
			}
			else if ((letters[num] >= '\ud800' && letters[num] <= '\udbff') || (letters[num] >= '\udc00' && letters[num] <= '\udfff'))
			{
				AddNumber(letters[num]);
			}
			else
			{
				AppendNumbers();
				if (letters[num] != '\uffff')
				{
					internalStringBuilder.Append(letters[num]);
				}
			}
		}
		AppendNumbers();
		return internalStringBuilder.ToString();
		void AddNumber(char value)
		{
			if (numberList == null)
			{
				numberList = new List<char>();
			}
			numberList.Add(value);
		}
		void AppendNumbers()
		{
			if (numberList != null && numberList.Count > 0)
			{
				for (int k = 0; k < numberList.Count; k++)
				{
					internalStringBuilder.Append(numberList[numberList.Count - 1 - k]);
				}
				numberList.Clear();
			}
		}
	}

	internal static ushort HandleInduNumber(ushort letterOrigin, ushort letterFinal)
	{
		return letterOrigin switch
		{
			48 => 1632, 
			49 => 1633, 
			50 => 1634, 
			51 => 1635, 
			52 => 1636, 
			53 => 1637, 
			54 => 1638, 
			55 => 1639, 
			56 => 1640, 
			57 => 1641, 
			_ => letterFinal, 
		};
	}

	internal static bool IsIgnoredCharacter(char ch)
	{
		bool num = char.IsPunctuation(ch);
		bool flag = char.IsNumber(ch);
		bool flag2 = char.IsLower(ch);
		bool flag3 = char.IsUpper(ch);
		bool flag4 = char.IsSymbol(ch);
		bool flag5 = ch == 'ﭖ' || ch == 'ﭺ' || ch == 'ﮊ' || ch == 'ﮒ' || ch == 'ﮎ';
		bool flag6 = (ch <= '\ufeff' && ch >= 'ﹰ') || flag5 || ch == 'ﯼ';
		if (!(num || flag || flag2 || flag3 || flag4) && flag6 && ch != 'a' && ch != '>' && ch != '<')
		{
			return ch == '؛';
		}
		return true;
	}

	internal static bool IsLeadingLetter(char[] letters, int index)
	{
		bool num = index == 0 || letters[index - 1] == ' ' || char.IsPunctuation(letters[index - 1]) || letters[index - 1] == 'ﺍ' || letters[index - 1] == 'ﺩ' || letters[index - 1] == 'ﺫ' || letters[index - 1] == 'ﺭ' || letters[index - 1] == 'ﺯ' || letters[index - 1] == 'ﮊ' || letters[index - 1] == 'ﻭ' || letters[index - 1] == 'ﺁ' || letters[index - 1] == 'ﺃ' || letters[index - 1] == 'ﺀ' || letters[index - 1] == 'ﺇ' || letters[index - 1] == 'ﺅ';
		bool flag = letters[index] != ' ' && letters[index] != 'ﺩ' && letters[index] != 'ﺫ' && letters[index] != 'ﺭ' && letters[index] != 'ﺯ' && letters[index] != 'ﮊ' && letters[index] != 'ﺍ' && letters[index] != 'ﺃ' && letters[index] != 'ﺇ' && letters[index] != 'ﺁ' && letters[index] != 'ﺅ' && letters[index] != 'ﻭ' && letters[index] != 'ﺀ';
		bool flag2 = index < letters.Length - 1 && letters[index + 1] != ' ' && letters[index + 1] != '\n' && letters[index + 1] != '\r' && !char.IsPunctuation(letters[index + 1]) && !char.IsNumber(letters[index + 1]) && !char.IsSymbol(letters[index + 1]) && !char.IsLower(letters[index + 1]) && !char.IsUpper(letters[index + 1]) && letters[index + 1] != 'ﺀ';
		if (num && flag && flag2)
		{
			return true;
		}
		return false;
	}

	internal static bool IsFinishingLetter(char[] letters, int index)
	{
		bool num = index != 0 && letters[index - 1] != ' ' && letters[index - 1] != 'ﺩ' && letters[index - 1] != 'ﺫ' && letters[index - 1] != 'ﺭ' && letters[index - 1] != 'ﺯ' && letters[index - 1] != 'ﮊ' && letters[index - 1] != 'ﻭ' && letters[index - 1] != 'ﺍ' && letters[index - 1] != 'ﺁ' && letters[index - 1] != 'ﺃ' && letters[index - 1] != 'ﺇ' && letters[index - 1] != 'ﺅ' && letters[index - 1] != 'ﺀ' && !char.IsPunctuation(letters[index - 1]) && !char.IsSymbol(letters[index - 1]);
		bool flag = letters[index] != ' ' && letters[index] != 'ﺀ';
		if (num && flag)
		{
			return true;
		}
		return false;
	}

	internal static bool IsMiddleLetter(char[] letters, int index)
	{
		bool flag = index != 0 && letters[index] != 'ﺍ' && letters[index] != 'ﺩ' && letters[index] != 'ﺫ' && letters[index] != 'ﺭ' && letters[index] != 'ﺯ' && letters[index] != 'ﮊ' && letters[index] != 'ﻭ' && letters[index] != 'ﺁ' && letters[index] != 'ﺃ' && letters[index] != 'ﺇ' && letters[index] != 'ﺅ' && letters[index] != 'ﺀ';
		bool flag2 = index != 0 && letters[index - 1] != 'ﺍ' && letters[index - 1] != 'ﺩ' && letters[index - 1] != 'ﺫ' && letters[index - 1] != 'ﺭ' && letters[index - 1] != 'ﺯ' && letters[index - 1] != 'ﮊ' && letters[index - 1] != 'ﻭ' && letters[index - 1] != 'ﺁ' && letters[index - 1] != 'ﺃ' && letters[index - 1] != 'ﺇ' && letters[index - 1] != 'ﺅ' && letters[index - 1] != 'ﺀ' && !char.IsPunctuation(letters[index - 1]) && letters[index - 1] != '>' && letters[index - 1] != '<' && letters[index - 1] != ' ' && letters[index - 1] != '*';
		if (index < letters.Length - 1 && letters[index + 1] != ' ' && letters[index + 1] != '\r' && letters[index + 1] != 'ﺀ' && !char.IsNumber(letters[index + 1]) && !char.IsSymbol(letters[index + 1]) && !char.IsPunctuation(letters[index + 1]) && flag2 && flag)
		{
			try
			{
				if (char.IsPunctuation(letters[index + 1]))
				{
					return false;
				}
				return true;
			}
			catch
			{
				return false;
			}
		}
		return false;
	}
}
namespace ArabicSupportUnity
{
	public class ArabicFixer
	{
		private static readonly Dictionary<string, string> processedCache = new Dictionary<string, string>(StringComparer.Ordinal);

		private static readonly string[] protectedPatterns = new string[3] { "<color=[^>]+>.*?</color>", "\\{\\d+\\}", "<[^>]+>" };

		private const int MaxCacheSize = 1000;

		private static string PreserveSpecialText(string input, out Dictionary<string, string> placeholderMap)
		{
			string text = input;
			int num = 0;
			placeholderMap = new Dictionary<string, string>(StringComparer.Ordinal);
			string[] array = protectedPatterns;
			foreach (string pattern in array)
			{
				foreach (Match item in Regex.Matches(text, pattern))
				{
					string text2 = $"##TAG_{num}##";
					placeholderMap[text2] = item.Value;
					text = text.Replace(item.Value, text2);
					num++;
				}
			}
			return text;
		}

		private static string RestoreSpecialText(string input, Dictionary<string, string> placeholderMap)
		{
			if (placeholderMap == null || placeholderMap.Count == 0)
			{
				return input;
			}
			string text = input;
			foreach (KeyValuePair<string, string> item in placeholderMap)
			{
				if (item.Key != null)
				{
					text = text.Replace(item.Key, item.Value);
				}
			}
			return text;
		}

		private static void TrimCache()
		{
			if (processedCache.Count > 1000)
			{
				processedCache.Clear();
			}
		}

		public static string Fix(string str)
		{
			if (string.IsNullOrEmpty(str))
			{
				return str;
			}
			if (processedCache.TryGetValue(str, out var value))
			{
				return value;
			}
			TrimCache();
			string input = FixMixedText(PreserveSpecialText(str, out var placeholderMap));
			input = RestoreSpecialText(input, placeholderMap);
			processedCache[str] = input;
			return input;
		}

		private static string FixMixedText(string input)
		{
			if (string.IsNullOrEmpty(input))
			{
				return input;
			}
			Regex regex = new Regex("([\u0600-ۿݐ-ݿࢠ-\u08ff]+)|([^\u0600-ۿݐ-ݿࢠ-\u08ff]+)", RegexOptions.Compiled);
			StringBuilder stringBuilder = new StringBuilder();
			foreach (Match item in regex.Matches(input))
			{
				if (item.Groups[1].Success)
				{
					stringBuilder.Append(ArabicFixerTool.FixLine(item.Value));
				}
				else
				{
					stringBuilder.Append(item.Value);
				}
			}
			return stringBuilder.ToString();
		}

		public static string Fix(string str, bool rtl)
		{
			return FixMixedText(str);
		}

		public static string Fix(string str, bool showTashkeel, bool useHinduNumbers)
		{
			ArabicFixerTool.showTashkeel = showTashkeel;
			ArabicFixerTool.useHinduNumbers = useHinduNumbers;
			if (str.Contains("\n"))
			{
				str = str.Replace("\n", Environment.NewLine);
			}
			if (str.Contains(Environment.NewLine))
			{
				string[] separator = new string[1] { Environment.NewLine };
				string[] array = str.Split(separator, StringSplitOptions.None);
				if (array.Length == 0)
				{
					return ArabicFixerTool.FixLine(str);
				}
				if (array.Length == 1)
				{
					return ArabicFixerTool.FixLine(str);
				}
				string text = ArabicFixerTool.FixLine(array[0]);
				int i = 1;
				if (array.Length > 1)
				{
					for (; i < array.Length; i++)
					{
						text = text + Environment.NewLine + ArabicFixerTool.FixLine(array[i]);
					}
				}
				return text;
			}
			return ArabicFixerTool.FixLine(str);
		}

		public static string Fix(string str, bool showTashkeel, bool combineTashkeel, bool useHinduNumbers)
		{
			ArabicFixerTool.combineTashkeel = combineTashkeel;
			return Fix(str, showTashkeel, useHinduNumbers);
		}
	}
}
namespace UltrakULL
{
	public static class Act1
	{
		private static void PatchHellmap(ref GameObject canvasObj)
		{
			try
			{
				GameObject gameObjectChild = CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(canvasObj, "Hellmap"), "Hellmap Act 1");
				((TMP_Text)CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(gameObjectChild, "Text"))).text = LanguageManager.CurrentLanguage.misc.hellmap_limbo;
				((TMP_Text)CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(gameObjectChild, "Text (1)"))).text = LanguageManager.CurrentLanguage.misc.hellmap_lust;
				((TMP_Text)CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(gameObjectChild, "Text (2)"))).text = LanguageManager.CurrentLanguage.misc.hellmap_gluttony;
			}
			catch (Exception ex)
			{
				Logging.Warn("Failed to patch Act 1 hellmap.");
				Logging.Warn(ex.ToString());
			}
		}

		public static void PatchAct1(ref GameObject canvasObj)
		{
			string currentSceneName = CommonFunctions.GetCurrentSceneName();
			string levelName = Act1Strings.GetLevelName();
			string levelChallenge = Act1Strings.GetLevelChallenge(currentSceneName);
			PatchHellmap(ref canvasObj);
			CommonFunctions.PatchResultsScreen(levelName, levelChallenge);
			if (currentSceneName.Contains("2-1"))
			{
				Transform transform = CommonFunctions.GetGameObjectChild(CommonFunctions.GetInactiveRootObject("3-4 - Outdoors Arenas"), "3-4 Stuff").transform;
				((TMP_Text)CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(((Component)transform.Find("Crane (Moveable)")).gameObject, "Cube (19)"), "Cube"), "UsableScreen New"), "InteractiveScreen"), "Canvas"), "Background"), "Text (TMP) (1)"))).text = LanguageManager.CurrentLanguage.act1.act1_lustFirst_crane;
				((TMP_Text)CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(((Component)transform.Find("UsableScreen New")).gameObject, "InteractiveScreen"), "Canvas"), "Background"), "InteractiveScreen Button"), "Text (TMP)"))).text = LanguageManager.CurrentLanguage.act1.act1_lustFirst_elevator;
			}
		}
	}
	public static class Act1Strings
	{
		private static string Level11(string message, string message2, string input)
		{
			string text = message + message2;
			if (text.Contains("ITEMS"))
			{
				CommonFunctions.PreviousHudMessage = LanguageManager.CurrentLanguage.act1.act1_limboFirst_items1 + " '<color=orange>" + input + "</color>'" + LanguageManager.CurrentLanguage.act1.act1_limboFirst_items2;
				return LanguageManager.CurrentLanguage.act1.act1_limboFirst_items1 + " \"<color=orange>" + input + "</color>\"" + LanguageManager.CurrentLanguage.act1.act1_limboFirst_items2;
			}
			if (text.Contains("NAILGUN"))
			{
				CommonFunctions.PreviousHudMessage = LanguageManager.CurrentLanguage.act1.act1_limboFirst_nailgun1 + " '<color=orange>" + input + "</color>' " + LanguageManager.CurrentLanguage.act1.act1_limboFirst_nailgun2 + "\n" + LanguageManager.CurrentLanguage.act1.act1_limboFirst_nailgun3;
				return LanguageManager.CurrentLanguage.act1.act1_limboFirst_nailgun1 + " '<color=orange>" + input + "</color>'" + LanguageManager.CurrentLanguage.act1.act1_limboFirst_nailgun2 + "\n" + LanguageManager.CurrentLanguage.act1.act1_limboFirst_nailgun3;
			}
			return CommonFunctions.PreviousHudMessage;
		}

		private static string Level12(string message, string message2)
		{
			if ((message + message2).Contains("BLUE"))
			{
				return LanguageManager.CurrentLanguage.act1.act1_limboSecond_blueAttack;
			}
			return "Unimplemented string";
		}

		private static string Level13(string message, string message2)
		{
			if ((message + message2).Contains("SPLIT"))
			{
				return LanguageManager.CurrentLanguage.act1.act1_limboThird_splitDoor1 + "\n" + LanguageManager.CurrentLanguage.act1.act1_limboThird_splitDoor2;
			}
			return "Unimplemented string";
		}

		private static string Level14(string message, string message2, string input)
		{
			string text = message + message2;
			if (text.Contains("PICK"))
			{
				return LanguageManager.CurrentLanguage.act1.act1_limboFourth_book;
			}
			if (text.Contains("Hank"))
			{
				return LanguageManager.CurrentLanguage.act1.act1_limboFourth_hank1 + "\n" + LanguageManager.CurrentLanguage.act1.act1_limboFourth_hank2;
			}
			if (message.Contains("versions"))
			{
				return LanguageManager.CurrentLanguage.misc.hud_alternateVersion;
			}
			if (text.Contains("ALTERNATE REVOLVER"))
			{
				return LanguageManager.CurrentLanguage.act1.act1_limboFourth_alternateRevolver;
			}
			if (text.Contains("EQUIPPED"))
			{
				return LanguageManager.CurrentLanguage.act1.act1_limboFourth_newArm + " '<color=orange>" + input + "</color>'";
			}
			return "Unimplemented string";
		}

		private static string Level1Secret(string message, string message2)
		{
			if ((message + message2).Contains("LOOKS"))
			{
				return LanguageManager.CurrentLanguage.act1.act1_limboSecret_noclipSkip;
			}
			return "Unimplemented string";
		}

		private static string Level21(string message, string message2, string input)
		{
			string text = message + message2;
			if (text.Contains("KNUCKLE"))
			{
				return LanguageManager.CurrentLanguage.act1.act1_lustFirst_knuckleblaster1 + " '<color=orange>" + input + "</color>' " + LanguageManager.CurrentLanguage.act1.act1_lustFirst_knuckleblaster2;
			}
			if (text.Contains("DASH"))
			{
				return LanguageManager.CurrentLanguage.act1.act1_lustFirst_dashJump;
			}
			return "Unimplemented string";
		}

		private static string Level22(string message, string message2, string input)
		{
			string text = message + message2;
			if (text.Contains("FEEDBACKER"))
			{
				return LanguageManager.CurrentLanguage.act1.act1_lustSecond_feedbacker1 + "\n" + LanguageManager.CurrentLanguage.act1.act1_lustSecond_feedbacker2 + " '<color=orange>" + input + "</color>'.";
			}
			if (text.Contains("RAILCANNON"))
			{
				return LanguageManager.CurrentLanguage.act1.act1_lustSecond_railcannon;
			}
			if (text.Contains("CHECKPOINTS"))
			{
				return LanguageManager.CurrentLanguage.act1.act1_lustSecond_checkPoints;
			}
			return "Unimplemented string";
		}

		private static string Level23(string message, string message2)
		{
			if ((message + message2).Contains("water"))
			{
				return LanguageManager.CurrentLanguage.act1.act1_lustThird_water;
			}
			return "Unimplemented string";
		}

		private static string Level24(string message, string message2)
		{
			if ((message + message2).Contains("OFF THE BEATEN TRACK"))
			{
				return LanguageManager.CurrentLanguage.act1.act1_lustFourth_offTheBeatenTrack;
			}
			return "Unimplemented string";
		}

		private static string Level2Secret(string message, string message2)
		{
			_ = message + message2;
			return "Unimplemented string";
		}

		private static string Level31(string message, string message2)
		{
			if ((message + message2).Contains("YUP, THAT'S A CAVITY"))
			{
				return LanguageManager.CurrentLanguage.act1.act1_greedFirst_cavity;
			}
			return "Unimplemented string";
		}

		private static string Level32(string message, string message2)
		{
			_ = message + message2;
			return "Unimplemented string";
		}

		public static string GetMessage(string message, string message2, string input)
		{
			string currentSceneName = CommonFunctions.GetCurrentSceneName();
			if ((message + message2).Contains("mechanism"))
			{
				return LanguageManager.CurrentLanguage.act1.act1_secret;
			}
			return currentSceneName switch
			{
				"Level 1-1" => Level11(message, message2, input), 
				"Level 1-2" => Level12(message, message2), 
				"Level 1-3" => Level13(message, message2), 
				"Level 1-4" => Level14(message, message2, input), 
				"Level 1-S" => Level1Secret(message, message2), 
				"Level 2-1" => Level21(message, message2, input), 
				"Level 2-2" => Level22(message, message2, input), 
				"Level 2-3" => Level23(message, message2), 
				"Level 2-4" => Level24(message, message2), 
				"Level 2-S" => Level2Secret(message, message2), 
				"Level 3-1" => Level31(message, message2), 
				"Level 3-2" => Level32(message, message2), 
				_ => "Unimplemented string", 
			};
		}

		public static string GetLevelChallenge(string currentLevel)
		{
			return currentLevel switch
			{
				"Level 1-1" => LanguageManager.CurrentLanguage.levelChallenges.challenges_limboFirst, 
				"Level 1-2" => LanguageManager.CurrentLanguage.levelChallenges.challenges_limboSecond, 
				"Level 1-3" => LanguageManager.CurrentLanguage.levelChallenges.challenges_limboThird, 
				"Level 1-4" => LanguageManager.CurrentLanguage.levelChallenges.challenges_limboFourth, 
				"Level 2-1" => LanguageManager.CurrentLanguage.levelChallenges.challenges_lustFirst, 
				"Level 2-2" => LanguageManager.CurrentLanguage.levelChallenges.challenges_lustSecond, 
				"Level 2-3" => LanguageManager.CurrentLanguage.levelChallenges.challenges_lustThird, 
				"Level 2-4" => LanguageManager.CurrentLanguage.levelChallenges.challenges_lustFourth, 
				"Level 3-1" => LanguageManager.CurrentLanguage.levelChallenges.challenges_gluttonyFirst, 
				"Level 3-2" => LanguageManager.CurrentLanguage.levelChallenges.challenges_gluttonySecond, 
				_ => "Unknown challenge description", 
			};
		}

		public static string GetLevelName()
		{
			return CommonFunctions.GetCurrentSceneName() switch
			{
				"Level 1-1" => "1-1: " + LanguageManager.CurrentLanguage.levelNames.levelName_limboFirst, 
				"Level 1-2" => "1-2: " + LanguageManager.CurrentLanguage.levelNames.levelName_limboSecond, 
				"Level 1-3" => "1-3: " + LanguageManager.CurrentLanguage.levelNames.levelName_limboThird, 
				"Level 1-4" => "1-4: " + LanguageManager.CurrentLanguage.levelNames.levelName_limboFourth, 
				"Level 1-S" => "1-S: " + LanguageManager.CurrentLanguage.levelNames.levelName_limboSecret, 
				"Level 2-1" => "2-1: " + LanguageManager.CurrentLanguage.levelNames.levelName_lustFirst, 
				"Level 2-2" => "2-2: " + LanguageManager.CurrentLanguage.levelNames.levelName_lustSecond, 
				"Level 2-3" => "2-3: " + LanguageManager.CurrentLanguage.levelNames.levelName_lustThird, 
				"Level 2-4" => "2-4: " + LanguageManager.CurrentLanguage.levelNames.levelName_lustFourth, 
				"Level 2-S" => "2-S: " + LanguageManager.CurrentLanguage.levelNames.levelName_lustSecret, 
				"Level 3-1" => "3-1: " + LanguageManager.CurrentLanguage.levelNames.levelName_gluttonyFirst, 
				"Level 3-2" => "3-2: " + LanguageManager.CurrentLanguage.levelNames.levelName_gluttonySecond, 
				_ => "Unknown level name", 
			};
		}
	}
	public static class Act1Vn
	{
		public static void PatchPrompts(ref GameObject canvasObj)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			GameObject gameObjectChild = CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(canvasObj, "PowerUpVignette"), "Panel"), "Aspect Ratio Mask");
			GameObject gameObjectChild2 = CommonFunctions.GetGameObjectChild(gameObjectChild, "Fallen");
			List<GameObject> list = new List<GameObject>();
			foreach (Transform item in gameObjectChild2.transform)
			{
				Transform val = item;
				if (((Object)((Component)val).gameObject).name == "Choices Box")
				{
					list.Add(((Component)val).gameObject);
				}
			}
			GameObject parent = list[0];
			GameObject parent2 = list[1];
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(parent, "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_fallenPromptFirst1;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(parent, "Button (B)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_fallenPromptFirst2;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(parent, "Button (C)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_fallenPromptFirst3;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(parent2, "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_fallenPromptSecond1;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(parent2, "Button (B)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_fallenPromptSecond2;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(parent2, "Button (C)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_fallenPromptSecond3;
			GameObject gameObjectChild3 = CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "Middle"), "Choices Box (1)");
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild3, "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_middlePrompt1;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild3, "Button (B)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_middlePrompt2;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild3, "Button (C)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_middlePrompt3;
			GameObject gameObjectChild4 = CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "Middle"), "Choices Box (2)");
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild4, "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_middlePromptSecondRecklessness;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild4, "Button (B)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_middlePromptSecondWaiting;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild4, "Button (C)"), "Text")).text = "...Pourquoi sommes-nous ici?";
			GameObject gameObjectChild5 = CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "Recklessness"), "Choices Box");
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild5, "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_recklessnessPrompt1;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild5, "Button (B)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_recklessnessPrompt2;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "Recklessness"), "Choices Box (1)"), "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_recklessnessPrompt3;
			GameObject gameObjectChild6 = CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "Waiting"), "Choices Box");
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild6, "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_waitingPromptFirst1;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild6, "Button (B)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_waitingPromptFirst2;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "Waiting"), "Choices Box (1)"), "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_waitingPromptThird;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "Nihilism"), "Choices Box (2)"), "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilismPrompt1;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "Nihilism"), "Choices Box (3)"), "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilismPrompt2;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "Nihilism"), "Choices Box (4)"), "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilismPrompt3;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "Nihilism"), "Choices Box (5)"), "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilismPrompt4;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "Nihilism"), "Choices Box (6)"), "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilismPrompt5;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "Nihilism"), "Choices Box (7)"), "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilismPrompt6;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "Nihilism"), "Choices Box (8)"), "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilismPrompt7;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "Nihilism"), "Choices Box (9)"), "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilismPrompt8;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "Nihilism"), "Choices Box (10)"), "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilismPrompt9;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "Nihilism"), "Choices Box (11)"), "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilismPrompt10;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "Nihilism"), "Choices Box (12)"), "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilismPrompt11;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "Nihilism"), "Choices Box (13)"), "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilismPrompt12;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "Nihilism"), "Choices Box (14)"), "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilismPrompt13;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "Nihilism"), "Choices Box (16)"), "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilismPrompt14;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "Nihilism"), "Choices Box (17)"), "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilismPrompt15;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "Nihilism"), "Choices Box (18)"), "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilismPrompt16;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "Nihilism"), "Choices Box (19)"), "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilismPrompt17;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "Nihilism"), "Choices Box (20)"), "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilismPrompt18;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "Nihilism"), "Choices Box (21)"), "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilismPrompt19;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "Nihilism"), "Choices Box (22)"), "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilismPrompt20;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "Nihilism"), "Choices Box (25)"), "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilismPrompt21;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "Nihilism"), "Choices Box (23)"), "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilismPrompt22;
			CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "Nihilism"), "Choices Box (24)"), "Button (A)"), "Text")).text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilismPrompt23;
			GameObject gameObjectChild7 = CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "Conclusion"), "Choices Box (2)");
			Text textfromGameObject = CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild7, "Button (A)"), "Text"));
			Text textfromGameObject2 = CommonFunctions.GetTextfromGameObject(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild7, "Button (B)"), "Text"));
			textfromGameObject.text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_conclusionPrompt1;
			textfromGameObject2.text = LanguageManager.CurrentLanguage.visualnovel.visualnovel_conclusionPrompt2;
		}

		public static string GetNextString(string inputString)
		{
			if (inputString.Contains("Heavy steps"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_introFirst1 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_introFirst2 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_introFirst3 + "▼\n\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_introFirst4 + "▼\n\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_introFirst5 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_introFirst6 + "▼\n\n\n\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_introFirst7 + "▼\n";
			}
			if (inputString.Contains("I bit down"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_introSecond1 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_introSecond2 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_introSecond3 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_introSecond4 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_introSecond5 + "▼}\n\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_introSecond6 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_introSecond7 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_introSecond8 + "▼";
			}
			if (inputString.Contains("Oof ow"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_fallen1 + "▼";
			}
			if (inputString.Contains("I'm just someone"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_fallenResponseFirst + "▼";
			}
			if (inputString.Contains("Well I just got"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_fallenResponseSecond + "▼";
			}
			if (inputString.Contains("Oh great"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_fallenResponseThird1 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_fallenResponseThird2 + "▼";
			}
			if (inputString.Contains("Alright, alright"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_fallenResponseFourth + "▼";
			}
			if (inputString.Contains("UGH?"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_fallenResponseFifth + "▼";
			}
			if (inputString.Contains("*Sigh*"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_kindFirst1 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_kindFirst2 + "▼";
			}
			if (inputString.Contains("Though, by the"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_kindSecond + "▼";
			}
			if (inputString.Contains("So how about you"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_kindThird + "▼";
			}
			if (inputString.Contains("Listen up,"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_rudeFirst1 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_rudeFirst2 + "▼";
			}
			if (inputString.Contains("By the looks of it"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_rudeSecond + "▼";
			}
			if (inputString.Contains("So I'll forgive you"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_rudeThird + "▼";
			}
			if (inputString.Contains("UGH!"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_middleResponseFirst1 + "▼";
			}
			if (inputString.Contains("Though in retrospect"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_middleResponseFirst2 + "▼";
			}
			if (inputString.Contains("Oh well,"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_middleResponseFirst3 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_middleResponseFirst4 + "▼\n";
			}
			if (inputString.Contains("I'm Mirage."))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_middleResponseFirst5 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_middleResponseFirst6 + "▼";
			}
			if (inputString.Contains("WHAT?"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_middleResponseSecond1 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_middleResponseSecond2 + "▼";
			}
			if (inputString.Contains("If you DON'T"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_middleResponseSecond3 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_middleResponseSecond4 + "▼";
			}
			if (inputString.Contains("Bullshit!"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_middleResponseThird1 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_middleResponseThird2 + "▼";
			}
			if (inputString.Contains("Though considering"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_middleResponseThird3 + "▼";
			}
			if (inputString.Contains("Wandering around like"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_waitingFirst + "▼";
			}
			if (inputString.Contains("Since we were"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_waitingSecond + "▼";
			}
			if (inputString.Contains("Therefore,"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_waitingThird1 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_waitingThird2 + "▼";
			}
			if (inputString.Contains("Suit yourself"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_waitingResponseFirst1 + "▼\n";
			}
			if (inputString.Contains("Couldn't care less"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_waitingResponseFirst2 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_waitingResponseFirst3 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_waitingResponseFirst4 + "▼";
			}
			if (inputString.Contains("Hah!"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_waitingResponseSecond1 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_waitingResponseSecond2 + "▼";
			}
			if (inputString.Contains("Because nothing"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_waitingResponseThird1 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_waitingResponseThird2 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_waitingResponseThird3 + "▼";
			}
			if (inputString.Contains("Yeah?"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_recklessnessFirst + "▼";
			}
			if (inputString.Contains("But yes,"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_recklessnessSecond1 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_recklessnessSecond2 + "▼";
			}
			if (inputString.Contains("What's the point of making"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_recklessnessResponseFirst1 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_recklessnessResponseFirst2 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_recklessnessResponseFirst3 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_recklessnessResponseFirst4 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_recklessnessResponseFirst5 + "▼\n";
			}
			if (inputString.Contains("Don't flatter yourself"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_recklessnessResponseSecond1 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_recklessnessResponseSecond2 + "▼";
			}
			if (inputString.Contains("Everything."))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_recklessnessResponseThird + "▼";
			}
			if (inputString.Contains("I mean really"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism1 + "▼";
			}
			if (inputString.Contains("The human mind,"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism2 + "▼";
			}
			if (inputString.Contains("We can only ever"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism3 + "▼";
			}
			if (inputString.Contains("Death is"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism4 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism5 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism6 + "▼";
			}
			if (inputString.Contains("It doesn't matter"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism7 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism8 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism9 + "▼";
			}
			if (inputString.Contains("Human intelligence"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism10 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism11 + "▼";
			}
			if (inputString.Contains("Our intelligence"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism12 + "▼";
			}
			if (inputString.Contains("It's an over-extension"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism13 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism14 + "▼\n";
			}
			if (inputString.Contains("Much like the Irish"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism15 + "▼";
			}
			if (inputString.Contains("The human mind is an"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism16 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism17 + "▼\n";
			}
			if (inputString.Contains("Existential dread"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism18 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism19 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism20 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism21 + "▼";
			}
			if (inputString.Contains("We are unable"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism22 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism23 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism24 + "▼";
			}
			if (inputString.Contains("We create distractions"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism25 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism26 + "▼";
			}
			if (inputString.Contains("We sublimate it"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism27 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism28 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism29 + "▼";
			}
			if (inputString.Contains("But these ways"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism30 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism31 + "▼";
			}
			if (inputString.Contains("In the end"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism32 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism33 + "▼";
			}
			if (inputString.Contains("Huh?"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism34 + "▼";
			}
			if (inputString.Contains("How could it not be?"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism35 + "▼";
			}
			if (inputString.Contains("But still"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism36 + "▼";
			}
			if (inputString.Contains("I do understand"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism37 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism38 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism39 + "▼";
			}
			if (inputString.Contains("I see."))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism40 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism41 + "▼";
			}
			if (inputString.Contains("I understand it logically"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism42 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_nihilism43 + "▼";
			}
			if (inputString.Contains("Well I'll be damned"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_conclusion1 + "▼";
			}
			if (inputString.Contains("Guess you got a good"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_conclusion2 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_conclusion3 + "▼";
			}
			if (inputString.Contains("Man..."))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_conclusion4 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_conclusion5 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_conclusion6 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_conclusion7 + "▼";
			}
			if (inputString.Contains("Thank you."))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_conclusion8 + "▼\n";
			}
			if (inputString.Contains("You've given me a lot"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_conclusion9 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_conclusion10 + "▼\n";
			}
			if (inputString.Contains("Say..."))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_conclusion11 + "▼";
			}
			if (inputString.Contains("Oh, you sneaky"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_conclusionResponseFirst1 + "▼";
			}
			if (inputString.Contains("But alright"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_conclusionResponseFirst2 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_conclusionResponseFirst3 + "▼";
			}
			if (inputString.Contains("Alright, suit yourself"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_conclusionResponseSecond1 + "▼\n" + LanguageManager.CurrentLanguage.visualnovel.visualnovel_conclusionResponseSecond2 + "▼";
			}
			if (inputString.Contains("See you around"))
			{
				return LanguageManager.CurrentLanguage.visualnovel.visualnovel_conclusionResponseSecond3 + "▼";
			}
			return inputString;
		}
	}
	public static class Act2
	{
		private static void PatchHellmap(ref GameObject canvasObj)
		{
			GameObject gameObjectChild = CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(canvasObj, "Hellmap"), "Hellmap Act 2");
			((TMP_Text)CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(gameObjectChild, "Text"))).text = LanguageManager.CurrentLanguage.misc.hellmap_greed;
			((TMP_Text)CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(gameObjectChild, "Text (1)"))).text = LanguageManager.CurrentLanguage.misc.hellmap_wrath;
			((TMP_Text)CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(gameObjectChild, "Text (2)"))).text = LanguageManager.CurrentLanguage.misc.hellmap_heresy;
		}

		public static void PatchAct2(ref GameObject canvasObj)
		{
			string currentSceneName = CommonFunctions.GetCurrentSceneName();
			string levelName = Act2Strings.GetLevelName();
			string levelChallenge = Act2Strings.GetLevelChallenge(currentSceneName);
			CommonFunctions.PatchResultsScreen(levelName, levelChallenge);
			PatchHellmap(ref canvasObj);
		}
	}
	public static class Act2Strings
	{
		private static string _previousMessage = "";

		private static string Level41(string message, string message2)
		{
			if ((message + message2).Contains("An eye opens."))
			{
				return LanguageManager.CurrentLanguage.act2.act2_greed_secretDoor;
			}
			return "Unimplemented string";
		}

		private static string Level42(string message, string message2)
		{
			string text = message + message2;
			if (text.Contains("BLEED"))
			{
				return LanguageManager.CurrentLanguage.act2.act2_greedSecond_sand;
			}
			if (text.Contains("A door opens."))
			{
				return LanguageManager.CurrentLanguage.act3.act3_violenceFirst_doorOpens;
			}
			return "Unimplemented string";
		}

		private static string Level43(string message, string message2)
		{
			string text = message + message2;
			if (text.Contains("FILTH"))
			{
				return LanguageManager.CurrentLanguage.act2.act2_greedThird_wallClip;
			}
			if (text.Contains("wicked"))
			{
				return LanguageManager.CurrentLanguage.act2.act2_greedThird_troll1;
			}
			if (text.Contains("kidding"))
			{
				return LanguageManager.CurrentLanguage.act2.act2_greedThird_troll2;
			}
			if (text.Contains("TOMB"))
			{
				return LanguageManager.CurrentLanguage.act2.act2_greedThird_tombOfKings;
			}
			return "Unimplemented string";
		}

		private static string Level44(string message, string message2, string input)
		{
			string text = message + message2;
			if (text == "")
			{
				return _previousMessage;
			}
			if (message.Contains("versions"))
			{
				return LanguageManager.CurrentLanguage.misc.hud_alternateVersion;
			}
			if (text.Contains("ALTERNATE NAILGUN"))
			{
				return LanguageManager.CurrentLanguage.act2.act2_greedFourth_alternateNailgun;
			}
			if (text.Contains("You're"))
			{
				return LanguageManager.CurrentLanguage.act2.act2_greedFourth_v2;
			}
			if (text.Contains("Hold"))
			{
				_previousMessage = LanguageManager.CurrentLanguage.act2.act2_greedFourth_whiplash1 + " <color=orange>" + input + "</color> " + LanguageManager.CurrentLanguage.act2.act2_greedFourth_whiplash2;
				return LanguageManager.CurrentLanguage.act2.act2_greedFourth_whiplash1 + " <color=orange>" + input + "</color> " + LanguageManager.CurrentLanguage.act2.act2_greedFourth_whiplash2;
			}
			if (text.Contains("HEAVY"))
			{
				_previousMessage = LanguageManager.CurrentLanguage.act2.act2_greedFourth_whiplash3;
				return LanguageManager.CurrentLanguage.act2.act2_greedFourth_whiplash3;
			}
			return "Unimplemented string";
		}

		private static string Level4Secret(string message, string message2, string input)
		{
			if ((message + message2).Contains("HOLD"))
			{
				return LanguageManager.CurrentLanguage.act2.act2_greedSecret_holdToJump1 + " [<color=orange>" + input + "</color>]" + LanguageManager.CurrentLanguage.act2.act2_greedSecret_holdToJump2;
			}
			return "Unimplemented string";
		}

		private static string Level51(string message, string message2)
		{
			string text = message + message2;
			if (text.Contains("HOOKPOINT"))
			{
				return LanguageManager.CurrentLanguage.act2.act2_wrathFirst_slingshot;
			}
			if (text.Contains("SENTRIES"))
			{
				return LanguageManager.CurrentLanguage.act2.act2_wrathFirst_sentry;
			}
			if (text.Contains("drained"))
			{
				return LanguageManager.CurrentLanguage.act2.act2_wrathFirst_waterDrained;
			}
			if (text.Contains("HARD DAMAGE"))
			{
				return LanguageManager.CurrentLanguage.act2.act2_wrathFirst_whiplashHardDamage1 + "\n" + LanguageManager.CurrentLanguage.act2.act2_wrathFirst_whiplashHardDamage2;
			}
			if (text.Contains("A door opens."))
			{
				return LanguageManager.CurrentLanguage.act3.act3_violenceFirst_doorOpens;
			}
			return "Unimplemented string";
		}

		private static string Level52(string message, string message2)
		{
			string text = message + message2;
			if (text.Contains("JAKITO"))
			{
				return LanguageManager.CurrentLanguage.act2.act2_wrathSecond_jakito1;
			}
			if (text.Contains("THANK"))
			{
				return LanguageManager.CurrentLanguage.act2.act2_wrathSecond_jakito2;
			}
			if (text.Contains("NO"))
			{
				return LanguageManager.CurrentLanguage.act2.act2_wrathSecond_jakito3;
			}
			if (text.Contains("Hark"))
			{
				return LanguageManager.CurrentLanguage.act2.act2_wrathSecond_neptune;
			}
			if (text.Contains("IDOL"))
			{
				return LanguageManager.CurrentLanguage.act2.act2_wrathSecond_idol;
			}
			return "Unimplemented string";
		}

		private static string Level53(string message, string message2)
		{
			string text = message + message2;
			if (text.Contains("Indirect"))
			{
				return LanguageManager.CurrentLanguage.act2.act2_wrathThird_rocketLauncher;
			}
			if (text.Contains("FALLING"))
			{
				return LanguageManager.CurrentLanguage.act2.act2_wrathThird_rocketLauncherMidair;
			}
			if (text.Contains("Soldiers"))
			{
				return LanguageManager.CurrentLanguage.act2.act2_wrathThird_soldierBlock;
			}
			if (text.Contains("Hank"))
			{
				return LanguageManager.CurrentLanguage.act2.act2_wrathThird_hank;
			}
			return "Unimplemented string";
		}

		private static string Level54(string message, string message2)
		{
			_ = message + message2;
			return "Unimplemented string";
		}

		private static string Level5Secret(string message)
		{
			if (message.Contains("living"))
			{
				return LanguageManager.CurrentLanguage.fishing.fish_living;
			}
			if (message.Contains("Too small"))
			{
				return LanguageManager.CurrentLanguage.fishing.fish_tooSmall;
			}
			if (message.Contains("This bait"))
			{
				return LanguageManager.CurrentLanguage.fishing.fish_baitNotWork;
			}
			if (message.Contains("A fish took"))
			{
				return LanguageManager.CurrentLanguage.fishing.fish_baitTaken;
			}
			if (message.Contains("Fishing interrupted"))
			{
				return LanguageManager.CurrentLanguage.fishing.fish_interrupted;
			}
			if (message.Contains("Cooking failed"))
			{
				return LanguageManager.CurrentLanguage.fishing.fish_cookingFailed;
			}
			if (message.Contains("Nothing seems"))
			{
				return LanguageManager.CurrentLanguage.fishing.fish_noFishBiting;
			}
			return "Unimplemented string";
		}

		private static string Level61(string message, string message2)
		{
			if ((message + message2).Contains("A R M B O Y"))
			{
				return LanguageManager.CurrentLanguage.act2.act2_heresyFirst_armboy;
			}
			return "Unimplemented string";
		}

		private static string Level62(string message, string message2)
		{
			_ = message + message2;
			return "Unimplemented string";
		}

		public static string GetMessage(string message, string message2, string input)
		{
			string currentSceneName = CommonFunctions.GetCurrentSceneName();
			_ = message + message2;
			return currentSceneName switch
			{
				"Level 4-1" => Level41(message, message2), 
				"Level 4-2" => Level42(message, message2), 
				"Level 4-3" => Level43(message, message2), 
				"Level 4-4" => Level44(message, message2, input), 
				"Level 4-S" => Level4Secret(message, message2, input), 
				"Level 5-1" => Level51(message, message2), 
				"Level 5-2" => Level52(message, message2), 
				"Level 5-3" => Level53(message, message2), 
				"Level 5-4" => Level54(message, message2), 
				"Level 5-S" => Level5Secret(message), 
				"Level 6-1" => Level61(message, message2), 
				"Level 6-2" => Level62(message, message2), 
				_ => "Unimplemented string", 
			};
		}

		public static string GetLevelChallenge(string currentLevel)
		{
			return currentLevel switch
			{
				"Level 4-1" => LanguageManager.CurrentLanguage.levelChallenges.challenges_greedFirst, 
				"Level 4-2" => LanguageManager.CurrentLanguage.levelChallenges.challenges_greedSecond, 
				"Level 4-3" => LanguageManager.CurrentLanguage.levelChallenges.challenges_greedThird, 
				"Level 4-4" => LanguageManager.CurrentLanguage.levelChallenges.challenges_greedFourth, 
				"Level 5-1" => LanguageManager.CurrentLanguage.levelChallenges.challenges_wrathFirst, 
				"Level 5-2" => LanguageManager.CurrentLanguage.levelChallenges.challenges_wrathSecond, 
				"Level 5-3" => LanguageManager.CurrentLanguage.levelChallenges.challenges_wrathThird, 
				"Level 5-4" => LanguageManager.CurrentLanguage.levelChallenges.challenges_wrathFourth, 
				"Level 6-1" => LanguageManager.CurrentLanguage.levelChallenges.challenges_heresyFirst, 
				"Level 6-2" => LanguageManager.CurrentLanguage.levelChallenges.challenges_heresySecond, 
				_ => "Unknown challenge description", 
			};
		}

		public static string GetLevelName()
		{
			return CommonFunctions.GetCurrentSceneName() switch
			{
				"Level 4-1" => "4-1: " + LanguageManager.CurrentLanguage.levelNames.levelName_greedFirst, 
				"Level 4-2" => "4-2: " + LanguageManager.CurrentLanguage.levelNames.levelName_greedSecond, 
				"Level 4-3" => "4-3: " + LanguageManager.CurrentLanguage.levelNames.levelName_greedThird, 
				"Level 4-4" => "4-4: " + LanguageManager.CurrentLanguage.levelNames.levelName_greedFourth, 
				"Level 5-1" => "5-1: " + LanguageManager.CurrentLanguage.levelNames.levelName_wrathFirst, 
				"Level 5-2" => "5-2: " + LanguageManager.CurrentLanguage.levelNames.levelName_wrathSecond, 
				"Level 5-3" => "5-3: " + LanguageManager.CurrentLanguage.levelNames.levelName_wrathThird, 
				"Level 5-4" => "5-4: " + LanguageManager.CurrentLanguage.levelNames.levelName_wrathFourth, 
				"Level 6-1" => "6-1: " + LanguageManager.CurrentLanguage.levelNames.levelName_heresyFirst, 
				"Level 6-2" => "6-2: " + LanguageManager.CurrentLanguage.levelNames.levelName_heresySecond, 
				_ => "Unknown level name", 
			};
		}
	}
	public static class Act3
	{
		private static void PatchHellmap(ref GameObject canvasObj)
		{
			GameObject gameObjectChild = CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(canvasObj, "Hellmap"), "Hellmap Act 3");
			((TMP_Text)CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(gameObjectChild, "Text"))).text = LanguageManager.CurrentLanguage.misc.hellmap_violence;
			((TMP_Text)CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(gameObjectChild, "Text (1)"))).text = LanguageManager.CurrentLanguage.misc.hellmap_fraud;
			((TMP_Text)CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(gameObjectChild, "Text (2)"))).text = LanguageManager.CurrentLanguage.misc.hellmap_treachery;
		}

		public static void PatchAct3(ref GameObject canvasObj)
		{
			string currentSceneName = CommonFunctions.GetCurrentSceneName();
			string levelName = Act3Strings.GetLevelName();
			string levelChallenge = Act3Strings.GetLevelChallenge(currentSceneName);
			CommonFunctions.PatchResultsScreen(levelName, levelChallenge);
			PatchHellmap(ref canvasObj);
			if (currentSceneName.Contains("7-2"))
			{
				GameObject gameObjectChild = CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetInactiveRootObject("Other Interiors"), "9 - Tram Station"), "9 Stuff"), "9A"), "InteractiveScreenWithStand"), "InteractiveScreen"), "Canvas"), "Background");
				TextMeshProUGUI textMeshProUGUI = CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "A"), "Opened"), "Text (TMP)"));
				TextMeshProUGUI textMeshProUGUI2 = CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "A"), "Closed"), "Text (TMP)"));
				TextMeshProUGUI textMeshProUGUI3 = CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "B"), "Opened"), "Text (TMP)"));
				TextMeshProUGUI textMeshProUGUI4 = CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "B"), "Closed"), "Text (TMP)"));
				TextMeshProUGUI textMeshProUGUI5 = CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "C"), "Opened"), "Text (TMP)"));
				TextMeshProUGUI textMeshProUGUI6 = CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "C"), "Closed"), "Text (TMP)"));
				TextMeshProUGUI textMeshProUGUI7 = CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "D"), "Opened"), "Text (TMP)"));
				TextMeshProUGUI textMeshProUGUI8 = CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild, "D"), "Closed"), "Text (TMP)"));
				((TMP_Text)textMeshProUGUI).text = LanguageManager.CurrentLanguage.act3.act3_violenceSecond_gateControlOpen;
				((TMP_Text)textMeshProUGUI2).text = LanguageManager.CurrentLanguage.act3.act3_violenceSecond_gateControlClosed;
				((TMP_Text)textMeshProUGUI3).text = LanguageManager.CurrentLanguage.act3.act3_violenceSecond_gateControlOpen;
				((TMP_Text)textMeshProUGUI4).text = LanguageManager.CurrentLanguage.act3.act3_violenceSecond_gateControlClosed;
				((TMP_Text)textMeshProUGUI5).text = LanguageManager.CurrentLanguage.act3.act3_violenceSecond_gateControlOpen;
				((TMP_Text)textMeshProUGUI6).text = LanguageManager.CurrentLanguage.act3.act3_violenceSecond_gateControlClosed;
				((TMP_Text)textMeshProUGUI7).text = LanguageManager.CurrentLanguage.act3.act3_violenceSecond_gateControlOpen;
				((TMP_Text)textMeshProUGUI8).text = LanguageManager.CurrentLanguage.act3.act3_violenceSecond_gateControlClosed;
				GameObject gameObjectChild2 = CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetInactiveRootObject("Outdoors"), "10 - Ambush Station"), "10 Nonstuff"), "InteractiveScreenWithStand"), "InteractiveScreen"), "Canvas"), "Background");
				TextMeshProUGUI textMeshProUGUI9 = CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(gameObjectChild2, "Text (TMP) (1)"));
				TextMeshProUGUI textMeshProUGUI10 = CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild2, "Button (Open)"), "Text (TMP)"));
				TextMeshProUGUI textMeshProUGUI11 = CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild2, "Button (Closed)"), "Text (TMP)"));
				((TMP_Text)textMeshProUGUI9).text = LanguageManager.CurrentLanguage.act3.act3_violenceSecond_cartGateControlTitle;
				((TMP_Text)textMeshProUGUI10).text = LanguageManager.CurrentLanguage.act3.act3_violenceSecond_cartGateControlOpen;
				((TMP_Text)textMeshProUGUI11).text = LanguageManager.CurrentLanguage.act3.act3_violenceSecond_cartGateControlClosed;
				GameObject gameObjectChild3 = CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetInactiveRootObject("Outdoors"), "11 - Bomb Station"), "11 Nonstuff"), "Bomb Mechanisms"), "InteractiveScreenWithStand"), "InteractiveScreen"), "Canvas");
				TextMeshProUGUI textMeshProUGUI12 = CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(gameObjectChild3, "Text (TMP)"));
				TextMeshProUGUI[] componentsInChildren = CommonFunctions.GetGameObjectChild(gameObjectChild3, "UsableButtons").GetComponentsInChildren<TextMeshProUGUI>(true);
				TextMeshProUGUI textMeshProUGUI13 = CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild3, "UsableButtons"), "Error"));
				TextMeshProUGUI textMeshProUGUI14 = CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(gameObjectChild3, "Done"));
				((TMP_Text)textMeshProUGUI12).text = LanguageManager.CurrentLanguage.act3.act3_violenceSecond_payloadControlTitle;
				TextMeshProUGUI[] array = componentsInChildren;
				foreach (TextMeshProUGUI val in array)
				{
					if (((TMP_Text)val).text.Contains("LOWER"))
					{
						((TMP_Text)val).text = LanguageManager.CurrentLanguage.act3.act3_violenceSecond_payloadControlLower;
					}
				}
				((TMP_Text)textMeshProUGUI13).text = LanguageManager.CurrentLanguage.act3.act3_violenceSecond_payloadControlError1 + "<size=12>\n" + LanguageManager.CurrentLanguage.act3.act3_violenceSecond_payloadControlError2;
				((TMP_Text)textMeshProUGUI14).text = LanguageManager.CurrentLanguage.act3.act3_violenceSecond_payloadControlHell;
			}
			else if (currentSceneName.Contains("7-3"))
			{
				GameObject gameObjectChild4 = CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetInactiveRootObject("Outdoors Areas"), "8 - Upper Garden Battlefield"), "8 Stuff"), "Destructible Tunnel"), "InteractiveScreenWithStand"), "InteractiveScreen"), "Canvas"), "Background");
				TextMeshProUGUI textMeshProUGUI15 = CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild4, "PreActivation"), "Text (TMP) (1)"));
				TextMeshProUGUI textMeshProUGUI16 = CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild4, "PreActivation"), "InteractiveScreenButton"), "Text (TMP)"));
				TextMeshProUGUI textMeshProUGUI17 = CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(gameObjectChild4, "PostActivation"), "Text (TMP) (1)"));
				((TMP_Text)textMeshProUGUI15).text = LanguageManager.CurrentLanguage.act3.act3_violenceThird_becomeMarked;
				((TMP_Text)textMeshProUGUI16).text = LanguageManager.CurrentLanguage.act3.act3_violenceThird_becomeMarkedButton;
				((TMP_Text)textMeshProUGUI17).text = LanguageManager.CurrentLanguage.act3.act3_violenceThird_starOfTheShow;
			}
			else if (currentSceneName.Contains("7-4"))
			{
				((TMP_Text)CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(canvasObj, "Warning"), "Text (TMP)"))).text = LanguageManager.CurrentLanguage.act3.act3_violenceFourth_floodingWarning;
				((TMP_Text)CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(canvasObj, "Countdown"), "Text (TMP)"))).text = LanguageManager.CurrentLanguage.act3.act3_violenceFourth_countdownTitle;
			}
			else if (currentSceneName.Contains("8-2"))
			{
				GameObject inactiveRootObject = CommonFunctions.GetInactiveRootObject("4 - Hub");
				if ((Object)(object)inactiveRootObject == (Object)null)
				{
					inactiveRootObject = CommonFunctions.GetInactiveRootObject("Hub");
				}
				if ((Object)(object)inactiveRootObject != (Object)null)
				{
					TextMeshProUGUI[] componentsInChildren2 = inactiveRootObject.GetComponentsInChildren<TextMeshProUGUI>(true);
					string act3_fraudSecond_outOfOrder = LanguageManager.CurrentLanguage.act3.act3_fraudSecond_outOfOrder;
					string act3_fraudSecond_errorResetPower = LanguageManager.CurrentLanguage.act3.act3_fraudSecond_errorResetPower;
					bool flag = string.IsNullOrEmpty(act3_fraudSecond_outOfOrder);
					bool flag2 = string.IsNullOrEmpty(act3_fraudSecond_errorResetPower);
					if (flag)
					{
						Logging.Warn("[Act3] Translation for 'act3_fraudSecond_outOfOrder' is missing or empty. Will keep original text.");
					}
					if (flag2)
					{
						Logging.Warn("[Act3] Translation for 'act3_fraudSecond_errorResetPower' is missing or empty. Will keep original text.");
					}
					TextMeshProUGUI[] array = componentsInChildren2;
					foreach (TextMeshProUGUI val2 in array)
					{
						string text = ((TMP_Text)val2).text;
						string text2 = Regex.Replace(Regex.Replace(text, "<.*?>", ""), "\\s+", " ").Trim().ToUpperInvariant();
						if (text2.Contains("ERROR") || text2.Contains("RESET") || text2.Contains("POWER") || text2.Contains("OUT") || text2.Contains("ORDER"))
						{
							Logging.Info("[Act3] Text candidate: original='" + text + "', normalized='" + text2 + "'");
						}
						if (text2 == "OUT OF ORDER" && !flag)
						{
							Logging.Info("[Act3] Replacing OUT OF ORDER with translation");
							((TMP_Text)val2).text = act3_fraudSecond_outOfOrder;
						}
						else if (text2 == "ERROR RESET POWER TO OPEN" && !flag2)
						{
							Logging.Info("[Act3] Replacing ERROR RESET POWER TO OPEN with translation");
							((TMP_Text)val2).text = act3_fraudSecond_errorResetPower;
						}
					}
				}
				else
				{
					Logging.Warn("[Act3] Hub not found");
				}
			}
			else if (currentSceneName.Contains("8-3"))
			{
				string[] obj = new string[2] { "Pre-Space/Rooms/10B - Night Street/10B Nonstuff/Office/ElevatorSet (1)/ElevatorStop/InteractiveScreen/Canvas/Background/Text (TMP)", "Pre-Space/Rooms/10B - Night Street/10B Nonstuff/Office/ElevatorSet (1)/ElevatorStop (1)/InteractiveScreen/Canvas/Background/Text (TMP)" };
				string act3_fraudSecond_outOfOrder2 = LanguageManager.CurrentLanguage.act3.act3_fraudSecond_outOfOrder;
				bool flag3 = string.IsNullOrEmpty(act3_fraudSecond_outOfOrder2);
				if (flag3)
				{
					Logging.Warn("[Act3] Translation for 'act3_fraudSecond_outOfOrder' is missing or empty. Will keep original text.");
				}
				string[] array2 = obj;
				foreach (string text3 in array2)
				{
					GameObject @object = CommonFunctions.GetObject(text3);
					if ((Object)(object)@object != (Object)null)
					{
						TextMeshProUGUI textMeshProUGUI18 = CommonFunctions.GetTextMeshProUGUI(@object);
						if ((Object)(object)textMeshProUGUI18 != (Object)null)
						{
							if (!flag3)
							{
								((TMP_Text)textMeshProUGUI18).text = act3_fraudSecond_outOfOrder2;
								Logging.Info("[Act3] Replaced OUT OF ORDER text on 8-3 screen at path: " + text3);
							}
						}
						else
						{
							Logging.Warn("[Act3] Text (TMP) component not found on screen object at path: " + text3);
						}
					}
					else
					{
						Logging.Warn("[Act3] Screen object not found at path: " + text3);
					}
				}
			}
			else
			{
				if (!currentSceneName.Contains("8-4"))
				{
					return;
				}
				TextMeshProUGUI textMeshProUGUI19 = CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(CommonFunctions.GetGameObjectChild(canvasObj, "HeightMarkerParent"), "HeightMarker"), "Title"));
				string act3_fraudFourth_heightMarkerTitle = LanguageManager.CurrentLanguage.act3.act3_fraudFourth_heightMarkerTitle;
				((TMP_Text)textMeshProUGUI19).text = CommonFunctions.MakeVertical(act3_fraudFourth_heightMarkerTitle);
				((TMP_Text)textMeshProUGUI19).ForceMeshUpdate(false, false);
				GameObject inactiveRootObject2 = CommonFunctions.GetInactiveRootObject("The Intro");
				if (!((Object)(object)inactiveRootObject2 != (Object)null))
				{
					return;
				}
				GameObject gameObjectChild5 = CommonFunctions.GetGameObjectChild(inactiveRootObject2, "3 - Upper Intro");
				if (!((Object)(object)gameObjectChild5 != (Object)null))
				{
					return;
				}
				GameObject gameObjectChild6 = CommonFunctions.GetGameObjectChild(gameObjectChild5, "ElevatorSet");
				if (!((Object)(object)gameObjectChild6 != (Object)null))
				{
					return;
				}
				GameObject gameObjectChild7 = CommonFunctions.GetGameObjectChild(gameObjectChild6, "Elevator");
				if (!((Object)(object)gameObjectChild7 != (Object)null))
				{
					return;
				}
				GameObject gameObjectChild8 = CommonFunctions.GetGameObjectChild(gameObjectChild7, "InteractiveScreen");
				if (!((Object)(object)gameObjectChild8 != (Object)null))
				{
					return;
				}
				GameObject gameObjectChild9 = CommonFunctions.GetGameObjectChild(gameObjectChild8, "Canvas");
				if (!((Object)(object)gameObjectChild9 != (Object)null))
				{
					return;
				}
				GameObject gameObjectChild10 = CommonFunctions.GetGameObjectChild(gameObjectChild9, "Background");
				if (!((Object)(object)gameObjectChild10 != (Object)null))
				{
					return;
				}
				GameObject gameObjectChild11 = CommonFunctions.GetGameObjectChild(gameObjectChild10, "1 (Nope)");
				if (!((Object)(object)gameObjectChild11 != (Object)null))
				{
					return;
				}
				TextMeshProUGUI textMeshProUGUI20 = CommonFunctions.GetTextMeshProUGUI(CommonFunctions.GetGameObjectChild(gameObjectChild11, "Text (TMP)"));
				if ((Object)(object)textMeshProUGUI20 != (Object)null)
				{
					string act3_fraudFourth_nope = LanguageManager.CurrentLanguage.act3.act3_fraudFourth_nope;
					if (!string.IsNullOrEmpty(act3_fraudFourth_nope))
					{
						((TMP_Text)textMeshProUGUI20).text = act3_fraudFourth_nope;
					}
					else
					{
						Logging.Warn("[Act3] Translation for 'act3_fraudFourth_nope' is missing or empty. Will keep original text.");
					}
				}
			}
		}
	}
	public static class Act3Strings
	{
		public static string Level71(string message, string message2)
		{
			if ((message + message2).Contains("A door opens."))
			{
				return LanguageManager.CurrentLanguage.act3.act3_violenceFirst_doorOpens;
			}
			return "Unimplemented string";
		}

		public static string Level72(string message, string message2, string input)
		{
			string text = message + message2;
			if (text.Contains("Swap arms with"))
			{
				return LanguageManager.CurrentLanguage.act3.act3_violenceSecond_guttermanTutorial + " '<color=orange>" + input + "</color>'.";
			}
			if (text.Contains("You should probably"))
			{
				return LanguageManager.CurrentLanguage.act3.act3_violenceSecond_guttermanTutorialNoKB;
			}
			if (text.Contains("BIGGER BOOM"))
			{
				return "<color=red>" + LanguageManager.CurrentLanguage.act3.act3_violenceSecond_biggerBoom + "</color>";
			}
			if (message.Contains("versions"))
			{
				return LanguageManager.CurrentLanguage.misc.hud_alternateVersion;
			}
			if (text.Contains("ALTERNATE SHOTGUN"))
			{
				return LanguageManager.CurrentLanguage.act3.act3_violenceSecond_alternateShotgun;
			}
			return "Unimplemented string";
		}

		public static string Level73(string message, string message2)
		{
			if ((message + message2).Contains("F E E D"))
			{
				return "<color=red>" + LanguageManager.CurrentLanguage.act3.act3_violenceThird_feedIt + "</color>";
			}
			return "Unimplemented string";
		}

		public static string Level74(string message, string message2)
		{
			if ((message + message2).Contains("MAGENTA"))
			{
				return LanguageManager.CurrentLanguage.act3.act3_violenceFourth_magentaAttack;
			}
			return "Unimplemented string";
		}

		public static string Level7Secret(string message, string message2)
		{
			return "Unimplemented string";
		}

		public static string Level81(string message, string message2)
		{
			string text = message + message2;
			if (text.Contains("The cycle of life"))
			{
				return LanguageManager.CurrentLanguage.act3.act3_fraudSecond_cycleOfLife;
			}
			if (text.Contains("It is happening again"))
			{
				return LanguageManager.CurrentLanguage.act3.act3_fraudSecond_happeningAgain;
			}
			return "Unimplemented string";
		}

		public static string Level82(string message, string message2)
		{
			string text = message + message2;
			if (text.Contains("The cycle of life"))
			{
				return LanguageManager.CurrentLanguage.act3.act3_fraudSecond_cycleOfLife;
			}
			if (text.Contains("YOU'RE NOT SUPPOSED TO BE HERE."))
			{
				return LanguageManager.CurrentLanguage.act3.act3_secretNotReady;
			}
			if (text.Contains("It is happening again"))
			{
				return LanguageManager.CurrentLanguage.act3.act3_fraudSecond_happeningAgain;
			}
			return "Unimplemented string";
		}

		public static string Level83(string message, string message2)
		{
			string text = message + message2;
			if (text.Contains("The cycle of life"))
			{
				return LanguageManager.CurrentLanguage.act3.act3_fraudSecond_cycleOfLife;
			}
			if (text.Contains("It is happening again"))
			{
				return LanguageManager.CurrentLanguage.act3.act3_fraudSecond_happeningAgain;
			}
			return "Unimplemented string";
		}

		public static string Level84(string format = "", string message2 = "", string[] inputs = null)
		{
			string text = format + message2;
			if (text.Contains("WARNING:") && text.Contains("free fall"))
			{
				string text2 = ((inputs != null && inputs.Length != 0) ? CommonFunctions.GetLocalizedInput(inputs[0]) : "");
				string text3 = ((inputs != null && inputs.Length > 1) ? CommonFunctions.GetLocalizedInput(inputs[1]) : "");
				return LanguageManager.CurrentLanguage.act3.act3_fraudFourth_fallWarning_part1 + "\n" + LanguageManager.CurrentLanguage.act3.act3_fraudFourth_fallWarning_part2 + " <color=orange>" + text2 + "</color> " + LanguageManager.CurrentLanguage.act3.act3_fraudFourth_fallWarning_part3 + " <color=orange>" + text3 + "</color>.";
			}
			if (text.Contains("The cycle of life"))
			{
				return LanguageManager.CurrentLanguage.act3.act3_fraudSecond_cycleOfLife;
			}
			if (text.Contains("It is happening again"))
			{
				return LanguageManager.CurrentLanguage.act3.act3_fraudSecond_happeningAgain;
			}
			return "Unimplemented string";
		}

		public static string Level8Secret(string message, string message2)
		{
			return "Unimplemented string";
		}

		public static string Level91(string message, string message2)
		{
			return "Unimplemented string";
		}

		public static string Level92(string message, string message2)
		{
			return "Unimplemented string";
		}

		public static string GetMessage(string message, string message2, string input)
		{
			string currentSceneName = CommonFunctions.GetCurrentSceneName();
			_ = message + message2;
			return currentSceneName switch
			{
				"Level 7-1" => Level71(message, message2), 
				"Level 7-2" => Level72(message, message2, input), 
				"Level 7-3" => Level73(message, message2), 
				"Level 7-4" => Level74(message, message2), 
				"Level 7-S" => Level7Secret(message, message2), 
				"Level 8-1" => Level81(message, message2), 
				"Level 8-2" => Level82(message, message2), 
				"Level 8-3" => Level83(message, message2), 
				"Level 8-4" => Level84(message, message2), 
				"Level 8-S" => Level8Secret(message, message2), 
				"Level 9-1" => Level91(message, message2), 
				"Level 9-2" => Level92(message, message2), 
				_ => "Unimplemented string", 
			};
		}

		public static string GetLevelChallenge(string currentLevel)
		{
			return currentLevel switch
			{
				"Level 7-1" => LanguageManager.CurrentLanguage.levelChallenges.challenges_violenceFirst, 
				"Level 7-2" => LanguageManager.CurrentLanguage.levelChallenges.challenges_violenceSecond, 
				"Level 7-3" => LanguageManager.CurrentLanguage.levelChallenges.challenges_violenceThird, 
				"Level 7-4" => LanguageManager.CurrentLanguage.levelChallenges.challenges_violenceFourth, 
				"Level 8-1" => LanguageManager.CurrentLanguage.levelChallenges.challenges_fraudFirst, 
				"Level 8-2" => LanguageManager.CurrentLanguage.levelChallenges.challenges_fraudSecond, 
				"Level 8-3" => LanguageManager.CurrentLanguage.levelChallenges.challenges_fraudThird, 
				"Level 8-4" => LanguageManager.CurrentLanguage.levelChallenges.challenges_fraudFourth, 
				"Level 9-1" => LanguageManager.CurrentLanguage.levelChallenges.challenges_treacheryFirst, 
				"Level 9-2" => LanguageManager.CurrentLanguage.levelChallenges.challenges_treacherySecond, 
				_ => "Unknown challenge description", 
			};
		}

		public static string GetLevelName()
		{
			return CommonFunctions.GetCurrentSceneName() switch
			{
				"Level 7-1" => "7-1: " + LanguageManager.CurrentLanguage.levelNames.levelName_violenceFirst, 
				"Level 7-2" => "7-2: " + LanguageManager.CurrentLanguage.levelNames.levelName_violenceSecond, 
				"Level 7-3" => "7-3: " + LanguageManager.CurrentLanguage.levelNames.levelName_violenceThird, 
				"Level 7-4" => "7-4: " + LanguageManager.CurrentLanguage.levelNames.levelName_violenceFourth, 
				"Level 8-1" => "8-1: " + LanguageManager.CurrentLanguage.levelNames.levelName_fraudFirst, 
				"Level 8-2" => "8-2: " + LanguageManager.CurrentLanguage.levelNames.levelName_fraudSecond, 
				"Level 8-3" => "8-3: " + LanguageManager.CurrentLanguage.levelNames.levelName_fraudThird, 
				"Level 8-4" => "8-4: " + LanguageManager.CurrentLanguage.levelNames.levelName_fraudFourth, 
				"Level 9-1" => "9-1: " + LanguageManager.CurrentLanguage.levelNames.levelName_treacheryFirst, 
				"Level 9-2" => "9-2: " + LanguageManager.CurrentLanguage.levelNames.levelName_treacherySecond, 
				_ => "Unknown level name", 
			};
		}
	}
	internal class AngryLevel
	{
		public static bool IsAngryCustomLevel()
		{
			Type type = Type.GetType("AngryLevelLoader.Managers.AngrySceneManager, AngryLevelLoader");
			if (type == null)
			{
				return false;
			}
			PropertyInfo property = type.GetProperty("isInCustomLevel");
			if (property == null)
			{
				return false;
			}
			return (bool)property.GetValue(null);
		}

		public static void PatchAngry()
		{
			CommonFunctions.PatchResultsScreen(null, null);
			GameObject @object = CommonFunctions.GetObject("Canvas/Hellmap/Hellmap Co

plugins/UltrakULL/Emgu.CV.dll

Decompiled a day ago
#define TRACE
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.IO;
using System.IO.Compression;
using System.Net.Http;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Serialization;
using System.Runtime.Versioning;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
using System.Xml.Schema;
using System.Xml.Serialization;
using Emgu.CV.Cuda;
using Emgu.CV.CvEnum;
using Emgu.CV.Dnn;
using Emgu.CV.Features2D;
using Emgu.CV.Flann;
using Emgu.CV.ML.MlEnum;
using Emgu.CV.Ocl;
using Emgu.CV.Reflection;
using Emgu.CV.Structure;
using Emgu.CV.Util;
using Emgu.Util;
using Emgu.Util.TypeEnum;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("Emgu Corporation")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Emgu Corporation 2022")]
[assembly: AssemblyFileVersion("4.6.0.5131")]
[assembly: AssemblyInformationalVersion("4.6.0.5131")]
[assembly: AssemblyProduct("Emgu.CV")]
[assembly: AssemblyTitle("Emgu.CV")]
[assembly: AssemblyVersion("4.6.0.5131")]
namespace Emgu.Util
{
	public abstract class DisposableObject : IDisposable
	{
		private bool _disposed;

		public void Dispose()
		{
			Dispose(disposing: true);
			GC.SuppressFinalize(this);
		}

		private void Dispose(bool disposing)
		{
			if (!_disposed)
			{
				_disposed = true;
				if (disposing)
				{
					ReleaseManagedResources();
				}
				DisposeObject();
			}
		}

		protected virtual void ReleaseManagedResources()
		{
		}

		protected abstract void DisposeObject();

		~DisposableObject()
		{
			Dispose(disposing: false);
		}
	}
	public class DownloadableFile
	{
		private string _url;

		private string _localSubfolder;

		private string _sha256Hash;

		private string _localFile;

		public string Url => _url;

		public bool IsLocalFileValid
		{
			get
			{
				string localFile = LocalFile;
				if (!File.Exists(localFile))
				{
					return false;
				}
				FileInfo fileInfo = new FileInfo(localFile);
				if (fileInfo.Length == 0L)
				{
					return false;
				}
				if (_sha256Hash != null)
				{
					using SHA256 sHA = SHA256.Create();
					try
					{
						using FileStream fileStream = fileInfo.Open(FileMode.Open);
						fileStream.Position = 0L;
						string text = ByteArrayToString(sHA.ComputeHash(fileStream));
						if (text != _sha256Hash)
						{
							Trace.WriteLine($"{localFile}: expecting SHA256 of \"{_sha256Hash}\", got \"{text}\"");
							return false;
						}
					}
					catch (IOException ex)
					{
						Trace.WriteLine("I/O Exception: " + ex.Message);
						return false;
					}
					catch (UnauthorizedAccessException ex2)
					{
						Trace.WriteLine("Access Exception: " + ex2.Message);
						return false;
					}
				}
				return true;
			}
		}

		public string LocalFile
		{
			get
			{
				if (_localFile != null)
				{
					return _localFile;
				}
				if (Url == null)
				{
					return null;
				}
				string fileName = Path.GetFileName(new Uri(Url).LocalPath);
				return GetLocalFileName(fileName);
			}
			set
			{
				_localFile = value;
			}
		}

		public string LocalFolder => new FileInfo(LocalFile).DirectoryName;

		public DownloadableFile(string url, string localSubfolder, string sha256Hash = null)
		{
			_url = url;
			_localSubfolder = localSubfolder;
			if (sha256Hash != null)
			{
				_sha256Hash = sha256Hash.ToUpper();
			}
			else
			{
				_sha256Hash = null;
			}
		}

		private static string ByteArrayToString(byte[] array)
		{
			StringBuilder stringBuilder = new StringBuilder();
			for (int i = 0; i < array.Length; i++)
			{
				stringBuilder.Append($"{array[i]:X2}");
			}
			return stringBuilder.ToString();
		}

		public string GetLocalFileName(string fileName)
		{
			return Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), _localSubfolder, fileName);
		}
	}
	public class EventArgs<T> : EventArgs
	{
		private T _value;

		public T Value => _value;

		public EventArgs(T value)
		{
			_value = value;
		}
	}
	public class EventArgs<T1, T2> : EventArgs
	{
		private T1 _value1;

		private T2 _value2;

		public T1 Value1 => _value1;

		public T2 Value2 => _value2;

		public EventArgs(T1 value1, T2 value2)
		{
			_value1 = value1;
			_value2 = value2;
		}
	}
	public abstract class ExceptionHandler
	{
		public abstract bool HandleException(Exception ex);
	}
	public class FileDownloadManager
	{
		public delegate void DownloadProgressChangedEventHandler(long? totalBytesToReceive, long bytesReceived, double? progressPercentage);

		public class HttpClientWithProgress : HttpClient
		{
			public event DownloadProgressChangedEventHandler DownloadProgressChanged;

			public async Task DownloadFileTaskAsync(string downloadUrl, string destinationFilePath)
			{
				using HttpResponseMessage response = await GetAsync(downloadUrl, HttpCompletionOption.ResponseHeadersRead);
				await DownloadFileFromHttpResponseMessage(response, destinationFilePath);
			}

			private async Task DownloadFileFromHttpResponseMessage(HttpResponseMessage response, string destinationFilePath)
			{
				response.EnsureSuccessStatusCode();
				long? totalBytes = response.Content.Headers.ContentLength;
				using System.IO.Stream contentStream = await response.Content.ReadAsStreamAsync();
				await ProcessContentStream(totalBytes, contentStream, destinationFilePath);
			}

			private async Task ProcessContentStream(long? totalDownloadSize, System.IO.Stream contentStream, string destinationFilePath)
			{
				long totalBytesRead = 0L;
				long readCount = 0L;
				byte[] buffer = new byte[8192];
				bool isMoreToRead = true;
				using FileStream fileStream = new FileStream(destinationFilePath, FileMode.Create, FileAccess.Write, FileShare.None, 8192, useAsync: true);
				do
				{
					int bytesRead = await contentStream.ReadAsync(buffer, 0, buffer.Length);
					if (bytesRead == 0)
					{
						isMoreToRead = false;
						TriggerProgressChanged(totalDownloadSize, totalBytesRead);
						continue;
					}
					await fileStream.WriteAsync(buffer, 0, bytesRead);
					totalBytesRead += bytesRead;
					readCount++;
					if (readCount % 100 == 0L)
					{
						TriggerProgressChanged(totalDownloadSize, totalBytesRead);
					}
				}
				while (isMoreToRead);
			}

			private void TriggerProgressChanged(long? totalDownloadSize, long totalBytesRead)
			{
				if (this.DownloadProgressChanged != null)
				{
					double? progressPercentage = null;
					if (totalDownloadSize.HasValue)
					{
						progressPercentage = Math.Round((double)totalBytesRead / (double)totalDownloadSize.Value * 100.0, 2);
					}
					this.DownloadProgressChanged(totalDownloadSize, totalBytesRead, progressPercentage);
				}
			}
		}

		private List<DownloadableFile> _files = new List<DownloadableFile>();

		public bool AllFilesDownloaded
		{
			get
			{
				bool flag = true;
				foreach (DownloadableFile file in _files)
				{
					flag &= file.IsLocalFileValid;
				}
				return flag;
			}
		}

		public DownloadableFile[] Files => _files.ToArray();

		public event DownloadProgressChangedEventHandler OnDownloadProgressChanged;

		public void Clear()
		{
			_files.Clear();
		}

		public void AddFile(string url, string localSubfolder, string sha256Hash = null)
		{
			_files.Add(new DownloadableFile(url, localSubfolder, sha256Hash));
		}

		public void AddFile(DownloadableFile downloadableFile)
		{
			_files.Add(downloadableFile);
		}

		public async Task Download(int retry = 1)
		{
			await Download(_files.ToArray(), retry, this.OnDownloadProgressChanged);
		}

		private static async Task Download(DownloadableFile[] files, int retry = 1, DownloadProgressChangedEventHandler onDownloadProgressChanged = null)
		{
			await DownloadHelperMultiple(files, retry, onDownloadProgressChanged);
		}

		private static async Task DownloadHelperMultiple(DownloadableFile[] downloadableFiles, int retry = 1, DownloadProgressChangedEventHandler onDownloadProgressChanged = null)
		{
			if (downloadableFiles != null && downloadableFiles.Length != 0)
			{
				if (downloadableFiles.Length == 1)
				{
					await DownloadHelper(downloadableFiles[0], retry, onDownloadProgressChanged);
					return;
				}
				DownloadableFile downloadableFile = downloadableFiles[0];
				DownloadableFile[] remainingFiles = new DownloadableFile[downloadableFiles.Length - 1];
				Array.Copy(downloadableFiles, 1, remainingFiles, 0, remainingFiles.Length);
				await DownloadHelper(downloadableFile, retry, onDownloadProgressChanged);
				await DownloadHelperMultiple(remainingFiles, retry, onDownloadProgressChanged);
			}
		}

		private static async Task DownloadHelper(DownloadableFile downloadableFile, int retry = 1, DownloadProgressChangedEventHandler onDownloadProgressChanged = null)
		{
			if (downloadableFile.Url == null || downloadableFile.IsLocalFileValid)
			{
				return;
			}
			try
			{
				Trace.WriteLine("downloading file from:" + downloadableFile.Url + " to: " + downloadableFile.LocalFile);
				HttpClientWithProgress httpClientWithProgress = new HttpClientWithProgress();
				if (onDownloadProgressChanged != null)
				{
					httpClientWithProgress.DownloadProgressChanged += onDownloadProgressChanged;
				}
				FileInfo fileInfo = new FileInfo(downloadableFile.LocalFile);
				if (!fileInfo.Directory.Exists)
				{
					fileInfo.Directory.Create();
				}
				await httpClientWithProgress.DownloadFileTaskAsync(downloadableFile.Url, downloadableFile.LocalFile);
			}
			catch (Exception value)
			{
				if (!downloadableFile.IsLocalFileValid)
				{
					File.Delete(downloadableFile.LocalFile);
				}
				if (retry <= 0)
				{
					Trace.WriteLine(value);
					throw;
				}
				await DownloadHelper(downloadableFile, retry - 1);
			}
		}
	}
	public interface ICodeGenerable
	{
		string ToCode(ProgrammingLanguage language);
	}
	public interface IInterpolatable<T> where T : new()
	{
		double InterpolationIndex { get; }

		T LinearInterpolate(T other, double index);
	}
	public class PinnedArray<T> : DisposableObject
	{
		private T[] _array;

		private GCHandle _handle;

		public T[] Array => _array;

		public PinnedArray(int size)
		{
			_array = new T[size];
			_handle = GCHandle.Alloc(_array, GCHandleType.Pinned);
		}

		public IntPtr AddrOfPinnedObject()
		{
			return _handle.AddrOfPinnedObject();
		}

		protected override void ReleaseManagedResources()
		{
			_handle.Free();
		}

		protected override void DisposeObject()
		{
		}
	}
	public static class Platform
	{
		public enum OS
		{
			Unknown,
			Windows,
			Linux,
			MacOS,
			IOS,
			Android
		}

		public enum Clr
		{
			Unknown,
			DotNet,
			DotNetNative,
			Mono,
			Unity
		}

		private static readonly OS _os;

		private static readonly Clr _runtime;

		public static OS OperationSystem => _os;

		public static Clr ClrType => _runtime;

		static Platform()
		{
			if (RuntimeInformation.FrameworkDescription.ToLower().StartsWith(".net native"))
			{
				_runtime = Clr.DotNetNative;
			}
			else if (RuntimeInformation.FrameworkDescription.ToLower().StartsWith(".net core"))
			{
				_runtime = Clr.DotNet;
			}
			else if (RuntimeInformation.FrameworkDescription.ToLower().StartsWith(".net "))
			{
				_runtime = Clr.DotNet;
			}
			if (RuntimeInformation.IsOSPlatform(OSPlatform.Windows))
			{
				_os = OS.Windows;
			}
			else if (Toolbox.FindAssembly("Mono.Android.dll") != null)
			{
				_os = OS.Android;
				_runtime = Clr.Mono;
			}
			else if (Toolbox.FindAssembly("Microsoft.Android.dll") != null)
			{
				_os = OS.Android;
				_runtime = Clr.DotNet;
			}
			else if (Toolbox.FindAssembly("Xamarin.iOS.dll") != null)
			{
				_os = OS.IOS;
				_runtime = Clr.Mono;
			}
			else if (Toolbox.FindAssembly("Microsoft.iOS.dll") != null)
			{
				_os = OS.IOS;
				_runtime = Clr.DotNet;
			}
			else if (RuntimeInformation.IsOSPlatform(OSPlatform.OSX))
			{
				_os = OS.MacOS;
			}
			else if (RuntimeInformation.IsOSPlatform(OSPlatform.Linux))
			{
				_os = OS.Linux;
			}
			else
			{
				_os = OS.Unknown;
				_runtime = Clr.Unknown;
			}
		}
	}
	public static class Toolbox
	{
		private static Dictionary<string, AssemblyName> _assemblyNameDict = new Dictionary<string, AssemblyName>();

		public static XDocument XmlSerialize<T>(T sourceObject)
		{
			StringBuilder stringBuilder = new StringBuilder();
			using (StringWriter textWriter = new StringWriter(stringBuilder))
			{
				new XmlSerializer(typeof(T)).Serialize(textWriter, sourceObject);
			}
			return XDocument.Parse(stringBuilder.ToString());
		}

		public static XDocument XmlSerialize<T>(T sourceObject, Type[] knownTypes)
		{
			StringBuilder stringBuilder = new StringBuilder();
			using (StringWriter textWriter = new StringWriter(stringBuilder))
			{
				new XmlSerializer(typeof(T), knownTypes).Serialize(textWriter, sourceObject);
			}
			return XDocument.Parse(stringBuilder.ToString());
		}

		public static T XmlDeserialize<T>(XDocument document)
		{
			using XmlReader xmlReader = document.Root.CreateReader();
			if (xmlReader.CanReadBinaryContent)
			{
				return (T)new XmlSerializer(typeof(T)).Deserialize(xmlReader);
			}
			return XmlStringDeserialize<T>(document.ToString());
		}

		public static T XmlDeserialize<T>(XDocument xDoc, Type[] knownTypes)
		{
			using XmlReader xmlReader = xDoc.Root.CreateReader();
			if (xmlReader.CanReadBinaryContent)
			{
				return (T)new XmlSerializer(typeof(T), knownTypes).Deserialize(xmlReader);
			}
			using StringReader textReader = new StringReader(xDoc.ToString());
			return (T)new XmlSerializer(typeof(T), knownTypes).Deserialize(textReader);
		}

		public static T XmlStringDeserialize<T>(string xmlString)
		{
			using StringReader textReader = new StringReader(xmlString);
			return (T)new XmlSerializer(typeof(T)).Deserialize(textReader);
		}

		public static int SizeOf<T>()
		{
			return Marshal.SizeOf<T>();
		}

		public static byte[] MergeBytes(byte[] a, byte[] b)
		{
			byte[] array = new byte[a.Length + b.Length];
			Buffer.BlockCopy(a, 0, array, 0, a.Length);
			Buffer.BlockCopy(b, 0, array, a.Length, b.Length);
			return array;
		}

		public static string ExecuteCmd(string execFileName, string arguments)
		{
			using Process process = new Process();
			process.StartInfo.FileName = execFileName;
			process.StartInfo.Arguments = arguments;
			process.StartInfo.UseShellExecute = false;
			process.StartInfo.RedirectStandardOutput = true;
			process.StartInfo.RedirectStandardError = true;
			try
			{
				process.Start();
			}
			catch (Exception)
			{
			}
			string result = process.StandardOutput.ReadToEnd();
			process.WaitForExit();
			process.Close();
			return result;
		}

		public static Type GetBaseType(Type currentType, string baseClassName)
		{
			if (currentType.Name.Equals(baseClassName))
			{
				return currentType;
			}
			Type baseType = currentType.BaseType;
			if (!(baseType == null))
			{
				return GetBaseType(baseType, baseClassName);
			}
			return null;
		}

		public static byte[] ToBytes<TData>(TData[] data)
		{
			int num = Marshal.SizeOf<TData>() * data.Length;
			byte[] array = new byte[num];
			GCHandle gCHandle = GCHandle.Alloc(data, GCHandleType.Pinned);
			Marshal.Copy(gCHandle.AddrOfPinnedObject(), array, 0, num);
			gCHandle.Free();
			return array;
		}

		public static IEnumerable<T> LinearInterpolate<T>(IEnumerable<T> src, IEnumerable<double> indexes) where T : IInterpolatable<T>, new()
		{
			using IEnumerator<T> sampleEnumerator = src.GetEnumerator();
			if (!sampleEnumerator.MoveNext())
			{
				yield break;
			}
			T old = sampleEnumerator.Current;
			if (!sampleEnumerator.MoveNext())
			{
				yield break;
			}
			T current = sampleEnumerator.Current;
			foreach (double index in indexes)
			{
				while (index > current.InterpolationIndex && sampleEnumerator.MoveNext())
				{
					old = current;
					current = sampleEnumerator.Current;
				}
				yield return old.LinearInterpolate(current, index);
			}
		}

		public static IEnumerable<T> LinearSubsample<T>(IEnumerable<T> src, double subsampleRate) where T : IInterpolatable<T>, new()
		{
			using IEnumerator<T> sampleEnumerator = src.GetEnumerator();
			if (!sampleEnumerator.MoveNext())
			{
				yield break;
			}
			T old = sampleEnumerator.Current;
			yield return old;
			if (!sampleEnumerator.MoveNext())
			{
				yield break;
			}
			T current = sampleEnumerator.Current;
			double currentIndex = old.InterpolationIndex + subsampleRate;
			bool endOfSubsample = false;
			while (!endOfSubsample)
			{
				while (currentIndex > current.InterpolationIndex)
				{
					bool flag;
					endOfSubsample = (flag = !sampleEnumerator.MoveNext());
					if (flag)
					{
						break;
					}
					old = current;
					current = sampleEnumerator.Current;
				}
				if (!endOfSubsample)
				{
					yield return old.LinearInterpolate(current, currentIndex);
					currentIndex += subsampleRate;
				}
			}
		}

		public static IEnumerable<T> JoinInterpolatables<T>(params IEnumerable<T>[] enums) where T : IInterpolatable<T>, new()
		{
			if (enums.Length == 0)
			{
				yield break;
			}
			if (enums.Length == 1)
			{
				foreach (T item in enums[0])
				{
					yield return item;
				}
				yield break;
			}
			if (enums.Length == 2)
			{
				foreach (T item2 in JoinTwoInterpolatables(enums[0], enums[1]))
				{
					yield return item2;
				}
				yield break;
			}
			int num = enums.Length / 2;
			IEnumerable<T>[] array = new IEnumerable<T>[num];
			IEnumerable<T>[] array2 = new IEnumerable<T>[enums.Length - num];
			Array.Copy(enums, array, num);
			Array.Copy(enums, num, array2, 0, enums.Length - num);
			foreach (T item3 in JoinTwoInterpolatables(JoinInterpolatables(array), JoinInterpolatables(array2)))
			{
				yield return item3;
			}
		}

		private static IEnumerable<T> JoinTwoInterpolatables<T>(IEnumerable<T> enum1, IEnumerable<T> enum2) where T : IInterpolatable<T>, new()
		{
			IEnumerator<T> l1 = enum1.GetEnumerator();
			IEnumerator<T> l2 = enum2.GetEnumerator();
			if (!l1.MoveNext())
			{
				while (l2.MoveNext())
				{
					yield return l2.Current;
				}
				yield break;
			}
			if (!l2.MoveNext())
			{
				while (l1.MoveNext())
				{
					yield return l1.Current;
				}
				yield break;
			}
			T s1 = l1.Current;
			T s2 = l2.Current;
			while (true)
			{
				if (s1.InterpolationIndex < s2.InterpolationIndex)
				{
					yield return s1;
					if (!l1.MoveNext())
					{
						while (l2.MoveNext())
						{
							yield return l2.Current;
						}
						yield break;
					}
					s1 = l1.Current;
				}
				else
				{
					yield return s2;
					if (!l2.MoveNext())
					{
						break;
					}
					s2 = l2.Current;
				}
			}
			while (l1.MoveNext())
			{
				yield return l1.Current;
			}
		}

		public static Assembly[] LoadAllDependentAssemblies()
		{
			Assembly[] array;
			try
			{
				lock (_assemblyNameDict)
				{
					Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
					bool flag = false;
					array = assemblies;
					for (int i = 0; i < array.Length; i++)
					{
						AssemblyName name = array[i].GetName();
						if (!_assemblyNameDict.ContainsKey(name.ToString()))
						{
							_assemblyNameDict.Add(name.ToString(), name);
						}
					}
					array = assemblies;
					for (int i = 0; i < array.Length; i++)
					{
						AssemblyName[] referencedAssemblies = array[i].GetReferencedAssemblies();
						foreach (AssemblyName assemblyName in referencedAssemblies)
						{
							if (!_assemblyNameDict.ContainsKey(assemblyName.ToString()))
							{
								try
								{
									Assembly.Load(assemblyName);
									_assemblyNameDict.Add(assemblyName.ToString(), assemblyName);
									flag = true;
								}
								catch (Exception)
								{
								}
							}
						}
					}
					array = ((!flag) ? assemblies : AppDomain.CurrentDomain.GetAssemblies());
				}
			}
			catch (Exception)
			{
				goto IL_00f9;
			}
			return array;
			IL_00f9:
			return null;
		}

		public static Type[] GetInterfaceImplementationFromAssembly<T>()
		{
			Assembly[] array = LoadAllDependentAssemblies();
			List<Type> list = new List<Type>();
			if (array != null)
			{
				Assembly[] array2 = array;
				for (int i = 0; i < array2.Length; i++)
				{
					Type[] types = array2[i].GetTypes();
					foreach (Type type in types)
					{
						if (typeof(T).IsAssignableFrom(type) && typeof(T) != type)
						{
							list.Add(type);
						}
					}
				}
			}
			return list.ToArray();
		}

		public static Assembly FindAssembly(string assembleName)
		{
			try
			{
				Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
				foreach (Assembly assembly in assemblies)
				{
					if (assembly.ManifestModule.Name.Equals(assembleName))
					{
						return assembly;
					}
				}
			}
			catch (Exception ex)
			{
				Trace.WriteLine($"FindAssembly({assembleName}) failed: {ex.Message}");
			}
			return null;
		}

		private static IntPtr LoadLibraryExWindows(string dllname, int flags)
		{
			IntPtr intPtr = LoadLibraryEx(dllname, IntPtr.Zero, flags);
			if (intPtr == IntPtr.Zero)
			{
				int lastWin32Error = Marshal.GetLastWin32Error();
				Win32Exception ex = new Win32Exception(lastWin32Error);
				Trace.WriteLine(string.Format("LoadLibraryEx(\"{0}\", 0, {3}) failed with error code {1}: {2}", dllname, (uint)lastWin32Error, ex.Message, flags));
				if (lastWin32Error == 5)
				{
					Trace.WriteLine($"Please check if the current user has execute permission for file: {dllname} ");
				}
			}
			else
			{
				Trace.WriteLine($"LoadLibraryEx(\"{dllname}\", 0, {flags}) successfully loaded library.");
			}
			return intPtr;
		}

		private static IntPtr LoadLibraryWindows(string dllname)
		{
			int flags = ((!Path.IsPathRooted(dllname)) ? 4096 : 4352);
			IntPtr intPtr = LoadLibraryExWindows(dllname, flags);
			if (intPtr == IntPtr.Zero)
			{
				intPtr = LoadLibraryExWindows(dllname, 0);
			}
			if (intPtr == IntPtr.Zero && Environment.OSVersion.Version >= new Version(6, 2))
			{
				IntPtr intPtr2 = LoadPackagedLibrary(dllname, 0);
				if (!(intPtr2 == IntPtr.Zero))
				{
					Trace.WriteLine($"LoadPackagedLibrary loaded: {dllname}");
					return intPtr2;
				}
				new Win32Exception(Marshal.GetLastWin32Error());
			}
			return intPtr;
		}

		public static IntPtr LoadLibrary(string dllname)
		{
			if (Platform.OperationSystem == Platform.OS.Windows)
			{
				return LoadLibraryWindows(dllname);
			}
			IntPtr intPtr;
			try
			{
				intPtr = Dlopen(dllname, 258);
				if (intPtr == IntPtr.Zero)
				{
					Trace.WriteLine($"Failed to use dlopen to load {dllname}");
				}
			}
			catch
			{
				Trace.WriteLine($"Failed to use dlopen from libdl.so to load {dllname}, will try using libdl.so.2 instead");
				intPtr = Dlopen2(dllname, 258);
				if (intPtr == IntPtr.Zero)
				{
					Trace.WriteLine($"Failed to use dlopen from libdl.so.2 to load {dllname}");
				}
			}
			return intPtr;
		}

		[DllImport("Kernel32.dll", SetLastError = true)]
		private static extern IntPtr LoadPackagedLibrary([MarshalAs(UnmanagedType.LPStr)] string fileName, int dwFlags);

		[DllImport("Kernel32.dll", SetLastError = true)]
		private static extern IntPtr LoadLibraryEx([MarshalAs(UnmanagedType.LPStr)] string fileName, IntPtr hFile, int dwFlags);

		[DllImport("dl", EntryPoint = "dlopen")]
		private static extern IntPtr Dlopen([MarshalAs(UnmanagedType.LPStr)] string dllname, int mode);

		[DllImport("libdl.so.2", EntryPoint = "dlopen")]
		private static extern IntPtr Dlopen2([MarshalAs(UnmanagedType.LPStr)] string dllname, int mode);

		[DllImport("Kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
		[return: MarshalAs(UnmanagedType.Bool)]
		public static extern bool SetDllDirectory(string path);

		public static string GetDllDirectory()
		{
			int num = 2048;
			IntPtr intPtr = Marshal.AllocHGlobal(num);
			try
			{
				if (!GetDllDirectory((uint)num, intPtr))
				{
					return null;
				}
				return Marshal.PtrToStringUni(intPtr);
			}
			catch (Exception ex)
			{
				Trace.WriteLine("Failed to call into GetDllDirectory:" + Environment.NewLine + ex.StackTrace);
				return null;
			}
			finally
			{
				Marshal.FreeHGlobal(intPtr);
			}
		}

		[DllImport("Kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
		[return: MarshalAs(UnmanagedType.Bool)]
		private static extern bool GetDllDirectory(uint nBufferLength, IntPtr lpBuffer);

		[DllImport("Kernel32.dll", CharSet = CharSet.Unicode, SetLastError = true)]
		[return: MarshalAs(UnmanagedType.Bool)]
		public static extern bool AddDllDirectory(string path);
	}
	public abstract class UnmanagedObject : DisposableObject
	{
		protected IntPtr _ptr;

		public IntPtr Ptr => _ptr;

		public static implicit operator IntPtr(UnmanagedObject obj)
		{
			return obj?._ptr ?? IntPtr.Zero;
		}
	}
}
namespace Emgu.Util.TypeEnum
{
	public enum ProgrammingLanguage
	{
		CSharp,
		CPlusPlus
	}
}
namespace Emgu.CV
{
	[DebuggerTypeProxy(typeof(DebuggerProxy))]
	public class Affine3d : UnmanagedObject
	{
		internal class DebuggerProxy
		{
			private Affine3d _v;

			public double[] Values => _v.GetValues();

			public DebuggerProxy(Affine3d v)
			{
				_v = v;
			}
		}

		public Affine3d()
		{
			_ptr = CvInvoke.cveAffine3dCreate();
		}

		public static Affine3d Identity()
		{
			return new Affine3d(CvInvoke.cveAffine3dGetIdentity());
		}

		private Affine3d(IntPtr ptr)
		{
			_ptr = ptr;
		}

		public Affine3d Rotate(double r0, double r1, double r2)
		{
			return new Affine3d(CvInvoke.cveAffine3dRotate(_ptr, r0, r1, r2));
		}

		public Affine3d Translate(double t0, double t1, double t2)
		{
			return new Affine3d(CvInvoke.cveAffine3dTranslate(_ptr, t0, t1, t2));
		}

		public double[] GetValues()
		{
			double[] array = new double[9];
			GCHandle gCHandle = GCHandle.Alloc(array, GCHandleType.Pinned);
			CvInvoke.cveAffine3dGetValues(_ptr, gCHandle.AddrOfPinnedObject());
			gCHandle.Free();
			return array;
		}

		protected override void DisposeObject()
		{
			if (IntPtr.Zero != _ptr)
			{
				CvInvoke.cveAffine3dRelease(ref _ptr);
			}
		}
	}
	public static class CvInvoke
	{
		[UnmanagedFunctionPointer(CallingConvention.Cdecl)]
		public delegate int CvErrorCallback(int status, IntPtr funcName, IntPtr errMsg, IntPtr fileName, int line, IntPtr userData);

		private static readonly bool _libraryLoaded;

		public const UnmanagedType StringMarshalType = UnmanagedType.LPStr;

		public const UnmanagedType BoolMarshalType = UnmanagedType.U1;

		public const UnmanagedType BoolToIntMarshalType = UnmanagedType.Bool;

		public const CallingConvention CvCallingConvention = CallingConvention.Cdecl;

		public static readonly CvErrorCallback CvErrorHandlerThrowException;

		public static readonly CvErrorCallback CvErrorHandlerIgnoreError;

		public const string ExternLibrary = "cvextern";

		public const string ExternCudaLibrary = "cvextern";

		public const string OpencvFFMpegLibrary = "opencv_videoio_ffmpeg460_64";

		public static List<string> OpenCVModuleList;

		public static MCvScalar MorphologyDefaultBorderValue;

		public static Backend[] Backends
		{
			get
			{
				using VectorOfInt vectorOfInt = new VectorOfInt();
				cveGetBackends(vectorOfInt);
				int[] array = vectorOfInt.ToArray();
				Backend[] array2 = new Backend[array.Length];
				for (int i = 0; i < array.Length; i++)
				{
					array2[i] = new Backend(array[i]);
				}
				return array2;
			}
		}

		public static Backend[] CameraBackends
		{
			get
			{
				using VectorOfInt vectorOfInt = new VectorOfInt();
				cveGetCameraBackends(vectorOfInt);
				int[] array = vectorOfInt.ToArray();
				Backend[] array2 = new Backend[array.Length];
				for (int i = 0; i < array.Length; i++)
				{
					array2[i] = new Backend(array[i]);
				}
				return array2;
			}
		}

		public static Backend[] StreamBackends
		{
			get
			{
				using VectorOfInt vectorOfInt = new VectorOfInt();
				cveGetStreamBackends(vectorOfInt);
				int[] array = vectorOfInt.ToArray();
				Backend[] array2 = new Backend[array.Length];
				for (int i = 0; i < array.Length; i++)
				{
					array2[i] = new Backend(array[i]);
				}
				return array2;
			}
		}

		public static Backend[] WriterBackends
		{
			get
			{
				using VectorOfInt vectorOfInt = new VectorOfInt();
				cveGetWriterBackends(vectorOfInt);
				int[] array = vectorOfInt.ToArray();
				Backend[] array2 = new Backend[array.Length];
				for (int i = 0; i < array.Length; i++)
				{
					array2[i] = new Backend(array[i]);
				}
				return array2;
			}
		}

		public static LogLevel LogLevel
		{
			get
			{
				return cveGetLogLevel();
			}
			set
			{
				cveSetLogLevel(value);
			}
		}

		public static bool UseOptimized
		{
			get
			{
				return cveUseOptimized();
			}
			set
			{
				cveSetUseOptimized(value);
			}
		}

		public static bool HaveOpenVX => cveHaveOpenVX();

		public static bool UseOpenVX
		{
			get
			{
				return cveUseOpenVX();
			}
			set
			{
				cveSetUseOpenVX(value);
			}
		}

		public static string BuildInformation
		{
			get
			{
				using CvString cvString = new CvString();
				cveGetBuildInformation(cvString);
				return cvString.ToString();
			}
		}

		public static int NumThreads
		{
			get
			{
				return cveGetNumThreads();
			}
			set
			{
				cveSetNumThreads(value);
			}
		}

		public static int ThreadNum => cveGetThreadNum();

		public static int NumberOfCPUs => cveGetNumberOfCPUs();

		public static string[] AvailableParallelBackends
		{
			get
			{
				using VectorOfCvString vectorOfCvString = new VectorOfCvString();
				cveGetParallelBackends(vectorOfCvString);
				return vectorOfCvString.ToArray();
			}
		}

		public static bool HaveOpenCL => cveHaveOpenCL();

		public static bool UseOpenCL
		{
			get
			{
				return cveUseOpenCL();
			}
			set
			{
				cveSetUseOpenCL(value);
			}
		}

		public static bool HaveOpenCLCompatibleGpuDevice
		{
			get
			{
				if (HaveOpenCL)
				{
					using VectorOfOclPlatformInfo vectorOfOclPlatformInfo = OclInvoke.GetPlatformsInfo();
					if (vectorOfOclPlatformInfo.Size > 0)
					{
						for (int i = 0; i < vectorOfOclPlatformInfo.Size; i++)
						{
							PlatformInfo platformInfo = vectorOfOclPlatformInfo[i];
							for (int j = 0; j < platformInfo.DeviceNumber; j++)
							{
								if (platformInfo.GetDevice(j).Type == DeviceType.Gpu)
								{
									return true;
								}
							}
						}
					}
				}
				return false;
			}
		}

		public static Dictionary<string, double> ConfigDict
		{
			get
			{
				using VectorOfCvString vectorOfCvString = new VectorOfCvString();
				using VectorOfDouble vectorOfDouble = new VectorOfDouble();
				cveGetConfigDict(vectorOfCvString, vectorOfDouble);
				string[] array = vectorOfCvString.ToArray();
				double[] array2 = vectorOfDouble.ToArray();
				Dictionary<string, double> dictionary = new Dictionary<string, double>();
				for (int i = 0; i < array.Length; i++)
				{
					dictionary[array[i]] = array2[i];
				}
				return dictionary;
			}
		}

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern IntPtr cveAffine3dCreate();

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern IntPtr cveAffine3dGetIdentity();

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern IntPtr cveAffine3dRotate(IntPtr affine, double r0, double r1, double r2);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern IntPtr cveAffine3dTranslate(IntPtr affine, double t0, double t1, double t2);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveAffine3dGetValues(IntPtr affine, IntPtr values);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveAffine3dRelease(ref IntPtr affine);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern IntPtr cveStringCreate();

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveStringRelease(ref IntPtr str);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern int cveStringGetLength(IntPtr str);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveStringGetCStr(IntPtr str, ref IntPtr cStr, ref int size);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern IntPtr cveStringCreateFromStr(IntPtr c);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveDirectxConvertToD3D11Texture2D(IntPtr src, IntPtr pD3D11Texture2D);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveDirectxConvertFromD3D11Texture2D(IntPtr pD3D11Texture2D, IntPtr dst);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveDirectxConvertToD3D10Texture2D(IntPtr src, IntPtr pD3D10Texture2D);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveDirectxConvertFromD3D10Texture2D(IntPtr pD3D10Texture2D, IntPtr dst);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveDirectxConvertToDirect3DSurface9(IntPtr src, IntPtr pDirect3DSurface9, IntPtr surfaceSharedHandle);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveDirectxConvertFromDirect3DSurface9(IntPtr pDirect3DSurface9, IntPtr dst, IntPtr surfaceSharedHandle);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveFileNodeRelease(ref IntPtr node);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveFileNodeReadMat(IntPtr node, IntPtr mat, IntPtr defaultMat);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern int cveFileNodeGetType(IntPtr node);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveFileNodeGetName(IntPtr node, IntPtr name);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveFileNodeGetKeys(IntPtr node, IntPtr keys);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveFileNodeReadString(IntPtr node, IntPtr str, IntPtr defaultStr);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern int cveFileNodeReadInt(IntPtr node, int defaultInt);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern double cveFileNodeReadDouble(IntPtr node, double defaultDouble);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern float cveFileNodeReadFloat(IntPtr node, float defaultFloat);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool cveFileNodeIsNamed(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool cveFileNodeIsEmpty(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool cveFileNodeIsNone(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool cveFileNodeIsSeq(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool cveFileNodeIsMap(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool cveFileNodeIsInt(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool cveFileNodeIsReal(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool cveFileNodeIsString(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern IntPtr cveFileNodeIteratorCreate();

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveFileNodeIteratorRelease(ref IntPtr iterator);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern IntPtr cveFileNodeIteratorCreateFromNode(IntPtr node, [MarshalAs(UnmanagedType.U1)] bool seekEnd);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool cveFileNodeIteratorEqualTo(IntPtr iterator, IntPtr otherIterator);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveFileNodeIteratorNext(IntPtr iterator);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern IntPtr cveFileNodeIteratorGetFileNode(IntPtr iterator);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern IntPtr cveFileStorageCreate(IntPtr source, FileStorage.Mode flags, IntPtr encoding);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool cveFileStorageIsOpened(IntPtr storage);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveFileStorageReleaseAndGetString(IntPtr storage, IntPtr result);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveFileStorageRelease(ref IntPtr storage);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveFileStorageWriteMat(IntPtr fs, IntPtr name, IntPtr value);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveFileStorageWriteInt(IntPtr fs, IntPtr name, int value);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveFileStorageWriteFloat(IntPtr fs, IntPtr name, float value);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveFileStorageWriteDouble(IntPtr fs, IntPtr name, double value);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveFileStorageWriteString(IntPtr fs, IntPtr name, IntPtr value);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern IntPtr cveFileStorageRoot(IntPtr fs, int streamIdx);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern IntPtr cveFileStorageGetFirstTopLevelNode(IntPtr fs);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern IntPtr cveFileStorageGetNode(IntPtr fs, IntPtr nodeName);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveFileStorageInsertString(IntPtr fs, IntPtr value);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveAlgorithmRead(IntPtr algorithm, IntPtr node);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveAlgorithmWrite(IntPtr algorithm, IntPtr storage);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveAlgorithmWrite2(IntPtr algorithm, IntPtr storage, IntPtr name);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveAlgorithmSave(IntPtr algorithm, IntPtr filename);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveAlgorithmClear(IntPtr algorithm);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool cveAlgorithmEmpty(IntPtr algorithm);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveAlgorithmGetDefaultName(IntPtr algorithm, IntPtr defaultName);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveInputArrayRelease(ref IntPtr arr);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern int cveInputArrayGetDims(IntPtr ia, int idx);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveInputArrayGetSize(IntPtr ia, ref Size size, int idx);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern DepthType cveInputArrayGetDepth(IntPtr ia, int idx);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern int cveInputArrayGetChannels(IntPtr ia, int idx);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool cveInputArrayIsEmpty(IntPtr ia);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveInputArrayGetMat(IntPtr ia, int idx, IntPtr mat);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveInputArrayGetUMat(IntPtr ia, int idx, IntPtr umat);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveInputArrayCopyTo(IntPtr ia, IntPtr arr, IntPtr mask);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool cveInputArrayIsMat(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool cveInputArrayIsUMat(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool cveInputArrayIsMatVector(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool cveInputArrayIsUMatVector(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool cveInputArrayIsMatx(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern InputArray.Type cveInputArrayKind(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveInputOutputArrayRelease(ref IntPtr arr);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool cveMatIsContinuous(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool cveMatIsSubmatrix(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern DepthType cveMatDepth(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool cveMatIsEmpty(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern int cveMatNumberOfChannels(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveMatPopBack(IntPtr obj, int val);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveMatPushBack(IntPtr obj, IntPtr val);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern IntPtr cveMatTotal(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern int cveMatGetDims(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern IntPtr cveMomentsCreate();

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveMomentsRelease(ref IntPtr moments);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern double cveMomentsGetM00(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveMomentsSetM00(IntPtr obj, double val);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern double cveMomentsGetM10(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveMomentsSetM10(IntPtr obj, double val);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern double cveMomentsGetM01(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveMomentsSetM01(IntPtr obj, double val);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern double cveMomentsGetM20(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveMomentsSetM20(IntPtr obj, double val);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern double cveMomentsGetM11(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveMomentsSetM11(IntPtr obj, double val);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern double cveMomentsGetM02(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveMomentsSetM02(IntPtr obj, double val);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern double cveMomentsGetM30(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveMomentsSetM30(IntPtr obj, double val);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern double cveMomentsGetM21(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveMomentsSetM21(IntPtr obj, double val);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern double cveMomentsGetM12(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveMomentsSetM12(IntPtr obj, double val);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern double cveMomentsGetM03(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveMomentsSetM03(IntPtr obj, double val);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern double cveMomentsGetMu20(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveMomentsSetMu20(IntPtr obj, double val);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern double cveMomentsGetMu11(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveMomentsSetMu11(IntPtr obj, double val);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern double cveMomentsGetMu02(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveMomentsSetMu02(IntPtr obj, double val);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern double cveMomentsGetMu30(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveMomentsSetMu30(IntPtr obj, double val);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern double cveMomentsGetMu21(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveMomentsSetMu21(IntPtr obj, double val);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern double cveMomentsGetMu12(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveMomentsSetMu12(IntPtr obj, double val);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern double cveMomentsGetMu03(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveMomentsSetMu03(IntPtr obj, double val);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern double cveMomentsGetNu20(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveMomentsSetNu20(IntPtr obj, double val);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern double cveMomentsGetNu11(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveMomentsSetNu11(IntPtr obj, double val);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern double cveMomentsGetNu02(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveMomentsSetNu02(IntPtr obj, double val);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern double cveMomentsGetNu30(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveMomentsSetNu30(IntPtr obj, double val);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern double cveMomentsGetNu21(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveMomentsSetNu21(IntPtr obj, double val);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern double cveMomentsGetNu12(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveMomentsSetNu12(IntPtr obj, double val);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern double cveMomentsGetNu03(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveMomentsSetNu03(IntPtr obj, double val);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveOutputArrayRelease(ref IntPtr arr);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool cveOutputArrayFixedSize(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool cveOutputArrayFixedType(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool cveOutputArrayNeeded(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern IntPtr cveRngCreate();

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern IntPtr cveRngCreateWithSeed(ulong state);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveRngFill(IntPtr rng, IntPtr mat, RNG.DistType distType, IntPtr a, IntPtr b, bool saturateRange);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern double cveRngGaussian(IntPtr rng, double sigma);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern uint cveRngNext(IntPtr rng);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern int cveRngUniformInt(IntPtr rng, int a, int b);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern float cveRngUniformFloat(IntPtr rng, float a, float b);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern double cveRngUniformDouble(IntPtr rng, double a, double b);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveRngRelease(ref IntPtr rng);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool cveUMatIsContinuous(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool cveUMatIsSubmatrix(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern DepthType cveUMatDepth(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool cveUMatIsEmpty(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern int cveUMatNumberOfChannels(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern IntPtr cveUMatTotal(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern int cveUMatGetDims(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern IntPtr cveVideoCaptureCreateFromDevice(int index, VideoCapture.API apiPreference, IntPtr captureProperties);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern IntPtr cveVideoCaptureCreateFromFile(IntPtr filename, VideoCapture.API api, IntPtr captureProperties);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveVideoCaptureRelease(ref IntPtr capture);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.Bool)]
		internal static extern bool cveVideoCaptureRead(IntPtr capture, IntPtr frame);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveVideoCaptureReadToMat(IntPtr capture, IntPtr mat);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveVideoCaptureReadToUMat(IntPtr capture, IntPtr umat);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.Bool)]
		internal static extern bool cveVideoCaptureGrab(IntPtr capture);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.Bool)]
		internal static extern bool cveVideoCaptureRetrieve(IntPtr capture, IntPtr image, int flag);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern double cveVideoCaptureGet(IntPtr capture, CapProp prop);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.Bool)]
		internal static extern bool cveVideoCaptureSet(IntPtr capture, CapProp propertyId, double value);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveVideoCaptureGetBackendName(IntPtr capture, IntPtr backendName);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveGetBackendName(int api, IntPtr name);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.Bool)]
		internal static extern bool cveVideoCaptureWaitAny(IntPtr streams, IntPtr readyIndex, int timeoutNs);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveGetBackends(IntPtr backends);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveGetCameraBackends(IntPtr backends);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveGetStreamBackends(IntPtr backends);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveGetWriterBackends(IntPtr backends);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool cveVideoCaptureIsOpened(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool cveVideoCaptureGetExceptionMode(IntPtr obj);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveVideoCaptureSetExceptionMode(IntPtr obj, [MarshalAs(UnmanagedType.U1)] bool val);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern IntPtr cveVideoWriterCreate(IntPtr filename, int fourcc, double fps, ref Size frameSize, [MarshalAs(UnmanagedType.U1)] bool isColor);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern IntPtr cveVideoWriterCreate2(IntPtr filename, int apiPreference, int fourcc, double fps, ref Size frameSize, [MarshalAs(UnmanagedType.U1)] bool isColor);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern IntPtr cveVideoWriterCreate3(IntPtr filename, int apiPreference, int fourcc, double fps, ref Size frameSize, IntPtr parameters);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveVideoWriterRelease(ref IntPtr writer);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveVideoWriterWrite(IntPtr writer, IntPtr image);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern int cveVideoWriterFourcc(char c1, char c2, char c3, char c4);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool cveVideoWriterIsOpened(IntPtr writer);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		internal static extern bool cveVideoWriterSet(IntPtr writer, VideoWriter.WriterProperty propId, double value);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern double cveVideoWriterGet(IntPtr writer, VideoWriter.WriterProperty propId);

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		internal static extern void cveVideoWriterGetBackendName(IntPtr writer, IntPtr backendName);

		public static bool Init()
		{
			return _libraryLoaded;
		}

		private static string FindValidSubfolders(string baseFolder, List<string> subfolderOptions)
		{
			foreach (string subfolderOption in subfolderOptions)
			{
				if (Directory.Exists(Path.Combine(baseFolder, subfolderOption)))
				{
					return subfolderOption;
				}
			}
			return string.Empty;
		}

		public static bool LoadUnmanagedModules(string loadDirectory, params string[] unmanagedModules)
		{
			string text = string.Empty;
			if (loadDirectory == null)
			{
				List<string> list = new List<string>();
				if (Platform.OperationSystem == Platform.OS.MacOS)
				{
					list.Add(Path.Combine("runtimes", "osx", "native"));
				}
				else if (Platform.OperationSystem == Platform.OS.Linux)
				{
					switch (RuntimeInformation.ProcessArchitecture)
					{
					case Architecture.X86:
						list.Add(Path.Combine("runtimes", "linux-x86", "native"));
						list.Add(Path.Combine("runtimes", "ubuntu-x86", "native"));
						list.Add("x86");
						break;
					case Architecture.X64:
						list.Add(Path.Combine("runtimes", "linux-x64", "native"));
						list.Add(Path.Combine("runtimes", "ubuntu-x64", "native"));
						list.Add("x64");
						break;
					case Architecture.Arm:
						list.Add(Path.Combine("runtimes", "linux-arm", "native"));
						list.Add(Path.Combine("runtimes", "ubuntu-arm", "native"));
						list.Add("arm");
						break;
					case Architecture.Arm64:
						list.Add(Path.Combine("runtimes", "linux-arm64", "native"));
						list.Add(Path.Combine("runtimes", "ubuntu-arm64", "native"));
						list.Add("arm64");
						break;
					}
				}
				else if (Platform.OperationSystem == Platform.OS.Windows)
				{
					string dllDirectory = Toolbox.GetDllDirectory();
					if (dllDirectory != null)
					{
						list.Add(dllDirectory);
					}
					switch (RuntimeInformation.ProcessArchitecture)
					{
					case Architecture.X86:
						list.Add(Path.Combine("runtimes", "win-x86", "native"));
						list.Add("x86");
						break;
					case Architecture.X64:
						list.Add(Path.Combine("runtimes", "win-x64", "native"));
						list.Add("x64");
						break;
					case Architecture.Arm:
						list.Add(Path.Combine("runtimes", "win-arm", "native"));
						list.Add("arm");
						break;
					case Architecture.Arm64:
						list.Add(Path.Combine("runtimes", "win-arm64", "native"));
						list.Add("arm64");
						break;
					}
				}
				string text2 = string.Empty;
				Assembly assembly = typeof(CvInvoke).Assembly;
				if (string.IsNullOrEmpty(assembly.Location) || !File.Exists(assembly.Location))
				{
					if (string.IsNullOrEmpty(AppDomain.CurrentDomain.BaseDirectory))
					{
						loadDirectory = string.Empty;
					}
					else
					{
						DirectoryInfo directoryInfo = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory);
						string text3 = string.Empty;
						if (directoryInfo.Parent != null)
						{
							text3 = Path.Combine(directoryInfo.Parent.FullName, "Packages", "Debugger", "Visualizers");
						}
						loadDirectory = ((text3.Equals(string.Empty) || !Directory.Exists(text3)) ? directoryInfo.FullName : text3);
						text2 = FindValidSubfolders(loadDirectory, list);
					}
				}
				else
				{
					loadDirectory = Path.GetDirectoryName(assembly.Location);
					if (loadDirectory != null)
					{
						text2 = FindValidSubfolders(loadDirectory, list);
					}
				}
				if (!string.IsNullOrEmpty(text2))
				{
					loadDirectory = ((!Directory.Exists(Path.Combine(loadDirectory, text2))) ? Path.Combine(Path.GetFullPath("."), text2) : Path.Combine(loadDirectory, text2));
				}
				if (!Directory.Exists(loadDirectory))
				{
					if (string.IsNullOrEmpty(assembly.Location) || !File.Exists(assembly.Location))
					{
						System.Diagnostics.Trace.WriteLine($"asm.Location is invalid: '{assembly.Location}'");
					}
					else
					{
						DirectoryInfo directory = new FileInfo(assembly.Location).Directory;
						if (directory != null && !string.IsNullOrEmpty(text2) && Directory.Exists(Path.Combine(directory.FullName, text2)))
						{
							loadDirectory = Path.Combine(directory.FullName, text2);
						}
						else if (directory != null && Directory.Exists(directory.FullName))
						{
							loadDirectory = directory.FullName;
						}
					}
				}
			}
			bool flag = false;
			if (!string.IsNullOrEmpty(loadDirectory) && Directory.Exists(loadDirectory) && Platform.ClrType != Platform.Clr.DotNetNative)
			{
				if (Platform.OperationSystem == Platform.OS.Windows)
				{
					flag = Toolbox.SetDllDirectory(loadDirectory);
					if (!flag)
					{
						System.Diagnostics.Trace.WriteLine($"Failed to set dll directory: {loadDirectory}");
					}
				}
				else if (Platform.OperationSystem == Platform.OS.IOS)
				{
					System.Diagnostics.Trace.WriteLine("iOS required static linking, Setting loadDirectory is not supported");
				}
				else
				{
					text = Environment.CurrentDirectory;
					Environment.CurrentDirectory = loadDirectory;
				}
			}
			if (flag)
			{
				System.Diagnostics.Trace.WriteLine($"Loading Open CV binary from default locations. Current directory: {Environment.CurrentDirectory}; Additional load folder: {loadDirectory}");
			}
			else
			{
				System.Diagnostics.Trace.WriteLine($"Loading Open CV binary from default locations. Current directory: {Environment.CurrentDirectory}");
			}
			bool flag2 = true;
			string empty = string.Empty;
			foreach (string text4 in unmanagedModules)
			{
				string text5 = text4;
				if (text5.StartsWith("opencv_videoio_ffmpeg") && IntPtr.Size == 4)
				{
					text5 = text4.Replace("_64", string.Empty);
				}
				bool num = text5.Contains("ffmpeg");
				string path = Path.Combine(empty, text5);
				string text6 = Path.Combine(loadDirectory, path);
				bool num2 = File.Exists(text6);
				bool flag3 = false;
				if (num2)
				{
					System.Diagnostics.Trace.WriteLine($"Found full path {text6} for {text5}. Trying to load it.");
					IntPtr zero = IntPtr.Zero;
					flag3 = !zero.Equals((object?)(nint)Toolbox.LoadLibrary(text6));
					if (flag3)
					{
						System.Diagnostics.Trace.WriteLine($"{text5} loaded.");
					}
					else
					{
						System.Diagnostics.Trace.WriteLine($"Failed to load {text5} from {text6}.");
					}
				}
				if (!flag3)
				{
					System.Diagnostics.Trace.WriteLine($"Trying to load {text5} using default path.");
					IntPtr zero = IntPtr.Zero;
					flag3 = !zero.Equals((object?)(nint)Toolbox.LoadLibrary(text5));
					if (flag3)
					{
						System.Diagnostics.Trace.WriteLine($"{text5} loaded using default path");
					}
					else
					{
						System.Diagnostics.Trace.WriteLine($"Failed to load {text5} using default path");
					}
				}
				if (!flag3)
				{
					System.Diagnostics.Trace.WriteLine($"!!! Failed to load {text5}.");
				}
				if (!num)
				{
					flag2 = flag2 && flag3;
				}
			}
			if (!text.Equals(string.Empty))
			{
				Environment.CurrentDirectory = text;
			}
			return flag2;
		}

		public static string GetModuleFormatString()
		{
			string result = "{0}";
			if (Platform.OperationSystem == Platform.OS.Windows)
			{
				result = "{0}.dll";
			}
			else if (Platform.OperationSystem == Platform.OS.Linux)
			{
				result = "lib{0}.so";
			}
			else if (Platform.OperationSystem == Platform.OS.MacOS)
			{
				result = "lib{0}.dylib";
			}
			return result;
		}

		public static bool DefaultLoadUnmanagedModules(string[] modules, string loadDirectory = null)
		{
			bool flag = true;
			if (Platform.OperationSystem == Platform.OS.IOS)
			{
				return flag;
			}
			if (Platform.OperationSystem == Platform.OS.Android && Platform.ClrType != Platform.Clr.Unity)
			{
				Type type = Toolbox.FindAssembly("Mono.Android.dll").GetType("Java.Lang.JavaSystem");
				if (type != null)
				{
					MethodInfo method = type.GetMethod("LoadLibrary");
					if (method != null)
					{
						foreach (string text in modules)
						{
							if (text.StartsWith("opencv_videoio_ffmpeg"))
							{
								continue;
							}
							try
							{
								string text2 = ((loadDirectory == null) ? text : Path.Combine(loadDirectory, text));
								System.Diagnostics.Trace.WriteLine($"Trying to load {text2} ({IntPtr.Size * 8} bit).");
								method.Invoke(null, new object[1] { text2 });
								System.Diagnostics.Trace.WriteLine($"Loaded {text2}.");
							}
							catch (Exception ex)
							{
								flag = false;
								System.Diagnostics.Trace.WriteLine($"Failed to load {text}: {ex.Message}");
								if (ex.InnerException != null && ex.InnerException.Message != null)
								{
									System.Diagnostics.Trace.WriteLine($"InnerException {ex.InnerException.Message}");
								}
							}
						}
						return flag;
					}
				}
			}
			else
			{
				string moduleFormatString = GetModuleFormatString();
				for (int j = 0; j < modules.Length; j++)
				{
					modules[j] = string.Format(moduleFormatString, modules[j]);
				}
				flag &= LoadUnmanagedModules(loadDirectory, modules);
			}
			return flag;
		}

		static CvInvoke()
		{
			CvErrorHandlerThrowException = CvErrorHandler;
			CvErrorHandlerIgnoreError = CvIgnoreErrorErrorHandler;
			OpenCVModuleList = new List<string> { "opencv_videoio_ffmpeg460_64", "cvextern" };
			MorphologyDefaultBorderValue = new MCvScalar(double.MaxValue, double.MaxValue, double.MaxValue, double.MaxValue);
			if (Platform.OperationSystem == Platform.OS.IOS)
			{
				_libraryLoaded = true;
				return;
			}
			List<string> openCVModuleList = OpenCVModuleList;
			openCVModuleList.RemoveAll(string.IsNullOrEmpty);
			_libraryLoaded = DefaultLoadUnmanagedModules(openCVModuleList.ToArray());
			try
			{
				RedirectError(CvErrorHandlerThrowException, IntPtr.Zero, IntPtr.Zero);
			}
			catch (Exception ex)
			{
				System.Diagnostics.Trace.WriteLine($"Failed to register error handler using RedirectError : {ex.StackTrace}");
				throw;
			}
		}

		public static Type GetDepthType(DepthType t)
		{
			return t switch
			{
				DepthType.Cv8U => typeof(byte), 
				DepthType.Cv8S => typeof(sbyte), 
				DepthType.Cv16U => typeof(ushort), 
				DepthType.Cv16S => typeof(short), 
				DepthType.Cv32S => typeof(int), 
				DepthType.Cv32F => typeof(float), 
				DepthType.Cv64F => typeof(double), 
				_ => throw new ArgumentException($"Unable to convert type {t.ToString()} to depth type"), 
			};
		}

		public static DepthType GetDepthType(Type t)
		{
			if (t == typeof(byte))
			{
				return DepthType.Cv8U;
			}
			if (t == typeof(sbyte))
			{
				return DepthType.Cv8S;
			}
			if (t == typeof(ushort))
			{
				return DepthType.Cv16U;
			}
			if (t == typeof(short))
			{
				return DepthType.Cv16S;
			}
			if (t == typeof(int))
			{
				return DepthType.Cv32S;
			}
			if (t == typeof(float))
			{
				return DepthType.Cv32F;
			}
			if (t == typeof(double))
			{
				return DepthType.Cv64F;
			}
			throw new ArgumentException($"Unable to convert type {t.ToString()} to depth type");
		}

		public static int MakeType(DepthType depth, int channels)
		{
			return (int)((depth & (DepthType)7) + (channels - 1 << 3));
		}

		public static bool SanityCheck()
		{
			CvStructSizes cvStructSizes = GetCvStructSizes();
			int num = 1 & ((cvStructSizes.CvBox2D == Toolbox.SizeOf<RotatedRect>()) ? 1 : 0) & ((cvStructSizes.CvMat == Toolbox.SizeOf<MCvMat>()) ? 1 : 0) & ((cvStructSizes.CvMatND == Toolbox.SizeOf<MCvMatND>()) ? 1 : 0) & ((cvStructSizes.CvPoint == Toolbox.SizeOf<Point>()) ? 1 : 0) & ((cvStructSizes.CvPoint2D32f == Toolbox.SizeOf<PointF>()) ? 1 : 0) & ((cvStructSizes.CvPoint3D32f == Toolbox.SizeOf<MCvPoint3D32f>()) ? 1 : 0) & ((cvStructSizes.CvRect == Toolbox.SizeOf<Rectangle>()) ? 1 : 0) & ((cvStructSizes.CvScalar == Toolbox.SizeOf<MCvScalar>()) ? 1 : 0) & ((cvStructSizes.CvSize == Toolbox.SizeOf<Size>()) ? 1 : 0) & ((cvStructSizes.CvSize2D32f == Toolbox.SizeOf<SizeF>()) ? 1 : 0) & ((cvStructSizes.CvTermCriteria == Toolbox.SizeOf<MCvTermCriteria>()) ? 1 : 0) & ((2 * Toolbox.SizeOf<int>() == Toolbox.SizeOf<Emgu.CV.Structure.Range>()) ? 1 : 0);
			int num2 = Toolbox.SizeOf<MIplImage>();
			return (byte)((uint)num & ((cvStructSizes.IplImage == num2) ? 1u : 0u)) != 0;
		}

		public static Mat FindHomography(PointF[] srcPoints, PointF[] dstPoints, RobustEstimationAlgorithm method = RobustEstimationAlgorithm.AllPoints, double ransacReprojThreshold = 3.0, IOutputArray mask = null)
		{
			GCHandle gCHandle = GCHandle.Alloc(srcPoints, GCHandleType.Pinned);
			GCHandle gCHandle2 = GCHandle.Alloc(dstPoints, GCHandleType.Pinned);
			try
			{
				using Mat srcPoints2 = new Mat(srcPoints.Length, 2, DepthType.Cv32F, 1, gCHandle.AddrOfPinnedObject(), 8);
				using Mat dstPoints2 = new Mat(dstPoints.Length, 2, DepthType.Cv32F, 1, gCHandle2.AddrOfPinnedObject(), 8);
				return FindHomography(srcPoints2, dstPoints2, method, ransacReprojThreshold, mask);
			}
			finally
			{
				gCHandle.Free();
				gCHandle2.Free();
			}
		}

		public static Mat FindHomography(IInputArray srcPoints, IInputArray dstPoints, RobustEstimationAlgorithm method = RobustEstimationAlgorithm.AllPoints, double ransacReprojThreshold = 3.0, IOutputArray mask = null)
		{
			Mat mat = new Mat();
			using InputArray inputArray = srcPoints.GetInputArray();
			using InputArray inputArray2 = dstPoints.GetInputArray();
			using OutputArray outputArray = mat.GetOutputArray();
			using OutputArray outputArray2 = ((mask == null) ? OutputArray.GetEmpty() : mask.GetOutputArray());
			cveFindHomography(inputArray, inputArray2, outputArray, method, ransacReprojThreshold, outputArray2);
			return mat;
		}

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		private static extern void cveFindHomography(IntPtr srcPoints, IntPtr dstPoints, IntPtr homography, RobustEstimationAlgorithm method, double ransacReprojThreshold, IntPtr mask);

		public static void Rodrigues(IInputArray src, IOutputArray dst, IOutputArray jacobian = null)
		{
			using InputArray inputArray = src.GetInputArray();
			using OutputArray outputArray = dst.GetOutputArray();
			using OutputArray outputArray2 = ((jacobian == null) ? OutputArray.GetEmpty() : jacobian.GetOutputArray());
			cveRodrigues(inputArray, outputArray, outputArray2);
		}

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		private static extern void cveRodrigues(IntPtr src, IntPtr dst, IntPtr jacobian);

		public static Mat FindEssentialMat(IInputArray points1, IInputArray points2, IInputArray cameraMatrix, FmType method = FmType.Ransac, double prob = 0.999, double threshold = 1.0, IOutputArray mask = null)
		{
			using InputArray inputArray = points1.GetInputArray();
			using InputArray inputArray2 = points2.GetInputArray();
			using InputArray inputArray3 = cameraMatrix.GetInputArray();
			using OutputArray outputArray = ((mask == null) ? OutputArray.GetEmpty() : mask.GetOutputArray());
			Mat mat = new Mat();
			cveFindEssentialMat(inputArray, inputArray2, inputArray3, method, prob, threshold, outputArray, mat);
			return mat;
		}

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		private static extern void cveFindEssentialMat(IntPtr points1, IntPtr points2, IntPtr cameraMatrix, FmType method, double prob, double threshold, IntPtr mask, IntPtr essentialMat);

		public static Mat FindFundamentalMat(IInputArray points1, IInputArray points2, FmType method = FmType.Ransac, double param1 = 3.0, double param2 = 0.99, IOutputArray mask = null)
		{
			Mat mat = new Mat();
			using InputArray inputArray = points1.GetInputArray();
			using InputArray inputArray2 = points2.GetInputArray();
			using OutputArray outputArray = mat.GetOutputArray();
			using OutputArray outputArray2 = ((mask == null) ? OutputArray.GetEmpty() : mask.GetOutputArray());
			cveFindFundamentalMat(inputArray, inputArray2, outputArray, method, param1, param2, outputArray2);
			return mat;
		}

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		private static extern void cveFindFundamentalMat(IntPtr points1, IntPtr points2, IntPtr dst, FmType method, double param1, double param2, IntPtr mask);

		public static void ComputeCorrespondEpilines(IInputArray points, int whichImage, IInputArray fundamentalMatrix, IOutputArray correspondentLines)
		{
			using InputArray inputArray = points.GetInputArray();
			using InputArray inputArray2 = fundamentalMatrix.GetInputArray();
			using OutputArray outputArray = correspondentLines.GetOutputArray();
			cveComputeCorrespondEpilines(inputArray, whichImage, inputArray2, outputArray);
		}

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		private static extern void cveComputeCorrespondEpilines(IntPtr points, int whichImage, IntPtr fundamentalMatrix, IntPtr correspondentLines);

		public static void ConvertPointsToHomogeneous(IInputArray src, IOutputArray dst)
		{
			using InputArray inputArray = src.GetInputArray();
			using OutputArray outputArray = dst.GetOutputArray();
			cveConvertPointsToHomogeneous(inputArray, outputArray);
		}

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		private static extern void cveConvertPointsToHomogeneous(IntPtr src, IntPtr dst);

		public static void ConvertPointsFromHomogeneous(IInputArray src, IOutputArray dst)
		{
			using InputArray inputArray = src.GetInputArray();
			using OutputArray outputArray = dst.GetOutputArray();
			cveConvertPointsFromHomogeneous(inputArray, outputArray);
		}

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		private static extern void cveConvertPointsFromHomogeneous(IntPtr src, IntPtr dst);

		public static void ReprojectImageTo3D(IInputArray disparity, IOutputArray image3D, IInputArray q, bool handleMissingValues = false, DepthType ddepth = DepthType.Default)
		{
			using InputArray inputArray = disparity.GetInputArray();
			using OutputArray outputArray = image3D.GetOutputArray();
			using InputArray inputArray2 = q.GetInputArray();
			cveReprojectImageTo3D(inputArray, outputArray, inputArray2, handleMissingValues, ddepth);
		}

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		private static extern void cveReprojectImageTo3D(IntPtr disparity, IntPtr image3D, IntPtr q, [MarshalAs(UnmanagedType.U1)] bool handleMissingValues, DepthType ddepth);

		public static Mat GetOptimalNewCameraMatrix(IInputArray cameraMatrix, IInputArray distCoeffs, Size imageSize, double alpha, Size newImgSize, ref Rectangle validPixROI, bool centerPrincipalPoint = false)
		{
			Mat mat = new Mat();
			using InputArray inputArray = cameraMatrix.GetInputArray();
			using InputArray inputArray2 = ((distCoeffs == null) ? InputArray.GetEmpty() : distCoeffs.GetInputArray());
			cveGetOptimalNewCameraMatrix(inputArray, inputArray2, ref imageSize, alpha, ref newImgSize, ref validPixROI, centerPrincipalPoint, mat);
			return mat;
		}

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		private static extern void cveGetOptimalNewCameraMatrix(IntPtr cameraMatrix, IntPtr distCoeffs, ref Size imageSize, double alpha, ref Size newImgSize, ref Rectangle validPixROI, [MarshalAs(UnmanagedType.U1)] bool centerPrincipalPoint, IntPtr newCameraMatrix);

		public static Mat InitCameraMatrix2D(IInputArrayOfArrays objectPoints, IInputArrayOfArrays imagePoints, Size imageSize, double aspectRatio = 1.0)
		{
			Mat mat = new Mat();
			using InputArray inputArray = objectPoints.GetInputArray();
			using InputArray inputArray2 = imagePoints.GetInputArray();
			cveInitCameraMatrix2D(inputArray, inputArray2, ref imageSize, aspectRatio, mat);
			return mat;
		}

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		private static extern void cveInitCameraMatrix2D(IntPtr objectPoints, IntPtr imagePoints, ref Size imageSize, double aspectRatio, IntPtr cameraMatrix);

		public static PointF[] ProjectPoints(MCvPoint3D32f[] objectPoints, IInputArray rvec, IInputArray tvec, IInputArray cameraMatrix, IInputArray distCoeffs, IOutputArray jacobian = null, double aspectRatio = 0.0)
		{
			PointF[] array = new PointF[objectPoints.Length];
			GCHandle gCHandle = GCHandle.Alloc(objectPoints, GCHandleType.Pinned);
			GCHandle gCHandle2 = GCHandle.Alloc(array, GCHandleType.Pinned);
			using (Mat objectPoints2 = new Mat(objectPoints.Length, 1, DepthType.Cv32F, 3, gCHandle.AddrOfPinnedObject(), 12))
			{
				using Mat imagePoints = new Mat(array.Length, 1, DepthType.Cv32F, 2, gCHandle2.AddrOfPinnedObject(), 8);
				ProjectPoints(objectPoints2, rvec, tvec, cameraMatrix, distCoeffs, imagePoints, jacobian, aspectRatio);
			}
			gCHandle.Free();
			gCHandle2.Free();
			return array;
		}

		public static void ProjectPoints(IInputArray objectPoints, IInputArray rvec, IInputArray tvec, IInputArray cameraMatrix, IInputArray distCoeffs, IOutputArray imagePoints, IOutputArray jacobian = null, double aspectRatio = 0.0)
		{
			using InputArray inputArray = objectPoints.GetInputArray();
			using InputArray inputArray2 = rvec.GetInputArray();
			using InputArray inputArray3 = tvec.GetInputArray();
			using InputArray inputArray4 = cameraMatrix.GetInputArray();
			using InputArray inputArray5 = ((distCoeffs == null) ? InputArray.GetEmpty() : distCoeffs.GetInputArray());
			using OutputArray outputArray = imagePoints.GetOutputArray();
			using OutputArray outputArray2 = ((jacobian == null) ? OutputArray.GetEmpty() : jacobian.GetOutputArray());
			cveProjectPoints(inputArray, inputArray2, inputArray3, inputArray4, inputArray5, outputArray, outputArray2, aspectRatio);
		}

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		private static extern void cveProjectPoints(IntPtr objPoints, IntPtr rvec, IntPtr tvec, IntPtr cameraMatrix, IntPtr distCoeffs, IntPtr imagePoints, IntPtr jacobian, double aspectRatio);

		public static double CalibrateCamera(MCvPoint3D32f[][] objectPoints, PointF[][] imagePoints, Size imageSize, IInputOutputArray cameraMatrix, IInputOutputArray distortionCoeffs, CalibType calibrationType, MCvTermCriteria termCriteria, out Mat[] rotationVectors, out Mat[] translationVectors)
		{
			int num = objectPoints.Length;
			using VectorOfVectorOfPoint3D32F objectPoints2 = new VectorOfVectorOfPoint3D32F(objectPoints);
			using VectorOfVectorOfPointF imagePoints2 = new VectorOfVectorOfPointF(imagePoints);
			double result;
			using (VectorOfMat vectorOfMat = new VectorOfMat())
			{
				using VectorOfMat vectorOfMat2 = new VectorOfMat();
				result = CalibrateCamera(objectPoints2, imagePoints2, imageSize, cameraMatrix, distortionCoeffs, vectorOfMat, vectorOfMat2, calibrationType, termCriteria);
				rotationVectors = new Mat[num];
				translationVectors = new Mat[num];
				for (int i = 0; i < num; i++)
				{
					rotationVectors[i] = new Mat();
					using (Mat mat = vectorOfMat[i])
					{
						mat.CopyTo(rotationVectors[i]);
					}
					translationVectors[i] = new Mat();
					using Mat mat2 = vectorOfMat2[i];
					mat2.CopyTo(translationVectors[i]);
				}
			}
			return result;
		}

		public static double CalibrateCamera(IInputArray objectPoints, IInputArray imagePoints, Size imageSize, IInputOutputArray cameraMatrix, IInputOutputArray distortionCoeffs, IOutputArray rotationVectors, IOutputArray translationVectors, CalibType flags, MCvTermCriteria termCriteria)
		{
			using InputArray inputArray = objectPoints.GetInputArray();
			using InputArray inputArray2 = imagePoints.GetInputArray();
			using InputOutputArray inputOutputArray = cameraMatrix.GetInputOutputArray();
			using InputOutputArray inputOutputArray2 = distortionCoeffs.GetInputOutputArray();
			using OutputArray outputArray = rotationVectors.GetOutputArray();
			using OutputArray outputArray2 = translationVectors.GetOutputArray();
			return cveCalibrateCamera(inputArray, inputArray2, ref imageSize, inputOutputArray, inputOutputArray2, outputArray, outputArray2, flags, ref termCriteria);
		}

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		private static extern double cveCalibrateCamera(IntPtr objectPoints, IntPtr imagePoints, ref Size imageSize, IntPtr cameraMatrix, IntPtr distortionCoeffs, IntPtr rotationVectors, IntPtr translationVectors, CalibType flags, ref MCvTermCriteria termCriteria);

		public static void CalibrationMatrixValues(IInputArray cameraMatrix, Size imageSize, double apertureWidth, double apertureHeight, ref double fovx, ref double fovy, ref double focalLength, ref MCvPoint2D64f principalPoint, ref double aspectRatio)
		{
			using InputArray inputArray = cameraMatrix.GetInputArray();
			cveCalibrationMatrixValues(inputArray, ref imageSize, apertureWidth, apertureHeight, ref fovx, ref fovy, ref focalLength, ref principalPoint, ref aspectRatio);
		}

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		private static extern void cveCalibrationMatrixValues(IntPtr cameraMatrix, ref Size imageSize, double apertureWidth, double apertureHeight, ref double fovx, ref double fovy, ref double focalLength, ref MCvPoint2D64f principalPoint, ref double aspectRatio);

		public static bool SolvePnP(MCvPoint3D32f[] objectPoints, PointF[] imagePoints, IInputArray intrinsicMatrix, IInputArray distortionCoeffs, IOutputArray rotationVector, IOutputArray translationVector, bool useExtrinsicGuess = false, SolvePnpMethod method = SolvePnpMethod.Iterative)
		{
			using VectorOfPoint3D32F objectPoints2 = new VectorOfPoint3D32F(objectPoints);
			using VectorOfPointF imagePoints2 = new VectorOfPointF(imagePoints);
			return SolvePnP(objectPoints2, imagePoints2, intrinsicMatrix, distortionCoeffs, rotationVector, translationVector, useExtrinsicGuess: false, method);
		}

		public static bool SolvePnP(IInputArray objectPoints, IInputArray imagePoints, IInputArray intrinsicMatrix, IInputArray distortionCoeffs, IOutputArray rotationVector, IOutputArray translationVector, bool useExtrinsicGuess = false, SolvePnpMethod flags = SolvePnpMethod.Iterative)
		{
			using InputArray inputArray = objectPoints.GetInputArray();
			using InputArray inputArray2 = imagePoints.GetInputArray();
			using InputArray inputArray3 = intrinsicMatrix.GetInputArray();
			using InputArray inputArray4 = distortionCoeffs.GetInputArray();
			using OutputArray outputArray = rotationVector.GetOutputArray();
			using OutputArray outputArray2 = translationVector.GetOutputArray();
			return cveSolvePnP(inputArray, inputArray2, inputArray3, inputArray4, outputArray, outputArray2, useExtrinsicGuess, flags);
		}

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		private static extern bool cveSolvePnP(IntPtr objectPoints, IntPtr imagePoints, IntPtr cameraMatrix, IntPtr distCoeffs, IntPtr rvec, IntPtr tvec, [MarshalAs(UnmanagedType.U1)] bool useExtrinsicGuess, SolvePnpMethod flags);

		public static bool SolvePnPRansac(IInputArray objectPoints, IInputArray imagePoints, IInputArray cameraMatrix, IInputArray distCoeffs, IOutputArray rvec, IOutputArray tvec, bool useExtrinsicGuess = false, int iterationsCount = 100, float reprojectionError = 8f, double confident = 0.99, IOutputArray inliers = null, SolvePnpMethod flags = SolvePnpMethod.Iterative)
		{
			using InputArray inputArray = objectPoints.GetInputArray();
			using InputArray inputArray2 = imagePoints.GetInputArray();
			using InputArray inputArray3 = cameraMatrix.GetInputArray();
			using InputArray inputArray4 = ((distCoeffs == null) ? InputArray.GetEmpty() : distCoeffs.GetInputArray());
			using OutputArray outputArray = rvec.GetOutputArray();
			using OutputArray outputArray2 = tvec.GetOutputArray();
			using OutputArray outputArray3 = ((inliers == null) ? OutputArray.GetEmpty() : inliers.GetOutputArray());
			return cveSolvePnPRansac(inputArray, inputArray2, inputArray3, inputArray4, outputArray, outputArray2, useExtrinsicGuess, iterationsCount, reprojectionError, confident, outputArray3, flags);
		}

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		private static extern bool cveSolvePnPRansac(IntPtr objectPoints, IntPtr imagePoints, IntPtr cameraMatrix, IntPtr distCoeffs, IntPtr rvec, IntPtr tvec, [MarshalAs(UnmanagedType.U1)] bool useExtrinsicGuess, int iterationsCount, float reprojectionError, double confident, IntPtr inliers, SolvePnpMethod flags);

		public static int SolveP3P(IInputArray objectPoints, IInputArray imagePoints, IInputArray cameraMatrix, IInputArray distCoeffs, IOutputArrayOfArrays rvecs, IOutputArrayOfArrays tvecs, SolvePnpMethod flags)
		{
			using InputArray inputArray = objectPoints.GetInputArray();
			using InputArray inputArray2 = imagePoints.GetInputArray();
			using InputArray inputArray3 = cameraMatrix.GetInputArray();
			using InputArray inputArray4 = ((distCoeffs == null) ? InputArray.GetEmpty() : distCoeffs.GetInputArray());
			using OutputArray outputArray = rvecs.GetOutputArray();
			using OutputArray outputArray2 = tvecs.GetOutputArray();
			return cveSolveP3P(inputArray, inputArray2, inputArray3, inputArray4, outputArray, outputArray2, flags);
		}

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		private static extern int cveSolveP3P(IntPtr objectPoints, IntPtr imagePoints, IntPtr cameraMatrix, IntPtr distCoeffs, IntPtr rvec, IntPtr tvec, SolvePnpMethod flags);

		public static void SolvePnPRefineLM(IInputArray objectPoints, IInputArray imagePoints, IInputArray cameraMatrix, IInputArray distCoeffs, IInputOutputArray rvec, IInputOutputArray tvec, MCvTermCriteria criteria)
		{
			using InputArray inputArray = objectPoints.GetInputArray();
			using InputArray inputArray2 = imagePoints.GetInputArray();
			using InputArray inputArray3 = cameraMatrix.GetInputArray();
			using InputArray inputArray4 = ((distCoeffs == null) ? InputArray.GetEmpty() : distCoeffs.GetInputArray());
			using InputOutputArray inputOutputArray = rvec.GetInputOutputArray();
			using InputOutputArray inputOutputArray2 = tvec.GetInputOutputArray();
			cveSolvePnPRefineLM(inputArray, inputArray2, inputArray3, inputArray4, inputOutputArray, inputOutputArray2, ref criteria);
		}

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		private static extern void cveSolvePnPRefineLM(IntPtr objectPoints, IntPtr imagePoints, IntPtr cameraMatrix, IntPtr distCoeffs, IntPtr rvec, IntPtr tvec, ref MCvTermCriteria criteria);

		public static void SolvePnPRefineVVS(IInputArray objectPoints, IInputArray imagePoints, IInputArray cameraMatrix, IInputArray distCoeffs, IInputOutputArray rvec, IInputOutputArray tvec, MCvTermCriteria criteria, double VVSlambda)
		{
			using InputArray inputArray = objectPoints.GetInputArray();
			using InputArray inputArray2 = imagePoints.GetInputArray();
			using InputArray inputArray3 = cameraMatrix.GetInputArray();
			using InputArray inputArray4 = ((distCoeffs == null) ? InputArray.GetEmpty() : distCoeffs.GetInputArray());
			using InputOutputArray inputOutputArray = rvec.GetInputOutputArray();
			using InputOutputArray inputOutputArray2 = tvec.GetInputOutputArray();
			cveSolvePnPRefineVVS(inputArray, inputArray2, inputArray3, inputArray4, inputOutputArray, inputOutputArray2, ref criteria, VVSlambda);
		}

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		private static extern void cveSolvePnPRefineVVS(IntPtr objectPoints, IntPtr imagePoints, IntPtr cameraMatrix, IntPtr distCoeffs, IntPtr rvec, IntPtr tvec, ref MCvTermCriteria criteria, double VVSlambda);

		public static int SolvePnPGeneric(IInputArray objectPoints, IInputArray imagePoints, IInputArray cameraMatrix, IInputArray distCoeffs, IOutputArrayOfArrays rvecs, IOutputArrayOfArrays tvecs, bool useExtrinsicGuess = false, SolvePnpMethod flags = SolvePnpMethod.Iterative, IInputArray rvec = null, IInputArray tvec = null, IOutputArray reprojectionError = null)
		{
			using InputArray inputArray = objectPoints.GetInputArray();
			using InputArray inputArray2 = imagePoints.GetInputArray();
			using InputArray inputArray3 = cameraMatrix.GetInputArray();
			using InputArray inputArray4 = distCoeffs.GetInputArray();
			using OutputArray outputArray = rvecs.GetOutputArray();
			using OutputArray outputArray2 = tvecs.GetOutputArray();
			using InputArray inputArray5 = ((rvec == null) ? InputArray.GetEmpty() : rvec.GetInputArray());
			using InputArray inputArray6 = ((tvec == null) ? InputArray.GetEmpty() : tvec.GetInputArray());
			using OutputArray outputArray3 = ((reprojectionError == null) ? OutputArray.GetEmpty() : reprojectionError.GetOutputArray());
			return cveSolvePnPGeneric(inputArray, inputArray2, inputArray3, inputArray4, outputArray, outputArray2, useExtrinsicGuess, flags, inputArray5, inputArray6, outputArray3);
		}

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		private static extern int cveSolvePnPGeneric(IntPtr objectPoints, IntPtr imagePoints, IntPtr cameraMatrix, IntPtr distCoeffs, IntPtr rvecs, IntPtr tvecs, [MarshalAs(UnmanagedType.U1)] bool useExtrinsicGuess, SolvePnpMethod flags, IntPtr rvec, IntPtr tvec, IntPtr reprojectionError);

		public static double StereoCalibrate(MCvPoint3D32f[][] objectPoints, PointF[][] imagePoints1, PointF[][] imagePoints2, IInputOutputArray cameraMatrix1, IInputOutputArray distCoeffs1, IInputOutputArray cameraMatrix2, IInputOutputArray distCoeffs2, Size imageSize, IOutputArray r, IOutputArray t, IOutputArray e, IOutputArray f, CalibType flags, MCvTermCriteria termCrit)
		{
			using VectorOfVectorOfPoint3D32F objectPoints2 = new VectorOfVectorOfPoint3D32F(objectPoints);
			using VectorOfVectorOfPointF imagePoints3 = new VectorOfVectorOfPointF(imagePoints1);
			using VectorOfVectorOfPointF imagePoints4 = new VectorOfVectorOfPointF(imagePoints2);
			return StereoCalibrate(objectPoints2, imagePoints3, imagePoints4, cameraMatrix1, distCoeffs1, cameraMatrix2, distCoeffs2, imageSize, r, t, e, f, flags, termCrit);
		}

		public static double StereoCalibrate(IInputArray objectPoints, IInputArray imagePoints1, IInputArray imagePoints2, IInputOutputArray cameraMatrix1, IInputOutputArray distCoeffs1, IInputOutputArray cameraMatrix2, IInputOutputArray distCoeffs2, Size imageSize, IOutputArray r, IOutputArray t, IOutputArray e, IOutputArray f, CalibType flags, MCvTermCriteria termCrit)
		{
			using InputArray inputArray = objectPoints.GetInputArray();
			using InputArray inputArray2 = imagePoints1.GetInputArray();
			using InputArray inputArray3 = imagePoints2.GetInputArray();
			using InputOutputArray inputOutputArray = cameraMatrix1.GetInputOutputArray();
			using InputOutputArray inputOutputArray3 = cameraMatrix2.GetInputOutputArray();
			using InputOutputArray inputOutputArray2 = distCoeffs1.GetInputOutputArray();
			using InputOutputArray inputOutputArray4 = distCoeffs2.GetInputOutputArray();
			using OutputArray outputArray = r.GetOutputArray();
			using OutputArray outputArray2 = t.GetOutputArray();
			using OutputArray outputArray3 = e.GetOutputArray();
			using OutputArray outputArray4 = f.GetOutputArray();
			return cveStereoCalibrate(inputArray, inputArray2, inputArray3, inputOutputArray, inputOutputArray2, inputOutputArray3, inputOutputArray4, ref imageSize, outputArray, outputArray2, outputArray3, outputArray4, flags, ref termCrit);
		}

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		private static extern double cveStereoCalibrate(IntPtr objectPoints, IntPtr imagePoints1, IntPtr imagePoints2, IntPtr cameraMatrix1, IntPtr distCoeffs1, IntPtr cameraMatrix2, IntPtr distCoeffs2, ref Size imageSize, IntPtr r, IntPtr t, IntPtr e, IntPtr f, CalibType flags, ref MCvTermCriteria termCrit);

		public static bool StereoRectifyUncalibrated(IInputArray points1, IInputArray points2, IInputArray f, Size imgSize, IOutputArray h1, IOutputArray h2, double threshold = 5.0)
		{
			using InputArray inputArray = points1.GetInputArray();
			using InputArray inputArray2 = points2.GetInputArray();
			using InputArray inputArray3 = f.GetInputArray();
			using OutputArray outputArray = h1.GetOutputArray();
			using OutputArray outputArray2 = h2.GetOutputArray();
			return cveStereoRectifyUncalibrated(inputArray, inputArray2, inputArray3, ref imgSize, outputArray, outputArray2, threshold);
		}

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		private static extern bool cveStereoRectifyUncalibrated(IntPtr points1, IntPtr points2, IntPtr f, ref Size imgSize, IntPtr h1, IntPtr h2, double threshold);

		public static void StereoRectify(IInputArray cameraMatrix1, IInputArray distCoeffs1, IInputArray cameraMatrix2, IInputArray distCoeffs2, Size imageSize, IInputArray r, IInputArray t, IOutputArray r1, IOutputArray r2, IOutputArray p1, IOutputArray p2, IOutputArray q, StereoRectifyType flags, double alpha, Size newImageSize, ref Rectangle validPixRoi1, ref Rectangle validPixRoi2)
		{
			using InputArray inputArray = cameraMatrix1.GetInputArray();
			using InputArray inputArray2 = distCoeffs1.GetInputArray();
			using InputArray inputArray3 = cameraMatrix2.GetInputArray();
			using InputArray inputArray4 = distCoeffs2.GetInputArray();
			using InputArray inputArray5 = r.GetInputArray();
			using InputArray inputArray6 = t.GetInputArray();
			using OutputArray outputArray = r1.GetOutputArray();
			using OutputArray outputArray2 = r2.GetOutputArray();
			using OutputArray outputArray3 = p1.GetOutputArray();
			using OutputArray outputArray4 = p2.GetOutputArray();
			using OutputArray outputArray5 = q.GetOutputArray();
			cveStereoRectify(inputArray, inputArray2, inputArray3, inputArray4, ref imageSize, inputArray5, inputArray6, outputArray, outputArray2, outputArray3, outputArray4, outputArray5, flags, alpha, ref newImageSize, ref validPixRoi1, ref validPixRoi2);
		}

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		private static extern void cveStereoRectify(IntPtr cameraMatrix1, IntPtr distCoeffs1, IntPtr cameraMatrix2, IntPtr distCoeffs2, ref Size imageSize, IntPtr r, IntPtr t, IntPtr r1, IntPtr r2, IntPtr p1, IntPtr p2, IntPtr q, StereoRectifyType flags, double alpha, ref Size newImageSize, ref Rectangle validPixRoi1, ref Rectangle validPixRoi2);

		public static bool Find4QuadCornerSubpix(IInputArray image, IInputOutputArray corners, Size regionSize)
		{
			using InputArray inputArray = image.GetInputArray();
			using InputOutputArray inputOutputArray = corners.GetInputOutputArray();
			return cveFind4QuadCornerSubpix(inputArray, inputOutputArray, ref regionSize);
		}

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		private static extern bool cveFind4QuadCornerSubpix(IntPtr image, IntPtr corners, ref Size regionSize);

		public static bool FindChessboardCorners(IInputArray image, Size patternSize, IOutputArray corners, CalibCbType flags = CalibCbType.AdaptiveThresh | CalibCbType.NormalizeImage)
		{
			using InputArray inputArray = image.GetInputArray();
			using OutputArray outputArray = corners.GetOutputArray();
			return cveFindChessboardCorners(inputArray, ref patternSize, outputArray, flags);
		}

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		private static extern bool cveFindChessboardCorners(IntPtr image, ref Size patternSize, IntPtr corners, CalibCbType flags);

		public static void FilterSpeckles(IInputOutputArray img, double newVal, int maxSpeckleSize, double maxDiff, IInputOutputArray buf = null)
		{
			using InputOutputArray inputOutputArray = img.GetInputOutputArray();
			using InputOutputArray inputOutputArray2 = ((buf == null) ? InputOutputArray.GetEmpty() : buf.GetInputOutputArray());
			cveFilterSpeckles(inputOutputArray, newVal, maxSpeckleSize, maxDiff, inputOutputArray2);
		}

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		private static extern void cveFilterSpeckles(IntPtr img, double newVal, int maxSpeckleSize, double maxDiff, IntPtr buf);

		public static bool FindChessboardCornersSB(IInputArray image, Size patternSize, IOutputArray corners, CalibCbType flags = CalibCbType.Default)
		{
			using InputArray inputArray = image.GetInputArray();
			using OutputArray outputArray = corners.GetOutputArray();
			return cveFindChessboardCornersSB(inputArray, ref patternSize, outputArray, flags);
		}

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		[return: MarshalAs(UnmanagedType.U1)]
		private static extern bool cveFindChessboardCornersSB(IntPtr image, ref Size patternSize, IntPtr corners, CalibCbType flags);

		public static void DrawChessboardCorners(IInputOutputArray image, Size patternSize, IInputArray corners, bool patternWasFound)
		{
			using InputOutputArray inputOutputArray = image.GetInputOutputArray();
			using InputArray inputArray = corners.GetInputArray();
			cveDrawChessboardCorners(inputOutputArray, ref patternSize, inputArray, patternWasFound);
		}

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		private static extern void cveDrawChessboardCorners(IntPtr image, ref Size patternSize, IntPtr corners, [MarshalAs(UnmanagedType.U1)] bool patternWasFound);

		public static void TriangulatePoints(IInputArray projMat1, IInputArray projMat2, IInputArray projPoints1, IInputArray projPoints2, IOutputArray points4D)
		{
			using InputArray inputArray = projMat1.GetInputArray();
			using InputArray inputArray2 = projMat2.GetInputArray();
			using InputArray inputArray3 = projPoints1.GetInputArray();
			using InputArray inputArray4 = projPoints2.GetInputArray();
			using OutputArray outputArray = points4D.GetOutputArray();
			cveTriangulatePoints(inputArray, inputArray2, inputArray3, inputArray4, outputArray);
		}

		[DllImport("cvextern", CallingConvention = CallingConvention.Cdecl)]
		private static extern void cveTriangulatePoints(IntPtr projMat1, IntPtr projMat2, IntPtr projPoints1, IntPtr projPoints2, IntPtr points4D);

		public static void CorrectMatches(IInputArray f, IInputArray points1, IInputArray points2, IOutputArray newPoints1, IOutputArray newPoints2)
		{
			using InputArray inputArray = f.GetInputArray();
			using InputArray inputArray2 = points1.GetInputArray();
			using InputArray inputArray3 = points2.GetInputArray();
			using OutputArray out