Decompiled source of PlaneImagePlugin v2.0.1

PlaneImagePlugin.dll

Decompiled 2 weeks ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using ModdingTales;
using Newtonsoft.Json;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.Video;

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

[BepInPlugin("org.lordashes.plugins.planeimage", "Plane Image Plugin", "2.0.1.0")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class PlaneImagePlugin : BaseUnityPlugin
{
	internal static class Camera
	{
		private static readonly MethodInfo _ToggleCameraMovement = Reflection.Method(_CameraController, "ToggleCameraMovement", (string[])null);

		public static void SetCameraMovementEnabled(bool enabled, string context)
		{
			try
			{
				Reflection.Execute(_ToggleCameraMovement, (object)null, new object[1] { enabled }, 0);
				LoggingPlugin.LogDebug(context + ": camera movement " + (enabled ? "enabled" : "disabled"));
			}
			catch (Exception ex)
			{
				LoggingPlugin.LogWarning(context + ": SetCameraMovementEnabled(" + enabled + ") failed: " + ex.Message);
			}
		}

		public static void RecentreCameraOnCurrentPlane(string context, bool transition = true)
		{
			//IL_004e: 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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			if (currentPlaneIndex < 0 || currentPlaneIndex >= planes.Count)
			{
				return;
			}
			try
			{
				Reflection.Execute(m_MoveToPosition, (object)null, new object[4]
				{
					planes[currentPlaneIndex].transform.position,
					transition,
					false,
					false
				}, 0);
				Vector3 position;
				if (transition)
				{
					position = planes[currentPlaneIndex].transform.position;
					LoggingPlugin.LogDebug(context + ": camera recentred on " + ((object)(Vector3)(ref position)).ToString());
				}
				else
				{
					position = planes[currentPlaneIndex].transform.position;
					LoggingPlugin.LogTrace(context + ": camera snapped to " + ((object)(Vector3)(ref position)).ToString());
				}
			}
			catch (Exception ex)
			{
				LoggingPlugin.LogWarning(context + ": camera recentre failed: " + ex.Message);
			}
		}
	}

	public enum GridMode
	{
		Off,
		Partial,
		Full
	}

	public enum PlaneImageMode
	{
		game,
		move,
		size,
		rotate
	}

	public static class Utility
	{
		private static object gameInputInstance;

		private static MethodInfo gameInputDisable;

		private static MethodInfo gameInputEnable;

		private static PropertyInfo isLoadingProp;

		private static PropertyInfo inBoardProp;

		public static bool isBoardLoaded()
		{
			try
			{
				if (inBoardProp == null)
				{
					inBoardProp = Reflection.Property(_BoardSessionManager, "InBoard", (string)null);
				}
				if (isLoadingProp == null)
				{
					isLoadingProp = Reflection.Property(_BoardSessionManager, "IsLoading", (string)null);
				}
				bool flag = false;
				try
				{
					flag = (bool)inBoardProp.GetValue(null);
				}
				catch
				{
				}
				bool flag2 = false;
				try
				{
					flag2 = (bool)isLoadingProp.GetValue(null);
				}
				catch
				{
				}
				return flag && !flag2;
			}
			catch (Exception ex)
			{
				Reflection.CatchFullError(ex);
				return false;
			}
		}

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

		public static void GameInputEnabled(bool setting)
		{
			if (gameInputInstance == null || gameInputDisable == null || gameInputEnable == null)
			{
				object obj = null;
				try
				{
					gameInputInstance = null;
					gameInputDisable = null;
					gameInputEnable = null;
					LoggingPlugin.LogDebug("Trying To Get Cntroller Instance");
					LoggingPlugin.LogDebug("Closed Type = " + _SimpleSingletonBehaviourControllerManager.GetType().Name);
					obj = Reflection.Execute(Reflection.Method(_SimpleSingletonBehaviourControllerManager, "TryGetInstance", (string[])null), (object)null, new object[1], 1);
					if (obj != null)
					{
						LoggingPlugin.LogDebug("ControllerManager = " + obj);
						object value = Reflection.Field(_ControllerManager, "_gameInput", (string)null).GetValue(obj);
						gameInputDisable = Reflection.Method(_GameInput, "Disable", (string[])null);
						gameInputEnable = Reflection.Method(_GameInput, "Enable", (string[])null);
						LoggingPlugin.LogDebug("Successfully Obtained References To Game Input");
					}
					else
					{
						LoggingPlugin.LogWarning("Unable to obtain ControllerManager instance");
						LoggingPlugin.LogDebug("ControllerManager = " + ((obj != null) ? obj.ToString() : "Null"));
						LoggingPlugin.LogDebug("GameInputDisable = " + ((gameInputDisable != null) ? gameInputDisable.ToString() : "Null"));
						LoggingPlugin.LogDebug("GameInputEnable = " + ((gameInputEnable != null) ? gameInputEnable.ToString() : "Null"));
					}
				}
				catch (Exception ex)
				{
					LoggingPlugin.LogWarning("Unable To Get Game Input Reference Or Reference To One Of Its Methods");
					Reflection.CatchFullError(ex);
					LoggingPlugin.LogDebug("ControllerManager = " + ((obj != null) ? obj.ToString() : "Null"));
					LoggingPlugin.LogDebug("GameInputDisable = " + ((gameInputDisable != null) ? gameInputDisable.ToString() : "Null"));
					LoggingPlugin.LogDebug("GameInputEnable = " + ((gameInputEnable != null) ? gameInputEnable.ToString() : "Null"));
				}
			}
			if (gameInputInstance != null && gameInputDisable != null && gameInputEnable != null)
			{
				if (setting && gameInputEnable != null)
				{
					LoggingPlugin.LogDebug("Enabling Game Input");
					gameInputEnable.Invoke(gameInputInstance, new object[0]);
				}
				else if (!setting && gameInputDisable != null)
				{
					LoggingPlugin.LogDebug("Disabling Game Input");
					gameInputDisable.Invoke(gameInputInstance, new object[0]);
				}
			}
		}
	}

	[CompilerGenerated]
	private sealed class <>c__DisplayClass82_0
	{
		public GameObject plane;

		public VideoPlayer video;

		internal bool <ApplyVideoAspectWhenReady>b__0()
		{
			return (Object)(object)plane == (Object)null || (Object)(object)video == (Object)null || video.width != 0;
		}
	}

	[CompilerGenerated]
	private sealed class <ApplyVideoAspectWhenReady>d__82 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public GameObject plane;

		public VideoPlayer video;

		public PlaneImagePlugin <>4__this;

		private <>c__DisplayClass82_0 <>8__1;

		private float <aspect>5__2;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <ApplyVideoAspectWhenReady>d__82(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>8__1 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Expected O, but got Unknown
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0184: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: 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)
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>8__1 = new <>c__DisplayClass82_0();
				<>8__1.plane = plane;
				<>8__1.video = video;
				<>2__current = (object)new WaitUntil((Func<bool>)(() => (Object)(object)<>8__1.plane == (Object)null || (Object)(object)<>8__1.video == (Object)null || <>8__1.video.width != 0));
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				if ((Object)(object)<>8__1.plane == (Object)null || (Object)(object)<>8__1.video == (Object)null)
				{
					return false;
				}
				if (<>8__1.video.height == 0)
				{
					LoggingPlugin.LogWarning("ApplyVideoAspectWhenReady: video reported width=" + <>8__1.video.width + " but height=0; skipping rescale");
					return false;
				}
				<aspect>5__2 = (float)<>8__1.video.height / (float)<>8__1.video.width;
				LoggingPlugin.LogDebug("ApplyVideoAspectWhenReady: Scaling Plane Based On Video Size " + <>8__1.video.width + "x" + <>8__1.video.height + " With Anchor Size = " + <>8__1.plane.transform.localScale.x);
				<>8__1.plane.transform.localScale = new Vector3(<>8__1.plane.transform.localScale.x, <>8__1.plane.transform.localScale.y, <>8__1.plane.transform.localScale.x * <aspect>5__2);
				<>4__this.BuildGridForPlane(<>8__1.plane);
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	[CompilerGenerated]
	private sealed class <TemporarilyDisplayPlaneInformation>d__83 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public PlaneImagePlugin <>4__this;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <TemporarilyDisplayPlaneInformation>d__83(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<>4__this.displayCurrentPlaneInfo = true;
				<>2__current = (object)new WaitForSeconds(3f);
				<>1__state = 1;
				return true;
			case 1:
				<>1__state = -1;
				<>4__this.displayCurrentPlaneInfo = false;
				return false;
			}
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	public static readonly Type _BoardSessionManager = Reflection.Type("BoardSessionManager", (string[])null, (string[])null, 0);

	public static readonly Type _Camera = Reflection.Type("Camera", (string[])null, (string[])null, 0);

	public static readonly Type _CameraController = Reflection.Type("CameraController", (string[])null, (string[])null, 0);

	public static readonly Type _ControllerManager = Reflection.Type("ControllerManager", (string[])null, (string[])null, 0);

	public static readonly Type _GameInput = Reflection.Type("GameInput", (string[])null, (string[])null, 0);

	public static readonly Type _LocalClient = Reflection.Type("LocalClient", (string[])null, (string[])null, 0);

	public static readonly Type _SystemMessage = Reflection.Type("SystemMessage", (string[])null, (string[])null, 0);

	public static readonly Type _SimpleSingletonBehaviourControllerManager = Reflection.ClosedType("SimpleSingletonBehaviour`1", "ControllerManager", (string[])null, (string[])null);

	public static readonly MethodInfo m_AskForTextInput = Reflection.Method(_SystemMessage, "AskForTextInput", (string[])null);

	public static readonly MethodInfo m_GetCamera = Reflection.Method(Reflection.Type("CameraController", (string[])null, (string[])null, 0), "GetCamera", (string[])null);

	public static readonly MethodInfo m_MoveToPosition = Reflection.Method(_CameraController, "MoveToPosition", (string[])null);

	public static readonly PropertyInfo p_IsInGmMode = Reflection.Property(_LocalClient, "IsInGmMode", (string)null);

	private const string GridMaterialResourcePath = "Materials/GridLines";

	private static readonly int ID_Color = Shader.PropertyToID("_Color");

	private static readonly int ID_VisibleDistance = Shader.PropertyToID("_VisibleDistance");

	private static readonly int ID_GridWorldFade = Shader.PropertyToID("GridWorldFade");

	private const string GridChildName = "_PlaneImageGridOverlay";

	private const string GridChildNameMouse = "_PlaneImageGridOverlayMouse";

	private const float DefaultStripThickness = 0.07f;

	private const float DefaultDashRepeat = 8f;

	private const float DefaultHeightOffset = 0.05f;

	private const float BrDefaultVisibleDistance = 11.44f;

	private const float FullVisibleDistanceMultiplier = 10f;

	private Material gridSourceMaterial = null;

	private ConfigEntry<GridMode> cfgGridMode;

	private ConfigEntry<string> cfgGridColor;

	private ConfigEntry<int> cfgGridAlphaPct;

	private ConfigEntry<float> cfgGridSpacing;

	private ConfigEntry<float> cfgGridThickness;

	private ConfigEntry<float> cfgGridDashRepeat;

	private ConfigEntry<float> cfgGridHeightOffset;

	private readonly List<Vector3> _gridVerts = new List<Vector3>(256);

	private readonly List<Vector2> _gridUVs = new List<Vector2>(256);

	private readonly List<int> _gridTris = new List<int>(512);

	private readonly MaterialPropertyBlock _gridFadeBlock = new MaterialPropertyBlock();

	private readonly Dictionary<GameObject, MeshRenderer> _gridRenderers = new Dictionary<GameObject, MeshRenderer>();

	private readonly Dictionary<GameObject, MeshRenderer> _gridRenderersMouse = new Dictionary<GameObject, MeshRenderer>();

	private readonly List<GameObject> _gridFadeEvict = new List<GameObject>(8);

	public static bool displayCurrentGridInfo = false;

	public static object cam = null;

	public static PropertyInfo p_transform = null;

	private GameObject prefab = null;

	private static int currentPlaneIndex = -1;

	private bool displayCurrentPlaneInfo = false;

	public static PlaneImageMode activeMode = PlaneImageMode.game;

	private static List<GameObject> planes = new List<GameObject>();

	public const string Name = "Plane Image Plugin";

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

	public const string Version = "2.0.1.0";

	public static PlaneImagePlugin _self = null;

	private int debounce = -1;

	private KeyboardShortcut[] applyKeys = (KeyboardShortcut[])(object)new KeyboardShortcut[12]
	{
		new KeyboardShortcut((KeyCode)273, Array.Empty<KeyCode>()),
		new KeyboardShortcut((KeyCode)274, Array.Empty<KeyCode>()),
		new KeyboardShortcut((KeyCode)276, Array.Empty<KeyCode>()),
		new KeyboardShortcut((KeyCode)275, Array.Empty<KeyCode>()),
		new KeyboardShortcut((KeyCode)280, Array.Empty<KeyCode>()),
		new KeyboardShortcut((KeyCode)281, Array.Empty<KeyCode>()),
		new KeyboardShortcut((KeyCode)306, (KeyCode[])(object)new KeyCode[1] { (KeyCode)273 }),
		new KeyboardShortcut((KeyCode)306, (KeyCode[])(object)new KeyCode[1] { (KeyCode)274 }),
		new KeyboardShortcut((KeyCode)306, (KeyCode[])(object)new KeyCode[1] { (KeyCode)276 }),
		new KeyboardShortcut((KeyCode)306, (KeyCode[])(object)new KeyCode[1] { (KeyCode)275 }),
		new KeyboardShortcut((KeyCode)306, (KeyCode[])(object)new KeyCode[1] { (KeyCode)280 }),
		new KeyboardShortcut((KeyCode)306, (KeyCode[])(object)new KeyCode[1] { (KeyCode)281 })
	};

	private ConfigEntry<KeyboardShortcut>[] triggerKeys { get; set; }

	private void BindGridConfig()
	{
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Expected O, but got Unknown
		cfgGridMode = ((BaseUnityPlugin)this).Config.Bind<GridMode>("Grid Overlay", "Mode", GridMode.Partial, "Off: no grid overlay. Partial: dotted grid fades around the camera and mouse cursor using BR's default radius. Full: same overlays but with the fade radius scaled 10x so the grid is effectively always visible across the whole plane.");
		cfgGridColor = ((BaseUnityPlugin)this).Config.Bind<string>("Grid Overlay", "Line Color (R,G,B 0..1)", "1,1,1", "Grid line color as three comma-separated values between 0 and 1 (e.g. 1,1,1 = white, 1,0,0 = red). Opacity is controlled separately by 'Line Alpha %'.");
		cfgGridAlphaPct = ((BaseUnityPlugin)this).Config.Bind<int>("Grid Overlay", "Line Alpha %", 60, new ConfigDescription("Grid line opacity from 0 (invisible) to 100 (solid).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 100), Array.Empty<object>()));
		cfgGridSpacing = ((BaseUnityPlugin)this).Config.Bind<float>("Grid Overlay", "Spacing (tiles)", 1f, "Distance between grid lines, measured in TaleSpire tiles. Leave at 1.0 to match the floor grid; raise for a coarser overlay, lower for a finer one.");
		cfgGridThickness = ((BaseUnityPlugin)this).Config.Bind<float>("Grid Overlay", "Line Thickness (tiles)", 0.07f, "How wide each grid line is, in tiles. Default matches the look of TaleSpire's own floor grid.");
		cfgGridDashRepeat = ((BaseUnityPlugin)this).Config.Bind<float>("Grid Overlay", "Dashes Per Tile", 8f, "How many dashes appear along each tile of grid line. Higher = denser dot pattern.");
		cfgGridHeightOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Grid Overlay", "Height Offset (tiles)", 0.05f, "How far the grid sits above the image surface. Increase if you see the grid flickering through the image, or set to 0 to lay it flush.");
		LoggingPlugin.LogDebug("Grid Overlay config bound:");
		LoggingPlugin.LogDebug("  Mode               = " + cfgGridMode.Value);
		LoggingPlugin.LogDebug("  Color              = " + cfgGridColor.Value);
		LoggingPlugin.LogDebug("  Alpha %            = " + cfgGridAlphaPct.Value);
		LoggingPlugin.LogDebug("  Spacing            = " + cfgGridSpacing.Value);
		LoggingPlugin.LogDebug("  Thickness          = " + cfgGridThickness.Value);
		LoggingPlugin.LogDebug("  Dashes Per Unit    = " + cfgGridDashRepeat.Value);
		LoggingPlugin.LogDebug("  Height Offset      = " + cfgGridHeightOffset.Value);
		EventHandler eventHandler = delegate
		{
			RefreshGridOnAllPlanes();
		};
		cfgGridMode.SettingChanged += eventHandler;
		cfgGridColor.SettingChanged += eventHandler;
		cfgGridAlphaPct.SettingChanged += eventHandler;
		cfgGridSpacing.SettingChanged += eventHandler;
		cfgGridThickness.SettingChanged += eventHandler;
		cfgGridDashRepeat.SettingChanged += eventHandler;
		cfgGridHeightOffset.SettingChanged += eventHandler;
	}

	private void LoadGridMaterial()
	{
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Expected O, but got Unknown
		try
		{
			gridSourceMaterial = Resources.Load<Material>("Materials/GridLines");
			if ((Object)(object)gridSourceMaterial != (Object)null)
			{
				LoggingPlugin.LogInfo("LoadGridMaterial: loaded Bouncyrock material '" + ((Object)gridSourceMaterial).name + "' from Resources/Materials/GridLines (shader='" + (((Object)(object)gridSourceMaterial.shader != (Object)null) ? ((Object)gridSourceMaterial.shader).name : "<null>") + "')");
			}
			else
			{
				LoggingPlugin.LogWarning("LoadGridMaterial: Resources/Materials/GridLines not found. Falling back to a stock unlit-transparent shader; the grid will be solid (no dotted pattern).");
				Shader val = Shader.Find("Sprites/Default") ?? Shader.Find("Unlit/Transparent") ?? Shader.Find("Unlit/Color");
				if ((Object)(object)val == (Object)null)
				{
					LoggingPlugin.LogError("LoadGridMaterial: no fallback shader found; grid overlay will be disabled.");
					return;
				}
				gridSourceMaterial = new Material(val);
				((Object)gridSourceMaterial).name = "PlaneImageGridFallback";
			}
		}
		catch (Exception ex)
		{
			LoggingPlugin.LogError("LoadGridMaterial caught exception: " + ex);
		}
	}

	private void RefreshGridOnAllPlanes()
	{
		try
		{
			if (planes == null)
			{
				return;
			}
			LoggingPlugin.LogDebug("RefreshGridOnAllPlanes: " + planes.Count + " plane(s)");
			for (int i = 0; i < planes.Count; i++)
			{
				if ((Object)(object)planes[i] != (Object)null)
				{
					BuildGridForPlane(planes[i]);
				}
			}
		}
		catch (Exception ex)
		{
			LoggingPlugin.LogError("RefreshGridOnAllPlanes caught exception: " + ex);
		}
	}

	private void BuildGridForPlane(GameObject plane)
	{
		if ((Object)(object)plane == (Object)null || (Object)(object)gridSourceMaterial == (Object)null)
		{
			return;
		}
		try
		{
			EnsureGridChild(plane, "_PlaneImageGridOverlay", out var mf, out var mr);
			EnsureGridChild(plane, "_PlaneImageGridOverlayMouse", out var mf2, out var mr2);
			_gridRenderers[plane] = mr;
			_gridRenderersMouse[plane] = mr2;
			if (cfgGridMode == null || cfgGridMode.Value == GridMode.Off)
			{
				if ((Object)(object)mr != (Object)null)
				{
					((Renderer)mr).enabled = false;
				}
				if ((Object)(object)mr2 != (Object)null)
				{
					((Renderer)mr2).enabled = false;
				}
				return;
			}
			if (!RebuildGridMesh(plane, mf))
			{
				if ((Object)(object)mr != (Object)null)
				{
					((Renderer)mr).enabled = false;
				}
				if ((Object)(object)mr2 != (Object)null)
				{
					((Renderer)mr2).enabled = false;
				}
				return;
			}
			if ((Object)(object)mf2 != (Object)null)
			{
				mf2.sharedMesh = mf.sharedMesh;
			}
			if ((Object)(object)mr != (Object)null)
			{
				((Renderer)mr).enabled = true;
			}
			if ((Object)(object)mr2 != (Object)null)
			{
				((Renderer)mr2).enabled = true;
			}
			ApplyGridMaterialProps(plane, mr);
			ApplyGridMaterialProps(plane, mr2);
		}
		catch (Exception ex)
		{
			LoggingPlugin.LogError("BuildGridForPlane caught exception for plane '" + (((Object)(object)plane != (Object)null) ? ((Object)plane).name : "<null>") + "': " + ex);
		}
	}

	private void EnsureGridChild(GameObject plane, string childName, out MeshFilter mf, out MeshRenderer mr)
	{
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003e: Expected O, but got Unknown
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Expected O, but got Unknown
		Transform val = plane.transform.Find(childName);
		if ((Object)(object)val != (Object)null)
		{
			GameObject gameObject = ((Component)val).gameObject;
			mf = gameObject.GetComponent<MeshFilter>();
			mr = gameObject.GetComponent<MeshRenderer>();
			return;
		}
		GameObject val2 = new GameObject(childName);
		val2.transform.SetParent(plane.transform, false);
		val2.transform.localPosition = Vector3.zero;
		val2.transform.localRotation = Quaternion.identity;
		val2.transform.localScale = Vector3.one;
		mf = val2.AddComponent<MeshFilter>();
		mr = val2.AddComponent<MeshRenderer>();
		((Renderer)mr).receiveShadows = false;
		((Renderer)mr).shadowCastingMode = (ShadowCastingMode)0;
		((Renderer)mr).lightProbeUsage = (LightProbeUsage)0;
		((Renderer)mr).reflectionProbeUsage = (ReflectionProbeUsage)0;
		((Renderer)mr).material = new Material(gridSourceMaterial);
		((Object)((Renderer)mr).material).name = "PlaneImageGrid";
		LoggingPlugin.LogDebug("EnsureGridChild: created '" + childName + "' for plane '" + ((Object)plane).name + "'");
	}

	private bool RebuildGridMesh(GameObject plane, MeshFilter targetMF)
	{
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: 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)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0076: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ad: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f1: 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_00fb: 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_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: 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_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//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_0119: 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_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0122: Unknown result type (might be due to invalid IL or missing references)
		//IL_0124: Unknown result type (might be due to invalid IL or missing references)
		//IL_0126: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_015c: 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_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_018f: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b5: 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_01c8: 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_01e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_020f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0216: Unknown result type (might be due to invalid IL or missing references)
		//IL_0222: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: Unknown result type (might be due to invalid IL or missing references)
		//IL_017e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0180: Unknown result type (might be due to invalid IL or missing references)
		//IL_0185: 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_02ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0343: Unknown result type (might be due to invalid IL or missing references)
		//IL_0345: Unknown result type (might be due to invalid IL or missing references)
		//IL_0347: Unknown result type (might be due to invalid IL or missing references)
		//IL_0349: Unknown result type (might be due to invalid IL or missing references)
		//IL_034b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0389: Unknown result type (might be due to invalid IL or missing references)
		//IL_0390: Expected O, but got Unknown
		MeshFilter component = plane.GetComponent<MeshFilter>();
		if ((Object)(object)component == (Object)null || (Object)(object)component.sharedMesh == (Object)null)
		{
			return false;
		}
		Bounds bounds = component.sharedMesh.bounds;
		Vector3 val = default(Vector3);
		((Vector3)(ref val))..ctor(((Bounds)(ref bounds)).min.x, ((Bounds)(ref bounds)).center.y, ((Bounds)(ref bounds)).min.z);
		Vector3 val2 = default(Vector3);
		((Vector3)(ref val2))..ctor(((Bounds)(ref bounds)).max.x, ((Bounds)(ref bounds)).center.y, ((Bounds)(ref bounds)).min.z);
		Vector3 val3 = default(Vector3);
		((Vector3)(ref val3))..ctor(((Bounds)(ref bounds)).max.x, ((Bounds)(ref bounds)).center.y, ((Bounds)(ref bounds)).max.z);
		Vector3 val4 = default(Vector3);
		((Vector3)(ref val4))..ctor(((Bounds)(ref bounds)).min.x, ((Bounds)(ref bounds)).center.y, ((Bounds)(ref bounds)).max.z);
		Transform transform = plane.transform;
		Vector3 val5 = transform.TransformPoint(val);
		Vector3 val6 = transform.TransformPoint(val2);
		Vector3 val7 = transform.TransformPoint(val3);
		Vector3 val8 = transform.TransformPoint(val4);
		Vector3 val9 = Vector3.Cross(val6 - val5, val8 - val5);
		float magnitude = ((Vector3)(ref val9)).magnitude;
		if (magnitude < 1E-05f)
		{
			return false;
		}
		val9 /= magnitude;
		if (Vector3.Dot(val9, plane.transform.up) < 0f)
		{
			val9 = -val9;
		}
		float num = Mathf.Min(Mathf.Min(val5.x, val6.x), Mathf.Min(val7.x, val8.x));
		float num2 = Mathf.Max(Mathf.Max(val5.x, val6.x), Mathf.Max(val7.x, val8.x));
		float num3 = Mathf.Min(Mathf.Min(val5.z, val6.z), Mathf.Min(val7.z, val8.z));
		float num4 = Mathf.Max(Mathf.Max(val5.z, val6.z), Mathf.Max(val7.z, val8.z));
		float num5 = Mathf.Max(0.0001f, cfgGridSpacing.Value);
		float halfStrip = Mathf.Max(0f, cfgGridThickness.Value) * 0.5f;
		float dashRepeat = Mathf.Max(0.0001f, cfgGridDashRepeat.Value);
		float heightOffset = Mathf.Max(0f, cfgGridHeightOffset.Value);
		_gridVerts.Clear();
		_gridUVs.Clear();
		_gridTris.Clear();
		int num6 = Mathf.CeilToInt(num / num5);
		int num7 = Mathf.FloorToInt(num2 / num5);
		for (int i = num6; i <= num7; i++)
		{
			float gridValue = (float)i * num5;
			AddGridStrip(plane, val5, val6, val7, val8, val9, axisX: true, gridValue, halfStrip, dashRepeat, heightOffset);
		}
		int num8 = Mathf.CeilToInt(num3 / num5);
		int num9 = Mathf.FloorToInt(num4 / num5);
		for (int j = num8; j <= num9; j++)
		{
			float gridValue2 = (float)j * num5;
			AddGridStrip(plane, val5, val6, val7, val8, val9, axisX: false, gridValue2, halfStrip, dashRepeat, heightOffset);
		}
		Mesh val10 = targetMF.sharedMesh;
		if ((Object)(object)val10 == (Object)null)
		{
			val10 = new Mesh();
			((Object)val10).name = "PlaneImageGridMesh";
			val10.MarkDynamic();
			targetMF.sharedMesh = val10;
		}
		else
		{
			val10.Clear();
		}
		val10.SetVertices(_gridVerts);
		val10.SetUVs(0, _gridUVs);
		val10.SetTriangles(_gridTris, 0);
		val10.RecalculateBounds();
		return true;
	}

	private void AddGridStrip(GameObject plane, Vector3 wc0, Vector3 wc1, Vector3 wc2, Vector3 wc3, Vector3 worldNormal, bool axisX, float gridValue, float halfStrip, float dashRepeat, float heightOffset)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: 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_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: 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_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0047: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0095: 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_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: 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_00c9: 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_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: 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_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fe: 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_0105: 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_010c: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: 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_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: 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_013f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0141: Unknown result type (might be due to invalid IL or missing references)
		//IL_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0151: Unknown result type (might be due to invalid IL or missing references)
		//IL_0166: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: 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_01af: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e2: 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)
		Vector3 firstHit = Vector3.zero;
		Vector3 secondHit = Vector3.zero;
		int hitsSoFar = 0;
		hitsSoFar = TryEdgeIntersection(wc0, wc1, axisX, gridValue, ref firstHit, ref secondHit, hitsSoFar);
		hitsSoFar = TryEdgeIntersection(wc1, wc2, axisX, gridValue, ref firstHit, ref secondHit, hitsSoFar);
		hitsSoFar = TryEdgeIntersection(wc2, wc3, axisX, gridValue, ref firstHit, ref secondHit, hitsSoFar);
		hitsSoFar = TryEdgeIntersection(wc3, wc0, axisX, gridValue, ref firstHit, ref secondHit, hitsSoFar);
		if (hitsSoFar < 2)
		{
			return;
		}
		Vector3 val = secondHit - firstHit;
		float magnitude = ((Vector3)(ref val)).magnitude;
		if (!(magnitude < 1E-05f))
		{
			val /= magnitude;
			Vector3 val2 = Vector3.Cross(worldNormal, val);
			float magnitude2 = ((Vector3)(ref val2)).magnitude;
			if (!(magnitude2 < 1E-05f))
			{
				val2 = val2 / magnitude2 * halfStrip;
				Vector3 val3 = worldNormal * heightOffset;
				Vector3 val4 = firstHit - val2 + val3;
				Vector3 val5 = firstHit + val2 + val3;
				Vector3 val6 = secondHit + val2 + val3;
				Vector3 val7 = secondHit - val2 + val3;
				Transform transform = plane.transform;
				Vector3 item = transform.InverseTransformPoint(val4);
				Vector3 item2 = transform.InverseTransformPoint(val5);
				Vector3 item3 = transform.InverseTransformPoint(val6);
				Vector3 item4 = transform.InverseTransformPoint(val7);
				int count = _gridVerts.Count;
				_gridVerts.Add(item);
				_gridVerts.Add(item2);
				_gridVerts.Add(item3);
				_gridVerts.Add(item4);
				float num = magnitude * dashRepeat;
				_gridUVs.Add(new Vector2(1f, 0f));
				_gridUVs.Add(new Vector2(0f, 0f));
				_gridUVs.Add(new Vector2(0f, num));
				_gridUVs.Add(new Vector2(1f, num));
				_gridTris.Add(count);
				_gridTris.Add(count + 1);
				_gridTris.Add(count + 2);
				_gridTris.Add(count);
				_gridTris.Add(count + 2);
				_gridTris.Add(count + 3);
			}
		}
	}

	private static int TryEdgeIntersection(Vector3 a, Vector3 b, bool axisX, float gridValue, ref Vector3 firstHit, ref Vector3 secondHit, int hitsSoFar)
	{
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: 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_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: 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)
		//IL_0097: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: 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_00a9: 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_00e2: Unknown result type (might be due to invalid IL or missing references)
		if (hitsSoFar >= 2)
		{
			return hitsSoFar;
		}
		float num = (axisX ? a.x : a.z);
		float num2 = (axisX ? b.x : b.z);
		float num3 = num2 - num;
		if (Mathf.Abs(num3) < 1E-06f)
		{
			return hitsSoFar;
		}
		float num4 = (gridValue - num) / num3;
		if (num4 < 0f || num4 > 1f)
		{
			return hitsSoFar;
		}
		Vector3 val = a + (b - a) * num4;
		if (hitsSoFar == 0)
		{
			firstHit = val;
			return 1;
		}
		Vector3 val2 = val - firstHit;
		if (((Vector3)(ref val2)).sqrMagnitude < 1E-10f)
		{
			return hitsSoFar;
		}
		secondHit = val;
		return 2;
	}

	private void ApplyGridMaterialProps(GameObject plane, MeshRenderer mr)
	{
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0055: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: 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)
		if (!((Object)(object)mr == (Object)null) && !((Object)(object)((Renderer)mr).material == (Object)null))
		{
			Color val = ParseRgb(cfgGridColor.Value, Color.white);
			float num = Mathf.Clamp01((float)cfgGridAlphaPct.Value / 100f);
			Color val2 = default(Color);
			((Color)(ref val2))..ctor(val.r, val.g, val.b, num);
			Material material = ((Renderer)mr).material;
			if (material.HasProperty(ID_Color))
			{
				material.SetColor(ID_Color, val2);
			}
			float num2 = ((cfgGridMode != null && cfgGridMode.Value == GridMode.Full) ? 114.399994f : 11.44f);
			if (material.HasProperty(ID_VisibleDistance))
			{
				material.SetFloat(ID_VisibleDistance, num2);
			}
		}
	}

	private void LateUpdate()
	{
		//IL_00ed: 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_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: 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_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_028c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0291: Unknown result type (might be due to invalid IL or missing references)
		//IL_0296: 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_031c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0335: Unknown result type (might be due to invalid IL or missing references)
		//IL_033e: 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)
		if (cfgGridMode == null || cfgGridMode.Value == GridMode.Off || (_gridRenderers.Count == 0 && _gridRenderersMouse.Count == 0))
		{
			return;
		}
		if (cam == null)
		{
			try
			{
				cam = Reflection.Execute(m_GetCamera, (object)null, new object[0], 0);
			}
			catch
			{
				cam = Reflection.Property(_Camera, "main", (string)null).GetValue(null);
			}
		}
		if (p_transform == null)
		{
			p_transform = Reflection.Property(_Camera, "transform", (string)null);
		}
		if (cam == null || p_transform == null)
		{
			return;
		}
		Vector3 position = ((Transform)p_transform.GetValue(cam)).position;
		Vector4 val = default(Vector4);
		foreach (KeyValuePair<GameObject, MeshRenderer> gridRenderer in _gridRenderers)
		{
			GameObject key = gridRenderer.Key;
			MeshRenderer value = gridRenderer.Value;
			if ((Object)(object)key == (Object)null || (Object)(object)value == (Object)null)
			{
				_gridFadeEvict.Add(key);
			}
			else if (((Renderer)value).enabled)
			{
				Vector3 position2 = key.transform.position;
				((Vector4)(ref val))..ctor(position.x, position2.y, position.z, 0f);
				((Renderer)value).GetPropertyBlock(_gridFadeBlock);
				_gridFadeBlock.SetVector(ID_GridWorldFade, val);
				((Renderer)value).SetPropertyBlock(_gridFadeBlock);
			}
		}
		if (_gridFadeEvict.Count > 0)
		{
			for (int i = 0; i < _gridFadeEvict.Count; i++)
			{
				_gridRenderers.Remove(_gridFadeEvict[i]);
			}
			_gridFadeEvict.Clear();
		}
		if (_gridRenderersMouse.Count <= 0)
		{
			return;
		}
		object obj2 = cam;
		Camera val2 = (Camera)((obj2 is Camera) ? obj2 : null);
		if ((Object)(object)val2 == (Object)null)
		{
			val2 = Camera.main;
		}
		if (!((Object)(object)val2 != (Object)null))
		{
			return;
		}
		Ray ray = val2.ScreenPointToRay(Input.mousePosition);
		Vector4 val3 = default(Vector4);
		foreach (KeyValuePair<GameObject, MeshRenderer> item in _gridRenderersMouse)
		{
			GameObject key2 = item.Key;
			MeshRenderer value2 = item.Value;
			if ((Object)(object)key2 == (Object)null || (Object)(object)value2 == (Object)null)
			{
				_gridFadeEvict.Add(key2);
			}
			else if (((Renderer)value2).enabled)
			{
				float y = key2.transform.position.y;
				if (TryRayPlaneIntersect(ray, y, out var hit))
				{
					((Vector4)(ref val3))..ctor(hit.x, y, hit.z, 0f);
					((Renderer)value2).GetPropertyBlock(_gridFadeBlock);
					_gridFadeBlock.SetVector(ID_GridWorldFade, val3);
					((Renderer)value2).SetPropertyBlock(_gridFadeBlock);
				}
			}
		}
		if (_gridFadeEvict.Count > 0)
		{
			for (int j = 0; j < _gridFadeEvict.Count; j++)
			{
				_gridRenderersMouse.Remove(_gridFadeEvict[j]);
			}
			_gridFadeEvict.Clear();
		}
	}

	private static bool TryRayPlaneIntersect(Ray ray, float planeY, out Vector3 hit)
	{
		//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_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: 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_0066: 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_0070: Unknown result type (might be due to invalid IL or missing references)
		hit = Vector3.zero;
		float y = ((Ray)(ref ray)).direction.y;
		if (Mathf.Abs(y) < 1E-05f)
		{
			return false;
		}
		float num = (planeY - ((Ray)(ref ray)).origin.y) / y;
		if (num <= 0f)
		{
			return false;
		}
		hit = ((Ray)(ref ray)).origin + ((Ray)(ref ray)).direction * num;
		return true;
	}

	private static Color ParseRgb(string s, Color fallback)
	{
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: 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_000d: Unknown result type (might be due to invalid IL or missing references)
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: 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)
		try
		{
			if (string.IsNullOrEmpty(s))
			{
				return fallback;
			}
			string[] array = s.Split(new char[1] { ',' });
			if (array.Length < 3)
			{
				return fallback;
			}
			return new Color(Utility.ParseFloat(array[0].Trim()), Utility.ParseFloat(array[1].Trim()), Utility.ParseFloat(array[2].Trim()), 1f);
		}
		catch
		{
			return fallback;
		}
	}

	private void Awake()
	{
		//IL_001e: 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_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: 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_0128: 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_0178: 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_0256: Unknown result type (might be due to invalid IL or missing references)
		//IL_025b: Unknown result type (might be due to invalid IL or missing references)
		//IL_028f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0294: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
		_self = this;
		LoggingPlugin.SetLogLevel(((BaseUnityPlugin)this).Config.Bind<DiagnosticLevel>("Settings", "Diagnostic Level", (DiagnosticLevel)3, (ConfigDescription)null).Value);
		string? assemblyQualifiedName = ((object)this).GetType().AssemblyQualifiedName;
		DiagnosticLevel logLevel = LoggingPlugin.GetLogLevel();
		LoggingPlugin.LogInfo(assemblyQualifiedName + ": Active. (Diagnostic Mode = " + ((object)(DiagnosticLevel)(ref logLevel)).ToString() + ")");
		triggerKeys = new ConfigEntry<KeyboardShortcut>[8]
		{
			((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Add Plane Image", new KeyboardShortcut((KeyCode)291, Array.Empty<KeyCode>()), (ConfigDescription)null),
			((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Remove Plane Image", new KeyboardShortcut((KeyCode)303, (KeyCode[])(object)new KeyCode[1] { (KeyCode)291 }), (ConfigDescription)null),
			((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Replace Image", new KeyboardShortcut((KeyCode)292, Array.Empty<KeyCode>()), (ConfigDescription)null),
			((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Cycle Planes", new KeyboardShortcut((KeyCode)282, Array.Empty<KeyCode>()), (ConfigDescription)null),
			((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Toggle Move Mode", new KeyboardShortcut((KeyCode)283, Array.Empty<KeyCode>()), (ConfigDescription)null),
			((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Toggle Size Mode", new KeyboardShortcut((KeyCode)284, Array.Empty<KeyCode>()), (ConfigDescription)null),
			((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Toggle Rotate Mode", new KeyboardShortcut((KeyCode)285, Array.Empty<KeyCode>()), (ConfigDescription)null),
			((BaseUnityPlugin)this).Config.Bind<KeyboardShortcut>("Hotkeys", "Toggle Grid Overlay", new KeyboardShortcut((KeyCode)286, Array.Empty<KeyCode>()), (ConfigDescription)null)
		};
		AssetDataPlugin.Subscribe("org.lordashes.plugins.planeimage.Create", (Action<DatumChange>)RequestHandler);
		AssetDataPlugin.Subscribe("org.lordashes.plugins.planeimage.Update", (Action<DatumChange>)RequestHandler, (Func<DatumChange, bool>)CheckPlaneExistance);
		string[] array = File.Find("/laplane01", (CacheType)0);
		if (array.Length != 0)
		{
			try
			{
				LoggingPlugin.LogDebug("Loading asset bundle '" + array[0] + "'");
				AssetBundle val = AssetBundle.LoadFromFile(array[0]);
				LoggingPlugin.LogDebug("Loading asset prefab 'laplane01.prefab'");
				prefab = val.LoadAsset<GameObject>("laplane01.prefab");
				val.Unload(false);
				if (prefab.transform.localScale.x.ToString("0.00").ToString().ToUpper() == "NAN" || prefab.transform.localScale.z.ToString("0.00").ToString().ToUpper() == "NAN")
				{
					LoggingPlugin.LogTrace("Setting prefab localScale to (1,1,1)");
					prefab.transform.localScale = new Vector3(1f, 1f, 1f);
				}
			}
			catch (Exception ex)
			{
				LoggingPlugin.LogWarning("Exception: " + ex);
			}
		}
		else
		{
			LoggingPlugin.LogWarning("Missing 'laplane01' file");
		}
		Reflection.AddEvent(_BoardSessionManager, "OnCurrentBoardChanged", (Delegate)(Action)delegate
		{
			LoggingPlugin.LogDebug("Board Change Event: Removing All Planes");
			planes = (from go in Object.FindObjectsOfType<GameObject>()
				where ((Object)go).name.StartsWith("Plane:")
				select go).ToList();
			for (int i = 0; i < planes.Count; i++)
			{
				Object.Destroy((Object)(object)planes[i]);
			}
			planes.Clear();
			currentPlaneIndex = -1;
			activeMode = PlaneImageMode.game;
			Utility.GameInputEnabled(setting: true);
			Camera.SetCameraMovementEnabled(enabled: true, "Board Change");
			LoggingPlugin.LogDebug("Board change cleanup complete; currentPlaneIndex reset to -1, mode reset to game, GameInput + camera-movement re-enabled");
		}, (object)null);
		BindGridConfig();
		LoadGridMaterial();
		ModdingUtils.AddPluginToMenuList((BaseUnityPlugin)(object)this, "Lord Ashes's");
	}

	private void Update()
	{
		//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)
		//IL_00b6: 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_1d8a: Unknown result type (might be due to invalid IL or missing references)
		//IL_1d8f: Unknown result type (might be due to invalid IL or missing references)
		//IL_1dc9: Unknown result type (might be due to invalid IL or missing references)
		//IL_1dce: Unknown result type (might be due to invalid IL or missing references)
		//IL_1e08: Unknown result type (might be due to invalid IL or missing references)
		//IL_1e0d: Unknown result type (might be due to invalid IL or missing references)
		//IL_1e47: Unknown result type (might be due to invalid IL or missing references)
		//IL_1e4c: Unknown result type (might be due to invalid IL or missing references)
		//IL_1e86: Unknown result type (might be due to invalid IL or missing references)
		//IL_1e8b: Unknown result type (might be due to invalid IL or missing references)
		//IL_1ec5: Unknown result type (might be due to invalid IL or missing references)
		//IL_1eca: Unknown result type (might be due to invalid IL or missing references)
		//IL_1f04: Unknown result type (might be due to invalid IL or missing references)
		//IL_1f09: Unknown result type (might be due to invalid IL or missing references)
		//IL_1f43: Unknown result type (might be due to invalid IL or missing references)
		//IL_1f48: Unknown result type (might be due to invalid IL or missing references)
		//IL_1f82: Unknown result type (might be due to invalid IL or missing references)
		//IL_1f87: 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_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ad: 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_02a3: 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)
		//IL_0356: Unknown result type (might be due to invalid IL or missing references)
		//IL_035b: Unknown result type (might be due to invalid IL or missing references)
		//IL_057e: Unknown result type (might be due to invalid IL or missing references)
		//IL_059c: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_0409: Unknown result type (might be due to invalid IL or missing references)
		//IL_040e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d7a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d98: Unknown result type (might be due to invalid IL or missing references)
		//IL_0db6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0dc6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0621: Unknown result type (might be due to invalid IL or missing references)
		//IL_063f: Unknown result type (might be due to invalid IL or missing references)
		//IL_065d: Unknown result type (might be due to invalid IL or missing references)
		//IL_066d: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_04be: Unknown result type (might be due to invalid IL or missing references)
		//IL_1582: Unknown result type (might be due to invalid IL or missing references)
		//IL_15a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_15c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_15ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e1d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e3b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e59: Unknown result type (might be due to invalid IL or missing references)
		//IL_0e69: Unknown result type (might be due to invalid IL or missing references)
		//IL_06c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_06e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0706: Unknown result type (might be due to invalid IL or missing references)
		//IL_0710: Unknown result type (might be due to invalid IL or missing references)
		//IL_1625: Unknown result type (might be due to invalid IL or missing references)
		//IL_1649: Unknown result type (might be due to invalid IL or missing references)
		//IL_1667: Unknown result type (might be due to invalid IL or missing references)
		//IL_1671: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ec0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ee4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f02: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f0c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0767: Unknown result type (might be due to invalid IL or missing references)
		//IL_078b: Unknown result type (might be due to invalid IL or missing references)
		//IL_07a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_16c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_16e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_1704: Unknown result type (might be due to invalid IL or missing references)
		//IL_1714: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f63: Unknown result type (might be due to invalid IL or missing references)
		//IL_0f87: Unknown result type (might be due to invalid IL or missing references)
		//IL_0fa5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0faf: Unknown result type (might be due to invalid IL or missing references)
		//IL_080a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0828: Unknown result type (might be due to invalid IL or missing references)
		//IL_084c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0856: Unknown result type (might be due to invalid IL or missing references)
		//IL_176b: Unknown result type (might be due to invalid IL or missing references)
		//IL_1789: Unknown result type (might be due to invalid IL or missing references)
		//IL_17a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_17b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_1006: Unknown result type (might be due to invalid IL or missing references)
		//IL_102a: Unknown result type (might be due to invalid IL or missing references)
		//IL_1048: Unknown result type (might be due to invalid IL or missing references)
		//IL_1058: Unknown result type (might be due to invalid IL or missing references)
		//IL_08ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_08cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_08ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_08f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_180e: Unknown result type (might be due to invalid IL or missing references)
		//IL_182c: Unknown result type (might be due to invalid IL or missing references)
		//IL_1850: Unknown result type (might be due to invalid IL or missing references)
		//IL_185a: Unknown result type (might be due to invalid IL or missing references)
		//IL_10af: Unknown result type (might be due to invalid IL or missing references)
		//IL_10d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_10f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_1101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0950: Unknown result type (might be due to invalid IL or missing references)
		//IL_096e: Unknown result type (might be due to invalid IL or missing references)
		//IL_098c: Unknown result type (might be due to invalid IL or missing references)
		//IL_099c: Unknown result type (might be due to invalid IL or missing references)
		//IL_18b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_18cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_18f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_18fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_1158: Unknown result type (might be due to invalid IL or missing references)
		//IL_1176: Unknown result type (might be due to invalid IL or missing references)
		//IL_1194: Unknown result type (might be due to invalid IL or missing references)
		//IL_11a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_09f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a11: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a2f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a3f: Unknown result type (might be due to invalid IL or missing references)
		//IL_1954: Unknown result type (might be due to invalid IL or missing references)
		//IL_1978: Unknown result type (might be due to invalid IL or missing references)
		//IL_1996: Unknown result type (might be due to invalid IL or missing references)
		//IL_19a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_11fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_1219: Unknown result type (might be due to invalid IL or missing references)
		//IL_1237: Unknown result type (might be due to invalid IL or missing references)
		//IL_1247: Unknown result type (might be due to invalid IL or missing references)
		//IL_0a96: Unknown result type (might be due to invalid IL or missing references)
		//IL_0aba: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ad8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ae2: Unknown result type (might be due to invalid IL or missing references)
		//IL_19f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_1a1b: Unknown result type (might be due to invalid IL or missing references)
		//IL_1a39: Unknown result type (might be due to invalid IL or missing references)
		//IL_1a43: Unknown result type (might be due to invalid IL or missing references)
		//IL_129e: Unknown result type (might be due to invalid IL or missing references)
		//IL_12c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_12e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_12ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b3a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b5e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b7c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b86: Unknown result type (might be due to invalid IL or missing references)
		//IL_1a9a: Unknown result type (might be due to invalid IL or missing references)
		//IL_1ab8: Unknown result type (might be due to invalid IL or missing references)
		//IL_1ad6: Unknown result type (might be due to invalid IL or missing references)
		//IL_1ae6: Unknown result type (might be due to invalid IL or missing references)
		//IL_1342: Unknown result type (might be due to invalid IL or missing references)
		//IL_1366: Unknown result type (might be due to invalid IL or missing references)
		//IL_1384: Unknown result type (might be due to invalid IL or missing references)
		//IL_138e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bde: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bfc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c20: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c2a: Unknown result type (might be due to invalid IL or missing references)
		//IL_1b3e: Unknown result type (might be due to invalid IL or missing references)
		//IL_1b5c: Unknown result type (might be due to invalid IL or missing references)
		//IL_1b7a: Unknown result type (might be due to invalid IL or missing references)
		//IL_1b8a: Unknown result type (might be due to invalid IL or missing references)
		//IL_13e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_140a: Unknown result type (might be due to invalid IL or missing references)
		//IL_1428: Unknown result type (might be due to invalid IL or missing references)
		//IL_1438: Unknown result type (might be due to invalid IL or missing references)
		//IL_0c82: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ca0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cc4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cce: Unknown result type (might be due to invalid IL or missing references)
		//IL_1be2: Unknown result type (might be due to invalid IL or missing references)
		//IL_1c00: Unknown result type (might be due to invalid IL or missing references)
		//IL_1c24: Unknown result type (might be due to invalid IL or missing references)
		//IL_1c2e: Unknown result type (might be due to invalid IL or missing references)
		//IL_1490: Unknown result type (might be due to invalid IL or missing references)
		//IL_14b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_14d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_14e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_1c86: Unknown result type (might be due to invalid IL or missing references)
		//IL_1ca4: Unknown result type (might be due to invalid IL or missing references)
		//IL_1cc8: Unknown result type (might be due to invalid IL or missing references)
		//IL_1cd2: Unknown result type (might be due to invalid IL or missing references)
		if (!Utility.isBoardLoaded())
		{
			return;
		}
		if ((bool)p_IsInGmMode.GetValue(null))
		{
			KeyboardShortcut value = triggerKeys[0].Value;
			if (((KeyboardShortcut)(ref value)).IsUp())
			{
				LoggingPlugin.LogDebug("Add Plane Request");
				Reflection.Execute(m_AskForTextInput, (object)null, new object[8]
				{
					"Plane Image",
					"Name Of Image",
					"Set",
					(Action<string>)delegate(string image)
					{
						AssetDataPlugin.SetInfo("Plane:" + System.Guid.NewGuid(), "org.lordashes.plugins.planeimage.Create", image, false);
					},
					null,
					"Canel",
					null,
					"Plane Image"
				}, 0);
			}
			else
			{
				value = triggerKeys[1].Value;
				if (((KeyboardShortcut)(ref value)).IsUp())
				{
					LoggingPlugin.LogDebug("Remove Plane Request");
					AssetDataPlugin.ClearInfo(((Object)planes[currentPlaneIndex]).name, "org.lordashes.plugins.planeimage.Update", false);
					AssetDataPlugin.ClearInfo(((Object)planes[currentPlaneIndex]).name, "org.lordashes.plugins.planeimage.Create", false);
				}
				else
				{
					value = triggerKeys[2].Value;
					if (((KeyboardShortcut)(ref value)).IsUp())
					{
						LoggingPlugin.LogDebug("Replace Image Request");
						Reflection.Execute(m_AskForTextInput, (object)null, new object[8]
						{
							"Replace Image",
							"Name Of Image",
							"Set",
							(Action<string>)delegate(string image)
							{
								AssetDataPlugin.SetInfo(((Object)planes[currentPlaneIndex]).name, "org.lordashes.plugins.planeimage.Create", image, false);
							},
							null,
							"Canel",
							null,
							"Plane Image"
						}, 0);
					}
					else
					{
						value = triggerKeys[3].Value;
						if (((KeyboardShortcut)(ref value)).IsUp())
						{
							LoggingPlugin.LogDebug("Cycle Planes Request");
							if (planes.Count > 0)
							{
								currentPlaneIndex++;
								if (currentPlaneIndex >= planes.Count)
								{
									currentPlaneIndex = 0;
								}
								LoggingPlugin.LogDebug("Cycle Planes: (planes=" + planes.Count + ", currentIndex=" + currentPlaneIndex + ", mode=" + activeMode.ToString() + ")");
								Camera.RecentreCameraOnCurrentPlane("Cycle Planes");
							}
							((MonoBehaviour)this).StartCoroutine(TemporarilyDisplayPlaneInformation());
						}
						else
						{
							value = triggerKeys[4].Value;
							if (((KeyboardShortcut)(ref value)).IsUp())
							{
								if (activeMode != PlaneImageMode.move)
								{
									activeMode = PlaneImageMode.move;
								}
								else
								{
									activeMode = PlaneImageMode.game;
								}
								LoggingPlugin.LogDebug("Toggle Move Mode Request (Mode = " + activeMode.ToString() + ")");
								if (activeMode == PlaneImageMode.move)
								{
									Utility.GameInputEnabled(setting: false);
									Camera.SetCameraMovementEnabled(enabled: true, "Enter Move Mode");
									Camera.RecentreCameraOnCurrentPlane("Enter Move Mode");
								}
								else
								{
									Utility.GameInputEnabled(setting: true);
									Camera.SetCameraMovementEnabled(enabled: true, "Exit Move Mode");
								}
							}
							else
							{
								value = triggerKeys[5].Value;
								if (((KeyboardShortcut)(ref value)).IsUp())
								{
									if (activeMode != PlaneImageMode.size)
									{
										activeMode = PlaneImageMode.size;
									}
									else
									{
										activeMode = PlaneImageMode.game;
									}
									LoggingPlugin.LogDebug("Toggle Size Mode Request (Mode = " + activeMode.ToString() + ")");
									if (activeMode == PlaneImageMode.size)
									{
										Utility.GameInputEnabled(setting: false);
										Camera.SetCameraMovementEnabled(enabled: true, "Enter Size Mode");
										Camera.RecentreCameraOnCurrentPlane("Enter Size Mode");
									}
									else
									{
										Utility.GameInputEnabled(setting: true);
										Camera.SetCameraMovementEnabled(enabled: true, "Exit Size Mode");
									}
								}
								else
								{
									value = triggerKeys[6].Value;
									if (((KeyboardShortcut)(ref value)).IsUp())
									{
										if (activeMode != PlaneImageMode.rotate)
										{
											activeMode = PlaneImageMode.rotate;
										}
										else
										{
											activeMode = PlaneImageMode.game;
										}
										LoggingPlugin.LogDebug("Toggle Rotate Mode Request (Mode = " + activeMode.ToString() + ")");
										if (activeMode == PlaneImageMode.rotate)
										{
											Utility.GameInputEnabled(setting: false);
											Camera.SetCameraMovementEnabled(enabled: true, "Enter Rotate Mode");
											Camera.RecentreCameraOnCurrentPlane("Enter Rotate Mode");
										}
										else
										{
											Utility.GameInputEnabled(setting: true);
											Camera.SetCameraMovementEnabled(enabled: true, "Exit Rotate Mode");
										}
									}
									else
									{
										value = triggerKeys[7].Value;
										if (((KeyboardShortcut)(ref value)).IsUp())
										{
											switch (cfgGridMode.Value)
											{
											case GridMode.Off:
												cfgGridMode.Value = GridMode.Partial;
												break;
											case GridMode.Partial:
												cfgGridMode.Value = GridMode.Full;
												break;
											default:
												cfgGridMode.Value = GridMode.Off;
												break;
											}
											((MonoBehaviour)this).StartCoroutine(TemporarilyDisplayPlaneInformation());
										}
									}
								}
							}
						}
					}
				}
			}
			if (activeMode == PlaneImageMode.move)
			{
				bool flag = false;
				if (((KeyboardShortcut)(ref applyKeys[0])).IsUp())
				{
					planes[currentPlaneIndex].transform.position = new Vector3(planes[currentPlaneIndex].transform.position.x, planes[currentPlaneIndex].transform.position.y, planes[currentPlaneIndex].transform.position.z + 0.01f);
					flag = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[1])).IsUp())
				{
					planes[currentPlaneIndex].transform.position = new Vector3(planes[currentPlaneIndex].transform.position.x, planes[currentPlaneIndex].transform.position.y, planes[currentPlaneIndex].transform.position.z - 0.01f);
					flag = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[2])).IsUp())
				{
					planes[currentPlaneIndex].transform.position = new Vector3(planes[currentPlaneIndex].transform.position.x - 0.01f, planes[currentPlaneIndex].transform.position.y, planes[currentPlaneIndex].transform.position.z);
					flag = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[3])).IsUp())
				{
					planes[currentPlaneIndex].transform.position = new Vector3(planes[currentPlaneIndex].transform.position.x + 0.01f, planes[currentPlaneIndex].transform.position.y, planes[currentPlaneIndex].transform.position.z);
					flag = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[4])).IsUp())
				{
					planes[currentPlaneIndex].transform.position = new Vector3(planes[currentPlaneIndex].transform.position.x, planes[currentPlaneIndex].transform.position.y + 0.01f, planes[currentPlaneIndex].transform.position.z);
					flag = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[5])).IsUp())
				{
					planes[currentPlaneIndex].transform.position = new Vector3(planes[currentPlaneIndex].transform.position.x, planes[currentPlaneIndex].transform.position.y - 0.01f, planes[currentPlaneIndex].transform.position.z);
					flag = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[6])).IsPressed())
				{
					planes[currentPlaneIndex].transform.position = new Vector3(planes[currentPlaneIndex].transform.position.x, planes[currentPlaneIndex].transform.position.y, planes[currentPlaneIndex].transform.position.z + 0.1f);
					flag = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[7])).IsPressed())
				{
					planes[currentPlaneIndex].transform.position = new Vector3(planes[currentPlaneIndex].transform.position.x, planes[currentPlaneIndex].transform.position.y, planes[currentPlaneIndex].transform.position.z - 0.1f);
					flag = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[8])).IsPressed())
				{
					planes[currentPlaneIndex].transform.position = new Vector3(planes[currentPlaneIndex].transform.position.x - 0.1f, planes[currentPlaneIndex].transform.position.y, planes[currentPlaneIndex].transform.position.z);
					flag = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[9])).IsPressed())
				{
					planes[currentPlaneIndex].transform.position = new Vector3(planes[currentPlaneIndex].transform.position.x + 0.1f, planes[currentPlaneIndex].transform.position.y, planes[currentPlaneIndex].transform.position.z);
					flag = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[10])).IsPressed())
				{
					planes[currentPlaneIndex].transform.position = new Vector3(planes[currentPlaneIndex].transform.position.x, planes[currentPlaneIndex].transform.position.y + 0.1f, planes[currentPlaneIndex].transform.position.z);
					flag = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[11])).IsPressed())
				{
					planes[currentPlaneIndex].transform.position = new Vector3(planes[currentPlaneIndex].transform.position.x, planes[currentPlaneIndex].transform.position.y - 0.1f, planes[currentPlaneIndex].transform.position.z);
					flag = true;
				}
				if (flag)
				{
					debounce = 30;
					BuildGridForPlane(planes[currentPlaneIndex]);
					Camera.RecentreCameraOnCurrentPlane("Move Follow", transition: false);
					LoggingPlugin.LogTrace("Move change queued; debounce updater reset to 30");
				}
			}
			else if (activeMode == PlaneImageMode.size)
			{
				bool flag2 = false;
				if (((KeyboardShortcut)(ref applyKeys[0])).IsUp())
				{
					planes[currentPlaneIndex].transform.localScale = new Vector3(planes[currentPlaneIndex].transform.localScale.x, planes[currentPlaneIndex].transform.localScale.y, planes[currentPlaneIndex].transform.localScale.z + 0.01f);
					flag2 = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[1])).IsUp())
				{
					planes[currentPlaneIndex].transform.localScale = new Vector3(planes[currentPlaneIndex].transform.localScale.x, planes[currentPlaneIndex].transform.localScale.y, planes[currentPlaneIndex].transform.localScale.z - 0.01f);
					flag2 = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[2])).IsUp())
				{
					planes[currentPlaneIndex].transform.localScale = new Vector3(planes[currentPlaneIndex].transform.localScale.x - 0.01f, planes[currentPlaneIndex].transform.localScale.y, planes[currentPlaneIndex].transform.localScale.z);
					flag2 = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[3])).IsUp())
				{
					planes[currentPlaneIndex].transform.localScale = new Vector3(planes[currentPlaneIndex].transform.localScale.x + 0.01f, planes[currentPlaneIndex].transform.localScale.y, planes[currentPlaneIndex].transform.localScale.z);
					flag2 = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[4])).IsUp())
				{
					planes[currentPlaneIndex].transform.localScale = new Vector3(planes[currentPlaneIndex].transform.localScale.x + 0.01f, planes[currentPlaneIndex].transform.localScale.y, planes[currentPlaneIndex].transform.localScale.z + 0.01f);
					flag2 = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[5])).IsUp())
				{
					planes[currentPlaneIndex].transform.localScale = new Vector3(planes[currentPlaneIndex].transform.localScale.x - 0.01f, planes[currentPlaneIndex].transform.localScale.y, planes[currentPlaneIndex].transform.localScale.z - 0.01f);
					flag2 = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[6])).IsPressed())
				{
					planes[currentPlaneIndex].transform.localScale = new Vector3(planes[currentPlaneIndex].transform.localScale.x, planes[currentPlaneIndex].transform.localScale.y, planes[currentPlaneIndex].transform.localScale.z + 0.1f);
					flag2 = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[7])).IsPressed())
				{
					planes[currentPlaneIndex].transform.localScale = new Vector3(planes[currentPlaneIndex].transform.localScale.x, planes[currentPlaneIndex].transform.localScale.y, planes[currentPlaneIndex].transform.localScale.z - 0.1f);
					flag2 = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[8])).IsPressed())
				{
					planes[currentPlaneIndex].transform.localScale = new Vector3(planes[currentPlaneIndex].transform.localScale.x - 0.1f, planes[currentPlaneIndex].transform.localScale.y, planes[currentPlaneIndex].transform.localScale.z);
					flag2 = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[9])).IsPressed())
				{
					planes[currentPlaneIndex].transform.localScale = new Vector3(planes[currentPlaneIndex].transform.localScale.x + 0.1f, planes[currentPlaneIndex].transform.localScale.y, planes[currentPlaneIndex].transform.localScale.z);
					flag2 = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[10])).IsPressed())
				{
					planes[currentPlaneIndex].transform.localScale = new Vector3(planes[currentPlaneIndex].transform.localScale.x + 0.1f, planes[currentPlaneIndex].transform.localScale.y, planes[currentPlaneIndex].transform.localScale.z + 0.1f);
					flag2 = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[11])).IsPressed())
				{
					planes[currentPlaneIndex].transform.localScale = new Vector3(planes[currentPlaneIndex].transform.localScale.x - 0.1f, planes[currentPlaneIndex].transform.localScale.y, planes[currentPlaneIndex].transform.localScale.z - 0.1f);
					flag2 = true;
				}
				if (flag2)
				{
					debounce = 30;
					BuildGridForPlane(planes[currentPlaneIndex]);
					LoggingPlugin.LogTrace("Size change queued; debounce updater reset to 30");
				}
			}
			else if (activeMode == PlaneImageMode.rotate)
			{
				bool flag3 = false;
				if (((KeyboardShortcut)(ref applyKeys[0])).IsUp())
				{
					planes[currentPlaneIndex].transform.eulerAngles = new Vector3(planes[currentPlaneIndex].transform.eulerAngles.x + 1f, planes[currentPlaneIndex].transform.eulerAngles.y, planes[currentPlaneIndex].transform.eulerAngles.z);
					flag3 = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[1])).IsUp())
				{
					planes[currentPlaneIndex].transform.eulerAngles = new Vector3(planes[currentPlaneIndex].transform.eulerAngles.x - 1f, planes[currentPlaneIndex].transform.eulerAngles.y, planes[currentPlaneIndex].transform.eulerAngles.z);
					flag3 = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[2])).IsUp())
				{
					planes[currentPlaneIndex].transform.eulerAngles = new Vector3(planes[currentPlaneIndex].transform.eulerAngles.x, planes[currentPlaneIndex].transform.eulerAngles.y, planes[currentPlaneIndex].transform.eulerAngles.z + 1f);
					flag3 = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[3])).IsUp())
				{
					planes[currentPlaneIndex].transform.eulerAngles = new Vector3(planes[currentPlaneIndex].transform.eulerAngles.x, planes[currentPlaneIndex].transform.eulerAngles.y, planes[currentPlaneIndex].transform.eulerAngles.z - 1f);
					flag3 = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[4])).IsUp())
				{
					planes[currentPlaneIndex].transform.eulerAngles = new Vector3(planes[currentPlaneIndex].transform.eulerAngles.x, planes[currentPlaneIndex].transform.eulerAngles.y + 1f, planes[currentPlaneIndex].transform.eulerAngles.z);
					flag3 = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[5])).IsUp())
				{
					planes[currentPlaneIndex].transform.eulerAngles = new Vector3(planes[currentPlaneIndex].transform.eulerAngles.x, planes[currentPlaneIndex].transform.eulerAngles.y - 1f, planes[currentPlaneIndex].transform.eulerAngles.z);
					flag3 = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[6])).IsPressed())
				{
					planes[currentPlaneIndex].transform.eulerAngles = new Vector3(planes[currentPlaneIndex].transform.eulerAngles.x + 1f, planes[currentPlaneIndex].transform.eulerAngles.y, planes[currentPlaneIndex].transform.eulerAngles.z);
					flag3 = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[7])).IsPressed())
				{
					planes[currentPlaneIndex].transform.eulerAngles = new Vector3(planes[currentPlaneIndex].transform.eulerAngles.x - 1f, planes[currentPlaneIndex].transform.eulerAngles.y, planes[currentPlaneIndex].transform.eulerAngles.z);
					flag3 = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[8])).IsPressed())
				{
					planes[currentPlaneIndex].transform.eulerAngles = new Vector3(planes[currentPlaneIndex].transform.eulerAngles.x, planes[currentPlaneIndex].transform.eulerAngles.y, planes[currentPlaneIndex].transform.eulerAngles.z + 1f);
					flag3 = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[9])).IsPressed())
				{
					planes[currentPlaneIndex].transform.eulerAngles = new Vector3(planes[currentPlaneIndex].transform.eulerAngles.x, planes[currentPlaneIndex].transform.eulerAngles.y, planes[currentPlaneIndex].transform.eulerAngles.z - 1f);
					flag3 = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[10])).IsPressed())
				{
					planes[currentPlaneIndex].transform.eulerAngles = new Vector3(planes[currentPlaneIndex].transform.eulerAngles.x, planes[currentPlaneIndex].transform.eulerAngles.y + 1f, planes[currentPlaneIndex].transform.eulerAngles.z);
					flag3 = true;
				}
				else if (((KeyboardShortcut)(ref applyKeys[11])).IsPressed())
				{
					planes[currentPlaneIndex].transform.eulerAngles = new Vector3(planes[currentPlaneIndex].transform.eulerAngles.x, planes[currentPlaneIndex].transform.eulerAngles.y - 1f, planes[currentPlaneIndex].transform.eulerAngles.z);
					flag3 = true;
				}
				if (flag3)
				{
					debounce = 30;
					BuildGridForPlane(planes[currentPlaneIndex]);
					LoggingPlugin.LogTrace("Rotate change queued; debounce updater reset to 30");
				}
			}
		}
		if (debounce > 0)
		{
			debounce--;
		}
		else if (debounce == 0)
		{
			LoggingPlugin.LogTrace("Sending Update for plane '" + ((Object)planes[currentPlaneIndex]).name + "' (debounce expired)");
			string text = planes[currentPlaneIndex].transform.position.x.ToString("f", CultureInfo.InvariantCulture) + ",";
			text = text + planes[currentPlaneIndex].transform.position.y.ToString("f", CultureInfo.InvariantCulture) + ",";
			text = text + planes[currentPlaneIndex].transform.position.z.ToString("f", CultureInfo.InvariantCulture) + ",";
			text = text + planes[currentPlaneIndex].transform.localScale.x.ToString("f", CultureInfo.InvariantCulture) + ",";
			text = text + planes[currentPlaneIndex].transform.localScale.y.ToString("f", CultureInfo.InvariantCulture) + ",";
			text = text + planes[currentPlaneIndex].transform.localScale.z.ToString("f", CultureInfo.InvariantCulture) + ",";
			text = text + planes[currentPlaneIndex].transform.eulerAngles.x.ToString("f", CultureInfo.InvariantCulture) + ",";
			text = text + planes[currentPlaneIndex].transform.eulerAngles.y.ToString("f", CultureInfo.InvariantCulture) + ",";
			text += planes[currentPlaneIndex].transform.eulerAngles.z.ToString("f", CultureInfo.InvariantCulture);
			AssetDataPlugin.SetInfo(((Object)planes[currentPlaneIndex]).name, "org.lordashes.plugins.planeimage.Update", text, false);
			debounce--;
		}
	}

	private void OnGUI()
	{
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_019c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0274: 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_02ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e6: 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_031f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0324: 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_035d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0391: Unknown result type (might be due to invalid IL or missing references)
		//IL_0396: 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_03cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0403: Unknown result type (might be due to invalid IL or missing references)
		//IL_0408: Unknown result type (might be due to invalid IL or missing references)
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		if (!displayCurrentPlaneInfo && activeMode == PlaneImageMode.game)
		{
			return;
		}
		if (planes.Count == 0)
		{
			UpdatePlanesCache(0, "Zero Planes When In Non-Game Mode");
		}
		if (planes.Count == 0)
		{
			displayCurrentPlaneInfo = false;
			activeMode = PlaneImageMode.game;
			currentPlaneIndex = -1;
			Camera.SetCameraMovementEnabled(enabled: true, "Zero Planes Cleanup");
			return;
		}
		if (currentPlaneIndex >= planes.Count || currentPlaneIndex < 0)
		{
			currentPlaneIndex = 0;
		}
		try
		{
			if (planes[currentPlaneIndex].transform.localScale.x.ToString("0.00").ToString().ToUpper() == "NAN" || planes[currentPlaneIndex].transform.localScale.z.ToString("0.00").ToString().ToUpper() == "NAN")
			{
				LoggingPlugin.LogTrace("Detected NaN localScale on '" + ((Object)planes[currentPlaneIndex]).name + "'; Resetting to (1,1,1)");
				planes[currentPlaneIndex].transform.localScale = new Vector3(1f, 1f, 1f);
			}
			GUI.Label(new Rect(20f, (float)(Screen.height - 60), (float)(Screen.width - 40), 30f), "Planes: " + planes.Count + ", Plane: " + ((Object)((Renderer)planes[currentPlaneIndex].GetComponentInChildren<MeshRenderer>()).material).name + ", Mode: " + activeMode.ToString().Substring(0, 1).ToUpper() + activeMode.ToString().Substring(1) + ", Grid: " + cfgGridMode.Value.ToString() + ", Position: (" + planes[currentPlaneIndex].transform.position.x.ToString("0.00") + "," + planes[currentPlaneIndex].transform.position.y.ToString("0.00") + "," + planes[currentPlaneIndex].transform.position.z.ToString("0.00") + ") , Size: (" + planes[currentPlaneIndex].transform.localScale.x.ToString("0.00") + "x" + planes[currentPlaneIndex].transform.localScale.z.ToString("0.00") + "), Rotation: (" + planes[currentPlaneIndex].transform.eulerAngles.x.ToString("0.00") + "," + planes[currentPlaneIndex].transform.eulerAngles.y.ToString("0.00") + "," + planes[currentPlaneIndex].transform.eulerAngles.z.ToString("0.00") + ")");
		}
		catch (Exception ex)
		{
			LoggingPlugin.LogWarning("OnGUI render failed; reverting to game mode. Exception: " + ex.Message);
			Reflection.CatchFullError(ex);
			displayCurrentPlaneInfo = false;
			activeMode = PlaneImageMode.game;
		}
	}

	private void RequestHandler(DatumChange datum)
	{
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Invalid comparison between Unknown and I4
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Invalid comparison between Unknown and I4
		//IL_0167: Unknown result type (might be due to invalid IL or missing references)
		//IL_016c: Unknown result type (might be due to invalid IL or missing references)
		LoggingPlugin.LogDebug("Datum = " + JsonConvert.SerializeObject((object)datum));
		if (datum.key.EndsWith(".Create"))
		{
			if ((int)datum.action != 1)
			{
				LoggingPlugin.LogDebug("Routing to PlaneBuild (source='" + datum.source + "', content='" + datum.value?.ToString() + "')");
				PlaneBuild(datum.source, datum.value.ToString());
			}
			else
			{
				LoggingPlugin.LogDebug("Routing to PlaneRemove (source='" + datum.source + "')");
				PlaneRemove(datum.source);
			}
		}
		else if ((int)datum.action != 1 && datum.key.EndsWith(".Update"))
		{
			LoggingPlugin.LogDebug("Routing to PlaneUpdate (source='" + datum.source + "', specs='" + datum.value?.ToString() + "')");
			PlaneUpdate(datum.source, datum.value.ToString());
		}
		else
		{
			string[] obj = new string[5] { "RequestHandler: no route for action=", null, null, null, null };
			ChangeAction action = datum.action;
			obj[1] = ((object)(ChangeAction)(ref action)).ToString();
			obj[2] = " key=";
			obj[3] = datum.key;
			obj[4] = " (Ignored)";
			LoggingPlugin.LogDebug(string.Concat(obj));
		}
	}

	private bool CheckPlaneExistance(DatumChange datum)
	{
		LoggingPlugin.LogDebug("CheckPlaneExistance: Pending Datum " + datum.key + " on " + datum.source + " to " + datum.value);
		GameObject val = GameObject.Find(datum.source);
		if ((Object)(object)val == (Object)null)
		{
			LoggingPlugin.LogDebug("CheckPlaneExistance: No Go");
			return false;
		}
		MeshRenderer component = val.GetComponent<MeshRenderer>();
		if ((Object)(object)component == (Object)null)
		{
			LoggingPlugin.LogDebug("CheckPlaneExistance: No Mesh Renderer");
			return false;
		}
		if ((Object)(object)((Renderer)component).material == (Object)null)
		{
			LoggingPlugin.LogDebug("No Material");
			return false;
		}
		if ((Object)(object)((Renderer)component).material.mainTexture == (Object)null)
		{
			LoggingPlugin.LogDebug("CheckPlaneExistance: No Main Texture");
			return false;
		}
		if (val.activeInHierarchy && ((Renderer)component).enabled)
		{
			LoggingPlugin.LogDebug("CheckPlaneExistance: '" + datum.source + "' active and enabled — applying pending datum");
			return true;
		}
		LoggingPlugin.LogDebug("CheckPlaneExistance: '" + datum.source + "' not active/enabled (activeInHierarchy=" + val.activeInHierarchy + ", mr.enabled=" + ((Renderer)component).enabled + ") — deferring");
		return false;
	}

	private void PlaneBuild(string id, string image)
	{
		//IL_0075: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Unknown result type (might be due to invalid IL or missing references)
		try
		{
			LoggingPlugin.LogInfo("PlaneBuild: id='" + id + "', content='" + image + "'");
			GameObject val = GameObject.Find(id);
			if ((Object)(object)val != (Object)null)
			{
				LoggingPlugin.LogDebug("PlaneBuild: Using Existing Plane Game Object");
			}
			else
			{
				LoggingPlugin.LogDebug("PlaneBuild: Adding Plane Game Object");
				val = Object.Instantiate<GameObject>(prefab, new Vector3(0f, 0.1f, 0f), Quaternion.identity);
				planes.Add(val);
			}
			LoggingPlugin.LogDebug("PlaneBuild: Adding SkinnedMeshRenderer");
			MeshRenderer val2 = default(MeshRenderer);
			val.TryGetComponent<MeshRenderer>(ref val2);
			if ((Object)(object)val2 != (Object)null)
			{
				LoggingPlugin.LogDebug("PlaneBuild: Using Existing SkinnedMeshRenderer Object");
			}
			else
			{
				LoggingPlugin.LogDebug("PlaneBuild: Adding A SkinnedMeshRenderer Object");
				val2 = val.AddComponent<MeshRenderer>();
			}
			LoggingPlugin.LogDebug("PlaneBuild: Setting Bounds");
			((Renderer)val2).bounds = new Bounds(new Vector3(0f, 0f, 0f), new Vector3(2f, 2f, 2f));
			LoggingPlugin.LogDebug("PlaneBuild: Creating Material");
			ApplyPlaneTexture(val, val2, image);
			LoggingPlugin.LogDebug("PlaneBuild: Setting Mesh Name");
			((Object)val2).name = Path.GetFileNameWithoutExtension(image);
			LoggingPlugin.LogDebug("PlaneBuild: Setting Shadow Settings");
			((Renderer)val2).receiveShadows = false;
			((Renderer)val2).staticShadowCaster = false;
			LoggingPlugin.LogDebug("PlaneBuild: Enabling SkinnedMeshRenderer");
			((Renderer)val2).enabled = true;
			LoggingPlugin.LogDebug("PlaneBuild: Enabling Plane " + id);
			((Object)val).name = id;
			val.SetActive(true);
			UpdatePlanesCache(0, "Post Build");
			BuildGridForPlane(val);
			LoggingPlugin.LogInfo("PlaneBuild: Complete for '" + id + "' (planes=" + planes.Count + ", currentIndex=" + currentPlaneIndex + ")");
		}
		catch (Exception ex)
		{
			LoggingPlugin.LogWarning("PlaneBuild: Exception: " + ex);
			Reflection.CatchFullError(ex);
		}
		((MonoBehaviour)this).StartCoroutine(TemporarilyDisplayPlaneInformation());
	}

	private void PlaneUpdate(string id, string data)
	{
		//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b9: 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_01d5: 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_01f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0212: Unknown result type (might be due to invalid IL or missing references)
		//IL_0220: 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)
		try
		{
			LoggingPlugin.LogInfo("PlaneBuild: id='" + id + "', data='" + data + "'");
			GameObject val = planes.Where((GameObject p) => ((Object)p).name == id).ElementAt(0);
			if ((Object)(object)val == (Object)null)
			{
				UpdatePlanesCache(currentPlaneIndex - 1, "Plane Not Found During Update");
				val = planes.Where((GameObject p) => ((Object)p).name == id).ElementAt(0);
				if ((Object)(object)val != (Object)null)
				{
					LoggingPlugin.LogDebug("PlaneUpdate: Updating Plane Not Found");
					{