Decompiled source of NM Killfeed REPO v0.2.0

BepInEx/plugins/NM_Killfeed_REPO/NM_Killfeed_REPO.dll

Decompiled 2 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using ExitGames.Client.Photon;
using Microsoft.CodeAnalysis;
using Nightmare.REPO.Core;
using Nightmare.REPO.Localization;
using Photon.Pun;
using Photon.Realtime;
using TMPro;
using UnityEngine;
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("0.2.0.0")]
[assembly: AssemblyInformationalVersion("0.2.0")]
[assembly: AssemblyProduct("NM_Killfeed_REPO")]
[assembly: AssemblyTitle("NM_Killfeed_REPO")]
[assembly: AssemblyVersion("0.1.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.REPO.Localization
{
	internal static class L
	{
		internal static readonly Dictionary<string, string> Translations = new Dictionary<string, string>(StringComparer.Ordinal)
		{
			{ "Größe", "Size" },
			{ " besiegt", " defeated" },
			{ " gestorben", " died" },
			{ " beigetreten", " joined" },
			{ " hat die Runde verlassen", " left the game" },
			{ "Gegnertode", "Enemy deaths" },
			{ "Besiegte Gegner anzeigen.", "Show defeated enemies." },
			{ "Spielertode", "Player deaths" },
			{ "Spielertode anzeigen.", "Show player deaths." },
			{ "Beitritte", "Joins" },
			{ "Neue Spieler in der Runde anzeigen.", "Show players joining the game." },
			{ "Verlassen/Verbindungsabbruch anzeigen.", "Show players leaving / disconnecting." },
			{ "Bestätigte NM-Bounty-Belohnungen anzeigen.", "Show confirmed NM Bounty rewards." },
			{ "Textgröße.", "Text size." },
			{ "Sekunden je Meldung.", "Seconds per notification." },
			{ "Maximal sichtbare Meldungen.", "Maximum visible notifications." },
			{ "Pixel bei 1920x1080.", "Pixels at 1920x1080." },
			{ "Rohname=Anzeigename; weiterer Rohname=Name. Unbekannte Namen bleiben lesbar.", "RawName=DisplayName; AnotherRawName=Name. Unknown names remain readable." },
			{ "Optional die NM-Namensvorgaben des aktuellen Hosts verwenden.", "Optionally use the current host's NM name mappings." },
			{ "Tode, Beitritte und Verlassen; Mod-Gegner mit ihren eigenen Namen.", "Deaths, joins and departures; mod enemies use their own names." },
			{ "Denis UI Killfeed ist geladen. NM-Anzeige pausiert, um Doppelmeldungen zu vermeiden. Alten Killfeed entfernen.", "Denis UI Killfeed is loaded. NM display is paused to avoid duplicate notifications. Remove the old killfeed." },
			{ "Verlassen / Disconnect", "Leaves / disconnects" },
			{ "Bounty-Belohnungen", "Bounty rewards" },
			{ "Dauer in Sekunden", "Duration in seconds" },
			{ "Meldungen: ", "Notifications: " },
			{ "Abstand rechts", "Right margin" },
			{ "Abstand oben", "Top margin" },
			{ "Gegnernamen vom Host übernehmen", "Use enemy names from the host" },
			{ "Eigene Gegnernamen: Rohname=Anzeigename; Rohname2=Name2", "Custom enemy names: RawName=DisplayName; RawName2=Name2" },
			{ "Namen speichern", "Save names" },
			{ "Vorschau anzeigen", "Show preview" },
			{ "NM Testgegner", "NM test enemy" }
		};

		[ThreadStatic]
		private static string? captureLanguage;

		internal static string Language => captureLanguage ?? CoreApi.Language;

		internal static string T(string german)
		{
			if (!(Language == "de"))
			{
				return English(german);
			}
			return german;
		}

		internal static string English(string german)
		{
			if (!Translations.TryGetValue(german, out string value) || value == null)
			{
				return german;
			}
			return value;
		}

		internal static string Help(string german)
		{
			return "DE: " + german + "\nEN: " + English(german);
		}

		internal static LocalText Capture(Func<string> render)
		{
			string text = captureLanguage;
			try
			{
				captureLanguage = "de";
				string german = render();
				captureLanguage = "en";
				return new LocalText(german, render());
			}
			finally
			{
				captureLanguage = text;
			}
		}

		internal static AddonDefinition Describe(AddonDefinition definition, string name, string description)
		{
			definition.NameProvider = () => T(name);
			definition.DescriptionProvider = () => T(description);
			return definition;
		}
	}
	internal sealed class LocalText
	{
		private readonly string de;

		private readonly string en;

		internal int Length => ToString().Length;

		internal LocalText(string german, string english)
		{
			de = german;
			en = english;
		}

		public override string ToString()
		{
			if (!(L.Language == "de"))
			{
				return en;
			}
			return de;
		}

		public static implicit operator string(LocalText value)
		{
			return value.ToString();
		}

		public static implicit operator LocalText(string value)
		{
			return new LocalText(value, value);
		}
	}
}
namespace Nightmare.REPO.Killfeed
{
	internal sealed class FeedRow
	{
		internal string Id = "";

		internal string Name = "";

		internal string Text = "";

		internal string Language = "";

		internal CombatEventKind Kind;

		internal int Reward;

		internal float Created;
	}
	internal sealed class FeedModel
	{
		internal readonly List<FeedRow> Rows = new List<FeedRow>();

		internal void Add(CombatEventKind kind, string id, string name, int reward, float time, int maximum)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Invalid comparison between Unknown and I4
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Invalid comparison between Unknown and I4
			//IL_005a: 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)
			FeedRow feedRow = (((int)kind == 0 || (int)kind == 4) ? Rows.FirstOrDefault((FeedRow r) => r.Id == id && ((int)r.Kind == 0 || (int)r.Kind == 4)) : null);
			if (feedRow == null)
			{
				feedRow = new FeedRow
				{
					Id = id,
					Name = CombatText.Clean(name, "Unbekannt"),
					Kind = kind,
					Created = time
				};
				Rows.Insert(0, feedRow);
			}
			if ((int)kind == 4)
			{
				feedRow.Reward = reward;
			}
			feedRow.Language = "";
			Refresh(feedRow);
			while (Rows.Count > Math.Max(1, maximum))
			{
				Rows.RemoveAt(Rows.Count - 1);
			}
		}

		internal static void Refresh(FeedRow row)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Invalid comparison between Unknown and I4
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Invalid comparison between Unknown and I4
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Invalid comparison between Unknown and I4
			if (!(row.Language == L.Language) || row.Text.Length <= 0)
			{
				row.Language = L.Language;
				CombatEventKind kind = row.Kind;
				bool flag = (int)kind == 0 || (int)kind == 4;
				row.Text = row.Name + (flag ? L.T(" besiegt") : (((int)kind == 1) ? L.T(" gestorben") : (((int)kind == 2) ? L.T(" beigetreten") : L.T(" hat die Runde verlassen"))));
				if (row.Reward > 0)
				{
					row.Text = row.Text + " · +$" + row.Reward.ToString("N0");
				}
			}
		}

		internal void Expire(float now, float seconds, int maximum)
		{
			Rows.RemoveAll((FeedRow r) => now - r.Created >= seconds);
			while (Rows.Count > maximum)
			{
				Rows.RemoveAt(Rows.Count - 1);
			}
		}
	}
	[BepInPlugin("nightmare.repo.killfeed", "NM_Killfeed_REPO", "0.2.0")]
	[BepInProcess("REPO.exe")]
	[BepInDependency("nightmare.repo.core", "2.10.1")]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string Id = "nightmare.repo.killfeed";

		public const string Version = "0.2.0";

		private const string NamesProperty = "nm.killfeed.names.v1";

		private AddonHandle page;

		private IDisposable? subscription;

		private ConfigEntry<bool> enemy;

		private ConfigEntry<bool> deaths;

		private ConfigEntry<bool> joins;

		private ConfigEntry<bool> leaves;

		private ConfigEntry<bool> rewards;

		private ConfigEntry<bool> hostNames;

		private ConfigEntry<float> scale;

		private ConfigEntry<float> duration;

		private ConfigEntry<float> x;

		private ConfigEntry<float> y;

		private ConfigEntry<int> maximum;

		private ConfigEntry<string> names;

		private readonly FeedModel feed = new FeedModel();

		private readonly List<TextMeshProUGUI> labels = new List<TextMeshProUGUI>();

		private readonly Dictionary<string, string> aliases = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);

		private GameObject? canvas;

		private TMP_FontAsset? font;

		private string aliasSource = "";

		private string nameDraft = "";

		private string lastPublished = "";

		private object? room;

		private float nextNames;

		private float nextHud;

		private int scene;

		private Action? tick;

		private static bool Conflict => Chainloader.PluginInfos.ContainsKey("denis.repo.denisuikillfeed");

		private void Awake()
		{
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Expected O, but got Unknown
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Expected O, but got Unknown
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Expected O, but got Unknown
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Expected O, but got Unknown
			//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Expected O, but got Unknown
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_0299: Expected O, but got Unknown
			enemy = ((BaseUnityPlugin)this).Config.Bind<bool>("Meldungen", "Gegnertode", true, L.Help("Besiegte Gegner anzeigen."));
			deaths = ((BaseUnityPlugin)this).Config.Bind<bool>("Meldungen", "Spielertode", true, L.Help("Spielertode anzeigen."));
			joins = ((BaseUnityPlugin)this).Config.Bind<bool>("Meldungen", "Beitritte", true, L.Help("Neue Spieler in der Runde anzeigen."));
			leaves = ((BaseUnityPlugin)this).Config.Bind<bool>("Meldungen", "Verlassen", true, L.Help("Verlassen/Verbindungsabbruch anzeigen."));
			rewards = ((BaseUnityPlugin)this).Config.Bind<bool>("Meldungen", "Belohnungen", true, L.Help("Bestätigte NM-Bounty-Belohnungen anzeigen."));
			scale = ((BaseUnityPlugin)this).Config.Bind<float>("Anzeige", "Skalierung", 1f, new ConfigDescription(L.Help("Textgröße."), (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 2f), Array.Empty<object>()));
			duration = ((BaseUnityPlugin)this).Config.Bind<float>("Anzeige", "Dauer", 6f, new ConfigDescription(L.Help("Sekunden je Meldung."), (AcceptableValueBase)(object)new AcceptableValueRange<float>(2f, 20f), Array.Empty<object>()));
			maximum = ((BaseUnityPlugin)this).Config.Bind<int>("Anzeige", "Anzahl", 6, new ConfigDescription(L.Help("Maximal sichtbare Meldungen."), (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 12), Array.Empty<object>()));
			x = ((BaseUnityPlugin)this).Config.Bind<float>("Anzeige", "AbstandRechts", 24f, new ConfigDescription(L.Help("Pixel bei 1920x1080."), (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1200f), Array.Empty<object>()));
			y = ((BaseUnityPlugin)this).Config.Bind<float>("Anzeige", "AbstandOben", 250f, new ConfigDescription(L.Help("Pixel bei 1920x1080."), (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 900f), Array.Empty<object>()));
			names = ((BaseUnityPlugin)this).Config.Bind<string>("Namen", "Zuordnungen", "", L.Help("Rohname=Anzeigename; weiterer Rohname=Name. Unbekannte Namen bleiben lesbar."));
			hostNames = ((BaseUnityPlugin)this).Config.Bind<bool>("Namen", "HostNamen", true, L.Help("Optional die NM-Namensvorgaben des aktuellen Hosts verwenden."));
			nameDraft = names.Value;
			page = CoreApi.Register(L.Describe(new AddonDefinition("nightmare.repo.killfeed", "Killfeed", "0.2.0", "Tode, Beitritte und Verlassen; Mod-Gegner mit ihren eigenen Namen.", (Action<AddonUi>)Draw, 1), "Killfeed", "Tode, Beitritte und Verlassen; Mod-Gegner mit ihren eigenen Namen."));
			subscription = CombatEvents.Subscribe(page, (Action<CombatEvent>)OnCombat);
		}

		private void HideFaultedDisplay()
		{
			if (Object.op_Implicit((Object)(object)canvas) && canvas.activeSelf)
			{
				canvas.SetActive(false);
			}
		}

		private void OnCombat(CombatEvent e)
		{
			CoreRuntime.Run("nightmare.repo.killfeed", (Action)delegate
			{
				HandleCombat(e);
			});
		}

		private void HandleCombat(CombatEvent e)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Invalid comparison between Unknown and I4
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Invalid comparison between Unknown and I4
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Invalid comparison between Unknown and I4
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Invalid comparison between Unknown and I4
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Invalid comparison between Unknown and I4
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			if (!Conflict && ((int)e.Kind != 0 || enemy.Value) && ((int)e.Kind != 4 || rewards.Value) && ((int)e.Kind != 1 || deaths.Value) && ((int)e.Kind != 2 || joins.Value) && ((int)e.Kind != 3 || leaves.Value))
			{
				string name = e.Name;
				if (((int)e.Kind == 0 || (int)e.Kind == 4) && aliases.TryGetValue(e.Name, out string value))
				{
					name = value;
				}
				feed.Add(e.Kind, e.Id, name, e.Reward, Time.unscaledTime, maximum.Value);
			}
		}

		private void Update()
		{
			if (!CoreRuntime.Run("nightmare.repo.killfeed", (Action)Tick))
			{
				HideFaultedDisplay();
			}
		}

		private void Tick()
		{
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: 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_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cd: Invalid comparison between Unknown and I4
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d7: Invalid comparison between Unknown and I4
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_0346: Unknown result type (might be due to invalid IL or missing references)
			//IL_034b: Unknown result type (might be due to invalid IL or missing references)
			//IL_031e: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e1: Invalid comparison between Unknown and I4
			//IL_0356: Unknown result type (might be due to invalid IL or missing references)
			//IL_0308: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0419: Unknown result type (might be due to invalid IL or missing references)
			//IL_041e: Unknown result type (might be due to invalid IL or missing references)
			//IL_043c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0441: Unknown result type (might be due to invalid IL or missing references)
			//IL_042e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0451: Unknown result type (might be due to invalid IL or missing references)
			if (Time.unscaledTime >= nextNames)
			{
				nextNames = Time.unscaledTime + 2f;
				UpdateNames();
			}
			if (scene != CoreApi.Context.Scene)
			{
				scene = CoreApi.Context.Scene;
				feed.Rows.Clear();
				labels.Clear();
				if (Object.op_Implicit((Object)(object)canvas))
				{
					Object.Destroy((Object)(object)canvas);
				}
				canvas = null;
				font = null;
			}
			feed.Expire(Time.unscaledTime, duration.Value, maximum.Value);
			if (Conflict || feed.Rows.Count == 0)
			{
				if ((Object)(object)canvas != (Object)null && Object.op_Implicit((Object)(object)canvas))
				{
					canvas.SetActive(false);
				}
				return;
			}
			if (!Object.op_Implicit((Object)(object)canvas) && Time.unscaledTime >= nextHud)
			{
				nextHud = Time.unscaledTime + 1f;
				CreateHud();
			}
			if ((Object)(object)canvas == (Object)null || !Object.op_Implicit((Object)(object)canvas))
			{
				return;
			}
			canvas.SetActive(true);
			Vector2 val3 = default(Vector2);
			while (labels.Count < maximum.Value)
			{
				GameObject val = new GameObject("NM Feed Row", new Type[1] { typeof(RectTransform) });
				val.transform.SetParent(canvas.transform, false);
				TextMeshProUGUI val2 = val.AddComponent<TextMeshProUGUI>();
				((TMP_Text)val2).font = font;
				((TMP_Text)val2).richText = false;
				((Graphic)val2).raycastTarget = false;
				((TMP_Text)val2).alignment = (TextAlignmentOptions)260;
				((TMP_Text)val2).textWrappingMode = (TextWrappingModes)1;
				((TMP_Text)val2).overflowMode = (TextOverflowModes)1;
				RectTransform rectTransform = ((TMP_Text)val2).rectTransform;
				((Vector2)(ref val3))..ctor(1f, 1f);
				rectTransform.pivot = val3;
				Vector2 anchorMin = (rectTransform.anchorMax = val3);
				rectTransform.anchorMin = anchorMin;
				labels.Add(val2);
			}
			Vector2 val7 = default(Vector2);
			Vector2 val8 = default(Vector2);
			for (int i = 0; i < labels.Count; i++)
			{
				TextMeshProUGUI val5 = labels[i];
				bool flag = i < feed.Rows.Count;
				((Component)val5).gameObject.SetActive(flag);
				if (flag)
				{
					FeedRow feedRow = feed.Rows[i];
					FeedModel.Refresh(feedRow);
					if (((TMP_Text)val5).text != feedRow.Text)
					{
						((TMP_Text)val5).text = feedRow.Text;
					}
					float num = Time.unscaledTime - feedRow.Created;
					float a = Mathf.Min(Mathf.Clamp01(num / 0.16f), Mathf.Clamp01((duration.Value - num) / 0.24f));
					Color val6 = (((int)feedRow.Kind == 1) ? new Color(1f, 0.35f, 0.35f) : (((int)feedRow.Kind == 2) ? new Color(0.4f, 1f, 0.75f) : (((int)feedRow.Kind == 3) ? new Color(0.7f, 0.75f, 0.8f) : new Color(1f, 0.83f, 0.3f))));
					val6.a = a;
					if (((Graphic)val5).color != val6)
					{
						((Graphic)val5).color = val6;
					}
					if (!Mathf.Approximately(((TMP_Text)val5).fontSize, 24f * scale.Value))
					{
						((TMP_Text)val5).fontSize = 24f * scale.Value;
					}
					((Vector2)(ref val7))..ctor(640f * scale.Value, 58f * scale.Value);
					((Vector2)(ref val8))..ctor(0f - x.Value + 24f * Mathf.Pow(1f - Mathf.Clamp01(num / 0.18f), 3f), 0f - y.Value - (float)(i * 60) * scale.Value);
					if (((TMP_Text)val5).rectTransform.sizeDelta != val7)
					{
						((TMP_Text)val5).rectTransform.sizeDelta = val7;
					}
					if (((TMP_Text)val5).rectTransform.anchoredPosition != val8)
					{
						((TMP_Text)val5).rectTransform.anchoredPosition = val8;
					}
				}
			}
		}

		private void CreateHud()
		{
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = GameObject.Find("Tax Haul");
			TMP_Text val2 = (Object.op_Implicit((Object)(object)val) ? val.GetComponent<TMP_Text>() : null);
			font = (((Object)(object)val2 != (Object)null && Object.op_Implicit((Object)(object)val2)) ? val2.font : TMP_Settings.defaultFontAsset);
			if (Object.op_Implicit((Object)(object)font))
			{
				canvas = new GameObject("NM Killfeed", new Type[3]
				{
					typeof(RectTransform),
					typeof(Canvas),
					typeof(CanvasScaler)
				});
				Canvas component = canvas.GetComponent<Canvas>();
				component.renderMode = (RenderMode)0;
				component.sortingOrder = 80;
				CanvasScaler component2 = canvas.GetComponent<CanvasScaler>();
				component2.uiScaleMode = (ScaleMode)1;
				component2.referenceResolution = new Vector2(1920f, 1080f);
				component2.matchWidthOrHeight = 0.5f;
				labels.Clear();
			}
		}

		private void UpdateNames()
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			if (room != PhotonNetwork.CurrentRoom)
			{
				room = PhotonNetwork.CurrentRoom;
				lastPublished = "";
			}
			string text = ((names.Value.Length > 2000) ? names.Value.Substring(0, 2000) : names.Value);
			if (PhotonNetwork.InRoom && PhotonNetwork.IsMasterClient && lastPublished != text + "\0")
			{
				PhotonNetwork.LocalPlayer.SetCustomProperties(new Hashtable { [(object)"nm.killfeed.names.v1"] = text }, (Hashtable)null, (WebFlags)null);
				lastPublished = text + "\0";
			}
			string text2 = text;
			if (hostNames.Value && PhotonNetwork.InRoom && !PhotonNetwork.IsMasterClient)
			{
				Player masterClient = PhotonNetwork.MasterClient;
				if (((masterClient != null) ? masterClient.CustomProperties[(object)"nm.killfeed.names.v1"] : null) is string { Length: <=2000 } text3)
				{
					text2 = text3;
				}
			}
			if (text2 == aliasSource)
			{
				return;
			}
			aliasSource = text2;
			aliases.Clear();
			string[] array = text2.Split(';');
			foreach (string text4 in array)
			{
				int num = text4.IndexOf('=');
				if (num >= 1)
				{
					string text5 = CombatText.Clean(text4.Substring(0, num), "");
					string text6 = CombatText.Clean(text4.Substring(num + 1), "");
					if (text5.Length > 0 && text6.Length > 0)
					{
						aliases[text5] = text6;
					}
				}
			}
		}

		private void Draw(AddonUi ui)
		{
			GUILayout.Label("KILLFEED", ui.Heading, Array.Empty<GUILayoutOption>());
			if (Conflict)
			{
				GUILayout.Label(L.T("Denis UI Killfeed ist geladen. NM-Anzeige pausiert, um Doppelmeldungen zu vermeiden. Alten Killfeed entfernen."), ui.Notice, Array.Empty<GUILayoutOption>());
			}
			Toggle(ui, enemy, L.T("Gegnertode"));
			Toggle(ui, deaths, L.T("Spielertode"));
			Toggle(ui, joins, L.T("Beitritte"));
			Toggle(ui, leaves, L.T("Verlassen / Disconnect"));
			Toggle(ui, rewards, L.T("Bounty-Belohnungen"));
			Slider(ui, L.T("Größe"), scale, 0.5f, 2f);
			Slider(ui, L.T("Dauer in Sekunden"), duration, 2f, 20f);
			GUILayout.Label(L.T("Meldungen: ") + maximum.Value, ui.Small, Array.Empty<GUILayoutOption>());
			maximum.Value = Mathf.RoundToInt(GUILayout.HorizontalSlider((float)maximum.Value, 1f, 12f, Array.Empty<GUILayoutOption>()));
			Slider(ui, L.T("Abstand rechts"), x, 0f, 1200f);
			Slider(ui, L.T("Abstand oben"), y, 0f, 900f);
			Toggle(ui, hostNames, L.T("Gegnernamen vom Host übernehmen"));
			GUILayout.Label(L.T("Eigene Gegnernamen: Rohname=Anzeigename; Rohname2=Name2"), ui.Small, Array.Empty<GUILayoutOption>());
			nameDraft = GUILayout.TextField(nameDraft, 2000, ui.TextField, Array.Empty<GUILayoutOption>());
			if (GUILayout.Button(L.T("Namen speichern"), ui.Button, Array.Empty<GUILayoutOption>()))
			{
				names.Value = nameDraft;
				nextNames = 0f;
			}
			if (GUILayout.Button(L.T("Vorschau anzeigen"), ui.Button, Array.Empty<GUILayoutOption>()))
			{
				feed.Add((CombatEventKind)0, "preview:" + Time.unscaledTime, L.T("NM Testgegner"), 0, Time.unscaledTime, maximum.Value);
			}
		}

		private static void Toggle(AddonUi ui, ConfigEntry<bool> value, string text)
		{
			if (GUILayout.Button((value.Value ? "✓ " : "○ ") + text, ui.Button, Array.Empty<GUILayoutOption>()))
			{
				value.Value = !value.Value;
			}
		}

		private static void Slider(AddonUi ui, string label, ConfigEntry<float> value, float min, float max)
		{
			GUILayout.Label(label + ": " + value.Value.ToString("0.0"), ui.Small, Array.Empty<GUILayoutOption>());
			float num = GUILayout.HorizontalSlider(value.Value, min, max, Array.Empty<GUILayoutOption>());
			if (Math.Abs(num - value.Value) > 0.001f)
			{
				value.Value = num;
			}
		}

		private void OnDestroy()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			subscription?.Dispose();
			AddonHandle obj = page;
			if (obj != null)
			{
				obj.Dispose();
			}
			if (Object.op_Implicit((Object)(object)canvas))
			{
				Object.Destroy((Object)(object)canvas);
			}
			if (PhotonNetwork.InRoom)
			{
				PhotonNetwork.LocalPlayer.SetCustomProperties(new Hashtable { [(object)"nm.killfeed.names.v1"] = null }, (Hashtable)null, (WebFlags)null);
			}
		}
	}
}