Decompiled source of Aura Rings v1.0.0

Auras.dll

Decompiled a week ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Globalization;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Jotunn.Configs;
using Jotunn.Entities;
using Jotunn.Managers;
using Jotunn.Utils;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.Rendering;

[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("Auras")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Auras")]
[assembly: AssemblyTitle("Auras")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Auras
{
	internal sealed class AuraAnchor : MonoBehaviour
	{
		private Transform? _wearer;

		public Transform? Wearer => _wearer;

		private void OnEnable()
		{
			_wearer = null;
			Follow();
		}

		private void LateUpdate()
		{
			Follow();
		}

		private void Follow()
		{
			//IL_00ca: 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)
			//IL_004e: 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_0054: 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_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)_wearer))
			{
				VisEquipment componentInParent = ((Component)this).GetComponentInParent<VisEquipment>();
				_wearer = (Object.op_Implicit((Object)(object)componentInParent) ? ((Component)componentInParent).transform : null);
				if (!Object.op_Implicit((Object)(object)_wearer))
				{
					return;
				}
			}
			Transform parent = ((Component)this).transform.parent;
			if (Object.op_Implicit((Object)(object)parent))
			{
				Vector3 lossyScale = parent.lossyScale;
				if (Mathf.Abs(lossyScale.x) > 1E-06f && Mathf.Abs(lossyScale.y) > 1E-06f && Mathf.Abs(lossyScale.z) > 1E-06f)
				{
					((Component)this).transform.localScale = new Vector3(1f / lossyScale.x, 1f / lossyScale.y, 1f / lossyScale.z);
				}
			}
			((Component)this).transform.SetPositionAndRotation(_wearer.position, Quaternion.identity);
		}
	}
	internal sealed class AuraLook
	{
		public float Brightness = 1f;

		public float Density = 1f;

		public float Speed = 1f;

		public float Light;

		public int Seed { get; set; }

		public Func<Color, Color>? Convert { get; set; }
	}
	internal static class AuraBuilder
	{
		private enum Blend
		{
			Add,
			Over
		}

		private sealed class Maker
		{
			private readonly AuraDef _def;

			private readonly Shader _shader;

			private readonly AuraLook _look;

			private readonly Transform _root;

			private int _made;

			public Maker(AuraDef def, Shader shader, AuraLook look)
			{
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				_def = def;
				_shader = shader;
				_look = look;
				_root = new GameObject("aura").transform;
			}

			public GameObject Run()
			{
				//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_00f8: 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_012a: Unknown result type (might be due to invalid IL or missing references)
				float num = Mathf.Clamp(_look.Density, 0.1f, 4f);
				Halo();
				Mist(7.2f * num);
				Haze(29f * num);
				Wisps(11.5f * num);
				Rise(10.2f * num);
				Motes(25.6f * num);
				Glints(((_def.Accent == AuraAccent.Stars) ? 1.6f : 0.51f) * num);
				switch (_def.Accent)
				{
				case AuraAccent.Petals:
					Petals(1.9f * num);
					break;
				case AuraAccent.Smoke:
					Smoke(4f * num);
					break;
				case AuraAccent.Radiance:
					Radiance();
					break;
				}
				if (_look.Light > 0f)
				{
					GameObject val = new GameObject("light");
					val.transform.SetParent(_root, false);
					val.transform.localPosition = new Vector3(0f, 1f, 0f);
					Light obj = val.AddComponent<Light>();
					obj.type = (LightType)2;
					obj.color = _def.Glow;
					obj.range = 4f;
					obj.intensity = _look.Light;
					obj.shadows = (LightShadows)0;
				}
				return ((Component)_root).gameObject;
			}

			private void Halo()
			{
				//IL_0015: 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_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_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: 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_0083: 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_00a6: Unknown result type (might be due to invalid IL or missing references)
				ParticleSystem val = New("halo", new Vector3(0f, 1.02f, 0f), Quaternion.identity, leftBehind: false);
				MainModule main = val.main;
				((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(4f);
				((MainModule)(ref main)).startSize3D = true;
				((MainModule)(ref main)).startSizeX = MinMaxCurve.op_Implicit(2f);
				((MainModule)(ref main)).startSizeY = MinMaxCurve.op_Implicit(3f);
				((MainModule)(ref main)).startSizeZ = MinMaxCurve.op_Implicit(1f);
				((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(C(_def.Glow, _def.Dark ? 0.052f : 0.096f));
				((MainModule)(ref main)).maxParticles = 4;
				Rate(val, 0.5f);
				NoShape(val);
				Fade(val, (0f, 0f), (0.5f, 1f), (1f, 0f));
				Size(val, (0f, 0.92f), (0.5f, 1.06f), (1f, 0.92f));
				ParticleSystemRenderer obj = Renderer(val);
				((Renderer)obj).sharedMaterial = Mat(AuraTextures.Glow, Blend.Add, 1f, fadeNearCamera: true);
				obj.maxParticleSize = 5f;
				obj.sortingFudge = 20f;
			}

			private void Mist(float rate)
			{
				//IL_0015: 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_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_003a: 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_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_010d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0112: Unknown result type (might be due to invalid IL or missing references)
				//IL_012f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0145: Unknown result type (might be due to invalid IL or missing references)
				//IL_015b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0171: Unknown result type (might be due to invalid IL or missing references)
				//IL_0187: Unknown result type (might be due to invalid IL or missing references)
				//IL_019d: Unknown result type (might be due to invalid IL or missing references)
				//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c2: Unknown result type (might be due to invalid IL or missing references)
				ParticleSystem val = New("mist", new Vector3(0f, 0.3f, 0f), Quaternion.identity, leftBehind: false);
				MainModule main = val.main;
				((MainModule)(ref main)).startLifetime = new MinMaxCurve(3.2f, 4.8f);
				((MainModule)(ref main)).startSize = new MinMaxCurve(0.6f, 1f);
				((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, (float)Math.PI * 2f);
				((MainModule)(ref main)).startColor = Random((Color[])((!_def.Dark) ? ((Array)_def.Palette) : ((Array)new Color[2] { _def.Glow, _def.Glow })), _def.Dark ? 0.05f : 0.075f);
				((MainModule)(ref main)).maxParticles = Mathf.CeilToInt(rate * 4.8f * 1.3f) + 4;
				Rate(val, rate);
				FlatCircle(val, 0.6f, 1f);
				VelocityOverLifetimeModule velocityOverLifetime = val.velocityOverLifetime;
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true;
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)0;
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = Between(0f, 0f);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = Between(0.02f, 0.12f);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = Between(0f, 0f);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).orbitalX = Between(0f, 0f);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).orbitalY = Between(-0.22f, 0.22f);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).orbitalZ = Between(0f, 0f);
				RotationOverLifetimeModule rotationOverLifetime = val.rotationOverLifetime;
				((RotationOverLifetimeModule)(ref rotationOverLifetime)).enabled = true;
				((RotationOverLifetimeModule)(ref rotationOverLifetime)).z = Between(-0.3f, 0.3f);
				Fade(val, (0f, 0f), (0.3f, 1f), (0.7f, 0.8f), (1f, 0f));
				Size(val, (0f, 0.7f), (1f, 1.25f));
				ParticleSystemRenderer obj = Renderer(val);
				((Renderer)obj).sharedMaterial = Mat(AuraTextures.Smoke, Blend.Add, 1f, fadeNearCamera: true);
				obj.maxParticleSize = 5f;
				obj.sortingFudge = 19f;
			}

			private void Haze(float rate)
			{
				//IL_0015: 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_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_003a: 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_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_009b: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
				//IL_010c: 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_0121: 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_0154: Unknown result type (might be due to invalid IL or missing references)
				//IL_016a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0180: Unknown result type (might be due to invalid IL or missing references)
				//IL_0196: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
				ParticleSystem val = New("haze", new Vector3(0f, 0.85f, 0f), Quaternion.identity, leftBehind: false);
				MainModule main = val.main;
				((MainModule)(ref main)).startLifetime = new MinMaxCurve(2.1f, 3.3f);
				((MainModule)(ref main)).startSize = new MinMaxCurve(0.4f, 0.75f);
				((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, (float)Math.PI * 2f);
				((MainModule)(ref main)).startColor = Random((Color[])((!_def.Dark) ? ((Array)_def.Palette) : ((Array)new Color[2] { _def.Glow, _def.Glow })), _def.Dark ? 0.03f : 0.042f);
				((MainModule)(ref main)).maxParticles = Mathf.CeilToInt(rate * 3.3f * 1.3f) + 4;
				Rate(val, rate);
				Shell(val, new Vector3(0.55f, 0.85f, 0.55f), 0.6f);
				VelocityOverLifetimeModule velocityOverLifetime = val.velocityOverLifetime;
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true;
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)0;
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = Between(0f, 0f);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = Between(0.15f, 0.38f);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = Between(0f, 0f);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).orbitalX = Between(0f, 0f);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).orbitalY = Between(-0.25f, 0.25f);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).orbitalZ = Between(0f, 0f);
				Fade(val, (0f, 0f), (0.3f, 1f), (0.65f, 0.7f), (1f, 0f));
				Size(val, (0f, 0.75f), (1f, 1.2f));
				ParticleSystemRenderer obj = Renderer(val);
				((Renderer)obj).sharedMaterial = Mat(AuraTextures.Glow, Blend.Add, 1f, fadeNearCamera: true);
				obj.maxParticleSize = 5f;
				obj.sortingFudge = 18f;
			}

			private void Wisps(float rate)
			{
				//IL_0015: 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_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_003a: 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_0085: Unknown result type (might be due to invalid IL or missing references)
				//IL_008a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0097: 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_00a6: 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_0105: 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_0131: Unknown result type (might be due to invalid IL or missing references)
				ParticleSystem val = New("wisps", new Vector3(0f, 0.05f, 0f), Quaternion.identity, leftBehind: false, points: true);
				MainModule main = val.main;
				((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.8f, 1.5f);
				((MainModule)(ref main)).startSize = new MinMaxCurve(0.05f, 0.1f);
				((MainModule)(ref main)).startColor = Random((Color[])((!_def.Dark) ? ((Array)_def.Palette) : ((Array)new Color[2] { _def.Glow, _def.Spark })), 0.5f);
				((MainModule)(ref main)).maxParticles = Mathf.CeilToInt(rate * 1.5f * 1.3f) + 4;
				Rate(val, rate);
				FlatCircle(val, 0.5f, 0.6f);
				VelocityOverLifetimeModule velocityOverLifetime = val.velocityOverLifetime;
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true;
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)0;
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = Between(0f, 0f);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = Between(0.5f, 1.1f);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = Between(0f, 0f);
				Fade(val, (0f, 0f), (0.25f, 1f), (1f, 0f));
				Size(val, (0f, 1f), (1f, 0.3f));
				ParticleSystemRenderer obj = Renderer(val);
				obj.renderMode = (ParticleSystemRenderMode)1;
				obj.lengthScale = 3.5f;
				obj.velocityScale = 0.2f;
				((Renderer)obj).sharedMaterial = Mat(AuraTextures.Glow, Blend.Add, 1f, fadeNearCamera: false);
			}

			private void Motes(float rate)
			{
				//IL_0015: 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_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_003a: 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_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_00c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00da: Unknown result type (might be due to invalid IL or missing references)
				//IL_0116: Unknown result type (might be due to invalid IL or missing references)
				//IL_0126: Unknown result type (might be due to invalid IL or missing references)
				//IL_012b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0148: Unknown result type (might be due to invalid IL or missing references)
				//IL_015e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0174: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
				ParticleSystem val = New("motes", new Vector3(0f, 1f, 0f), Quaternion.identity, leftBehind: true, points: true);
				MainModule main = val.main;
				((MainModule)(ref main)).startLifetime = new MinMaxCurve(1.8f, 3f);
				((MainModule)(ref main)).startSize = new MinMaxCurve(0.025f, 0.06f);
				((MainModule)(ref main)).startColor = Random((Color[])((_def.Palette.Length > 2) ? ((Array)_def.Palette) : ((Array)new Color[2]
				{
					_def.Spark,
					_def.Dark ? _def.Glow : _def.Palette[0]
				})), 1f);
				((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-0.012f);
				((MainModule)(ref main)).maxParticles = Mathf.CeilToInt(rate * 3f * 1.3f) + 4;
				Rate(val, rate);
				Shell(val, new Vector3(0.7f, 1f, 0.7f), 0.8f);
				VelocityOverLifetimeModule velocityOverLifetime = val.velocityOverLifetime;
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true;
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)1;
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = Between(-0.06f, 0.06f);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = Between(0.06f, 0.28f);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = Between(-0.06f, 0.06f);
				Wander(val, 0.14f, 0.7f);
				Fade(val, (0f, 0f), (0.2f, 1f), (0.7f, 0.8f), (1f, 0f));
				Size(val, (0f, 0.6f), (0.3f, 1f), (1f, 0.3f));
				((Renderer)Renderer(val)).sharedMaterial = Mat(AuraTextures.Glow, Blend.Add, 1.5f, fadeNearCamera: false);
			}

			private void Rise(float rate)
			{
				//IL_0015: 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_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_003a: 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_0085: Unknown result type (might be due to invalid IL or missing references)
				//IL_008a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0097: 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_00a6: 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_0105: 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_0131: Unknown result type (might be due to invalid IL or missing references)
				ParticleSystem val = New("rise", new Vector3(0f, 0.15f, 0f), Quaternion.identity, leftBehind: false, points: true);
				MainModule main = val.main;
				((MainModule)(ref main)).startLifetime = new MinMaxCurve(2.2f, 3.6f);
				((MainModule)(ref main)).startSize = new MinMaxCurve(0.03f, 0.065f);
				((MainModule)(ref main)).startColor = Random((Color[])((!_def.Dark) ? ((Array)_def.Palette) : ((Array)new Color[2] { _def.Glow, _def.Spark })), 1f);
				((MainModule)(ref main)).maxParticles = Mathf.CeilToInt(rate * 3.6f * 1.3f) + 4;
				Rate(val, rate);
				FlatCircle(val, 0.6f, 0.8f);
				VelocityOverLifetimeModule velocityOverLifetime = val.velocityOverLifetime;
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true;
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)0;
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = Between(-0.03f, 0.03f);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = Between(0.3f, 0.6f);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = Between(-0.03f, 0.03f);
				Wander(val, 0.1f, 0.7f);
				Fade(val, (0f, 0f), (0.2f, 1f), (0.7f, 0.8f), (1f, 0f));
				Size(val, (0f, 0.5f), (0.3f, 1f), (1f, 0.4f));
				((Renderer)Renderer(val)).sharedMaterial = Mat(AuraTextures.Glow, Blend.Add, 1.5f, fadeNearCamera: false);
			}

			private void Glints(float rate)
			{
				//IL_0015: 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_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_003a: 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_0066: 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_0093: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00cd: 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_0113: Unknown result type (might be due to invalid IL or missing references)
				ParticleSystem val = New("glints", new Vector3(0f, 1f, 0f), Quaternion.identity, leftBehind: true, points: true);
				MainModule main = val.main;
				((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.45f, 0.9f);
				((MainModule)(ref main)).startSize = new MinMaxCurve(0.07f, 0.15f);
				((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, (float)Math.PI / 2f);
				((MainModule)(ref main)).startColor = Random((Color[])(object)new Color[2]
				{
					_def.Spark,
					Color.Lerp(_def.Spark, _def.Dark ? _def.Glow : _def.Palette[0], 0.5f)
				}, 1f);
				((MainModule)(ref main)).maxParticles = Mathf.CeilToInt(rate * 0.9f * 1.5f) + 4;
				Rate(val, rate);
				Shell(val, new Vector3(0.7f, 1f, 0.7f), 0.5f);
				Fade(val, (0f, 0f), (0.3f, 1f), (1f, 0f));
				Size(val, (0f, 0.1f), (0.3f, 1f), (1f, 0.1f));
				((Renderer)Renderer(val)).sharedMaterial = Mat(AuraTextures.Star, Blend.Add, 1.5f, fadeNearCamera: false);
			}

			private void Petals(float rate)
			{
				//IL_0015: 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_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_003a: 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_0066: 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_0098: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b9: 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_00c8: 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_0115: 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_012a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0147: Unknown result type (might be due to invalid IL or missing references)
				//IL_015d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0173: Unknown result type (might be due to invalid IL or missing references)
				//IL_018e: 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_01a8: Unknown result type (might be due to invalid IL or missing references)
				ParticleSystem val = New("petals", new Vector3(0f, 1.45f, 0f), Quaternion.identity, leftBehind: true, points: true);
				MainModule main = val.main;
				((MainModule)(ref main)).startLifetime = new MinMaxCurve(2.8f, 4.2f);
				((MainModule)(ref main)).startSize = new MinMaxCurve(0.05f, 0.085f);
				((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, (float)Math.PI * 2f);
				((MainModule)(ref main)).flipRotation = 0.5f;
				((MainModule)(ref main)).startColor = Random((Color[])(object)new Color[2]
				{
					_def.Palette[0],
					_def.Palette[_def.Palette.Length - 1]
				}, 0.95f);
				((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(0.03f);
				((MainModule)(ref main)).maxParticles = Mathf.CeilToInt(rate * 4.2f * 1.3f) + 4;
				Rate(val, rate);
				Shell(val, new Vector3(0.75f, 0.5f, 0.75f), 0.6f);
				VelocityOverLifetimeModule velocityOverLifetime = val.velocityOverLifetime;
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true;
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)1;
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = Between(-0.12f, 0.12f);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = Between(-0.06f, 0.04f);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = Between(-0.12f, 0.12f);
				Wander(val, 0.22f, 0.5f);
				RotationOverLifetimeModule rotationOverLifetime = val.rotationOverLifetime;
				((RotationOverLifetimeModule)(ref rotationOverLifetime)).enabled = true;
				((RotationOverLifetimeModule)(ref rotationOverLifetime)).z = Between(-2.5f, 2.5f);
				Fade(val, (0f, 0f), (0.12f, 1f), (0.8f, 1f), (1f, 0f));
				((Renderer)Renderer(val)).sharedMaterial = Mat(AuraTextures.Petal, Blend.Over, 1f, fadeNearCamera: false);
			}

			private void Smoke(float rate)
			{
				//IL_0015: 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_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_003a: 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_0066: Unknown result type (might be due to invalid IL or missing references)
				//IL_0083: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
				//IL_010e: 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_013a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0150: Unknown result type (might be due to invalid IL or missing references)
				//IL_015b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0160: Unknown result type (might be due to invalid IL or missing references)
				//IL_0175: Unknown result type (might be due to invalid IL or missing references)
				ParticleSystem val = New("smoke", new Vector3(0f, 0.25f, 0f), Quaternion.identity, leftBehind: false);
				MainModule main = val.main;
				((MainModule)(ref main)).startLifetime = new MinMaxCurve(2.4f, 3.8f);
				((MainModule)(ref main)).startSize = new MinMaxCurve(0.5f, 0.9f);
				((MainModule)(ref main)).startRotation = new MinMaxCurve(0f, (float)Math.PI * 2f);
				((MainModule)(ref main)).startColor = Random(_def.Palette, 0.5f);
				((MainModule)(ref main)).maxParticles = Mathf.CeilToInt(rate * 3.8f * 1.3f) + 4;
				Rate(val, rate);
				FlatCircle(val, 0.5f, 0.6f);
				VelocityOverLifetimeModule velocityOverLifetime = val.velocityOverLifetime;
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true;
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).space = (ParticleSystemSimulationSpace)0;
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).x = Between(0f, 0f);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).y = Between(0.3f, 0.55f);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).z = Between(0f, 0f);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).orbitalX = Between(0f, 0f);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).orbitalY = Between(-0.3f, 0.3f);
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).orbitalZ = Between(0f, 0f);
				RotationOverLifetimeModule rotationOverLifetime = val.rotationOverLifetime;
				((RotationOverLifetimeModule)(ref rotationOverLifetime)).enabled = true;
				((RotationOverLifetimeModule)(ref rotationOverLifetime)).z = Between(-0.4f, 0.4f);
				Fade(val, (0f, 0f), (0.25f, 1f), (0.6f, 0.8f), (1f, 0f));
				Size(val, (0f, 0.6f), (1f, 1.3f));
				ParticleSystemRenderer obj = Renderer(val);
				((Renderer)obj).sharedMaterial = Mat(AuraTextures.Smoke, Blend.Over, 1f, fadeNearCamera: true);
				obj.sortingFudge = 10f;
			}

			private void Radiance()
			{
				//IL_0015: 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_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_0035: Unknown result type (might be due to invalid IL or missing references)
				//IL_0046: Unknown result type (might be due to invalid IL or missing references)
				//IL_006d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0077: Unknown result type (might be due to invalid IL or missing references)
				//IL_007c: Unknown result type (might be due to invalid IL or missing references)
				ParticleSystem val = New("radiance", new Vector3(0f, 1.2f, 0f), Quaternion.identity, leftBehind: false);
				MainModule main = val.main;
				((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(3.6f);
				((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(1f);
				((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(C(_def.Palette[_def.Palette.Length - 1], 0.32f));
				((MainModule)(ref main)).maxParticles = 8;
				Rate(val, 0.68f);
				NoShape(val);
				Fade(val, (0f, 0f), (0.2f, 1f), (0.6f, 0.6f), (1f, 0f));
				Size(val, (0f, 0.5f), (1f, 2.7f));
				ParticleSystemRenderer obj = Renderer(val);
				((Renderer)obj).sharedMaterial = Mat(AuraTextures.Circle, Blend.Add, 1f, fadeNearCamera: true);
				obj.maxParticleSize = 5f;
				obj.sortingFudge = 15f;
			}

			private ParticleSystem New(string name, Vector3 position, Quaternion rotation, bool leftBehind, bool points = false)
			{
				//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_0018: 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_0024: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: 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_0085: 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)
				GameObject val = new GameObject(name);
				val.transform.SetParent(_root, false);
				val.transform.localPosition = position;
				val.transform.localRotation = rotation;
				ParticleSystem val2 = val.AddComponent<ParticleSystem>();
				val2.Stop(true, (ParticleSystemStopBehavior)0);
				if (_look.Seed != 0)
				{
					val2.useAutoRandomSeed = false;
					val2.randomSeed = (uint)(_look.Seed + _made * 7919);
				}
				_made++;
				MainModule main = val2.main;
				((MainModule)(ref main)).duration = 5f;
				((MainModule)(ref main)).loop = true;
				((MainModule)(ref main)).playOnAwake = true;
				((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(0f);
				((MainModule)(ref main)).startDelay = MinMaxCurve.op_Implicit(0f);
				((MainModule)(ref main)).simulationSpeed = 0.75f * (points ? 0.8f : 1f) * Mathf.Clamp(_look.Speed, 0.1f, 3f);
				((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)(leftBehind ? 1 : 0);
				((MainModule)(ref main)).scalingMode = (ParticleSystemScalingMode)1;
				ParticleSystemRenderer component = val.GetComponent<ParticleSystemRenderer>();
				((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
				((Renderer)component).receiveShadows = false;
				((Renderer)component).lightProbeUsage = (LightProbeUsage)0;
				((Renderer)component).reflectionProbeUsage = (ReflectionProbeUsage)0;
				component.alignment = (ParticleSystemRenderSpace)0;
				return val2;
			}

			private static ParticleSystemRenderer Renderer(ParticleSystem ps)
			{
				return ((Component)ps).GetComponent<ParticleSystemRenderer>();
			}

			private static void Rate(ParticleSystem ps, float perSecond)
			{
				//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_0012: Unknown result type (might be due to invalid IL or missing references)
				EmissionModule emission = ps.emission;
				((EmissionModule)(ref emission)).enabled = true;
				((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(perSecond);
			}

			private static void NoShape(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)
				ShapeModule shape = ps.shape;
				((ShapeModule)(ref shape)).enabled = false;
			}

			private static void FlatCircle(ParticleSystem ps, float radius, float thickness)
			{
				//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_0045: Unknown result type (might be due to invalid IL or missing references)
				ShapeModule shape = ps.shape;
				((ShapeModule)(ref shape)).enabled = true;
				((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)10;
				((ShapeModule)(ref shape)).radius = radius;
				((ShapeModule)(ref shape)).radiusThickness = thickness;
				((ShapeModule)(ref shape)).arc = 360f;
				((ShapeModule)(ref shape)).rotation = new Vector3(90f, 0f, 0f);
			}

			private static void Shell(ParticleSystem ps, Vector3 size, float thickness)
			{
				//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_002d: Unknown result type (might be due to invalid IL or missing references)
				ShapeModule shape = ps.shape;
				((ShapeModule)(ref shape)).enabled = true;
				((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
				((ShapeModule)(ref shape)).radius = 1f;
				((ShapeModule)(ref shape)).radiusThickness = thickness;
				((ShapeModule)(ref shape)).scale = size;
			}

			private static void Wander(ParticleSystem ps, float strength, float frequency)
			{
				//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_0012: Unknown result type (might be due to invalid IL or missing references)
				//IL_002b: Unknown result type (might be due to invalid IL or missing references)
				NoiseModule noise = ps.noise;
				((NoiseModule)(ref noise)).enabled = true;
				((NoiseModule)(ref noise)).strength = MinMaxCurve.op_Implicit(strength);
				((NoiseModule)(ref noise)).frequency = frequency;
				((NoiseModule)(ref noise)).scrollSpeed = MinMaxCurve.op_Implicit(0.25f);
				((NoiseModule)(ref noise)).damping = true;
				((NoiseModule)(ref noise)).octaveCount = 1;
				((NoiseModule)(ref noise)).quality = (ParticleSystemNoiseQuality)1;
			}

			private static void Fade(ParticleSystem ps, params (float Time, float Alpha)[] keys)
			{
				//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)
				ColorOverLifetimeModule colorOverLifetime = ps.colorOverLifetime;
				((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
				((ColorOverLifetimeModule)(ref colorOverLifetime)).color = new MinMaxGradient(Alpha(keys));
			}

			private static void Size(ParticleSystem ps, params (float Time, float Size)[] keys)
			{
				//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_001c: Unknown result type (might be due to invalid IL or missing references)
				SizeOverLifetimeModule sizeOverLifetime = ps.sizeOverLifetime;
				((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
				((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, Curve(keys));
			}

			private static MinMaxCurve Between(float min, float max)
			{
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				return new MinMaxCurve(min, max);
			}

			private static Gradient Alpha(params (float Time, float Alpha)[] keys)
			{
				//IL_0027: 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_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0041: Expected O, but got Unknown
				//IL_004a: 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_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_0060: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_006f: Unknown result type (might be due to invalid IL or missing references)
				GradientAlphaKey[] array = (GradientAlphaKey[])(object)new GradientAlphaKey[keys.Length];
				for (int i = 0; i < keys.Length; i++)
				{
					array[i] = new GradientAlphaKey(keys[i].Alpha, keys[i].Time);
				}
				Gradient val = new Gradient();
				val.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
				{
					new GradientColorKey(Color.white, 0f),
					new GradientColorKey(Color.white, 1f)
				}, array);
				return val;
			}

			private static AnimationCurve Curve(params (float Time, float Value)[] keys)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0006: Expected O, but got Unknown
				AnimationCurve val = new AnimationCurve();
				for (int i = 0; i < keys.Length; i++)
				{
					var (num, num2) = keys[i];
					val.AddKey(num, num2);
				}
				for (int j = 0; j < val.length; j++)
				{
					val.SmoothTangents(j, 0f);
				}
				return val;
			}

			private Color C(Color colour, float alpha)
			{
				//IL_001b: 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_000d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				Color result = ((_look.Convert != null) ? _look.Convert(colour) : colour);
				result.a = alpha;
				return result;
			}

			private MinMaxGradient Random(Color[] colours, float alpha)
			{
				//IL_0027: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0036: Unknown result type (might be due to invalid IL or missing references)
				//IL_003a: 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: Expected O, but got Unknown
				//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_008e: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: 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)
				int num = Mathf.Clamp(colours.Length, 1, 8);
				GradientColorKey[] array = (GradientColorKey[])(object)new GradientColorKey[Mathf.Max(num, 2)];
				for (int i = 0; i < array.Length; i++)
				{
					Color val = C(colours[Mathf.Min(i, num - 1)], 1f);
					array[i] = new GradientColorKey(val, (array.Length == 1) ? 0f : ((float)i / (float)(array.Length - 1)));
				}
				Gradient val2 = new Gradient();
				val2.SetKeys(array, (GradientAlphaKey[])(object)new GradientAlphaKey[2]
				{
					new GradientAlphaKey(alpha, 0f),
					new GradientAlphaKey(alpha, 1f)
				});
				MinMaxGradient result = default(MinMaxGradient);
				((MinMaxGradient)(ref result))..ctor(val2);
				((MinMaxGradient)(ref result)).mode = (ParticleSystemGradientMode)4;
				return result;
			}

			private Material Mat(Texture2D texture, Blend blend, float strength, bool fadeNearCamera)
			{
				//IL_00e0: 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_010e: Expected O, but got Unknown
				//IL_014b: Unknown result type (might be due to invalid IL or missing references)
				//IL_014d: Unknown result type (might be due to invalid IL or missing references)
				//IL_013c: 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)
				//IL_032c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0360: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ab: Unknown result type (might be due to invalid IL or missing references)
				//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
				float num = ((blend == Blend.Add) ? (strength * Mathf.Clamp(_look.Brightness, 0.05f, 4f)) : 1f);
				string key = ((Object)_shader).GetInstanceID() + "|" + ((Object)texture).name + "|" + blend.ToString() + "|" + num.ToString("0.###") + "|" + fadeNearCamera + "|" + (_look.Convert != null);
				if (Materials.TryGetValue(key, out Material value) && Object.op_Implicit((Object)(object)value))
				{
					return value;
				}
				Material val = new Material(_shader)
				{
					name = "aura_" + ((Object)texture).name + "_" + blend
				};
				val.SetTexture("_MainTex", (Texture)(object)texture);
				Color val2 = default(Color);
				((Color)(ref val2))..ctor(num, num, num, 1f);
				val.SetColor("_Color", (_look.Convert != null) ? _look.Convert(val2) : val2);
				val.SetFloat("_Mode", (blend == Blend.Add) ? 4f : 2f);
				val.SetFloat("_ColorMode", 0f);
				val.SetFloat("_BlendOp", 0f);
				val.SetFloat("_SrcBlend", 5f);
				val.SetFloat("_DstBlend", (float)((blend == Blend.Add) ? 1 : 10));
				val.SetFloat("_ZWrite", 0f);
				val.SetFloat("_Cull", 0f);
				val.SetFloat("_LightingEnabled", 0f);
				val.SetFloat("_EmissionEnabled", 0f);
				val.SetFloat("_DistortionEnabled", 0f);
				val.SetFloat("_FlipbookMode", 0f);
				val.SetVector("_ColorAddSubDiff", Vector4.zero);
				string[] shaderKeywords = val.shaderKeywords;
				foreach (string text in shaderKeywords)
				{
					val.DisableKeyword(text);
				}
				val.EnableKeyword("_ALPHABLEND_ON");
				if (fadeNearCamera)
				{
					val.SetFloat("_SoftParticlesEnabled", 1f);
					val.SetFloat("_SoftParticlesNearFadeDistance", 0f);
					val.SetFloat("_SoftParticlesFarFadeDistance", 0.2f);
					val.SetVector("_SoftParticleFadeParams", new Vector4(0f, 5f, 0f, 0f));
					val.SetFloat("_CameraFadingEnabled", 1f);
					val.SetFloat("_CameraNearFadeDistance", 0.5f);
					val.SetFloat("_CameraFarFadeDistance", 1.8f);
					val.SetVector("_CameraFadeParams", new Vector4(0.5f, 0.7692308f, 0f, 0f));
					val.EnableKeyword("_FADING_ON");
				}
				else
				{
					val.SetFloat("_SoftParticlesEnabled", 0f);
					val.SetVector("_SoftParticleFadeParams", Vector4.zero);
					val.SetFloat("_CameraFadingEnabled", 0f);
					val.SetVector("_CameraFadeParams", new Vector4(0f, float.PositiveInfinity, 0f, 0f));
				}
				val.renderQueue = 3000;
				Materials[key] = val;
				return val;
			}
		}

		public const string ShaderName = "Particles/Standard Unlit2";

		private const float Middle = 1f;

		private const float DesignSpeed = 0.75f;

		private const float PointSpeed = 0.8f;

		private static readonly Dictionary<string, Material> Materials = new Dictionary<string, Material>();

		public static GameObject Build(AuraDef def, Shader shader, AuraLook look)
		{
			return new Maker(def, shader, look).Run();
		}
	}
	internal enum AuraAccent
	{
		None,
		Petals,
		Smoke,
		Radiance,
		Stars
	}
	internal sealed class AuraDef
	{
		public string Key = "";

		public Color[] Palette = (Color[])(object)new Color[2]
		{
			Color.white,
			Color.white
		};

		public Color Spark = Color.white;

		public Color Glow = Color.white;

		public Color Gem = Color.white;

		public AuraAccent Accent;

		public bool Dark;

		public bool SilverBand;

		public List<(string Item, int Amount)> Recipe = new List<(string, int)>();

		public string AuraName => Key + " Aura";

		public string ItemId => "SkaAuraRing" + Key;

		public string ItemName => Key + " Aura Ring";

		public string Description => "A ring that wraps its wearer in " + ((Key == "Emerald" || Key == "Amethyst" || Key == "Orange" || Key == "Indigo") ? "an " : "a ") + Key.ToLowerInvariant() + " aura.";

		public string NameToken => "item_" + ItemId.ToLowerInvariant();

		public string DescriptionToken => NameToken + "_description";
	}
	internal static class AuraDefs
	{
		public static readonly AuraDef[] All = Build();

		private static Color Hex(uint rgb)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			return new Color((float)((rgb >> 16) & 0xFF) / 255f, (float)((rgb >> 8) & 0xFF) / 255f, (float)(rgb & 0xFF) / 255f, 1f);
		}

		private static AuraDef Aura(string key, uint main, uint second, uint spark, params (string Item, int Amount)[] colourIngredients)
		{
			//IL_0017: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			AuraDef auraDef = new AuraDef();
			auraDef.Key = key;
			auraDef.Palette = (Color[])(object)new Color[2]
			{
				Hex(main),
				Hex(second)
			};
			auraDef.Spark = Hex(spark);
			auraDef.Glow = Hex(main);
			auraDef.Gem = Hex(main);
			auraDef.Recipe.Add(("Coins", 200));
			auraDef.Recipe.Add(("SurtlingCore", 1));
			auraDef.Recipe.AddRange(colourIngredients);
			return auraDef;
		}

		private static AuraDef Silvered(AuraDef def)
		{
			def.SilverBand = true;
			return def;
		}

		private static AuraDef With(AuraDef def, AuraAccent accent)
		{
			def.Accent = accent;
			return def;
		}

		private static AuraDef[] Build()
		{
			//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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cc: 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_00dd: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: 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_0158: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_016d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0216: Unknown result type (might be due to invalid IL or missing references)
			AuraDef auraDef = With(Aura("Black", 2363958u, 787986u, 10506495u, ("Obsidian", 10), ("Coal", 10)), AuraAccent.Smoke);
			auraDef.Dark = true;
			auraDef.Glow = Hex(8007896u);
			auraDef.Gem = Hex(3807344u);
			auraDef.SilverBand = true;
			AuraDef auraDef2 = Aura("Rainbow", 16724032u, 16724032u, 16777215u, ("Crystal", 5), ("AmberPearl", 5));
			auraDef2.Palette = (Color[])(object)new Color[8]
			{
				Hex(16724032u),
				Hex(16748576u),
				Hex(16769072u),
				Hex(4253792u),
				Hex(3199231u),
				Hex(4219135u),
				Hex(11555071u),
				Hex(16728256u)
			};
			auraDef2.Glow = Hex(15255807u);
			auraDef2.Gem = Hex(15790335u);
			AuraDef auraDef3 = With(Aura("Celestial", 9218303u, 16767120u, 16777215u, ("DragonTear", 1), ("Crystal", 5)), AuraAccent.Stars);
			auraDef3.Palette = (Color[])(object)new Color[3]
			{
				Hex(9218303u),
				Hex(16777215u),
				Hex(16767120u)
			};
			auraDef3.Glow = Hex(7375103u);
			auraDef3.Gem = Hex(13161727u);
			auraDef3.SilverBand = true;
			return new AuraDef[20]
			{
				Aura("Golden", 16761134u, 16771488u, 16774344u, ("Amber", 5)),
				Silvered(Aura("Silver", 12897514u, 16777215u, 16777215u, ("Silver", 2))),
				Aura("Emerald", 2285670u, 11075524u, 14221284u, ("Guck", 5)),
				Aura("Ruby", 16722498u, 16747672u, 16765140u, ("Ruby", 3)),
				Aura("Amethyst", 11816447u, 14987519u, 16047359u, ("Thistle", 10)),
				Aura("Sapphire", 3107839u, 9484543u, 13952255u, ("Blueberries", 20)),
				Aura("Topaz", 16752676u, 16766088u, 16772296u, ("Cloudberry", 10)),
				Aura("Turquoise", 2677992u, 11073791u, 14482687u, ("FreezeGland", 5)),
				With(Aura("Rose", 16738996u, 16761054u, 16770288u, ("Raspberry", 20)), AuraAccent.Petals),
				Aura("Violet", 8146175u, 12363007u, 14734591u, ("GreydwarfEye", 20)),
				Aura("Cyan", 3196159u, 11069695u, 14481151u, ("Crystal", 5)),
				Aura("Orange", 16741400u, 16758912u, 16769220u, ("Carrot", 10)),
				Aura("Indigo", 4733183u, 9472255u, 13683967u, ("MushroomBlue", 5)),
				Aura("Teal", 1103012u, 8454108u, 13697008u, ("Chitin", 10)),
				Aura("Magenta", 16724184u, 16750828u, 16766200u, ("Bloodbag", 5)),
				Aura("Lime", 10813208u, 14483344u, 15794128u, ("Ooze", 5)),
				Silvered(With(Aura("White", 16777215u, 14214399u, 16777215u, ("AmberPearl", 5)), AuraAccent.Radiance)),
				auraDef,
				auraDef2,
				auraDef3
			};
		}
	}
	internal sealed class AuraDiagnostics : MonoBehaviour
	{
		private const float SettleSeconds = 3f;

		private const float CheckSeconds = 0.5f;

		private const float WornReportDelay = 4f;

		private Player? _player;

		private float _readyAt;

		private float _nextCheck;

		private bool _introDone;

		private string _worn = "";

		private float _wornReportAt = float.MaxValue;

		public bool LogState { get; set; }

		public bool GiveItems { get; set; }

		private void Update()
		{
			if (!LogState && !GiveItems)
			{
				return;
			}
			float unscaledTime = Time.unscaledTime;
			if (unscaledTime < _nextCheck)
			{
				return;
			}
			_nextCheck = unscaledTime + 0.5f;
			Player localPlayer = Player.m_localPlayer;
			if (!Object.op_Implicit((Object)(object)localPlayer))
			{
				_player = null;
				return;
			}
			if ((Object)(object)localPlayer != (Object)(object)_player)
			{
				_player = localPlayer;
				_readyAt = unscaledTime + 3f;
				_introDone = false;
				_worn = "";
				_wornReportAt = float.MaxValue;
			}
			if (unscaledTime < _readyAt || !Object.op_Implicit((Object)(object)ObjectDB.instance))
			{
				return;
			}
			try
			{
				if (!_introDone)
				{
					_introDone = true;
					if (LogState)
					{
						ReportRegistration();
					}
					if (GiveItems)
					{
						Give(localPlayer);
					}
				}
				if (LogState)
				{
					WatchWorn(localPlayer, unscaledTime);
				}
			}
			catch (Exception arg)
			{
				AurasPlugin.Log.LogError((object)$"[test] {arg}");
			}
		}

		private static void ReportRegistration()
		{
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			int num2 = 0;
			List<string> list = new List<string>();
			foreach (BuiltRing ring in AurasPlugin.Rings)
			{
				GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(ring.Def.ItemId);
				if (!Object.op_Implicit((Object)(object)itemPrefab))
				{
					list.Add(ring.Def.ItemId);
					continue;
				}
				num++;
				ItemDrop component = itemPrefab.GetComponent<ItemDrop>();
				if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)ObjectDB.instance.GetRecipe(component.m_itemData)))
				{
					num2++;
				}
			}
			AurasPlugin.Log.LogInfo((object)($"[test] {num} of {AuraDefs.All.Length} aura rings are in the item database, {num2} with a recipe" + ((list.Count > 0) ? ("; missing: " + string.Join(", ", list)) : "") + "."));
			BuiltRing builtRing = AurasPlugin.Rings.FirstOrDefault();
			if (builtRing == null)
			{
				return;
			}
			GameObject prefab = ObjectDB.instance.GetItemPrefab(builtRing.Def.ItemId);
			if (Object.op_Implicit((Object)(object)prefab))
			{
				string arg = string.Join(", ", from i in Enumerable.Range(0, prefab.transform.childCount)
					select ((Object)prefab.transform.GetChild(i)).name);
				AurasPlugin.Log.LogInfo((object)$"[test] {builtRing.Def.ItemId}: type {builtRing.Shared.m_itemType}, parts [{arg}].");
			}
		}

		private static void Give(Player player)
		{
			Inventory inventory = ((Humanoid)player).GetInventory();
			List<string> list = new List<string>();
			List<string> list2 = new List<string>();
			foreach (BuiltRing ring in AurasPlugin.Rings)
			{
				if (inventory.GetAllItems().Any((ItemData item) => Object.op_Implicit((Object)(object)item.m_dropPrefab) && ((Object)item.m_dropPrefab).name == ring.Def.ItemId))
				{
					continue;
				}
				GameObject itemPrefab = ObjectDB.instance.GetItemPrefab(ring.Def.ItemId);
				if (Object.op_Implicit((Object)(object)itemPrefab))
				{
					if (inventory.CanAddItem(itemPrefab, 1) && inventory.AddItem(itemPrefab, 1))
					{
						list.Add(ring.Def.Key);
					}
					else
					{
						list2.Add(ring.Def.Key);
					}
				}
			}
			if (list.Count > 0)
			{
				AurasPlugin.Log.LogInfo((object)string.Format("[test] Put {0} aura ring(s) in the inventory: {1}.", list.Count, string.Join(", ", list)));
			}
			if (list2.Count > 0)
			{
				AurasPlugin.Log.LogInfo((object)string.Format("[test] No room in the inventory for {0} aura ring(s): {1}.", list2.Count, string.Join(", ", list2)));
			}
		}

		private void WatchWorn(Player player, float now)
		{
			//IL_0169: 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_0172: 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_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: 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_022f: 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_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			ItemData val = ((IEnumerable<ItemData>)((Humanoid)player).GetInventory().GetEquippedItems()).FirstOrDefault((Func<ItemData, bool>)((ItemData item) => Object.op_Implicit((Object)(object)item.m_dropPrefab) && ((Object)item.m_dropPrefab).name.StartsWith("SkaAuraRing", StringComparison.Ordinal)));
			string text = ((val != null) ? ((Object)val.m_dropPrefab).name : "");
			if (text != _worn)
			{
				_worn = text;
				if (text == "")
				{
					_wornReportAt = float.MaxValue;
					int num = ((Component)player).GetComponentsInChildren<AuraAnchor>(true).Length;
					AurasPlugin.Log.LogInfo((object)$"[test] No aura ring worn. Auras left on the character: {num}.");
				}
				else
				{
					_wornReportAt = now + 4f;
				}
			}
			if (now < _wornReportAt)
			{
				return;
			}
			_wornReportAt = float.MaxValue;
			AuraAnchor[] componentsInChildren = ((Component)player).GetComponentsInChildren<AuraAnchor>(true);
			if (componentsInChildren.Length == 0)
			{
				AurasPlugin.Log.LogWarning((object)("[test] Wearing " + _worn + ", but no aura is on the character."));
				return;
			}
			AuraAnchor[] array = componentsInChildren;
			for (int num2 = 0; num2 < array.Length; num2++)
			{
				Transform transform = ((Component)array[num2]).transform;
				Transform parent = transform.parent;
				ParticleSystem[] componentsInChildren2 = ((Component)transform).GetComponentsInChildren<ParticleSystem>(true);
				ParticleSystemRenderer[] componentsInChildren3 = ((Component)transform).GetComponentsInChildren<ParticleSystemRenderer>(true);
				Material val2 = componentsInChildren3.Select((ParticleSystemRenderer renderer) => (!Object.op_Implicit((Object)(object)((Renderer)renderer).sharedMaterial)) ? renderer.trailMaterial : ((Renderer)renderer).sharedMaterial).FirstOrDefault((Func<Material, bool>)((Material found) => Object.op_Implicit((Object)(object)found)));
				Vector3 lossyScale = transform.lossyScale;
				Vector3 up = transform.up;
				AurasPlugin.Log.LogInfo((object)string.Format(CultureInfo.InvariantCulture, "[test] Wearing {0}. Aura hung on '{1}' as '{2}', active {3}, world size ({4:0.00}, {5:0.00}, {6:0.00}), {7:0.00} m from the character's feet, up ({8:0.00}, {9:0.00}, {10:0.00}); {11} particle systems, {12} playing, {13} particles alive, {14} of {15} renderers on screen; shader '{16}', supported {17}.", _worn, (Object.op_Implicit((Object)(object)parent) && Object.op_Implicit((Object)(object)parent.parent)) ? ((Object)parent.parent).name : "nothing", Object.op_Implicit((Object)(object)parent) ? ((Object)parent).name : "nothing", ((Component)transform).gameObject.activeInHierarchy, lossyScale.x, lossyScale.y, lossyScale.z, Vector3.Distance(transform.position, ((Component)player).transform.position), up.x, up.y, up.z, componentsInChildren2.Length, componentsInChildren2.Count((ParticleSystem system) => system.isPlaying), componentsInChildren2.Sum((ParticleSystem system) => system.particleCount), componentsInChildren3.Count((ParticleSystemRenderer renderer) => ((Renderer)renderer).isVisible), componentsInChildren3.Length, Object.op_Implicit((Object)(object)val2) ? ((Object)val2.shader).name : "none", Object.op_Implicit((Object)(object)val2) && val2.shader.isSupported));
			}
			ReportFinger(player);
		}

		private void ReportFinger(Player player)
		{
			//IL_015f: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: 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_01c6: 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_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			BodyFit[] componentsInChildren = ((Component)player).GetComponentsInChildren<BodyFit>(true);
			if (componentsInChildren.Length == 0)
			{
				AurasPlugin.Log.LogWarning((object)("[test] Wearing " + _worn + ", but no ring is on the finger."));
				return;
			}
			BuiltRing builtRing = AurasPlugin.Rings.FirstOrDefault((BuiltRing ring) => ring.Def.ItemId == _worn);
			VisEquipment component = ((Component)player).GetComponent<VisEquipment>();
			BodyFit[] array = componentsInChildren;
			foreach (BodyFit bodyFit in array)
			{
				Transform transform = ((Component)bodyFit).transform;
				Transform parent = transform.parent;
				Transform val = (Object.op_Implicit((Object)(object)parent) ? parent.parent : null);
				Renderer[] componentsInChildren2 = ((Component)transform).GetComponentsInChildren<Renderer>(false);
				string text = "nothing of it is switched on";
				if (componentsInChildren2.Length != 0 && Object.op_Implicit((Object)(object)val))
				{
					Bounds bounds = componentsInChildren2[0].bounds;
					Renderer[] array2 = componentsInChildren2;
					foreach (Renderer val2 in array2)
					{
						((Bounds)(ref bounds)).Encapsulate(val2.bounds);
					}
					text = string.Format(CultureInfo.InvariantCulture, "its middle is {0:0} mm from the bone", Vector3.Distance(((Bounds)(ref bounds)).center, val.position) * 1000f);
					if (builtRing != null && builtRing.Placed && builtRing.ModelCentres.TryGetValue(bodyFit.Shown, out var value))
					{
						text += string.Format(CultureInfo.InvariantCulture, " (built for {0:0} mm)", Vector3.Distance(value, builtRing.JointPosition) * 1000f);
					}
				}
				Vector3 lossyScale = transform.lossyScale;
				AurasPlugin.Log.LogInfo((object)string.Format(CultureInfo.InvariantCulture, "[test] Ring hung on '{0}' as '{1}', active {2}, world size ({3:0.00}, {4:0.00}, {5:0.00}). Body shape {6}, model '{7}' shown, {8} part(s), {9} on screen; {10}.", Object.op_Implicit((Object)(object)val) ? ((Object)val).name : "nothing", Object.op_Implicit((Object)(object)parent) ? ((Object)parent).name : "nothing", ((Component)transform).gameObject.activeInHierarchy, lossyScale.x, lossyScale.y, lossyScale.z, Object.op_Implicit((Object)(object)component) ? component.GetModelIndex() : (-1), bodyFit.Shown, componentsInChildren2.Length, componentsInChildren2.Count((Renderer part) => part.isVisible), text));
			}
		}
	}
	[BepInPlugin("com.skaket.valheim.auras", "Aura Rings", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	public class AurasPlugin : BaseUnityPlugin
	{
		public const string PluginGuid = "com.skaket.valheim.auras";

		public const string PluginName = "Aura Rings";

		public const string PluginVersion = "1.0.0";

		internal static ManualLogSource Log = null;

		internal static readonly List<BuiltRing> Rings = new List<BuiltRing>();

		private ConfigEntry<float> _brightness;

		private ConfigEntry<float> _density;

		private ConfigEntry<float> _speed;

		private ConfigEntry<float> _light;

		private ConfigEntry<bool> _diagnostics;

		private ConfigEntry<bool> _giveItems;

		private Shader? _particleShader;

		private void Awake()
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Expected O, but got Unknown
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Expected O, but got Unknown
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			_brightness = ((BaseUnityPlugin)this).Config.Bind<float>("Look", "Brightness", 1f, new ConfigDescription("How bright the light of every aura is: 1 as designed, 0.5 half as bright on screen, 2 much brighter. Only on this computer. An aura already worn changes when its ring is next put on.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 3f), Array.Empty<object>()));
			_density = ((BaseUnityPlugin)this).Config.Bind<float>("Look", "Density", 1f, new ConfigDescription("How much mist and how many points of light an aura has: 1 as designed, 0.5 half as much, 2 twice as much. Only on this computer. An aura already worn changes when its ring is next put on.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.25f, 3f), Array.Empty<object>()));
			_speed = ((BaseUnityPlugin)this).Config.Bind<float>("Look", "Speed", 1f, new ConfigDescription("How fast everything in an aura moves: 1 as designed, 0.5 half as fast, 2 twice as fast. The whole aura is slowed together, so it keeps its shape and its amount of mist and light; a slower aura also takes longer to build when the ring is put on. Only on this computer. An aura already worn changes when its ring is next put on.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.2f, 2f), Array.Empty<object>()));
			_light = ((BaseUnityPlugin)this).Config.Bind<float>("Look", "Light", 0f, new ConfigDescription("Strength of a real light at the wearer, in the aura's colour, which lights the ground and things within a few metres. 0 is none: an aura then glows without lighting its surroundings. Try 0.5 to 1.5. Only on this computer. An aura already worn changes when its ring is next put on.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), Array.Empty<object>()));
			_diagnostics = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "Diagnostics", false, "Write test lines to the log: whether the rings and recipes exist, and for a worn ring what the game hung on the character, where, at what size, and how many particles it is drawing. Takes effect on the next launch.");
			_giveItems = ((BaseUnityPlugin)this).Config.Bind<bool>("Debug", "GiveItemsOnSpawn", false, "On entering a world, put one of each aura ring into the inventory if the character has none, as far as there is room. For testing how an aura looks without crafting its ring. Takes effect on the next launch.");
			_brightness.SettingChanged += delegate
			{
				RebuildAuras();
			};
			_density.SettingChanged += delegate
			{
				RebuildAuras();
			};
			_speed.SettingChanged += delegate
			{
				RebuildAuras();
			};
			_light.SettingChanged += delegate
			{
				RebuildAuras();
			};
			AuraDiagnostics auraDiagnostics = ((Component)this).gameObject.AddComponent<AuraDiagnostics>();
			auraDiagnostics.LogState = _diagnostics.Value;
			auraDiagnostics.GiveItems = _giveItems.Value;
			AddTranslations();
			PrefabManager.OnVanillaPrefabsAvailable += AddItems;
			ItemManager.OnItemsRegistered += PlaceRings;
		}

		private AuraLook Look()
		{
			return new AuraLook
			{
				Brightness = _brightness.Value,
				Density = _density.Value,
				Speed = _speed.Value,
				Light = _light.Value
			};
		}

		private static void AddTranslations()
		{
			Dictionary<string, string> dictionary = new Dictionary<string, string>();
			AuraDef[] all = AuraDefs.All;
			foreach (AuraDef auraDef in all)
			{
				dictionary[auraDef.NameToken] = auraDef.ItemName;
				dictionary[auraDef.DescriptionToken] = auraDef.Description;
			}
			CustomLocalization localization = LocalizationManager.Instance.GetLocalization();
			string text = "English";
			localization.AddTranslation(ref text, dictionary);
		}

		private void AddItems()
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			PrefabManager.OnVanillaPrefabsAvailable -= AddItems;
			_particleShader = RingFactory.FindParticleShader(out string source);
			if (!Object.op_Implicit((Object)(object)_particleShader))
			{
				Log.LogError((object)"The game's particle shader 'Particles/Standard Unlit2' was not found, so no aura rings were added. The game may have renamed it in an update.");
				return;
			}
			Log.LogInfo((object)($"Particle shader '{((Object)_particleShader).name}' from {source}, supported {_particleShader.isSupported}. " + $"The game's colour space is {QualitySettings.activeColorSpace}."));
			AuraLook auraLook = Look();
			AuraDef[] all = AuraDefs.All;
			foreach (AuraDef auraDef in all)
			{
				try
				{
					Rings.Add(RingFactory.Add(auraDef, _particleShader, auraLook));
				}
				catch (Exception arg)
				{
					Log.LogError((object)$"{auraDef.ItemId} was not added: {arg}");
				}
			}
			Log.LogInfo((object)$"{Rings.Count} of {AuraDefs.All.Length} aura rings added. Brightness {auraLook.Brightness:0.##}, density {auraLook.Density:0.##}, speed {auraLook.Speed:0.##}, light {auraLook.Light:0.##}.");
			PlaceRings();
		}

		private void PlaceRings()
		{
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: 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_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			int num2 = 0;
			string problem = "";
			BuiltRing builtRing = null;
			foreach (BuiltRing ring in Rings)
			{
				if (ring.Placed)
				{
					continue;
				}
				try
				{
					if (RingFactory.Place(ring, out problem))
					{
						num++;
						builtRing = ring;
					}
					else
					{
						num2++;
					}
				}
				catch (Exception arg)
				{
					Log.LogError((object)string.Format("{0}: its ring could not be set against {1}: {2}", ring.Def.ItemId, "LeftHandRing1", arg));
				}
			}
			if (builtRing != null)
			{
				Vector3 jointPosition = builtRing.JointPosition;
				List<string> list = new List<string>();
				foreach (KeyValuePair<string, Vector3> modelCentre in builtRing.ModelCentres)
				{
					list.Add($"{modelCentre.Key} {Vector3.Distance(modelCentre.Value, jointPosition) * 1000f:0} mm");
				}
				Log.LogInfo((object)(string.Format("{0} ring(s) set against {1}, which rests at ({2:0.000}, {3:0.000}, {4:0.000}) in the ", num, "LeftHandRing1", jointPosition.x, jointPosition.y, jointPosition.z) + "character's space; the ring's middle is this far from it: " + string.Join(", ", list) + "."));
			}
			if (num2 > 0)
			{
				if (Object.op_Implicit((Object)(object)ZNetScene.instance))
				{
					Log.LogError((object)string.Format("{0} ring(s) could not be set against {1}: {2}. They will not show in the right place on the finger.", num2, "LeftHandRing1", problem));
				}
				else
				{
					Log.LogInfo((object)string.Format("{0} ring(s) not set against {1} yet ({2}); trying again when a world loads.", num2, "LeftHandRing1", problem));
				}
			}
		}

		private void RebuildAuras()
		{
			if (!Object.op_Implicit((Object)(object)_particleShader) || Rings.Count == 0)
			{
				return;
			}
			AuraLook auraLook = Look();
			int num = 0;
			foreach (BuiltRing ring in Rings)
			{
				try
				{
					RingFactory.SetAura(ring, _particleShader, auraLook);
					num++;
				}
				catch (Exception arg)
				{
					Log.LogError((object)$"{ring.Def.ItemId}: its aura could not be rebuilt: {arg}");
				}
			}
			Log.LogInfo((object)($"{num} auras rebuilt: brightness {auraLook.Brightness:0.##}, density {auraLook.Density:0.##}, speed {auraLook.Speed:0.##}, light {auraLook.Light:0.##}. " + "Take a ring off and put it on again to see the change."));
		}
	}
	internal static class AuraTextures
	{
		private static Texture2D? _glow;

		private static Texture2D? _star;

		private static Texture2D? _petal;

		private static Texture2D? _smoke;

		private static Texture2D? _circle;

		public static Texture2D Glow
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)_glow))
				{
					return _glow = Make("aura_glow", 128, 128, delegate(float x, float y)
					{
						float num = Mathf.Sqrt(x * x + y * y);
						return Mathf.Exp((0f - num) * num * 4.5f) * Edge(num);
					});
				}
				return _glow;
			}
		}

		public static Texture2D Star
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)_star))
				{
					return _star = Make("aura_star", 64, 64, delegate(float x, float y)
					{
						float num = Mathf.Sqrt(x * x + y * y);
						float num2 = Mathf.Exp((0f - num) * num * 60f);
						float num3 = Mathf.Max(Ray(x, y, 34f, 2.2f), Ray(y, x, 34f, 2.2f));
						float num4 = 0.18f * Mathf.Exp((0f - num) * num * 8f);
						return Mathf.Clamp01(num2 + num3 + num4) * Edge(num);
					});
				}
				return _star;
			}
		}

		public static Texture2D Petal
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)_petal))
				{
					return _petal = Make("aura_petal", 32, 32, delegate(float x, float y)
					{
						float num = (y + 0.9f) / 1.8f;
						if (num <= 0f || num >= 1f)
						{
							return 0f;
						}
						float num2 = 0.62f * Mathf.Pow(Mathf.Sin((float)Math.PI * Mathf.Pow(num, 0.75f)), 0.8f);
						return Mathf.Clamp01((num2 - Mathf.Abs(x)) / 0.12f) * (0.75f + 0.25f * Mathf.Clamp01(Mathf.Abs(x) / Mathf.Max(num2, 0.01f)));
					});
				}
				return _petal;
			}
		}

		public static Texture2D Smoke
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)_smoke))
				{
					return _smoke = Make("aura_smoke", 128, 128, delegate(float x, float y)
					{
						float num = Mathf.Sqrt(x * x + y * y);
						float num2 = 0.5f * Noise(x * 2.2f + 7.3f, y * 2.2f + 1.9f) + 0.3f * Noise(x * 4.6f + 3.1f, y * 4.6f + 8.4f) + 0.2f * Noise(x * 9.4f, y * 9.4f + 5.5f);
						float num3 = Mathf.Clamp01(1.25f - num * 1.35f - 0.55f * (1f - num2));
						return num3 * num3 * Edge(num);
					});
				}
				return _smoke;
			}
		}

		public static Texture2D Circle
		{
			get
			{
				if (!Object.op_Implicit((Object)(object)_circle))
				{
					return _circle = Make("aura_circle", 128, 128, delegate(float x, float y)
					{
						float r = Mathf.Sqrt(x * x + y * y);
						return Mathf.Clamp01(Band(r, 0.88f, 0.016f) + 0.22f * Band(r, 0.88f, 0.07f)) * Edge(r);
					});
				}
				return _circle;
			}
		}

		private static float Edge(float r)
		{
			float num = Mathf.Clamp01((r - 0.86f) / 0.14f);
			return 1f - num * num * (3f - 2f * num);
		}

		private static float Band(float r, float at, float width)
		{
			float num = (r - at) / width;
			return Mathf.Exp((0f - num) * num);
		}

		private static float Ray(float along, float across, float thin, float fade)
		{
			return Mathf.Exp((0f - Mathf.Abs(across)) * thin) * Mathf.Exp((0f - along) * along * fade);
		}

		private static float Noise(float x, float y)
		{
			int num = Mathf.FloorToInt(x);
			int num2 = Mathf.FloorToInt(y);
			float num3 = x - (float)num;
			float num4 = y - (float)num2;
			num3 = num3 * num3 * (3f - 2f * num3);
			num4 = num4 * num4 * (3f - 2f * num4);
			float num5 = Hash(num, num2);
			float num6 = Hash(num + 1, num2);
			float num7 = Hash(num, num2 + 1);
			float num8 = Hash(num + 1, num2 + 1);
			return Mathf.Lerp(Mathf.Lerp(num5, num6, num3), Mathf.Lerp(num7, num8, num3), num4);
		}

		private static float Hash(int x, int y)
		{
			int num = x * 374761393 + y * 668265263;
			int num2 = (num ^ (num >>> 13)) * 1274126177;
			return (float)(uint)((num2 ^ (num2 >>> 16)) & 0xFFFF) / 65535f;
		}

		private static Texture2D Make(string name, int width, int height, Func<float, float, float> alpha)
		{
			//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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Expected O, but got Unknown
			//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)
			Color32[] array = (Color32[])(object)new Color32[width * height];
			for (int i = 0; i < height; i++)
			{
				float arg = ((float)i + 0.5f) / (float)height * 2f - 1f;
				for (int j = 0; j < width; j++)
				{
					float arg2 = ((float)j + 0.5f) / (float)width * 2f - 1f;
					array[i * width + j] = new Color32(byte.MaxValue, byte.MaxValue, byte.MaxValue, (byte)Mathf.RoundToInt(Mathf.Clamp01(alpha(arg2, arg)) * 255f));
				}
			}
			Texture2D val = new Texture2D(width, height, (TextureFormat)4, true)
			{
				name = name,
				wrapMode = (TextureWrapMode)1,
				filterMode = (FilterMode)2,
				hideFlags = (HideFlags)32
			};
			val.SetPixels32(array);
			val.Apply(true, true);
			return val;
		}
	}
	internal sealed class BodyFit : MonoBehaviour
	{
		public const string First = "model";

		public const string Second = "model_F";

		public const string Slim = "model_FF";

		private const string FeminineFigureGuid = "com.skaket.valheim.femininefigure";

		private const float CheckSeconds = 1f;

		private static bool? _feminineFigure;

		private VisEquipment? _equipment;

		private float _nextCheck;

		public string Shown { get; private set; } = "model";

		internal static bool FeminineFigureInstalled
		{
			get
			{
				if (!_feminineFigure.HasValue)
				{
					_feminineFigure = Chainloader.PluginInfos.ContainsKey("com.skaket.valheim.femininefigure");
				}
				return _feminineFigure.Value;
			}
		}

		public static string Pick(Transform holder, int bodyShape)
		{
			if (bodyShape != 1)
			{
				return "model";
			}
			if (FeminineFigureInstalled && Object.op_Implicit((Object)(object)holder.Find("model_FF")))
			{
				return "model_FF";
			}
			if (!Object.op_Implicit((Object)(object)holder.Find("model_F")))
			{
				return "model";
			}
			return "model_F";
		}

		private void OnEnable()
		{
			Apply();
		}

		private void Update()
		{
			if (Time.unscaledTime >= _nextCheck)
			{
				Apply();
			}
		}

		private void Apply()
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			_nextCheck = Time.unscaledTime + 1f;
			if (!Object.op_Implicit((Object)(object)_equipment))
			{
				_equipment = ((Component)this).GetComponentInParent<VisEquipment>();
			}
			Shown = Pick(((Component)this).transform, Object.op_Implicit((Object)(object)_equipment) ? _equipment.GetModelIndex() : 0);
			foreach (Transform item in ((Component)this).transform)
			{
				Transform val = item;
				bool flag = ((Object)val).name == Shown;
				if (((Component)val).gameObject.activeSelf != flag)
				{
					((Component)val).gameObject.SetActive(flag);
				}
			}
		}
	}
	internal sealed class BuiltRing
	{
		public AuraDef Def;

		public GameObject Prefab;

		public SharedData Shared;

		public Transform Worn;

		public int ParticleSystems;

		public Transform FingerVisual;

		public readonly Dictionary<string, Vector3> ModelCentres = new Dictionary<string, Vector3>();

		public bool Placed;

		public Vector3 JointPosition;
	}
	internal static class RingFactory
	{
		private const string BasePrefab = "HelmetRootCrown";

		public const string Joint = "Armature";

		public const string FingerJoint = "LeftHandRing1";

		private const float GroundSize = 0.18f;

		private static readonly Quaternion IconRotation = Quaternion.Euler(18f, 0f, 0f) * Quaternion.Euler(0f, 28f, 0f);

		public static BuiltRing Add(AuraDef def, Shader particleShader, AuraLook look)
		{
			//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_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Expected O, but got Unknown
			//IL_0145: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Expected O, but got Unknown
			//IL_01a4: 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)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_022c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0251: Unknown result type (might be due to invalid IL or missing references)
			//IL_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: 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_0279: Expected O, but got Unknown
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_02fb: Expected O, but got Unknown
			//IL_0313: Unknown result type (might be due to invalid IL or missing references)
			//IL_0318: Unknown result type (might be due to invalid IL or missing references)
			//IL_0326: Expected O, but got Unknown
			//IL_038e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0393: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a1: Expected O, but got Unknown
			//IL_03d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03dd: Unknown result type (might be due to invalid IL or missing references)
			ItemConfig val = new ItemConfig
			{
				Name = "$" + def.NameToken,
				Description = "$" + def.DescriptionToken,
				CraftingStation = CraftingStations.Forge
			};
			foreach (var (text, num) in def.Recipe)
			{
				val.AddRequirement(text, num, 0);
			}
			CustomItem val2 = new CustomItem(def.ItemId, "HelmetRootCrown", val);
			GameObject itemPrefab = val2.ItemPrefab;
			if (!Object.op_Implicit((Object)(object)itemPrefab))
			{
				throw new InvalidOperationException("Could not clone HelmetRootCrown.");
			}
			Transform val3 = itemPrefab.transform.Find("attach");
			if (!Object.op_Implicit((Object)(object)val3))
			{
				throw new InvalidOperationException("HelmetRootCrown has no 'attach' child.");
			}
			MeshRenderer componentInChildren = ((Component)val3).GetComponentInChildren<MeshRenderer>(true);
			Shader val4 = ((Object.op_Implicit((Object)(object)componentInChildren) && Object.op_Implicit((Object)(object)((Renderer)componentInChildren).sharedMaterial)) ? ((Renderer)componentInChildren).sharedMaterial.shader : null);
			if (!Object.op_Implicit((Object)(object)val4))
			{
				throw new InvalidOperationException("HelmetRootCrown has no mesh material to take the game's shader from.");
			}
			for (int num2 = val3.childCount - 1; num2 >= 0; num2--)
			{
				Object.DestroyImmediate((Object)(object)((Component)val3.GetChild(num2)).gameObject);
			}
			val3.localPosition = Vector3.zero;
			val3.localRotation = Quaternion.identity;
			val3.localScale = Vector3.one;
			RingModel.Materials materials = RingModel.MaterialsFor(val4, def);
			GameObject val5 = new GameObject("visual")
			{
				layer = itemPrefab.layer
			};
			val5.transform.SetParent(val3, false);
			Bounds val6 = RingModel.Build(val5.transform, materials, itemPrefab.layer);
			float num3 = Mathf.Max(new float[3]
			{
				((Bounds)(ref val6)).size.x,
				((Bounds)(ref val6)).size.y,
				((Bounds)(ref val6)).size.z
			});
			float num4 = ((num3 < 0.18f) ? (0.18f / num3) : 1f);
			val5.transform.localScale = Vector3.one * num4;
			val5.transform.localPosition = -((Bounds)(ref val6)).center * num4;
			BoxCollider obj = val5.AddComponent<BoxCollider>();
			obj.center = ((Bounds)(ref val6)).center;
			obj.size = Vector3.Max(((Bounds)(ref val6)).size, Vector3.one * (0.03f / num4));
			GameObject val7 = new GameObject("attach_Armature");
			val7.transform.SetParent(itemPrefab.transform, false);
			val7.SetActive(false);
			SharedData shared = val2.ItemDrop.m_itemData.m_shared;
			shared.m_itemType = (ItemType)18;
			shared.m_armor = 0f;
			shared.m_armorPerLevel = 0f;
			shared.m_maxQuality = 1;
			shared.m_weight = 0.1f;
			shared.m_useDurability = false;
			GameObject val8 = new GameObject("attach_LeftHandRing1")
			{
				layer = itemPrefab.layer
			};
			val8.transform.SetParent(itemPrefab.transform, false);
			GameObject val9 = new GameObject("visual")
			{
				layer = itemPrefab.layer
			};
			val9.transform.SetParent(val8.transform, false);
			BuiltRing builtRing = new BuiltRing
			{
				Def = def,
				Prefab = itemPrefab,
				Shared = shared,
				Worn = val7.transform,
				FingerVisual = val9.transform
			};
			RingFit[] all = RingFits.All;
			foreach (RingFit ringFit in all)
			{
				GameObject val10 = new GameObject(ringFit.Name)
				{
					layer = itemPrefab.layer
				};
				val10.transform.SetParent(val9.transform, false);
				Dictionary<string, Vector3> modelCentres = builtRing.ModelCentres;
				string name = ringFit.Name;
				Bounds val11 = RingModel.BuildWorn(val10.transform, ringFit, materials, itemPrefab.layer);
				modelCentres[name] = ((Bounds)(ref val11)).center;
				val10.SetActive(ringFit.Name == "model");
			}
			val9.AddComponent<BodyFit>();
			val8.SetActive(false);
			SetAura(builtRing, particleShader, look);
			Sprite val12 = RenderIcon(val3, def.ItemId);
			if (Object.op_Implicit((Object)(object)val12))
			{
				shared.m_icons = (Sprite[])(object)new Sprite[1] { val12 };
			}
			else
			{
				AurasPlugin.Log.LogWarning((object)(def.ItemId + ": the icon could not be rendered; it keeps the HelmetRootCrown icon."));
			}
			if (!ItemManager.Instance.AddItem(val2))
			{
				throw new InvalidOperationException("Jotunn refused to add " + def.ItemId + ".");
			}
			AurasPlugin.Log.LogInfo((object)("Added " + def.ItemId + " (" + def.ItemName + "): a Utility item, its aura hung on Armature, " + string.Format("{0} particle systems, accent {1}, its ring worn on {2} and fitted to ", builtRing.ParticleSystems, def.Accent, "LeftHandRing1") + string.Format("{0} body shape(s) [{1}], ring shown {2:0.#} times larger on the ground, ", builtRing.ModelCentres.Count, string.Join(", ", builtRing.ModelCentres.Keys), num4) + "icon " + (Object.op_Implicit((Object)(object)val12) ? "rendered" : "vanilla")));
			return builtRing;
		}

		public static bool Place(BuiltRing ring, out string problem)
		{
			//IL_0013: 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_0020: 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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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_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)
			if (!Skeleton.TryGetRestPose("LeftHandRing1", out var position, out var rotation, out problem))
			{
				return false;
			}
			Quaternion val = Quaternion.Inverse(rotation);
			ring.FingerVisual.localRotation = val;
			ring.FingerVisual.localPosition = val * -position;
			ring.FingerVisual.localScale = Vector3.one;
			ring.JointPosition = position;
			ring.Placed = true;
			return true;
		}

		public static void SetAura(BuiltRing ring, Shader particleShader, AuraLook look)
		{
			for (int num = ring.Worn.childCount - 1; num >= 0; num--)
			{
				Object.DestroyImmediate((Object)(object)((Component)ring.Worn.GetChild(num)).gameObject);
			}
			GameObject val = AuraBuilder.Build(ring.Def, particleShader, look);
			val.transform.SetParent(ring.Worn, false);
			val.AddComponent<AuraAnchor>();
			ring.ParticleSystems = val.GetComponentsInChildren<ParticleSystem>(true).Length;
		}

		private static Sprite? RenderIcon(Transform attach, string name)
		{
			//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_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			GameObject val = Object.Instantiate<GameObject>(((Component)attach).gameObject);
			try
			{
				((Object)val).name = name;
				RenderRequest val2 = new RenderRequest(val)
				{
					Rotation = IconRotation,
					DistanceMultiplier = 0.9f
				};
				return RenderManager.Instance.Render(val2);
			}
			catch (Exception ex)
			{
				AurasPlugin.Log.LogWarning((object)("Icon render for " + name + " failed: " + ex.Message));
				return null;
			}
			finally
			{
				Object.DestroyImmediate((Object)(object)val);
			}
		}

		public static Shader? FindParticleShader(out string source)
		{
			string[] array = new string[5] { "vfx_Potion_health_medium", "vfx_Potion_stamina_medium", "vfx_StaffShield", "vfx_GoblinShield", "vfx_Firework_Sparkler" };
			foreach (string text in array)
			{
				GameObject prefab = PrefabManager.Instance.GetPrefab(text);
				if (!Object.op_Implicit((Object)(object)prefab))
				{
					continue;
				}
				Renderer[] componentsInChildren = prefab.GetComponentsInChildren<Renderer>(true);
				for (int j = 0; j < componentsInChildren.Length; j++)
				{
					Material[] sharedMaterials = componentsInChildren[j].sharedMaterials;
					foreach (Material val in sharedMaterials)
					{
						if (Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.shader) && ((Object)val.shader).name == "Particles/Standard Unlit2")
						{
							source = "material '" + ((Object)val).name + "' of the game's " + text;
							return val.shader;
						}
					}
				}
			}
			Shader val2 = ((IEnumerable<Shader>)Resources.FindObjectsOfTypeAll<Shader>()).FirstOrDefault((Func<Shader, bool>)((Shader shader) => ((Object)shader).name == "Particles/Standard Unlit2" && shader.isSupported));
			source = (Object.op_Implicit((Object)(object)val2) ? "the shaders in memory, by name" : "nowhere");
			if (!Object.op_Implicit((Object)(object)val2))
			{
				return null;
			}
			return val2;
		}
	}
	internal sealed class RingFit
	{
		public string Name = "";

		public string Body = "";

		public Vector3 Centre;

		public Vector3 Axis;

		public Vector3 Top;

		public Vector3 Side;

		public float[] Radii = new float[0];
	}
	internal static class RingFits
	{
		public static readonly RingFit[] All = new RingFit[3]
		{
			new RingFit
			{
				Name = "model",
				Body = "body",
				Centre = new Vector3(-0.61691f, 0.94004f, -0.07649f),
				Axis = new Vector3(-0.66288f, -0.74842f, 0.02138f),
				Top = new Vector3(-0.74859f, 0.66304f, -0f),
				Side = new Vector3(0.01418f, 0.01601f, 0.99977f),
				Radii = new float[32]
				{
					0.02297f, 0.02432f, 0.02627f, 0.02193f, 0.01838f, 0.01604f, 0.0147f, 0.01405f, 0.01396f, 0.0144f,
					0.01549f, 0.0172f, 0.01924f, 0.01737f, 0.01614f, 0.01563f, 0.0157f, 0.01627f, 0.01746f, 0.01925f,
					0.01943f, 0.01751f, 0.