Decompiled source of Mists of Avalor BETA v0.1.11

plugins/MistsofAvalor.dll

Decompiled 16 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using System.Threading;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Jotunn;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("MistsofAvalor")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyDescription("Mists of Avalor: Procedural Labyrinth Dimension")]
[assembly: AssemblyFileVersion("0.1.11.0")]
[assembly: AssemblyInformationalVersion("0.1.11+272d11ecfb195f66ec9380a7f0dc86b9cf9145a2")]
[assembly: AssemblyProduct("MistsofAvalor")]
[assembly: AssemblyTitle("MistsofAvalor")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.1.11.0")]
[module: UnverifiableCode]
namespace MistsofAvalor;

public enum AvalorAtmoKind
{
	Mist,
	Torch
}
public class AvalorAtmoProp : MonoBehaviour
{
	public AvalorAtmoKind Kind;

	public const string AlwaysLitKey = "AvalorAlwaysLit";

	private ParticleSystem[] _systems;

	private ParticleSystemRenderer[] _psRenderers;

	private Light[] _lights;

	private float[] _baseRate;

	private MinMaxGradient[] _baseColor;

	private float[] _baseIntensity;

	private ZNetView _nview;

	private float _bias;

	private float _timer;

	private bool _ready;

	private float _lastBright = -1f;

	private float _pendingBright = -1f;

	private float _lastIntensity = -1f;

	public const float AlwaysLitFloor = 0.55f;

	private void Start()
	{
		//IL_0059: 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_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)
		//IL_0085: 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_00de: 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)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		_systems = ((Component)this).GetComponentsInChildren<ParticleSystem>(true);
		_psRenderers = ((Component)this).GetComponentsInChildren<ParticleSystemRenderer>(true);
		_lights = ((Component)this).GetComponentsInChildren<Light>(true);
		_nview = ((Component)this).GetComponent<ZNetView>();
		_baseRate = new float[_systems.Length];
		for (int i = 0; i < _systems.Length; i++)
		{
			float[] baseRate = _baseRate;
			int num = i;
			EmissionModule emission = _systems[i].emission;
			MinMaxCurve rateOverTime = ((EmissionModule)(ref emission)).rateOverTime;
			baseRate[num] = ((MinMaxCurve)(ref rateOverTime)).constant;
		}
		_bias = PositionBias(((Component)this).transform.position);
		if (Kind == AvalorAtmoKind.Torch)
		{
			TintGreen();
		}
		_baseColor = (MinMaxGradient[])(object)new MinMaxGradient[_systems.Length];
		for (int j = 0; j < _systems.Length; j++)
		{
			if ((Object)(object)_systems[j] != (Object)null)
			{
				MinMaxGradient[] baseColor = _baseColor;
				int num2 = j;
				MainModule main = _systems[j].main;
				baseColor[num2] = ((MainModule)(ref main)).startColor;
			}
		}
		_baseIntensity = new float[_lights.Length];
		for (int k = 0; k < _lights.Length; k++)
		{
			if ((Object)(object)_lights[k] != (Object)null)
			{
				_baseIntensity[k] = _lights[k].intensity;
			}
		}
		_ready = true;
		Apply(force: true);
	}

	private void Update()
	{
		if (_ready)
		{
			_timer += Time.deltaTime;
			if (!(_timer < 1f))
			{
				_timer = 0f;
				Apply(force: false);
			}
		}
	}

	private void Apply(bool force)
	{
		//IL_017d: 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_01b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0203: Unknown result type (might be due to invalid IL or missing references)
		//IL_0208: Unknown result type (might be due to invalid IL or missing references)
		//IL_0214: Unknown result type (might be due to invalid IL or missing references)
		//IL_021b: Unknown result type (might be due to invalid IL or missing references)
		bool flag = (Object)(object)_nview != (Object)null && _nview.IsValid() && _nview.GetZDO() != null && _nview.GetZDO().GetInt("AvalorAlwaysLit", 0) == 1;
		float num = 1f;
		float num2;
		if (Kind == AvalorAtmoKind.Mist)
		{
			num2 = MistFraction(MistsofAvalorPlugin.MistConfig.Value);
		}
		else
		{
			LightingLevel value = MistsofAvalorPlugin.LightingConfig.Value;
			num = (flag ? Mathf.Max(TorchIntensityFor(value), 0.55f) : TorchIntensityFor(value));
			num2 = ((flag || value != LightingLevel.None) ? 1f : 0f);
		}
		bool flag2 = num2 > 0f && _bias < num2;
		if (!flag2 && flag)
		{
			flag2 = true;
		}
		bool flag3 = Kind == AvalorAtmoKind.Torch && (force || !Mathf.Approximately(num, _lastIntensity));
		for (int i = 0; i < _lights.Length; i++)
		{
			if (!((Object)(object)_lights[i] == (Object)null))
			{
				if (((Behaviour)_lights[i]).enabled != flag2)
				{
					((Behaviour)_lights[i]).enabled = flag2;
				}
				if (flag3)
				{
					_lights[i].intensity = _baseIntensity[i] * num;
				}
			}
		}
		if (flag3)
		{
			_lastIntensity = num;
		}
		for (int j = 0; j < _systems.Length; j++)
		{
			ParticleSystem val = _systems[j];
			if ((Object)(object)val == (Object)null)
			{
				continue;
			}
			if (flag2)
			{
				EmissionModule emission = val.emission;
				float num3 = ((Kind == AvalorAtmoKind.Mist) ? Mathf.Lerp(0.15f, 1f, num2) : 1f);
				((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(_baseRate[j] * num3);
				if (!((EmissionModule)(ref emission)).enabled)
				{
					((EmissionModule)(ref emission)).enabled = true;
				}
				if (Kind == AvalorAtmoKind.Mist && _baseColor != null)
				{
					float num4 = AvalorCryptEnvZone.MistBrightnessFor(MistsofAvalorPlugin.LightingConfig.Value);
					if (force || !Mathf.Approximately(num4, _lastBright))
					{
						MainModule main = val.main;
						((MainModule)(ref main)).startColor = Dim(_baseColor[j], num4);
						_pendingBright = num4;
					}
				}
				if (!val.isPlaying)
				{
					val.Play(false);
				}
			}
			else if (val.isPlaying)
			{
				val.Stop(false, (ParticleSystemStopBehavior)0);
			}
		}
		for (int k = 0; k < _psRenderers.Length; k++)
		{
			if ((Object)(object)_psRenderers[k] != (Object)null)
			{
				((Renderer)_psRenderers[k]).enabled = flag2;
			}
		}
		if (_pendingBright >= 0f)
		{
			_lastBright = _pendingBright;
			_pendingBright = -1f;
		}
	}

	private static MinMaxGradient Dim(MinMaxGradient src, float f)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Invalid comparison between Unknown and I4
		//IL_002c: 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_0037: 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_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		if ((int)((MinMaxGradient)(ref src)).mode == 2)
		{
			return new MinMaxGradient(Scale(((MinMaxGradient)(ref src)).colorMin, f), Scale(((MinMaxGradient)(ref src)).colorMax, f));
		}
		return new MinMaxGradient(Scale(((MinMaxGradient)(ref src)).color, f));
	}

	private static Color Scale(Color c, float f)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0008: Unknown result type (might be due to invalid IL or missing references)
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		return new Color(c.r * f, c.g * f, c.b * f, c.a * f);
	}

	private void TintGreen()
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: 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_0065: 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_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: 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_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Invalid comparison between Unknown and I4
		//IL_0096: 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_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: 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)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: 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)
		Color avalorGreen = AvalorCryptEnvZone.AvalorGreen;
		Light[] lights = _lights;
		foreach (Light val in lights)
		{
			if (!((Object)(object)val == (Object)null))
			{
				val.color = avalorGreen;
			}
		}
		ParticleSystem[] systems = _systems;
		foreach (ParticleSystem val2 in systems)
		{
			if ((Object)(object)val2 == (Object)null)
			{
				continue;
			}
			MainModule main = val2.main;
			MinMaxGradient startColor = ((MainModule)(ref main)).startColor;
			ParticleSystemGradientMode mode = ((MinMaxGradient)(ref startColor)).mode;
			if ((int)mode != 0)
			{
				if ((int)mode == 2)
				{
					((MainModule)(ref main)).startColor = new MinMaxGradient(Recolor(((MinMaxGradient)(ref startColor)).colorMin, avalorGreen), Recolor(((MinMaxGradient)(ref startColor)).colorMax, avalorGreen));
				}
				else
				{
					((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Recolor(((MinMaxGradient)(ref startColor)).color, avalorGreen));
				}
			}
			else
			{
				((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Recolor(((MinMaxGradient)(ref startColor)).color, avalorGreen));
			}
		}
	}

	private static Color Recolor(Color src, Color green)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		float num = Mathf.Max(0.15f, ((Color)(ref src)).grayscale);
		Color result = green * num;
		result.a = src.a;
		return result;
	}

	private static float PositionBias(Vector3 p)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		int num = Mathf.RoundToInt(p.x * 4f);
		int num2 = Mathf.RoundToInt(p.y * 4f);
		int num3 = Mathf.RoundToInt(p.z * 4f);
		int num4 = (num * 73856093) ^ (num2 * 19349663) ^ (num3 * 83492791);
		int num5 = (num4 ^ (num4 >>> 13)) * -2048144789;
		return (float)((uint)(num5 ^ (num5 >>> 16)) % 100000u) / 100000f;
	}

	public static float MistFraction(MistDensity d)
	{
		return d switch
		{
			MistDensity.None => 0f, 
			MistDensity.Little => 0.05f, 
			MistDensity.Normal => 0.25f, 
			MistDensity.More => 0.55f, 
			MistDensity.Most => 1f, 
			_ => 0.25f, 
		};
	}

	public static float TorchIntensityFor(LightingLevel l)
	{
		return l switch
		{
			LightingLevel.None => 0f, 
			LightingLevel.Some => 0.38f, 
			LightingLevel.More => 0.68f, 
			LightingLevel.Most => 1f, 
			_ => 0.38f, 
		};
	}
}
public class AvalorCryptEnvZone : MonoBehaviour
{
	private const string CryptEnv = "Crypt";

