Decompiled source of AuraPlugin v1.0.5

AuraPlugin.dll

Decompiled 5 days ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using Bounce.Unmanaged;
using DataModel;
using LordAshes;
using RadialUI;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETFramework,Version=v4.8.1", FrameworkDisplayName = ".NET Framework 4.8.1")]
[assembly: AssemblyVersion("0.0.0.0")]
namespace AuraPlugin;

[BepInPlugin("andrew.talespire.auraplugin", "AuraPlugin", "1.0.5")]
[BepInDependency(/*Could not decode attribute arguments.*/)]
[BepInDependency(/*Could not decode attribute arguments.*/)]
public class AuraPlugin : BaseUnityPlugin
{
	private enum CustomInputField
	{
		Radius,
		Opacity
	}

	public const string Guid = "andrew.talespire.auraplugin";

	private const string EnabledKey = "AuraPlugin.Enabled";

	private const string RadiusKey = "AuraPlugin.Radius";

	private const string ColorKey = "AuraPlugin.Color";

	private const string ShapeKey = "AuraPlugin.Shape";

	private const string OpacityKey = "AuraPlugin.Opacity";

	private const string GridLinesKey = "AuraPlugin.GridLines";

	private const string ShapeFlat = "Flat";

	private const string ShapeBubble = "Bubble";

	private const string ToggleOn = "On";

	private const string ToggleOff = "Off";

	private ConfigEntry<float> radiusStepFeetConfig;

	private ConfigEntry<float> radiusMaxFeetConfig;

	private ConfigEntry<float> feetPerTileConfig;

	private ConfigEntry<string> colorPresetsConfig;

	private ConfigEntry<float> ringHeightConfig;

	private ConfigEntry<float> ringWidthConfig;

	private ConfigEntry<float> bubbleGridAlphaConfig;

	private ConfigEntry<int> bubbleGridRingCountConfig;

	private ConfigEntry<int> bubbleGridMeridianCountConfig;

	private ConfigEntry<float> bubbleGridLineWidthConfig;

	private ConfigEntry<float> opacityStepPercentConfig;

	private ConfigEntry<float> opacityRealMaxPercentConfig;

	private List<(string Name, Color Value)> colorSteps;

	private readonly Dictionary<string, GameObject> activeRings = new Dictionary<string, GameObject>();

	private MapMenuItem openEnabledItem;

	private MapMenuItem openRadiusItem;

	private MapMenuItem openColorItem;

	private MapMenuItem openShapeItem;

	private MapMenuItem openOpacityItem;

	private MapMenuItem openGridLinesItem;

	private string openSubmenuIdentity;

	private bool showCustomInput;

	private CustomInputField customInputField;

	private string customInputText = "";

	private string customInputTargetIdentity;

	private static readonly FieldInfo ValueTextField = typeof(MapMenuItem).GetField("_valueText", BindingFlags.Instance | BindingFlags.NonPublic);

	private static readonly FieldInfo CircleTextField = typeof(MapMenuItem).GetField("_circleContetText", BindingFlags.Instance | BindingFlags.NonPublic);

	private static Mesh unitSphereMesh;

