Decompiled source of OverheadNotesPlugin v1.4.0

OverheadNotesPlugin.dll

Decompiled 2 months ago
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Bounce.Singletons;
using Bounce.Unmanaged;
using HarmonyLib;
using Newtonsoft.Json;
using RadialUI;
using TMPro;
using UnityEngine;
using UnityEngine.InputSystem;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("OverheadNotesPlugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("OverheadNotesPlugin")]
[assembly: AssemblyCopyright("Copyright ©  2024")]
[assembly: AssemblyTrademark("OverheadNotesPlugin")]
[assembly: ComVisible(false)]
[assembly: Guid("c303405d-e66c-4316-9cdb-4e3ca15c6360")]
[assembly: AssemblyFileVersion("1.4.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.4.0.0")]
namespace LordAshes;

[BepInPlugin("org.lordashes.plugins.overheadnotes", "Overhead Notes Plug-In", "1.4.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class OverheadNotesPlugin : BaseUnityPlugin
{
	public enum DiagnosticLevel
	{
		none,
		low,
		high,
		ultra
	}

	public enum UpdateLevel
	{
		none,
		selected,
		all
	}

	public enum ContentType
	{
		player,
		gm
	}

	[HarmonyPatch(typeof(LocalClient), "SetLocalClientMode")]
	internal sealed class PatchLocalClientSetLocalClientMode
	{
		public static void Postfix(ref ClientMode mode)
		{
			//IL_0013: 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)
			Debug.Log((object)"GM Info Plugin: GM Mode changed. Updating GM Info visibility.");
			_self.UpdateTextInfo(default(CreatureGuid));
		}
	}

	[HarmonyPatch(typeof(ActionEvent), "Performed")]
	internal sealed class PatchControllerManagerCameraMove
	{
		public static void Postfix(CallbackContext context)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			if (_self.updateLevel.Value == UpdateLevel.all)
			{
				_self.UpdateTextInfo(default(CreatureGuid));
			}
			else if (_self.updateLevel.Value == UpdateLevel.selected)
			{
				if (_self.playerBlocks.ContainsKey(LocalClient.SelectedCreatureId))
				{
					_self.UpdateTextInfo(LocalClient.SelectedCreatureId);
				}
				else if (_self.gmBlocks.ContainsKey(LocalClient.SelectedCreatureId))
				{
					_self.UpdateTextInfo(LocalClient.SelectedCreatureId);
				}
			}
		}
	}

	public static class Utility
	{
		public static void Initialize(MemberInfo plugin)
		{
			SceneManager.sceneLoaded += delegate(Scene scene, LoadSceneMode mode)
			{
				//IL_0072: Unknown result type (might be due to invalid IL or missing references)
				//IL_0079: Expected O, but got Unknown
				try
				{
					if (((Scene)(ref scene)).name == "UI")
					{
						TextMeshProUGUI uITextByName = GetUITextByName("BETA");
						if (Object.op_Implicit((Object)(object)uITextByName))
						{
							((TMP_Text)uITextByName).text = "INJECTED BUILD - unstable mods";
						}
					}
					else
					{
						TextMeshProUGUI uITextByName2 = GetUITextByName("TextMeshPro Text");
						if (Object.op_Implicit((Object)(object)uITextByName2))
						{
							BepInPlugin val = (BepInPlugin)Attribute.GetCustomAttribute(plugin, typeof(BepInPlugin));
							if (((TMP_Text)uITextByName2).text.EndsWith("</size>"))
							{
								((TMP_Text)uITextByName2).text = ((TMP_Text)uITextByName2).text + "\n\nMods Currently Installed:\n";
							}
							TextMeshProUGUI val2 = uITextByName2;
							((TMP_Text)val2).text = ((TMP_Text)val2).text + "\nLord Ashes' " + val.Name + " - " + val.Version;
						}
					}
				}
				catch (Exception ex)
				{
					Debug.Log((object)ex);
				}
			};
		}

		public static TextMeshProUGUI GetUITextByName(string name)
		{
			TextMeshProUGUI[] array = Object.FindObjectsOfType<TextMeshProUGUI>();
			for (int i = 0; i < array.Length; i++)
			{
				if (((Object)array[i]).name == name)
				{
					return array[i];
				}
			}
			return null;
		}

		public static bool isBoardLoaded()
		{
			return SimpleSingletonBehaviour<CameraController>.HasInstance && SingletonStateMBehaviour<BoardSessionManager, State<BoardSessionManager>>.HasInstance && !BoardSessionManager.IsLoading;
		}

		public static bool StrictKeyCheck(KeyboardShortcut check)
		{
			//IL_002e: 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_003f: Unknown result type (might be due to invalid IL or missing references)
			if (!((KeyboardShortcut)(ref check)).IsUp())
			{
				return false;
			}
			KeyCode[] array = new KeyCode[6];
			RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
			KeyCode[] array2 = (KeyCode[])(object)array;
			foreach (KeyCode val in array2)
			{
				if (Input.GetKey(val) != ((KeyboardShortcut)(ref check)).Modifiers.Contains(val))
				{
					return false;
				}
			}
			return true;
		}

		public static GameObject GetBaseLoader(CreatureGuid cid)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			CreatureBoardAsset val = null;
			CreaturePresenter.TryGetAsset(cid, ref val);
			if ((Object)(object)val != (Object)null)
			{
				CreatureBase match = null;
				StartWith(val, "_base", ref match);
				Transform match2 = null;
				Traverse(((Component)match).transform, "BaseLoader", ref match2);
				if ((Object)(object)match2 != (Object)null)
				{
					return ((Component)match2.GetChild(0)).gameObject;
				}
				Debug.LogWarning((object)"Overhead Notes Plugin: Could Not Find Base Loader");
				return null;
			}
			return null;
		}

		public static GameObject GetAssetLoader(CreatureGuid cid)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			CreatureBoardAsset val = null;
			CreaturePresenter.TryGetAsset(cid, ref val);
			if ((Object)(object)val != (Object)null)
			{
				Transform match = null;
				StartWith(val, "_creatureRoot", ref match);
				Transform match2 = null;
				Traverse(match, "AssetLoader", ref match2);
				if ((Object)(object)match2 != (Object)null)
				{
					return ((Component)match2.GetChild(0)).gameObject;
				}
				Debug.LogWarning((object)"Overhead Notes Plugin: Could Not Find Asset Loader");
				return null;
			}
			return null;
		}

		public static void StartWith<T>(CreatureBoardAsset asset, string seek, ref T match)
		{
			Type typeFromHandle = typeof(CreatureBoardAsset);
			match = default(T);
			foreach (FieldInfo runtimeField in typeFromHandle.GetRuntimeFields())
			{
				if (runtimeField.Name == seek)
				{
					match = (T)runtimeField.GetValue(asset);
					break;
				}
			}
		}

		public static void Traverse(Transform root, string seek, ref Transform match)
		{
			if ((Object)(object)match != (Object)null)
			{
				return;
			}
			if (((Object)root).name == seek)
			{
				match = root;
				return;
			}
			foreach (Transform item in ExtensionMethods.Children(root))
			{
				Traverse(item, seek, ref match);
			}
		}
	}

	public const string Name = "Overhead Notes Plug-In";

	public const string Guid = "org.lordashes.plugins.overheadnotes";

	public const string Version = "1.4.0.0";

	private Dictionary<string, string> colorizations = new Dictionary<string, string>();

	private ConcurrentQueue<DatumChange> backlogChangeQueue = new ConcurrentQueue<DatumChange>();

	public static OverheadNotesPlugin _self = null;

	public static string keywordGmNote = "";

	public static string borderCharacter = "|";

	private bool boardLoaded = false;

	private Dictionary<CreatureGuid, TextMeshPro> gmBlocks = new Dictionary<CreatureGuid, TextMeshPro>();

	private Dictionary<CreatureGuid, TextMeshPro> playerBlocks = new Dictionary<CreatureGuid, TextMeshPro>();

	public static bool dragging = false;

	private ConfigEntry<KeyboardShortcut> triggerAddPlayerNote { get; set; }

	private ConfigEntry<KeyboardShortcut> triggerAddGMNote { get; set; }

	private ConfigEntry<KeyboardShortcut> triggerReapply { get; set; }

	private ConfigEntry<KeyboardShortcut> triggerClear { get; set; }

	private ConfigEntry<UpdateLevel> updateLevel { get; set; }

	private ConfigEntry<int> updateThrottle { get; set; }

	private ConfigEntry<float> updateTimeout { get; set; }

	private ConfigEntry<float> autoTextBlockHeightMultiplier { get; set; }

	private ConfigEntry<float> autoTextBlockHeightOffset { get; set; }

	private ConfigEntry<Color> baseColor { get; set; }

	private ConfigEntry<string> backgroundColor { get; set; }

	private ConfigEntry<float> baseSize { get; set; }

	private ConfigEntry<float> backlogProcessingAttemptInterval { get; set; }

	private ConfigEntry<float> textOffsetPerLine { get; set; }

	private ConfigEntry<float> forceTextBoxHeight { get; set; }

	public ConfigEntry<DiagnosticLevel> diagnostics { get; set; }

	private void Awake()
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0350: Unknown result type (might be due to invalid IL or missing references)
		//IL_0355: Unknown result type (might be due to invalid IL or missing references)
		//IL_0367: Unknown result type (might be due to invalid IL or missing references)
		//IL_0372: Unknown result type (might be due to invalid IL or missing references)
		//IL_038d: Expected O, but got Unknown
		//IL_03a8: 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)
		//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_03e5: Expected O, but got Unknown
		//IL_03f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f7: Expected O, but got Unknown
		_self = this;
		triggerAddPlayerNote = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Add Player Note", new KeyboardShortcut((KeyCode)110, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), (ConfigDescription)null);
		triggerAddGMNote = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Add GM Note", new KeyboardShortcut((KeyCode)110, (KeyCode[])(object)new KeyCode[1] { (KeyCode)308 }), (ConfigDescription)null);
		triggerClear = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Clear All Note", new KeyboardShortcut((KeyCode)110, (KeyCode[])(object)new KeyCode[1] { (KeyCode)303 }), (ConfigDescription)null);
		triggerReapply = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Reapply Notes", new KeyboardShortcut((KeyCode)110, (KeyCode[])(object)new KeyCode[1] { (KeyCode)305 }), (ConfigDescription)null);
		baseColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Appearance", "Base Text Color", Color.white, (ConfigDescription)null);
		backgroundColor = ((BaseUnityPlugin)this).Config.Bind<string>("Appearance", "Background Highlight Color", "00000088", (ConfigDescription)null);
		baseSize = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "Base Text Size", 1f, (ConfigDescription)null);
		textOffsetPerLine = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "Text Offset Per Line", 0.075f, (ConfigDescription)null);
		keywordGmNote = "<size=" + baseSize.Value / 2f + ">GM Notes:</size>";
		if (backgroundColor.Value.Trim().EndsWith("00"))
		{
			borderCharacter = " ";
		}
		updateLevel = ((BaseUnityPlugin)this).Config.Bind<UpdateLevel>("Settings", "Update Level", UpdateLevel.all, (ConfigDescription)null);
		updateThrottle = ((BaseUnityPlugin)this).Config.Bind<int>("Settings", "Maximum Number Of Backlog Changes Per Update Cycle", 10, (ConfigDescription)null);
		updateTimeout = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Duration After Which Unrendered TextBlock Are Ignored", 60f, (ConfigDescription)null);
		backlogProcessingAttemptInterval = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Backlog Processing Attempt Interval", 1f, (ConfigDescription)null);
		forceTextBoxHeight = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Height Of The Tallest Medium Sized Mini Or 0 For Auto", 0f, (ConfigDescription)null);
		autoTextBlockHeightOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Auto TextBlock Height Offet", 0.25f, (ConfigDescription)null);
		autoTextBlockHeightMultiplier = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Auto TextBlock Height Multiplier", 1f, (ConfigDescription)null);
		diagnostics = ((BaseUnityPlugin)this).Config.Bind<DiagnosticLevel>("Settings", "Diagnostics Log Level", DiagnosticLevel.low, (ConfigDescription)null);
		Debug.Log((object)("Overhead Notes Plugin: " + ((object)this).GetType().AssemblyQualifiedName + " Active. (Diagnostic Mode = " + diagnostics.Value.ToString() + ")"));
		if (File.Exists("/org.lordashes.plugins.overheadnotes/ColorizedKeywords.json"))
		{
			string text = File.ReadAllText("/org.lordashes.plugins.overheadnotes/ColorizedKeywords.json", (CacheType)999);
			colorizations = JsonConvert.DeserializeObject<Dictionary<string, string>>(text);
		}
		RadialUIPlugin.AddCustomButtonGMSubmenu("org.lordashes.plugins.overheadnotes." + ContentType.player, new ItemArgs
		{
			Action = delegate
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				SetRequest(ContentType.player, new CreatureGuid(RadialUIPlugin.GetLastRadialTargetCreature()));
			},
			Title = "Player Info",
			Icon = Image.LoadSprite("Info.png", (CacheType)999)
		}, (Func<NGuid, NGuid, bool>)null);
		RadialUIPlugin.AddCustomButtonGMSubmenu("org.lordashes.plugins.overheadnotes." + ContentType.gm, new ItemArgs
		{
			Action = delegate
			{
				//IL_0003: Unknown result type (might be due to invalid IL or missing references)
				//IL_0008: Unknown result type (might be due to invalid IL or missing references)
				SetRequest(ContentType.gm, new CreatureGuid(RadialUIPlugin.GetLastRadialTargetCreature()));
			},
			Title = "GM Info",
			Icon = Image.LoadSprite("Info.png", (CacheType)999)
		}, (Func<NGuid, NGuid, bool>)null);
		dragging = false;
		Harmony val = new Harmony("org.lordashes.plugins.overheadnotes");
		val.PatchAll();
		AssetDataPlugin.Subscribe("org.lordashes.plugins.overheadnotes." + ContentType.player, (Action<DatumChange>)HandleRequest, (Func<DatumChange, bool>)Checker.CheckSourceAsCreature);
		AssetDataPlugin.Subscribe("org.lordashes.plugins.overheadnotes." + ContentType.gm, (Action<DatumChange>)HandleRequest, (Func<DatumChange, bool>)Checker.CheckSourceAsCreature);
		Utility.Initialize(((object)this).GetType());
	}

	private void Update()
	{
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: 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_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00da: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: 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_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Expected O, but got Unknown
		//IL_0230: Unknown result type (might be due to invalid IL or missing references)
		//IL_0236: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: 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_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_019c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: Expected O, but got Unknown
		//IL_0264: Unknown result type (might be due to invalid IL or missing references)
		//IL_0292: Unknown result type (might be due to invalid IL or missing references)
		//IL_027a: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a8: Unknown result type (might be due to invalid IL or missing references)
		if (Utility.isBoardLoaded())
		{
			if (Utility.StrictKeyCheck(triggerAddPlayerNote.Value))
			{
				SetRequest(ContentType.player, LocalClient.SelectedCreatureId);
			}
			if (Utility.StrictKeyCheck(triggerAddGMNote.Value))
			{
				SetRequest(ContentType.gm, LocalClient.SelectedCreatureId);
			}
			CreatureGuid activeGuid;
			if (Utility.StrictKeyCheck(triggerReapply.Value))
			{
				Debug.Log((object)"Overhead Notes Plugin: Re-Applying Overhead Notes");
				foreach (CreatureBoardAsset item in (IEnumerable<CreatureBoardAsset>)CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets())
				{
					string text = "";
					activeGuid = item.CreatureId;
					text = AssetDataPlugin.ReadInfo(((object)(CreatureGuid)(ref activeGuid)).ToString(), "org.lordashes.plugins.overheadnotes.player");
					if (text != "")
					{
						DatumChange val = new DatumChange
						{
							action = (ChangeAction)0,
							previous = null
						};
						activeGuid = item.CreatureId;
						val.source = ((object)(CreatureGuid)(ref activeGuid)).ToString();
						val.key = "org.lordashes.plugins.overheadnotes.player";
						val.value = text;
						ProcessRequest(val);
					}
					activeGuid = item.CreatureId;
					text = AssetDataPlugin.ReadInfo(((object)(CreatureGuid)(ref activeGuid)).ToString(), "org.lordashes.plugins.overheadnotes.gm");
					if (text != "")
					{
						DatumChange val2 = new DatumChange
						{
							action = (ChangeAction)0,
							previous = null
						};
						activeGuid = item.CreatureId;
						val2.source = ((object)(CreatureGuid)(ref activeGuid)).ToString();
						val2.key = "org.lordashes.plugins.overheadnotes.gm";
						val2.value = text;
						ProcessRequest(val2);
					}
				}
			}
			if (Utility.StrictKeyCheck(triggerClear.Value))
			{
				ClearAllNotes(LocalClient.SelectedCreatureId);
			}
			if (!Input.GetMouseButton(0) && !Input.GetMouseButton(1) && !Input.GetMouseButton(2))
			{
				return;
			}
			if (_self.updateLevel.Value == UpdateLevel.all)
			{
				OverheadNotesPlugin self = _self;
				activeGuid = default(CreatureGuid);
				self.UpdateTextInfo(activeGuid);
			}
			else if (_self.updateLevel.Value == UpdateLevel.selected)
			{
				if (_self.playerBlocks.ContainsKey(LocalClient.SelectedCreatureId))
				{
					_self.UpdateTextInfo(LocalClient.SelectedCreatureId);
				}
				else if (_self.gmBlocks.ContainsKey(LocalClient.SelectedCreatureId))
				{
					_self.UpdateTextInfo(LocalClient.SelectedCreatureId);
				}
			}
		}
		else if (boardLoaded)
		{
			boardLoaded = false;
		}
	}

	public void SetRequest(ContentType viewer, CreatureGuid cid)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		CreatureBoardAsset asset = default(CreatureBoardAsset);
		CreaturePresenter.TryGetAsset(cid, ref asset);
		if (!((Object)(object)asset != (Object)null))
		{
			return;
		}
		if (diagnostics.Value >= DiagnosticLevel.ultra)
		{
			Debug.Log((object)"Overhead Notes Plugin: Open Request Dialog");
		}
		CreatureGuid creatureId = asset.CreatureId;
		string text = AssetDataPlugin.ReadInfo(((object)(CreatureGuid)(ref creatureId)).ToString(), "org.lordashes.plugins.overheadnotes." + viewer);
		string text2 = viewer.ToString().Substring(0, 1).ToUpper() + viewer.ToString().Substring(1);
		SystemMessage.AskForTextInput(text2 + " Notes", "Enter Creature State(s):", "OK", (Action<string>)delegate(string newStates)
		{
			//IL_002e: 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)
			if (diagnostics.Value >= DiagnosticLevel.high)
			{
				Debug.Log((object)"Overhead Notes Plugin: Send Set Request");
			}
			CreatureGuid creatureId3 = asset.CreatureId;
			AssetDataPlugin.SetInfo(((object)(CreatureGuid)(ref creatureId3)).ToString(), "org.lordashes.plugins.overheadnotes." + viewer, newStates, false);
		}, (Action)null, "Clear", (Action)delegate
		{
			//IL_002e: 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)
			if (diagnostics.Value >= DiagnosticLevel.high)
			{
				Debug.Log((object)"Overhead Notes Plugin: Send Clear Request");
			}
			CreatureGuid creatureId2 = asset.CreatureId;
			AssetDataPlugin.ClearInfo(((object)(CreatureGuid)(ref creatureId2)).ToString(), "org.lordashes.plugins.overheadnotes." + viewer, false);
		}, text);
	}

	public void ClearAllNotes(CreatureGuid cid)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: 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)
		CreatureBoardAsset val = default(CreatureBoardAsset);
		CreaturePresenter.TryGetAsset(cid, ref val);
		if (!((Object)(object)val != (Object)null))
		{
			return;
		}
		if (diagnostics.Value >= DiagnosticLevel.high)
		{
			Debug.Log((object)("Overhead Notes Plugin: Request Clear Of All Notes On Creature " + ((object)(CreatureGuid)(ref cid)).ToString()));
		}
		foreach (ContentType value in Enum.GetValues(typeof(ContentType)))
		{
			CreatureGuid creatureId = val.CreatureId;
			AssetDataPlugin.ClearInfo(((object)(CreatureGuid)(ref creatureId)).ToString(), "org.lordashes.plugins.overheadnotes." + value, false);
		}
	}

	public void HandleRequest(DatumChange change)
	{
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: 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_00d1: 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_00e8: Expected I4, but got Unknown
		//IL_028d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0292: Unknown result type (might be due to invalid IL or missing references)
		//IL_0258: Unknown result type (might be due to invalid IL or missing references)
		//IL_020d: Unknown result type (might be due to invalid IL or missing references)
		ChangeAction action;
		if (change == null)
		{
			Debug.LogWarning((object)"Overhead Notes Plugin: Asset Data Plugin change was null");
		}
		else if (diagnostics.Value >= DiagnosticLevel.low)
		{
			string[] obj = new string[10] { "Overhead Notes Plugin: Request = Creature ID: ", change.source, ", Action: ", null, null, null, null, null, null, null };
			action = change.action;
			obj[3] = ((object)(ChangeAction)(ref action)).ToString();
			obj[4] = ", Key: ";
			obj[5] = change.key;
			obj[6] = ", Previous Value: ";
			obj[7] = change.previous?.ToString();
			obj[8] = ", New Value: ";
			obj[9] = change.value?.ToString();
			Debug.Log((object)string.Concat(obj));
		}
		try
		{
			ChangeAction action2 = change.action;
			ChangeAction val = action2;
			switch ((int)val)
			{
			case 0:
			case 2:
			case 3:
				if (diagnostics.Value >= DiagnosticLevel.high)
				{
					Debug.Log((object)("Overhead Notes Plugin: Adding/Modifying Text Block for creature '" + change.source + "'"));
				}
				if (change.key.EndsWith(ContentType.gm.ToString()))
				{
					change.value = keywordGmNote + "," + change.value;
				}
				ProcessRequest(change);
				break;
			case 1:
				if (diagnostics.Value >= DiagnosticLevel.high)
				{
					Debug.Log((object)("Overhead Notes Plugin: Removing GmInfo Block for creature '" + change.source + "'"));
				}
				try
				{
					if (change.key.EndsWith(ContentType.gm.ToString()))
					{
						Object.Destroy((Object)(object)GameObject.Find("CustomContent:GMInfo:" + change.source + "." + ContentType.gm));
						gmBlocks.Remove(new CreatureGuid(change.source));
					}
					else
					{
						Object.Destroy((Object)(object)GameObject.Find("CustomContent:GMInfo:" + change.source + "." + ContentType.player));
						playerBlocks.Remove(new CreatureGuid(change.source));
					}
					break;
				}
				catch
				{
					break;
				}
			default:
				if (diagnostics.Value >= DiagnosticLevel.high)
				{
					action = change.action;
					Debug.Log((object)("Overhead Notes Plugin: Not sure what to do with action '" + ((object)(ChangeAction)(ref action)).ToString() + "'"));
				}
				break;
			}
		}
		catch (Exception ex)
		{
			Debug.Log((object)"Overhead Notes Plugin: Exception");
			Debug.LogException(ex);
		}
	}

	public void ProcessRequest(DatumChange change)
	{
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			string[] obj = new string[10] { "Overhead Notes Plugin: Processing = Creature ID: ", change.source, ", Action: ", null, null, null, null, null, null, null };
			ChangeAction action = change.action;
			obj[3] = ((object)(ChangeAction)(ref action)).ToString();
			obj[4] = ", Key: ";
			obj[5] = change.key;
			obj[6] = ", Previous Value: ";
			obj[7] = change.previous?.ToString();
			obj[8] = ", New Value: ";
			obj[9] = change.value?.ToString();
			Debug.Log((object)string.Concat(obj));
			CreatureBoardAsset val = default(CreatureBoardAsset);
			CreaturePresenter.TryGetAsset(new CreatureGuid(change.source), ref val);
			if ((Object)(object)val != (Object)null)
			{
				Debug.Log((object)("Overhead Notes Plugin: Found creature '" + change.source + "'"));
				if ((Object)(object)Utility.GetAssetLoader(val.CreatureId) != (Object)null)
				{
					PopulateCreatureGMInfoText(val, change, change.key.EndsWith(ContentType.gm.ToString()));
				}
				else
				{
					Debug.LogWarning((object)("Overhead Notes Plugin: Unable To Get Asset Loader For Creature '" + change.source + "'."));
				}
			}
			else
			{
				Debug.LogWarning((object)("Overhead Notes Plugin: Unable To Access Creature '" + change.source + "' Even Though Asset Data Check Passed."));
			}
		}
		catch (Exception ex)
		{
			Debug.LogWarning((object)("Overhead Notes Plugin: Exception " + ex));
		}
	}

	public void PopulateCreatureGMInfoText(CreatureBoardAsset asset, DatumChange change, bool gmOnly)
	{
		//IL_032d: Unknown result type (might be due to invalid IL or missing references)
		//IL_02da: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0367: Unknown result type (might be due to invalid IL or missing references)
		//IL_036c: Unknown result type (might be due to invalid IL or missing references)
		//IL_038b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0390: Unknown result type (might be due to invalid IL or missing references)
		//IL_03af: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b4: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)asset == (Object)null || change == null)
		{
			return;
		}
		if (diagnostics.Value >= DiagnosticLevel.ultra)
		{
			Debug.Log((object)("Overhead Notes Plugin: Processing request for creature '" + change.source + "'"));
		}
		TextMeshPro creatureGMInfoText = GetCreatureGMInfoText(asset, gmOnly);
		if (diagnostics.Value >= DiagnosticLevel.ultra)
		{
			Debug.Log((object)("Overhead Notes Plugin: Populating TextMeshPro (" + Convert.ToString(((Object)creatureGMInfoText).name) + ")"));
		}
		((TMP_Text)creatureGMInfoText).autoSizeTextContainer = false;
		string text = change.value.ToString().Replace(",", "\r\n");
		text = ((!text.Contains(keywordGmNote)) ? ("<mark=#" + backgroundColor.Value + ">" + borderCharacter + text.Replace("\r\n", borderCharacter + "\r\n" + borderCharacter) + borderCharacter + "</mark>") : (keywordGmNote + "<mark=#" + backgroundColor.Value + ">\r\n " + borderCharacter.Trim() + text.Substring(keywordGmNote.Length + 2).Replace("\r\n", borderCharacter + "\r\n" + borderCharacter) + borderCharacter + "</mark>"));
		if (colorizations.ContainsKey("<Default>"))
		{
			text = "<Default>" + text;
		}
		((TMP_Text)creatureGMInfoText).richText = true;
		foreach (KeyValuePair<string, string> colorization in colorizations)
		{
			text = text.Replace(colorization.Key, colorization.Value);
		}
		((TMP_Text)creatureGMInfoText).text = text;
		((TMP_Text)creatureGMInfoText).autoSizeTextContainer = true;
		int num = 0;
		for (int i = 0; i < text.Length - 1; i++)
		{
			if (text.Substring(i, 2) == "\r\n")
			{
				num++;
			}
		}
		if (((TMP_Text)creatureGMInfoText).text.Contains(keywordGmNote))
		{
			((TMP_Text)creatureGMInfoText).alignment = (TextAlignmentOptions)513;
			((TMP_Text)creatureGMInfoText).fontSize = baseSize.Value;
			creatureGMInfoText.transform.localPosition = new Vector3(0f, 0.75f, 0.25f + (float)num * textOffsetPerLine.Value);
		}
		else
		{
			((TMP_Text)creatureGMInfoText).alignment = (TextAlignmentOptions)1026;
			((TMP_Text)creatureGMInfoText).fontSize = baseSize.Value;
			creatureGMInfoText.transform.localPosition = new Vector3(0f, 0f, calculateYMax(asset) + (float)num * textOffsetPerLine.Value);
		}
		if (diagnostics.Value >= DiagnosticLevel.ultra)
		{
			Debug.Log((object)("Overhead Notes Plugin: Text Offset = " + creatureGMInfoText.transform.localPosition.x + "," + creatureGMInfoText.transform.localPosition.y + "," + creatureGMInfoText.transform.localPosition.z));
		}
		UpdateTextInfo(asset.CreatureId);
	}

	private TextMeshPro GetCreatureGMInfoText(CreatureBoardAsset asset, bool gmOnly)
	{
		//IL_00d7: 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_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_0279: Unknown result type (might be due to invalid IL or missing references)
		//IL_0280: Expected O, but got Unknown
		//IL_0288: 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)
		//IL_0310: Unknown result type (might be due to invalid IL or missing references)
		//IL_0374: Unknown result type (might be due to invalid IL or missing references)
		//IL_035c: Unknown result type (might be due to invalid IL or missing references)
		CreatureGuid val;
		if (diagnostics.Value >= DiagnosticLevel.ultra)
		{
			foreach (KeyValuePair<CreatureGuid, TextMeshPro> gmBlock in gmBlocks)
			{
				val = gmBlock.Key;
				Debug.Log((object)("Overhead Notes Plugin: Have TextMeshPro GM Block For Creature " + ((object)(CreatureGuid)(ref val)).ToString()));
			}
			foreach (KeyValuePair<CreatureGuid, TextMeshPro> playerBlock in playerBlocks)
			{
				val = playerBlock.Key;
				Debug.Log((object)("Overhead Notes Plugin: Have TextMeshPro Player Block For Creature " + ((object)(CreatureGuid)(ref val)).ToString()));
			}
		}
		if (gmOnly && gmBlocks.ContainsKey(asset.CreatureId))
		{
			if (diagnostics.Value >= DiagnosticLevel.ultra)
			{
				Debug.Log((object)("Overhead Notes Plugin: Using Registered GM Block (" + Convert.ToString(((Object)gmBlocks[asset.CreatureId]).name) + ")"));
			}
			return gmBlocks[asset.CreatureId];
		}
		if (!gmOnly && playerBlocks.ContainsKey(asset.CreatureId))
		{
			if (diagnostics.Value >= DiagnosticLevel.ultra)
			{
				Debug.Log((object)("Overhead Notes Plugin: Using Registered Player Block (" + Convert.ToString(((Object)playerBlocks[asset.CreatureId]).name) + ")"));
			}
			return playerBlocks[asset.CreatureId];
		}
		if (diagnostics.Value >= DiagnosticLevel.ultra)
		{
			Debug.Log((object)"Overhead Notes Plugin: Creating New Block");
		}
		GameObject baseLoader = Utility.GetBaseLoader(asset.CreatureId);
		if ((Object)(object)baseLoader != (Object)null)
		{
			if (diagnostics.Value >= DiagnosticLevel.ultra)
			{
				Debug.Log((object)"Overhead Notes Plugin: Getting GMInfoBlock");
			}
			if (diagnostics.Value >= DiagnosticLevel.ultra)
			{
				Debug.Log((object)"Overhead Notes Plugin: Creating New GMInfoBlock");
			}
			string text = "." + (gmOnly ? ContentType.gm : ContentType.player);
			GameObject val2 = new GameObject();
			val = asset.CreatureId;
			((Object)val2).name = "CustomContent:GMInfo:" + ((object)(CreatureGuid)(ref val)).ToString() + text;
			val2.transform.SetParent(baseLoader.transform);
			if (diagnostics.Value >= DiagnosticLevel.ultra)
			{
				Debug.Log((object)"Overhead Notes Plugin: Creating New TextMeshPro Component");
			}
			TextMeshPro val3 = val2.AddComponent<TextMeshPro>();
			((TMP_Text)val3).textStyle = TMP_Style.NormalStyle;
			((TMP_Text)val3).enableWordWrapping = true;
			((TMP_Text)val3).autoSizeTextContainer = true;
			((Graphic)val3).color = baseColor.Value;
			((TMP_Text)val3).fontSize = baseSize.Value;
			((TMP_Text)val3).fontWeight = (FontWeight)700;
			((TMP_Text)val3).isTextObjectScaleStatic = true;
			((Behaviour)val3).enabled = true;
			if (gmOnly)
			{
				gmBlocks.Add(asset.CreatureId, val3);
			}
			else
			{
				playerBlocks.Add(asset.CreatureId, val3);
			}
			return val3;
		}
		return null;
	}

	public void UpdateTextInfo(CreatureGuid activeGuid)
	{
		//IL_0007: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_0244: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_020c: 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_0170: Unknown result type (might be due to invalid IL or missing references)
		//IL_0175: Unknown result type (might be due to invalid IL or missing references)
		//IL_017a: Unknown result type (might be due to invalid IL or missing references)
		List<TextMeshPro> list = new List<TextMeshPro>();
		if (activeGuid == default(CreatureGuid))
		{
			if (diagnostics.Value >= DiagnosticLevel.ultra)
			{
				Debug.Log((object)"Overhead Notes Plugin: Updating Rotation for all GM Info text blocks");
			}
			list.AddRange(playerBlocks.Values.ToList());
			list.AddRange(gmBlocks.Values.ToList());
		}
		else
		{
			if (diagnostics.Value >= DiagnosticLevel.ultra)
			{
				Debug.Log((object)("Overhead Notes Plugin: Updating Rotation for GM Info text block of creature " + ((object)(CreatureGuid)(ref activeGuid)).ToString()));
			}
			if (playerBlocks.ContainsKey(activeGuid))
			{
				list.Add(playerBlocks[activeGuid]);
			}
			if (gmBlocks.ContainsKey(activeGuid))
			{
				list.Add(gmBlocks[activeGuid]);
			}
		}
		foreach (TextMeshPro tmp in list)
		{
			try
			{
				((Behaviour)tmp).enabled = !((TMP_Text)tmp).text.Contains(keywordGmNote) || LocalClient.IsInGmMode;
				tmp.transform.rotation = Quaternion.LookRotation(tmp.transform.position - ((Component)Camera.main).transform.position);
			}
			catch (Exception ex)
			{
				Debug.Log((object)("Overhead Notes Plugin: Exception: " + ex));
				if (backlogChangeQueue.Count == 0)
				{
					if (diagnostics.Value >= DiagnosticLevel.ultra)
					{
						Debug.Log((object)"Overhead Notes Plugin: Failure to update Rotation. Removing.");
					}
					try
					{
						playerBlocks.Remove(playerBlocks.First((KeyValuePair<CreatureGuid, TextMeshPro> kvp) => (Object)(object)kvp.Value == (Object)(object)tmp).Key);
					}
					catch
					{
					}
					try
					{
						gmBlocks.Remove(gmBlocks.First((KeyValuePair<CreatureGuid, TextMeshPro> kvp) => (Object)(object)kvp.Value == (Object)(object)tmp).Key);
					}
					catch
					{
					}
				}
				else if (diagnostics.Value >= DiagnosticLevel.ultra)
				{
					Debug.Log((object)"Overhead Notes Plugin: Failure to update Rotation. Unprocessed backlog.");
				}
			}
		}
	}

	private float calculateYMax(CreatureBoardAsset asset)
	{
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006b: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0203: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02be: Unknown result type (might be due to invalid IL or missing references)
		//IL_0390: Unknown result type (might be due to invalid IL or missing references)
		//IL_0395: Unknown result type (might be due to invalid IL or missing references)
		//IL_0399: Unknown result type (might be due to invalid IL or missing references)
		//IL_0429: 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_0432: Unknown result type (might be due to invalid IL or missing references)
		float val = 0f;
		if (forceTextBoxHeight.Value <= 0f)
		{
			float num = 0f;
			float num2 = 0f;
			GameObject assetLoader = Utility.GetAssetLoader(asset.CreatureId);
			MeshFilter[] componentsInChildren = assetLoader.GetComponentsInChildren<MeshFilter>();
			Bounds val4;
			foreach (MeshFilter val2 in componentsInChildren)
			{
				num2 = 0f;
				float val3 = num2;
				val4 = val2.mesh.bounds;
				num2 = Math.Max(val3, ((Bounds)(ref val4)).max.y);
				if (diagnostics.Value >= DiagnosticLevel.ultra)
				{
					Debug.Log((object)("Overhead Notes Plugin: " + ((Object)val2).name + ": Y by MF.Bounds = " + num2));
				}
				val = Math.Max(val, num2);
			}
			MeshFilter[] componentsInChildren2 = assetLoader.GetComponentsInChildren<MeshFilter>();
			foreach (MeshFilter val5 in componentsInChildren2)
			{
				num = 0f;
				num2 = 0f;
				Vector3[] vertices = val5.mesh.vertices;
				foreach (Vector3 val6 in vertices)
				{
					num = Math.Min(num2, val6.y);
					num2 = Math.Max(num2, val6.y);
				}
				if (diagnostics.Value >= DiagnosticLevel.ultra)
				{
					Debug.Log((object)("Overhead Notes Plugin: " + ((Object)val5).name + ": Y by MF.Vertices = From " + num + " To " + num2 + " = " + (num2 - num)));
				}
				val = Math.Max(val, num2 - num);
			}
			SkinnedMeshRenderer[] componentsInChildren3 = assetLoader.GetComponentsInChildren<SkinnedMeshRenderer>();
			foreach (SkinnedMeshRenderer val7 in componentsInChildren3)
			{
				num2 = 0f;
				float val8 = num2;
				val4 = val7.sharedMesh.bounds;
				num2 = Math.Max(val8, ((Bounds)(ref val4)).max.y);
				if (diagnostics.Value >= DiagnosticLevel.ultra)
				{
					Debug.Log((object)("Overhead Notes Plugin: " + ((Object)val7).name + ": Y by SMR.Bounds = " + num2));
				}
				val = Math.Max(val, num2);
			}
			SkinnedMeshRenderer[] componentsInChildren4 = assetLoader.GetComponentsInChildren<SkinnedMeshRenderer>();
			foreach (SkinnedMeshRenderer val9 in componentsInChildren4)
			{
				num = 0f;
				num2 = 0f;
				Vector3[] vertices2 = val9.sharedMesh.vertices;
				foreach (Vector3 val10 in vertices2)
				{
					num = Math.Min(num2, val10.y);
					num2 = Math.Max(num2, val10.y);
				}
				if (diagnostics.Value >= DiagnosticLevel.ultra)
				{
					Debug.Log((object)("Overhead Notes Plugin: " + ((Object)val9).name + " Y by SMR.Vertices = From " + num + " To " + num2 + " = " + (num2 - num)));
				}
				val = Math.Max(val, num2 - num);
			}
			Renderer[] componentsInChildren5 = assetLoader.GetComponentsInChildren<Renderer>();
			foreach (Renderer val11 in componentsInChildren5)
			{
				num2 = 0f;
				float val12 = num2;
				val4 = val11.bounds;
				num2 = Math.Max(val12, ((Bounds)(ref val4)).max.y);
				if (diagnostics.Value >= DiagnosticLevel.ultra)
				{
					Debug.Log((object)("Overhead Notes Plugin: " + ((Object)val11).name + " (" + ((object)val11).GetType().ToString() + "): Y by Rendere.Bounds = " + num2));
				}
				val = Math.Max(val, num2);
			}
			val4 = asset.CreatureBounds;
			num2 = ((Bounds)(ref val4)).max.y;
			if (diagnostics.Value >= DiagnosticLevel.ultra)
			{
				Debug.Log((object)("Overhead Notes Plugin: Creature.Bounds = " + num2));
			}
			val = Math.Max(val, num2);
			val *= autoTextBlockHeightMultiplier.Value;
			val += autoTextBlockHeightOffset.Value;
		}
		else
		{
			val = forceTextBoxHeight.Value;
		}
		if (diagnostics.Value >= DiagnosticLevel.ultra)
		{
			Debug.Log((object)("Overhead Notes Plugin: Y Offset = " + val));
		}
		return val;
	}
}