Decompiled source of StatesPlugin v3.5.0

StatesPlugin.dll

Decompiled 7 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Bounce.ManagedCollections;
using Bounce.Singletons;
using HarmonyLib;
using Newtonsoft.Json;
using RadialUI;
using TMPro;
using UnityEngine;
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("StatesPlugin")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("StatesPlugin")]
[assembly: AssemblyCopyright("Copyright ©  2023")]
[assembly: AssemblyTrademark("StatesPlugin")]
[assembly: ComVisible(false)]
[assembly: Guid("c303405d-e66c-4316-9cdb-4e3ca15c6360")]
[assembly: AssemblyFileVersion("3.5.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("3.5.0.0")]
namespace LordAshes;

[BepInPlugin("org.lordashes.plugins.states", "States Plug-In", "3.5.0.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class StatesPlugin : BaseUnityPlugin
{
	[HarmonyPatch(typeof(CreatureManager), "DeleteCreature")]
	public static class PatchDeleteCreature
	{
		public static bool Prefix(CreatureGuid creatureId, UniqueCreatureGuid uniqueId, bool deleteUniqueFromBackend)
		{
			GameObject val = GameObject.Find("Effect:" + ((object)(CreatureGuid)(ref creatureId)).ToString() + ".StatesBlock");
			if ((Object)(object)val != (Object)null)
			{
				Debug.Log((object)("States Plugin: DeleteCreature Patch: Destroying 'Effect:" + ((object)(CreatureGuid)(ref creatureId)).ToString() + ".StatesBlock'"));
				Object.Destroy((Object)(object)val);
			}
			return true;
		}
	}

	[HarmonyPatch(typeof(CreatureManager), "DeleteCreatures")]
	public static class PatchDeleteCreatures
	{
		public static bool Prefix(CreatureGuid[] creatureIds, BList<UniqueCreatureGuid> uniqueIds, bool deleteUniqueFromBackend)
		{
			//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)
			for (int i = 0; i < creatureIds.Length; i++)
			{
				CreatureGuid val = creatureIds[i];
				GameObject val2 = GameObject.Find("Effect:" + ((object)(CreatureGuid)(ref val)).ToString() + ".StatesBlock");
				if ((Object)(object)val2 != (Object)null)
				{
					Debug.Log((object)("States Plugin: DeleteCreature Patch: Destroying 'Effect:" + ((object)(CreatureGuid)(ref val)).ToString() + ".StatesBlock'"));
					Object.Destroy((Object)(object)val2);
				}
			}
			return true;
		}
	}

	public enum OffsetMethod
	{
		fixedOffset,
		baseScaleFixedOffet,
		headHookMultiplierOffset,
		boundsOffset
	}

	public const string Name = "States Plug-In";

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

	public const string Version = "3.5.0.0";

	private Queue<Change> backlogChangeQueue = new Queue<Change>();

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

	private float baseSize = 16f;

	private OffsetMethod offsetMethod = OffsetMethod.boundsOffset;

	private float offsetValue = 1f;

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

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

	private void Awake()
	{
		//IL_0011: 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_005f: Unknown result type (might be due to invalid IL or missing references)
		Debug.Log((object)"States Plugin: Active.");
		new Harmony("org.lordashes.plugins.states").PatchAll();
		triggerKey = ((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "States Activation", new KeyboardShortcut((KeyCode)115, (KeyCode[])(object)new KeyCode[1] { (KeyCode)306 }), (ConfigDescription)null);
		baseColor = ((BaseUnityPlugin)this).Config.Bind<Color>("Appearance", "Base Text Color", Color.black, (ConfigDescription)null);
		baseSize = ((BaseUnityPlugin)this).Config.Bind<float>("Appearance", "Base Text Size", 2f, (ConfigDescription)null).Value;
		offsetMethod = ((BaseUnityPlugin)this).Config.Bind<OffsetMethod>("Settings", "Height Offset Method", OffsetMethod.boundsOffset, (ConfigDescription)null).Value;
		offsetValue = ((BaseUnityPlugin)this).Config.Bind<float>("Settings", "Height Offset Value", 1f, (ConfigDescription)null).Value;
		if (File.Exists("ColorizedKeywords.json"))
		{
			string text = File.ReadAllText(File.Find("ColorizedKeywords.json", (CacheType)999)[0], (CacheType)999);
			colorizations = JsonConvert.DeserializeObject<Dictionary<string, string>>(text);
		}
		RadialSubmenu.EnsureMainMenuItem("org.hollofox.plugins.RadialUIPlugin.Info", (MenuType)1, "Info", Image.LoadSprite("Info.png", (CacheType)999));
		RadialSubmenu.CreateSubMenuItem("org.hollofox.plugins.RadialUIPlugin.Info", "States", Image.LoadSprite("States.png", (CacheType)999), (Action<CreatureGuid, string, MapMenuItem>)delegate(CreatureGuid cid, string menu, MapMenuItem mmi)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			SetRequest(cid);
		}, false, (Func<bool>)null);
		StatMessaging.Subscribe("org.lordashes.plugins.states", (Action<Change[]>)HandleRequest);
		Utility.Initialize(((object)this).GetType());
	}

	private void Update()
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: 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_006c: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: 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_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fe: 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_021f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0224: Unknown result type (might be due to invalid IL or missing references)
		if (!isBoardLoaded())
		{
			return;
		}
		syncStealthMode();
		KeyboardShortcut value = triggerKey.Value;
		if (((KeyboardShortcut)(ref value)).IsUp())
		{
			SetRequest(LocalClient.SelectedCreatureId);
		}
		CreatureGuid val;
		foreach (CreatureBoardAsset item in (IEnumerable<CreatureBoardAsset>)CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets())
		{
			try
			{
				val = item.CreatureId;
				GameObject val2 = GameObject.Find("Effect:" + ((object)(CreatureGuid)(ref val)).ToString() + ".StatesBlock");
				if ((Object)(object)val2 != (Object)null)
				{
					val2.transform.rotation = Quaternion.LookRotation(val2.transform.position - ((Component)Camera.main).transform.position);
					TextMeshPro val3 = val2.GetComponent<TextMeshPro>();
					if ((Object)(object)val3 == (Object)null)
					{
						val3 = val2.AddComponent<TextMeshPro>();
					}
					val3.transform.rotation = val2.transform.rotation;
					val3.transform.position = new Vector3(Utility.GetBaseLoader(item.CreatureId).transform.position.x, calculateYPos(item) + ((TMP_Text)val3).preferredHeight, Utility.GetBaseLoader(item.CreatureId).transform.position.z);
				}
			}
			catch (Exception)
			{
			}
		}
		CreatureBoardAsset val5 = default(CreatureBoardAsset);
		while (backlogChangeQueue.Count > 0)
		{
			Change val4 = backlogChangeQueue.Peek();
			CreaturePresenter.TryGetAsset(val4.cid, ref val5);
			if ((Object)(object)val5 != (Object)null)
			{
				if ((Object)(object)Utility.GetAssetLoader(val5.CreatureId) == (Object)null)
				{
					break;
				}
				backlogChangeQueue.Dequeue();
				TextMeshPro creatureStateText = null;
				GameObject creatureBlock = null;
				string[] obj = new string[10] { "States Plugin: Processing Queued Request = Creature ID: ", null, null, null, null, null, null, null, null, null };
				val = val4.cid;
				obj[1] = ((object)(CreatureGuid)(ref val)).ToString();
				obj[2] = ", Action: ";
				ChangeType action = val4.action;
				obj[3] = ((object)(ChangeType)(ref action)).ToString();
				obj[4] = ", Key: ";
				obj[5] = val4.key;
				obj[6] = ", Previous Value: ";
				obj[7] = val4.previous;
				obj[8] = ", New Value: ";
				obj[9] = val4.value;
				Debug.Log((object)string.Concat(obj));
				createNewCreatureStateText(out creatureStateText, out creatureBlock, val5);
				populateCreatureStateText(creatureStateText, val4, val5);
			}
		}
	}

	public void HandleRequest(Change[] changes)
	{
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b0: 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_00f5: 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_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: Invalid comparison between Unknown and I4
		//IL_0112: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Invalid comparison between Unknown and I4
		//IL_014b: 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_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)
		CreatureBoardAsset val3 = default(CreatureBoardAsset);
		foreach (Change val in changes)
		{
			CreatureGuid val2;
			if (val == null)
			{
				Debug.Log((object)"States Plugin: ERROR: StatMessaging change was NULL;");
			}
			else
			{
				string[] obj = new string[10] { "States Plugin: Handle Request, Creature ID: ", null, null, null, null, null, null, null, null, null };
				val2 = val.cid;
				obj[1] = ((object)(CreatureGuid)(ref val2)).ToString();
				obj[2] = ", Action: ";
				ChangeType action = val.action;
				obj[3] = ((object)(ChangeType)(ref action)).ToString();
				obj[4] = ", Key: ";
				obj[5] = val.key;
				obj[6] = ", Previous Value: ";
				obj[7] = val.previous;
				obj[8] = ", New Value: ";
				obj[9] = val.value;
				Debug.Log((object)string.Concat(obj));
			}
			if (!(val.key == "org.lordashes.plugins.states"))
			{
				continue;
			}
			try
			{
				CreaturePresenter.TryGetAsset(val.cid, ref val3);
				if ((Object)(object)val3 != (Object)null)
				{
					ChangeType action2 = val.action;
					ChangeType val4 = action2;
					if (val4 - 1 > 1)
					{
						if ((int)val4 == 3)
						{
							val2 = val.cid;
							Debug.Log((object)("States Plugin: Removing States Block for creature '" + ((object)(CreatureGuid)(ref val2)).ToString() + "'"));
							val2 = val3.CreatureId;
							Object.Destroy((Object)(object)GameObject.Find("Effect:" + ((object)(CreatureGuid)(ref val2)).ToString() + ".StatesBlock"));
						}
					}
					else
					{
						val2 = val.cid;
						Debug.Log((object)("States Plugin: Updating States Block for creature '" + ((object)(CreatureGuid)(ref val2)).ToString() + "'"));
						backlogChangeQueue.Enqueue(val);
					}
				}
				else
				{
					val2 = val.cid;
					Debug.Log((object)("States Plugin: Received States update for invalid asset (" + ((object)(CreatureGuid)(ref val2)).ToString() + ")"));
				}
			}
			catch (Exception ex)
			{
				Debug.Log((object)("Exception: " + ex));
			}
		}
	}

	private void createNewCreatureStateText(out TextMeshPro creatureStateText, out GameObject creatureBlock, CreatureBoardAsset asset)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: Expected O, but got Unknown
		//IL_0046: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: 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_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_016f: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b2: 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)
		CreatureGuid creatureId = asset.CreatureId;
		if ((Object)(object)GameObject.Find("Effect:" + ((object)(CreatureGuid)(ref creatureId)).ToString() + ".StatesBlock") != (Object)null)
		{
			Debug.Log((object)"States Plugin: StatesText already exists.");
			creatureId = asset.CreatureId;
			creatureBlock = GameObject.Find("Effect:" + ((object)(CreatureGuid)(ref creatureId)).ToString() + ".StatesBlock");
			creatureStateText = creatureBlock.GetComponentInChildren<TextMeshPro>();
			return;
		}
		Debug.Log((object)"States Plugin: Creating CreatureBlock GameObject");
		creatureId = asset.CreatureId;
		creatureBlock = new GameObject("Effect:" + ((object)(CreatureGuid)(ref creatureId)).ToString() + ".StatesBlock");
		Debug.Log((object)"States Plugin: Checking Source");
		if ((Object)(object)asset != (Object)null)
		{
			if ((Object)(object)Utility.GetBaseLoader(asset.CreatureId) != (Object)null)
			{
				if ((Object)(object)Utility.GetBaseLoader(asset.CreatureId).transform != (Object)null)
				{
					Debug.Log((object)"States Plugin: Creating Creature Block");
					Vector3 position = Utility.GetBaseLoader(asset.CreatureId).transform.position;
					Vector3 eulerAngles = Utility.GetBaseLoader(asset.CreatureId).transform.eulerAngles;
					if ((Object)(object)creatureBlock != (Object)null)
					{
						Debug.Log((object)"States Plugin: Applying Creature Block Position And Rotation");
						creatureBlock.transform.position = Vector3.zero;
						creatureBlock.transform.eulerAngles = Vector3.zero;
						Debug.Log((object)"States Plugin: Creating StatesText (TextMeshPro)");
						creatureStateText = creatureBlock.AddComponent<TextMeshPro>();
						Debug.Log((object)"States Plugin: Applying StatesText (TextMeshPro) Properties");
						creatureStateText.transform.position = Vector3.zero;
						creatureStateText.transform.eulerAngles = Vector3.zero;
						((TMP_Text)creatureStateText).textStyle = TMP_Style.NormalStyle;
						((TMP_Text)creatureStateText).enableWordWrapping = true;
						((TMP_Text)creatureStateText).alignment = (TextAlignmentOptions)514;
						((TMP_Text)creatureStateText).autoSizeTextContainer = true;
						((Graphic)creatureStateText).color = baseColor.Value;
						((TMP_Text)creatureStateText).fontSize = 1f;
						((TMP_Text)creatureStateText).fontWeight = (FontWeight)700;
						((TMP_Text)creatureStateText).isTextObjectScaleStatic = true;
					}
					else
					{
						Debug.Log((object)"States Plugin: Newly Create CreatureBlock Is Null");
						creatureStateText = null;
					}
				}
				else
				{
					Debug.Log((object)"States Plugin: Invalid Transform Provided");
					creatureStateText = null;
				}
			}
			else
			{
				Debug.Log((object)"States Plugin: Invalid Creature Root Provided");
				creatureStateText = null;
			}
		}
		else
		{
			Debug.Log((object)"States Plugin: Invalid Asset Provided");
			creatureStateText = null;
		}
	}

	private void populateCreatureStateText(TextMeshPro creatureStateText, Change change, CreatureBoardAsset asset)
	{
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)creatureStateText == (Object)null)
		{
			return;
		}
		Debug.Log((object)"States Plugin: Populating StatesText (TextMeshPro)");
		((TMP_Text)creatureStateText).autoSizeTextContainer = false;
		string text = change.value.Replace(",", "\r\n");
		if (colorizations.ContainsKey("<Default>"))
		{
			text = "<Default>" + text;
		}
		((TMP_Text)creatureStateText).richText = true;
		((TMP_Text)creatureStateText).fontSize = baseSize;
		((TMP_Text)creatureStateText).alignment = (TextAlignmentOptions)1026;
		foreach (KeyValuePair<string, string> colorization in colorizations)
		{
			text = text.Replace(colorization.Key, colorization.Value);
		}
		((TMP_Text)creatureStateText).text = text;
		((TMP_Text)creatureStateText).autoSizeTextContainer = true;
		creatureStateText.transform.position = new Vector3(Utility.GetBaseLoader(asset.CreatureId).transform.position.x, calculateYPos(asset) + ((TMP_Text)creatureStateText).preferredHeight, Utility.GetBaseLoader(asset.CreatureId).transform.position.z);
	}

	private float calculateYPos(CreatureBoardAsset asset, bool diagnostic = false)
	{
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//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_009b: 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_00c8: 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_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: 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_015b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_0164: Unknown result type (might be due to invalid IL or missing references)
		//IL_0169: Unknown result type (might be due to invalid IL or missing references)
		//IL_0412: Unknown result type (might be due to invalid IL or missing references)
		//IL_0417: Unknown result type (might be due to invalid IL or missing references)
		//IL_0420: Unknown result type (might be due to invalid IL or missing references)
		//IL_0433: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ef: 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_0484: Unknown result type (might be due to invalid IL or missing references)
		//IL_0489: Unknown result type (might be due to invalid IL or missing references)
		//IL_048d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0492: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_04bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_022e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0233: Unknown result type (might be due to invalid IL or missing references)
		//IL_0237: Unknown result type (might be due to invalid IL or missing references)
		//IL_023c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0257: Unknown result type (might be due to invalid IL or missing references)
		//IL_025c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0260: Unknown result type (might be due to invalid IL or missing references)
		//IL_0265: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_032a: Unknown result type (might be due to invalid IL or missing references)
		//IL_032f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0333: Unknown result type (might be due to invalid IL or missing references)
		//IL_0338: Unknown result type (might be due to invalid IL or missing references)
		//IL_0353: Unknown result type (might be due to invalid IL or missing references)
		//IL_0358: 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)
		//IL_0361: Unknown result type (might be due to invalid IL or missing references)
		float val = 1000f;
		float num = 0f;
		try
		{
			switch (offsetMethod)
			{
			case OffsetMethod.fixedOffset:
				val = 0f;
				num = 1f;
				break;
			case OffsetMethod.baseScaleFixedOffet:
				val = 0f;
				num = 1f * ((MovableBoardAsset)asset).Scale;
				break;
			case OffsetMethod.headHookMultiplierOffset:
				val = 0f;
				num = asset.HookHead.position.y;
				break;
			case OffsetMethod.boundsOffset:
			{
				Bounds bounds2;
				if ((Object)(object)Utility.GetAssetLoader(asset.CreatureId).GetComponentInChildren<MeshFilter>() != (Object)null)
				{
					MeshFilter[] componentsInChildren = Utility.GetAssetLoader(asset.CreatureId).GetComponentsInChildren<MeshFilter>();
					foreach (MeshFilter val2 in componentsInChildren)
					{
						Bounds bounds = val2.mesh.bounds;
						bool flag = true;
						val = Math.Min(val, ((Bounds)(ref bounds)).min.y);
						num = Math.Max(num, ((Bounds)(ref bounds)).max.y);
						if (diagnostic)
						{
							string[] obj = new string[8]
							{
								"Mesh ",
								((Object)val2.mesh).name,
								": Bounds ",
								null,
								null,
								null,
								null,
								null
							};
							bounds2 = val2.mesh.bounds;
							obj[3] = ((Bounds)(ref bounds2)).min.y.ToString();
							obj[4] = "->";
							bounds2 = val2.mesh.bounds;
							obj[5] = ((Bounds)(ref bounds2)).max.y.ToString();
							obj[6] = " | Max: ";
							obj[7] = num.ToString();
							Debug.Log((object)string.Concat(obj));
						}
					}
					MeshRenderer[] componentsInChildren2 = Utility.GetAssetLoader(asset.CreatureId).GetComponentsInChildren<MeshRenderer>();
					foreach (MeshRenderer val3 in componentsInChildren2)
					{
						Bounds bounds3 = ((Renderer)val3).bounds;
						bool flag2 = true;
						val = Math.Min(val, ((Bounds)(ref bounds3)).min.y);
						num = Math.Max(num, ((Bounds)(ref bounds3)).max.y);
						if (diagnostic)
						{
							string[] obj2 = new string[8]
							{
								"Mesh ",
								((Object)val3).name,
								": Bounds ",
								null,
								null,
								null,
								null,
								null
							};
							bounds2 = ((Renderer)val3).bounds;
							obj2[3] = ((Bounds)(ref bounds2)).min.y.ToString();
							obj2[4] = "->";
							bounds2 = ((Renderer)val3).bounds;
							obj2[5] = ((Bounds)(ref bounds2)).max.y.ToString();
							obj2[6] = " | Max: ";
							obj2[7] = num.ToString();
							Debug.Log((object)string.Concat(obj2));
						}
					}
					SkinnedMeshRenderer[] componentsInChildren3 = Utility.GetAssetLoader(asset.CreatureId).GetComponentsInChildren<SkinnedMeshRenderer>();
					foreach (SkinnedMeshRenderer val4 in componentsInChildren3)
					{
						Bounds bounds4 = ((Renderer)val4).bounds;
						bool flag3 = true;
						val = Math.Min(val, ((Bounds)(ref bounds4)).min.y);
						num = Math.Max(num, ((Bounds)(ref bounds4)).max.y);
						if (diagnostic)
						{
							string[] obj3 = new string[8]
							{
								"Mesh ",
								((Object)val4).name,
								": Bounds ",
								null,
								null,
								null,
								null,
								null
							};
							bounds2 = ((Renderer)val4).bounds;
							obj3[3] = ((Bounds)(ref bounds2)).min.y.ToString();
							obj3[4] = "->";
							bounds2 = ((Renderer)val4).bounds;
							obj3[5] = ((Bounds)(ref bounds2)).max.y.ToString();
							obj3[6] = " | Max: ";
							obj3[7] = num.ToString();
							Debug.Log((object)string.Concat(obj3));
						}
					}
				}
				CreatureGuid creatureId = asset.CreatureId;
				GameObject val5 = GameObject.Find("CustomContent:" + ((object)(CreatureGuid)(ref creatureId)).ToString());
				if (!((Object)(object)val5 != (Object)null) || !((Object)(object)val5.GetComponentInChildren<MeshFilter>() != (Object)null))
				{
					break;
				}
				MeshFilter[] componentsInChildren4 = val5.GetComponentsInChildren<MeshFilter>();
				foreach (MeshFilter val6 in componentsInChildren4)
				{
					Bounds bounds5 = val5.GetComponentInChildren<MeshFilter>().mesh.bounds;
					bool flag4 = true;
					val = Math.Min(val, ((Bounds)(ref bounds5)).min.y);
					num = Math.Max(num, ((Bounds)(ref bounds5)).max.y);
					if (diagnostic)
					{
						string[] obj4 = new string[8]
						{
							"Mesh ",
							((Object)val5.GetComponentInChildren<MeshFilter>().mesh).name,
							": Bounds ",
							null,
							null,
							null,
							null,
							null
						};
						bounds2 = val5.GetComponentInChildren<MeshFilter>().mesh.bounds;
						obj4[3] = ((Bounds)(ref bounds2)).min.y.ToString();
						obj4[4] = "->";
						bounds2 = val5.GetComponentInChildren<MeshFilter>().mesh.bounds;
						obj4[5] = ((Bounds)(ref bounds2)).max.y.ToString();
						obj4[6] = " | Max: ";
						obj4[7] = num.ToString();
						Debug.Log((object)string.Concat(obj4));
					}
				}
				break;
			}
			}
		}
		catch (Exception ex)
		{
			Debug.Log((object)"States Plugin: Exception");
			Debug.LogException(ex);
			val = 0f;
			num = 1f;
		}
		return num * offsetValue;
	}

	public void SetRequest(CreatureGuid cid)
	{
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		CreatureBoardAsset asset = default(CreatureBoardAsset);
		CreaturePresenter.TryGetAsset(cid, ref asset);
		if ((Object)(object)asset != (Object)null)
		{
			string text = StatMessaging.ReadInfo(asset.CreatureId, "org.lordashes.plugins.states");
			SystemMessage.AskForTextInput("State", "Enter Creature State(s):", "OK", (Action<string>)delegate(string newStates)
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				StatMessaging.SetInfo(asset.CreatureId, "org.lordashes.plugins.states", newStates);
			}, (Action)null, "Clear", (Action)delegate
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				StatMessaging.ClearInfo(asset.CreatureId, "org.lordashes.plugins.states");
			}, text);
		}
	}

	public void syncStealthMode()
	{
		//IL_0002: 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)
		//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)
		foreach (CreatureBoardAsset item in (IEnumerable<CreatureBoardAsset>)CreaturePresenter.GetTempReadOnlyViewOfAllCreatureAssets())
		{
			try
			{
				CreatureGuid creatureId = item.CreatureId;
				GameObject val = GameObject.Find("Effect:" + ((object)(CreatureGuid)(ref creatureId)).ToString() + ".StatesBlock");
				if ((Object)(object)val != (Object)null)
				{
					if (item.IsExplicitlyHidden && ((Behaviour)val.GetComponent<TextMeshPro>()).enabled)
					{
						((Behaviour)val.GetComponent<TextMeshPro>()).enabled = false;
					}
					else if (!item.IsExplicitlyHidden && !((Behaviour)val.GetComponent<TextMeshPro>()).enabled)
					{
						((Behaviour)val.GetComponent<TextMeshPro>()).enabled = true;
					}
				}
			}
			catch (Exception)
			{
			}
		}
	}

	public bool isBoardLoaded()
	{
		return SimpleSingletonBehaviour<CameraController>.HasInstance && SingletonStateMBehaviour<BoardSessionManager, State<BoardSessionManager>>.HasInstance && !BoardSessionManager.IsLoading;
	}
}
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 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)
			{
				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;
				}
				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;
				StartWith(val, "_creatureRoot", ref match);
				Transform match2 = null;
				Traverse(match, "AssetLoader", ref match2);
				if ((Object)(object)match2 != (Object)null)
				{
					if (match2.childCount > 0)
					{
						return ((Component)match2.GetChild(0)).gameObject;
					}
					return null;
				}
				return null;
			}
			return null;
		}
		catch
		{
			return null;
		}
	}

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

	public static void Traverse(Transform root, string seek, 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))
			{
				Traverse(item, seek, ref match);
			}
		}
		catch
		{
		}
	}
}