Decompiled source of StatMessagingPlugin v4.1.1

StatMessaging.dll

Decompiled 4 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
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 Newtonsoft.Json;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("StatMessaging")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("StatMessaging")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("StatMessaging")]
[assembly: ComVisible(false)]
[assembly: Guid("74902334-ecd0-4125-91a6-485549cfd810")]
[assembly: AssemblyFileVersion("3.2.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("3.2.0.0")]
namespace LordAshes;

[BepInPlugin("org.lordashes.plugins.statmessaging", "Stat Messaging Plug-In", "3.2.0.0")]
public class StatMessaging : BaseUnityPlugin
{
	public class Subscription
	{
		public string key { get; set; }

		public Action<Change[]> callback { get; set; }
	}

	public enum ChangeType
	{
		added = 1,
		modified,
		removed
	}

	public class Change : IEquatable<Change>
	{
		public CreatureGuid cid { get; set; }

		public ChangeType action { get; set; }

		public string key { get; set; }

		public string previous { get; set; }

		public string value { get; set; }

		public bool Equals(Change otherChange)
		{
			//IL_0002: 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)
			if (cid == otherChange.cid && action == otherChange.action && key == otherChange.key && value == otherChange.value)
			{
				return true;
			}
			return false;
		}
	}

	public class ReflectionChange
	{
		public string cid { get; set; }

		public string action { get; set; }

		public string key { get; set; }

		public string previous { get; set; }

		public string value { get; set; }

		public ReflectionChange()
		{
		}

		public ReflectionChange(Change content)
		{
			//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)
			CreatureGuid val = content.cid;
			cid = ((object)(CreatureGuid)(ref val)).ToString();
			action = content.action.ToString();
			key = content.key;
			previous = content.previous;
			value = content.value;
		}
	}

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

		public static string GetCreatureName(string nameBlock)
		{
			if (nameBlock == null)
			{
				return "(Unknown)";
			}
			if (!nameBlock.Contains("<size=0>"))
			{
				return nameBlock;
			}
			return nameBlock.Substring(0, nameBlock.IndexOf("<size=0>")).Trim();
		}

		public static GameObject GetBaseLoader(CreatureGuid cid)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				CreatureBoardAsset val = null;
				CreaturePresenter.TryGetAsset(cid, ref val);
				if ((Object)(object)val != (Object)null)
				{
					Transform match = null;
					Traverse(((Component)val).transform, "BaseLoader", 0, 10, ref match);
					if ((Object)(object)match != (Object)null)
					{
						Debug.Log((object)("Stat Messaging Plug-In: Base Loader '" + ((Object)match.GetChild(0)).name + "' Found"));
						return ((Component)match.GetChild(0)).gameObject;
					}
					Debug.LogWarning((object)"Stat Messaging Plug-In: Could Not Find Base Loader");
					return null;
				}
				return null;
			}
			catch
			{
				return null;
			}
		}

		public static GameObject GetAssetLoader(CreatureGuid cid)
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				CreatureBoardAsset val = null;
				CreaturePresenter.TryGetAsset(cid, ref val);
				if ((Object)(object)val != (Object)null)
				{
					Transform match = null;
					Traverse(((Component)val).transform, "AssetLoader", 0, 10, ref match);
					if ((Object)(object)match != (Object)null)
					{
						Debug.Log((object)("Stat Messaging Plug-In: Asset Loader '" + ((Object)match.GetChild(0)).name + "' Found"));
						return ((Component)match.GetChild(0)).gameObject;
					}
					Debug.LogWarning((object)"Stat Messaging Plug-In: Could Not Find Asset Loader");
					return null;
				}
				return null;
			}
			catch
			{
				return null;
			}
		}

		public static void Traverse(Transform root, string seek, int depth, int depthMax, ref Transform match)
		{
			try
			{
				if ((Object)(object)match != (Object)null)
				{
					return;
				}
				if (((Object)root).name == seek)
				{
					match = root;
					return;
				}
				foreach (Transform item in ExtensionMethods.Children(root))
				{
					if (depth < depthMax)
					{
						Traverse(item, seek, depth + 1, depthMax, ref match);
					}
				}
			}
			catch
			{
			}
		}

		public static float ParseFloat(string value)
		{
			return float.Parse(value, CultureInfo.InvariantCulture);
		}
	}

	public const string Name = "Stat Messaging Plug-In";

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

	public const string Version = "3.2.0.0";

	private static object exclusionLock = new object();

	private static Dictionary<CreatureGuid, string> data = new Dictionary<CreatureGuid, string>();

	private static Dictionary<Guid, Subscription> subscriptions = new Dictionary<Guid, Subscription>();

	private static bool diagnosticMode = false;

	private ConfigEntry<KeyboardShortcut> triggerDebugMode;

	private ConfigEntry<KeyboardShortcut> triggerDebugDump;

	private ConfigEntry<KeyboardShortcut> triggerReset;

	private static Type caller = null;

	private static MethodInfo callback = null;

	private static bool checkInProgress = false;

	private static bool ready = false;

	private static Queue<Change> operationQueue = new Queue<Change>();

	private void Awake()
	{
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: 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)
		Debug.Log((object)("Stat Messaging Plugin: " + ((object)this).GetType().AssemblyQualifiedName + " is active."));
		triggerDebugMode = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Toggle Diagnostic Mode", new KeyboardShortcut((KeyCode)46, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), (ConfigDescription)null);
		triggerDebugDump = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Dump Selected Mini Message Values", new KeyboardShortcut((KeyCode)44, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), (ConfigDescription)null);
		triggerReset = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Reset Mini Messages", new KeyboardShortcut((KeyCode)114, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), (ConfigDescription)null);
		diagnosticMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Settings", "Additional Disgnostic Information In Logs", false, (ConfigDescription)null).Value;
	}

	private void Update()
	{
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_0368: Unknown result type (might be due to invalid IL or missing references)
		//IL_036d: 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_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: 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)
		//IL_044a: Unknown result type (might be due to invalid IL or missing references)
		//IL_044f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_052a: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_04e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: 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_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0201: 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)
		string text = "";
		try
		{
			text = "Board State Sync";
			if (Utility.isBoardLoaded() != ready)
			{
				ready = Utility.isBoardLoaded();
				if (ready)
				{
					Debug.Log((object)"Stat Messaging Plugin: Started looking for messages.");
				}
				else
				{
					data.Clear();
					Debug.Log((object)"Stat Messaging Plugin: Stopped looking for messages.");
				}
			}
			text = "Message Check";
			if (ready)
			{
				StatMessagingCheck();
			}
			text = "Keyboard Requests";
			KeyboardShortcut value = triggerDebugMode.Value;
			CreatureGuid val2;
			if (((KeyboardShortcut)(ref value)).IsUp())
			{
				diagnosticMode = !diagnosticMode;
			}
			else
			{
				value = triggerDebugDump.Value;
				if (((KeyboardShortcut)(ref value)).IsUp())
				{
					CreatureBoardAsset val = default(CreatureBoardAsset);
					CreaturePresenter.TryGetAsset(LocalClient.SelectedCreatureId, ref val);
					val2 = val.CreatureId;
					Debug.Log((object)("Stat Messaging Plugin: Stat Message Dump For Creature " + ((object)(CreatureGuid)(ref val2)).ToString()));
					Debug.Log((object)("Stat Messaging Plugin: " + val.Name));
				}
				else
				{
					value = triggerReset.Value;
					if (((KeyboardShortcut)(ref value)).IsUp())
					{
						_ = LocalClient.SelectedCreatureId;
						if (true)
						{
							CreatureBoardAsset val3 = default(CreatureBoardAsset);
							CreaturePresenter.TryGetAsset(LocalClient.SelectedCreatureId, ref val3);
							CreatureManager.SetCreatureName(val3.CreatureId, GetCreatureName(val3));
							if (data.ContainsKey(val3.CreatureId))
							{
								data.Remove(val3.CreatureId);
							}
							SystemMessage.DisplayInfoText("Stat Messages For Creature '" + GetCreatureName(val3) + "' Reset", 2.5f);
						}
						else
						{
							SystemMessage.DisplayInfoText("Stat Messages For All Creatures Reset", 2.5f);
							foreach (CreatureBoardAsset item in (IEnumerable<CreatureBoardAsset>)CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets())
							{
								CreatureManager.SetCreatureName(item.CreatureId, GetCreatureName(item));
								if (data.ContainsKey(item.CreatureId))
								{
									data.Remove(item.CreatureId);
								}
							}
						}
					}
				}
			}
			text = "Process Queue";
			if (operationQueue.Count <= 0)
			{
				return;
			}
			if (diagnosticMode)
			{
				Debug.Log((object)("Stat Messaging Plugin: Operation Queue Count: " + operationQueue.Count));
			}
			text = "Process Queue: Dequeue";
			Change change = operationQueue.Dequeue();
			text = "Process Queue: Try Get Asset";
			CreatureBoardAsset val4 = default(CreatureBoardAsset);
			CreaturePresenter.TryGetAsset(change.cid, ref val4);
			text = "Process Queue: Get Stat Block";
			Dictionary<string, string> dictionary = null;
			if (!((Object)(object)val4 != (Object)null))
			{
				return;
			}
			string text2 = val4.Name.Substring(val4.Name.IndexOf("<size=0>") + "<size=0>".Length);
			try
			{
				dictionary = JsonConvert.DeserializeObject<Dictionary<string, string>>(text2);
			}
			catch (Exception)
			{
				Debug.Log((object)"Stat Messaging Plugin: Corrupt Stat Block Detected. Resetting Mini's JSON Block.");
				dictionary = new Dictionary<string, string>();
			}
			text = "Process Queue: Switch";
			switch (change.action)
			{
			case ChangeType.added:
			case ChangeType.modified:
				if (diagnosticMode)
				{
					string[] obj2 = new string[10] { "Stat Messaging Plugin: Queue Processing: On '", null, null, null, null, null, null, null, null, null };
					val2 = change.cid;
					obj2[1] = ((object)(CreatureGuid)(ref val2)).ToString();
					obj2[2] = "' process '";
					obj2[3] = change.action.ToString();
					obj2[4] = "' request for key ";
					obj2[5] = change.key;
					obj2[6] = " to ";
					obj2[7] = change.value;
					obj2[8] = " from ";
					obj2[9] = change.previous;
					Debug.Log((object)string.Concat(obj2));
				}
				if (dictionary.ContainsKey(change.key))
				{
					dictionary[change.key] = change.value;
				}
				else
				{
					dictionary.Add(change.key, change.value);
				}
				break;
			case ChangeType.removed:
				if (diagnosticMode)
				{
					string[] obj = new string[6] { "Stat Messaging Plugin: Queue Processing: On '", null, null, null, null, null };
					val2 = change.cid;
					obj[1] = ((object)(CreatureGuid)(ref val2)).ToString();
					obj[2] = "' process '";
					obj[3] = change.action.ToString();
					obj[4] = "' request for key ";
					obj[5] = change.key;
					Debug.Log((object)string.Concat(obj));
				}
				if (dictionary.ContainsKey(change.key))
				{
					dictionary.Remove(change.key);
				}
				break;
			}
			if (diagnosticMode)
			{
				string[] obj3 = new string[6] { "Stat Messaging Plugin: Queue Processing: Setting Creature '", null, null, null, null, null };
				val2 = change.cid;
				obj3[1] = ((object)(CreatureGuid)(ref val2)).ToString();
				obj3[2] = "' name to: ";
				obj3[3] = GetCreatureName(val4);
				obj3[4] = "<size=0>";
				obj3[5] = JsonConvert.SerializeObject((object)dictionary);
				Debug.Log((object)string.Concat(obj3));
			}
			CreatureManager.SetCreatureName(change.cid, GetCreatureName(val4) + "<size=0>" + JsonConvert.SerializeObject((object)dictionary));
		}
		catch (Exception ex2)
		{
			Debug.Log((object)("Stat Messaging Plugin: Exception In Update Sequence At Phase = " + text));
			Debug.LogException(ex2);
		}
	}

	private void OnGUI()
	{
		//IL_000b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Expected O, but got Unknown
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		if (diagnosticMode)
		{
			CreatureBoardAsset val = default(CreatureBoardAsset);
			CreaturePresenter.TryGetAsset(LocalClient.SelectedCreatureId, ref val);
			if ((Object)(object)val != (Object)null)
			{
				GUIStyle val2 = new GUIStyle
				{
					wordWrap = true
				};
				GUI.Label(new Rect(10f, 30f, 1900f, 80f), "Debug: " + val.Name, val2);
			}
		}
	}

	[Obsolete]
	public static void Check(Action<Change[]> dataChangeCallback)
	{
		foreach (Subscription value in subscriptions.Values)
		{
			if (value.callback == dataChangeCallback)
			{
				return;
			}
		}
		Debug.LogWarning((object)"Stat Messaging Plugin: Check(callback) is obsolete. Use the Subscribe() method instead.");
		Subscribe("*", dataChangeCallback);
	}

	public static Guid Subscribe(string key, Action<Change[]> dataChangeCallback)
	{
		try
		{
			Guid guid = System.Guid.NewGuid();
			subscriptions.Add(guid, new Subscription
			{
				key = key,
				callback = dataChangeCallback
			});
			return guid;
		}
		catch (Exception)
		{
			return System.Guid.Empty;
		}
	}

	public static void Unsubscribe(Guid subscriptionId)
	{
		if (subscriptions.ContainsKey(subscriptionId))
		{
			string[] obj = new string[5]
			{
				"Stat Messaging Plugin: Removing Subscription ",
				subscriptions[subscriptionId].key,
				" (",
				null,
				null
			};
			Guid guid = subscriptionId;
			obj[3] = guid.ToString();
			obj[4] = ")";
			Debug.Log((object)string.Concat(obj));
			subscriptions.Remove(subscriptionId);
		}
	}

	public static void SetInfo(CreatureGuid cid, string key, string value)
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		lock (exclusionLock)
		{
			Change item = new Change
			{
				cid = cid,
				key = key,
				value = value,
				action = ChangeType.modified,
				previous = null
			};
			if (!operationQueue.Contains(item))
			{
				operationQueue.Enqueue(item);
			}
		}
	}

	public static void ClearInfo(CreatureGuid cid, string key)
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		operationQueue.Enqueue(new Change
		{
			cid = cid,
			key = key,
			value = null,
			action = ChangeType.removed,
			previous = null
		});
	}

	public static string ReadInfo(CreatureGuid cid, string key)
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		lock (exclusionLock)
		{
			if (data.ContainsKey(cid))
			{
				string text = data[cid];
				text = text.Substring(text.IndexOf("<size=0>") + "<size=0>".Length);
				Dictionary<string, string> dictionary = null;
				try
				{
					dictionary = JsonConvert.DeserializeObject<Dictionary<string, string>>(text);
				}
				catch (Exception)
				{
					dictionary = new Dictionary<string, string>();
				}
				if (dictionary.ContainsKey(key))
				{
					return dictionary[key];
				}
			}
			else
			{
				Debug.LogWarning((object)("Stat Messaging Plugin: Creature '" + ((object)(CreatureGuid)(ref cid)).ToString() + "' not defined in data dictionary"));
			}
			return "";
		}
	}

	[Obsolete]
	public static void Reset()
	{
		Debug.Log((object)"Stat Messaging Plugin: Data dictionary reset is obsolete. Use Reset(key) instead.");
		data.Clear();
	}

	public static void Reset(string key)
	{
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0133: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bd: 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_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		Debug.Log((object)("Stat Messaging Plugin: Removing key '" + key + "' from all assets"));
		CreatureGuid[] array = data.Keys.ToArray();
		CreatureGuid[] array2 = array;
		for (int i = 0; i < array2.Length; i++)
		{
			CreatureGuid val = array2[i];
			CreatureBoardAsset val2 = null;
			CreaturePresenter.TryGetAsset(val, ref val2);
			if ((Object)(object)val2 != (Object)null)
			{
				if (data.ContainsKey(val))
				{
					if (data[val].Contains("<size=0>"))
					{
						string text = data[val].Substring(data[val].IndexOf("<size=0>") + "<size=0>".Length);
						Dictionary<string, string> dictionary = null;
						try
						{
							dictionary = JsonConvert.DeserializeObject<Dictionary<string, string>>(text);
						}
						catch (Exception)
						{
							dictionary = new Dictionary<string, string>();
						}
						if (dictionary.ContainsKey(key))
						{
							dictionary.Remove(key);
						}
						data[val] = GetCreatureName(val2) + "<size=0>" + JsonConvert.SerializeObject((object)dictionary);
						Debug.Log((object)("Stat Messaging Plugin: Creature " + ((object)(CreatureGuid)(ref val)).ToString() + " StatBlock is " + data[val]));
					}
					else
					{
						Debug.Log((object)("Stat Messaging Plugin: Creature " + ((object)(CreatureGuid)(ref val)).ToString() + " Had No StatBlock..."));
					}
				}
				else
				{
					Debug.Log((object)("Stat Messaging Plugin: Creature " + ((object)(CreatureGuid)(ref val)).ToString() + " Had Data But Doesn't Anymore..."));
				}
			}
			else
			{
				Debug.Log((object)("Stat Messaging Plugin: Creature " + ((object)(CreatureGuid)(ref val)).ToString() + " Had Data But Does Not Exist. Removing Data..."));
				data.Remove(val);
			}
		}
	}

	public static string GetCreatureName(CreatureBoardAsset asset)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		string text = asset.Name;
		if (text == null)
		{
			text = ((Object)asset).name;
		}
		if (text == null)
		{
			text = ((Object)Utility.GetAssetLoader(asset.CreatureId).GetComponent<MeshFilter>()).name;
		}
		if (text.Contains("<size=0>"))
		{
			text = text.Substring(0, text.IndexOf("<size=0>")).Trim();
		}
		return text;
	}

	private static void StatMessagingCheck()
	{
		//IL_0342: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0438: Unknown result type (might be due to invalid IL or missing references)
		//IL_0250: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_028e: Unknown result type (might be due to invalid IL or missing references)
		//IL_026a: 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_0223: 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_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_053f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0544: Unknown result type (might be due to invalid IL or missing references)
		if (checkInProgress)
		{
			return;
		}
		checkInProgress = true;
		try
		{
			foreach (CreatureBoardAsset item in (IEnumerable<CreatureBoardAsset>)CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets())
			{
				string text = item.Name;
				if (text == null)
				{
					if (text == null)
					{
						text = ((Object)item).name;
					}
					if (text == null)
					{
						text = ((Object)Utility.GetAssetLoader(item.CreatureId).GetComponent<MeshFilter>()).name;
					}
				}
				CreatureGuid val;
				if (!text.Contains("<size=0>"))
				{
					Debug.Log((object)("Stat Messaging Plugin: CreatureName is " + text));
					if (data.ContainsKey(item.CreatureId))
					{
						string[] obj = new string[5]
						{
							"Stat Messaging Plugin: Restoring previous data for Creature '",
							GetCreatureName(item),
							"' (",
							null,
							null
						};
						val = item.CreatureId;
						obj[3] = ((object)(CreatureGuid)(ref val)).ToString();
						obj[4] = "). Probably lost due to a character rename.";
						Debug.Log((object)string.Concat(obj));
						data[item.CreatureId] = GetCreatureName(item) + data[item.CreatureId].Substring(data[item.CreatureId].IndexOf("<size=0>"));
						CreatureManager.SetCreatureName(item.CreatureId, data[item.CreatureId]);
						Debug.Log((object)("Stat Messaging Plugin: Creature '" + GetCreatureName(item) + "' is now '" + data[item.CreatureId] + "'"));
						text = data[item.CreatureId];
					}
					else
					{
						string[] obj2 = new string[5]
						{
							"Stat Messaging Plugin: Creating new data block for Creature '",
							GetCreatureName(item),
							"' (",
							null,
							null
						};
						val = item.CreatureId;
						obj2[3] = ((object)(CreatureGuid)(ref val)).ToString();
						obj2[4] = "). This is probably a new asset.";
						Debug.Log((object)string.Concat(obj2));
						CreatureManager.SetCreatureName(item.CreatureId, text + " <size=0>{}");
						text += " <size=0>{}";
					}
				}
				if (!data.ContainsKey(item.CreatureId))
				{
					data.Add(item.CreatureId, GetCreatureName(item) + "<size=0>{}");
				}
				if (!(text != data[item.CreatureId]))
				{
					continue;
				}
				string text2 = data[item.CreatureId].Substring(data[item.CreatureId].IndexOf("<size=0>") + "<size=0>".Length);
				string text3 = text.Substring(text.IndexOf("<size=0>") + "<size=0>".Length);
				Dictionary<string, string> dictionary = null;
				Dictionary<string, string> dictionary2 = null;
				try
				{
					dictionary = JsonConvert.DeserializeObject<Dictionary<string, string>>(text2);
				}
				catch (Exception)
				{
					dictionary = new Dictionary<string, string>();
				}
				try
				{
					dictionary2 = JsonConvert.DeserializeObject<Dictionary<string, string>>(text3);
				}
				catch (Exception)
				{
					dictionary2 = new Dictionary<string, string>();
				}
				data[item.CreatureId] = text;
				List<Change> list = new List<Change>();
				foreach (KeyValuePair<string, string> item2 in dictionary)
				{
					if (!dictionary2.ContainsKey(item2.Key))
					{
						list.Add(new Change
						{
							action = ChangeType.removed,
							key = item2.Key,
							previous = item2.Value,
							value = "",
							cid = item.CreatureId
						});
					}
					else if (item2.Value != dictionary2[item2.Key])
					{
						list.Add(new Change
						{
							action = ChangeType.modified,
							key = item2.Key,
							previous = item2.Value,
							value = dictionary2[item2.Key],
							cid = item.CreatureId
						});
					}
				}
				foreach (KeyValuePair<string, string> item3 in dictionary2)
				{
					if (!dictionary.ContainsKey(item3.Key))
					{
						list.Add(new Change
						{
							action = ChangeType.added,
							key = item3.Key,
							previous = "",
							value = item3.Value,
							cid = item.CreatureId
						});
					}
				}
				if (list.Count <= 0)
				{
					continue;
				}
				foreach (Change item4 in list)
				{
					string[] obj3 = new string[10] { "Stat Messaging Plugin: Cid: ", null, null, null, null, null, null, null, null, null };
					val = item4.cid;
					obj3[1] = ((object)(CreatureGuid)(ref val)).ToString();
					obj3[2] = ", Type: ";
					obj3[3] = item4.action.ToString();
					obj3[4] = ", Key: ";
					obj3[5] = item4.key;
					obj3[6] = ", Previous: ";
					obj3[7] = item4.previous;
					obj3[8] = ", Current: ";
					obj3[9] = item4.value;
					Debug.Log((object)string.Concat(obj3));
					foreach (Subscription value in subscriptions.Values)
					{
						if (diagnosticMode)
						{
							Debug.Log((object)("Stat Messaging Plugin: Subscription: " + value.key + ", Change: " + item4.key + ", Match: " + (value.key == item4.key)));
						}
						if (value.key == item4.key)
						{
							value.callback(new Change[1] { item4 });
						}
					}
				}
				foreach (Subscription value2 in subscriptions.Values)
				{
					if (value2.key == "*")
					{
						if (diagnosticMode)
						{
							Debug.Log((object)"Stat Messaging Plugin: Subscription: *");
						}
						value2.callback(list.ToArray());
					}
				}
				if (!(caller != null) || !(callback != null) || list == null)
				{
					continue;
				}
				if (diagnosticMode)
				{
					Debug.Log((object)"Stat Messaging Plugin: Reflection Subscription: *");
				}
				List<ReflectionChange> list2 = new List<ReflectionChange>();
				foreach (Change item5 in list)
				{
					list2.Add(new ReflectionChange(item5));
				}
				string text4 = JsonConvert.SerializeObject((object)list2);
				callback.Invoke(null, new object[1] { text4 });
			}
		}
		catch (Exception ex3)
		{
			Debug.Log((object)"Stat Messaging Plugin: Exception");
			Debug.LogException(ex3);
		}
		checkInProgress = false;
	}

	public static Dictionary<Guid, Subscription> Subscriptions()
	{
		if (diagnosticMode)
		{
			Debug.Log((object)"Stat Messaging Plugin: Obtaining subscriptions");
		}
		Dictionary<Guid, Subscription> dictionary = new Dictionary<Guid, Subscription>();
		foreach (KeyValuePair<Guid, Subscription> subscription in subscriptions)
		{
			dictionary.Add(subscription.Key, subscription.Value);
		}
		return dictionary;
	}

	public static void ReflectionSubscription(string callerName, string callbackName)
	{
		if (diagnosticMode)
		{
			Debug.Log((object)("Stat Messaging Plugin: Setting Reflection Subscription (" + callerName + ", " + callbackName));
		}
		try
		{
			caller = Type.GetType(callerName);
			if (caller == null)
			{
				throw new Exception("Reflection subscribe type is invalid");
			}
			callback = caller.GetMethod(callbackName);
			if (callback == null)
			{
				throw new Exception("Reflection callback is invalid");
			}
		}
		catch (Exception ex)
		{
			Debug.Log((object)"Stat Messaging Plugin: Unable To Set Reflection Subscription");
			Debug.LogException(ex);
		}
	}
}