Decompiled source of InstantMonsterLootDrop v0.8.2

InstantMonsterDrop.dll

Decompiled 3 weeks 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 BepInEx;
using BepInEx.Configuration;
using HarmonyLib;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.8.2")]
[assembly: AssemblyInformationalVersion("0.8.2+450aed4a5fb555cf8453bc36004aea97baefb473")]
[assembly: AssemblyVersion("0.8.2.0")]
namespace InstantMonsterDrop;

public enum NotificationAnchor
{
	BottomRight,
	BottomLeft,
	TopRight,
	TopLeft
}
[BepInPlugin("cjayride.InstantMonsterDrop", "Instant Monster Drop", "0.8.2")]
public class BepInExPlugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(Terminal), "InitTerminal")]
	private static class Terminal_InitTerminal_Patch
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static ConsoleEvent <>9__0_0;

			internal void <Postfix>b__0_0(ConsoleEventArgs args)
			{
				int num = ForceCleanupRagdolls();
				if ((Object)(object)Console.instance != (Object)null)
				{
					Console.instance.Print("InstantMonsterDrop removed " + num + " ragdolls.");
				}
				if ((Object)(object)Player.m_localPlayer != (Object)null)
				{
					((Character)Player.m_localPlayer).Message((MessageType)2, "Removed " + num + " leftover corpses", 0, (Sprite)null, false);
				}
			}
		}

		private static void Postfix()
		{
			//IL_0041: 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_0037: Expected O, but got Unknown
			if (commandsRegistered)
			{
				return;
			}
			commandsRegistered = true;
			object obj = <>c.<>9__0_0;
			if (obj == null)
			{
				ConsoleEvent val = delegate
				{
					int num = ForceCleanupRagdolls();
					if ((Object)(object)Console.instance != (Object)null)
					{
						Console.instance.Print("InstantMonsterDrop removed " + num + " ragdolls.");
					}
					if ((Object)(object)Player.m_localPlayer != (Object)null)
					{
						((Character)Player.m_localPlayer).Message((MessageType)2, "Removed " + num + " leftover corpses", 0, (Sprite)null, false);
					}
				};
				<>c.<>9__0_0 = val;
				obj = (object)val;
			}
			new ConsoleCommand("imd_cleanup", "Remove leftover InstantMonsterDrop ragdolls", (ConsoleEvent)obj, false, false, false, false, false, false, (ConsoleOptionsFetcher)null, false, false, false);
		}
	}

	[HarmonyPatch(typeof(Ragdoll), "Awake")]
	private static class Ragdoll_Awake_Patch
	{
		private static void Postfix(Ragdoll __instance, ZNetView ___m_nview, EffectList ___m_removeEffect)
		{
			if (Object.op_Implicit((Object)(object)ZNetScene.instance))
			{
				ScheduleRagdoll(__instance, ___m_nview, ___m_removeEffect);
			}
		}
	}

	[HarmonyPatch(typeof(Ragdoll), "DestroyNow")]
	private static class Ragdoll_DestroyNow_Patch
	{
		private static bool Prefix()
		{
			return !modEnabled.Value;
		}
	}

	[HarmonyPatch(typeof(ItemDrop), "Awake")]
	private static class ItemDrop_Awake_Patch
	{
		private static void Postfix(ItemDrop __instance)
		{
			if (spawningLoot && !(autoPickupDelay.Value <= 0f) && __instance.m_autoPickup)
			{
				__instance.m_autoPickup = false;
				((MonoBehaviour)context).StartCoroutine(EnableAutoPickupLater(__instance, autoPickupDelay.Value));
			}
		}
	}

	[HarmonyPatch(typeof(Player), "AutoPickup")]
	private static class Player_AutoPickup_Patch
	{
		private static void Prefix(Player __instance)
		{
			if (modEnabled.Value && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
			{
				__instance.m_autoPickupRange = autoPickupRange.Value;
			}
		}
	}

	[HarmonyPatch(typeof(Player), "OnSpawned")]
	private static class Player_OnSpawned_Patch
	{
		private static void Postfix(Player __instance)
		{
			if (modEnabled.Value && !((Object)(object)__instance != (Object)(object)Player.m_localPlayer))
			{
				((MonoBehaviour)context).StartCoroutine(SweepLoadedRagdolls());
			}
		}
	}

	[HarmonyPatch(typeof(Character), "ShowPickupMessage")]
	private static class Character_ShowPickupMessage_Patch
	{
		private static bool Prefix(Character __instance, ItemData item, int amount)
		{
			if (!modEnabled.Value || !NotificationEnabled || (Object)(object)__instance != (Object)(object)Player.m_localPlayer)
			{
				return true;
			}
			if ((Object)(object)PickupFeed.Instance != (Object)null)
			{
				PickupFeed.Instance.Add(item, amount);
			}
			return false;
		}
	}

	internal const string LootedKey = "IMD_Looted";

	private static BepInExPlugin context;

	private static ConfigEntry<bool> modEnabled;

	private static ConfigEntry<float> dropDelay;

	private static ConfigEntry<float> destroyDelay;

	private static ConfigEntry<float> autoPickupDelay;

	private static ConfigEntry<float> autoPickupRange;

	private static ConfigEntry<bool> notificationEnabled;

	private static ConfigEntry<int> notificationX;

	private static ConfigEntry<int> notificationY;

	private static ConfigEntry<int> notificationWidth;

	private static ConfigEntry<int> notificationHeight;

	private static ConfigEntry<float> notificationOpacity;

	private static ConfigEntry<float> notificationLinger;

	private static ConfigEntry<int> notificationFontSize;

	private static ConfigEntry<NotificationAnchor> notificationAnchor;

	private static ConfigEntry<bool> notificationShowBorders;

	private static ConfigEntry<bool> notificationTextOutline;

	private static ConfigEntry<Color> notificationTextColor;

	private static ConfigEntry<Color> notificationAmountColor;

	private static ConfigEntry<Color> notificationOutlineColor;

	private static bool spawningLoot;

	private static bool commandsRegistered;

	private static readonly HashSet<int> scheduledRagdolls = new HashSet<int>();

	internal static bool ModEnabled
	{
		get
		{
			if (modEnabled != null)
			{
				return modEnabled.Value;
			}
			return false;
		}
	}

	internal static bool NotificationEnabled
	{
		get
		{
			if (notificationEnabled != null)
			{
				return notificationEnabled.Value;
			}
			return true;
		}
	}

	internal static int NotificationX
	{
		get
		{
			if (notificationX == null)
			{
				return 20;
			}
			return notificationX.Value;
		}
	}

	internal static int NotificationY
	{
		get
		{
			if (notificationY == null)
			{
				return 20;
			}
			return notificationY.Value;
		}
	}

	internal static int NotificationWidth
	{
		get
		{
			if (notificationWidth == null)
			{
				return 250;
			}
			return Mathf.Max(80, notificationWidth.Value);
		}
	}

	internal static int NotificationHeight
	{
		get
		{
			if (notificationHeight == null)
			{
				return 120;
			}
			return Mathf.Max(40, notificationHeight.Value);
		}
	}

	internal static float NotificationOpacity
	{
		get
		{
			if (notificationOpacity == null)
			{
				return 0.72f;
			}
			return Mathf.Clamp01(notificationOpacity.Value);
		}
	}

	internal static float NotificationLinger
	{
		get
		{
			if (notificationLinger == null)
			{
				return 8f;
			}
			return Mathf.Max(0.5f, notificationLinger.Value);
		}
	}

	internal static int NotificationFontSize
	{
		get
		{
			if (notificationFontSize == null)
			{
				return 15;
			}
			return Mathf.Clamp(notificationFontSize.Value, 8, 48);
		}
	}

	internal static NotificationAnchor Anchor
	{
		get
		{
			if (notificationAnchor == null)
			{
				return NotificationAnchor.BottomRight;
			}
			return notificationAnchor.Value;
		}
	}

	internal static bool ShowBorders
	{
		get
		{
			if (notificationShowBorders != null)
			{
				return notificationShowBorders.Value;
			}
			return false;
		}
	}

	internal static bool TextOutline
	{
		get
		{
			if (notificationTextOutline != null)
			{
				return notificationTextOutline.Value;
			}
			return true;
		}
	}

	internal static Color TextColor
	{
		get
		{
			//IL_0012: 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)
			if (notificationTextColor == null)
			{
				return Color.white;
			}
			return notificationTextColor.Value;
		}
	}

	internal static Color AmountColor
	{
		get
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			if (notificationAmountColor == null)
			{
				return new Color(0.95f, 0.9f, 0.75f);
			}
			return notificationAmountColor.Value;
		}
	}

	internal static Color OutlineColor
	{
		get
		{
			//IL_0012: 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)
			if (notificationOutlineColor == null)
			{
				return Color.black;
			}
			return notificationOutlineColor.Value;
		}
	}

	private void Awake()
	{
		//IL_0236: Unknown result type (might be due to invalid IL or missing references)
		//IL_0269: Unknown result type (might be due to invalid IL or missing references)
		//IL_028d: Unknown result type (might be due to invalid IL or missing references)
		context = this;
		modEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Enable this mod");
		dropDelay = ((BaseUnityPlugin)this).Config.Bind<float>("General", "DropDelay", 0.05f, "Delay before dropping loot");
		destroyDelay = ((BaseUnityPlugin)this).Config.Bind<float>("General", "DestroyDelay", 60f, "Seconds the ragdoll stays on the ground before it is destroyed");
		autoPickupDelay = ((BaseUnityPlugin)this).Config.Bind<float>("General", "AutoPickupDelay", 1f, "Seconds before dropped monster loot can be auto-picked up. 0 is vanilla auto-pickup timing");
		autoPickupRange = ((BaseUnityPlugin)this).Config.Bind<float>("General", "AutoPickupRange", 2.5f, "Auto-pickup radius in meters");
		notificationEnabled = ((BaseUnityPlugin)this).Config.Bind<bool>("Notification", "Enabled", true, "Show the stacked loot window. Disable to restore vanilla one-at-a-time pickup messages");
		notificationAnchor = ((BaseUnityPlugin)this).Config.Bind<NotificationAnchor>("Notification", "Anchor", NotificationAnchor.BottomRight, "Corner of the screen the window is offset from");
		notificationX = ((BaseUnityPlugin)this).Config.Bind<int>("Notification", "WindowX", 20, "Horizontal offset from the chosen corner, in pixels");
		notificationY = ((BaseUnityPlugin)this).Config.Bind<int>("Notification", "WindowY", 20, "Vertical offset from the chosen corner, in pixels");
		notificationWidth = ((BaseUnityPlugin)this).Config.Bind<int>("Notification", "WindowWidth", 250, "Loot window width in pixels");
		notificationHeight = ((BaseUnityPlugin)this).Config.Bind<int>("Notification", "WindowHeight", 120, "Loot window height in pixels");
		notificationOpacity = ((BaseUnityPlugin)this).Config.Bind<float>("Notification", "Opacity", 0.72f, "Window background opacity from 0 (invisible) to 1 (solid)");
		notificationLinger = ((BaseUnityPlugin)this).Config.Bind<float>("Notification", "Linger", 8f, "Seconds each pickup line stays in the window");
		notificationFontSize = ((BaseUnityPlugin)this).Config.Bind<int>("Notification", "FontSize", 15, "Font size for pickup names and amounts");
		notificationShowBorders = ((BaseUnityPlugin)this).Config.Bind<bool>("Notification", "ShowBorders", false, "Draw the gold side bar and top line on the loot window");
		notificationTextOutline = ((BaseUnityPlugin)this).Config.Bind<bool>("Notification", "TextOutline", true, "Draw a dark stroke around loot text so it stays readable");
		notificationTextColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Notification", "TextColor", Color.white, "Item name color");
		notificationAmountColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Notification", "AmountColor", new Color(0.95f, 0.9f, 0.75f), "Item count color");
		notificationOutlineColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Notification", "OutlineColor", Color.black, "Text outline color");
		((BaseUnityPlugin)this).Config.Save();
		if (modEnabled.Value)
		{
			((Component)this).gameObject.AddComponent<PickupFeed>();
			Harmony.CreateAndPatchAll(Assembly.GetExecutingAssembly(), (string)null);
		}
	}

	internal static int ForceCleanupRagdolls()
	{
		int num = 0;
		Ragdoll[] array = Object.FindObjectsByType<Ragdoll>((FindObjectsSortMode)0);
		foreach (Ragdoll val in array)
		{
			if (!((Object)(object)val == (Object)null))
			{
				ZNetView component = ((Component)val).GetComponent<ZNetView>();
				if ((Object)(object)component != (Object)null && component.IsValid() && !component.IsOwner())
				{
					component.ClaimOwnership();
				}
				if (Object.op_Implicit((Object)(object)ZNetScene.instance))
				{
					ZNetScene.instance.Destroy(((Component)val).gameObject);
					num++;
				}
			}
		}
		return num;
	}

	private static void ScheduleRagdoll(Ragdoll ragdoll, ZNetView nview, EffectList removeEffect)
	{
		if (!((Object)(object)ragdoll == (Object)null))
		{
			int instanceID = ((Object)ragdoll).GetInstanceID();
			if (scheduledRagdolls.Add(instanceID))
			{
				((MonoBehaviour)context).StartCoroutine(DropNow(ragdoll, nview, removeEffect, instanceID));
			}
		}
	}

	private static IEnumerator SweepLoadedRagdolls()
	{
		yield return (object)new WaitForSeconds(2f);
		if (!modEnabled.Value)
		{
			yield break;
		}
		Ragdoll[] array = Object.FindObjectsByType<Ragdoll>((FindObjectsSortMode)0);
		foreach (Ragdoll val in array)
		{
			if (!((Object)(object)val == (Object)null))
			{
				ZNetView component = ((Component)val).GetComponent<ZNetView>();
				EffectList value = Traverse.Create((object)val).Field("m_removeEffect").GetValue<EffectList>();
				ScheduleRagdoll(val, component, value);
			}
		}
	}

	private static IEnumerator DropNow(Ragdoll ragdoll, ZNetView nview, EffectList removeEffect, int id)
	{
		if (dropDelay.Value >= 0f)
		{
			yield return (object)new WaitForSeconds(dropDelay.Value);
		}
		if (!modEnabled.Value)
		{
			scheduledRagdolls.Remove(id);
			yield break;
		}
		if ((Object)(object)ragdoll != (Object)null && (Object)(object)nview != (Object)null && nview.IsValid() && nview.IsOwner() && !WasLooted(nview))
		{
			Vector3 averageBodyPosition = ragdoll.GetAverageBodyPosition();
			spawningLoot = true;
			try
			{
				Traverse.Create((object)ragdoll).Method("SpawnLoot", new object[1] { averageBodyPosition }).GetValue();
				MarkLooted(nview);
			}
			finally
			{
				spawningLoot = false;
			}
		}
		yield return ((MonoBehaviour)context).StartCoroutine(DestroyNow(ragdoll, nview, removeEffect));
		scheduledRagdolls.Remove(id);
	}

	private static IEnumerator DestroyNow(Ragdoll ragdoll, ZNetView nview, EffectList m_removeEffect)
	{
		yield return (object)new WaitForSeconds(Mathf.Max(destroyDelay.Value - Mathf.Max(dropDelay.Value, 0f), 0f));
		float waited = 0f;
		while (modEnabled.Value && (Object)(object)ragdoll != (Object)null && (Object)(object)nview != (Object)null && nview.IsValid() && waited < 30f)
		{
			if (!nview.IsOwner())
			{
				nview.ClaimOwnership();
			}
			if (nview.IsOwner())
			{
				Vector3 averageBodyPosition = ragdoll.GetAverageBodyPosition();
				if (m_removeEffect != null)
				{
					m_removeEffect.Create(averageBodyPosition, Quaternion.identity, (Transform)null, 1f, -1, ZDOID.None);
				}
				if (Object.op_Implicit((Object)(object)ZNetScene.instance))
				{
					ZNetScene.instance.Destroy(((Component)ragdoll).gameObject);
				}
				break;
			}
			yield return (object)new WaitForSeconds(0.5f);
			waited += 0.5f;
		}
	}

	private static bool WasLooted(ZNetView nview)
	{
		ZDO val = (((Object)(object)nview != (Object)null) ? nview.GetZDO() : null);
		if (val != null)
		{
			return val.GetInt("IMD_Looted", 0) == 1;
		}
		return false;
	}

	private static void MarkLooted(ZNetView nview)
	{
		ZDO val = (((Object)(object)nview != (Object)null) ? nview.GetZDO() : null);
		if (val != null)
		{
			val.Set("IMD_Looted", 1);
		}
	}

	private static IEnumerator EnableAutoPickupLater(ItemDrop drop, float delay)
	{
		yield return (object)new WaitForSeconds(delay);
		if ((Object)(object)drop != (Object)null)
		{
			drop.m_autoPickup = true;
		}
	}
}
public class PickupFeed : MonoBehaviour
{
	private class Line
	{
		public string Name;