	private float timer;

	private bool forcing;

	public static bool DebugBright = false;

	public static readonly Color AvalorGreen = new Color(0.3f, 1f, 0.55f);

	private static readonly Color FogGreen = new Color(0.1f, 0.26f, 0.19f);

	private const float GreenTint = 0.45f;

	private const float GreenBoost = 1.15f;

	private static readonly Color BaseAmbient = new Color(0.42f, 0.46f, 0.44f);

	private int _paintedFrame = -1;

	private bool _reportedFight;

	private bool _paintedWanted;

	private float _paintedDensity;

	private readonly List<GameObject> _suppressed = new List<GameObject>();

	private static readonly FieldInfo CurrentPSystemsField = AccessTools.Field(typeof(EnvMan), "m_currentPSystems");

	private void Update()
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		bool flag = (Object)(object)Player.m_localPlayer != (Object)null && AvalorRegion.InSkyMaze(((Component)Player.m_localPlayer).transform.position);
		bool flag2 = !forcing && flag;
		timer += Time.deltaTime;
		if (timer < 1f && !flag2)
		{
			return;
		}
		timer = 0f;
		if ((Object)(object)EnvMan.instance == (Object)null || (Object)(object)Player.m_localPlayer == (Object)null)
		{
			forcing = false;
		}
		else if (flag)
		{
			if (!forcing && MistsofAvalorPlugin.DebugLogging.Value)
			{
				Logger.LogInfo((object)"[Avalor] Entered sky maze - forcing 'Crypt' environment (overriding biome).");
			}
			EnvMan.instance.SetForceEnvironment("Crypt");
			forcing = true;
		}
		else if (forcing)
		{
			if (MistsofAvalorPlugin.DebugLogging.Value)
			{
				Logger.LogInfo((object)"[Avalor] Left sky maze - releasing forced environment.");
			}
			EnvMan.instance.SetForceEnvironment("");
			forcing = false;
		}
	}

	private void OnEnable()
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Expected O, but got Unknown
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		Camera.onPreRender = (CameraCallback)Delegate.Combine((Delegate?)(object)Camera.onPreRender, (Delegate?)new CameraCallback(OnAnyCameraPreRender));
	}

	private void OnDisable()
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Expected O, but got Unknown
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		Camera.onPreRender = (CameraCallback)Delegate.Remove((Delegate?)(object)Camera.onPreRender, (Delegate?)new CameraCallback(OnAnyCameraPreRender));
	}

	private void OnAnyCameraPreRender(Camera cam)
	{
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		if (Time.frameCount != _paintedFrame)
		{
			_paintedFrame = Time.frameCount;
			if (!_reportedFight && _paintedWanted && (Object)(object)Player.m_localPlayer != (Object)null && AvalorRegion.InSkyMaze(((Component)Player.m_localPlayer).transform.position) && (!RenderSettings.fog || RenderSettings.fogDensity < _paintedDensity * 0.5f))
			{
				_reportedFight = true;
				Logger.LogWarning((object)"[Avalor][FAIL] something else is clearing the labyrinth's fog after our LateUpdate (a de-misting mod, most likely). Re-asserting it at render time, so the maze keeps its mist - but if the fog still looks wrong, that mod is the reason.");
			}
			Paint();
		}
	}

	private void LateUpdate()
	{
		Paint();
	}

	private void Paint()
	{
		//IL_0025: 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_0090: 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_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: 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_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Player.m_localPlayer == (Object)null)
		{
			RestoreEnvParticles();
			_paintedWanted = false;
			return;
		}
		if (!AvalorRegion.InSkyMaze(((Component)Player.m_localPlayer).transform.position))
		{
			RestoreEnvParticles();
			_paintedWanted = false;
			return;
		}
		if (DebugBright)
		{
			RenderSettings.ambientLight = new Color(0.9f, 0.9f, 0.9f);
			RenderSettings.fogDensity = 0f;
			_paintedWanted = false;
			return;
		}
		MistDensity value = MistsofAvalorPlugin.MistConfig.Value;
		bool flag = (RenderSettings.fog = value != MistDensity.None);
		if (flag)
		{
			RenderSettings.fogMode = (FogMode)3;
			RenderSettings.fogColor = FogGreen;
			RenderSettings.fogDensity = FogDensityFor(value);
		}
		_paintedWanted = flag;
		_paintedDensity = (flag ? FogDensityFor(value) : 0f);
		ApplyEnvParticles(flag);
		float num = AmbientScaleFor(MistsofAvalorPlugin.LightingConfig.Value);
		Color val = BaseAmbient * num;
		RenderSettings.ambientLight = Color.Lerp(val, AvalorGreen * ((Color)(ref val)).grayscale * 1.15f, 0.45f);
	}

	private void ApplyEnvParticles(bool wanted)
	{
		if (wanted)
		{
			RestoreEnvParticles();
		}
		else
		{
			if ((Object)(object)EnvMan.instance == (Object)null || CurrentPSystemsField == null || !(CurrentPSystemsField.GetValue(EnvMan.instance) is GameObject[] array))
			{
				return;
			}
			GameObject[] array2 = array;
			foreach (GameObject val in array2)
			{
				if (!((Object)(object)val == (Object)null) && val.activeSelf)
				{
					val.SetActive(false);
					if (!_suppressed.Contains(val))
					{
						_suppressed.Add(val);
					}
				}
			}
		}
	}

	private void RestoreEnvParticles()
	{
		if (_suppressed.Count == 0)
		{
			return;
		}
		foreach (GameObject item in _suppressed)
		{
			if ((Object)(object)item != (Object)null)
			{
				item.SetActive(true);
			}
		}
		_suppressed.Clear();
	}

	public static float FogDensityFor(MistDensity d)
	{
		return d switch
		{
			MistDensity.None => 0f, 
			MistDensity.Little => 0.0016f, 
			MistDensity.Normal => 0.0055f, 
			MistDensity.More => 0.016f, 
			MistDensity.Most => 0.042f, 
			_ => 0.0055f, 
		};
	}

	public static float MistBrightnessFor(LightingLevel l)
	{
		return Mathf.Lerp(0.18f, 1f, AmbientScaleFor(l));
	}

	public static float AmbientScaleFor(LightingLevel l)
	{
		return l switch
		{
			LightingLevel.None => 0.04f, 
			LightingLevel.Some => 0.38f, 
			LightingLevel.More => 0.7f, 
			LightingLevel.Most => 1f, 
			_ => 0.38f, 
		};
	}

	private void OnDestroy()
	{
		RestoreEnvParticles();
		if (!forcing)
		{
			return;
		}
		forcing = false;
		try
		{
			if ((Object)(object)EnvMan.instance != (Object)null)
			{
				EnvMan.instance.SetForceEnvironment("");
			}
		}
		catch
		{
		}
	}
}
public class AvalorExitCompass : MonoBehaviour
{
	public static ConfigEntry<float> CompassX;

	public static ConfigEntry<float> CompassY;

	public static ConfigEntry<float> CompassSize;

	public static ConfigEntry<float> CompassOpacity;

	public static ConfigEntry<float> CompassTilt;

	public static ConfigEntry<KeyboardShortcut> CompassAdjustKey;

	private GameObject _uiRoot;

	private RectTransform _rootRt;

	private CanvasGroup _group;

	private RectTransform _disc;

	private RectTransform _blip;

	private RectTransform _blipStem;

	private RectTransform _player;

	private RectTransform[] _ring;

	private RectTransform[] _spokes;

	private Text _label;

	private Text _hint;

	private Font _valheimFont;

	private const float RefreshInterval = 1f;

	private float _timer = 1f;

	private Vector3 _exit;

	private bool _haveExit;

	private const float RimRange = 120f;

	private const int RingSegments = 56;

	private bool _adjusting;

	private bool _dragging;

	private Vector2 _dragOffset;

	private bool _dirty;

	private float _builtSize = -1f;

	private float _builtSquash = -1f;

	private float Squash => Mathf.Max(0.12f, Mathf.Sin(CompassTilt.Value * ((float)Math.PI / 180f)));