	private void Awake()
	{
		//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_022e: Expected O, but got Unknown
		radiusStepFeetConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Presets", "RadiusStepFeet", 5f, "How much each click on the Aura Radius button adds.");
		radiusMaxFeetConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Presets", "RadiusMaxFeet", 60f, "Radius wraps back to the smallest step after exceeding this - use the Aura On/Off button to actually switch the aura off, not this.");
		feetPerTileConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Presets", "FeetPerTile", 5f, "Feet represented by one board tile/grid square. Match your table's ruler scale.");
		colorPresetsConfig = ((BaseUnityPlugin)this).Config.Bind<string>("Presets", "ColorSteps", "Gold:#FFD70066,Red:#FF000066,Blue:#1E90FF66,Green:#32CD3266,Purple:#9370DB66", "Aura color cycle as Name:RRGGBBAA pairs, comma separated.");
		ringHeightConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "RingHeightAboveBase", 0.05f, "How far above the tabletop the ring floats, in board units.");
		ringWidthConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "RingLineWidth", 0.05f, "Thickness of the aura ring line, in board units.");
		bubbleGridAlphaConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "BubbleGridAlpha", 0.45f, "Transparency of the bubble's latitude/longitude grid lines.");
		bubbleGridRingCountConfig = ((BaseUnityPlugin)this).Config.Bind<int>("Visual", "BubbleGridRingCount", 2, "Number of latitude rings drawn on the bubble between the equator and the pole.");
		bubbleGridMeridianCountConfig = ((BaseUnityPlugin)this).Config.Bind<int>("Visual", "BubbleGridMeridianCount", 6, "Number of longitude arcs drawn over the top of the bubble.");
		bubbleGridLineWidthConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "BubbleGridLineWidth", 0.015f, "Thickness of the bubble's equator/grid lines, in the bubble's own local (unit-radius) space - scales up with the radius, same as the real line's proportions in the reference screenshot.");
		opacityStepPercentConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Presets", "OpacityStepPercent", 10f, "How much each click on the Aura Opacity button adds, on the displayed 0-100 scale.");
		opacityRealMaxPercentConfig = ((BaseUnityPlugin)this).Config.Bind<float>("Visual", "OpacityRealMaxPercent", 30f, "The Aura Opacity button always displays 0-100%, but that's a rescaled range: this is the actual surface alpha percent applied when the display reads 100%. E.g. the default 30 means displayed 100% = 30% real alpha, displayed 50% = 15% real alpha, and so on - a linear rescale, not a cap.");
		ParsePresets();
		Sprite val = LoadIcon("aura.png");
		RadialUIPlugin.AddCustomButtonOnCharacter("AuraPlugin.Menu", new ItemArgs
		{
			Title = "Aura",
			Icon = val,
			CloseMenuOnActivate = false,
			FadeName = ((Object)(object)val != (Object)null),
			Action = delegate
			{
				OpenAuraSubmenu();
			}
		}, (Func<NGuid, NGuid, bool>)((NGuid self, NGuid target) => true));
		AssetDataPlugin.Subscribe("AuraPlugin.*", (Action<DatumChange>)OnAuraDataChanged);
		((BaseUnityPlugin)this).Logger.LogInfo((object)"AuraPlugin loaded.");
	}

	private void ParsePresets()
	{
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		colorSteps = new List<(string, Color)>();
		string[] array = colorPresetsConfig.Value.Split(new char[1] { ',' });
		Color item = default(Color);
		foreach (string text in array)
		{
			string[] array2 = text.Split(new char[1] { ':' });
			if (array2.Length == 2 && ColorUtility.TryParseHtmlString("#" + array2[1].Trim().TrimStart(new char[1] { '#' }), ref item))
			{
				colorSteps.Add((array2[0].Trim(), item));
			}
		}
		if (colorSteps.Count == 0)
		{
			colorSteps.Add(("Gold", new Color(1f, 0.84f, 0f, 0.4f)));
		}
	}

	private Sprite LoadIcon(string fileName)
	{
		//IL_0052: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Expected O, but got Unknown
		//IL_00a7: 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)
		string text = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) ?? "", fileName);
		if (!File.Exists(text))
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("AuraPlugin: icon file not found at '" + text + "' - button will show its text label instead."));
			return null;
		}
		Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
		if (!ImageConversion.LoadImage(val, File.ReadAllBytes(text)))
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("AuraPlugin: could not decode icon file '" + text + "' - button will show its text label instead."));
			return null;
		}
		return Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
	}

	private void OpenAuraSubmenu()
	{
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: 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_00ae: 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_00cc: Expected O, but got Unknown
		//IL_00d3: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: 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_0108: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: Expected O, but got Unknown
		//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_0136: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Expected O, but got Unknown
		//IL_0174: Unknown result type (might be due to invalid IL or missing references)
		//IL_0179: 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_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bb: Expected O, but got Unknown
		//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d2: 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_01f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_020e: Expected O, but got Unknown
		//IL_0215: Unknown result type (might be due to invalid IL or missing references)
		//IL_021a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0225: Unknown result type (might be due to invalid IL or missing references)
		//IL_0245: Unknown result type (might be due to invalid IL or missing references)
		//IL_024c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0253: Unknown result type (might be due to invalid IL or missing references)
		//IL_026a: Expected O, but got Unknown
		//IL_0270: Unknown result type (might be due to invalid IL or missing references)
		//IL_0275: Unknown result type (might be due to invalid IL or missing references)
		//IL_0280: Unknown result type (might be due to invalid IL or missing references)
		//IL_0297: Unknown result type (might be due to invalid IL or missing references)
		//IL_029e: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bc: Expected O, but got Unknown
		//IL_02be: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ec: 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_030a: Expected O, but got Unknown
		CreatureBoardAsset targetCreature = RadialMenus.GetTargetCreature();
		if (!((Object)(object)targetCreature == (Object)null))
		{
			string identity = ((object)targetCreature.CreatureId/*cast due to .constrained prefix*/).ToString();
			openSubmenuIdentity = identity;
			Vector3 val = ((Component)targetCreature).transform.position + Vector3.up * RadialMenus.GetHeightDiff();
			MapMenu val2 = MapMenuManager.OpenMenu(val, true);
			openEnabledItem = val2.AddItem(new ItemArgs
			{
				Title = "Aura On/Off",
				ValueText = (GetAuraEnabled(identity) ? "On" : "Off"),
				CloseMenuOnActivate = false,
				FadeName = false,
				Action = delegate
				{
					CycleAuraEnabled(identity);
				}
			});
			openRadiusItem = val2.AddItem(new ItemArgs
			{
				Title = "Aura Radius",
				ValueText = FormatRadius(GetCurrentRadiusFeet(identity)),
				CloseMenuOnActivate = false,
				FadeName = false,
				Action = delegate
				{
					StepRadius(identity);
				}
			});
			openColorItem = val2.AddItem(new ItemArgs
			{
				Title = "Aura Color",
				ValueText = ResolveColorName(identity),
				CloseMenuOnActivate = false,
				FadeName = false,
				Action = delegate
				{
					CycleColor(identity);
				}
			});
			openShapeItem = val2.AddItem(new ItemArgs
			{
				Title = "Aura Shape",
				ValueText = GetCurrentShape(identity),
				CloseMenuOnActivate = false,
				FadeName = false,
				Action = delegate
				{
					CycleShape(identity);
				}
			});
			openOpacityItem = val2.AddItem(new ItemArgs
			{
				Title = "Aura Opacity",
				ValueText = FormatOpacity(GetCurrentOpacityPercent(identity)),
				CloseMenuOnActivate = false,
				FadeName = false,
				Action = delegate
				{
					StepOpacity(identity);
				}
			});
			openGridLinesItem = val2.AddItem(new ItemArgs
			{
				Title = "Show Gridlines",
				ValueText = (GetShowGridLines(identity) ? "On" : "Off"),
				CloseMenuOnActivate = false,
				FadeName = false,
				Action = delegate
				{
					CycleGridLines(identity);
				}
			});
			val2.AddItem(new ItemArgs
			{
				Title = "Type Exact Radius...",
				ValueText = FormatRadius(GetCurrentRadiusFeet(identity)),
				CloseMenuOnActivate = true,
				FadeName = false,
				Action = delegate
				{
					OpenCustomInput(CustomInputField.Radius, identity);
				}
			});
			val2.AddItem(new ItemArgs
			{
				Title = "Type Exact Opacity...",
				ValueText = FormatOpacity(GetCurrentOpacityPercent(identity)),
				CloseMenuOnActivate = true,
				FadeName = false,
				Action = delegate
				{
					OpenCustomInput(CustomInputField.Opacity, identity);
				}
			});
		}
	}

	private bool GetAuraEnabled(string identity)
	{
		string text = AssetDataPlugin.ReadInfo(identity, "AuraPlugin.Enabled");
		if (!string.IsNullOrEmpty(text))
		{
			return text == "On";
		}
		string text2 = AssetDataPlugin.ReadInfo(identity, "AuraPlugin.Radius");
		float result;
		return !string.IsNullOrEmpty(text2) && float.TryParse(text2, NumberStyles.Float, CultureInfo.InvariantCulture, out result) && result > 0f;
	}

	private void CycleAuraEnabled(string identity)
	{
		bool flag = !GetAuraEnabled(identity);
		if (flag)
		{
			if (string.IsNullOrEmpty(AssetDataPlugin.ReadInfo(identity, "AuraPlugin.Radius")))
			{
				AssetDataPlugin.SetInfo(identity, "AuraPlugin.Radius", GetCurrentRadiusFeet(identity).ToString(CultureInfo.InvariantCulture), false);
			}
			if (string.IsNullOrEmpty(AssetDataPlugin.ReadInfo(identity, "AuraPlugin.Color")))
			{
				AssetDataPlugin.SetInfo(identity, "AuraPlugin.Color", ResolveColorName(identity), false);
			}
		}
		AssetDataPlugin.SetInfo(identity, "AuraPlugin.Enabled", flag ? "On" : "Off", false);
		if ((Object)(object)openEnabledItem != (Object)null && identity == openSubmenuIdentity)
		{
			RefreshDisplayedValue(openEnabledItem, flag ? "On" : "Off");
		}
	}

	private float GetCurrentRadiusFeet(string identity)
	{
		string text = AssetDataPlugin.ReadInfo(identity, "AuraPlugin.Radius");
		if (!string.IsNullOrEmpty(text) && float.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && result > 0f)
		{
			return result;
		}
		return Mathf.Max(0.1f, radiusStepFeetConfig.Value);
	}

	private static string FormatRadius(float feet)
	{
		return feet.ToString("0.#", CultureInfo.InvariantCulture) + " ft";
	}

	private void StepRadius(string identity)
	{
		float currentRadiusFeet = GetCurrentRadiusFeet(identity);
		float num = Mathf.Max(0.1f, radiusStepFeetConfig.Value);
		float num2 = Mathf.Max(num, radiusMaxFeetConfig.Value);
		float num3 = currentRadiusFeet + num;
		if (num3 > num2 + 0.001f)
		{
			num3 = num;
		}
		AssetDataPlugin.SetInfo(identity, "AuraPlugin.Radius", num3.ToString(CultureInfo.InvariantCulture), false);
		if ((Object)(object)openRadiusItem != (Object)null && identity == openSubmenuIdentity)
		{
			RefreshDisplayedValue(openRadiusItem, FormatRadius(num3));
		}
	}

	private void CycleColor(string identity)
	{
		string current = ResolveColorName(identity);
		int num = colorSteps.FindIndex(((string Name, Color Value) c) => c.Name == current);
		num = (num + 1) % colorSteps.Count;
		AssetDataPlugin.SetInfo(identity, "AuraPlugin.Color", colorSteps[num].Name, false);
		if ((Object)(object)openColorItem != (Object)null && identity == openSubmenuIdentity)
		{
			RefreshDisplayedValue(openColorItem, colorSteps[num].Name);
		}
	}

	private string GetCurrentShape(string identity)
	{
		string text = AssetDataPlugin.ReadInfo(identity, "AuraPlugin.Shape");
		return (text == "Bubble") ? "Bubble" : "Flat";
	}

	private void CycleShape(string identity)
	{
		string text = ((GetCurrentShape(identity) == "Flat") ? "Bubble" : "Flat");
		AssetDataPlugin.SetInfo(identity, "AuraPlugin.Shape", text, false);
		if ((Object)(object)openShapeItem != (Object)null && identity == openSubmenuIdentity)
		{
			RefreshDisplayedValue(openShapeItem, text);
		}
	}

	private float GetCurrentOpacityPercent(string identity)
	{
		string text = AssetDataPlugin.ReadInfo(identity, "AuraPlugin.Opacity");
		if (!string.IsNullOrEmpty(text) && float.TryParse(text, NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
		{
			return Mathf.Clamp(result, 0f, 100f);
		}
		return 100f;
	}

	private static string FormatOpacity(float percent)
	{
		return percent.ToString("0", CultureInfo.InvariantCulture) + "%";
	}

	private float ResolveOpacityAlpha(string identity)
	{
		float currentOpacityPercent = GetCurrentOpacityPercent(identity);
		float num = Mathf.Clamp01(opacityRealMaxPercentConfig.Value / 100f);
		return currentOpacityPercent / 100f * num;
	}

	private void StepOpacity(string identity)
	{
		float currentOpacityPercent = GetCurrentOpacityPercent(identity);
		float num = Mathf.Clamp(opacityStepPercentConfig.Value, 0.5f, 100f);
		float num2 = currentOpacityPercent + num;
		if (num2 > 100.001f)
		{
			num2 = 0f;
		}
		AssetDataPlugin.SetInfo(identity, "AuraPlugin.Opacity", num2.ToString(CultureInfo.InvariantCulture), false);
		if ((Object)(object)openOpacityItem != (Object)null && identity == openSubmenuIdentity)
		{
			RefreshDisplayedValue(openOpacityItem, FormatOpacity(num2));
		}
	}

	private bool GetShowGridLines(string identity)
	{
		string text = AssetDataPlugin.ReadInfo(identity, "AuraPlugin.GridLines");
		return text != "Off";
	}

	private void CycleGridLines(string identity)
	{
		bool flag = !GetShowGridLines(identity);
		AssetDataPlugin.SetInfo(identity, "AuraPlugin.GridLines", flag ? "On" : "Off", false);
		if ((Object)(object)openGridLinesItem != (Object)null && identity == openSubmenuIdentity)
		{
			RefreshDisplayedValue(openGridLinesItem, flag ? "On" : "Off");
		}
	}

	private static void RefreshDisplayedValue(MapMenuItem item, string valueText)
	{
		if (!((Object)(object)item == (Object)null))
		{
			ValueTextField?.SetValue(item, valueText);
			object obj = CircleTextField?.GetValue(item);
			obj?.GetType().GetProperty("text")?.SetValue(obj, valueText);
		}
	}

	private void OpenCustomInput(CustomInputField field, string identity)
	{
		customInputField = field;
		customInputTargetIdentity = identity;
		customInputText = ((field == CustomInputField.Radius) ? GetCurrentRadiusFeet(identity).ToString("0.#", CultureInfo.InvariantCulture) : GetCurrentOpacityPercent(identity).ToString("0", CultureInfo.InvariantCulture));
		showCustomInput = true;
		openEnabledItem = null;
		openRadiusItem = null;
		openColorItem = null;
		openShapeItem = null;
		openOpacityItem = null;
		openGridLinesItem = null;
		openSubmenuIdentity = null;
	}

	private void OnGUI()
	{
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: 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_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Invalid comparison between Unknown and I4
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0146: Invalid comparison between Unknown and I4
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_0166: Invalid comparison between Unknown and I4
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Invalid comparison between Unknown and I4
		//IL_016a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0171: Invalid comparison between Unknown and I4
		if (!showCustomInput)
		{
			return;
		}
		bool flag = customInputField == CustomInputField.Radius;
		string text = (flag ? "Aura Radius (feet)" : "Aura Opacity (%)");
		Rect val = default(Rect);
		((Rect)(ref val))..ctor(((float)Screen.width - 220f) / 2f, ((float)Screen.height - 100f) / 2f, 220f, 100f);
		GUI.Box(val, text);
		GUI.SetNextControlName("AuraPlugin.CustomInputField");
		customInputText = GUI.TextField(new Rect(((Rect)(ref val)).x + 10f, ((Rect)(ref val)).y + 30f, 200f, 24f), customInputText, 8);
		GUI.FocusControl("AuraPlugin.CustomInputField");
		bool flag2 = GUI.Button(new Rect(((Rect)(ref val)).x + 10f, ((Rect)(ref val)).y + 64f, 95f, 24f), "Set");
		bool flag3 = GUI.Button(new Rect(((Rect)(ref val)).x + 20f + 95f, ((Rect)(ref val)).y + 64f, 95f, 24f), "Cancel");
		Event current = Event.current;
		bool flag4 = (int)current.type == 4 && ((int)current.keyCode == 13 || (int)current.keyCode == 271);
		bool flag5 = (int)current.type == 4 && (int)current.keyCode == 27;
		if (flag2 || flag4)
		{
			float num = (flag ? float.MaxValue : 100f);
			float num2 = (flag ? 0.1f : 0f);
			if (float.TryParse(customInputText, NumberStyles.Float, CultureInfo.InvariantCulture, out var result) && !float.IsNaN(result) && !float.IsInfinity(result) && result >= num2 && result <= num)
			{
				if (flag)
				{
					AssetDataPlugin.SetInfo(customInputTargetIdentity, "AuraPlugin.Radius", result.ToString(CultureInfo.InvariantCulture), false);
					if ((Object)(object)openRadiusItem != (Object)null && customInputTargetIdentity == openSubmenuIdentity)
					{
						RefreshDisplayedValue(openRadiusItem, FormatRadius(result));
					}
				}
				else
				{
					AssetDataPlugin.SetInfo(customInputTargetIdentity, "AuraPlugin.Opacity", result.ToString(CultureInfo.InvariantCulture), false);
					if ((Object)(object)openOpacityItem != (Object)null && customInputTargetIdentity == openSubmenuIdentity)
					{
						RefreshDisplayedValue(openOpacityItem, FormatOpacity(result));
					}
				}
				showCustomInput = false;
			}
			if (flag4)
			{
				current.Use();
			}
		}
		else if (flag3 || flag5)
		{
			showCustomInput = false;
			if (flag5)
			{
				current.Use();
			}
		}
	}

	private string ResolveColorName(string identity)
	{
		string name = AssetDataPlugin.ReadInfo(identity, "AuraPlugin.Color");
		if (!string.IsNullOrEmpty(name) && colorSteps.Exists(((string Name, Color Value) c) => c.Name == name))
		{
			return name;
		}
		return colorSteps[0].Name;
	}

	private void OnAuraDataChanged(DatumChange change)
	{
		RebuildRing(change.source);
	}

	private void RebuildRing(string identity)
	{
		//IL_0087: 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_00d5: 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_0116: Unknown result type (might be due to invalid IL or missing references)
		if (activeRings.TryGetValue(identity, out var value) && (Object)(object)value != (Object)null)
		{
			Object.Destroy((Object)(object)value);
		}
		activeRings.Remove(identity);
		if (GetAuraEnabled(identity))
		{
			float currentRadiusFeet = GetCurrentRadiusFeet(identity);
			CreatureGuid val = default(CreatureGuid);
			if (!CreatureGuid.TryParse(identity, ref val))
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("AuraPlugin: could not parse identity '" + identity + "' as a CreatureGuid - aura will not be drawn."));
				return;
			}
			CreatureBoardAsset val2 = default(CreatureBoardAsset);
			if (!CreaturePresenter.TryGetAsset(val, ref val2) || (Object)(object)val2 == (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("AuraPlugin: no CreatureBoardAsset found for '" + identity + "' - aura will not be drawn (mini may not be loaded on this client yet)."));
				return;
			}
			string name = AssetDataPlugin.ReadInfo(identity, "AuraPlugin.Color");
			Color color = ResolveColor(name);
			color.a = ResolveOpacityAlpha(identity);
			float radiusUnits = currentRadiusFeet / Mathf.Max(0.01f, feetPerTileConfig.Value);
			GameObject value2 = ((GetCurrentShape(identity) == "Bubble") ? CreateBubble(identity, val2, radiusUnits, color) : CreateFlatRing(identity, val2, radiusUnits, color));
			activeRings[identity] = value2;
		}
	}

	private GameObject CreateFlatRing(string identity, CreatureBoardAsset asset, float radiusUnits, Color color)
	{
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Expected O, but got Unknown
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Expected O, but got Unknown
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		GameObject ringObject = new GameObject("AuraPlugin_Ring_" + identity);
		LineRenderer val = ringObject.AddComponent<LineRenderer>();
		val.useWorldSpace = true;
		val.loop = true;
		val.positionCount = 64;
		float startWidth = (val.endWidth = ringWidthConfig.Value);
		val.startWidth = startWidth;
		((Renderer)val).material = new Material(Shader.Find("Sprites/Default"));
		Color startColor = (val.endColor = color);
		val.startColor = startColor;
		AuraRingFollower auraRingFollower = ringObject.AddComponent<AuraRingFollower>();
		auraRingFollower.Target = asset;
		auraRingFollower.RadiusUnits = radiusUnits;
		auraRingFollower.HeightOffset = ringHeightConfig.Value;
		auraRingFollower.OnTargetLost = delegate
		{
			if (activeRings.TryGetValue(identity, out var value2) && (Object)(object)value2 == (Object)(object)ringObject)
			{
				activeRings.Remove(identity);
			}
		};
		return ringObject;
	}

	private GameObject CreateBubble(string identity, CreatureBoardAsset asset, float radiusUnits, Color color)
	{
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Expected O, but got Unknown
		//IL_005e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0079: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: 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_0088: Expected O, but got Unknown
		//IL_0092: Unknown result type (might be due to invalid IL or missing references)
		//IL_0098: Expected O, but got Unknown
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0108: Expected O, but got Unknown
		//IL_0130: Unknown result type (might be due to invalid IL or missing references)
		//IL_0132: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)unitSphereMesh == (Object)null)
		{
			unitSphereMesh = BuildIcosphereMesh(3, "AuraPlugin_UnitSphere");
		}
		GameObject root = new GameObject("AuraPlugin_Bubble_" + identity);
		root.transform.localScale = Vector3.one * radiusUnits;
		Material surfaceMaterial = new Material(Shader.Find("Sprites/Default"))
		{
			color = color
		};
		Material lineMaterial = new Material(Shader.Find("Sprites/Default"));
		bool showGridLines = GetShowGridLines(identity);
		int latRings = (showGridLines ? Mathf.Clamp(bubbleGridRingCountConfig.Value, 0, 12) : 0);
		int meridians = (showGridLines ? Mathf.Clamp(bubbleGridMeridianCountConfig.Value, 0, 24) : 0);
		Color gridColor = default(Color);
		((Color)(ref gridColor))..ctor(1f, 1f, 1f, bubbleGridAlphaConfig.Value);
		GameObject val = new GameObject("SphereVisual");
		val.transform.SetParent(root.transform, false);
		BuildBubbleVisual(val.transform, unitSphereMesh, surfaceMaterial, lineMaterial, color, gridColor, latRings, meridians);
		AuraBubbleFollower auraBubbleFollower = root.AddComponent<AuraBubbleFollower>();
		auraBubbleFollower.Target = asset;
		auraBubbleFollower.HeightOffset = ringHeightConfig.Value;
		auraBubbleFollower.SurfaceMaterial = surfaceMaterial;
		auraBubbleFollower.LineMaterial = lineMaterial;
		auraBubbleFollower.OnTargetLost = delegate
		{
			if (activeRings.TryGetValue(identity, out var value) && (Object)(object)value == (Object)(object)root)
			{
				activeRings.Remove(identity);
			}
		};
		return root;
	}

	private void BuildBubbleVisual(Transform parent, Mesh mesh, Material surfaceMaterial, Material lineMaterial, Color equatorColor, Color gridColor, int latRings, int meridians)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_0049: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: 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)
		GameObject val = new GameObject("Surface");
		val.transform.SetParent(parent, false);
		val.AddComponent<MeshFilter>().mesh = mesh;
		((Renderer)val.AddComponent<MeshRenderer>()).material = surfaceMaterial;
		AddBubbleLine(parent, lineMaterial, BuildUnitCircle(64, 0f, 1f), equatorColor, loop: true);
		for (int i = 1; i <= latRings; i++)
		{
			float num = (float)Math.PI / 2f * (float)i / (float)(latRings + 1);
			AddBubbleLine(parent, lineMaterial, BuildUnitCircle(64, Mathf.Sin(num), Mathf.Cos(num)), gridColor, loop: true);
			AddBubbleLine(parent, lineMaterial, BuildUnitCircle(64, 0f - Mathf.Sin(num), Mathf.Cos(num)), gridColor, loop: true);
		}
		for (int j = 0; j < meridians; j++)
		{
			float phi = (float)Math.PI * (float)j / (float)Mathf.Max(1, meridians);
			Vector3[] points = BuildUnitMeridianArc(64, phi, 0f, (float)Math.PI * 2f, includeEndpoint: false);
			AddBubbleLine(parent, lineMaterial, points, gridColor, loop: true);
		}
	}

	private void AddBubbleLine(Transform parent, Material material, Vector3[] points, Color color, bool loop)
	{
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		//IL_000c: Expected O, but got Unknown
		//IL_006a: 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_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("Line");
		val.transform.SetParent(parent, false);
		LineRenderer val2 = val.AddComponent<LineRenderer>();
		val2.useWorldSpace = false;
		val2.loop = loop;
		val2.positionCount = points.Length;
		val2.SetPositions(points);
		float startWidth = (val2.endWidth = bubbleGridLineWidthConfig.Value);
		val2.startWidth = startWidth;
		((Renderer)val2).material = material;
		Color startColor = (val2.endColor = color);
		val2.startColor = startColor;
	}

	private static Vector3[] BuildUnitCircle(int segments, float y, float radius)
	{
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		Vector3[] array = (Vector3[])(object)new Vector3[segments];
		for (int i = 0; i < segments; i++)
		{
			float num = (float)i * (float)Math.PI * 2f / (float)segments;
			array[i] = new Vector3(Mathf.Cos(num) * radius, y, Mathf.Sin(num) * radius);
		}
		return array;
	}

	private static Vector3[] BuildUnitMeridianArc(int segments, float phi, float tStart, float tEnd, bool includeEndpoint)
	{
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		int num = (includeEndpoint ? (segments + 1) : segments);
		Vector3[] array = (Vector3[])(object)new Vector3[num];
		for (int i = 0; i < num; i++)
		{
			float num2 = Mathf.Lerp(tStart, tEnd, (float)i / (float)segments);
			float num3 = Mathf.Sin(num2);
			float num4 = Mathf.Cos(num2);
			array[i] = new Vector3(num4 * Mathf.Cos(phi), num3, num4 * Mathf.Sin(phi));
		}
		return array;
	}

	private static Mesh BuildIcosphereMesh(int subdivisions, string name)
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: Unknown result type (might be due to invalid IL or missing references)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: 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)
		//IL_00b8: 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_00e7: 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_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_04bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_050c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0532: Unknown result type (might be due to invalid IL or missing references)
		//IL_0537: Unknown result type (might be due to invalid IL or missing references)
		//IL_0541: Expected O, but got Unknown
		float num = (1f + Mathf.Sqrt(5f)) / 2f;
		List<Vector3> vertices = new List<Vector3>
		{
			new Vector3(-1f, num, 0f),
			new Vector3(1f, num, 0f),
			new Vector3(-1f, 0f - num, 0f),
			new Vector3(1f, 0f - num, 0f),
			new Vector3(0f, -1f, num),
			new Vector3(0f, 1f, num),
			new Vector3(0f, -1f, 0f - num),
			new Vector3(0f, 1f, 0f - num),
			new Vector3(num, 0f, -1f),
			new Vector3(num, 0f, 1f),
			new Vector3(0f - num, 0f, -1f),
			new Vector3(0f - num, 0f, 1f)
		};
		for (int i = 0; i < vertices.Count; i++)
		{
			List<Vector3> list = vertices;
			int index = i;
			Vector3 val = vertices[i];
			list[index] = ((Vector3)(ref val)).normalized;
		}
		List<int> list2 = new List<int>
		{
			0, 11, 5, 0, 5, 1, 0, 1, 7, 0,
			7, 10, 0, 10, 11, 1, 5, 9, 5, 11,
			4, 11, 10, 2, 10, 7, 6, 7, 1, 8,
			3, 9, 4, 3, 4, 2, 3, 2, 6, 3,
			6, 8, 3, 8, 9, 4, 9, 5, 2, 4,
			11, 6, 2, 10, 8, 6, 7, 9, 8, 1
		};
		Dictionary<long, int> midpointCache = new Dictionary<long, int>();
		for (int j = 0; j < subdivisions; j++)
		{
			List<int> list3 = new List<int>(list2.Count * 4);
			for (int k = 0; k < list2.Count; k += 3)
			{
				int num2 = list2[k];
				int num3 = list2[k + 1];
				int num4 = list2[k + 2];
				int item = GetMidpointIndex(num2, num3);
				int item2 = GetMidpointIndex(num3, num4);
				int item3 = GetMidpointIndex(num4, num2);
				list3.Add(num2);
				list3.Add(item);
				list3.Add(item3);
				list3.Add(num3);
				list3.Add(item2);
				list3.Add(item);
				list3.Add(num4);
				list3.Add(item3);
				list3.Add(item2);
				list3.Add(item);
				list3.Add(item2);
				list3.Add(item3);
			}
			list2 = list3;
		}
		List<Vector2> list4 = new List<Vector2>(vertices.Count);
		foreach (Vector3 item4 in vertices)
		{
			list4.Add(new Vector2(0.5f + Mathf.Atan2(item4.z, item4.x) / ((float)Math.PI * 2f), 0.5f - Mathf.Asin(Mathf.Clamp(item4.y, -1f, 1f)) / (float)Math.PI));
		}
		Mesh val2 = new Mesh
		{
			name = name
		};
		val2.SetVertices(vertices);
		val2.SetUVs(0, list4);
		val2.SetTriangles(list2, 0);
		val2.RecalculateNormals();
		val2.RecalculateBounds();
		return val2;
		int GetMidpointIndex(int a, int b)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			long key = ((a < b) ? (((long)a << 32) + b) : (((long)b << 32) + a));
			if (midpointCache.TryGetValue(key, out var value))
			{
				return value;
			}
			Vector3 val3 = (vertices[a] + vertices[b]) * 0.5f;
			Vector3 normalized = ((Vector3)(ref val3)).normalized;
			vertices.Add(normalized);
			int num5 = vertices.Count - 1;
			midpointCache[key] = num5;
			return num5;
		}
	}

	private Color ResolveColor(string name)
	{
		//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_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		if (!string.IsNullOrEmpty(name))
		{
			foreach (var colorStep in colorSteps)
			{
				if (colorStep.Name == name)
				{
					return colorStep.Value;
				}
			}
		}
		return colorSteps[0].Value;
	}
}
public class AuraRingFollower : MonoBehaviour
{
	public CreatureBoardAsset Target;

