Decompiled source of SleekNotify v1.1.0

SleekNotify.dll

Decompiled 2 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using TMPro;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("SleekNotify")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("SleekNotify")]
[assembly: AssemblyTitle("SleekNotify")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace SleekNotify;

[HarmonyPatch]
internal static class MessageHudPatches
{
	private static FieldInfo _queueField;

	private static FieldInfo _countField;

	private static FieldInfo _msgListField;

	private static FieldInfo _maxSpaceField;

	private static FieldInfo _prefabContainerField;

	private static bool _reflected;

	private static void CacheReflection()
	{
		if (!_reflected)
		{
			Type typeFromHandle = typeof(MessageHud);
			BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
			_queueField = typeFromHandle.GetField("m_unlockMsgQueue", bindingAttr);
			_countField = typeFromHandle.GetField("m_unlockMsgCount", bindingAttr);
			_msgListField = typeFromHandle.GetField("m_unlockMessages", bindingAttr);
			_maxSpaceField = typeFromHandle.GetField("m_maxUnlockMsgSpace", bindingAttr);
			_prefabContainerField = typeFromHandle.GetField("m_unlockMsgPrefab", bindingAttr);
			_reflected = true;
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(Hud), "Awake")]
	private static void Hud_Awake_Postfix()
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)SleekNotifManager.Instance != (Object)null))
		{
			new GameObject("SleekNotifManager").AddComponent<SleekNotifManager>();
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(MessageHud), "Awake")]
	private static void MessageHud_Awake_Postfix(MessageHud __instance)
	{
		CacheReflection();
		_maxSpaceField?.SetValue(__instance, 0);
		if (_prefabContainerField != null)
		{
			object? value = _prefabContainerField.GetValue(__instance);
			GameObject val = (GameObject)((value is GameObject) ? value : null);
			if ((Object)(object)val != (Object)null)
			{
				val.SetActive(false);
			}
		}
	}

	[HarmonyPostfix]
	[HarmonyPatch(typeof(MessageHud), "QueueUnlockMsg")]
	private static void QueueUnlockMsg_Postfix(Sprite icon, string topic, string description)
	{
		if (!((Object)(object)SleekNotifManager.Instance == (Object)null))
		{
			string text = ((Localization.instance != null) ? Localization.instance.Localize(topic ?? "") : (topic ?? ""));
			string text2 = ((Localization.instance != null) ? Localization.instance.Localize(description ?? "") : (description ?? ""));
			SleekNotifManager.Instance.EnqueueMessage(string.IsNullOrWhiteSpace(text2) ? null : text2, string.IsNullOrWhiteSpace(text) ? null : text, icon);
		}
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(MessageHud), "UpdateUnlockMsg")]
	private static bool UpdateUnlockMsg_Prefix(MessageHud __instance)
	{
		CacheReflection();
		(_queueField?.GetValue(__instance) as IList)?.Clear();
		if (_countField != null)
		{
			_countField.SetValue(__instance, 0);
		}
		if (_maxSpaceField != null)
		{
			_maxSpaceField.SetValue(__instance, 0);
		}
		if (_msgListField?.GetValue(__instance) is IList list)
		{
			foreach (object item in list)
			{
				if (item != null)
				{
					object? obj = item.GetType().GetField("m_go", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic)?.GetValue(item);
					GameObject val = (GameObject)((obj is GameObject) ? obj : null);
					if (val != null && (Object)(object)val != (Object)null)
					{
						val.SetActive(false);
					}
				}
			}
		}
		return false;
	}

	[HarmonyPrefix]
	[HarmonyPatch(typeof(MessageHud), "ShowMessage")]
	private static bool ShowMessage_Prefix(MessageType type, string text, int amount, Sprite icon)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Invalid comparison between Unknown and I4
		if ((int)type != 1)
		{
			return true;
		}
		if (!SleekNotifyPlugin.InterceptTopLeft.Value)
		{
			return true;
		}
		if (string.IsNullOrWhiteSpace(text))
		{
			return true;
		}
		if ((Object)(object)SleekNotifManager.Instance == (Object)null)
		{
			return true;
		}
		string text2 = ((Localization.instance != null) ? Localization.instance.Localize(text) : text);
		string body = ((amount > 1) ? $"{text2}  x{amount}" : text2);
		SleekNotifManager.Instance.EnqueueMessage(body, null, icon);
		return false;
	}
}
internal class SleekNotifEntry
{
	public enum Phase
	{
		SlideIn,
		Hold,
		SlideOut,
		Done
	}