	private void Awake()
	{
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Expected O, but got Unknown
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Expected O, but got Unknown
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Expected O, but got Unknown
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		ConfigFile config = ((BaseUnityPlugin)MistsofAvalorPlugin.Instance).Config;
		CompassX = config.Bind<float>("Compass", "PositionX", -640f, "Horizontal offset of the exit compass from the centre of the screen, in pixels. Set by dragging it; you should not need to edit this by hand.");
		CompassY = config.Bind<float>("Compass", "PositionY", -397f, "Vertical offset of the exit compass from the centre of the screen, in pixels. Set by dragging it; you should not need to edit this by hand.");
		CompassSize = config.Bind<float>("Compass", "Size", 190f, new ConfigDescription("Diameter of the exit compass disc in pixels.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(90f, 460f), Array.Empty<object>()));
		CompassOpacity = config.Bind<float>("Compass", "Opacity", 0.55f, new ConfigDescription("How solid the compass is. Low values keep it as a ghost over the labyrinth; 1 is fully opaque.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>()));
		CompassTilt = config.Bind<float>("Compass", "TiltDegrees", 60f, new ConfigDescription("The angle the disc is viewed from, in degrees above the horizontal. 90 is a flat top-down circle; lower lays the view down further and squashes it into a wider ellipse. 60 is the default raked view.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(15f, 90f), Array.Empty<object>()));
		CompassAdjustKey = config.Bind<KeyboardShortcut>("Compass", "AdjustKey", new KeyboardShortcut((KeyCode)308, Array.Empty<KeyCode>()), "Hold this to move and resize the compass. While held: drag it with the left mouse button, or nudge it with the arrow keys, and resize with the mouse wheel or +/-.");
	}

	private void LateUpdate()
	{
		//IL_0043: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
		if (MistsofAvalorPlugin.ExitCompass == null || !MistsofAvalorPlugin.ExitCompass.Value)
		{
			Hide();
			return;
		}
		Player localPlayer = Player.m_localPlayer;
		if ((Object)(object)localPlayer == (Object)null || (Object)(object)Hud.instance == (Object)null)
		{
			Hide();
			return;
		}
		if (!AvalorRegion.InSkyMaze(((Component)localPlayer).transform.position))
		{
			Hide();
			return;
		}
		_timer += Time.deltaTime;
		if (_timer >= 1f)
		{
			_timer = 0f;
			_haveExit = AvalorMobDirector.TryFindExit(out _exit);
			if (!_haveExit && AvalorNet.Role == AvalorNet.NetRole.Client)
			{
				AvalorNet.SendQuery(1);
				if (AvalorNet.TryGetFreshAnswer(1, 30f, out var found, out var pos) && found)
				{
					_haveExit = true;
					_exit = pos;
				}
			}
		}
		if (!_haveExit)
		{
			Hide();
			return;
		}
		if ((Object)(object)_uiRoot == (Object)null)
		{
			CreateUI();
		}
		if (!((Object)(object)_uiRoot == (Object)null))
		{
			if (!_uiRoot.activeSelf)
			{
				_uiRoot.SetActive(true);
			}
			HandleAdjust();
			ApplyLayout();
			DrawBearing(localPlayer);
		}
	}

	private void HandleAdjust()
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: 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_01fa: 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_021f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0224: Unknown result type (might be due to invalid IL or missing references)
		//IL_0232: Expected O, but got Unknown
		//IL_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_023c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_0246: Unknown result type (might be due to invalid IL or missing references)
		//IL_026d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0272: Unknown result type (might be due to invalid IL or missing references)
		//IL_0277: Unknown result type (might be due to invalid IL or missing references)
		//IL_0285: Expected O, but got Unknown
		//IL_0287: Unknown result type (might be due to invalid IL or missing references)
		//IL_028a: 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_029b: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
		KeyboardShortcut value = CompassAdjustKey.Value;
		bool flag = ((KeyboardShortcut)(ref value)).IsPressed();
		if (flag && !_adjusting)
		{
			_adjusting = true;
		}
		else if (!flag && _adjusting)
		{
			_adjusting = false;
			_dragging = false;
			if (_dirty)
			{
				_dirty = false;
				((BaseUnityPlugin)MistsofAvalorPlugin.Instance).Config.Save();
			}
		}
		if (_adjusting)
		{
			Cursor.lockState = (CursorLockMode)0;
			Cursor.visible = true;
			float num = ((Input.GetKey((KeyCode)304) || Input.GetKey((KeyCode)303)) ? 12f : 2f);
			if (Input.GetKey((KeyCode)276))
			{
				ConfigEntry<float> compassX = CompassX;
				compassX.Value -= num;
				_dirty = true;
			}
			if (Input.GetKey((KeyCode)275))
			{
				ConfigEntry<float> compassX2 = CompassX;
				compassX2.Value += num;
				_dirty = true;
			}
			if (Input.GetKey((KeyCode)274))
			{
				ConfigEntry<float> compassY = CompassY;
				compassY.Value -= num;
				_dirty = true;
			}
			if (Input.GetKey((KeyCode)273))
			{
				ConfigEntry<float> compassY2 = CompassY;
				compassY2.Value += num;
				_dirty = true;
			}
			float num2 = 0f;
			if (Input.GetKey((KeyCode)61) || Input.GetKey((KeyCode)270))
			{
				num2 += 1.5f;
			}
			if (Input.GetKey((KeyCode)45) || Input.GetKey((KeyCode)269))
			{
				num2 -= 1.5f;
			}
			num2 += Input.GetAxis("Mouse ScrollWheel") * 220f;
			if (Mathf.Abs(num2) > 0.001f)
			{
				CompassSize.Value = Mathf.Clamp(CompassSize.Value + num2, 90f, 460f);
				_dirty = true;
				RebuildRose();
			}
			Canvas componentInParent = _uiRoot.GetComponentInParent<Canvas>();
			Camera val = (((Object)(object)componentInParent != (Object)null && (int)componentInParent.renderMode != 0) ? componentInParent.worldCamera : null);
			if (Input.GetMouseButtonDown(0) && RectTransformUtility.RectangleContainsScreenPoint(_rootRt, Vector2.op_Implicit(Input.mousePosition), val))
			{
				_dragging = true;
				Vector2 val2 = default(Vector2);
				RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)((Transform)_rootRt).parent, Vector2.op_Implicit(Input.mousePosition), val, ref val2);
				_dragOffset = val2 - _rootRt.anchoredPosition;
			}
			if (Input.GetMouseButtonUp(0))
			{
				_dragging = false;
			}
			Vector2 val3 = default(Vector2);
			if (_dragging && RectTransformUtility.ScreenPointToLocalPointInRectangle((RectTransform)((Transform)_rootRt).parent, Vector2.op_Implicit(Input.mousePosition), val, ref val3))
			{
				Vector2 val4 = val3 - _dragOffset;
				CompassX.Value = val4.x;
				CompassY.Value = val4.y;
				_dirty = true;
			}
		}
	}

	private void ApplyLayout()
	{
		//IL_011b: 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_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_008f: 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)
		//IL_00a4: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		float value = CompassSize.Value;
		if (Mathf.Abs(_builtSize - value) > 0.5f || Mathf.Abs(_builtSquash - Squash) > 0.001f)
		{
			RebuildRose();
		}
		Vector2 val = default(Vector2);
		((Vector2)(ref val))..ctor(CompassX.Value, CompassY.Value);
		Transform parent = ((Transform)_rootRt).parent;
		RectTransform val2 = (RectTransform)(object)((parent is RectTransform) ? parent : null);
		if ((Object)(object)val2 != (Object)null)
		{
			Rect rect = val2.rect;
			if (((Rect)(ref rect)).width > 1f)
			{
				rect = val2.rect;
				if (((Rect)(ref rect)).height > 1f)
				{
					rect = val2.rect;
					float num = ((Rect)(ref rect)).width * 0.5f;
					rect = val2.rect;
					float num2 = ((Rect)(ref rect)).height * 0.5f;
					val.x = Mathf.Clamp(val.x, 0f - num + 30f, num - 30f);
					val.y = Mathf.Clamp(val.y, 0f - num2 + 30f, num2 - 30f);
				}
			}
		}
		_rootRt.anchoredPosition = val;
		_rootRt.sizeDelta = new Vector2(value, value * Squash + 46f);
		_group.alpha = (_adjusting ? Mathf.Max(0.9f, CompassOpacity.Value) : CompassOpacity.Value);
		((Behaviour)_hint).enabled = _adjusting;
	}

	private void DrawBearing(Player p)
	{
		//IL_0001: 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_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: 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_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Unknown result type (might be due to invalid IL or missing references)
		//IL_0071: 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_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_0097: 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_012b: 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_0164: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = _exit - ((Component)p).transform.position;
		Vector2 val2 = new Vector2(val.x, val.z);
		float magnitude = ((Vector2)(ref val2)).magnitude;
		Vector3 forward = (((Object)(object)Utils.GetMainCamera() != (Object)null) ? ((Component)Utils.GetMainCamera()).transform : ((Component)p).transform).forward;
		forward.y = 0f;
		if (((Vector3)(ref forward)).sqrMagnitude < 0.0001f)
		{
			forward = Vector3.forward;
		}
		Vector3 val3 = val;
		val3.y = 0f;
		if (((Vector3)(ref val3)).sqrMagnitude < 0.0001f)
		{
			val3 = forward;
		}
		float num = Vector3.SignedAngle(forward, val3, Vector3.up) * ((float)Math.PI / 180f);
		float num2 = CompassSize.Value * 0.5f;
		float num3 = num2 * Mathf.Clamp01(magnitude / 120f);
		num3 = Mathf.Max(num3, num2 * 0.06f);
		float num4 = Mathf.Sin(num) * num3;
		float num5 = Mathf.Cos(num) * num3 * Squash;
		float num6 = Mathf.Clamp(val.y * (num2 / 120f), (0f - num2) * 0.5f, num2 * 0.5f);
		_blip.anchoredPosition = new Vector2(num4, num5 + num6);
		_blipStem.anchoredPosition = new Vector2(num4, num5 + num6 * 0.5f);
		_blipStem.sizeDelta = new Vector2(2f, Mathf.Abs(num6));
		((Component)_blipStem).gameObject.SetActive(Mathf.Abs(num6) > 3f);
		string arg = "";
		if (val.y > 3f)
		{
			arg = "   above";
		}
		else if (val.y < -3f)
		{
			arg = "   below";
		}
		_label.text = $"The Way Out   {magnitude:F0}m{arg}";
	}

	private void Hide()
	{
		if ((Object)(object)_uiRoot != (Object)null && _uiRoot.activeSelf)
		{
			_uiRoot.SetActive(false);
		}
	}

	private void CreateUI()
	{
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Expected O, but got Unknown
		//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: 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_012a: Expected O, but got Unknown
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0232: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: Unknown result type (might be due to invalid IL or missing references)
		//IL_0278: 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_02b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0300: 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_0344: Unknown result type (might be due to invalid IL or missing references)
		//IL_0371: Unknown result type (might be due to invalid IL or missing references)
		//IL_039d: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)Hud.instance == (Object)null) && !((Object)(object)Hud.instance.m_rootObject == (Object)null))
		{
			Text componentInChildren = Hud.instance.m_rootObject.GetComponentInChildren<Text>(true);
			if ((Object)(object)componentInChildren != (Object)null)
			{
				_valheimFont = componentInChildren.font;
			}
			Font font = (((Object)(object)_valheimFont != (Object)null) ? _valheimFont : Resources.GetBuiltinResource<Font>("Arial.ttf"));
			_uiRoot = new GameObject("AvalorExitCompass");
			_uiRoot.transform.SetParent(Hud.instance.m_rootObject.transform, false);
			_rootRt = _uiRoot.AddComponent<RectTransform>();
			_rootRt.anchorMin = new Vector2(0.5f, 0.5f);
			_rootRt.anchorMax = new Vector2(0.5f, 0.5f);
			_rootRt.pivot = new Vector2(0.5f, 0.5f);
			_group = _uiRoot.AddComponent<CanvasGroup>();
			_group.interactable = false;
			_group.blocksRaycasts = false;
			GameObject val = new GameObject("Disc");
			val.transform.SetParent(_uiRoot.transform, false);
			_disc = val.AddComponent<RectTransform>();
			_disc.anchorMin = new Vector2(0.5f, 0.5f);
			_disc.anchorMax = new Vector2(0.5f, 0.5f);
			_disc.pivot = new Vector2(0.5f, 0.5f);
			_disc.anchoredPosition = new Vector2(0f, 14f);
			_ring = (RectTransform[])(object)new RectTransform[56];
			for (int i = 0; i < 56; i++)
			{
				_ring[i] = Quad("Ring" + i, (Transform)(object)_disc, Ink(0.55f));
			}
			_spokes = (RectTransform[])(object)new RectTransform[4];
			for (int j = 0; j < 4; j++)
			{
				_spokes[j] = Quad("Spoke" + j, (Transform)(object)_disc, Ink(0.38f));
			}
			_player = Quad("Player", (Transform)(object)_disc, Ink(0.95f));
			_player.sizeDelta = new Vector2(7f, 7f);
			((Transform)_player).localRotation = Quaternion.Euler(0f, 0f, 45f);
			_blipStem = Quad("BlipStem", (Transform)(object)_disc, Ink(0.45f));
			_blip = Quad("Blip", (Transform)(object)_disc, new Color(0.62f, 1f, 0.78f, 1f));
			_blip.sizeDelta = new Vector2(11f, 11f);
			((Transform)_blip).localRotation = Quaternion.Euler(0f, 0f, 45f);
			_label = Label("Label", _uiRoot.transform, new Vector2(0f, 0f), 15, font);
			_hint = Label("Hint", _uiRoot.transform, new Vector2(0f, 0f), 12, font);
			((Graphic)_hint).color = new Color(0.62f, 1f, 0.78f, 0.9f);
			_hint.text = "drag  •  arrows nudge  •  wheel / +- resize";
			((Behaviour)_hint).enabled = false;
			RebuildRose();
			_uiRoot.SetActive(false);
		}
	}

	private void RebuildRose()
	{
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: 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_00c1: 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_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: 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_026b: Unknown result type (might be due to invalid IL or missing references)
		//IL_027e: 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_01db: 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)
		if (_ring != null)
		{
			float value = CompassSize.Value;
			float num = value * 0.5f;
			float squash = Squash;
			_builtSize = value;
			_builtSquash = squash;
			for (int i = 0; i < 56; i++)
			{
				float num2 = (float)i / 56f * (float)Math.PI * 2f;
				float num3 = Mathf.Sin(num2) * num;
				float num4 = Mathf.Cos(num2) * num * squash;
				float num5 = Mathf.Cos(num2) * num;
				float num6 = (0f - Mathf.Sin(num2)) * num * squash;
				Vector2 val = new Vector2(num5, num6);
				float num7 = ((Vector2)(ref val)).magnitude * ((float)Math.PI / 28f);
				_ring[i].anchoredPosition = new Vector2(num3, num4);
				_ring[i].sizeDelta = new Vector2(Mathf.Max(num7, 2f), 2f);
				((Transform)_ring[i]).localRotation = Quaternion.Euler(0f, 0f, Mathf.Atan2(num6, num5) * 57.29578f);
			}
			for (int j = 0; j < 4; j++)
			{
				float num8 = (float)j * (float)Math.PI * 0.5f;
				float num9 = ((j == 0) ? 0.7f : 0.82f);
				float num10 = Mathf.Sin(num8) * num;
				float num11 = Mathf.Cos(num8) * num * squash;
				float num12 = num * (1f - num9);
				_spokes[j].anchoredPosition = new Vector2(num10 * (num9 + (1f - num9) * 0.5f), num11 * (num9 + (1f - num9) * 0.5f));
				_spokes[j].sizeDelta = new Vector2(2f, Mathf.Max(num12 * ((j == 0) ? (squash + 0.3f) : squash), 3f));
				((Transform)_spokes[j]).localRotation = Quaternion.Euler(0f, 0f, (0f - num8) * 57.29578f);
				((Graphic)((Component)_spokes[j]).GetComponent<Image>()).color = Ink((j == 0) ? 0.8f : 0.34f);
			}
			if ((Object)(object)_label != (Object)null)
			{
				((RectTransform)((Component)_label).transform).anchoredPosition = new Vector2(0f, (0f - num) * squash - 4f);
			}
			if ((Object)(object)_hint != (Object)null)
			{
				((RectTransform)((Component)_hint).transform).anchoredPosition = new Vector2(0f, num * squash + 30f);
			}
		}
	}

	private static Color Ink(float a)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0005: 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_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		Color avalorGreen = AvalorCryptEnvZone.AvalorGreen;
		return new Color(avalorGreen.r, avalorGreen.g, avalorGreen.b, a);
	}

	private static RectTransform Quad(string name, Transform parent, Color colour)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_0025: 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_004f: 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_0075: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name);
		val.transform.SetParent(parent, false);
		RectTransform obj = val.AddComponent<RectTransform>();
		obj.anchorMin = new Vector2(0.5f, 0.5f);
		obj.anchorMax = new Vector2(0.5f, 0.5f);
		obj.pivot = new Vector2(0.5f, 0.5f);
		obj.sizeDelta = new Vector2(2f, 2f);
		Image obj2 = val.AddComponent<Image>();
		((Graphic)obj2).color = colour;
		((Graphic)obj2).raycastTarget = false;
		return obj;
	}