	public float RadiusUnits;

	public float HeightOffset;

	public Action OnTargetLost;

	private LineRenderer lineRenderer;

	private Vector3[] unitCircle;

	private void Awake()
	{
		//IL_0061: 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)
		lineRenderer = ((Component)this).GetComponent<LineRenderer>();
		((Renderer)lineRenderer).enabled = false;
		int positionCount = lineRenderer.positionCount;
		unitCircle = (Vector3[])(object)new Vector3[positionCount];
		for (int i = 0; i < positionCount; i++)
		{
			float num = (float)i * (float)Math.PI * 2f / (float)positionCount;
			unitCircle[i] = new Vector3(Mathf.Cos(num), 0f, Mathf.Sin(num));
		}
	}

	private void Update()
	{
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: 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_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: 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_009e: 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_00ae: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Target == (Object)null)
		{
			OnTargetLost?.Invoke();
			Object.Destroy((Object)(object)((Component)this).gameObject);
			return;
		}
		LineRenderer obj = lineRenderer;
		ShaderStateRef shaderStateRef = Target.ShaderStateRef;
		((Renderer)obj).enabled = ((ShaderStateRef)(ref shaderStateRef)).IsValid && ((MovableBoardAsset)Target).IsVisible;
		Vector3 val = ((Component)Target).transform.position + Vector3.up * HeightOffset;
		for (int i = 0; i < unitCircle.Length; i++)
		{
			lineRenderer.SetPosition(i, val + unitCircle[i] * RadiusUnits);
		}
	}

	private void OnDestroy()
	{
		if ((Object)(object)lineRenderer != (Object)null && (Object)(object)((Renderer)lineRenderer).material != (Object)null)
		{
			Object.Destroy((Object)(object)((Renderer)lineRenderer).material);
		}
	}
}
public class AuraBubbleFollower : MonoBehaviour
{
	public CreatureBoardAsset Target;