	public GameObject Root;

	public RectTransform Rect;

	public CanvasGroup CG;

	public TMP_Text Label;

	public Image IconImage;

	public GameObject BadgeRoot;

	public TMP_Text BadgeLabel;

	public string Topic;

	public string Body;

	public Sprite Icon;

	public int StackCount = 1;

	public Phase CurrentPhase;

	public float PhaseTimer;

	public int SlotIndex;

	public float TargetX;

	public float OffscreenX;

	public float TargetY;

	public float StaggerOffset;

	public void RefreshBadge()
	{
		if (!((Object)(object)BadgeRoot == (Object)null))
		{
			bool flag = StackCount > 1;
			BadgeRoot.SetActive(flag);
			if (flag && (Object)(object)BadgeLabel != (Object)null)
			{
				BadgeLabel.text = $"x{StackCount}";
			}
		}
	}

	public void BumpStack()
	{
		StackCount++;
		RefreshBadge();
		if (CurrentPhase == Phase.Hold)
		{
			PhaseTimer = 0f;
		}
	}
}
internal class SleekNotifManager : MonoBehaviour
{
	public struct PendingNotif
	{
		public string Topic;

		public string Body;

		public Sprite Icon;
	}

	private readonly List<SleekNotifEntry> _active = new List<SleekNotifEntry>();

	private readonly Queue<PendingNotif> _pending = new Queue<PendingNotif>();

	private Canvas _hudCanvas;

	private RectTransform _hudRT;

	public static SleekNotifManager Instance { get; private set; }

	private static float EaseOutCubic(float t)
	{
		return 1f - Mathf.Pow(1f - Mathf.Clamp01(t), 3f);
	}

	private static float EaseInCubic(float t)
	{
		t = Mathf.Clamp01(t);
		return t * t * t;
	}