	private static Text Label(string name, Transform parent, Vector2 pos, int fontSize, Font font)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_0025: 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_004f: 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_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name);
		val.transform.SetParent(parent, false);
		RectTransform obj = val.AddComponent<RectTransform>();
		obj.anchorMin = new Vector2(0.5f, 0.5f);
		obj.anchorMax = new Vector2(0.5f, 0.5f);
		obj.pivot = new Vector2(0.5f, 0.5f);
		obj.anchoredPosition = pos;
		obj.sizeDelta = new Vector2(360f, 22f);
		Text obj2 = val.AddComponent<Text>();
		obj2.font = font;
		obj2.fontSize = fontSize;
		obj2.alignment = (TextAnchor)4;
		((Graphic)obj2).color = new Color(0.86f, 0.94f, 0.88f, 0.92f);
		((Graphic)obj2).raycastTarget = false;
		Shadow obj3 = val.AddComponent<Shadow>();
		obj3.effectColor = new Color(0f, 0f, 0f, 0.85f);
		obj3.effectDistance = new Vector2(1f, -1f);
		return obj2;
	}
}
public class AvalorPortalEnvZone : MonoBehaviour
{
	private const float OuterRadius = 32f;

	private const float InnerRadius = 14f;

	private static readonly Color GloomFog = new Color(0.16f, 0.34f, 0.25f);

	private const float GloomFogDensity = 0.028f;

	private const float AmbientDarken = 0.75f;

	private const float GreenTint = 0.55f;

	private bool _haveBase;

	private Color _baseFog;

	private Color _baseAmbient;

	private float _baseDensity;

	private bool _baseFogEnabled;