	public float HeightOffset;

	public Material SurfaceMaterial;

	public Material LineMaterial;

	public Action OnTargetLost;

	private Renderer[] renderers;

	private bool? renderersVisible;

	private void Awake()
	{
		renderers = ((Component)this).GetComponentsInChildren<Renderer>(true);
		Renderer[] array = renderers;
		foreach (Renderer val in array)
		{
			if ((Object)(object)val != (Object)null)
			{
				val.enabled = false;
			}
		}
	}

	private void Update()
	{
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: 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_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Target == (Object)null)
		{
			OnTargetLost?.Invoke();
			Object.Destroy((Object)(object)((Component)this).gameObject);
			return;
		}
		((Component)this).transform.position = ((Component)Target).transform.position + Vector3.up * HeightOffset;
		ShaderStateRef shaderStateRef = Target.ShaderStateRef;
		bool flag = ((ShaderStateRef)(ref shaderStateRef)).IsValid && ((MovableBoardAsset)Target).IsVisible;
		if (renderersVisible == flag)
		{
			return;
		}
		Renderer[] array = renderers;
		foreach (Renderer val in array)
		{
			if ((Object)(object)val != (Object)null)
			{
				val.enabled = flag;
			}
		}
		renderersVisible = flag;
	}

	private void OnDestroy()
	{
		if ((Object)(object)SurfaceMaterial != (Object)null)
		{
			Object.Destroy((Object)(object)SurfaceMaterial);
		}
		if ((Object)(object)LineMaterial != (Object)null)
		{
			Object.Destroy((Object)(object)LineMaterial);
		}
	}
}