	private void Awake()
	{
		if ((Object)(object)Instance != (Object)null && (Object)(object)Instance != (Object)(object)this)
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
			return;
		}
		Instance = this;
		Object.DontDestroyOnLoad((Object)(object)((Component)this).gameObject);
	}

	private void OnDestroy()
	{
		if ((Object)(object)Instance == (Object)(object)this)
		{
			Instance = null;
		}
	}

	private void OnLevelWasLoaded(int level)
	{
		_hudCanvas = null;
		_hudRT = null;
		foreach (SleekNotifEntry item in _active)
		{
			if ((Object)(object)item.Root != (Object)null)
			{
				Object.Destroy((Object)(object)item.Root);
			}
		}
		_active.Clear();
	}

	public void EnqueueMessage(string body, string topic = null, Sprite icon = null)
	{
		if (SleekNotifyPlugin.StackDuplicates.Value)
		{
			string text = MakeKey(topic, body);
			float value = SleekNotifyPlugin.StackWindow.Value;
			foreach (SleekNotifEntry item in _active)
			{
				if (item.CurrentPhase == SleekNotifEntry.Phase.Hold && !(MakeKey(item.Topic, item.Body) != text) && !(item.PhaseTimer > value))
				{
					item.BumpStack();
					return;
				}
			}
			foreach (PendingNotif item2 in _pending)
			{
				if (MakeKey(item2.Topic, item2.Body) == text)
				{
					return;
				}
			}
		}
		_pending.Enqueue(new PendingNotif
		{
			Topic = topic,
			Body = body,
			Icon = icon
		});
	}

	private static string MakeKey(string topic, string body)
	{
		return topic + "|" + body;
	}

	private void Update()
	{
		ResolveCanvas();
		if ((Object)(object)_hudCanvas == (Object)null)
		{
			return;
		}
		while (_pending.Count > 0 && _active.Count < SleekNotifyPlugin.MaxVisible.Value)
		{
			SpawnEntry(_pending.Dequeue());
		}
		float deltaTime = Time.deltaTime;
		for (int num = _active.Count - 1; num >= 0; num--)
		{
			if (TickEntry(_active[num], deltaTime))
			{
				DestroyEntry(_active[num]);
				_active.RemoveAt(num);
				RebuildTargetPositions();
			}
		}
	}

	private void LateUpdate()
	{
		//IL_003c: 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_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_hudCanvas == (Object)null)
		{
			return;
		}
		float value = SleekNotifyPlugin.SlotMoveSpeed.Value;
		float deltaTime = Time.deltaTime;
		foreach (SleekNotifEntry item in _active)
		{
			Vector2 anchoredPosition = item.Rect.anchoredPosition;
			if (Mathf.Abs(anchoredPosition.y - item.TargetY) > 0.5f)
			{
				item.Rect.anchoredPosition = new Vector2(anchoredPosition.x, Mathf.Lerp(anchoredPosition.y, item.TargetY, value * deltaTime));
			}
		}
	}

	private void ResolveCanvas()
	{
		if ((Object)(object)_hudCanvas != (Object)null)
		{
			return;
		}
		Hud instance = Hud.instance;
		if (!((Object)(object)instance == (Object)null))
		{
			_hudCanvas = ((Component)instance).GetComponent<Canvas>() ?? ((Component)instance).GetComponentInChildren<Canvas>(true);
			if ((Object)(object)_hudCanvas != (Object)null)
			{
				_hudRT = ((Component)_hudCanvas).GetComponent<RectTransform>();
			}
		}
	}

	private void SpawnEntry(PendingNotif notif)
	{
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Expected O, but got Unknown
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_01be: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_020b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0219: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0305: Unknown result type (might be due to invalid IL or missing references)
		//IL_031a: Unknown result type (might be due to invalid IL or missing references)
		//IL_032f: 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_037e: Unknown result type (might be due to invalid IL or missing references)
		int count = _active.Count;
		float value = SleekNotifyPlugin.NotifWidth.Value;
		float value2 = SleekNotifyPlugin.NotifHeight.Value;
		float value3 = SleekNotifyPlugin.ScreenEdgeMarginX.Value;
		float value4 = SleekNotifyPlugin.ScreenEdgeMarginY.Value;
		float value5 = SleekNotifyPlugin.NotifSpacing.Value;
		float value6 = SleekNotifyPlugin.BorderThickness.Value;
		float targetX = value3;
		float num = 0f - (value + value3 + 20f);
		float num2 = 0f - (value4 + (float)count * (value2 + value5));
		GameObject val = new GameObject($"SleekNotif_{count}", new Type[1] { typeof(RectTransform) });
		val.transform.SetParent(((Component)_hudCanvas).transform, false);
		val.transform.SetAsLastSibling();
		RectTransform component = val.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(0f, 1f);
		component.anchorMax = new Vector2(0f, 1f);
		component.pivot = new Vector2(0f, 1f);
		component.sizeDelta = new Vector2(value, value2);
		component.anchoredPosition = new Vector2(num, num2);
		CanvasGroup val2 = val.AddComponent<CanvasGroup>();
		val2.alpha = 0f;
		val2.interactable = false;
		val2.blocksRaycasts = false;
		BuildChrome(val);
		Image val3 = null;
		float value7 = SleekNotifyPlugin.IconSize.Value;
		float value8 = SleekNotifyPlugin.IconPadding.Value;
		float num3 = value6 + 6f;
		if (value7 > 0f && (Object)(object)notif.Icon != (Object)null)
		{
			GameObject val4 = new GameObject("Icon", new Type[1] { typeof(RectTransform) });
			val4.transform.SetParent(val.transform, false);
			RectTransform component2 = val4.GetComponent<RectTransform>();
			component2.anchorMin = new Vector2(0f, 0.5f);
			component2.anchorMax = new Vector2(0f, 0.5f);
			component2.pivot = new Vector2(0f, 0.5f);
			component2.anchoredPosition = new Vector2(num3, 0f);
			component2.sizeDelta = new Vector2(value7, value7);
			val3 = val4.AddComponent<Image>();
			val3.sprite = notif.Icon;
			val3.preserveAspect = true;
		}
		float num4 = ((value7 > 0f && (Object)(object)notif.Icon != (Object)null) ? (num3 + value7 + value8) : num3);
		bool flag = !string.IsNullOrWhiteSpace(notif.Topic);
		bool flag2 = !string.IsNullOrWhiteSpace(notif.Body);
		string text = ((flag && flag2) ? (notif.Topic + " - " + notif.Body) : ((!flag) ? (notif.Body ?? "") : notif.Topic));
		GameObject val5 = new GameObject("Label", new Type[1] { typeof(RectTransform) });
		val5.transform.SetParent(val.transform, false);
		RectTransform component3 = val5.GetComponent<RectTransform>();
		component3.anchorMin = new Vector2(0f, 0f);
		component3.anchorMax = new Vector2(1f, 1f);
		component3.offsetMin = new Vector2(num4, value6 + 2f);
		component3.offsetMax = new Vector2(0f - (value6 + 6f), 0f - (value6 + 2f));
		TextMeshProUGUI val6 = val5.AddComponent<TextMeshProUGUI>();
		((TMP_Text)val6).text = text;
		((TMP_Text)val6).fontSize = SleekNotifyPlugin.FontSize.Value;
		((Graphic)val6).color = SleekNotifyPlugin.TextColor.Value;
		((TMP_Text)val6).fontStyle = (FontStyles)0;
		((TMP_Text)val6).alignment = (TextAlignmentOptions)4097;
		((TMP_Text)val6).overflowMode = (TextOverflowModes)1;
		((TMP_Text)val6).enableWordWrapping = false;
		TMP_Text label;
		GameObject val7 = BuildBadge(val, value6, out label);
		val7.SetActive(false);
		SleekNotifEntry item = new SleekNotifEntry
		{
			Root = val,
			Rect = component,
			CG = val2,
			Label = (TMP_Text)(object)val6,
			IconImage = val3,
			BadgeRoot = val7,
			BadgeLabel = label,
			Topic = notif.Topic,
			Body = notif.Body,
			Icon = notif.Icon,
			StackCount = 1,
			CurrentPhase = SleekNotifEntry.Phase.SlideIn,
			PhaseTimer = 0f,
			SlotIndex = count,
			TargetX = targetX,
			OffscreenX = num,
			TargetY = num2,
			StaggerOffset = (float)count * SleekNotifyPlugin.StaggerDelay.Value
		};
		_active.Add(item);
	}

	private static void BuildChrome(GameObject parent)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: 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_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: 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_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		Color value = SleekNotifyPlugin.BackgroundColor.Value;
		Color value2 = SleekNotifyPlugin.BorderColor.Value;
		float value3 = SleekNotifyPlugin.BorderThickness.Value;
		MakeImg(parent, "Border", Vector2.zero, Vector2.one, Vector2.zero, Vector2.zero, value2);
		MakeImg(parent, "Background", Vector2.zero, Vector2.one, new Vector2(value3, value3), new Vector2(0f - value3, 0f - value3), value);
		RectTransform component = MakeImg(parent, "Shimmer", new Vector2(0f, 1f), new Vector2(1f, 1f), new Vector2(value3, 0f - value3), new Vector2(0f - value3, 0f - value3), new Color(value2.r, value2.g, value2.b, 0.45f)).GetComponent<RectTransform>();
		component.pivot = new Vector2(0.5f, 1f);
		component.sizeDelta = new Vector2(0f, 1f);
		RectTransform component2 = MakeImg(parent, "Accent", new Vector2(0f, 0f), new Vector2(0f, 1f), new Vector2(value3, value3), new Vector2(0f, 0f - value3), new Color(Mathf.Min(value2.r * 1.5f, 1f), Mathf.Min(value2.g * 1.3f, 1f), value2.b * 0.6f, 1f)).GetComponent<RectTransform>();
		component2.pivot = new Vector2(0f, 0.5f);
		component2.sizeDelta = new Vector2(3f, 0f);
	}

	private static GameObject BuildBadge(GameObject parent, float thick, out TMP_Text label)
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Expected O, but got Unknown
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: 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_0149: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("Badge", new Type[1] { typeof(RectTransform) });
		val.transform.SetParent(parent.transform, false);
		RectTransform component = val.GetComponent<RectTransform>();
		component.anchorMin = new Vector2(1f, 0f);
		component.anchorMax = new Vector2(1f, 0f);
		component.pivot = new Vector2(1f, 0f);
		component.anchoredPosition = new Vector2(0f - (thick + 3f), thick + 3f);
		component.sizeDelta = new Vector2(30f, 16f);
		((Graphic)val.AddComponent<Image>()).color = SleekNotifyPlugin.BorderColor.Value;
		GameObject val2 = new GameObject("Text", new Type[1] { typeof(RectTransform) });
		val2.transform.SetParent(val.transform, false);
		RectTransform component2 = val2.GetComponent<RectTransform>();
		component2.anchorMin = Vector2.zero;
		component2.anchorMax = Vector2.one;
		component2.offsetMin = Vector2.zero;
		component2.offsetMax = Vector2.zero;
		TextMeshProUGUI val3 = val2.AddComponent<TextMeshProUGUI>();
		((TMP_Text)val3).text = "x1";
		((TMP_Text)val3).fontSize = 10f;
		((Graphic)val3).color = new Color(0.05f, 0.04f, 0.02f, 1f);
		((TMP_Text)val3).alignment = (TextAlignmentOptions)514;
		((TMP_Text)val3).fontStyle = (FontStyles)1;
		label = (TMP_Text)(object)val3;
		return val;
	}

	private static GameObject MakeImg(GameObject parent, string name, Vector2 anchorMin, Vector2 anchorMax, Vector2 offsetMin, Vector2 offsetMax, Color color)
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: 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_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Expected O, but got Unknown
		GameObject val = new GameObject(name, new Type[1] { typeof(RectTransform) });
		val.transform.SetParent(parent.transform, false);
		RectTransform component = val.GetComponent<RectTransform>();
		component.anchorMin = anchorMin;
		component.anchorMax = anchorMax;
		component.offsetMin = offsetMin;
		component.offsetMax = offsetMax;
		((Graphic)val.AddComponent<Image>()).color = color;
		return val;
	}

	private bool TickEntry(SleekNotifEntry e, float dt)
	{
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		e.PhaseTimer += dt;
		switch (e.CurrentPhase)
		{
		case SleekNotifEntry.Phase.SlideIn:
		{
			float num4 = e.PhaseTimer - e.StaggerOffset;
			if (num4 < 0f)
			{
				return false;
			}
			float num5 = EaseOutCubic(num4 / SleekNotifyPlugin.SlideInDuration.Value);
			float num6 = EaseOutCubic(num4 / Mathf.Max(SleekNotifyPlugin.FadeInDuration.Value, 0.001f));
			e.Rect.anchoredPosition = new Vector2(Mathf.Lerp(e.OffscreenX, e.TargetX, num5), e.Rect.anchoredPosition.y);
			e.CG.alpha = Mathf.Clamp01(num6);
			if (num5 >= 1f)
			{
				e.Rect.anchoredPosition = new Vector2(e.TargetX, e.Rect.anchoredPosition.y);
				e.CG.alpha = 1f;
				e.PhaseTimer = 0f;
				e.CurrentPhase = SleekNotifEntry.Phase.Hold;
			}
			break;
		}
		case SleekNotifEntry.Phase.Hold:
			if (e.PhaseTimer >= SleekNotifyPlugin.DisplayDuration.Value)
			{
				e.StaggerOffset = (float)(_active.Count - 1 - e.SlotIndex) * SleekNotifyPlugin.StaggerDelay.Value;
				e.PhaseTimer = 0f;
				e.CurrentPhase = SleekNotifEntry.Phase.SlideOut;
			}
			break;
		case SleekNotifEntry.Phase.SlideOut:
		{
			float num = e.PhaseTimer - e.StaggerOffset;
			if (num < 0f)
			{
				return false;
			}
			float num2 = EaseInCubic(num / SleekNotifyPlugin.SlideOutDuration.Value);
			float num3 = EaseInCubic(num / Mathf.Max(SleekNotifyPlugin.FadeOutDuration.Value, 0.001f));
			e.Rect.anchoredPosition = new Vector2(Mathf.Lerp(e.TargetX, e.OffscreenX, num2), e.Rect.anchoredPosition.y);
			e.CG.alpha = Mathf.Clamp01(1f - num3);
			if (num2 >= 1f)
			{
				e.CurrentPhase = SleekNotifEntry.Phase.Done;
				return true;
			}
			break;
		}
		}
		return false;
	}

	private void RebuildTargetPositions()
	{
		float value = SleekNotifyPlugin.NotifHeight.Value;
		float value2 = SleekNotifyPlugin.NotifSpacing.Value;
		float value3 = SleekNotifyPlugin.ScreenEdgeMarginY.Value;
		for (int i = 0; i < _active.Count; i++)
		{
			_active[i].SlotIndex = i;
			_active[i].TargetY = 0f - (value3 + (float)i * (value + value2));
		}
	}

	private static void DestroyEntry(SleekNotifEntry e)
	{
		if ((Object)(object)e.Root != (Object)null)
		{
			Object.Destroy((Object)(object)e.Root);
		}
	}
}
[BepInPlugin("yourname.SleekNotify", "SleekNotify", "1.2.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class SleekNotifyPlugin : BaseUnityPlugin
{
	public const string PluginGUID = "yourname.SleekNotify";

	public const string PluginName = "SleekNotify";

	public const string PluginVersion = "1.2.0";

	public static ConfigEntry<float> NotifWidth;

	public static ConfigEntry<float> NotifHeight;

	public static ConfigEntry<int> FontSize;

	public static ConfigEntry<Color> BackgroundColor;

	public static ConfigEntry<Color> BorderColor;

	public static ConfigEntry<float> BorderThickness;

	public static ConfigEntry<Color> TextColor;

	public static ConfigEntry<float> IconSize;

	public static ConfigEntry<float> IconPadding;

	public static ConfigEntry<float> DisplayDuration;

	public static ConfigEntry<float> SlideInDuration;

	public static ConfigEntry<float> SlideOutDuration;

	public static ConfigEntry<float> StaggerDelay;

	public static ConfigEntry<float> FadeInDuration;

	public static ConfigEntry<float> FadeOutDuration;

	public static ConfigEntry<float> SlotMoveSpeed;

	public static ConfigEntry<float> NotifSpacing;

	public static ConfigEntry<int> MaxVisible;

	public static ConfigEntry<float> ScreenEdgeMarginX;

	public static ConfigEntry<float> ScreenEdgeMarginY;

	public static ConfigEntry<bool> InterceptTopLeft;

	public static ConfigEntry<bool> StackDuplicates;

	public static ConfigEntry<float> StackWindow;

	private Harmony _harmony;

	private void Awake()
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Expected O, but got Unknown
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Expected O, but got Unknown
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Expected O, but got Unknown
		//IL_00d1: 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_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: Expected O, but got Unknown
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ca: Expected O, but got Unknown
		//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: Expected O, but got Unknown
		//IL_023a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: Expected O, but got Unknown
		//IL_0277: Unknown result type (might be due to invalid IL or missing references)
		//IL_0281: Expected O, but got Unknown
		//IL_02b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02be: Expected O, but got Unknown
		//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fb: Expected O, but got Unknown
		//IL_032e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0338: Expected O, but got Unknown
		//IL_036b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0375: Expected O, but got Unknown
		//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b2: Expected O, but got Unknown
		//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ef: Expected O, but got Unknown
		//IL_0418: Unknown result type (might be due to invalid IL or missing references)
		//IL_0422: Expected O, but got Unknown
		//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e7: Expected O, but got Unknown
		//IL_04f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04fc: Expected O, but got Unknown
		NotifWidth = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "Width", 260f, new ConfigDescription("Width of each notification panel in pixels.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(80f, 700f), Array.Empty<object>()));
		NotifHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "Height", 32f, new ConfigDescription("Height of each notification panel in pixels (single line).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(20f, 120f), Array.Empty<object>()));
		FontSize = ((BaseUnityPlugin)this).Config.Bind<int>("Appearance", "FontSize", 12, new ConfigDescription("Font size for notification text.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(6, 36), Array.Empty<object>()));
		BackgroundColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Appearance", "BackgroundColor", new Color(0.08f, 0.06f, 0.04f, 0.92f), "Background fill colour (RGBA). Default is a dark warm brown.");
		BorderColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Appearance", "BorderColor", new Color(0.72f, 0.58f, 0.28f, 1f), "Border colour. Default is parchment gold.");
		BorderThickness = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "BorderThickness", 2f, new ConfigDescription("Outer border thickness in pixels.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>()));
		TextColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Appearance", "TextColor", new Color(0.95f, 0.9f, 0.78f, 1f), "Notification text colour.");
		IconSize = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "IconSize", 22f, new ConfigDescription("Item icon size in pixels. Set to 0 to hide icons.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 80f), Array.Empty<object>()));
		IconPadding = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "IconPadding", 4f, new ConfigDescription("Gap between icon and text in pixels.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 20f), Array.Empty<object>()));
		DisplayDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Timing", "DisplayDuration", 3f, new ConfigDescription("Seconds each panel stays visible.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 20f), Array.Empty<object>()));
		SlideInDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Timing", "SlideInDuration", 0.22f, new ConfigDescription("Slide-in animation duration (seconds).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 2f), Array.Empty<object>()));
		SlideOutDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Timing", "SlideOutDuration", 0.18f, new ConfigDescription("Slide-out animation duration (seconds).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 2f), Array.Empty<object>()));
		StaggerDelay = ((BaseUnityPlugin)this).Config.Bind<float>("Timing", "StaggerDelay", 0.06f, new ConfigDescription("Extra delay per slot for the cascade wave effect (seconds).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
		FadeInDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Timing", "FadeInDuration", 0.14f, new ConfigDescription("Alpha fade-in duration (seconds).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
		FadeOutDuration = ((BaseUnityPlugin)this).Config.Bind<float>("Timing", "FadeOutDuration", 0.14f, new ConfigDescription("Alpha fade-out duration (seconds).", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 1f), Array.Empty<object>()));
		SlotMoveSpeed = ((BaseUnityPlugin)this).Config.Bind<float>("Timing", "SlotMoveSpeed", 12f, new ConfigDescription("Speed panels lerp into a new slot when one above exits.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 60f), Array.Empty<object>()));
		NotifSpacing = ((BaseUnityPlugin)this).Config.Bind<float>("Layout", "Spacing", 4f, new ConfigDescription("Vertical gap between stacked panels in pixels.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 40f), Array.Empty<object>()));
		MaxVisible = ((BaseUnityPlugin)this).Config.Bind<int>("Layout", "MaxVisible", 10, new ConfigDescription("Maximum panels shown at once. Excess is queued.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 25), Array.Empty<object>()));
		ScreenEdgeMarginX = ((BaseUnityPlugin)this).Config.Bind<float>("Layout", "ScreenEdgeMarginX", 12f, "Distance from the LEFT edge of the screen in pixels.");
		ScreenEdgeMarginY = ((BaseUnityPlugin)this).Config.Bind<float>("Layout", "ScreenEdgeMarginY", 200f, "Distance from the TOP edge of the screen in pixels.");
		InterceptTopLeft = ((BaseUnityPlugin)this).Config.Bind<bool>("Behaviour", "InterceptTopLeft", true, "Route TopLeft ShowMessage calls through SleekNotify. Set false to leave them vanilla.");
		StackDuplicates = ((BaseUnityPlugin)this).Config.Bind<bool>("Behaviour", "StackDuplicates", true, "Merge identical messages within StackWindow seconds into one panel with a x N badge.");
		StackWindow = ((BaseUnityPlugin)this).Config.Bind<float>("Behaviour", "StackWindow", 1.5f, new ConfigDescription("Seconds in which a duplicate merges rather than spawning a new panel.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>()));
		_harmony = new Harmony("yourname.SleekNotify");
		_harmony.PatchAll(Assembly.GetExecutingAssembly());
		((BaseUnityPlugin)this).Logger.LogInfo((object)"SleekNotify v1.2.0 loaded.");
	}

	private void OnDestroy()
	{
		Harmony harmony = _harmony;
		if (harmony != null)
		{
			harmony.UnpatchSelf();
		}
	}
}