		public int Amount;

		public Texture Icon;

		public Rect Uv;

		public float Age;

		public float Punch;

		public float Slide;
	}

	private const float FadeOut = 0.8f;

	private readonly List<Line> lines = new List<Line>();

	private Texture2D pixel;

	private GUIStyle nameStyle;

	private GUIStyle amountStyle;

	private float panelAlpha;

	private int cachedFontSize = -1;

	public static PickupFeed Instance { get; private set; }

	private static float LineHeight => (float)BepInExPlugin.NotificationFontSize + 9f;

	private void Awake()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Expected O, but got Unknown
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		Instance = this;
		pixel = new Texture2D(1, 1, (TextureFormat)4, false);
		pixel.SetPixel(0, 0, Color.white);
		pixel.Apply();
		((Object)pixel).hideFlags = (HideFlags)61;
	}

	private void OnDestroy()
	{
		if ((Object)(object)Instance == (Object)(object)this)
		{
			Instance = null;
		}
		if ((Object)(object)pixel != (Object)null)
		{
			Object.Destroy((Object)(object)pixel);
		}
	}

	public void Add(ItemData item, int amount)
	{
		//IL_0231: Unknown result type (might be due to invalid IL or missing references)
		//IL_0232: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e2: 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)
		if (!BepInExPlugin.NotificationEnabled || item == null || item.m_shared == null || amount <= 0)
		{
			return;
		}
		string text = item.m_shared.m_name;
		if (Localization.instance != null)
		{
			text = Localization.instance.Localize(text);
		}
		if (string.IsNullOrEmpty(text))
		{
			text = (((Object)(object)item.m_dropPrefab != (Object)null) ? ((Object)item.m_dropPrefab).name : "Item");
		}
		Texture icon = null;
		Rect uv = default(Rect);
		((Rect)(ref uv))..ctor(0f, 0f, 1f, 1f);
		Sprite[] icons = item.m_shared.m_icons;
		if (icons != null && icons.Length != 0 && (Object)(object)icons[0] != (Object)null)
		{
			Sprite val = icons[Mathf.Clamp(item.m_variant, 0, icons.Length - 1)];
			if ((Object)(object)val != (Object)null && (Object)(object)val.texture != (Object)null)
			{
				icon = (Texture)(object)val.texture;
				Rect textureRect = val.textureRect;
				float num = ((Texture)val.texture).width;
				float num2 = ((Texture)val.texture).height;
				if (num > 0f && num2 > 0f && ((Rect)(ref textureRect)).width > 0f && ((Rect)(ref textureRect)).height > 0f)
				{
					((Rect)(ref uv))..ctor(((Rect)(ref textureRect)).x / num, ((Rect)(ref textureRect)).y / num2, ((Rect)(ref textureRect)).width / num, ((Rect)(ref textureRect)).height / num2);
				}
			}
		}
		for (int i = 0; i < lines.Count; i++)
		{
			if (lines[i].Name == text)
			{
				lines[i].Amount += amount;
				lines[i].Age = 0f;
				lines[i].Punch = 1f;
				Line item2 = lines[i];
				lines.RemoveAt(i);
				lines.Add(item2);
				return;
			}
		}
		lines.Add(new Line
		{
			Name = text,
			Amount = amount,
			Icon = icon,
			Uv = uv,
			Age = 0f,
			Punch = 1f,
			Slide = 0f
		});
		float num3 = BepInExPlugin.NotificationHeight;
		int num4 = Mathf.Max(1, Mathf.FloorToInt((num3 - 16f) / LineHeight));
		while (lines.Count > num4)
		{
			lines.RemoveAt(0);
		}
	}

	private void Update()
	{
		if (!BepInExPlugin.NotificationEnabled)
		{
			lines.Clear();
			panelAlpha = 0f;
			return;
		}
		float unscaledDeltaTime = Time.unscaledDeltaTime;
		float notificationLinger = BepInExPlugin.NotificationLinger;
		for (int num = lines.Count - 1; num >= 0; num--)
		{
			Line line = lines[num];
			line.Age += unscaledDeltaTime;
			line.Punch = Mathf.MoveTowards(line.Punch, 0f, unscaledDeltaTime * 4f);
			line.Slide = Mathf.MoveTowards(line.Slide, 1f, unscaledDeltaTime * 8f);
			if (line.Age >= notificationLinger)
			{
				lines.RemoveAt(num);
			}
		}
		float num2 = ((lines.Count > 0) ? 1f : 0f);
		panelAlpha = Mathf.MoveTowards(panelAlpha, num2, unscaledDeltaTime * 5f);
	}

	private void OnGUI()
	{
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0192: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: Unknown result type (might be due to invalid IL or missing references)
		//IL_0150: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_027c: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_034d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0352: Unknown result type (might be due to invalid IL or missing references)
		//IL_0354: Unknown result type (might be due to invalid IL or missing references)
		//IL_0359: Unknown result type (might be due to invalid IL or missing references)
		//IL_0376: Unknown result type (might be due to invalid IL or missing references)
		//IL_0385: Unknown result type (might be due to invalid IL or missing references)
		//IL_038f: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ad: Unknown result type (might be due to invalid IL or missing references)
		if (!BepInExPlugin.ModEnabled || !BepInExPlugin.NotificationEnabled || panelAlpha <= 0.01f || (Object)(object)Player.m_localPlayer == (Object)null || ((Object)(object)Hud.instance != (Object)null && Hud.IsUserHidden()))
		{
			return;
		}
		EnsureStyles();
		float num = BepInExPlugin.NotificationWidth;
		float num2 = BepInExPlugin.NotificationHeight;
		GetWindowRect(num, num2, out var x, out var y);
		Rect val = default(Rect);
		((Rect)(ref val))..ctor(x, y, num, num2);
		float num3 = BepInExPlugin.NotificationOpacity * panelAlpha;
		bool flag = BepInExPlugin.Anchor == NotificationAnchor.BottomRight || BepInExPlugin.Anchor == NotificationAnchor.TopRight;
		float num4 = AmountColumnWidth(num);
		Color color = GUI.color;
		GUI.color = new Color(0.04f, 0.05f, 0.06f, num3);
		GUI.DrawTexture(val, (Texture)(object)pixel);
		if (BepInExPlugin.ShowBorders)
		{
			GUI.color = new Color(0.82f, 0.68f, 0.32f, Mathf.Min(1f, num3 + 0.12f));
			GUI.DrawTexture(new Rect(flag ? (((Rect)(ref val)).xMax - 3f) : ((Rect)(ref val)).x, ((Rect)(ref val)).y, 3f, ((Rect)(ref val)).height), (Texture)(object)pixel);
			GUI.color = new Color(1f, 1f, 1f, 0.1f * panelAlpha);
			GUI.DrawTexture(new Rect(((Rect)(ref val)).x, ((Rect)(ref val)).y, ((Rect)(ref val)).width, 1f), (Texture)(object)pixel);
		}
		float lineHeight = LineHeight;
		float notificationLinger = BepInExPlugin.NotificationLinger;
		GUI.BeginGroup(val);
		float num5 = ((Rect)(ref val)).height - 8f;
		Rect val2 = default(Rect);
		Rect rect = default(Rect);
		Rect rect2 = default(Rect);
		for (int num6 = lines.Count - 1; num6 >= 0; num6--)
		{
			Line line = lines[num6];
			num5 -= lineHeight;
			if (num5 < 6f)
			{
				break;
			}
			float num7 = 1f;
			if (line.Age > notificationLinger - 0.8f)
			{
				num7 = Mathf.Clamp01((notificationLinger - line.Age) / 0.8f);
			}
			num7 *= panelAlpha;
			float num8 = (1f - line.Slide) * 36f;
			if (!flag)
			{
				num8 = 0f - num8;
			}
			float num9 = 1f + line.Punch * 0.08f;
			((Rect)(ref val2))..ctor(10f + num8, num5, ((Rect)(ref val)).width - 18f, lineHeight);
			GUI.color = new Color(1f, 1f, 1f, num7);
			if ((Object)(object)line.Icon != (Object)null)
			{
				float num10 = (lineHeight - 6f) * num9;
				GUI.DrawTextureWithTexCoords(new Rect(((Rect)(ref val2)).x, ((Rect)(ref val2)).y + (lineHeight - num10) * 0.5f, num10, num10), line.Icon, line.Uv);
			}
			float num11 = (((Object)(object)line.Icon != (Object)null) ? lineHeight : 4f);
			((Rect)(ref rect))..ctor(((Rect)(ref val2)).x + num11, ((Rect)(ref val2)).y, Mathf.Max(20f, ((Rect)(ref val2)).width - num11 - num4 - 4f), lineHeight);
			((Rect)(ref rect2))..ctor(((Rect)(ref val2)).x + ((Rect)(ref val2)).width - num4, ((Rect)(ref val2)).y, num4, lineHeight);
			Color textColor = BepInExPlugin.TextColor;
			Color amountColor = BepInExPlugin.AmountColor;
			textColor.a *= num7;
			amountColor.a *= num7;
			DrawLabel(rect, line.Name, nameStyle, textColor, num7);
			DrawLabel(rect2, "x" + line.Amount, amountStyle, amountColor, num7);
		}
		GUI.EndGroup();
		GUI.color = color;
	}

	private static float AmountColumnWidth(float windowWidth)
	{
		float num = (float)BepInExPlugin.NotificationFontSize * 3.4f + 16f;
		float num2 = windowWidth * 0.28f;
		return Mathf.Clamp(Mathf.Max(num, num2), 56f, windowWidth * 0.45f);
	}

	private void DrawLabel(Rect rect, string text, GUIStyle style, Color color, float fade)
	{
		//IL_00ee: 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_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_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: 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_00b2: 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)
		if (BepInExPlugin.TextOutline)
		{
			Color outlineColor = BepInExPlugin.OutlineColor;
			outlineColor.a *= fade;
			style.normal.textColor = outlineColor;
			float num = Mathf.Max(1f, (float)BepInExPlugin.NotificationFontSize / 14f);
			GUI.Label(new Rect(((Rect)(ref rect)).x - num, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, ((Rect)(ref rect)).height), text, style);
			GUI.Label(new Rect(((Rect)(ref rect)).x + num, ((Rect)(ref rect)).y, ((Rect)(ref rect)).width, ((Rect)(ref rect)).height), text, style);
			GUI.Label(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y - num, ((Rect)(ref rect)).width, ((Rect)(ref rect)).height), text, style);
			GUI.Label(new Rect(((Rect)(ref rect)).x, ((Rect)(ref rect)).y + num, ((Rect)(ref rect)).width, ((Rect)(ref rect)).height), text, style);
		}
		style.normal.textColor = color;
		GUI.Label(rect, text, style);
	}

	private static void GetWindowRect(float width, float height, out float x, out float y)
	{
		float num = BepInExPlugin.NotificationX;
		float num2 = BepInExPlugin.NotificationY;
		switch (BepInExPlugin.Anchor)
		{
		case NotificationAnchor.BottomLeft:
			x = num;
			y = (float)Screen.height - height - num2;
			break;
		case NotificationAnchor.TopRight:
			x = (float)Screen.width - width - num;
			y = num2;
			break;
		case NotificationAnchor.TopLeft:
			x = num;
			y = num2;
			break;
		default:
			x = (float)Screen.width - width - num;
			y = (float)Screen.height - height - num2;
			break;
		}
		x = Mathf.Clamp(x, 0f, Mathf.Max(0f, (float)Screen.width - width));
		y = Mathf.Clamp(y, 0f, Mathf.Max(0f, (float)Screen.height - height));
	}

	private void EnsureStyles()
	{
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: 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_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Expected O, but got Unknown
		//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_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Expected O, but got Unknown
		int notificationFontSize = BepInExPlugin.NotificationFontSize;
		if (nameStyle == null || cachedFontSize != notificationFontSize)
		{
			cachedFontSize = notificationFontSize;
			nameStyle = new GUIStyle(GUI.skin.label)
			{
				fontSize = notificationFontSize,
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)3,
				clipping = (TextClipping)1,
				wordWrap = false
			};
			amountStyle = new GUIStyle(GUI.skin.label)
			{
				fontSize = notificationFontSize,
				fontStyle = (FontStyle)1,
				alignment = (TextAnchor)5,
				clipping = (TextClipping)0,
				wordWrap = false
			};
		}
	}
}