	private void LateUpdate()
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_002c: 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_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: 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_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00a4: 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_011e: 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_012d: 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_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0144: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: 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_0152: 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_015f: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)Player.m_localPlayer == (Object)null)
		{
			return;
		}
		Vector3 position = ((Component)Player.m_localPlayer).transform.position;
		if (position.x > 25000f)
		{
			return;
		}
		float num = Vector3.Distance(position, ((Component)this).transform.position);
		float num2 = Mathf.Clamp01(Mathf.InverseLerp(32f, 14f, num));
		if (num2 <= 0f)
		{
			_baseFog = RenderSettings.fogColor;
			_baseAmbient = RenderSettings.ambientLight;
			_baseDensity = RenderSettings.fogDensity;
			_baseFogEnabled = RenderSettings.fog;
			_haveBase = true;
			return;
		}
		if (!_haveBase)
		{
			_baseFog = RenderSettings.fogColor;
			_baseAmbient = RenderSettings.ambientLight;
			_baseDensity = RenderSettings.fogDensity;
			_baseFogEnabled = RenderSettings.fog;
			_haveBase = true;
		}
		num2 = Mathf.SmoothStep(0f, 1f, num2);
		RenderSettings.fog = true;
		RenderSettings.fogColor = Color.Lerp(_baseFog, GloomFog, num2);
		RenderSettings.fogDensity = Mathf.Lerp(_baseFogEnabled ? _baseDensity : 0f, 0.028f, num2);
		Color val = _baseAmbient * 0.75f;
		Color val2 = AvalorCryptEnvZone.AvalorGreen * ((Color)(ref val)).grayscale * 1.5f;
		RenderSettings.ambientLight = Color.Lerp(_baseAmbient, Color.Lerp(val, val2, 0.55f), num2);
	}
}
public class AvalorPortalRuneVFX : MonoBehaviour
{
	public Color Colour = new Color(0.3f, 1f, 0.55f);

	public float GateWidth = 3.2f;

	public float GateHeight = 7f;

	[NonSerialized]
	public float Charge;

	private ParticleSystem _veil;

	private ParticleSystem _motes;

	private LineRenderer _ringA;

	private LineRenderer _ringB;

	private LineRenderer _sigil;

	private LineRenderer _sigilInner;

	private LineRenderer[] _spokes;

	private ParticleSystem _sigilRunes;

	private float _spin;

	private const int RingSegments = 64;

	private static Texture2D _atlasTex;

	private static Texture2D _softTex;

	private void Start()
	{
		//IL_000d: 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_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)_atlasTex == (Object)null)
		{
			_atlasTex = AvalorRuneTexture.GenerateRuneAtlas(Color.white);
		}
		if ((Object)(object)_softTex == (Object)null)
		{
			_softTex = AvalorRuneTexture.GenerateSoftTrail(Color.white);
		}
		Texture2D atlasTex = _atlasTex;
		Texture2D softTex = _softTex;
		Material orCreateRuneMaterial = AvalorRuneMaterial.GetOrCreateRuneMaterial(atlasTex, Colour);
		Material orCreateRuneMaterial2 = AvalorRuneMaterial.GetOrCreateRuneMaterial(softTex, Colour);
		if ((Object)(object)orCreateRuneMaterial == (Object)null || (Object)(object)orCreateRuneMaterial2 == (Object)null)
		{
			Logger.LogWarning((object)"[Avalor] rune VFX: no usable particle shader - portal keeps vanilla effects only.");
			((Behaviour)this).enabled = false;
			return;
		}
		BuildVeil(orCreateRuneMaterial);
		BuildRings(orCreateRuneMaterial2);
		BuildSigil(orCreateRuneMaterial2, orCreateRuneMaterial);
		BuildMotes(orCreateRuneMaterial);
	}

