Decompiled source of NM Core REPO v2.10.0

BepInEx/plugins/NM_Core_REPO/NM_Core_REPO.dll

Decompiled 28 minutes ago
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Serialization;
using System.Runtime.Serialization.Json;
using System.Runtime.Versioning;
using System.Security.Cryptography;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Nightmare.Security;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using UnityEngine;
using UnityEngine.Events;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Nightmare Community / NM")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyCopyright("Copyright (c) 2026 Nick1Z2 (Nightmare Community / NM).")]
[assembly: AssemblyFileVersion("2.10.0.0")]
[assembly: AssemblyInformationalVersion("2.10.0")]
[assembly: AssemblyProduct("NM_Core_REPO")]
[assembly: AssemblyTitle("NM_Core_REPO")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Nightmare.Security
{
	[DataContract]
	internal sealed class NmClaim
	{
		[DataMember]
		public int Format;

		[DataMember]
		public string PluginId = "";

		[DataMember]
		public string Version = "";

		[DataMember]
		public string ModId = "";

		[DataMember]
		public string Mvid = "";

		[DataMember]
		public string Sha256 = "";
	}
	internal static class NmSignature
	{
		internal static string Sidecar(string dll)
		{
			return Path.ChangeExtension(dll, ".nmsig");
		}

		internal static NmClaim Verify(string dll, string? sidecar = null)
		{
			string text = sidecar ?? Sidecar(dll);
			if (!File.Exists(text) || new FileInfo(text).Length > 16384)
			{
				throw new InvalidDataException("NM-Signatur fehlt oder ist ungültig: " + Path.GetFileName(dll));
			}
			string[] array = File.ReadAllLines(text);
			if (array.Length != 2)
			{
				throw new InvalidDataException("Ungültiges NM-Signaturformat.");
			}
			byte[] array2 = Convert.FromBase64String(array[0]);
			byte[] signature = Convert.FromBase64String(array[1]);
			using (RSA rSA = RSA.Create())
			{
				rSA.FromXmlString("<RSAKeyValue><Modulus>xCELlJ2yUiMqx5OpXf53bNgfoAnsVfpSj5co1uOOv6/hzYhSA8X8QYLKDdmhq1DpIEo7Xkey11ks+aIe4e5JaJxVfPOYTFLNYx9HE9AHhcNxOnilcSY/m+gkF4gH/EbymhAgtct/t6AayQ0ImH+QhATKDc/z6F1WYvr3sAhMCQviGkYE2KIS33DNwUAhhbyv08BafRzcKbOcRTe6b4fUnebvTi3O4HROhHIUIcTnFLiNZLUVyLTohphKI/VbZfo6nnB/z7g7OpxIMAU7+sWWDZak6EtZTuJa5hsYVqKTvvilEqE81J9J8UrmqK9dkR3Rhu8C/QQQJjQKRun8luHf2KOXMAOJRal/U+EyPnTCbdaMAVP2izn7it8a+PENkZA1bD34SNc4tYKnUmMyJtEnpN37sBY/BaOOSup0FohgegMsOrYA+/35H3DS5fb2RvJaRWuuiXHW2L2F0WOCak/c9UgHKNmeBEeZM/t0V6A5k7D7n2986YOohXCl4+c1xql7</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>");
				if (!rSA.VerifyData(array2, signature, HashAlgorithmName.SHA256, RSASignaturePadding.Pkcs1))
				{
					throw new InvalidDataException("NM-Signaturprüfung fehlgeschlagen.");
				}
			}
			NmClaim nmClaim;
			using (MemoryStream stream = new MemoryStream(array2))
			{
				nmClaim = (NmClaim)new DataContractJsonSerializer(typeof(NmClaim)).ReadObject(stream);
			}
			using FileStream inputStream = File.OpenRead(dll);
			using SHA256 sHA = SHA256.Create();
			if (nmClaim.Format != 1 || string.IsNullOrWhiteSpace(nmClaim.ModId) || string.IsNullOrWhiteSpace(nmClaim.PluginId) || string.IsNullOrWhiteSpace(nmClaim.Version) || nmClaim.Sha256 != BitConverter.ToString(sHA.ComputeHash(inputStream)).Replace("-", "").ToLowerInvariant())
			{
				throw new InvalidDataException("NM-DLL wurde verändert oder gehört nicht zur Signatur.");
			}
			return nmClaim;
		}

		internal static void VerifyAddon(Assembly caller, string pluginId, string version)
		{
			NmClaim nmClaim = Verify(caller.Location);
			if (nmClaim.PluginId != pluginId || nmClaim.Version != version || nmClaim.Mvid != caller.ManifestModule.ModuleVersionId.ToString() || nmClaim.ModId != caller.GetName().Name)
			{
				throw new InvalidDataException("NM-Addon-Kennung passt nicht zur signierten DLL.");
			}
			CustomAttributeData[] array = (from a in caller.GetTypes().SelectMany((Type t) => t.GetCustomAttributesData())
				where a.AttributeType.FullName == "BepInEx.BepInPlugin" && a.ConstructorArguments.Count == 3
				select a).ToArray();
			if (array.Length != 1 || (string)array[0].ConstructorArguments[0].Value != pluginId || (string)array[0].ConstructorArguments[2].Value != version)
			{
				throw new InvalidDataException("NM-Plugin-Metadaten passen nicht zur Registrierung.");
			}
		}
	}
	internal static class NmTrustKey
	{
		internal const string Xml = "<RSAKeyValue><Modulus>xCELlJ2yUiMqx5OpXf53bNgfoAnsVfpSj5co1uOOv6/hzYhSA8X8QYLKDdmhq1DpIEo7Xkey11ks+aIe4e5JaJxVfPOYTFLNYx9HE9AHhcNxOnilcSY/m+gkF4gH/EbymhAgtct/t6AayQ0ImH+QhATKDc/z6F1WYvr3sAhMCQviGkYE2KIS33DNwUAhhbyv08BafRzcKbOcRTe6b4fUnebvTi3O4HROhHIUIcTnFLiNZLUVyLTohphKI/VbZfo6nnB/z7g7OpxIMAU7+sWWDZak6EtZTuJa5hsYVqKTvvilEqE81J9J8UrmqK9dkR3Rhu8C/QQQJjQKRun8luHf2KOXMAOJRal/U+EyPnTCbdaMAVP2izn7it8a+PENkZA1bD34SNc4tYKnUmMyJtEnpN37sBY/BaOOSup0FohgegMsOrYA+/35H3DS5fb2RvJaRWuuiXHW2L2F0WOCak/c9UgHKNmeBEeZM/t0V6A5k7D7n2986YOohXCl4+c1xql7</Modulus><Exponent>AQAB</Exponent></RSAKeyValue>";
	}
}
namespace Nightmare.REPO.Core
{
	public sealed class AddonDefinition
	{
		internal Assembly? VerifiedOwner;

		private Action<AddonUi>? drawHome;

		public string Id { get; }

		public string Name { get; }

		public string Version { get; }

		public string Description { get; }

		public int RequiredApiMajor { get; }

		internal Action<AddonUi> Draw { get; }

		public Action<AddonUi>? DrawHome
		{
			get
			{
				return drawHome;
			}
			set
			{
				if (VerifiedOwner != null && value != null && value.Method.DeclaringType?.Assembly != VerifiedOwner)
				{
					throw new InvalidOperationException(CoreText.Get("api.view"));
				}
				drawHome = value;
			}
		}

		public AddonDefinition(string id, string name, string version, string description, Action<AddonUi> draw, int requiredApiMajor = 1)
		{
			if (string.IsNullOrWhiteSpace(id) || id.Length > 120 || id.Any((char c) => !char.IsLetterOrDigit(c) && c != '.' && c != '_' && c != '-'))
			{
				throw new ArgumentException("Use a stable plugin GUID as the addon ID.", "id");
			}
			if (string.IsNullOrWhiteSpace(name))
			{
				throw new ArgumentException("Addon name is required.", "name");
			}
			Id = id;
			Name = Clean(name, 60);
			Version = Clean(version, 30);
			Description = Clean(description, 400);
			Draw = draw ?? throw new ArgumentNullException("draw");
			RequiredApiMajor = requiredApiMajor;
		}

		internal static string Clean(string? text, int maximum)
		{
			return new string((text ?? "").Where((char c) => !char.IsControl(c)).Take(maximum).ToArray());
		}
	}
	public sealed class AddonHandle : IDisposable
	{
		private readonly Action remove;

		private readonly Action<string, float> notify;

		private readonly Action open;

		private readonly Action<string, Func<string, string?>> provider;

		public string Id { get; }

		public bool IsDisposed { get; private set; }

		internal AddonHandle(string id, Action remove, Action<string, float> notify, Action open, Action<string, Func<string, string?>> provider)
		{
			Id = id;
			this.remove = remove;
			this.notify = notify;
			this.open = open;
			this.provider = provider;
		}

		private void Check()
		{
			if (IsDisposed)
			{
				throw new ObjectDisposedException(Id);
			}
		}

		public void Notify(string message, float seconds = 8f)
		{
			Check();
			notify(message, seconds);
		}

		public void OpenPage()
		{
			Check();
			open();
		}

		public void SetContextProvider(string topic, Func<string, string?> getNote)
		{
			Check();
			provider(topic, getNote);
		}

		public void Dispose()
		{
			if (!IsDisposed)
			{
				remove();
				IsDisposed = true;
			}
		}
	}
	internal sealed class AddonEntry
	{
		internal readonly AddonDefinition Definition;

		internal AddonHandle Handle;

		internal string Fault = "";

		internal readonly Dictionary<string, Func<string, string?>> Providers = new Dictionary<string, Func<string, string>>();

		internal AddonEntry(AddonDefinition definition)
		{
			Definition = definition;
		}
	}
	internal sealed class AddonCatalog
	{
		private readonly Dictionary<string, AddonEntry> entries = new Dictionary<string, AddonEntry>(StringComparer.OrdinalIgnoreCase);

		private readonly Action<string, string, float> notify;

		private readonly Action<string> open;

		private readonly Action<string, Exception> error;

		private readonly Action validateAccess;

		private readonly HashSet<string> providerErrors = new HashSet<string>();

		internal int Revision { get; private set; }

		internal AddonEntry[] Entries => entries.Values.OrderBy<AddonEntry, string>((AddonEntry e) => e.Definition.Name, StringComparer.OrdinalIgnoreCase).ToArray();

		internal AddonCatalog(Action<string, string, float> notify, Action<string> open, Action<string, Exception> error, Action? validateAccess = null)
		{
			this.notify = notify;
			this.open = open;
			this.error = error;
			this.validateAccess = validateAccess ?? ((Action)delegate
			{
			});
		}

		internal AddonEntry? Find(string id)
		{
			if (!entries.TryGetValue(id, out AddonEntry value))
			{
				return null;
			}
			return value;
		}

		internal AddonHandle Register(AddonDefinition definition)
		{
			validateAccess();
			if (definition == null)
			{
				throw new ArgumentNullException("definition");
			}
			if (definition.RequiredApiMajor != 1)
			{
				throw new NotSupportedException("NM Core API major version mismatch.");
			}
			if (entries.ContainsKey(definition.Id))
			{
				throw new InvalidOperationException("Addon already registered: " + definition.Id);
			}
			AddonEntry entry = new AddonEntry(definition);
			entry.Handle = new AddonHandle(definition.Id, delegate
			{
				validateAccess();
				if (Find(definition.Id) == entry)
				{
					entries.Remove(definition.Id);
					int revision = Revision;
					Revision = revision + 1;
				}
			}, delegate(string message, float seconds)
			{
				notify(definition.Id, AddonDefinition.Clean(message, 300), float.IsNaN(seconds) ? 8f : Math.Max(2f, Math.Min(30f, seconds)));
			}, delegate
			{
				open(definition.Id);
			}, delegate(string topic, Func<string, string?> provider)
			{
				validateAccess();
				if (string.IsNullOrWhiteSpace(topic) || topic.Length > 120)
				{
					throw new ArgumentException("A short, versioned topic ID is required.");
				}
				if (provider == null)
				{
					throw new ArgumentNullException("provider");
				}
				if (definition.VerifiedOwner != null && provider.Method.DeclaringType?.Assembly != definition.VerifiedOwner)
				{
					throw new InvalidOperationException(CoreText.Get("api.provider"));
				}
				entry.Providers[topic] = provider;
			});
			entries.Add(definition.Id, entry);
			Revision++;
			return entry.Handle;
		}

		internal string[] GetNotes(string topic, string key)
		{
			List<string> list = new List<string>();
			AddonEntry[] array = Entries;
			foreach (AddonEntry addonEntry in array)
			{
				if (!addonEntry.Providers.TryGetValue(topic, out Func<string, string> value))
				{
					continue;
				}
				try
				{
					string text = value(key);
					if (!string.IsNullOrWhiteSpace(text))
					{
						list.Add(AddonDefinition.Clean(text, 400));
					}
				}
				catch (Exception arg)
				{
					if (providerErrors.Add(addonEntry.Definition.Id + ":" + topic))
					{
						error(addonEntry.Definition.Id, arg);
					}
				}
			}
			return list.ToArray();
		}

		internal void DisposeAll()
		{
			AddonEntry[] array = Entries;
			for (int i = 0; i < array.Length; i++)
			{
				array[i].Handle.Dispose();
			}
		}
	}
	public sealed class AddonUi : IDisposable
	{
		private readonly List<Texture2D> textures = new List<Texture2D>();

		private bool styled;

		public GUIStyle Body { get; private set; }

		public GUIStyle Small { get; private set; }

		public GUIStyle Heading { get; private set; }

		public GUIStyle Title { get; private set; }

		public GUIStyle Muted { get; private set; }

		public GUIStyle Notice { get; private set; }

		public GUIStyle Danger { get; private set; }

		public GUIStyle Good { get; private set; }

		public GUIStyle Panel { get; private set; }

		public GUIStyle Button { get; private set; }

		public GUIStyle Selected { get; private set; }

		public GUIStyle TextField { get; private set; }

		internal GUIStyle Window { get; private set; }

		internal AddonUi()
		{
		}

		private Texture2D Solid(Color color)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			Texture2D val = new Texture2D(1, 1)
			{
				hideFlags = (HideFlags)61
			};
			val.SetPixel(0, 0, color);
			val.Apply();
			textures.Add(val);
			return val;
		}

		private static GUIStyle Label(int size, Color color, bool wrap = false, FontStyle weight = (FontStyle)0)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Expected O, but got Unknown
			//IL_0047: Expected O, but got Unknown
			GUIStyle val = new GUIStyle(GUI.skin.label)
			{
				fontSize = size,
				richText = false,
				wordWrap = wrap,
				fontStyle = weight
			};
			val.normal.textColor = color;
			val.padding = new RectOffset(3, 3, 3, 3);
			return val;
		}

		internal void EnsureStyles()
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_0084: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Expected O, but got Unknown
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0155: Expected O, but got Unknown
			//IL_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Expected O, but got Unknown
			//IL_0165: Expected O, but got Unknown
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Expected O, but got Unknown
			//IL_01ab: Expected O, but got Unknown
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Expected O, but got Unknown
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Expected O, but got Unknown
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0256: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Expected O, but got Unknown
			//IL_026c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0271: Unknown result type (might be due to invalid IL or missing references)
			//IL_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_0296: Unknown result type (might be due to invalid IL or missing references)
			//IL_029c: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ab: Expected O, but got Unknown
			//IL_02b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Expected O, but got Unknown
			//IL_02de: Expected O, but got Unknown
			if (!styled)
			{
				Color val = default(Color);
				((Color)(ref val))..ctor(0.9f, 0.94f, 0.98f);
				Body = Label(15, val, wrap: true, (FontStyle)0);
				Small = Label(12, new Color(0.68f, 0.74f, 0.83f), wrap: true, (FontStyle)0);
				Heading = Label(16, val, wrap: true, (FontStyle)1);
				Title = Label(23, val, wrap: false, (FontStyle)1);
				Muted = Label(14, new Color(0.64f, 0.7f, 0.79f), wrap: true, (FontStyle)0);
				Notice = Label(14, new Color(1f, 0.76f, 0.36f), wrap: true, (FontStyle)0);
				Danger = Label(14, new Color(1f, 0.48f, 0.48f), wrap: true, (FontStyle)0);
				Good = Label(14, new Color(0.5f, 0.87f, 0.76f), wrap: true, (FontStyle)0);
				GUIStyle val2 = new GUIStyle(GUI.skin.box);
				val2.normal.background = Solid(new Color(0.09f, 0.12f, 0.17f));
				val2.padding = new RectOffset(12, 12, 10, 10);
				val2.margin = new RectOffset(0, 0, 0, 8);
				val2.border = new RectOffset();
				Panel = val2;
				GUIStyle val3 = new GUIStyle(Panel);
				val3.normal.background = Solid(new Color(0.045f, 0.065f, 0.1f, 0.99f));
				val3.padding = new RectOffset();
				Window = val3;
				GUIStyle val4 = new GUIStyle(GUI.skin.button)
				{
					fontSize = 14,
					richText = false,
					wordWrap = true,
					alignment = (TextAnchor)3,
					padding = new RectOffset(12, 12, 9, 9),
					margin = new RectOffset(0, 6, 2, 4)
				};
				val4.normal.background = Solid(new Color(0.15f, 0.2f, 0.28f));
				val4.normal.textColor = val;
				val4.hover.background = Solid(new Color(0.2f, 0.29f, 0.39f));
				val4.hover.textColor = Color.white;
				Button = val4;
				GUIStyle val5 = new GUIStyle(Button);
				val5.normal.background = Solid(new Color(0.1f, 0.3f, 0.32f));
				val5.normal.textColor = Color.white;
				Selected = val5;
				TextField = new GUIStyle(GUI.skin.textField)
				{
					fontSize = 16,
					richText = false,
					padding = new RectOffset(8, 8, 5, 5)
				};
				styled = true;
			}
		}

		public void Dispose()
		{
			foreach (Texture2D texture in textures)
			{
				Object.Destroy((Object)(object)texture);
			}
			textures.Clear();
			styled = false;
		}
	}
	public sealed class ChangeGate
	{
		private object[]? previous;

		private float sent;

		public bool Due(object[] payload, float now, float keepalive)
		{
			if (previous != null && !(now < sent) && !(now - sent >= keepalive))
			{
				return !Same(previous, payload);
			}
			return true;
		}

		public void Sent(object[] payload, float now)
		{
			previous = payload;
			sent = now;
		}

		public void Clear()
		{
			previous = null;
			sent = 0f;
		}

		public static bool Same(object? a, object? b)
		{
			if (a == b)
			{
				return true;
			}
			if (a is object[] array && b is object[] array2)
			{
				if (array.Length != array2.Length)
				{
					return false;
				}
				for (int i = 0; i < array.Length; i++)
				{
					if (!Same(array[i], array2[i]))
					{
						return false;
					}
				}
				return true;
			}
			return object.Equals(a, b);
		}
	}
	public enum CombatEventKind
	{
		EnemyDeath,
		PlayerDeath,
		Joined,
		Left,
		Bounty
	}
	public sealed class CombatEvent
	{
		public CombatEventKind Kind { get; }

		public string Id { get; }

		public string Name { get; }

		public EnemyParent? Enemy { get; }

		public EnemyHealth? Health { get; }

		public int Reward { get; }

		internal CombatEvent(CombatEventKind kind, string id, string name, EnemyParent? enemy = null, EnemyHealth? health = null, int reward = 0)
		{
			Kind = kind;
			Id = id;
			Name = CombatText.Clean(name);
			Enemy = enemy;
			Health = health;
			Reward = reward;
		}
	}
	public static class CombatEvents
	{
		private sealed class Listener : IDisposable
		{
			internal AddonHandle Owner;

			internal Action<CombatEvent> Handler;

			public void Dispose()
			{
				listeners.Remove(this);
			}
		}

		internal sealed class CombatRuntime : IInRoomCallbacks, IOnEventCallback, IDisposable
		{
			private const byte Code = 194;

			private const string Capability = "nm.combat.v1";

			private const string Magic = "nm.combat.reward.v1";

			private readonly Harmony harmony = new Harmony("nightmare.repo.core.combat");

			private readonly DeathCycles cycles = new DeathCycles();

			private readonly Dictionary<int, int> deathStamps = new Dictionary<int, int>();

			private readonly Dictionary<int, (EnemyHealth Health, UnityAction Handler)> deathListeners = new Dictionary<int, (EnemyHealth, UnityAction)>();

			private readonly HashSet<string> rewards = new HashSet<string>();

			private readonly Queue<string> rewardOrder = new Queue<string>();

			private object? room;

			private int scene = -1;

			private int master;

			private float nextScan;

			private string token = "";

			internal static CombatRuntime? Current;

			internal CombatRuntime()
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Expected O, but got Unknown
				//IL_0091: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c7: Expected O, but got Unknown
				//IL_00c7: Expected O, but got Unknown
				//IL_00c7: Expected O, but got Unknown
				//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
				//IL_0102: Expected O, but got Unknown
				//IL_0130: Unknown result type (might be due to invalid IL or missing references)
				//IL_013d: Expected O, but got Unknown
				//IL_016a: Unknown result type (might be due to invalid IL or missing references)
				//IL_017f: Unknown result type (might be due to invalid IL or missing references)
				//IL_018c: Expected O, but got Unknown
				//IL_018c: Expected O, but got Unknown
				Current = this;
				harmony.Patch((MethodBase)AccessTools.Method(typeof(EnemyHealth), "DeathImpulseRPC", (Type[])null, (Type[])null), new HarmonyMethod(typeof(CombatRuntime), "BeforeEnemyDeath", (Type[])null), new HarmonyMethod(typeof(CombatRuntime), "EnemyDied", (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(CombatRuntime), "AfterEnemyDeath", (Type[])null), (HarmonyMethod)null);
				harmony.Patch((MethodBase)AccessTools.Method(typeof(EnemyHealth), "OnSpawn", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(CombatRuntime), "EnemySpawned", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				harmony.Patch((MethodBase)AccessTools.Method(typeof(EnemyHealth), "Awake", (Type[])null, (Type[])null), (HarmonyMethod)null, new HarmonyMethod(typeof(CombatRuntime), "TrackHealth", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				harmony.Patch((MethodBase)AccessTools.Method(typeof(PlayerAvatar), "PlayerDeathRPC", (Type[])null, (Type[])null), new HarmonyMethod(typeof(CombatRuntime), "BeforePlayerDeath", (Type[])null), new HarmonyMethod(typeof(CombatRuntime), "PlayerDied", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				PhotonNetwork.AddCallbackTarget((object)this);
			}

			private static object? Read(object value, string name)
			{
				return CoreReflection.Field(value.GetType(), name)?.GetValue(value);
			}

			private static void EnemySpawned(EnemyHealth __instance)
			{
				Current?.cycles.Alive(((Object)__instance).GetInstanceID());
				TrackHealth(__instance);
			}

			private static void TrackHealth(EnemyHealth __instance)
			{
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				//IL_0058: Expected O, but got Unknown
				CombatRuntime current = Current;
				if (current == null || __instance.onDeath == null || current.deathListeners.ContainsKey(((Object)__instance).GetInstanceID()))
				{
					return;
				}
				UnityAction val = (UnityAction)delegate
				{
					if (Object.op_Implicit((Object)(object)__instance))
					{
						EnemyParent componentInParent = ((Component)__instance).GetComponentInParent<EnemyParent>();
						if (Object.op_Implicit((Object)(object)componentInParent))
						{
							current.ReportDeath(componentInParent, __instance);
						}
					}
				};
				__instance.onDeath.AddListener(val);
				current.deathListeners[((Object)__instance).GetInstanceID()] = (__instance, val);
			}

			private void ClearListeners()
			{
				foreach (var value in deathListeners.Values)
				{
					if (Object.op_Implicit((Object)(object)value.Health))
					{
						UnityEvent onDeath = value.Health.onDeath;
						if (onDeath != null)
						{
							onDeath.RemoveListener(value.Handler);
						}
					}
				}
				deathListeners.Clear();
			}

			private static void BeforeEnemyDeath(EnemyHealth __instance, PhotonMessageInfo _info, out bool __state)
			{
				//IL_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				object obj = Read(__instance, "dead");
				__state = (!(obj is bool) || !(bool)obj) && (!GameManager.Multiplayer() || (_info.Sender != null && _info.Sender.IsMasterClient));
				if (__state && Current != null && GameManager.Multiplayer())
				{
					Current.deathStamps[((Object)__instance).GetInstanceID()] = ((PhotonMessageInfo)(ref _info)).SentServerTimestamp;
				}
			}

			private static void AfterEnemyDeath(EnemyHealth __instance)
			{
				Current?.deathStamps.Remove(((Object)__instance).GetInstanceID());
			}

			private static void EnemyDied(EnemyHealth __instance, bool __state)
			{
				if (!__state || Current == null)
				{
					return;
				}
				object obj = Read(__instance, "dead");
				if (obj is bool && (bool)obj)
				{
					EnemyParent componentInParent = ((Component)__instance).GetComponentInParent<EnemyParent>();
					if (Object.op_Implicit((Object)(object)componentInParent))
					{
						Current.ReportDeath(componentInParent, __instance);
					}
				}
			}

			private void ReportDeath(EnemyParent parent, EnemyHealth health)
			{
				if (cycles.Die(((Object)health).GetInstanceID(), out var life))
				{
					PhotonView component = ((Component)parent).GetComponent<PhotonView>();
					int value;
					string text = (deathStamps.TryGetValue(((Object)health).GetInstanceID(), out value) ? ("t" + value) : ("l" + life));
					string id = CoreApi.Context.SceneName + ":" + ((Object.op_Implicit((Object)(object)component) && component.ViewID != 0) ? component.ViewID : ((Object)health).GetInstanceID()) + ":" + text;
					Emit(new CombatEvent(CombatEventKind.EnemyDeath, id, CombatText.Clean(parent.enemyName, CombatText.Clean(((Object)parent).name)), parent, health));
				}
			}

			private static void BeforePlayerDeath(PlayerAvatar __instance, out bool __state)
			{
				object obj = Read(__instance, "deadSet");
				__state = obj is bool && (bool)obj;
			}

			private static void PlayerDied(PlayerAvatar __instance, bool __state)
			{
				if (!__state)
				{
					object obj = Read(__instance, "deadSet");
					if (obj is bool && (bool)obj)
					{
						Emit(new CombatEvent(CombatEventKind.PlayerDeath, "player:" + ((Object)__instance).GetInstanceID(), SemiFunc.PlayerGetName(__instance)));
					}
				}
			}

			internal void Tick()
			{
				//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d8: Expected O, but got Unknown
				int num = CoreApi.Context.Scene;
				Player masterClient = PhotonNetwork.MasterClient;
				int num2 = ((masterClient != null) ? masterClient.ActorNumber : 0);
				if (scene != num || room != PhotonNetwork.CurrentRoom || master != num2)
				{
					ClearListeners();
					cycles.Clear();
					deathStamps.Clear();
					rewards.Clear();
					rewardOrder.Clear();
					nextScan = 0f;
					scene = num;
					room = PhotonNetwork.CurrentRoom;
					master = num2;
					token = Guid.NewGuid().ToString("N");
					if (PhotonNetwork.InRoom)
					{
						PhotonNetwork.LocalPlayer.SetCustomProperties(new Hashtable { [(object)"nm.combat.v1"] = token }, (Hashtable)null, (WebFlags)null);
					}
				}
				if (Time.unscaledTime < nextScan)
				{
					return;
				}
				nextScan = Time.unscaledTime + 0.5f;
				if (!Object.op_Implicit((Object)(object)EnemyDirector.instance) || EnemyDirector.instance.enemiesSpawned == null)
				{
					return;
				}
				foreach (EnemyParent item in EnemyDirector.instance.enemiesSpawned)
				{
					if (!Object.op_Implicit((Object)(object)item))
					{
						continue;
					}
					object? obj2 = Read(item, "Enemy");
					Enemy val = (Enemy)((obj2 is Enemy) ? obj2 : null);
					EnemyHealth val2 = (EnemyHealth)(((Object)(object)val != (Object)null && Object.op_Implicit((Object)(object)val)) ? /*isinst with value type is only supported in some contexts*/: null);
					if (!((Object)(object)val2 == (Object)null) && Object.op_Implicit((Object)(object)val2))
					{
						TrackHealth(val2);
						object obj = Read(val2, "dead");
						if ((!(obj is bool) || !(bool)obj) && Read(val2, "healthCurrent") is int num3 && num3 > 0)
						{
							cycles.Alive(((Object)val2).GetInstanceID());
						}
					}
				}
				int[] array = deathListeners.Keys.Where((int id) => !Object.op_Implicit((Object)(object)deathListeners[id].Health)).ToArray();
				foreach (int key in array)
				{
					deathListeners.Remove(key);
				}
			}

			public void OnPlayerEnteredRoom(Player player)
			{
				Emit(new CombatEvent(CombatEventKind.Joined, "actor:" + player.ActorNumber, player.NickName));
			}

			public void OnPlayerLeftRoom(Player player)
			{
				Emit(new CombatEvent(CombatEventKind.Left, "actor:" + player.ActorNumber, player.NickName));
			}

			public void OnRoomPropertiesUpdate(Hashtable changed)
			{
			}

			public void OnPlayerPropertiesUpdate(Player player, Hashtable changed)
			{
			}

			public void OnMasterClientSwitched(Player player)
			{
			}

			internal void Send(CombatEvent e)
			{
				//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b6: Expected O, but got Unknown
				//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
				if (!PhotonNetwork.InRoom || !PhotonNetwork.IsMasterClient || PhotonNetwork.CurrentRoom == null)
				{
					return;
				}
				foreach (Player value in PhotonNetwork.CurrentRoom.Players.Values)
				{
					if (!value.IsLocal && value.CustomProperties[(object)"nm.combat.v1"] is string { Length: 32 } text)
					{
						object[] obj = new object[6]
						{
							"nm.combat.reward.v1",
							text,
							CoreApi.Context.SceneName,
							e.Id,
							e.Name,
							e.Reward
						};
						RaiseEventOptions val = new RaiseEventOptions();
						val.TargetActors = new int[1] { value.ActorNumber };
						val.CachingOption = (EventCaching)0;
						if (PhotonNetwork.RaiseEvent((byte)194, (object)obj, val, SendOptions.SendReliable))
						{
							CoreTraffic.Record("Bounty-Anzeige", 100 + e.Id.Length * 2 + e.Name.Length * 2);
						}
					}
				}
			}

			public void OnEvent(EventData e)
			{
				if (e.Code != 194 || !PhotonNetwork.InRoom || PhotonNetwork.IsMasterClient)
				{
					return;
				}
				int sender = e.Sender;
				Player masterClient = PhotonNetwork.MasterClient;
				if (sender == ((masterClient != null) ? new int?(masterClient.ActorNumber) : ((int?)null)) && room == PhotonNetwork.CurrentRoom && e.CustomData is object[] array && array.Length == 6 && object.Equals(array[0], "nm.combat.reward.v1") && object.Equals(array[1], token) && object.Equals(array[2], CoreApi.Context.SceneName) && array[3] is string { Length: <=200 } text && array[4] is string { Length: <=100 } text2 && array[5] is int num && num > 0 && num <= 1000000 && rewards.Add(text))
				{
					rewardOrder.Enqueue(text);
					if (rewardOrder.Count > 256)
					{
						rewards.Remove(rewardOrder.Dequeue());
					}
					Emit(new CombatEvent(CombatEventKind.Bounty, text, text2, null, null, num));
				}
			}

			public void Dispose()
			{
				//IL_0023: Unknown result type (might be due to invalid IL or missing references)
				//IL_002e: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Expected O, but got Unknown
				ClearListeners();
				harmony.UnpatchSelf();
				PhotonNetwork.RemoveCallbackTarget((object)this);
				if (PhotonNetwork.InRoom)
				{
					PhotonNetwork.LocalPlayer.SetCustomProperties(new Hashtable { [(object)"nm.combat.v1"] = null }, (Hashtable)null, (WebFlags)null);
				}
				Current = null;
			}
		}

		private static readonly List<Listener> listeners = new List<Listener>();

		private static CombatRuntime? runtime;

		private static bool faulted;

		[MethodImpl(MethodImplOptions.NoInlining)]
		public static IDisposable Subscribe(AddonHandle owner, Action<CombatEvent> handler)
		{
			CoreServices.Validate(owner, Assembly.GetCallingAssembly());
			if (handler == null || handler.Method.DeclaringType?.Assembly != Assembly.GetCallingAssembly())
			{
				throw new ArgumentException(CoreText.Get("api.handler"));
			}
			Listener listener = new Listener
			{
				Owner = owner,
				Handler = handler
			};
			listeners.Add(listener);
			return listener;
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		public static void PublishBounty(AddonHandle owner, CombatEvent death, int dollars)
		{
			CoreServices.Validate(owner, Assembly.GetCallingAssembly());
			if (!(owner.Id != "nightmare.repo.bounty") && death.Kind == CombatEventKind.EnemyDeath && SemiFunc.IsMasterClientOrSingleplayer() && dollars > 0)
			{
				CombatEvent e = new CombatEvent(CombatEventKind.Bounty, death.Id, death.Name, null, null, dollars);
				Emit(e);
				runtime?.Send(e);
			}
		}

		internal static void Tick()
		{
			listeners.RemoveAll((Listener l) => l.Owner.IsDisposed);
			if (listeners.Count == 0)
			{
				runtime?.Dispose();
				runtime = null;
			}
			else
			{
				if (faulted)
				{
					return;
				}
				try
				{
					if (runtime == null)
					{
						runtime = new CombatRuntime();
					}
					runtime.Tick();
				}
				catch (Exception ex)
				{
					faulted = true;
					CombatRuntime.Current?.Dispose();
					runtime = null;
					CoreRuntime.Report("nightmare.repo.core/combat", ex);
				}
			}
		}

		internal static void Emit(CombatEvent e)
		{
			Listener[] array = listeners.ToArray();
			foreach (Listener l in array)
			{
				if (!l.Owner.IsDisposed)
				{
					CoreRuntime.Run(l.Owner.Id, delegate
					{
						l.Handler(e);
					});
				}
			}
		}

		internal static void Reset()
		{
			runtime?.Dispose();
			runtime = null;
			listeners.Clear();
			faulted = false;
		}
	}
	public static class CombatText
	{
		public static string Clean(string? value, string fallback = "Unbekannt")
		{
			string text = new string((value ?? "").Where((char c) => !char.IsControl(c) && c != '<' && c != '>').Take(100).ToArray()).Replace("(Clone)", "").Trim();
			if (text.Length != 0)
			{
				return text;
			}
			return fallback;
		}
	}
	internal sealed class DeathCycles
	{
		private readonly Dictionary<int, (bool Dead, int Life)> states = new Dictionary<int, (bool, int)>();

		internal void Alive(int id)
		{
			if (states.TryGetValue(id, out (bool, int) value))
			{
				if (value.Item1)
				{
					states[id] = (false, value.Item2 + 1);
				}
			}
			else
			{
				states[id] = (false, 1);
			}
		}

		internal bool Die(int id, out int life)
		{
			if (!states.TryGetValue(id, out (bool, int) value))
			{
				value = (false, 1);
			}
			life = value.Item2;
			if (value.Item1)
			{
				return false;
			}
			states[id] = (true, life);
			return true;
		}

		internal void Keep(HashSet<int> ids)
		{
			int[] array = states.Keys.Where((int id) => !ids.Contains(id)).ToArray();
			foreach (int key in array)
			{
				states.Remove(key);
			}
		}

		internal void Clear()
		{
			states.Clear();
		}
	}
	public static class ConfigurationMigration
	{
		public static void BindWithLegacy(ConfigFile target, string legacyPluginGuid, Action bindDefinitions)
		{
			if (legacyPluginGuid.Any((char c) => !char.IsLetterOrDigit(c) && c != '.' && c != '_' && c != '-'))
			{
				throw new ArgumentException("Expected a plugin GUID.", "legacyPluginGuid");
			}
			Dictionary<string, string> dictionary = IniValues.Read(target.ConfigFilePath);
			Dictionary<string, string> dictionary2 = IniValues.Read(Path.Combine(Paths.ConfigPath, legacyPluginGuid + ".cfg"));
			bool saveOnConfigSet = target.SaveOnConfigSet;
			target.SaveOnConfigSet = false;
			try
			{
				bindDefinitions();
				ConfigEntryBase[] array = ((IEnumerable<KeyValuePair<ConfigDefinition, ConfigEntryBase>>)target).Select((KeyValuePair<ConfigDefinition, ConfigEntryBase> pair) => pair.Value).ToArray();
				foreach (ConfigEntryBase val in array)
				{
					string key = IniValues.Key(val.Definition.Section, val.Definition.Key);
					if (!dictionary.ContainsKey(key) && dictionary2.TryGetValue(key, out var value) && value != null)
					{
						val.SetSerializedValue(value);
					}
				}
				target.Save();
			}
			finally
			{
				target.SaveOnConfigSet = saveOnConfigSet;
			}
		}
	}
	public static class CoreApi
	{
		public const string PluginGuid = "nightmare.repo.core";

		public const int ApiMajor = 1;

		public const string Version = "2.10.0";

		private static CorePlugin Runtime => CorePlugin.Instance ?? throw new InvalidOperationException("NM_Core_REPO is not loaded. Declare a BepInDependency on nightmare.repo.core");

		public static bool IsAvailable => (Object)(object)CorePlugin.Instance != (Object)null;

		public static string Language => CoreText.Language;

		public static string ToggleKey => Runtime.ToggleKey;

		public static bool IsOpen => Runtime.Visible;

		public static SessionInfo Session => CoreSession.Current;

		public static GameContext Context => CoreSession.ReadContext();

		public static string? GetPeerVersion(int actor, string pluginId)
		{
			Runtime.AssertMainThread();
			return Runtime.Peers.VersionOf(actor, pluginId);
		}

		public static bool OpenAddon(string id)
		{
			Runtime.AssertMainThread();
			if (Runtime.Catalog.Find(id) == null)
			{
				return false;
			}
			Runtime.Selected = id;
			Runtime.SetVisible(value: true);
			return true;
		}

		public static IReadOnlyList<LoadedPlugin> GetLocalPlugins()
		{
			Runtime.AssertMainThread();
			return LocalPluginInventory.Snapshot;
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		public static AddonHandle Register(AddonDefinition definition)
		{
			Runtime.AssertMainThread();
			if (definition == null)
			{
				throw new ArgumentNullException("definition");
			}
			Assembly callingAssembly = Assembly.GetCallingAssembly();
			try
			{
				NmSignature.VerifyAddon(callingAssembly, definition.Id, definition.Version);
				if (definition.Draw.Method.DeclaringType?.Assembly != callingAssembly || (definition.DrawHome != null && definition.DrawHome.Method.DeclaringType?.Assembly != callingAssembly))
				{
					throw new InvalidDataException(CoreText.Get("api.unsignedview"));
				}
				definition.VerifiedOwner = callingAssembly;
				return Runtime.Catalog.Register(definition);
			}
			catch (Exception ex)
			{
				Runtime.RejectAddon(definition.Id, ex);
				throw new InvalidOperationException(CoreText.Get("api.signature") + definition.Id + ": " + ex.Message, ex);
			}
		}

		public static IReadOnlyList<AddonDefinition> GetLoadedAddons()
		{
			Runtime.AssertMainThread();
			return Array.AsReadOnly(Runtime.Catalog.Entries.Select((AddonEntry e) => e.Definition).ToArray());
		}

		public static IReadOnlyList<string> GetContextNotes(string topic, string key)
		{
			Runtime.AssertMainThread();
			return Array.AsReadOnly(Runtime.Catalog.GetNotes(topic, key));
		}
	}
	internal sealed class CoreLanguageService : IDisposable
	{
		private readonly ConfigEntry<CoreLanguage> selection;

		private LocalizationManager? manager;

		private LocaleAsset? locale;

		private float nextCheck;

		private string? gameCode;

		internal CoreLanguageService(ConfigFile config)
		{
			selection = config.Bind<CoreLanguage>("Bedienung", "Sprache", CoreLanguage.Automatic, CoreText.Help("language.config"));
			selection.SettingChanged += SelectionChanged;
			Tick();
		}

		internal void Tick()
		{
			if (Time.unscaledTime < nextCheck)
			{
				return;
			}
			nextCheck = Time.unscaledTime + 0.5f;
			LocalizationManager instance = LocalizationManager.instance;
			if (manager != instance)
			{
				if (Object.op_Implicit((Object)(object)manager))
				{
					manager.RemoveLocalizationChangedCallback((Action)Refresh);
				}
				manager = instance;
				if (Object.op_Implicit((Object)(object)manager))
				{
					manager.AddLocalizationChangedCallback((Action)Refresh);
				}
				Refresh();
			}
			else if (locale != (Object.op_Implicit((Object)(object)manager) ? manager.ActiveLocale : null) || gameCode == null)
			{
				Refresh();
			}
		}

		private void SelectionChanged(object? sender, EventArgs e)
		{
			CoreText.Select(selection.Value, gameCode);
		}

		private void Refresh()
		{
			locale = (Object.op_Implicit((Object)(object)manager) ? manager.ActiveLocale : null);
			gameCode = null;
			if (Object.op_Implicit((Object)(object)manager) && Object.op_Implicit((Object)(object)locale))
			{
				foreach (KeyValuePair<string, LocaleAsset> locale in manager.Locales)
				{
					if (locale.Value == this.locale)
					{
						gameCode = locale.Key;
						break;
					}
				}
			}
			CoreText.Select(selection.Value, gameCode);
		}

		internal void Draw(AddonUi ui)
		{
			GUILayout.Label(CoreText.Get("language.title"), ui.Heading, Array.Empty<GUILayoutOption>());
			GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
			try
			{
				Pick(CoreLanguage.Automatic, CoreText.Get("language.auto"), ui);
				Pick(CoreLanguage.Deutsch, "Deutsch", ui);
				Pick(CoreLanguage.English, "English", ui);
			}
			finally
			{
				GUILayout.EndHorizontal();
			}
			GUILayout.Label(CoreText.Format("language.active", (CoreText.Language == "de") ? "Deutsch" : "English"), ui.Small, Array.Empty<GUILayoutOption>());
			GUILayout.Label(CoreText.Get("language.help"), ui.Small, Array.Empty<GUILayoutOption>());
			GUILayout.Space(12f);
		}

		private void Pick(CoreLanguage value, string label, AddonUi ui)
		{
			if (GUILayout.Button(((selection.Value == value) ? "✓ " : "") + label, (selection.Value == value) ? ui.Selected : ui.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(190f) }) && selection.Value != value)
			{
				selection.Value = value;
			}
		}

		public void Dispose()
		{
			selection.SettingChanged -= SelectionChanged;
			if (Object.op_Implicit((Object)(object)manager))
			{
				manager.RemoveLocalizationChangedCallback((Action)Refresh);
			}
			manager = null;
			locale = null;
			CoreText.Select(CoreLanguage.Automatic, null);
		}
	}
	[BepInPlugin("nightmare.repo.core", "NM_Core_REPO", "2.10.0")]
	[BepInProcess("REPO.exe")]
	[BepInIncompatibility("nickz.repo.statwatch")]
	public sealed class CorePlugin : BaseUnityPlugin
	{
		internal static CorePlugin? Instance;

		internal AddonCatalog Catalog;

		internal LobbyPrefixes Prefixes;

		internal PlayerNames Names;

		internal PeerPresence Peers;

		private ServerListPresence servers;

		internal CoreLanguageService Languages;

		internal bool Visible;

		internal string Selected = "";

		internal readonly Dictionary<string, string> RejectedAddons = new Dictionary<string, string>();

		private ConfigEntry<KeyCode> key;

		private ConfigEntry<float> scale;

		private ConfigEntry<bool> sessionOverlay;

		private CoreWindow window;

		private int mainThread;

		private bool capturedCursor;

		private bool oldCursorVisible;

		private CursorLockMode oldCursorMode;

		private Action prefixTick;

		private Action peersTick;

		private Action serversTick;

		internal string ToggleKey => ((object)key.Value/*cast due to .constrained prefix*/).ToString();

		internal void RejectAddon(string id, Exception ex)
		{
			if (RejectedAddons.Count < 30 || RejectedAddons.ContainsKey(id))
			{
				RejectedAddons[id] = AddonDefinition.Clean(ex.Message, 240);
			}
			ReportError(id, ex);
		}

		private void Awake()
		{
			Instance = this;
			mainThread = Thread.CurrentThread.ManagedThreadId;
			Languages = new CoreLanguageService(((BaseUnityPlugin)this).Config);
			ConfigurationMigration.BindWithLegacy(((BaseUnityPlugin)this).Config, "nickz.repo.statwatch", delegate
			{
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Expected O, but got Unknown
				key = ((BaseUnityPlugin)this).Config.Bind<KeyCode>("Bedienung", "Taste", (KeyCode)288, CoreText.Help("config.key"));
				scale = ((BaseUnityPlugin)this).Config.Bind<float>("Bedienung", "UISkalierung", 1f, new ConfigDescription(CoreText.Help("config.scale"), (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.75f, 1.75f), Array.Empty<object>()));
			});
			window = new CoreWindow(this);
			sessionOverlay = ((BaseUnityPlugin)this).Config.Bind<bool>("Anzeige", "RolleUndMap", true, CoreText.Help("config.overlay"));
			Catalog = new AddonCatalog(delegate(string id, string message, float seconds)
			{
				AssertMainThread();
				window.Notify(id, message, seconds);
			}, delegate(string id)
			{
				AssertMainThread();
				Selected = id;
				SetVisible(value: true);
			}, ReportError, AssertMainThread);
			Prefixes = new LobbyPrefixes(this);
			Names = new PlayerNames(this);
			Peers = new PeerPresence(this);
			servers = new ServerListPresence(this);
			prefixTick = Prefixes.Tick;
			peersTick = Peers.Tick;
			serversTick = servers.Tick;
			((BaseUnityPlugin)this).Logger.LogInfo((object)("NM_Core_REPO API v1 ready. " + ToggleKey + " opens the addon menu."));
		}

		internal void AssertMainThread()
		{
			if (Thread.CurrentThread.ManagedThreadId != mainThread)
			{
				throw new InvalidOperationException("NM Core API must be called from Unity's main thread.");
			}
		}

		internal void ReportError(string id, Exception ex)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)("Addon " + id + ": " + ex));
		}

		private void Start()
		{
			LocalPluginInventory.Refresh();
		}

		private void Update()
		{
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			CoreRuntime.Run("nightmare.repo.core/language", Languages.Tick);
			CoreRuntime.Run("nightmare.repo.core/session", CoreSession.Tick);
			CoreRuntime.Run("nightmare.repo.core/prefixes", prefixTick);
			CoreRuntime.Run("nightmare.repo.core/combat", CombatEvents.Tick);
			CoreRuntime.Run("nightmare.repo.core/peers", peersTick);
			CoreRuntime.Run("nightmare.repo.core/servers", serversTick);
			if (Input.GetKeyDown(key.Value) && SemiFunc.NoTextInputsActive())
			{
				SetVisible(!Visible);
			}
			if (Visible && Input.GetKeyDown((KeyCode)27))
			{
				SetVisible(value: false);
			}
			if (Visible)
			{
				BlockLocalInput();
			}
		}

		private static void BlockLocalInput()
		{
			if ((Object)(object)GameDirector.instance != (Object)null)
			{
				GameDirector.instance.SetDisableInput(0.15f);
				GameDirector.instance.SetDisableEscMenu(0.15f);
			}
			if ((Object)(object)PlayerController.instance != (Object)null)
			{
				PlayerController.instance.InputDisable(0.15f);
			}
			if ((Object)(object)CameraAim.Instance != (Object)null)
			{
				CameraAim.Instance.OverrideAimStop();
			}
		}

		private void LateUpdate()
		{
			if (Visible)
			{
				BlockLocalInput();
				if ((Object)(object)CursorManager.instance != (Object)null)
				{
					CursorManager.instance.Unlock(0.15f);
				}
				Cursor.lockState = (CursorLockMode)0;
				Cursor.visible = true;
			}
		}

		internal void SetVisible(bool value)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			if (Visible != value)
			{
				Visible = value;
				if (value)
				{
					oldCursorVisible = Cursor.visible;
					oldCursorMode = Cursor.lockState;
					capturedCursor = true;
				}
				else
				{
					RestoreCursor();
				}
			}
		}

		private void RestoreCursor()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if (capturedCursor)
			{
				Cursor.visible = oldCursorVisible;
				Cursor.lockState = oldCursorMode;
				capturedCursor = false;
			}
		}

		private void OnGUI()
		{
			window?.Draw(scale.Value);
			if (sessionOverlay.Value && !Visible)
			{
				CoreSession.DrawOverlay();
			}
		}

		internal void DrawSession(AddonUi ui)
		{
			GUILayout.Label(CoreApi.Session.Description, ui.Good, Array.Empty<GUILayoutOption>());
			if (GUILayout.Button((sessionOverlay.Value ? "✓ " : "○ ") + CoreText.Get("session.toggle"), ui.Button, Array.Empty<GUILayoutOption>()))
			{
				sessionOverlay.Value = !sessionOverlay.Value;
			}
		}

		private void OnDisable()
		{
			Visible = false;
			RestoreCursor();
		}

		private void OnDestroy()
		{
			Visible = false;
			RestoreCursor();
			CombatEvents.Reset();
			servers?.Dispose();
			Peers?.Dispose();
			Catalog?.DisposeAll();
			window?.Dispose();
			Prefixes?.Dispose();
			Names?.Dispose();
			CoreServices.Reset();
			Languages?.Dispose();
			CoreSession.Reset();
			CoreRuntime.Reset();
			if ((Object)(object)Instance == (Object)(object)this)
			{
				Instance = null;
			}
		}
	}
	public static class CoreReflection
	{
		private static readonly Dictionary<(Type, string), FieldInfo?> fields = new Dictionary<(Type, string), FieldInfo>();

		public static FieldInfo? Field(Type type, string name)
		{
			(Type, string) key = (type, name);
			if (fields.TryGetValue(key, out FieldInfo value))
			{
				return value;
			}
			value = AccessTools.Field(type, name);
			if (fields.Count < 1024)
			{
				fields.Add(key, value);
			}
			return value;
		}
	}
	public static class CoreRuntime
	{
		private static readonly Dictionary<string, string> faults;

		private static readonly Dictionary<string, Tuple<string, string>> details;

		public static IReadOnlyDictionary<string, string> Faults { get; }

		static CoreRuntime()
		{
			faults = new Dictionary<string, string>(StringComparer.Ordinal);
			details = new Dictionary<string, Tuple<string, string>>(StringComparer.Ordinal);
			Faults = new ReadOnlyDictionary<string, string>(faults);
			CoreText.Changed += RefreshMessages;
		}

		public static bool IsPaused(string id)
		{
			return faults.ContainsKey(id);
		}

		public static string Message(string id)
		{
			if (!faults.TryGetValue(id, out string value))
			{
				return "";
			}
			return value;
		}

		public static bool Run(string id, Action worker)
		{
			if (IsPaused(id))
			{
				return false;
			}
			try
			{
				worker();
				return true;
			}
			catch (Exception ex) when (ex.GetType().FullName != "UnityEngine.ExitGUIException")
			{
				Report(id, ex);
				return false;
			}
		}

		public static bool IsCompatibilityError(Exception ex)
		{
			if (!(ex is MissingMemberException) && !(ex is TypeLoadException) && !(ex is BadImageFormatException) && !(ex is FileNotFoundException) && !(ex is FileLoadException))
			{
				if (ex.InnerException != null)
				{
					return IsCompatibilityError(ex.InnerException);
				}
				return false;
			}
			return true;
		}

		public static void Report(string id, Exception ex)
		{
			if (!faults.ContainsKey(id))
			{
				string text = (IsCompatibilityError(ex) ? "runtime.compatibility" : "runtime.failure");
				details.Add(id, Tuple.Create(text, AddonDefinition.Clean(ex.Message, 240)));
				faults.Add(id, CoreText.Format("runtime.paused", CoreText.Get(text), details[id].Item2));
				CorePlugin.Instance?.ReportError(id, ex);
			}
		}

		private static void RefreshMessages()
		{
			foreach (KeyValuePair<string, Tuple<string, string>> detail in details)
			{
				faults[detail.Key] = CoreText.Format("runtime.paused", CoreText.Get(detail.Value.Item1), detail.Value.Item2);
			}
		}

		internal static void Reset()
		{
			faults.Clear();
			details.Clear();
		}
	}
	public static class CoreSceneObjects<T> where T : Component
	{
		private static IReadOnlyList<T> items = Array.Empty<T>();

		private static int scene = int.MinValue;

		private static float next;

		public static IReadOnlyList<T> Get()
		{
			int num = CoreApi.Context.Scene;
			if (scene == num && Time.unscaledTime < next)
			{
				return items;
			}
			scene = num;
			next = Time.unscaledTime + 2f;
			items = Array.AsReadOnly(Object.FindObjectsOfType<T>(true));
			return items;
		}
	}
	public sealed class OffsetRequest
	{
		public string SaveId { get; }

		public string PlayerId { get; }

		public string Stat { get; }

		public int Actual { get; }

		public OffsetRequest(string saveId, string playerId, string stat, int actual)
		{
			SaveId = saveId;
			PlayerId = playerId;
			Stat = stat;
			Actual = actual;
		}
	}
	public sealed class OffsetResult
	{
		public bool Ready { get; }

		public bool Known { get; }

		public int Offset { get; }

		public bool PersonalChange { get; }

		public OffsetResult(bool ready, bool known, int offset, bool personalChange = false)
		{
			Ready = ready;
			Known = known;
			Offset = offset;
			PersonalChange = personalChange;
		}
	}
	public static class CoreServices
	{
		private sealed class Provider
		{
			internal AddonHandle Handle;

			internal Func<OffsetRequest, OffsetResult> Read;

			internal bool ErrorReported;
		}

		private static readonly Dictionary<string, Provider> offsets = new Dictionary<string, Provider>();

		private static AddonHandle? historyOwner;

		private static Func<string, UpgradeHistorySnapshot?>? historyReader;

		private static bool historyError;

		internal static readonly Dictionary<string, string> Prefixes = new Dictionary<string, string>();

		public static bool HasOffsetProvider
		{
			get
			{
				CorePlugin.Instance?.AssertMainThread();
				if (offsets.TryGetValue("nightmare.repo.hosttools", out Provider value))
				{
					return !value.Handle.IsDisposed;
				}
				return false;
			}
		}

		internal static void Validate(AddonHandle owner, Assembly caller)
		{
			CorePlugin corePlugin = CorePlugin.Instance ?? throw new InvalidOperationException(CoreText.Get("api.missing"));
			corePlugin.AssertMainThread();
			if (owner == null || owner.IsDisposed || corePlugin.Catalog.Find(owner.Id)?.Handle != owner || corePlugin.Catalog.Find(owner.Id)?.Definition.VerifiedOwner != caller)
			{
				throw new InvalidOperationException(CoreText.Get("api.owner"));
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		public static void RegisterOffsets(AddonHandle owner, Func<OffsetRequest, OffsetResult> provider)
		{
			Assembly callingAssembly = Assembly.GetCallingAssembly();
			Validate(owner, callingAssembly);
			if (owner.Id != "nightmare.repo.hosttools" || provider.Method.DeclaringType?.Assembly != callingAssembly)
			{
				throw new InvalidOperationException(CoreText.Get("api.offset"));
			}
			offsets[owner.Id] = new Provider
			{
				Handle = owner,
				Read = provider
			};
		}

		public static OffsetResult GetOffset(OffsetRequest request)
		{
			CorePlugin.Instance?.AssertMainThread();
			if (!offsets.TryGetValue("nightmare.repo.hosttools", out Provider value) || value.Handle.IsDisposed)
			{
				return new OffsetResult(ready: true, known: false, 0);
			}
			try
			{
				return value.Read(request);
			}
			catch (Exception ex)
			{
				if (!value.ErrorReported)
				{
					CorePlugin.Instance?.ReportError(value.Handle.Id, ex);
				}
				value.ErrorReported = true;
				return new OffsetResult(ready: false, known: false, 0);
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		public static void RegisterLobbyPrefix(AddonHandle owner, string defaultText)
		{
			Validate(owner, Assembly.GetCallingAssembly());
			Prefixes[owner.Id] = PrefixText.Clean(defaultText);
		}

		[MethodImpl(MethodImplOptions.NoInlining)]
		public static void RegisterUpgradeHistory(AddonHandle owner, Func<string, UpgradeHistorySnapshot?> reader)
		{
			Assembly callingAssembly = Assembly.GetCallingAssembly();
			Validate(owner, callingAssembly);
			if (owner.Id != "nightmare.repo.upgradeshare" || reader.Method.DeclaringType?.Assembly != callingAssembly)
			{
				throw new InvalidOperationException(CoreText.Get("api.history"));
			}
			historyOwner = owner;
			historyReader = reader;
			historyError = false;
		}

		public static UpgradeHistorySnapshot? GetUpgradeHistory(string playerId)
		{
			CorePlugin.Instance?.AssertMainThread();
			if (historyOwner == null || historyOwner.IsDisposed || historyReader == null)
			{
				return null;
			}
			try
			{
				return historyReader(playerId);
			}
			catch (Exception ex)
			{
				if (!historyError)
				{
					CorePlugin.Instance?.ReportError(historyOwner.Id, ex);
				}
				historyError = true;
				return null;
			}
		}

		internal static void Reset()
		{
			offsets.Clear();
			Prefixes.Clear();
			historyOwner = null;
			historyReader = null;
			historyError = false;
		}
	}
	internal static class CoreSession
	{
		private static ContextTracker tracker = new ContextTracker();

		private static GameContext? displayed;

		private static float next;

		private static GUIStyle? style;

		internal static SessionInfo Current { get; private set; } = Empty();

		internal static GameContext ReadContext()
		{
			string name;
			int scene = SceneAdapter.Read(out name);
			RunManager instance = RunManager.instance;
			StatsManager instance2 = StatsManager.instance;
			ContextTracker contextTracker = tracker;
			string name2 = name;
			Room currentRoom = PhotonNetwork.CurrentRoom;
			Dictionary<string, int> nextValues = (Object.op_Implicit((Object)(object)instance2) ? instance2.runStats : null);
			Player masterClient = PhotonNetwork.MasterClient;
			return contextTracker.Read(scene, name2, currentRoom, instance, instance2, nextValues, (masterClient != null) ? masterClient.ActorNumber : 0, Object.op_Implicit((Object)(object)instance) ? instance.levelsCompleted : (-1));
		}

		private static SessionInfo Empty()
		{
			return new SessionInfo("Menü", "", "Keine Map geladen", "", authority: false, ready: false, -1);
		}

		internal static void Reset()
		{
			Current = Empty();
			next = 0f;
			tracker = new ContextTracker();
			displayed = null;
		}

		internal static void Tick()
		{
			GameContext gameContext = ReadContext();
			if (gameContext != displayed || !(Time.unscaledTime < next))
			{
				displayed = gameContext;
				next = Time.unscaledTime + 0.5f;
				RunManager instance = RunManager.instance;
				Level val = (Object.op_Implicit((Object)(object)instance) ? instance.levelCurrent : null);
				bool flag = Object.op_Implicit((Object)(object)GameManager.instance) && Object.op_Implicit((Object)(object)instance) && Object.op_Implicit((Object)(object)val) && (Object)(object)val != (Object)(object)instance.levelMainMenu && (Object)(object)val != (Object)(object)instance.levelSplashScreen;
				bool flag2 = flag && SemiFunc.IsMultiplayer();
				bool flag3 = flag && (!flag2 || (PhotonNetwork.InRoom && PhotonNetwork.IsMasterClient));
				Current = new SessionInfo((!flag) ? "Menü" : ((!flag2) ? "Einzelspieler" : ((!PhotonNetwork.InRoom) ? "Verbindung wird aufgebaut" : (flag3 ? "Host" : "Mitspieler"))), version: (!flag2 || !PhotonNetwork.InRoom || PhotonNetwork.MasterClient == null) ? "" : (CorePlugin.Instance?.Peers.VersionOf(PhotonNetwork.MasterClient.ActorNumber, "nightmare.repo.core") ?? ""), name: AddonDefinition.Clean((!Object.op_Implicit((Object)(object)val)) ? "Keine Map geladen" : (((Object)(object)val == (Object)(object)instance.levelLobbyMenu || (Object)(object)val == (Object)(object)instance.levelLobby) ? "Lobby" : (SemiFunc.IsLevelShop(val) ? "Shop" : (string.IsNullOrWhiteSpace(val.NarrativeName) ? ((Object)val).name : val.NarrativeName))), 100), id: Object.op_Implicit((Object)(object)val) ? ((Object)val).name : "", authority: flag3, ready: flag && Object.op_Implicit((Object)(object)LevelGenerator.Instance) && LevelGenerator.Instance.Generated, scene: gameContext.NativeScene);
			}
		}

		internal static void DrawOverlay()
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Expected O, but got Unknown
			if (!(Current.Role == "Menü"))
			{
				if (style == null)
				{
					GUIStyle val = new GUIStyle(GUI.skin.label)
					{
						fontSize = 14,
						wordWrap = true,
						richText = false
					};
					val.normal.textColor = new Color(0.4f, 0.95f, 0.85f);
					style = val;
				}
				GUI.Label(new Rect(18f, 70f, (float)Mathf.Min(500, Screen.width - 36), 55f), "NM · " + Current.Description, style);
			}
		}
	}
	internal enum CoreLanguage
	{
		Automatic,
		Deutsch,
		English
	}
	internal static class CoreText
	{
		internal static string Language { get; private set; } = "en";

		internal static CultureInfo Culture => CultureInfo.GetCultureInfo((Language == "de") ? "de-DE" : "en-US");

		internal static event Action? Changed;

		internal static string ResolveLanguage(CoreLanguage selection, string? gameCode)
		{
			switch (selection)
			{
			case CoreLanguage.Deutsch:
				return "de";
			case CoreLanguage.English:
				return "en";
			default:
				if (gameCode == null || (!gameCode.Equals("de", StringComparison.OrdinalIgnoreCase) && !gameCode.StartsWith("de-", StringComparison.OrdinalIgnoreCase) && !gameCode.StartsWith("de_", StringComparison.OrdinalIgnoreCase)))
				{
					return "en";
				}
				return "de";
			}
		}

		internal static void Select(CoreLanguage selection, string? gameCode)
		{
			string text = ResolveLanguage(selection, gameCode);
			if (!(text == Language))
			{
				Language = text;
				CoreText.Changed?.Invoke();
			}
		}

		internal static string Choose(string english, string? german, string language)
		{
			if (!(language == "de") || string.IsNullOrEmpty(german))
			{
				return english;
			}
			return german;
		}

		internal static string Get(string key)
		{
			if (!CoreTextCatalog.Text.TryGetValue(key, out string[] value))
			{
				return key;
			}
			return Choose(value[0], value[1], Language);
		}

		internal static string Format(string key, params object[] values)
		{
			return string.Format(Culture, Get(key), values);
		}

		internal static string Help(string key)
		{
			if (!CoreTextCatalog.Text.TryGetValue(key, out string[] value))
			{
				return key;
			}
			return value[1] + " / " + value[0];
		}

		internal static string DisplayRole(string stableRole)
		{
			return stableRole switch
			{
				"Menü" => Get("role.menu"), 
				"Mitspieler" => Get("role.client"), 
				"Verbindung wird aufgebaut" => Get("role.connecting"), 
				"Einzelspieler" => Get("role.single"), 
				_ => stableRole, 
			};
		}
	}
	internal static class CoreTextCatalog
	{
		internal static readonly IReadOnlyDictionary<string, string[]> Text = new Dictionary<string, string[]>
		{
			["api.handler"] = new string[2] { "Provide your own add-on handler.", "Eigenen Addon-Handler angeben." },
			["api.history"] = new string[2] { "Upgrade sources must come from verified Upgrade Share.", "Upgrade-Herkunft muss vom verifizierten Upgrade Share stammen." },
			["api.missing"] = new string[2] { "NM Core is missing.", "NM Core fehlt." },
			["api.offset"] = new string[2] { "The offset provider must be NM Host Tools.", "Offset-Anbieter muss NM Host Tools sein." },
			["api.owner"] = new string[2] { "The service requires your own verified add-on.", "Dienst benötigt ein eigenes verifiziertes Addon." },
			["api.provider"] = new string[2] { "The NM context provider must belong to the registered DLL.", "NM-Kontextanbieter muss aus der registrierten DLL stammen." },
			["api.signature"] = new string[2] { "NM Core: A signed add-on is required. ", "NM Core: Signiertes Addon erforderlich. " },
			["api.unsignedview"] = new string[2] { "The NM add-on view does not belong to the signed DLL.", "NM-Addon-Ansicht stammt nicht aus der signierten DLL." },
			["api.view"] = new string[2] { "The NM view must belong to the registered DLL.", "NM-Ansicht muss aus der registrierten DLL stammen." },
			["config.key"] = new string[2] { "Open/close the shared NM menu.", "Gemeinsames NM-Menü öffnen/schließen." },
			["config.overlay"] = new string[2] { "Show your role, host Core report and current map in a small overlay.", "Rolle, Core-Meldung des Hosts und aktuelle Map als kleine Einblendung anzeigen." },
			["config.scale"] = new string[2] { "Interface scale; adjusted to fit the screen.", "Größe der Oberfläche; wird an den Bildschirm angepasst." },
			["config.serverlist"] = new string[2] { "Mark your public lobby with a turquoise [NM]. Visible to players with Core 2.6.2 or later; independent of name prefixes.", "Eigene öffentliche Lobby mit türkisfarbenem [NM] kennzeichnen. Sichtbar für Spieler mit Core ab 2.6.2; unabhängig von Namenspräfixen." },
			["history.chance"] = new string[2] { "Your next sharing chance: ", "Deine nächste Teilungschance: " },
			["history.empty"] = new string[2] { "No tracked upgrade types available yet.", "Noch keine erfassten Upgrade-Typen bereit." },
			["history.help"] = new string[2] { "These are upgrade levels, not health points. Initial levels cannot be attributed retrospectively. Unknown change is the remaining positive or negative difference; it is not proof of cheating. Only known personal bonuses are listed separately.", "Stufen, keine Lebenspunkte: Anfangsbestand ist historisch nicht zuordenbar. Unbekannte Änderung ist die verbleibende positive oder negative Differenz; sie ist kein Cheating-Nachweis. Nur bekannte persönliche Boni werden getrennt ausgewiesen." },
			["history.summary"] = new string[2] { "Initial {0} · collected {1} · shared {2} · Late Join {3} · bonus {4} · unknown change {5} · total {6}", "Anfang {0} · selbst {1} · geteilt {2} · Late Join {3} · Bonus {4} · unbekannte Änderung {5} · Gesamt {6}" },
			["history.title"] = new string[2] { "UPGRADE LEVEL SOURCES", "HERKUNFT DER UPGRADE-STUFEN" },
			["history.unavailable"] = new string[2] { "Unavailable: Upgrade Share needs a fully loaded player and current data from the host. Without Share on the host, no source data is available; clients receive only their own statistics.", "Nicht verfügbar: Upgrade Share benötigt einen bereit geladenen Spieler und eine aktuelle Erfassung vom Host. Ohne Share beim Host gibt es keine Herkunftsdaten; als Mitspieler wird nur die eigene Statistik übertragen." },
			["history.unknown"] = new string[2] { "unknown", "nicht bekannt" },
			["language.active"] = new string[2] { "Active Core language: {0}", "Aktive Core-Sprache: {0}" },
			["language.auto"] = new string[2] { "Automatic", "Automatisch" },
			["language.config"] = new string[2] { "Language: Automatic follows the game language, falling back to English; Deutsch or English overrides it.", "Sprache: Automatic folgt der Spielsprache, sonst Englisch; Deutsch oder English erzwingen die Auswahl." },
			["language.help"] = new string[2] { "Automatic follows the game language; other or unavailable languages use English. Applies locally only. Add-ons supply their own text.", "Automatisch folgt der Spielsprache; andere oder unbekannte Sprachen verwenden Englisch. Gilt nur lokal. Add-ons bringen ihre eigenen Texte mit." },
			["language.title"] = new string[2] { "LANGUAGE", "SPRACHE" },
			["lobby.active"] = new string[2] { "Enable custom lobby prefixes", "Benutzerdefinierte Lobby-Präfixe aktiv" },
			["lobby.addonconfig"] = new string[2] { "Only controls the lobby addition; does not disable the mod.", "Nur den Lobby-Zusatz anzeigen; schaltet den Mod nicht aus." },
			["lobby.config"] = new string[2] { "Enable all NM prefixes together. When enabled, [NM] is required. Off also removes [NM].", "Alle NM-Präfixe gemeinsam aktivieren. Wenn aktiv, ist [NM] Pflicht. Aus entfernt auch [NM]." },
			["lobby.current"] = new string[2] { "Current display name: ", "Aktueller Anzeigename: " },
			["lobby.custom"] = new string[2] { "Custom addition", "Eigener Zusatz" },
			["lobby.customconfig"] = new string[2] { "Additional custom prefix line.", "Zusätzliche eigene Präfix-Zeile." },
			["lobby.disabled"] = new string[2] { "No NM prefixes. Other additions are preserved.", "Keine NM-Präfixe. Fremde Zusätze bleiben erhalten." },
			["lobby.editconfig"] = new string[2] { "Freely editable addition.", "Frei bearbeitbarer Zusatz." },
			["lobby.error"] = new string[2] { "Prefix integration failed: {0}", "Präfix-Anbindung fehlgeschlagen: {0}" },
			["lobby.latejoinhelp"] = new string[2] { "Disable LateJoinNow's own naming feature; this checkbox only controls its prefix.", "LateJoinNows eigene Namensfunktion ausschalten; dieser Haken steuert nur den Zusatz." },
			["lobby.required"] = new string[2] { "[NM] · required while prefixes are enabled", "[NM] · Pflicht bei aktiver Präfix-Funktion" },
			["lobby.runtimeerror"] = new string[2] { "Lobby prefix: {0}", "Lobby-Präfix: {0}" },
			["lobby.save"] = new string[2] { "Save prefix text", "Präfix-Texte speichern" },
			["lobby.textconfig"] = new string[2] { "Custom addition independent of add-ons.", "Eigener Zusatz, unabhängig von Addons." },
			["lobby.title"] = new string[2] { "LOBBY NAME", "LOBBY-NAME" },
			["lobby.waiting"] = new string[2] { "Waiting for your own public lobby.", "Wartet auf eine eigene öffentliche Lobby." },
			["names.always"] = new string[2] { "Always show names above players", "Spielernamen immer über den Köpfen anzeigen" },
			["names.apply"] = new string[2] { "Apply", "Übernehmen" },
			["names.changedtimer"] = new string[2] { "Nameplates: showTimer has changed.", "Namensanzeige: showTimer hat sich geändert." },
			["names.config"] = new string[2] { "Keep names above other players visible outside the shop. Your view only, including as a client. Off = normal game behaviour.", "Namen über anderen Spielern auch außerhalb des Shops dauerhaft einblenden. Nur deine Ansicht, auch als Gast. Aus = normales Spielverhalten." },
			["names.error"] = new string[2] { "Nameplate integration unavailable: {0}", "Namensanzeige nicht angebunden: {0}" },
			["names.help"] = new string[2] { "Applies locally, including as a client. Persistent names fade out beyond this range. Disabling restores normal game behaviour; the game still handles spectating and inactive players.", "Gilt lokal, auch als Gast. Außerhalb der Reichweite blenden dauerhafte Namen aus. Aus stellt normales Spielverhalten wieder her; Zuschauen und deaktivierte Spieler behandelt weiterhin das Spiel." },
			["names.missingupdate"] = new string[2] { "WorldSpaceUIPlayerName.Update is missing.", "WorldSpaceUIPlayerName.Update fehlt." },
			["names.range"] = new string[2] { "Range (1–100 metres)", "Reichweite (1–100 Meter)" },
			["names.rangeconfig"] = new string[2] { "Range in metres for persistent names.", "Reichweite in Metern bei dauerhaften Namen." },
			["names.title"] = new string[2] { "PLAYER NAMES", "SPIELERNAMEN" },
			["peer.error"] = new string[2] { "Player detection paused: {0}", "Mitspieler-Erkennung angehalten: {0}" },
			["peer.help"] = new string[2] { "One report on joining, with one retry after 2 minutes if data is missing. Other players report their own versions. The check mark compares them against your verified package catalog, not a worldwide version list.", "Eine Meldung beim Beitritt, bei fehlenden Daten ein Nachversuch nach 2 Minuten. Versionsangaben anderer Spieler sind Selbstauskünfte. Der Haken vergleicht mit deinem geprüften Paketkatalog, nicht mit einer weltweiten Versionsliste." },
			["peer.nocore"] = new string[2] { "No Core report. Core may be missing or too old for this detection.", "Keine Core-Meldung. Core kann fehlen oder zu alt für diese Erkennung sein." },
			["peer.noroom"] = new string[2] { "Not in a multiplayer room yet.", "Noch in keinem Mehrspielerraum." },
			["peer.notinstalled"] = new string[2] { "not installed", "nicht installiert" },
			["peer.title"] = new string[2] { "PLAYERS · CORE & ADD-ONS", "MITSPIELER · CORE & ADD-ONS" },
			["peer.unconfirmed"] = new string[2] { "not confirmed", "nicht bestätigt" },
			["peer.versions"] = new string[2] { " · installed locally: {0} · server catalog: {1}", " · bei dir: {0} · Serverkatalog: {1}" },
			["peer.you"] = new string[2] { " · You", " · Du" },
			["role.client"] = new string[2] { "Client", "Mitspieler" },
			["role.connecting"] = new string[2] { "Connecting", "Verbindung wird aufgebaut" },
			["role.hostcore"] = new string[2] { "Host with NM Core {0}", "Host mit NM Core {0}" },
			["role.menu"] = new string[2] { "Menu", "Menü" },
			["role.nomap"] = new string[2] { "No map loaded", "Keine Map geladen" },
			["role.single"] = new string[2] { "Single player", "Einzelspieler" },
			["role.unconfirmed"] = new string[2] { "Host Core not confirmed", "Host-Core nicht bestätigt" },
			["runtime.compatibility"] = new string[2] { "Game/mod interface is incompatible", "Spiel-/Mod-Schnittstelle nicht kompatibel" },
			["runtime.failure"] = new string[2] { "Processing failed", "Verarbeitung fehlgeschlagen" },
			["runtime.paused"] = new string[2] { "{0}. Feature paused until restart. {1}", "{0}. Funktion pausiert bis zum Neustart. {1}" },
			["session.toggle"] = new string[2] { "Show role and map in game", "Rolle und Map im Spiel anzeigen" },
			["traffic.summary"] = new string[2] { "{0}: {1} messages, {2} recorded payload bytes (excluding protocol overhead; 0 = not recorded)", "{0}: {1} Nachrichten, {2} erfasste Nutzdaten-Bytes (ohne Protokoll; 0 = nicht erfasst)" },
			["window.addonfault"] = new string[2] { "This add-on reported a display error.", "Die Anzeige dieses Add-ons hat einen Fehler gemeldet." },
			["window.addons"] = new string[2] { "YOUR ADD-ONS", "DEINE ADD-ONS" },
			["window.close"] = new string[2] { "Close · ", "Schließen · " },
			["window.empty"] = new string[2] { "Core is ready. No verified NM add-ons loaded yet.", "Core bereit. Noch keine verifizierten NM-Add-ons geladen." },
			["window.fault"] = new string[2] { "This tab reported an error. Other add-ons remain accessible. See the BepInEx log for details.", "Dieser Tab hat einen Fehler gemeldet. Andere Add-ons bleiben erreichbar. Details im BepInEx-Log." },
			["window.footer"] = new string[2] { " / Esc to close", " / Esc schließen" },
			["window.intro"] = new string[2] { "Core provides the shared menu. Each add-on provides its own features.", "Der Core stellt das gemeinsame Menü bereit. Jedes Add-on bringt seine eigenen Funktionen mit." },
			["window.open"] = new string[2] { "Open", "Öffnen" },
			["window.paused"] = new string[2] { ": display paused", ": Anzeige angehalten" },
			["window.peers"] = new string[2] { "Players", "Mitspieler" },
			["window.rejected"] = new string[2] { "Registration rejected: ", "Anbindung abgelehnt: " },
			["window.retry"] = new string[2] { "Retry display", "Anzeige erneut versuchen" },
			["window.verified"] = new string[2] { "  ·  NM verified", "  ·  NM verifiziert" },
			["window.view"] = new string[2] { "View · ", "Ansehen · " }
		};
	}
	public static class CoreTraffic
	{
		private static readonly Dictionary<string, long> counts = new Dictionary<string, long>();

		private static readonly Dictionary<string, long> bytes = new Dictionary<string, long>();

		public static void Record(string channel, int encodedPayloadBytes = 0)
		{
			counts.TryGetValue(channel, out var value);
			counts[channel] = value + 1;
			bytes.TryGetValue(channel, out var value2);
			bytes[channel] = value2 + encodedPayloadBytes;
		}

		public static string Summary()
		{
			return string.Join("; ", from p in counts
				orderby p.Key
				select CoreText.Format("traffic.summary", p.Key, p.Value, bytes[p.Key]));
		}
	}
	internal sealed class CoreWindow : IDisposable
	{
		private sealed class Toast
		{
			internal string Id = "";

			internal string Text = "";

			internal float Until;
		}

		private const float Width = 1120f;

		private const float Height = 840f;

		private readonly CorePlugin plugin;

		private readonly AddonUi ui = new AddonUi();

		private Rect rect = new Rect(20f, 20f, 1120f, 840f);

		private Vector2 tabsScroll;

		private Vector2 homeScroll;

		private readonly List<Toast> toasts = new List<Toast>();

		internal CoreWindow(CorePlugin plugin)
		{
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			this.plugin = plugin;
		}

		internal void Notify(string id, string text, float seconds)
		{
			toasts.RemoveAll((Toast t) => t.Id == id || t.Until <= Time.unscaledTime);
			if (toasts.Count == 3)
			{
				toasts.RemoveAt(0);
			}
			toasts.Add(new Toast
			{
				Id = id,
				Text = text,
				Until = Time.unscaledTime + seconds
			});
		}

		internal void Draw(float requestedScale)
		{
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Expected O, but got Unknown
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_0158: Unknown result type (might be due to invalid IL or missing references)
			if (!plugin.Visible && toasts.Count == 0)
			{
				return;
			}
			ui.EnsureStyles();
			Matrix4x4 matrix = GUI.matrix;
			Color color = GUI.color;
			int depth = GUI.depth;
			bool enabled = GUI.enabled;
			try
			{
				float num = Mathf.Max(0.1f, Mathf.Min(requestedScale, Mathf.Min((float)Screen.width / 1140f, (float)Screen.height / 860f)));
				GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, new Vector3(num, num, 1f));
				GUI.color = Color.white;
				GUI.enabled = true;
				GUI.depth = -2000;
				if (plugin.Visible)
				{
					((Rect)(ref rect)).x = Mathf.Clamp(((Rect)(ref rect)).x, 0f, Mathf.Max(0f, (float)Screen.width / num - 1120f));
					((Rect)(ref rect)).y = Mathf.Clamp(((Rect)(ref rect)).y, 0f, Mathf.Max(0f, (float)Screen.height / num - 840f));
					rect = GUI.Window(729541, rect, new WindowFunction(DrawWindow), "", ui.Window);
				}
				else
				{
					DrawToasts(num);
				}
			}
			finally
			{
				GUI.matrix = matrix;
				GUI.color = color;
				GUI.depth = depth;
				GUI.enabled = enabled;
			}
		}

		private void DrawWindow(int id)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0468: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			GUI.Label(new Rect(20f, 12f, 870f, 35f), "NIGHTMARE  /  R.E.P.O.", ui.Title);
			if (GUI.Button(new Rect(963f, 12f, 137f, 36f), CoreText.Get("window.close") + plugin.ToggleKey, ui.Button))
			{
				plugin.SetVisible(value: false);
			}
			GUI.DragWindow(new Rect(0f, 0f, 945f, 48f));
			if (plugin.Selected != "@peers" && plugin.Catalog.Find(plugin.Selected) == null)
			{
				plugin.Selected = "";
			}
			GUILayout.BeginArea(new Rect(20f, 54f, 1080f, 70f));
			try
			{
				tabsScroll = GUILayout.BeginScrollView(tabsScroll, false, false, Array.Empty<GUILayoutOption>());
				GUILayout.BeginHorizontal(Array.Empty<GUILayoutOption>());
				if (GUILayout.Button("Core / Add-ons", (plugin.Selected == "") ? ui.Selected : ui.Button, (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(175f),
					GUILayout.Height(39f)
				}))
				{
					plugin.Selected = "";
				}
				if (GUILayout.Button(CoreText.Get("window.peers"), (plugin.Selected == "@peers") ? ui.Selected : ui.Button, (GUILayoutOption[])(object)new GUILayoutOption[2]
				{
					GUILayout.Width(150f),
					GUILayout.Height(39f)
				}))
				{
					plugin.Selected = "@peers";
				}
				AddonEntry[] entries = plugin.Catalog.Entries;
				foreach (AddonEntry addonEntry in entries)
				{
					if (GUILayout.Button(addonEntry.Definition.Name, (plugin.Selected == addonEntry.Definition.Id) ? ui.Selected : ui.Button, (GUILayoutOption[])(object)new GUILayoutOption[2]
					{
						GUILayout.Width(185f),
						GUILayout.Height(39f)
					}))
					{
						plugin.Selected = addonEntry.Definition.Id;
					}
				}
				GUILayout.EndHorizontal();
				GUILayout.EndScrollView();
			}
			finally
			{
				GUILayout.EndArea();
			}
			GUILayout.BeginArea(new Rect(20f, 128f, 1080f, 678f));
			try
			{
				AddonEntry addonEntry2 = plugin.Catalog.Find(plugin.Selected);
				if (plugin.Selected == "@peers")
				{
					CoreRuntime.Run("nightmare.repo.core/peers-ui", delegate
					{
						plugin.Peers.Draw(ui);
					});
				}
				else if (addonEntry2 == null)
				{
					DrawHome();
				}
				else if (addonEntry2.Fault.Length > 0)
				{
					GUILayout.Label(addonEntry2.Definition.Name + CoreText.Get("window.paused"), ui.Heading, Array.Empty<GUILayoutOption>());
					GUILayout.Label(CoreText.Get("window.fault"), ui.Danger, Array.Empty<GUILayoutOption>());
					if (GUILayout.Button(CoreText.Get("window.retry"), ui.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(250f) }))
					{
						addonEntry2.Fault = "";
					}
				}
				else
				{
					if (CoreRuntime.IsPaused(addonEntry2.Definition.Id))
					{
						GUILayout.Label(CoreRuntime.Message(addonEntry2.Definition.Id), ui.Danger, Array.Empty<GUILayoutOption>());
					}
					try
					{
						addonEntry2.Definition.Draw(ui);
					}
					catch (ExitGUIException)
					{
						throw;
					}
					catch (Exception ex2)
					{
						addonEntry2.Fault = ex2.Message;
						plugin.ReportError(addonEntry2.Definition.Id, ex2);
					}
				}
			}
			finally
			{
				GUILayout.EndArea();
			}
			GUI.Label(new Rect(22f, 811f, 1076f, 23f), "NM_Core_REPO 2.10.0  ·  " + plugin.Catalog.Entries.Length + " Add-ons  ·  " + plugin.ToggleKey + CoreText.Get("window.footer"), ui.Small);
		}

		private void DrawHome()
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			GUILayout.Label(CoreText.Get("window.addons"), ui.Heading, Array.Empty<GUILayoutOption>());
			plugin.DrawSession(ui);
			GUILayout.Label(CoreText.Get("window.intro"), ui.Body, Array.Empty<GUILayoutOption>());
			homeScroll = GUILayout.BeginScrollView(homeScroll, Array.Empty<GUILayoutOption>());
			try
			{
				plugin.Languages.Draw(ui);
				foreach (KeyValuePair<string, string> fault in CoreRuntime.Faults)
				{
					GUILayout.Label(fault.Key + ": " + fault.Value, ui.Danger, Array.Empty<GUILayoutOption>());
				}
				CoreRuntime.Run("nightmare.repo.core/names-ui", delegate
				{
					plugin.Names.Draw(ui);
				});
				GUILayout.Space(16f);
				CoreRuntime.Run("nightmare.repo.core/prefixes-ui", delegate
				{
					plugin.Prefixes.Draw(ui);
				});
				GUILayout.Space(16f);
				AddonEntry[] entries = plugin.Catalog.Entries;
				AddonEntry[] array = entries;
				foreach (AddonEntry addonEntry in array)
				{
					if (addonEntry.Definition.DrawHome == null || addonEntry.Fault.Length > 0)
					{
						continue;
					}
					GUILayout.BeginVertical(ui.Panel, Array.Empty<GUILayoutOption>());
					try
					{
						addonEntry.Definition.DrawHome(ui);
					}
					catch (ExitGUIException)
					{
						throw;
					}
					catch (Exception ex2)
					{
						addonEntry.Fault = ex2.Message;
						plugin.ReportError(addonEntry.Definition.Id, ex2);
					}
					finally
					{
						GUILayout.EndVertical();
					}
				}
				if (entries.Length == 0)
				{
					GUILayout.Label(CoreText.Get("window.empty"), ui.Muted, Array.Empty<GUILayoutOption>());
				}
				foreach (KeyValuePair<string, string> rejectedAddon in plugin.RejectedAddons)
				{
					GUILayout.Label(CoreText.Get("window.rejected") + rejectedAddon.Key + "\n" + rejectedAddon.Value, ui.Danger, Array.Empty<GUILayoutOption>());
				}
				array = entries;
				foreach (AddonEntry addonEntry2 in array)
				{
					GUILayout.BeginVertical(ui.Panel, Array.Empty<GUILayoutOption>());
					GUILayout.Label(addonEntry2.Definition.Name + "  ·  " + addonEntry2.Definition.Version + CoreText.Get("window.verified"), ui.Heading, Array.Empty<GUILayoutOption>());
					GUILayout.Label(addonEntry2.Definition.Description, ui.Body, Array.Empty<GUILayoutOption>());
					if (addonEntry2.Fault.Length > 0)
					{
						GUILayout.Label(CoreText.Get("window.addonfault"), ui.Notice, Array.Empty<GUILayoutOption>());
					}
					if (GUILayout.Button(CoreText.Get("window.open"), ui.Button, (GUILayoutOption[])(object)new GUILayoutOption[1] { GUILayout.Width(130f) }))
					{
						plugin.Selected = addonEntry2.Definition.Id;
					}
					GUILayout.EndVertical();
				}
			}
			finally
			{
				GUILayout.EndScrollView();
			}
		}

		private void DrawToasts(float scale)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			toasts.RemoveAll((Toast t) => t.Until <= Time.unscaledTime || plugin.Catalog.Find(t.Id) == null);
			for (int num = 0; num < toasts.Count; num++)
			{
				Toast toast = toasts[num];
				float num2 = (float)Screen.width / scale - 530f;
				float num3 = 24 + num * 178;
				GUI.Box(new Rect(num2, num3, 510f, 166f), "", ui.Panel);
				GUI.Label(new Rect(num2 + 12f, num3 + 8f, 480f, 27f), plugin.Catalog.Find(toast.Id).Definition.Name, ui.Notice);
				GUI.Label(new Rect(num2 + 12f, num3 + 36f, 480f, 89f), toast.Text, ui.Body);
				if (GUI.Button(new Rect(num2 + 12f, num3 + 125f, 480f, 32f), CoreText.Get("window.view") + plugin.ToggleKey, ui.Button))
				{
					plugin.Selected = toast.Id;
					plugin.SetVisible(value: true);
				}
			}
		}

		public void Dispose()
		{
			ui.Dispose();
			toasts.Clear();
		}
	}
	public sealed class GameContext
	{
		public int Scene { get; }

		public string SceneName { get; }

		public long Lobby { get; }

		public long Run { get; }

		public int MasterActor { get; }

		public int Level { get; }

		internal int NativeScene { get; }

		internal GameContext(int scene, int nativeScene, string name, long lobby, long run, int master, int level)
		{
			Scene = scene;
			NativeScene = nativeScene;
			SceneName = name;
			Lobby = lobby;
			Run = run;
			MasterActor = master;
			Level = level;
		}
	}
	internal sealed class ContextTracker
	{
		private GameContext? current;

		private object? room;

		private object? run;

		private object? stats;

		private object? values;

		internal GameContext Read(int scene, string name, object? nextRoom, object? nextRun, object? nextStats, object? nextValues, int master, int level)
		{
			bool flag = current == null || current.NativeScene != scene || current.SceneName != name;
			bool flag2 = current == null || room != nextRoom;
			bool flag3 = current == null || run != nextRun || stats != nextStats || values != nextValues;
			if (!flag && !flag2 && !flag3 && current.MasterActor == master && current.Level == level)
			{
				return current;
			}
			int scene2 = (flag ? ((current?.Scene ?? 0) + 1) : current.Scene);
			current = new GameContext(scene2, scene, name, (current?.Lobby ?? 0) + (flag2 ? 1 : 0), (current?.Run ?? 0) + (flag3 ? 1 : 0), master, level);
			room = nextRoom;
			run = nextRun;
			stats = nextStats;
			values = nextValues;
			return current;
		}
	}
	internal static class IniValues
	{
		internal static string Key(string section, string key)
		{
			return section + "\n" + key;
		}

		internal static Dictionary<string, string> Read(string path)
		{
			Dictionary<string, string> dictionary = new Dictionary<string, string>(StringComparer.Ordinal);
			if (!File.Exists(path))
			{
				return dictionary;
			}
			string section = "";
			string[] array = File.ReadAllLines(path);
			for (int i = 0; i < array.Length; i++)
			{
				string text = array[i].Trim();
				if (text.Length == 0 || text.StartsWith("#") || text.StartsWith(";"))
				{
					continue;
				}
				if (text.StartsWith("[") && text.EndsWith("]"))
				{
					section = text.Substring(1, text.Length - 2);
					continue;
				}
				int num = text.IndexOf('=');
				if (num >= 0)
				{
					dictionary[Key(section, text.Substring(0, num).Trim())] = text.Substring(num + 1).Trim();
				}
			}
			return dictionary;
		}
	}
	internal sealed class LobbyPeerBadge : IDisposable
	{
		private readonly RectTransform row;

		private readonly TextMeshProUGUI name;

		private readonly TextMeshProUGUI text;

		private const float Gap = 8f;

		private const float Width = 76f;

		private const float Height = 22f;

		internal bool Alive
		{
			get
			{
				if (Object.op_Implicit((Object)(object)row) && Object.op_Implicit((Object)(object)name))
				{
					return Object.op_Implicit((Object)(object)text);
				}
				return false;
			}
		}

		internal LobbyPeerBadge(MenuPlayerListed player)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0154: Unknown result type (might be due to invalid IL or missing references)
			row = ((Component)player).GetComponent<RectTransform>();
			name = player.playerName;
			GameObject val = new GameObject("NM Core Status", new Type[1] { typeof(RectTransform) });
			val.transform.SetParent((Transform)(object)row, false);
			text = val.AddComponent<TextMeshProUGUI>();
			((TMP_Text)text).font = ((TMP_Text)name).font;
			((TMP_Text)text).fontSize = (((TMP_Text)text).fontSizeMax = 12f);
			((TMP_Text)text).fontSizeMin = 8f;
			((TMP_Text)text).enableAutoSizing = true;
			((TMP_Text)text).richText = false;
			((Graphic)text).raycastTarget = false;
			((MaskableGraphic)text).maskable = false;
			((TMP_Text)text).enableWordWrapping = false;
			((TMP_Text)text).overflowMode = (TextOverflowModes)1;
			((TMP_Text)text).alignment = (TextAlignmentOptions)4097;
			RectTransform rectTransform = ((TMP_Text)text).rectTransform;
			Vector2 val2 = default(Vector2);
			((Vector2)(ref val2))..ctor(1f, 0.5f);
			rectTransform.anchorMax = val2;
			rectTransform.anchorMin = val2;
			rectTransform.pivot = new Vector2(0f, 0.5f);
			rectTransform.anchoredPosition = new Vector2(8f, 0f);
			rectTransform.sizeDelta = new Vector2(76f, 22f);
			val.SetActive(false);
		}

		internal void SetVisible(bool visible)
		{
			if (Alive)
			{
				((Component)text).gameObject.SetActive(visible);
			}
		}

		internal void SetLabel(string label, Color color)
		{
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			if (Alive)
			{
				if (((TMP_Text)text).text != label)
				{
					((TMP_Text)text).text = label;
				}
				((Graphic)text).color = color;
				RectTransform obj = row;
				RectTransform rectTransform = ((TMP_Text)name).rectTransform;
				Rect rect = ((TMP_Text)name).rectTransform.rect;
				Vector3 val = ((Transform)obj).InverseTransformPoint(((Transform)rectTransform).TransformPoint(Vector2.op_Implicit(((Rect)(ref rect)).center)));
				RectTransform rectTransform2 = ((TMP_Text)text).rectTransform;
				float y = val.y;
				rect = row.rect;
				rectTransform2.anchoredPosition = new Vector2(8f, y - ((Rect)(ref rect)).center.y);
			}
		}

		public void Dispose()
		{
			if (Object.op_Implicit((Object)(object)text))
			{
				Object.Destroy((Object)(object)((Component)text).gameObject);
			}
		}
	}
	internal sealed class LobbyPrefixes : IDisposable
	{
		private readonly CorePlugin plugin;

		private readonly ConfigEntry<bool> active;

		private readonly ConfigEntry<bool> ownActive;

		private readonly ConfigEntry<string> ownText;

		private readonly Dictionary<string, Tuple<ConfigEntry<bool>, ConfigEntry<string>>> rows = new Dictionary<string, Tuple<ConfigEntry<bool>, ConfigEntry<string>>>();

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

		private readonly HashSet<string> owned = new HashSet<string>();

		private readonly Harmony harmony = new Harmony("nightmare.repo.core.lobby");

		private static LobbyPrefixes? instance;

		private object? room;

		private string cachedInput = "";

		private string cachedSettings = "";

		private string cachedOutput = "";

		private float next;

		private const string LateJoinId = "zichen.latejoinnow";

		private string status = "";

		private string statusKey = "lobby.waiting";

		internal LobbyPrefixes(CorePlugin plugin)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Expected O, but got Unknown
			this.plugin = plugin;
			instance = this;
			active = ((BaseUnityPlugin)plugin).Config.Bind<bool>("Lobby", "BenutzerdefiniertePraefixe", true, CoreText.Help("lobby.config"));
			ownActive = ((BaseUnityPlugin)plugin).Config.Bind<bool>("Lobby", "EigenerTextAktiv", false, CoreText.Help("lobby.customconfig"));
			ownText = ((BaseUnityPlugin)plugin).Config.Bind<string>("Lobby", "EigenerText", "[GER]", CoreText.Help("lobby.textconfig"));
			try
			{
				harmony.Patch((MethodBase)AccessTools.Method(typeof(NetworkConnect), "OnConnectedToMaster", (Type[])null, (Type[])null), new HarmonyMethod(typeof(LobbyPrefixes), "BeforeConnect", (Type[])null)
				{
					priority = 0
				}, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
			}
			catch (Exception ex)
			{
				status = ex.Message;
				statusKey = "lobby.error";
				plugin.ReportError("lobby", ex);
			}
		}

		private Tuple<ConfigEntry<bool>, ConfigEntry<string>> Row(string id, string defaultText)
		{
			if (!rows.TryGetValue(id, out Tuple<ConfigEntry<bool>, ConfigEntry<string>> value))
			{
				value = Tuple.Create<ConfigEntry<bool>, ConfigEntry<string>>(((BaseUnityPlugin)plugin).Config.Bind<bool>("Lobby-Addon " + id, "Aktiv", true, CoreText.Help("lobby.addonconfig")), ((BaseUnityPlugin)plugin).Config.Bind<string>("Lobby-Addon " + id, "Text", defaultText, CoreText.Help("lobby.editconfig")));
				rows[id] = value;
			}
			return value;
		}

		private string[] Ad