	private void BuildVeil(Material mat)
	{
		//IL_001c: 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_005b: 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)
		//IL_0087: 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)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0125: 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_013a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_016e: 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)
		GameObject val = Child("RuneVeil", new Vector3(0f, GateHeight * 0.42f, 0f));
		_veil = val.AddComponent<ParticleSystem>();
		MainModule main = _veil.main;
		((MainModule)(ref main)).loop = true;
		((MainModule)(ref main)).playOnAwake = true;
		((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.15f, 0.5f);
		((MainModule)(ref main)).startLifetime = new MinMaxCurve(1.6f, 3.2f);
		((MainModule)(ref main)).startSize = new MinMaxCurve(0.22f, 0.55f);
		((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Colour);
		((MainModule)(ref main)).maxParticles = 220;
		((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)0;
		((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, (float)Math.PI * 2f);
		EmissionModule emission = _veil.emission;
		((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(26f);
		ShapeModule shape = _veil.shape;
		((ShapeModule)(ref shape)).enabled = true;
		((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)5;
		((ShapeModule)(ref shape)).scale = new Vector3(GateWidth * 0.82f, GateHeight * 0.72f, 0.12f);
		VelocityOverLifetimeModule velocityOverLifetime = _veil.velocityOverLifetime;
		((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true;
		((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)0;
		((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = new MinMaxCurve(-0.06f, 0.06f);
		((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = new MinMaxCurve(0.25f, 0.75f);
		((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = new MinMaxCurve(-0.06f, 0.06f);
		FadeInOut(_veil);
		Atlas(_veil);
		ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>();
		component.renderMode = (ParticleSystemRenderMode)0;
		((Renderer)component).material = mat;
		((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
		((Renderer)component).receiveShadows = false;
	}

	private void BuildRings(Material glow)
	{
		//IL_002a: 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_00b6: 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_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_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_010f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0114: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		float num = GateWidth * 0.44f;
		_ringA = BuildCircle("RuneRingA", new Vector3(0f, GateHeight * 0.45f, 0f), num, glow, 0.055f, vertical: true);
		_ringB = BuildCircle("RuneRingB", new Vector3(0f, GateHeight * 0.45f, 0f), num * 0.68f, glow, 0.04f, vertical: true);
		_spokes = (LineRenderer[])(object)new LineRenderer[4];
		for (int i = 0; i < _spokes.Length; i++)
		{
			LineRenderer val = Child("RuneSpoke" + i, new Vector3(0f, GateHeight * 0.45f, 0f)).AddComponent<LineRenderer>();
			float num2 = (float)Math.PI / (float)_spokes.Length * (float)i;
			Vector3 val2 = new Vector3(Mathf.Cos(num2), Mathf.Sin(num2), 0f) * (num * 0.68f);
			Line(val, glow, 0.03f, (Vector3[])(object)new Vector3[2]
			{
				-val2,
				val2
			});
			_spokes[i] = val;
		}
	}

	private void BuildSigil(Material glow, Material runeMat)
	{
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0050: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_013d: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		float num = GateWidth * 0.85f;
		_sigil = BuildCircle("SigilOuter", new Vector3(0f, 0.06f, 0f), num, glow, 0.07f, vertical: false);
		_sigilInner = BuildCircle("SigilInner", new Vector3(0f, 0.06f, 0f), num * 0.62f, glow, 0.05f, vertical: false);
		GameObject val = Child("SigilRunes", new Vector3(0f, 0.35f, 0f));
		_sigilRunes = val.AddComponent<ParticleSystem>();
		MainModule main = _sigilRunes.main;
		((MainModule)(ref main)).loop = true;
		((MainModule)(ref main)).playOnAwake = true;
		((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0f);
		((MainModule)(ref main)).startLifetime = new MinMaxCurve(1.4f, 2.6f);
		((MainModule)(ref main)).startSize = new MinMaxCurve(0.3f, 0.5f);
		((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Colour);
		((MainModule)(ref main)).maxParticles = 90;
		((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)0;
		EmissionModule emission = _sigilRunes.emission;
		((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(14f);
		ShapeModule shape = _sigilRunes.shape;
		((ShapeModule)(ref shape)).enabled = true;
		((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)10;
		((ShapeModule)(ref shape)).radius = num * 0.9f;
		((ShapeModule)(ref shape)).radiusThickness = 0f;
		((ShapeModule)(ref shape)).rotation = new Vector3(90f, 0f, 0f);
		FadeInOut(_sigilRunes);
		Atlas(_sigilRunes);
		ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>();
		component.renderMode = (ParticleSystemRenderMode)0;
		((Renderer)component).material = runeMat;
		((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
		((Renderer)component).receiveShadows = false;
	}

	private void BuildMotes(Material mat)
	{
		//IL_0015: 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_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: 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_0080: 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_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: 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_00d1: 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_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = Child("RuneMotes", new Vector3(0f, 0.2f, 0f));
		_motes = val.AddComponent<ParticleSystem>();
		MainModule main = _motes.main;
		((MainModule)(ref main)).loop = true;
		((MainModule)(ref main)).playOnAwake = true;
		((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.3f, 0.9f);
		((MainModule)(ref main)).startLifetime = new MinMaxCurve(3f, 6f);
		((MainModule)(ref main)).startSize = new MinMaxCurve(0.1f, 0.26f);
		((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Colour);
		((MainModule)(ref main)).maxParticles = 120;
		((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
		((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-0.02f);
		EmissionModule emission = _motes.emission;
		((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(10f);
		ShapeModule shape = _motes.shape;
		((ShapeModule)(ref shape)).enabled = true;
		((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)10;
		((ShapeModule)(ref shape)).radius = GateWidth * 0.9f;
		((ShapeModule)(ref shape)).rotation = new Vector3(90f, 0f, 0f);
		FadeInOut(_motes);
		Atlas(_motes);
		ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>();
		component.renderMode = (ParticleSystemRenderMode)0;
		((Renderer)component).material = mat;
		((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
		((Renderer)component).receiveShadows = false;
	}

	private void Update()
	{
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: 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_0178: 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_00fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d0: 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_01e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0200: 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_0217: Unknown result type (might be due to invalid IL or missing references)
		//IL_0235: Unknown result type (might be due to invalid IL or missing references)
		//IL_023a: Unknown result type (might be due to invalid IL or missing references)
		//IL_024b: Unknown result type (might be due to invalid IL or missing references)
		Charge = Mathf.Max(0f, Charge - Time.deltaTime * 1.4f);
		float num = Mathf.Clamp01(Charge);
		_spin += Time.deltaTime * (18f + 150f * num);
		if ((Object)(object)_ringA != (Object)null)
		{
			((Component)_ringA).transform.localRotation = Quaternion.Euler(0f, 0f, _spin);
		}
		if ((Object)(object)_ringB != (Object)null)
		{
			((Component)_ringB).transform.localRotation = Quaternion.Euler(0f, 0f, (0f - _spin) * 1.6f);
		}
		if (_spokes != null)
		{
			LineRenderer[] spokes = _spokes;
			foreach (LineRenderer val in spokes)
			{
				if ((Object)(object)val != (Object)null)
				{
					((Component)val).transform.localRotation = Quaternion.Euler(0f, 0f, (0f - _spin) * 1.6f);
				}
			}
		}
		if ((Object)(object)_sigil != (Object)null)
		{
			((Component)_sigil).transform.localRotation = Quaternion.Euler(0f, (0f - _spin) * 0.5f, 0f);
		}
		if ((Object)(object)_sigilInner != (Object)null)
		{
			((Component)_sigilInner).transform.localRotation = Quaternion.Euler(0f, _spin * 0.8f, 0f);
		}
		if ((Object)(object)_sigilRunes != (Object)null)
		{
			((Component)_sigilRunes).transform.localRotation = Quaternion.Euler(0f, (0f - _spin) * 0.5f, 0f);
		}
		if ((Object)(object)_veil != (Object)null)
		{
			EmissionModule emission = _veil.emission;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(26f + 120f * num);
			MainModule main = _veil.main;
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(Colour * (1f + 1.6f * num));
		}
		if ((Object)(object)_sigilRunes != (Object)null)
		{
			EmissionModule emission2 = _sigilRunes.emission;
			((EmissionModule)(ref emission2)).rateOverTime = MinMaxCurve.op_Implicit(14f + 50f * num);
		}
		float num2 = 1f + 1.8f * num;
		Width(_ringA, 0.055f * num2);
		Width(_ringB, 0.04f * num2);
		Width(_sigil, 0.07f * num2);
		Width(_sigilInner, 0.05f * num2);
		if (_spokes != null)
		{
			LineRenderer[] spokes = _spokes;
			for (int i = 0; i < spokes.Length; i++)
			{
				Width(spokes[i], 0.03f * num2);
			}
		}
	}

	public void Discharge()
	{
		if ((Object)(object)_veil != (Object)null)
		{
			_veil.Emit(70);
		}
		if ((Object)(object)_motes != (Object)null)
		{
			_motes.Emit(45);
		}
		if ((Object)(object)_sigilRunes != (Object)null)
		{
			_sigilRunes.Emit(40);
		}
		Charge = 1f;
	}

	private GameObject Child(string name, Vector3 localPos)
	{
		//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_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Expected O, but got Unknown
		GameObject val = new GameObject(name)
		{
			layer = ((Component)this).gameObject.layer
		};
		val.transform.SetParent(((Component)this).transform, false);
		val.transform.localPosition = localPos;
		return val;
	}

	private LineRenderer BuildCircle(string name, Vector3 pos, float radius, Material mat, float width, bool vertical)
	{
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: 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_0056: Unknown result type (might be due to invalid IL or missing references)
		LineRenderer val = Child(name, pos).AddComponent<LineRenderer>();
		Vector3[] array = (Vector3[])(object)new Vector3[65];
		for (int i = 0; i <= 64; i++)
		{
			float num = (float)Math.PI / 32f * (float)i;
			float num2 = Mathf.Cos(num) * radius;
			float num3 = Mathf.Sin(num) * radius;
			array[i] = (vertical ? new Vector3(num2, num3, 0f) : new Vector3(num2, 0f, num3));
		}
		Line(val, mat, width, array);
		return val;
	}

	private void Line(LineRenderer lr, Material mat, float width, Vector3[] pts)
	{
		//IL_0039: 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)
		lr.useWorldSpace = false;
		lr.loop = false;
		((Renderer)lr).material = mat;
		lr.positionCount = pts.Length;
		lr.SetPositions(pts);
		float startWidth = (lr.endWidth = width);
		lr.startWidth = startWidth;
		lr.startColor = Colour;
		lr.endColor = Colour;
		((Renderer)lr).shadowCastingMode = (ShadowCastingMode)0;
		((Renderer)lr).receiveShadows = false;
		lr.alignment = (LineAlignment)0;
	}

	private static void Width(LineRenderer lr, float w)
	{
		if (!((Object)(object)lr == (Object)null))
		{
			float startWidth = (lr.endWidth = w);
			lr.startWidth = startWidth;
		}
	}

	private static void FadeInOut(ParticleSystem ps)
	{
		//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_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Expected O, but got Unknown
		//IL_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: 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_003e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: 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_005f: 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)
		//IL_0075: 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_008b: 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_00a1: 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)
		ColorOverLifetimeModule colorOverLifetime = ps.colorOverLifetime;
		((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
		Gradient val = new Gradient();
		val.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
		{
			new GradientColorKey(Color.white, 0f),
			new GradientColorKey(Color.white, 1f)
		}, (GradientAlphaKey[])(object)new GradientAlphaKey[4]
		{
			new GradientAlphaKey(0f, 0f),
			new GradientAlphaKey(1f, 0.25f),
			new GradientAlphaKey(1f, 0.65f),
			new GradientAlphaKey(0f, 1f)
		});
		((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(val);
	}

	private static void Atlas(ParticleSystem ps)
	{
		//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_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		TextureSheetAnimationModule textureSheetAnimation = ps.textureSheetAnimation;
		((TextureSheetAnimationModule)(ref textureSheetAnimation)).enabled = true;
		((TextureSheetAnimationModule)(ref textureSheetAnimation)).numTilesX = 4;
		((TextureSheetAnimationModule)(ref textureSheetAnimation)).numTilesY = 4;
		((TextureSheetAnimationModule)(ref textureSheetAnimation)).animation = (ParticleSystemAnimationType)0;
		((TextureSheetAnimationModule)(ref textureSheetAnimation)).timeMode = (ParticleSystemAnimationTimeMode)0;
		((TextureSheetAnimationModule)(ref textureSheetAnimation)).startFrame = new MinMaxCurve(0f, 16f);
		((TextureSheetAnimationModule)(ref textureSheetAnimation)).frameOverTime = new MinMaxCurve(0f);
	}
}
public static class AvalorRuneMaterial
{
	private static readonly Dictionary<long, Material> _materialCache = new Dictionary<long, Material>();

	private static bool _initialized = false;

	private static void Init()
	{
		if (!_initialized)
		{
			_initialized = true;
			Logger.LogInfo((object)"[Avalor] rune VFX: Seeking glowing, additive, unlit shaders worthy of Avalor.");
		}
	}

	private unsafe static long MakeCacheKey(Shader shader, Texture2D tex, Color color)
	{
		int num = (((Object)(object)shader != (Object)null) ? ((Object)shader).GetInstanceID() : 0);
		int num2 = (((Object)(object)tex != (Object)null) ? ((Object)tex).GetInstanceID() : 0);
		int hashCode = ((object)(*(Color*)(&color))/*cast due to .constrained prefix*/).GetHashCode();
		return (long)((ulong)((long)num << 32) ^ ((ulong)(uint)num2 << 16) ^ (uint)hashCode);
	}

	public static Material GetOrCreateRuneMaterial(Texture2D runeTex, Color color)
	{
		//IL_01cd: 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_01e6: 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)
		//IL_0172: Expected O, but got Unknown
		//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0205: Unknown result type (might be due to invalid IL or missing references)
		Init();
		Shader val = Shader.Find("Particles/Standard Unlit") ?? Shader.Find("Legacy Shaders/Particles/Alpha Blended") ?? Shader.Find("Particles/Alpha Blended") ?? Shader.Find("Particles/Additive");
		if ((Object)(object)val == (Object)null)
		{
			float num = float.MinValue;
			Material[] array = Resources.FindObjectsOfTypeAll<Material>();
			foreach (Material val2 in array)
			{
				if (!((Object)(object)val2 == (Object)null) && !((Object)(object)val2.shader == (Object)null))
				{
					Shader shader = val2.shader;
					string text = ((Object)shader).name.ToLower();
					float num2 = 0f;
					if (text.Contains("particle"))
					{
						num2 += 3f;
					}
					if (text.Contains("add"))
					{
						num2 += 3f;
					}
					if (text.Contains("unlit"))
					{
						num2 += 2f;
					}
					if (text.Contains("transparent"))
					{
						num2 += 1.5f;
					}
					if ((val2.HasProperty("_Color") || val2.HasProperty("_TintColor")) && num2 > num)
					{
						num = num2;
						val = shader;
					}
				}
			}
		}
		if ((Object)(object)val == (Object)null)
		{
			Logger.LogError((object)"[Avalor] rune VFX: No glowing shader found. The runes refuse to shine.");
			return null;
		}
		long key = MakeCacheKey(val, runeTex, color);
		if (_materialCache.TryGetValue(key, out var value) && (Object)(object)value != (Object)null)
		{
			return value;
		}
		Material val3 = new Material(val);
		if ((Object)(object)runeTex != (Object)null)
		{
			if (val3.HasProperty("_MainTex"))
			{
				val3.SetTexture("_MainTex", (Texture)(object)runeTex);
			}
			if (val3.HasProperty("_BaseMap"))
			{
				val3.SetTexture("_BaseMap", (Texture)(object)runeTex);
			}
			try
			{
				val3.mainTexture = (Texture)(object)runeTex;
			}
			catch
			{
			}
		}
		if (val3.HasProperty("_Color"))
		{
			val3.SetColor("_Color", color);
		}
		if (val3.HasProperty("_TintColor"))
		{
			val3.SetColor("_TintColor", color);
		}
		if (val3.HasProperty("_EmissionColor"))
		{
			val3.SetColor("_EmissionColor", color * 1.5f);
		}
		val3.SetInt("_SrcBlend", 1);
		val3.SetInt("_DstBlend", 1);
		val3.SetInt("_ZWrite", 0);
		val3.DisableKeyword("_ALPHATEST_ON");
		val3.EnableKeyword("_ALPHABLEND_ON");
		val3.DisableKeyword("_ALPHAPREMULTIPLY_ON");
		val3.renderQueue = 3000;
		_materialCache[key] = val3;
		Logger.LogInfo((object)("[Avalor] rune VFX: Forged glowing additive rune material from '" + ((Object)val).name + "'."));
		return val3;
	}

	public static void ClearCache()
	{
		_materialCache.Clear();
		_initialized = false;
	}
}
public static class AvalorRuneTexture
{
	private const int Size = 128;

	public unsafe static Texture2D GenerateRune(Color color)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		int runeIndex = Mathf.Abs(((object)(*(Color*)(&color))/*cast due to .constrained prefix*/).GetHashCode()) % 16;
		return GenerateRune(color, runeIndex);
	}

	public static Texture2D GenerateRuneAtlas(Color color)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0015: Expected O, but got Unknown
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: 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)
		int num = 128;
		Texture2D val = new Texture2D(512, 512, (TextureFormat)4, true);
		((Texture)val).filterMode = (FilterMode)1;
		((Texture)val).wrapMode = (TextureWrapMode)1;
		Color val2 = default(Color);
		((Color)(ref val2))..ctor(0f, 0f, 0f, 0f);
		Color[] array = (Color[])(object)new Color[512 * 512];
		for (int i = 0; i < array.Length; i++)
		{
			array[i] = val2;
		}
		val.SetPixels(array);
		for (int j = 0; j < 16; j++)
		{
			int num2 = j % 4;
			int num3 = 3 - j / 4;
			DrawRuneOntoAtlas(val, color, j, num2 * num, num3 * num, num);
		}
		val.Apply(true);
		return val;
	}

	public static Texture2D GenerateSoftTrail(Color color)
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		//IL_0050: 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_0091: 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_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: 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)
		Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false);
		((Texture)val).filterMode = (FilterMode)1;
		Vector2 val2 = default(Vector2);
		((Vector2)(ref val2))..ctor(64f, 64f);
		float num = 64f;
		Color val3 = default(Color);
		for (int i = 0; i < 128; i++)
		{
			for (int j = 0; j < 128; j++)
			{
				float num2 = Vector2.Distance(new Vector2((float)j + 0.5f, (float)i + 0.5f), val2) / num;
				float num3 = Mathf.Clamp01(1f - num2);
				num3 = Mathf.SmoothStep(0f, 1f, num3);
				num3 = Mathf.Pow(num3, 1.6f);
				((Color)(ref val3))..ctor(color.r, color.g, color.b, color.a * num3);
				val.SetPixel(j, i, val3);
			}
		}
		val.Apply(true);
		return val;
	}

	public static Texture2D GenerateStreak(Color color)
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		//IL_0047: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: 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_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		Texture2D val = new Texture2D(128, 128, (TextureFormat)4, false);
		((Texture)val).filterMode = (FilterMode)1;
		Vector2 val2 = default(Vector2);
		((Vector2)(ref val2))..ctor(64f, 64f);
		float num = 64f;
		Color val3 = default(Color);
		for (int i = 0; i < 128; i++)
		{
			for (int j = 0; j < 128; j++)
			{
				float num2 = Mathf.Abs((float)i + 0.5f - val2.y) / num;
				float num3 = Mathf.Abs((float)j + 0.5f - val2.x) / (num * 0.6f);
				float num4 = Mathf.Clamp01(1f - num3);
				float num5 = Mathf.SmoothStep(1f, 0f, num2);
				num4 *= Mathf.Pow(num5, 0.9f);
				((Color)(ref val3))..ctor(color.r, color.g, color.b, color.a * num4);
				val.SetPixel(j, i, val3);
			}
		}
		val.Apply(true);
		return val;
	}

	public static Texture2D GenerateBlend(Color color)
	{
		//IL_0000: 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_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Expected O, but got Unknown
		//IL_0034: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0042: 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_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_006c: 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_0084: Unknown result type (might be due to invalid IL or missing references)
		Texture2D val = GenerateSoftTrail(color);
		Texture2D val2 = GenerateRune(color);
		Texture2D val3 = new Texture2D(128, 128, (TextureFormat)4, false);
		((Texture)val3).filterMode = (FilterMode)1;
		Color val4 = default(Color);
		for (int i = 0; i < 128; i++)
		{
			for (int j = 0; j < 128; j++)
			{
				Color pixel = val.GetPixel(j, i);
				Color pixel2 = val2.GetPixel(j, i);
				float num = Mathf.Clamp01(pixel.a + pixel2.a * 0.65f);
				((Color)(ref val4))..ctor(color.r, color.g, color.b, color.a * num);
				val3.SetPixel(j, i, val4);
			}
		}
		val3.Apply(true);
		return val3;
	}

	private static void DrawRuneOntoAtlas(Texture2D tex, Color color, int runeIndex, int offsetX, int offsetY, int size)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: 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_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: 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_00c6: 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_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_013e: 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_0160: 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_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_0194: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: 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_01d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_020c: Unknown result type (might be due to invalid IL or missing references)
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_022e: Unknown result type (might be due to invalid IL or missing references)
		//IL_023f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0250: Unknown result type (might be due to invalid IL or missing references)
		//IL_0262: Unknown result type (might be due to invalid IL or missing references)
		//IL_0273: Unknown result type (might be due to invalid IL or missing references)
		//IL_0285: 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_02a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02da: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_030e: 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_0330: Unknown result type (might be due to invalid IL or missing references)
		//IL_0341: Unknown result type (might be due to invalid IL or missing references)
		//IL_0353: Unknown result type (might be due to invalid IL or missing references)
		//IL_0364: Unknown result type (might be due to invalid IL or missing references)
		//IL_0375: Unknown result type (might be due to invalid IL or missing references)
		//IL_0386: Unknown result type (might be due to invalid IL or missing references)
		//IL_0397: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b9: 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_03dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_040f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0421: Unknown result type (might be due to invalid IL or missing references)
		//IL_0432: Unknown result type (might be due to invalid IL or missing references)
		//IL_0443: Unknown result type (might be due to invalid IL or missing references)
		//IL_0454: Unknown result type (might be due to invalid IL or missing references)
		//IL_0465: Unknown result type (might be due to invalid IL or missing references)
		//IL_0476: Unknown result type (might be due to invalid IL or missing references)
		//IL_0487: Unknown result type (might be due to invalid IL or missing references)
		//IL_0498: Unknown result type (might be due to invalid IL or missing references)
		//IL_04aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_04bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_04cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_04dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_0500: Unknown result type (might be due to invalid IL or missing references)
		//IL_0511: Unknown result type (might be due to invalid IL or missing references)
		//IL_0522: Unknown result type (might be due to invalid IL or missing references)
		//IL_0533: Unknown result type (might be due to invalid IL or missing references)
		//IL_0544: Unknown result type (might be due to invalid IL or missing references)
		//IL_0555: Unknown result type (might be due to invalid IL or missing references)
		//IL_0566: Unknown result type (might be due to invalid IL or missing references)
		//IL_0577: Unknown result type (might be due to invalid IL or missing references)
		//IL_0588: Unknown result type (might be due to invalid IL or missing references)
		//IL_0599: Unknown result type (might be due to invalid IL or missing references)
		//IL_05aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_05bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_05cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_05de: Unknown result type (might be due to invalid IL or missing references)
		//IL_05ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_0600: Unknown result type (might be due to invalid IL or missing references)
		//IL_0611: Unknown result type (might be due to invalid IL or missing references)
		//IL_0622: Unknown result type (might be due to invalid IL or missing references)
		//IL_0633: Unknown result type (might be due to invalid IL or missing references)
		//IL_0645: Unknown result type (might be due to invalid IL or missing references)
		//IL_0656: Unknown result type (might be due to invalid IL or missing references)
		//IL_0667: Unknown result type (might be due to invalid IL or missing references)
		//IL_0678: Unknown result type (might be due to invalid IL or missing references)
		//IL_0689: Unknown result type (might be due to invalid IL or missing references)
		//IL_069a: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_06bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_06cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_06de: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0701: Unknown result type (might be due to invalid IL or missing references)
		//IL_0712: Unknown result type (might be due to invalid IL or missing references)
		//IL_0723: Unknown result type (might be due to invalid IL or missing references)
		//IL_0734: Unknown result type (might be due to invalid IL or missing references)
		//IL_0745: Unknown result type (might be due to invalid IL or missing references)
		//IL_0756: 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_0779: Unknown result type (might be due to invalid IL or missing references)
		//IL_078a: Unknown result type (might be due to invalid IL or missing references)
		//IL_079b: Unknown result type (might be due to invalid IL or missing references)
		//IL_07ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_07bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_07ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_07df: Unknown result type (might be due to invalid IL or missing references)
		//IL_07f0: Unknown result type (might be due to invalid IL or missing references)
		Color c = default(Color);
		((Color)(ref c))..ctor(color.r * 0.6f, color.g * 0.6f, color.b * 0.6f, 0.6f);
		Color c2 = default(Color);
		((Color)(ref c2))..ctor(color.r, color.g, color.b, 1f);
		float scale = (float)size / 128f;
		switch (runeIndex)
		{
		case 0:
			DrawLineLocal(20, 20, 108, 108, c, 6);
			DrawLineLocal(108, 20, 20, 108, c, 6);
			DrawLineLocal(20, 20, 108, 108, c2, 3);
			DrawLineLocal(108, 20, 20, 108, c2, 3);
			break;
		case 1:
			DrawLineLocal(64, 16, 64, 112, c, 6);
			DrawLineLocal(64, 64, 32, 96, c, 5);
			DrawLineLocal(64, 64, 96, 96, c, 5);
			DrawLineLocal(64, 16, 64, 112, c2, 3);
			DrawLineLocal(64, 64, 32, 96, c2, 2);
			DrawLineLocal(64, 64, 96, 96, c2, 2);
			break;
		case 2:
			DrawLineLocal(40, 20, 40, 108, c, 6);
			DrawLineLocal(40, 96, 96, 112, c, 5);
			DrawLineLocal(40, 72, 96, 88, c, 5);
			DrawLineLocal(40, 20, 40, 108, c2, 3);
			DrawLineLocal(40, 96, 96, 112, c2, 2);
			DrawLineLocal(40, 72, 96, 88, c2, 2);
			break;
		case 3:
			DrawLineLocal(40, 20, 40, 112, c, 6);
			DrawLineLocal(40, 96, 88, 112, c, 5);
			DrawLineLocal(88, 112, 88, 80, c, 5);
			DrawLineLocal(88, 80, 40, 96, c, 5);
			DrawLineLocal(40, 20, 40, 112, c2, 3);
			DrawLineLocal(40, 96, 88, 112, c2, 2);
			DrawLineLocal(88, 112, 88, 80, c2, 2);
			DrawLineLocal(88, 80, 40, 96, c2, 2);
			break;
		case 4:
			DrawLineLocal(64, 16, 64, 112, c, 8);
			DrawLineLocal(64, 16, 64, 112, c2, 4);
			break;
		case 5:
			DrawLineLocal(64, 16, 64, 112, c, 6);
			DrawLineLocal(64, 40, 32, 72, c, 5);
			DrawLineLocal(64, 40, 96, 72, c, 5);
			DrawLineLocal(64, 16, 64, 112, c2, 3);
			DrawLineLocal(64, 40, 32, 72, c2, 2);
			DrawLineLocal(64, 40, 96, 72, c2, 2);
			break;
		case 6:
			DrawLineLocal(36, 16, 36, 112, c, 6);
			DrawLineLocal(92, 16, 92, 112, c, 6);
			DrawLineLocal(36, 36, 92, 92, c, 5);
			DrawLineLocal(36, 16, 36, 112, c2, 3);
			DrawLineLocal(92, 16, 92, 112, c2, 3);
			DrawLineLocal(36, 36, 92, 92, c2, 2);
			break;
		case 7:
			DrawLineLocal(80, 20, 40, 20, c, 5);
			DrawLineLocal(80, 20, 40, 64, c, 5);
			DrawLineLocal(40, 64, 80, 108, c, 5);
			DrawLineLocal(80, 108, 40, 108, c, 5);
			DrawLineLocal(80, 20, 40, 20, c2, 2);
			DrawLineLocal(80, 20, 40, 64, c2, 2);
			DrawLineLocal(40, 64, 80, 108, c2, 2);
			DrawLineLocal(80, 108, 40, 108, c2, 2);
			break;
		case 8:
			DrawLineLocal(64, 16, 64, 112, c, 6);
			DrawLineLocal(96, 96, 32, 32, c, 5);
			DrawLineLocal(64, 16, 64, 112, c2, 3);
			DrawLineLocal(96, 96, 32, 32, c2, 2);
			break;
		case 9:
			DrawLineLocal(32, 48, 32, 112, c, 6);
			DrawLineLocal(96, 48, 96, 112, c, 6);
			DrawLineLocal(32, 48, 64, 16, c, 5);
			DrawLineLocal(64, 16, 96, 48, c, 5);
			DrawLineLocal(32, 48, 32, 112, c2, 3);
			DrawLineLocal(96, 48, 96, 112, c2, 3);
			DrawLineLocal(32, 48, 64, 16, c2, 2);
			DrawLineLocal(64, 16, 96, 48, c2, 2);
			break;
		case 10:
			DrawLineLocal(48, 16, 48, 112, c, 6);
			DrawLineLocal(48, 80, 96, 48, c, 5);
			DrawLineLocal(48, 16, 48, 112, c2, 3);
			DrawLineLocal(48, 80, 96, 48, c2, 2);
			break;
		case 11:
			DrawLineLocal(64, 112, 96, 72, c, 5);
			DrawLineLocal(96, 72, 64, 32, c, 5);
			DrawLineLocal(64, 32, 32, 72, c, 5);
			DrawLineLocal(32, 72, 64, 112, c, 5);
			DrawLineLocal(32, 72, 16, 16, c, 5);
			DrawLineLocal(96, 72, 112, 16, c, 5);
			DrawLineLocal(64, 112, 96, 72, c2, 2);
			DrawLineLocal(96, 72, 64, 32, c2, 2);
			DrawLineLocal(64, 32, 32, 72, c2, 2);
			DrawLineLocal(32, 72, 64, 112, c2, 2);
			DrawLineLocal(32, 72, 16, 16, c2, 2);
			DrawLineLocal(96, 72, 112, 16, c2, 2);
			break;
		case 12:
			DrawLineLocal(20, 20, 64, 64, c, 5);
			DrawLineLocal(20, 108, 64, 64, c, 5);
			DrawLineLocal(108, 20, 64, 64, c, 5);
			DrawLineLocal(108, 108, 64, 64, c, 5);
			DrawLineLocal(20, 20, 64, 64, c2, 2);
			DrawLineLocal(20, 108, 64, 64, c2, 2);
			DrawLineLocal(108, 20, 64, 64, c2, 2);
			DrawLineLocal(108, 108, 64, 64, c2, 2);
			break;
		case 13:
			DrawLineLocal(36, 16, 36, 112, c, 6);
			DrawLineLocal(36, 96, 80, 80, c, 5);
			DrawLineLocal(80, 80, 36, 64, c, 5);
			DrawLineLocal(36, 64, 80, 48, c, 5);
			DrawLineLocal(80, 48, 36, 32, c, 5);
			DrawLineLocal(36, 16, 36, 112, c2, 3);
			DrawLineLocal(36, 96, 80, 80, c2, 2);
			DrawLineLocal(80, 80, 36, 64, c2, 2);
			DrawLineLocal(36, 64, 80, 48, c2, 2);
			DrawLineLocal(80, 48, 36, 32, c2, 2);
			break;
		case 14:
			DrawLineLocal(32, 16, 32, 112, c, 6);
			DrawLineLocal(96, 16, 96, 112, c, 6);
			DrawLineLocal(32, 112, 96, 64, c, 5);
			DrawLineLocal(96, 112, 32, 64, c, 5);
			DrawLineLocal(32, 16, 32, 112, c2, 3);
			DrawLineLocal(96, 16, 96, 112, c2, 3);
			DrawLineLocal(32, 112, 96, 64, c2, 2);
			DrawLineLocal(96, 112, 32, 64, c2, 2);
			break;
		case 15:
			DrawLineLocal(64, 16, 108, 64, c, 6);
			DrawLineLocal(108, 64, 64, 112, c, 6);
			DrawLineLocal(64, 112, 20, 64, c, 6);
			DrawLineLocal(20, 64, 64, 16, c, 6);
			DrawLineLocal(64, 16, 108, 64, c2, 3);
			DrawLineLocal(108, 64, 64, 112, c2, 3);
			DrawLineLocal(64, 112, 20, 64, c2, 3);
			DrawLineLocal(20, 64, 64, 16, c2, 3);
			break;
		}
		void DrawLineLocal(int x0, int y0, int x1, int y1, Color c3, int thickness)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			DrawLineAtlas(tex, offsetX + (int)((float)x0 * scale), offsetY + (int)((float)y0 * scale), offsetX + (int)((float)x1 * scale), offsetY + (int)((float)y1 * scale), c3, thickness, 512);
		}
	}

	public static Texture2D GenerateRune(Color color, int runeIndex)
	{
		//IL_000c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0012: Expected O, but got Unknown
		//IL_003d: 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_0055: 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_0073: 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_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: 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_011e: 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_013e: 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_0163: Unknown result type (might be due to invalid IL or missing references)
		//IL_0173: Unknown result type (might be due to invalid IL or missing references)
		//IL_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: 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_01d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0208: Unknown result type (might be due to invalid IL or missing references)
		//IL_021d: Unknown result type (might be due to invalid IL or missing references)
		//IL_022d: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_024d: Unknown result type (might be due to invalid IL or missing references)
		//IL_025d: Unknown result type (might be due to invalid IL or missing references)
		//IL_026d: Unknown result type (might be due to invalid IL or missing references)
		//IL_027d: Unknown result type (might be due to invalid IL or missing references)
		//IL_028d: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a2: 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_02c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0307: Unknown result type (might be due to invalid IL or missing references)
		//IL_0317: Unknown resu