Decompiled source of Huntress Domain Expansion v1.0.1

plugins/HuntressDomainExpansion/HuntressDomainExpansion.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using RoR2;
using RoR2.ContentManagement;
using RoR2.Projectile;
using RoR2.UI;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.Rendering.PostProcessing;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: AssemblyVersion("0.0.0.0")]
namespace SurvivorDomains;

internal sealed class BlackEnclosure : MonoBehaviour
{
	private Mesh mesh;

	private Material material;

	private MeshRenderer renderer;

	private Color[] colors;

	private bool depthWriting;

	internal static BlackEnclosure Create(Transform parent, float radius)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		GameObject val = new GameObject("Persistent black domain enclosure");
		val.transform.SetParent(parent, false);
		BlackEnclosure blackEnclosure = val.AddComponent<BlackEnclosure>();
		try
		{
			blackEnclosure.Build(radius);
			return blackEnclosure;
		}
		catch
		{
			Object.Destroy((Object)(object)val);
			throw;
		}
	}

	private void Build(float radius)
	{
		//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d0: Expected O, but got Unknown
		//IL_010b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_011b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0120: Unknown result type (might be due to invalid IL or missing references)
		//IL_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Unknown result type (might be due to invalid IL or missing references)
		material = DomainVisual.CreateGlowMaterial();
		((Object)material).name = "Opaque black domain exterior";
		material.SetInt("_SrcBlend", 5);
		material.SetInt("_DstBlend", 10);
		material.SetInt("_Cull", 2);
		material.SetInt("_ZWrite", 0);
		material.renderQueue = 3120;
		Vector3[] array = (Vector3[])(object)new Vector3[8385];
		Vector2[] uv = (Vector2[])(object)new Vector2[array.Length];
		colors = (Color[])(object)new Color[array.Length];
		int[] array2 = new int[49152];
		int num = 0;
		for (int i = 0; i <= 64; i++)
		{
			for (int j = 0; j <= 128; j++)
			{
				int num2 = i * 129 + j;
				float num3 = MathF.PI * (float)i / 64f;
				float num4 = MathF.PI * 2f * (float)j / 128f;
				ref Vector3 reference = ref array[num2];
				reference = new Vector3(Mathf.Sin(num3) * Mathf.Cos(num4), Mathf.Cos(num3), Mathf.Sin(num3) * Mathf.Sin(num4)) * radius * 1.001f;
				ref Color reference2 = ref colors[num2];
				reference2 = new Color(0f, 0f, 0f, 0f);
				if (i != 64 && j != 128)
				{
					int num5 = num2 + 128 + 1;
					array2[num++] = num2;
					array2[num++] = num2 + 1;
					array2[num++] = num5;
					array2[num++] = num2 + 1;
					array2[num++] = num5 + 1;
					array2[num++] = num5;
				}
			}
		}
		Mesh val = new Mesh();
		((Object)val).name = "Closed outward-facing black sphere";
		mesh = val;
		mesh.vertices = array;
		mesh.uv = uv;
		mesh.colors = colors;
		mesh.triangles = array2;
		mesh.RecalculateBounds();
		((Component)this).gameObject.AddComponent<MeshFilter>().sharedMesh = mesh;
		renderer = ((Component)this).gameObject.AddComponent<MeshRenderer>();
		((Renderer)renderer).sharedMaterial = material;
		((Renderer)renderer).shadowCastingMode = (ShadowCastingMode)0;
		((Renderer)renderer).receiveShadows = false;
	}

	internal void Draw(float fade)
	{
		//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)
		float num = Mathf.Clamp01(Plugin.BlackOpacity.Value) * Mathf.Clamp01(fade);
		((Renderer)renderer).enabled = num > 0.0001f;
		bool flag = num >= 0.9999f;
		if (depthWriting != flag)
		{
			depthWriting = flag;
			material.SetInt("_ZWrite", flag ? 1 : 0);
			material.renderQueue = (flag ? 2990 : 3120);
		}
		for (int i = 0; i < colors.Length; i++)
		{
			ref Color reference = ref colors[i];
			reference = new Color(0f, 0f, 0f, num);
		}
		mesh.colors = colors;
	}

	private void OnDestroy()
	{
		if (Object.op_Implicit((Object)(object)mesh))
		{
			Object.Destroy((Object)(object)mesh);
		}
		if (Object.op_Implicit((Object)(object)material))
		{
			Object.Destroy((Object)(object)material);
		}
	}
}
[HarmonyPatch(typeof(CharacterBody), "RecalculateStats")]
internal static class HuntressFrenzyStats
{
	private static void Postfix(CharacterBody __instance)
	{
		HuntressDomain component = ((Component)__instance).GetComponent<HuntressDomain>();
		if (Object.op_Implicit((Object)(object)component))
		{
			component.ApplyFrenzy();
		}
		DomainCombat.ApplySlow(__instance);
	}
}
internal static class CastTimeline
{
	internal static bool Reached(float distanceSquared, float radius)
	{
		if (radius > 0f)
		{
			return distanceSquared <= radius * radius;
		}
		return false;
	}

	internal static float Expansion(float age, float seconds)
	{
		float num = Math.Max(0f, Math.Min(1f, age / Math.Max(0.01f, seconds)));
		return num * num * (3f - 2f * num);
	}
}
internal static class ChargeRules
{
	internal static float Add(float charge, float dealt, float baseDamage, float multiplier)
	{
		if (float.IsNaN(dealt) || float.IsInfinity(dealt) || dealt <= 0f || baseDamage <= 0f || multiplier <= 0f)
		{
			return charge;
		}
		float num = charge + dealt / (baseDamage * multiplier);
		if (!(num >= 0.99999f))
		{
			return num;
		}
		return 1f;
	}
}
internal enum CosmicQuality
{
	Low,
	Balanced,
	High
}
internal static class CosmicTimeline
{
	internal const float VolleyPeriod = 2.8f;

	internal static int VolleyIndex(float activeAge)
	{
		if (!(activeAge < 1.15f))
		{
			return (int)Math.Floor((activeAge - 1.15f) / 2.8f);
		}
		return -1;
	}

	internal static float Volley(float activeAge)
	{
		if (VolleyIndex(activeAge) < 0)
		{
			return 0f;
		}
		float num = (activeAge - 1.15f) % 2.8f;
		return CastTimeline.Expansion(num, 0.1f) * (1f - CastTimeline.Expansion(num - 0.1f, 0.58f));
	}

	internal static float Anticipation(float activeAge)
	{
		if (activeAge < 0f)
		{
			return 0f;
		}
		float age = ((activeAge < 1.15f) ? (1.15f - activeAge) : (2.8f - (activeAge - 1.15f) % 2.8f));
		return 1f - CastTimeline.Expansion(age, 0.48f);
	}
}
internal sealed class CrystalBarrier : MonoBehaviour
{
	private const int Columns = 36;

	private const int Rows = 18;

	private const int Shards = 72;

	private Mesh facets;

	private Mesh cracks;

	private Material exterior;

	private Material interior;

	private Material edgeMaterial;

	private MeshRenderer outsideRenderer;

	private MeshRenderer insideRenderer;

	private MeshRenderer edgeRenderer;

	private Vector3[] rest;

	private Vector3[] vertices;

	private Vector3[] edgeVertices;

	private Vector3[] normals;

	private Color[] colors;

	private Color[] innerColors;

	private Color[] edgeColors;

	private Mesh insideMesh;

	private float[] wave;

	private float[] seed;

	private float radius;

	private bool cyan;

	private bool ice;

	private bool violet;

	private bool gold;

	private bool midnight;

	private float iceCollapse;

	private float iceStress;

	internal static CrystalBarrier Create(Transform parent, float radius, bool cyan = false, bool ice = false, bool violet = false, bool gold = false, bool midnight = false)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		GameObject val = new GameObject("Black crystalline formation");
		val.transform.SetParent(parent, false);
		CrystalBarrier crystalBarrier = val.AddComponent<CrystalBarrier>();
		crystalBarrier.radius = radius;
		crystalBarrier.midnight = midnight;
		crystalBarrier.gold = gold;
		crystalBarrier.violet = violet;
		crystalBarrier.cyan = cyan;
		crystalBarrier.ice = ice;
		try
		{
			crystalBarrier.Build();
			return crystalBarrier;
		}
		catch
		{
			Object.Destroy((Object)(object)val);
			throw;
		}
	}

	private Mesh MakeMesh(string name, Material material, out MeshRenderer renderer)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001f: Expected O, but got Unknown
		GameObject val = new GameObject(name);
		val.transform.SetParent(((Component)this).transform, false);
		Mesh val2 = new Mesh();
		((Object)val2).name = name;
		Mesh val3 = val2;
		val3.MarkDynamic();
		val.AddComponent<MeshFilter>().sharedMesh = val3;
		renderer = val.AddComponent<MeshRenderer>();
		((Renderer)renderer).sharedMaterial = material;
		((Renderer)renderer).shadowCastingMode = (ShadowCastingMode)0;
		((Renderer)renderer).receiveShadows = false;
		return val3;
	}

	private Vector3 Point(int x, int y)
	{
		//IL_0049: 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)
		float num = MathF.PI * (float)y / 18f;
		float num2 = MathF.PI * 2f * ((float)x + (float)(y % 2) * 0.32f) / 36f;
		return new Vector3(Mathf.Sin(num) * Mathf.Cos(num2), Mathf.Cos(num), Mathf.Sin(num) * Mathf.Sin(num2)) * radius;
	}

	private void Face(List<Vector3> list, Vector3 a, Vector3 b, Vector3 c)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Unknown result type (might be due to invalid IL or missing references)
		//IL_0009: Unknown result type (might be due to invalid IL or missing references)
		//IL_000a: Unknown result type (might be due to invalid IL or missing references)
		//IL_000f: 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_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: 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)
		//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_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: 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_0052: 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_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Unknown result type (might be due to invalid IL or missing references)
		Vector3 val = Vector3.Cross(b - a, c - a);
		if (!(((Vector3)(ref val)).sqrMagnitude < 0.0001f))
		{
			if (Vector3.Dot(Vector3.Cross(b - a, c - a), a + b + c) < 0f)
			{
				Vector3 val2 = b;
				b = c;
				c = val2;
			}
			list.Add(a);
			list.Add(b);
			list.Add(c);
		}
	}

	private void Build()
	{
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_0112: Unknown result type (might be due to invalid IL or missing references)
		//IL_0232: Unknown result type (might be due to invalid IL or missing references)
		//IL_0248: Unknown result type (might be due to invalid IL or missing references)
		//IL_024d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0263: Unknown result type (might be due to invalid IL or missing references)
		//IL_0268: Unknown result type (might be due to invalid IL or missing references)
		//IL_0272: Unknown result type (might be due to invalid IL or missing references)
		//IL_0277: Unknown result type (might be due to invalid IL or missing references)
		//IL_027b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0280: Unknown result type (might be due to invalid IL or missing references)
		//IL_0428: Unknown result type (might be due to invalid IL or missing references)
		//IL_042d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0438: Unknown result type (might be due to invalid IL or missing references)
		//IL_0442: Unknown result type (might be due to invalid IL or missing references)
		//IL_0447: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a1: Unknown result type (might be due to invalid IL or missing references)
		exterior = DomainVisual.CreateGlowMaterial();
		interior = DomainVisual.CreateGlowMaterial();
		edgeMaterial = DomainVisual.CreateGlowMaterial();
		((Object)exterior).name = "Obsidian domain exterior";
		((Object)interior).name = "Readable domain interior";
		Material[] array = (Material[])(object)new Material[2] { exterior, interior };
		foreach (Material val in array)
		{
			val.SetInt("_DstBlend", 10);
			val.renderQueue = 3110;
		}
		exterior.SetInt("_Cull", 2);
		interior.SetInt("_Cull", 1);
		edgeMaterial.renderQueue = 3111;
		List<Vector3> list = new List<Vector3>();
		for (int j = 0; j < 18; j++)
		{
			for (int k = 0; k < 36; k++)
			{
				Face(list, Point(k, j), Point(k, j + 1), Point(k + 1, j));
				Face(list, Point(k + 1, j), Point(k, j + 1), Point(k + 1, j + 1));
			}
		}
		rest = list.ToArray();
		vertices = (Vector3[])(object)new Vector3[rest.Length];
		colors = (Color[])(object)new Color[rest.Length];
		innerColors = (Color[])(object)new Color[rest.Length];
		int num = rest.Length / 3;
		normals = (Vector3[])(object)new Vector3[num];
		wave = new float[num];
		seed = new float[num];
		edgeVertices = (Vector3[])(object)new Vector3[num * 12 + 216];
		edgeColors = (Color[])(object)new Color[edgeVertices.Length];
		int[] array2 = new int[rest.Length];
		int[] array3 = new int[num * 18 + 216];
		for (int l = 0; l < rest.Length; l++)
		{
			array2[l] = l;
		}
		for (int m = 0; m < num; m++)
		{
			ref Vector3 reference = ref normals[m];
			Vector3 val2 = (rest[m * 3] + rest[m * 3 + 1] + rest[m * 3 + 2]) / 3f;
			reference = ((Vector3)(ref val2)).normalized;
			seed[m] = Mathf.Repeat((float)m * 0.618034f, 1f);
			wave[m] = Mathf.Clamp01((1f - normals[m].y) * 0.43f + seed[m] * 0.12f);
			for (int n = 0; n < 3; n++)
			{
				int num2 = m * 12 + n * 4;
				int num3 = m * 18 + n * 6;
				array3[num3] = num2;
				array3[num3 + 1] = num2 + 2;
				array3[num3 + 2] = num2 + 1;
				array3[num3 + 3] = num2 + 1;
				array3[num3 + 4] = num2 + 2;
				array3[num3 + 5] = num2 + 3;
			}
		}
		for (int num4 = 0; num4 < 216; num4++)
		{
			array3[num * 18 + num4] = num * 12 + num4;
		}
		facets = MakeMesh("Black exterior facets", exterior, out outsideRenderer);
		insideMesh = MakeMesh("Translucent interior facets", interior, out insideRenderer);
		cracks = MakeMesh("Crimson fracture network", edgeMaterial, out edgeRenderer);
		Mesh[] array4 = (Mesh[])(object)new Mesh[2] { facets, insideMesh };
		foreach (Mesh val3 in array4)
		{
			val3.vertices = rest;
			val3.uv = (Vector2[])(object)new Vector2[rest.Length];
			val3.triangles = array2;
			val3.bounds = new Bounds(Vector3.zero, Vector3.one * radius * 2.15f);
		}
		cracks.vertices = edgeVertices;
		cracks.uv = (Vector2[])(object)new Vector2[edgeVertices.Length];
		cracks.triangles = array3;
		cracks.bounds = facets.bounds;
	}

	internal void DrawIce(float age, float opening, float fade, float collapse, float stress = 0f)
	{
		iceStress = stress;
		iceCollapse = collapse;
		Draw(age, opening, fade);
	}

	internal void ExteriorForCamera(bool visible)
	{
		if (Object.op_Implicit((Object)(object)outsideRenderer))
		{
			((Renderer)outsideRenderer).enabled = visible && Object.op_Implicit((Object)(object)insideRenderer) && ((Renderer)insideRenderer).enabled;
		}
	}

	internal void Draw(float age, float opening, float fade)
	{
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_013f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0155: Unknown result type (might be due to invalid IL or missing references)
		//IL_015a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0170: 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)
		//IL_017f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0184: Unknown result type (might be due to invalid IL or missing references)
		//IL_0272: Unknown result type (might be due to invalid IL or missing references)
		//IL_028b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0292: Unknown result type (might be due to invalid IL or missing references)
		//IL_0297: Unknown result type (might be due to invalid IL or missing references)
		//IL_079d: Unknown result type (might be due to invalid IL or missing references)
		//IL_07a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_07a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_07a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_07ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_07ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_07f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0808: Unknown result type (might be due to invalid IL or missing references)
		//IL_080d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0814: Unknown result type (might be due to invalid IL or missing references)
		//IL_081b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0820: Unknown result type (might be due to invalid IL or missing references)
		//IL_0825: Unknown result type (might be due to invalid IL or missing references)
		//IL_0860: Unknown result type (might be due to invalid IL or missing references)
		//IL_0862: Unknown result type (might be due to invalid IL or missing references)
		//IL_0869: Unknown result type (might be due to invalid IL or missing references)
		//IL_0873: Unknown result type (might be due to invalid IL or missing references)
		//IL_0878: Unknown result type (might be due to invalid IL or missing references)
		//IL_087d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0891: Unknown result type (might be due to invalid IL or missing references)
		//IL_0893: Unknown result type (might be due to invalid IL or missing references)
		//IL_0897: Unknown result type (might be due to invalid IL or missing references)
		//IL_089c: Unknown result type (might be due to invalid IL or missing references)
		//IL_08a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_08b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_08b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_08bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_08c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_08c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_07c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_07ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_032d: Unknown result type (might be due to invalid IL or missing references)
		//IL_032f: Unknown result type (might be due to invalid IL or missing references)
		//IL_09cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_09ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_09cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_09d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_09d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_09d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_09d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_09db: Unknown result type (might be due to invalid IL or missing references)
		//IL_09e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_09e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0403: Unknown result type (might be due to invalid IL or missing references)
		//IL_0412: Unknown result type (might be due to invalid IL or missing references)
		//IL_0417: Unknown result type (might be due to invalid IL or missing references)
		//IL_0419: Unknown result type (might be due to invalid IL or missing references)
		//IL_0420: Unknown result type (might be due to invalid IL or missing references)
		//IL_0425: Unknown result type (might be due to invalid IL or missing references)
		//IL_042a: Unknown result type (might be due to invalid IL or missing references)
		//IL_042e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0433: Unknown result type (might be due to invalid IL or missing references)
		//IL_0438: Unknown result type (might be due to invalid IL or missing references)
		//IL_044a: Unknown result type (might be due to invalid IL or missing references)
		//IL_044c: Unknown result type (might be due to invalid IL or missing references)
		//IL_045e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0460: Unknown result type (might be due to invalid IL or missing references)
		//IL_0644: Unknown result type (might be due to invalid IL or missing references)
		//IL_064e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0653: Unknown result type (might be due to invalid IL or missing references)
		//IL_066b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0675: Unknown result type (might be due to invalid IL or missing references)
		//IL_067a: Unknown result type (might be due to invalid IL or missing references)
		//IL_067c: Unknown result type (might be due to invalid IL or missing references)
		//IL_067e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0680: Unknown result type (might be due to invalid IL or missing references)
		//IL_0682: Unknown result type (might be due to invalid IL or missing references)
		//IL_0687: Unknown result type (might be due to invalid IL or missing references)
		//IL_068c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0690: Unknown result type (might be due to invalid IL or missing references)
		//IL_069b: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_06cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_06cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_06d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_06d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0707: Unknown result type (might be due to invalid IL or missing references)
		//IL_0709: Unknown result type (might be due to invalid IL or missing references)
		//IL_070b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0710: Unknown result type (might be due to invalid IL or missing references)
		//IL_0724: Unknown result type (might be due to invalid IL or missing references)
		//IL_0726: Unknown result type (might be due to invalid IL or missing references)
		//IL_0728: Unknown result type (might be due to invalid IL or missing references)
		//IL_072d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0747: Unknown result type (might be due to invalid IL or missing references)
		//IL_0749: Unknown result type (might be due to invalid IL or missing references)
		float num = ((ice || violet || gold || midnight) ? iceCollapse : FormationTimeline.Reveal(age, opening));
		bool flag = num < 1f && fade > 0.001f;
		MeshRenderer obj = outsideRenderer;
		MeshRenderer obj2 = insideRenderer;
		bool flag2 = (((Renderer)edgeRenderer).enabled = flag);
		bool enabled = (((Renderer)obj2).enabled = flag2);
		((Renderer)obj).enabled = enabled;
		if (!flag)
		{
			return;
		}
		float num2 = FormationTimeline.Crystal(age, opening);
		float num3 = Plugin.Clamp(Plugin.CrystalIntensity.Value, 0f, 1.5f);
		Color val3 = default(Color);
		Color val5 = default(Color);
		for (int i = 0; i < normals.Length; i++)
		{
			float num4 = CastTimeline.Expansion(num2 * 1.2f - wave[i], 0.2f);
			float num5 = CastTimeline.Expansion(num * 1.22f - seed[i] * 0.2f, 1f);
			float num6 = Mathf.Pow(Mathf.Max(0f, Mathf.Cos(wave[i] * 16f - age * 2.6f)), 12f);
			float num7 = (1f - num5) * fade;
			Vector3 val = normals[i];
			Vector3 val2 = (rest[i * 3] + rest[i * 3 + 1] + rest[i * 3 + 2]) / 3f;
			float num8 = num4 * seed[i] * radius * 0.002f + num5 * num5 * radius * 0.035f;
			float num9 = 1f - num5 * 0.85f;
			float num10 = 0.008f + seed[i] * 0.018f * num4;
			((Color)(ref val3))..ctor(num10 * 0.65f + num6 * 0.018f, num10 * 0.2f, num10 + num6 * 0.025f, Plugin.Clamp(Plugin.BlackOpacity.Value, 0f, 1f) * num7);
			if (cyan)
			{
				((Color)(ref val3))..ctor(num10 * 0.12f, num10 * 0.45f, num10 + num6 * 0.025f, val3.a);
			}
			if (ice)
			{
				val3 = Color.Lerp(new Color(0.012f, 0.024f, 0.045f, 0.85f), new Color(0.72f, 0.88f, 1f, 0.17f), num4);
				val3.a *= num7;
			}
			if (violet)
			{
				((Color)(ref val3))..ctor(0.012f + num6 * 0.015f, 0.003f, 0.032f + num6 * 0.04f, num7 * 0.92f);
			}
			if (gold)
			{
				((Color)(ref val3))..ctor(0.018f, 0.009f, 0.012f, num7 * 0.97f);
			}
			if (midnight)
			{
				((Color)(ref val3))..ctor(0.018f, 0.028f, 0.095f, num7 * 0.98f);
			}
			Color val4 = val3;
			val4.a = Plugin.Clamp(Plugin.InnerOpacity.Value, 0f, 0.45f) * num7;
			if (midnight)
			{
				val4.a = num7 * 0.025f;
			}
			if (gold)
			{
				val4.a = num7 * 0.03f;
			}
			if (violet)
			{
				val4.a = num7 * 0.025f * Mathf.Max(1f - CastTimeline.Expansion(age - opening * 0.35f, opening * 0.5f), CastTimeline.Expansion(num, 0.45f));
			}
			if (ice)
			{
				val4.a = Mathf.Lerp(0.14f, 0.045f, num4) * num7;
			}
			for (int j = 0; j < 3; j++)
			{
				int num11 = i * 3 + j;
				ref Vector3 reference = ref vertices[num11];
				reference = val2 + (rest[num11] - val2) * num9 + val * num8;
				colors[num11] = val3;
				innerColors[num11] = val4;
			}
			float num12 = num4 * (0.22f + num2 * 0.4f + num * 2f + num6 * 0.16f);
			((Color)(ref val5))..ctor(2.8f, 0.04f + num * 0.18f, 0.2f + num * 0.15f, num12 * num7 * num3);
			if (cyan)
			{
				((Color)(ref val5))..ctor(0.08f, 1.7f + num * 0.3f, 2.8f, val5.a);
			}
			if (ice)
			{
				((Color)(ref val5))..ctor(0.72f, 1.05f, 1.3f, num4 * num7 * (0.035f + num * 0.6f + iceStress * 0.85f + ((age < opening) ? 0.16f : 0f)));
			}
			if (violet)
			{
				((Color)(ref val5))..ctor(0.7f, 0.13f, 1.35f, num7 * num4 * (0.018f + num6 * 0.12f + num * 0.4f + ((age < opening) ? 0.16f : 0f)) * Mathf.Max(1f - CastTimeline.Expansion(age - opening * 0.35f, opening * 0.5f), CastTimeline.Expansion(num, 0.45f)));
			}
			if (gold)
			{
				((Color)(ref val5))..ctor(1.5f, 0.72f, 0.08f, num7 * num4 * (0.13f + num6 * 0.1f + num * 0.5f));
			}
			if (midnight)
			{
				((Color)(ref val5))..ctor(0.48f, 0.66f, 1f, num7 * num4 * (0.035f + num6 * 0.025f + num * 0.12f));
			}
			for (int k = 0; k < 3; k++)
			{
				Vector3 val6 = vertices[i * 3 + k] * 1.0006f;
				Vector3 val7 = vertices[i * 3 + (k + 1) % 3] * 1.0006f;
				Vector3 val8 = Vector3.Cross(val, val7 - val6);
				Vector3 val9 = ((Vector3)(ref val8)).normalized * radius * (0.0004f + num * 0.00045f);
				int num13 = i * 12 + k * 4;
				ref Vector3 reference2 = ref edgeVertices[num13];
				reference2 = val6 - val9;
				ref Vector3 reference3 = ref edgeVertices[num13 + 1];
				reference3 = val6 + val9;
				ref Vector3 reference4 = ref edgeVertices[num13 + 2];
				reference4 = val7 - val9;
				ref Vector3 reference5 = ref edgeVertices[num13 + 3];
				reference5 = val7 + val9;
				for (int l = 0; l < 4; l++)
				{
					edgeColors[num13 + l] = val5;
				}
			}
		}
		Color val14 = default(Color);
		for (int m = 0; m < 72; m++)
		{
			Vector3 val10 = normals[m * 17 % normals.Length];
			Vector3 val11 = Vector3.Cross(val10, Vector3.up);
			Vector3 val12 = ((Vector3)(ref val11)).normalized;
			if (((Vector3)(ref val12)).sqrMagnitude < 0.1f)
			{
				val12 = Vector3.right;
			}
			float num14 = Mathf.Repeat(age * 0.65f + (float)m * 0.618034f, 1f);
			Vector3 val13 = val10 * radius * (1.003f + num14 * 0.025f) + Vector3.down * num14 * num14;
			float num15 = radius * (0.001f + (float)(m % 3) * 0.0006f);
			int num16 = normals.Length * 12 + m * 3;
			ref Vector3 reference6 = ref edgeVertices[num16];
			reference6 = val13 + Vector3.up * num15 * 2f;
			ref Vector3 reference7 = ref edgeVertices[num16 + 1];
			reference7 = val13 - val12 * num15;
			ref Vector3 reference8 = ref edgeVertices[num16 + 2];
			reference8 = val13 + val12 * num15;
			((Color)(ref val14))..ctor(2f, 0.02f, 0.2f, num2 * (1f - num) * fade * Mathf.Sin(num14 * MathF.PI) * 0.6f * num3);
			if (cyan)
			{
				((Color)(ref val14))..ctor(0.06f, 1.4f, 2f, val14.a);
			}
			if (violet)
			{
				((Color)(ref val14))..ctor(0.6f, 0.08f, 1.3f, val14.a * 0.3f);
			}
			if (gold)
			{
				((Color)(ref val14))..ctor(1.5f, 0.65f, 0.06f, val14.a);
			}
			if (midnight)
			{
				((Color)(ref val14))..ctor(0.5f, 0.7f, 1f, val14.a * 0.12f);
			}
			ref Color reference9 = ref edgeColors[num16];
			ref Color reference10 = ref edgeColors[num16 + 1];
			reference9 = (reference10 = (edgeColors[num16 + 2] = val14));
		}
		facets.vertices = vertices;
		facets.colors = colors;
		insideMesh.vertices = vertices;
		insideMesh.colors = innerColors;
		cracks.vertices = edgeVertices;
		cracks.colors = edgeColors;
	}

	private void OnDestroy()
	{
		if (Object.op_Implicit((Object)(object)facets))
		{
			Object.Destroy((Object)(object)facets);
		}
		if (Object.op_Implicit((Object)(object)insideMesh))
		{
			Object.Destroy((Object)(object)insideMesh);
		}
		if (Object.op_Implicit((Object)(object)cracks))
		{
			Object.Destroy((Object)(object)cracks);
		}
		if (Object.op_Implicit((Object)(object)exterior))
		{
			Object.Destroy((Object)(object)exterior);
		}
		if (Object.op_Implicit((Object)(object)interior))
		{
			Object.Destroy((Object)(object)interior);
		}
		if (Object.op_Implicit((Object)(object)edgeMaterial))
		{
			Object.Destroy((Object)(object)edgeMaterial);
		}
	}
}
public sealed class DomainAtmosphere : MonoBehaviour
{
	private Transform owner;

	private PostProcessVolume volume;

	private PostProcessProfile profile;

	private Light ambient;

	private bool reported;

	private bool ice;

	private bool violet;

	private bool casino;

	private bool garden;

	private bool midnight;

	private bool tactical;

	private ColorGrading grade;

	private float baseExposure;

	internal bool CameraSupported { get; private set; }

	internal static DomainAtmosphere Create(DomainVisual owner, float radius)
	{
		return Create(((Component)owner).transform, radius, cyan: false);
	}

	internal static DomainAtmosphere Create(Transform owner, float radius, bool cyan)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bd: Expected O, but got Unknown
		//IL_01d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0219: Unknown result type (might be due to invalid IL or missing references)
		//IL_017b: Unknown result type (might be due to invalid IL or missing references)
		//IL_023b: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("Local crimson domain atmosphere");
		val.transform.SetParent(owner, false);
		val.layer = LayerIndex.postProcess.intVal;
		DomainAtmosphere domainAtmosphere = val.AddComponent<DomainAtmosphere>();
		domainAtmosphere.owner = owner;
		SphereCollider val2 = val.AddComponent<SphereCollider>();
		((Collider)val2).isTrigger = true;
		val2.radius = radius;
		domainAtmosphere.volume = val.AddComponent<PostProcessVolume>();
		domainAtmosphere.volume.isGlobal = false;
		domainAtmosphere.volume.priority = 100f;
		domainAtmosphere.volume.blendDistance = 4f;
		domainAtmosphere.volume.weight = 0f;
		domainAtmosphere.profile = ScriptableObject.CreateInstance<PostProcessProfile>();
		((Object)domainAtmosphere.profile).name = "Endless Arrow Rain local grade";
		ColorGrading val3 = (domainAtmosphere.grade = domainAtmosphere.profile.AddSettings<ColorGrading>());
		((ParameterOverride<bool>)(object)((PostProcessEffectSettings)domainAtmosphere.profile.AddSettings<RampFog>()).enabled).Override(true);
		((ParameterOverride<bool>)(object)((PostProcessEffectSettings)val3).enabled).Override(true);
		((ParameterOverride<float>)(object)val3.postExposure).Override(-0.55f * Plugin.Clamp(Plugin.ScreenDarkness.Value / 0.18f, 0f, 2f));
		domainAtmosphere.baseExposure = ((ParameterOverride<float>)(object)val3.postExposure).value;
		((ParameterOverride<float>)(object)val3.saturation).Override(-24f);
		((ParameterOverride<float>)(object)val3.contrast).Override(10f);
		((ParameterOverride<Color>)(object)val3.colorFilter).Override(new Color(1f, 0.96f, 1f));
		if (cyan)
		{
			((ParameterOverride<Color>)(object)val3.colorFilter).Override(new Color(0.5f, 0.8f, 1f));
			((ParameterOverride<float>)(object)val3.postExposure).Override(-1f);
			domainAtmosphere.baseExposure = -1f;
		}
		domainAtmosphere.volume.sharedProfile = domainAtmosphere.profile;
		GameObject val4 = new GameObject("Subtle domain red illumination");
		val4.transform.SetParent(val.transform, false);
		val4.transform.localPosition = Vector3.up * 4f;
		domainAtmosphere.ambient = val4.AddComponent<Light>();
		domainAtmosphere.ambient.type = (LightType)2;
		domainAtmosphere.ambient.color = new Color(1f, 0.015f, 0.065f);
		if (cyan)
		{
			domainAtmosphere.ambient.color = new Color(0.04f, 0.7f, 1f);
		}
		domainAtmosphere.ambient.range = radius;
		domainAtmosphere.ambient.shadows = (LightShadows)0;
		domainAtmosphere.ambient.intensity = 0f;
		return domainAtmosphere;
	}

	internal void ConfigureTactical()
	{
		//IL_0083: 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)
		tactical = true;
		RampFog setting = profile.GetSetting<RampFog>();
		((ParameterOverride<float>)(object)setting.fogIntensity).Override(0f);
		((ParameterOverride<float>)(object)setting.fogHeightIntensity).Override(0f);
		baseExposure = -0.12f;
		((ParameterOverride<float>)(object)grade.postExposure).Override(baseExposure);
		((ParameterOverride<float>)(object)grade.contrast).Override(14f);
		((ParameterOverride<Color>)(object)grade.colorFilter).Override(new Color(0.72f, 0.86f, 1f));
		ambient.color = new Color(0.15f, 0.55f, 1f);
	}

	internal void ConfigureMidnight()
	{
		//IL_0083: 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)
		midnight = true;
		RampFog setting = profile.GetSetting<RampFog>();
		((ParameterOverride<float>)(object)setting.fogIntensity).Override(0f);
		((ParameterOverride<float>)(object)setting.fogHeightIntensity).Override(0f);
		baseExposure = -0.1f;
		((ParameterOverride<float>)(object)grade.postExposure).Override(baseExposure);
		((ParameterOverride<float>)(object)grade.contrast).Override(2f);
		((ParameterOverride<Color>)(object)grade.colorFilter).Override(new Color(0.78f, 0.86f, 1f));
		ambient.color = new Color(0.48f, 0.66f, 1f);
	}

	internal void ConfigureGarden()
	{
		//IL_0083: 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)
		garden = true;
		RampFog setting = profile.GetSetting<RampFog>();
		((ParameterOverride<float>)(object)setting.fogIntensity).Override(0f);
		((ParameterOverride<float>)(object)setting.fogHeightIntensity).Override(0f);
		baseExposure = 0.12f;
		((ParameterOverride<float>)(object)grade.postExposure).Override(baseExposure);
		((ParameterOverride<float>)(object)grade.contrast).Override(-4f);
		((ParameterOverride<Color>)(object)grade.colorFilter).Override(new Color(1f, 0.98f, 0.87f));
		ambient.color = new Color(1f, 0.82f, 0.43f);
	}

	internal void ConfigureCasino()
	{
		//IL_0083: 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)
		casino = true;
		RampFog setting = profile.GetSetting<RampFog>();
		((ParameterOverride<float>)(object)setting.fogIntensity).Override(0f);
		((ParameterOverride<float>)(object)setting.fogHeightIntensity).Override(0f);
		baseExposure = 0.1f;
		((ParameterOverride<float>)(object)grade.postExposure).Override(baseExposure);
		((ParameterOverride<float>)(object)grade.contrast).Override(4f);
		((ParameterOverride<Color>)(object)grade.colorFilter).Override(new Color(1f, 0.92f, 0.85f));
		ambient.color = new Color(1f, 0.38f, 0.055f);
	}

	internal void ConfigureVoid()
	{
		//IL_0098: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		RampFog setting = profile.GetSetting<RampFog>();
		((ParameterOverride<float>)(object)setting.fogIntensity).Override(0f);
		((ParameterOverride<float>)(object)setting.fogHeightIntensity).Override(0f);
		violet = true;
		baseExposure = -0.12f;
		((ParameterOverride<float>)(object)grade.postExposure).Override(baseExposure);
		((ParameterOverride<float>)(object)grade.saturation).Override(-12f);
		((ParameterOverride<float>)(object)grade.contrast).Override(8f);
		((ParameterOverride<Color>)(object)grade.colorFilter).Override(new Color(0.94f, 0.94f, 1f));
		ambient.color = new Color(0.35f, 0.12f, 0.8f);
	}

	internal void ConfigureIce()
	{
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		ice = true;
		baseExposure = 0.16f;
		((ParameterOverride<float>)(object)grade.postExposure).Override(baseExposure);
		((ParameterOverride<float>)(object)grade.saturation).Override(-48f);
		((ParameterOverride<float>)(object)grade.contrast).Override(-6f);
		((ParameterOverride<Color>)(object)grade.colorFilter).Override(new Color(0.9f, 0.96f, 1f));
		ambient.color = new Color(0.65f, 0.85f, 1f);
	}

	internal void BeforeCamera(Camera camera, float weight, bool gathering, float reveal, float pulse)
	{
		//IL_0096: 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_00d4: 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)
		PostProcessLayer component = ((Component)camera).GetComponent<PostProcessLayer>();
		CameraSupported = Object.op_Implicit((Object)(object)component) && ((Behaviour)component).enabled && ((LayerMask)(ref component.volumeLayer)).value != 0;
		if (CameraSupported && (((LayerMask)(ref component.volumeLayer)).value & (1 << ((Component)this).gameObject.layer)) == 0)
		{
			for (int i = 0; i < 32; i++)
			{
				if ((((LayerMask)(ref component.volumeLayer)).value & (1 << i)) != 0)
				{
					((Component)this).gameObject.layer = i;
					break;
				}
			}
		}
		float num = Mathf.Max(0.025f, ((Component)owner).transform.localScale.x);
		float num2 = Mathf.Min(1f, 8f / ((Component)this).GetComponent<SphereCollider>().radius);
		((Component)this).transform.localScale = Vector3.one * Mathf.Max(num, num2) / num;
		volume.weight = weight;
		((ParameterOverride<float>)(object)grade.postExposure).value = baseExposure - 0.35f * (1f - reveal) + pulse * 0.12f;
		((ParameterOverride<float>)(object)grade.saturation).value = Mathf.Lerp(-32f, -24f, reveal);
		ambient.intensity = (0.08f + 0.2f * reveal + pulse * 0.22f) * weight * Plugin.Clamp(Plugin.VisualIntensity.Value, 0f, 1.5f);
		if (ice)
		{
			((ParameterOverride<float>)(object)grade.postExposure).value = baseExposure + pulse * 0.12f;
			((ParameterOverride<float>)(object)grade.saturation).value = -48f;
			ambient.intensity = 0.14f * weight;
		}
		if (midnight)
		{
			((ParameterOverride<float>)(object)grade.postExposure).value = baseExposure - (1f - reveal) * 0.2f;
			((ParameterOverride<float>)(object)grade.saturation).value = -12f;
			ambient.intensity = 0.3f * weight;
		}
		if (tactical)
		{
			((ParameterOverride<float>)(object)grade.postExposure).value = baseExposure - (1f - reveal) * 0.15f + pulse * 0.08f;
			((ParameterOverride<float>)(object)grade.saturation).value = Mathf.Lerp(-60f, -38f, reveal);
			ambient.intensity = 0.16f * weight;
		}
		if (garden)
		{
			((ParameterOverride<float>)(object)grade.postExposure).value = baseExposure + pulse * 0.1f;
			((ParameterOverride<float>)(object)grade.saturation).value = 4f;
			ambient.intensity = 0.25f * weight;
		}
		if (casino)
		{
			((ParameterOverride<float>)(object)grade.postExposure).value = baseExposure - (1f - reveal) * 0.18f;
			((ParameterOverride<float>)(object)grade.saturation).value = -8f;
			ambient.intensity = 0.24f * weight;
		}
		if (violet)
		{
			((ParameterOverride<float>)(object)grade.postExposure).value = baseExposure - (1f - reveal) * 0.5f;
			((ParameterOverride<float>)(object)grade.saturation).value = Mathf.Lerp(-65f, -12f, reveal);
			ambient.intensity = 0.08f * weight;
		}
		if (!reported)
		{
			reported = true;
			Plugin.Log.LogInfo((object)("Domain atmosphere: local post-processing=" + CameraSupported + " layer=" + ((Component)this).gameObject.layer + "; no global lighting/fog writes."));
		}
	}

	private void OnDestroy()
	{
		if (!Object.op_Implicit((Object)(object)profile))
		{
			return;
		}
		foreach (PostProcessEffectSettings setting in profile.settings)
		{
			if (Object.op_Implicit((Object)(object)setting))
			{
				Object.Destroy((Object)(object)setting);
			}
		}
		Object.Destroy((Object)(object)profile);
	}
}
internal sealed class DomainAudio : MonoBehaviour
{
	private sealed class Voice
	{
		internal GameObject Object;

		internal uint Playing;

		internal float Gain;

		internal float AnchoredUntil;
	}

	private static readonly string[] Events = new string[14]
	{
		"Play_majorConstruct_spawn_rumble", "Play_env_ship_pulsing_energy_loop", "Play_voidRaid_snipe_chargeUp", "Play_char_glass_death", "Play_bellBody_impact", "Play_voidRaid_snipe_shoot_final", "Play_env_desert_wind_gust", "Play_huntress_R_rain_loop", "Play_huntress_m1_shoot", "Play_huntress_m2_impact",
		"Play_lunar_wisp_attack1_windDown", "Play_voidRaid_snipe_impact", "Play_golem_spawn", "Play_env_gooWaterfall_loop"
	};

	private readonly Voice[] voices = new Voice[8];

	private Vector3 center;

	private Vector3 listener;

	private float radius;

	private float start;

	private float opening;

	private float end;

	private float collapse;

	private float lastAge;

	private float nextImpact;

	private float nextWind;

	private float nextHeroSound;

	private bool heard;

	private bool started;

	private bool closing;

	private bool paused;

	private bool enabledAudio;

	private bool warned;

	private bool impactPending;

	private Vector3 impactPosition;

	private int lastVolley = -1;

	private float ListenerProximity
	{
		get
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = listener - center;
			return 1f - Mathf.Clamp01((((Vector3)(ref val)).magnitude - radius) / Mathf.Max(8f, radius * 0.8f));
		}
	}

	internal void CelestialImpact(Vector3 position)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		impactPosition = position;
		impactPending = true;
	}

	internal static DomainAudio Create(Transform parent, Vector3 center, float radius, float start, float opening, float end, float collapse)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Expected O, but got Unknown
		GameObject val = new GameObject("Domain staged positional audio");
		val.transform.SetParent(parent, false);
		DomainAudio domainAudio = val.AddComponent<DomainAudio>();
		domainAudio.center = center;
		domainAudio.radius = radius;
		domainAudio.start = start;
		domainAudio.opening = opening;
		domainAudio.end = end;
		domainAudio.collapse = collapse;
		domainAudio.lastAge = Time.time - start - 0.001f;
		domainAudio.enabledAudio = Plugin.SoundEnabled.Value;
		if (domainAudio.enabledAudio)
		{
			for (int i = 0; i < domainAudio.voices.Length; i++)
			{
				GameObject val2 = new GameObject("Domain voice " + i);
				val2.transform.SetParent(val.transform, false);
				val2.AddComponent<AkGameObj>();
				domainAudio.voices[i] = new Voice
				{
					Object = val2
				};
			}
		}
		return domainAudio;
	}

	internal void Listener(Vector3 position)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0002: Unknown result type (might be due to invalid IL or missing references)
		listener = position;
		heard = true;
	}

	private void Stop(int slot, int milliseconds)
	{
		Voice voice = voices[slot];
		if (voice != null && voice.Playing != 0)
		{
			AkSoundEngine.StopPlayingID(voice.Playing, milliseconds);
			voice.Playing = 0u;
		}
	}

	private void Play(int slot, int sound, float gain)
	{
		if (enabledAudio && AkSoundEngine.IsInitialized())
		{
			Stop(slot, 70);
			Voice voice = voices[slot];
			voice.Gain = gain;
			ApplyGain(voice, gain * ListenerProximity);
			voice.Playing = Util.PlaySound(Events[sound], voice.Object);
			if (voice.Playing == 0 && !warned)
			{
				warned = true;
				Plugin.Log.LogWarning((object)("Domain audio event could not post: " + Events[sound] + ". Check native sound-bank loading."));
			}
		}
	}

	private void ApplyGain(Voice voice, float gain)
	{
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		float num = Mathf.Clamp01(gain * Plugin.Clamp(Plugin.SoundVolume.Value, 0f, 1f));
		foreach (AkAudioListener listener in ((BaseListenerList)AkAudioListener.DefaultListeners).ListenerList)
		{
			if (Object.op_Implicit((Object)(object)listener) && ((Behaviour)listener).isActiveAndEnabled)
			{
				AkSoundEngine.SetGameObjectOutputBusVolume(voice.Object, ((Component)listener).gameObject, num);
			}
		}
	}

	internal void BeginCollapse()
	{
		if (!closing)
		{
			closing = true;
			end = Mathf.Min(end, Time.time);
			if (enabledAudio && heard)
			{
				Stop(7, 220);
				Stop(2, 220);
				Play(0, 10, 0.36f);
				Play(3, 3, 0.28f);
			}
		}
	}

	private bool Crossed(float age, float cue)
	{
		if (lastAge < cue)
		{
			return age >= cue;
		}
		return false;
	}

	private void Update()
	{
		//IL_007d: 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_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0169: Unknown result type (might be due to invalid IL or missing references)
		//IL_016e: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c5: Unknown result type (might be due to invalid IL or missing references)
		if (!enabledAudio || !heard || !Object.op_Implicit((Object)(object)Run.instance))
		{
			return;
		}
		if (!Plugin.SoundEnabled.Value)
		{
			StopAll();
		}
		else
		{
			if (!AkSoundEngine.IsInitialized())
			{
				return;
			}
			if (Time.timeScale <= 0f || !Application.isFocused)
			{
				paused = true;
				return;
			}
			if (paused)
			{
				paused = false;
			}
			float num = Time.time - start;
			Vector3 val = listener - center;
			float num2 = 1f - Mathf.Clamp01((((Vector3)(ref val)).magnitude - radius) / Mathf.Max(8f, radius * 0.8f));
			Vector3 val2 = center + Vector3.ClampMagnitude(listener - center, radius * 0.92f);
			for (int i = 0; i < voices.Length; i++)
			{
				float num3 = (float)i * 2.399963f;
				if (Time.time >= voices[i].AnchoredUntil)
				{
					voices[i].Object.transform.position = ((i == 0 || i == 2) ? center : (val2 + new Vector3(Mathf.Cos(num3 + num * 0.035f) * 5f, (i == 6) ? 6f : 2f, Mathf.Sin(num3 + num * 0.035f) * 5f)));
				}
			}
			if (!started)
			{
				started = true;
				Play(1, 1, 0.2f);
				Play(6, 6, 0.1f);
				if (num < 0.3f)
				{
					Play(0, 0, 0.7f);
					Play(4, 11, 0.35f);
				}
				if (num < opening)
				{
					Play(2, 2, 0.27f);
				}
				else
				{
					Play(7, 7, 0.32f);
				}
				lastVolley = CosmicTimeline.VolleyIndex(num - opening);
				nextImpact = num + 0.3f;
				nextWind = num + 3f;
			}
			if (!closing && Time.time < end && Crossed(num, Mathf.Max(0.1f, opening - 1.65f)))
			{
				Play(3, 3, 0.2f);
			}
			if (!closing && Time.time < end && Crossed(num, Mathf.Max(0.2f, opening - 0.95f)))
			{
				Play(3, 3, 0.25f);
				Play(4, 4, 0.15f);
			}
			if (!closing && Time.time < end && Crossed(num, Mathf.Max(0.3f, opening - 0.35f)))
			{
				Play(3, 3, 0.32f);
			}
			if (!closing && Time.time < end && Crossed(num, opening))
			{
				Stop(2, 150);
				Play(2, 12, 0.4f);
				Play(7, 7, 0.32f);
			}
			if (!closing && Time.time < end && Crossed(num, opening + 0.28f))
			{
				Play(6, 13, 0.085f);
			}
			if (!closing && Time.time < end && Crossed(num, opening + 1.15f))
			{
				Play(0, 5, 0.7f);
				Play(4, 4, 0.22f);
				Play(6, 6, 0.1f);
			}
			if (Time.time >= end && !closing)
			{
				BeginCollapse();
			}
			float num4 = (closing ? (1f - CastTimeline.Expansion(Time.time - end, collapse)) : 1f);
			if (!closing && num >= opening)
			{
				int num5 = CosmicTimeline.VolleyIndex(num - opening);
				if (num5 > lastVolley)
				{
					lastVolley = num5;
					Play(5, 8, 0.24f);
					if (num5 > 0)
					{
						Play(0, 0, 0.18f);
						if (num5 % 2 == 0)
						{
							Play(3, 4, 0.1f);
						}
					}
				}
				if (impactPending && num >= nextHeroSound)
				{
					impactPending = false;
					nextHeroSound = num + 1.2f;
					voices[4].Object.transform.position = impactPosition;
					voices[4].AnchoredUntil = Time.time + 0.8f;
					Play(4, 11, 0.34f);
					nextImpact = num + 1f;
				}
				if (num >= nextImpact)
				{
					nextImpact = num + 0.9f;
					Play(4, 9, 0.055f);
				}
				if (num >= nextWind)
				{
					nextWind = num + 4.5f;
					Play(6, 6, 0.08f);
				}
			}
			if (closing && Crossed(num, end - start + collapse * 0.55f))
			{
				Play(3, 3, 0.34f);
				Play(4, 4, 0.15f);
			}
			float num6 = ((!closing && num >= opening + 0.93f && num < opening + 1.15f) ? 0.03f : 1f);
			for (int j = 0; j < voices.Length; j++)
			{
				float num7 = voices[j].Gain;
				if (j == 1 && num < opening)
				{
					num7 *= 0.6f + 1.2f * CastTimeline.Expansion(num, opening);
				}
				if (j == 7)
				{
					num7 *= 0.5f + 0.5f * CosmicTimeline.Volley(num - opening);
				}
				if (j == 1 && num >= opening)
				{
					num7 *= 0.8f + 0.2f * CosmicTimeline.Anticipation(num - opening);
				}
				ApplyGain(voices[j], num7 * num4 * num2 * num6);
			}
			lastAge = num;
		}
	}

	private void StopAll()
	{
		for (int i = 0; i < voices.Length; i++)
		{
			Stop(i, 0);
		}
	}

	private void OnDisable()
	{
		StopAll();
	}

	private void OnDestroy()
	{
		StopAll();
	}
}
internal static class DomainCombat
{
	internal sealed class Field
	{
		internal CharacterBody Owner;

		internal TeamIndex Team;

		internal Vector3 Center;

		internal float Radius;

		internal float Began;

		internal float Windup;

		internal float Expansion;

		internal float End;

		internal float Move;

		internal float Attack;

		internal bool DestroyProjectiles;

		internal bool Alive
		{
			get
			{
				if (Object.op_Implicit((Object)(object)Run.instance) && Object.op_Implicit((Object)(object)Owner) && Object.op_Implicit((Object)(object)Owner.healthComponent) && Owner.healthComponent.alive)
				{
					return Time.time < End;
				}
				return false;
			}
		}

		internal bool Gathering => Time.time < Began + Windup;

		internal float Reach
		{
			get
			{
				if (!Gathering)
				{
					return Radius * CastTimeline.Expansion(Time.time - Began - Windup, Expansion);
				}
				return Radius;
			}
		}
	}

	private sealed class SlowState
	{
		internal float Move;

		internal float Attack;

		internal Animator Animator;

		internal float SavedSpeed;

		internal float AppliedSpeed;
	}

	private sealed class FrozenProjectile
	{
		internal Rigidbody Body;

		internal ProjectileSimple Simple;

		internal Vector3 Velocity;

		internal Vector3 Angular;

		internal bool Kinematic;

		internal bool Enabled;

		internal void Restore()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)Body))
			{
				Body.isKinematic = Kinematic;
				if (!Kinematic)
				{
					Body.velocity = Velocity;
					Body.angularVelocity = Angular;
				}
			}
			if (Object.op_Implicit((Object)(object)Simple))
			{
				((Behaviour)Simple).enabled = Enabled;
			}
		}
	}

	private static readonly List<Field> fields = new List<Field>();

	private static readonly Dictionary<CharacterBody, SlowState> slowed = new Dictionary<CharacterBody, SlowState>();

	private static readonly List<CharacterBody> staleBodies = new List<CharacterBody>();

	internal static readonly HashSet<ProjectileController> Projectiles = new HashSet<ProjectileController>();

	private static readonly List<ProjectileController> projectileSnapshot = new List<ProjectileController>();

	private static readonly Dictionary<ProjectileController, FrozenProjectile> frozen = new Dictionary<ProjectileController, FrozenProjectile>();

	private static readonly List<Vector3> shatters = new List<Vector3>(32);

	private static readonly PropertyInfo AttackProperty = AccessTools.Property(typeof(CharacterBody), "attackSpeed");

	private static readonly PropertyInfo MoveProperty = AccessTools.Property(typeof(CharacterBody), "moveSpeed");

	internal static Field Open(CharacterBody body, DomainMessage data)
	{
		//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_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		Field field = new Field();
		field.Owner = body;
		field.Team = (TeamIndex)((!Object.op_Implicit((Object)(object)body.teamComponent)) ? 1 : ((int)body.teamComponent.teamIndex));
		field.Center = data.Center;
		field.Radius = data.Radius;
		field.Began = Time.time - data.Age;
		field.Windup = data.Freeze;
		field.Expansion = data.Expansion;
		field.End = Time.time - data.Age + data.Freeze + data.Expansion + data.Duration;
		field.Move = data.EnemyMove;
		field.Attack = data.EnemyAttack;
		field.DestroyProjectiles = data.DestroyProjectiles;
		Field field2 = field;
		fields.Add(field2);
		return field2;
	}

	internal static void Close(Field field)
	{
		if (field != null)
		{
			fields.Remove(field);
			RefreshBodies();
		}
	}

	private static void Factors(CharacterBody body, out float move, out float attack, out bool freeze)
	{
		//IL_0076: 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_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		move = 1f;
		attack = 1f;
		freeze = false;
		if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.teamComponent) || !Object.op_Implicit((Object)(object)body.healthComponent) || !body.healthComponent.alive)
		{
			return;
		}
		foreach (Field field in fields)
		{
			if (field.Alive && !((Object)(object)body == (Object)(object)field.Owner) && TeamManager.IsTeamEnemy(field.Team, body.teamComponent.teamIndex))
			{
				Vector3 val = body.corePosition - field.Center;
				if (!(((Vector3)(ref val)).sqrMagnitude > field.Reach * field.Reach))
				{
					move = Mathf.Min(move, field.Gathering ? 0.06f : field.Move);
					attack = Mathf.Min(attack, field.Gathering ? 0.12f : field.Attack);
					freeze |= field.Gathering;
				}
			}
		}
	}

	private static void RestoreAnimation(SlowState state)
	{
		if (Object.op_Implicit((Object)(object)state.Animator) && Mathf.Abs(state.Animator.speed - state.AppliedSpeed) < 0.0001f)
		{
			state.Animator.speed = state.SavedSpeed;
		}
		state.Animator = null;
	}

	private static void RefreshBodies()
	{
		foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList)
		{
			if (!Object.op_Implicit((Object)(object)readOnlyInstances))
			{
				continue;
			}
			Factors(readOnlyInstances, out var move, out var attack, out var freeze);
			if (move >= 1f && attack >= 1f)
			{
				continue;
			}
			if (!slowed.TryGetValue(readOnlyInstances, out var value))
			{
				SlowState slowState = new SlowState();
				slowState.Move = 1f;
				slowState.Attack = 1f;
				value = slowState;
				slowed.Add(readOnlyInstances, value);
			}
			bool flag = value.Move != move || value.Attack != attack;
			value.Move = move;
			value.Attack = attack;
			if (freeze && !Object.op_Implicit((Object)(object)value.Animator) && Object.op_Implicit((Object)(object)readOnlyInstances.modelLocator) && Object.op_Implicit((Object)(object)readOnlyInstances.modelLocator.modelTransform))
			{
				value.Animator = ((Component)readOnlyInstances.modelLocator.modelTransform).GetComponent<Animator>();
				if (Object.op_Implicit((Object)(object)value.Animator))
				{
					value.SavedSpeed = value.Animator.speed;
					value.AppliedSpeed = value.SavedSpeed * 0.08f;
					value.Animator.speed = value.AppliedSpeed;
				}
			}
			if (!freeze && Object.op_Implicit((Object)(object)value.Animator))
			{
				RestoreAnimation(value);
			}
			if (flag)
			{
				readOnlyInstances.MarkAllStatsDirty();
			}
		}
		staleBodies.Clear();
		foreach (KeyValuePair<CharacterBody, SlowState> item in slowed)
		{
			Factors(item.Key, out var move2, out var attack2, out var _);
			if (!Object.op_Implicit((Object)(object)item.Key) || (move2 >= 1f && attack2 >= 1f))
			{
				staleBodies.Add(item.Key);
			}
		}
		foreach (CharacterBody staleBody in staleBodies)
		{
			RestoreAnimation(slowed[staleBody]);
			slowed.Remove(staleBody);
			if (Object.op_Implicit((Object)(object)staleBody))
			{
				staleBody.MarkAllStatsDirty();
			}
		}
	}

	internal static void ApplySlow(CharacterBody body)
	{
		if (slowed.TryGetValue(body, out var value))
		{
			MoveProperty.SetValue(body, body.moveSpeed * value.Move, null);
			AttackProperty.SetValue(body, body.attackSpeed * value.Attack, null);
		}
	}

	internal static bool Suspended(ProjectileController p)
	{
		return frozen.ContainsKey(p);
	}

	internal static void Tick()
	{
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0225: Unknown result type (might be due to invalid IL or missing references)
		//IL_0230: Unknown result type (might be due to invalid IL or missing references)
		//IL_023f: Unknown result type (might be due to invalid IL or missing references)
		//IL_025d: 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_0256: Unknown result type (might be due to invalid IL or missing references)
		//IL_0262: Unknown result type (might be due to invalid IL or missing references)
		//IL_0267: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d4: 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)
		//IL_03e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_037b: Unknown result type (might be due to invalid IL or missing references)
		for (int num = fields.Count - 1; num >= 0; num--)
		{
			if (!fields[num].Alive)
			{
				fields.RemoveAt(num);
			}
		}
		if (fields.Count > 0 || slowed.Count > 0)
		{
			RefreshBodies();
		}
		projectileSnapshot.Clear();
		foreach (KeyValuePair<ProjectileController, FrozenProjectile> item in frozen)
		{
			if (!NetworkServer.active || fields.Count == 0 || !Object.op_Implicit((Object)(object)item.Key) || !((Component)item.Key).gameObject.activeInHierarchy)
			{
				projectileSnapshot.Add(item.Key);
			}
		}
		foreach (ProjectileController item2 in projectileSnapshot)
		{
			frozen[item2].Restore();
			frozen.Remove(item2);
		}
		if (!NetworkServer.active || (fields.Count == 0 && frozen.Count == 0))
		{
			return;
		}
		projectileSnapshot.Clear();
		projectileSnapshot.AddRange(Projectiles);
		shatters.Clear();
		foreach (ProjectileController item3 in projectileSnapshot)
		{
			if (!Object.op_Implicit((Object)(object)item3) || !((Component)item3).gameObject.activeInHierarchy || item3.isPrediction || !Object.op_Implicit((Object)(object)item3.teamFilter))
			{
				continue;
			}
			NetworkInstanceId netId = ((NetworkBehaviour)item3).netId;
			if (((NetworkInstanceId)(ref netId)).IsEmpty())
			{
				continue;
			}
			ProjectileSimple component = ((Component)item3).GetComponent<ProjectileSimple>();
			Rigidbody component2 = ((Component)item3).GetComponent<Rigidbody>();
			if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component2))
			{
				continue;
			}
			bool flag = false;
			bool flag2 = false;
			Vector3 position = ((Component)item3).transform.position;
			foreach (Field field in fields)
			{
				if (!field.Alive || !TeamManager.IsTeamEnemy(field.Team, item3.teamFilter.teamIndex))
				{
					continue;
				}
				Vector3 val = position + (component2.isKinematic ? Vector3.zero : (component2.velocity * Time.fixedDeltaTime));
				if (DomainRules.SegmentIntersectsSphere(position.x - field.Center.x, position.y - field.Center.y, position.z - field.Center.z, val.x - field.Center.x, val.y - field.Center.y, val.z - field.Center.z, field.Reach))
				{
					if (field.Gathering)
					{
						flag = true;
					}
					else
					{
						flag2 |= field.DestroyProjectiles;
					}
				}
			}
			FrozenProjectile value;
			if (flag2)
			{
				if (frozen.TryGetValue(item3, out value))
				{
					value.Restore();
					frozen.Remove(item3);
				}
				ProjectileDamage component3 = ((Component)item3).GetComponent<ProjectileDamage>();
				if (Object.op_Implicit((Object)(object)component3))
				{
					component3.damage = 0f;
				}
				if (shatters.Count < 32)
				{
					shatters.Add(position);
				}
				Projectiles.Remove(item3);
				NetworkServer.Destroy(((Component)item3).gameObject);
			}
			else if (flag && !frozen.ContainsKey(item3))
			{
				FrozenProjectile frozenProjectile = new FrozenProjectile();
				frozenProjectile.Body = component2;
				frozenProjectile.Simple = component;
				frozenProjectile.Velocity = component2.velocity;
				frozenProjectile.Angular = component2.angularVelocity;
				frozenProjectile.Kinematic = component2.isKinematic;
				frozenProjectile.Enabled = ((Behaviour)component).enabled;
				value = frozenProjectile;
				frozen.Add(item3, value);
				((Behaviour)component).enabled = false;
				component2.isKinematic = true;
			}
			else if (!flag && frozen.TryGetValue(item3, out value))
			{
				value.Restore();
				frozen.Remove(item3);
			}
		}
		Plugin.BroadcastShatters(shatters);
	}

	internal static void Forget(ProjectileController projectile)
	{
		Projectiles.Remove(projectile);
		frozen.Remove(projectile);
	}

	internal static void Clear()
	{
		fields.Clear();
		RefreshBodies();
		foreach (FrozenProjectile value in frozen.Values)
		{
			value.Restore();
		}
		frozen.Clear();
		Projectiles.Clear();
	}
}
[HarmonyPatch(typeof(ProjectileController), "Awake")]
internal static class TrackDomainProjectiles
{
	private static void Postfix(ProjectileController __instance)
	{
		DomainCombat.Projectiles.Add(__instance);
	}
}
[HarmonyPatch(typeof(ProjectileController), "OnDestroy")]
internal static class UntrackDomainProjectiles
{
	private static void Prefix(ProjectileController __instance)
	{
		DomainCombat.Forget(__instance);
	}
}
internal sealed class DomainInterior : MonoBehaviour
{
	private struct HeavenArrow
	{
		internal Vector3 From;

		internal Vector3 To;

		internal float Phase;

		internal float Flight;
	}

	private sealed class Ruin
	{
		internal RealmMesh Stone;

		internal RealmMesh Cracks;

		internal Color[] Colors;

		internal Vector3 Anchor;

		internal float Delay;
	}

	private readonly List<RealmMesh> layers = new List<RealmMesh>();

	private RealmMesh sky;

	private RealmMesh eclipse;

	private RealmMesh energy;

	private RealmMesh sigil;

	private float radius;

	private float intensity;

	private Vector3 view;

	private Vector3 forward;

	private Vector3 right;

	private float clock;

	private float visible;

	private float awakening;

	private bool closing;

	private bool legacySanctuary;

	private RealmMesh artifacts;

	private RealmMesh artifactEdges;

	private float RealmOpeningForDraw;

	private readonly Vector4[] surfaceHits = (Vector4[])(object)new Vector4[16];

	private int nextSurfaceHit;

	private Vector4 grandHit = new Vector4(0f, 0f, 0f, -999f);

	private Light impactLight;

	private RealmMesh impactSparks;

	private float nextGrandImpact;

	private HeavenArrow[] heavenArrows;

	private RealmMesh heavenRain;

	private readonly Ruin[] ruins = new Ruin[3];

	private RealmMesh debris;

	private Texture2D stoneTexture;

	private readonly Color stone = new Color(0.13f, 0.09f, 0.115f, 1f);

	private RealmMesh Layer(string name, bool additive, int queue)
	{
		RealmMesh realmMesh = new RealmMesh(((Component)this).transform, name, additive, queue);
		layers.Add(realmMesh);
		return realmMesh;
	}

	internal static DomainInterior Create(Transform parent, float radius)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		GameObject val = new GameObject("Huntress personal apocalypse");
		val.transform.SetParent(parent, false);
		DomainInterior domainInterior = val.AddComponent<DomainInterior>();
		domainInterior.radius = radius;
		domainInterior.intensity = Plugin.Clamp(Plugin.VisualIntensity.Value, 0f, 1.5f);
		domainInterior.legacySanctuary = Plugin.LegacySanctuary.Value;
		try
		{
			if (!RealmProjection.Supported)
			{
				domainInterior.BuildSky();
			}
			domainInterior.sigil = domainInterior.Layer("Celestial arrow of dominion", additive: true, 3100);
			if (domainInterior.legacySanctuary)
			{
				domainInterior.BuildRuins();
			}
			else
			{
				domainInterior.BuildArtifacts();
			}
			domainInterior.BuildPool();
			domainInterior.BuildHeavenRain();
			return domainInterior;
		}
		catch
		{
			Object.Destroy((Object)(object)val);
			throw;
		}
	}

	internal void Draw(Camera camera, float age, float opening, float fade, bool collapsing)
	{
		//IL_0013: 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_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_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0045: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		closing = collapsing;
		float num = Mathf.Max(0.025f, ((Component)this).transform.lossyScale.x);
		view = (((Component)camera).transform.position - ((Component)this).transform.position) / num;
		forward = ((Component)camera).transform.forward;
		right = ((Component)camera).transform.right;
		clock = age;
		RealmOpeningForDraw = opening;
		visible = fade * (1f - CastTimeline.Expansion(((Vector3)(ref view)).magnitude / radius - 0.9f, 0.1f));
		awakening = CastTimeline.Expansion(age - opening - 0.6f, 0.9f);
		if (sky == null && !RealmProjection.Supported)
		{
			BuildSky();
		}
		if (sky != null)
		{
			sky.Alpha(visible * CastTimeline.Expansion(age - opening + 0.5f, 0.8f), depth: false);
			DrawEclipse();
		}
		DrawSigil();
		if (legacySanctuary)
		{
			DrawRuins(age, opening);
		}
		else
		{
			DrawArtifacts(age, opening);
		}
		DrawPool(age, opening);
		DrawHeavenRain(age, opening);
	}

	private void DrawSigil()
	{
		//IL_0089: 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_0095: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: 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_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: 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_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: 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_012c: 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)
		//IL_0136: Unknown result type (might be due to invalid IL or missing references)
		//IL_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_0144: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0153: Unknown result type (might be due to invalid IL or missing references)
		//IL_0158: Unknown result type (might be due to invalid IL or missing references)
		//IL_0162: Unknown result type (might be due to invalid IL or missing references)
		//IL_0191: Unknown result type (might be due to invalid IL or missing references)
		//IL_0196: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ff: 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_0206: Unknown result type (might be due to invalid IL or missing references)
		//IL_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_022e: Unknown result type (might be due to invalid IL or missing references)
		//IL_022f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0231: Unknown result type (might be due to invalid IL or missing references)
		//IL_0233: Unknown result type (might be due to invalid IL or missing references)
		//IL_0238: Unknown result type (might be due to invalid IL or missing references)
		//IL_023a: Unknown result type (might be due to invalid IL or missing references)
		//IL_023c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_024e: Unknown result type (might be due to invalid IL or missing references)
		//IL_024f: 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_0253: Unknown result type (might be due to invalid IL or missing references)
		//IL_025d: Unknown result type (might be due to invalid IL or missing references)
		//IL_025f: Unknown result type (might be due to invalid IL or missing references)
		//IL_026f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0271: Unknown result type (might be due to invalid IL or missing references)
		//IL_0273: Unknown result type (might be due to invalid IL or missing references)
		//IL_0278: Unknown result type (might be due to invalid IL or missing references)
		//IL_027a: Unknown result type (might be due to invalid IL or missing references)
		//IL_027c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0286: Unknown result type (might be due to invalid IL or missing references)
		//IL_0288: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
		//IL_0303: Unknown result type (might be due to invalid IL or missing references)
		//IL_032b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0330: Unknown result type (might be due to invalid IL or missing references)
		//IL_0338: Unknown result type (might be due to invalid IL or missing references)
		//IL_033a: Unknown result type (might be due to invalid IL or missing references)
		//IL_034f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0354: Unknown result type (might be due to invalid IL or missing references)
		//IL_035f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0369: Unknown result type (might be due to invalid IL or missing references)
		//IL_036e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0373: Unknown result type (might be due to invalid IL or missing references)
		//IL_0375: Unknown result type (might be due to invalid IL or missing references)
		//IL_038a: Unknown result type (might be due to invalid IL or missing references)
		//IL_038f: Unknown result type (might be due to invalid IL or missing references)
		//IL_039a: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b5: Unknown result type (might be due to invalid IL or missing references)
		sigil.Clear();
		Vector3 val = default(Vector3);
		((Vector3)(ref val))..ctor(0f, radius * 0.58f, radius * 0.34f);
		float num = (closing ? 0f : CosmicTimeline.Volley(clock - RealmOpeningForDraw));
		Color val2 = default(Color);
		((Color)(ref val2))..ctor(3f, 0.08f, 0.13f, visible * awakening * (0.52f + num * 0.16f) * intensity);
		Vector3 val3 = val - Vector3.up * radius * 0.17f;
		Vector3 tail = val + Vector3.up * radius * 0.16f;
		sigil.Trail(val3, tail, 0.11f, val2, forward);
		sigil.Trail(val3, tail, 0.46f, new Color(1f, 0.015f, 0.055f, val2.a * 0.12f), forward);
		Quaternion val4 = Quaternion.AngleAxis(clock * 4f, Vector3.up);
		Vector3 val5 = val3 + Vector3.up * radius * 0.052f;
		for (int i = 0; i < 4; i++)
		{
			Vector3 val6 = val4 * new Vector3(Mathf.Cos((float)i * MathF.PI * 0.5f), 0f, Mathf.Sin((float)i * MathF.PI * 0.5f)) * radius * 0.022f;
			Vector3 val7 = val4 * new Vector3(Mathf.Cos((float)(i + 1) * MathF.PI * 0.5f), 0f, Mathf.Sin((float)(i + 1) * MathF.PI * 0.5f)) * radius * 0.022f;
			Color color = val2;
			color.a *= 0.24f + (float)(i % 2) * 0.12f;
			sigil.Triangle(val3, val5 + val6, val5 + val7, color);
			sigil.Line(val3, val5 + val6, 0.047f, val2, forward);
			sigil.Line(val5 + val6, val5 + val7, 0.03f, val2, forward);
		}
		for (int j = 0; j < 2; j++)
		{
			for (int k = 0; k < 64; k++)
			{
				float num2 = (float)k * MathF.PI / 32f;
				float num3 = (float)(k + 1) * MathF.PI / 32f;
				Vector3 val8 = val + Vector3.up * ((j == 0) ? (radius * 0.045f) : ((0f - radius) * 0.035f));
				Quaternion val9 = Quaternion.Euler((float)(56 + j * 32), clock * ((j == 0) ? 2f : (-1.5f)), (float)(j * 24));
				sigil.Line(val8 + val9 * new Vector3(Mathf.Cos(num2), Mathf.Sin(num2), 0f) * radius * 0.026f, val8 + val9 * new Vector3(Mathf.Cos(num3), Mathf.Sin(num3), 0f) * radius * 0.026f, 0.045f, val2, forward);
			}
		}
		sigil.Upload(radius);
		((Renderer)sigil.Renderer).enabled = visible * awakening > 0.001f;
	}

	private void BuildSky()
	{
		//IL_00e0: 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_00fe: 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_0111: Unknown result type (might be due to invalid IL or missing references)
		sky = Layer("Burgundy eclipse firmament", additive: false, 2985);
		eclipse = Layer("Black celestial disc", additive: false, 3040);
		energy = Layer("Eclipse corona and sacred rings", additive: true, 3100);
		Color color = default(Color);
		for (int i = 0; i < 24; i++)
		{
			for (int j = 0; j < 96; j++)
			{
				float num = MathF.PI * ((float)i + 0.5f) / 24f;
				float num2 = Mathf.Pow(Mathf.Sin(num), 5f);
				float num3 = 0.6f + 0.4f * Mathf.PerlinNoise((float)j * 0.17f, (float)i * 0.34f);
				((Color)(ref color))..ctor(0.018f + 0.16f * num2 * num3, 0.003f + 0.006f * num3, 0.017f + 0.022f * num2, 1f);
				sky.Quad(SkyPoint(i, j, 24, 96), SkyPoint(i + 1, j, 24, 96), SkyPoint(i + 1, j + 1, 24, 96), SkyPoint(i, j + 1, 24, 96), color);
			}
		}
		sky.Upload(radius);
	}

	private Vector3 SkyPoint(int y, int x, int bands, int sectors)
	{
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		float num = MathF.PI * (float)y / (float)bands;
		float num2 = MathF.PI * 2f * (float)x / (float)sectors;
		return new Vector3(Mathf.Sin(num) * Mathf.Cos(num2), Mathf.Cos(num), Mathf.Sin(num) * Mathf.Sin(num2)) * radius * 0.992f;
	}

	private void DrawEclipse()
	{
		//IL_0016: 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_002b: 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_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: 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_00ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: 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_01f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fa: 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_020b: Unknown result type (might be due to invalid IL or missing references)
		//IL_020c: Unknown result type (might be due to invalid IL or missing references)
		//IL_020f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0216: Unknown result type (might be due to invalid IL or missing references)
		//IL_021b: 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_0221: 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_022b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0230: Unknown result type (might be due to invalid IL or missing references)
		//IL_0235: Unknown result type (might be due to invalid IL or missing references)
		//IL_0236: Unknown result type (might be due to invalid IL or missing references)
		//IL_0239: 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_0245: Unknown result type (might be due to invalid IL or missing references)
		//IL_024a: 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_024e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0250: Unknown result type (might be due to invalid IL or missing references)
		//IL_026b: Unknown result type (might be due to invalid IL or missing references)
		//IL_026c: Unknown result type (might be due to invalid IL or missing references)
		//IL_026f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0274: Unknown result type (might be due to invalid IL or missing references)
		//IL_0279: Unknown result type (might be due to invalid IL or missing references)
		//IL_027a: Unknown result type (might be due to invalid IL or missing references)
		//IL_027d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0282: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02af: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ec: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0301: Unknown result type (might be due to invalid IL or missing references)
		//IL_0306: Unknown result type (might be due to invalid IL or missing references)
		//IL_0308: Unknown result type (might be due to invalid IL or missing references)
		//IL_0322: Unknown result type (might be due to invalid IL or missing references)
		//IL_0328: Unknown result type (might be due to invalid IL or missing references)
		//IL_0332: Unknown result type (might be due to invalid IL or missing references)
		//IL_0337: Unknown result type (might be due to invalid IL or missing references)
		//IL_033c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0344: Unknown result type (might be due to invalid IL or missing references)
		//IL_0346: Unknown result type (might be due to invalid IL or missing references)
		//IL_036a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0370: Unknown result type (might be due to invalid IL or missing references)
		eclipse.Clear();
		energy.Clear();
		Vector3 val = Vector3.up * radius * 0.76f;
		float num = radius * 0.255f;
		float num2 = visible * awakening;
		Vector3 val2 = default(Vector3);
		Vector3 val3 = default(Vector3);
		Color ca = default(Color);
		Color cb = default(Color);
		Color cc = default(Color);
		Color cd = default(Color);
		for (int i = 0; i < 192; i++)
		{
			float num3 = (float)i * MathF.PI * 2f / 192f;
			float num4 = (float)(i + 1) * MathF.PI * 2f / 192f;
			((Vector3)(ref val2))..ctor(Mathf.Cos(num3), 0f, Mathf.Sin(num3));
			((Vector3)(ref val3))..ctor(Mathf.Cos(num4), 0f, Mathf.Sin(num4));
			eclipse.Triangle(val, val + val2 * num, val + val3 * num, new Color(0.001f, 0f, 0.002f, num2));
			for (int j = 0; j < 6; j++)
			{
				float num5 = CoronaRadius(j);
				float num6 = CoronaRadius(j + 1);
				float num7 = CoronaOpacity(j) * num2 * intensity;
				float num8 = CoronaOpacity(j + 1) * num2 * intensity;
				float num9 = 0.92f + 0.08f * Mathf.Sin(num3 * 3f - clock * 0.3f);
				float num10 = 0.92f + 0.08f * Mathf.Sin(num4 * 3f - clock * 0.3f);
				((Color)(ref ca))..ctor(2.4f, 0.025f, 0.07f, num7 * num9);
				((Color)(ref cb))..ctor(2.4f, 0.025f, 0.07f, num7 * num10);
				((Color)(ref cc))..ctor(2.4f, 0.025f, 0.07f, num8 * num10);
				((Color)(ref cd))..ctor(2.4f, 0.025f, 0.07f, num8 * num9);
				energy.GradientQuad(val + val2 * num * num5, val + val3 * num * num5, val + val3 * num * num6, val + val2 * num * num6, ca, cb, cc, cd);
			}
			energy.Line(val + val2 * num, val + val3 * num, 0.1f, new Color(2.6f, 0.09f, 0.15f, num2 * 0.75f * intensity), forward);
			if (i % 32 < 20)
			{
				float num11 = clock * 0.035f;
				Vector3 a = val + new Vector3(Mathf.Cos(num3 + num11), 0f, Mathf.Sin(num3 + num11)) * num * 1.6f;
				Vector3 b = val + new Vector3(Mathf.Cos(num4 + num11), 0f, Mathf.Sin(num4 + num11)) * num * 1.6f;
				energy.Line(a, b, 0.035f, new Color(1f, 0.015f, 0.05f, num2 * 0.12f * intensity), forward);
			}
		}
		eclipse.Upload(radius);
		energy.Upload(radius);
		MeshRenderer renderer = eclipse.Renderer;
		bool enabled = (((Renderer)energy.Renderer).enabled = num2 > 0.001f);
		((Renderer)renderer).enabled = enabled;
	}

	private static float CoronaRadius(int band)
	{
		return band switch
		{
			0 => 0.997f, 
			1 => 1.014f, 
			2 => 1.045f, 
			3 => 1.095f, 
			4 => 1.18f, 
			5 => 1.29f, 
			_ => 1.42f, 
		};
	}

	private static float CoronaOpacity(int band)
	{
		return band switch
		{
			0 => 0.32f, 
			1 => 0.46f, 
			2 => 0.26f, 
			3 => 0.12f, 
			4 => 0.045f, 
			5 => 0.012f, 
			_ => 0f, 
		};
	}

	private void OnDestroy()
	{
		foreach (RealmMesh layer in layers)
		{
			layer.Dispose();
		}
		if (Object.op_Implicit((Object)(object)stoneTexture))
		{
			Object.Destroy((Object)(object)stoneTexture);
		}
	}

	private void BuildArtifacts()
	{
		artifacts = Layer("Four suspended celestial remnants", additive: false, 3001);
		artifactEdges = Layer("Celestial fracture glints", additive: true, 3098);
	}

	private void DrawArtifacts(float age, float opening)
	{
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_0107: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: 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_0115: Unknown result type (might be due to invalid IL or missing references)
		//IL_011f: 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_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_012b: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: 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_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0145: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_01df: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f0: 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_01f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_020e: 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_021a: Unknown result type (might be due to invalid IL or missing references)
		//IL_021f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0224: Unknown result type (might be due to invalid IL or missing references)
		//IL_0226: Unknown result type (might be due to invalid IL or missing references)
		//IL_0228: Unknown result type (might be due to invalid IL or missing references)
		//IL_0271: Unknown result type (might be due to invalid IL or missing references)
		//IL_0273: Unknown result type (might be due to invalid IL or missing references)
		//IL_0275: Unknown result type (might be due to invalid IL or missing references)
		//IL_0277: Unknown result type (might be due to invalid IL or missing references)
		//IL_0284: Unknown result type (might be due to invalid IL or missing references)
		//IL_0286: Unknown result type (might be due to invalid IL or missing references)
		//IL_0288: Unknown result type (might be due to invalid IL or missing references)
		//IL_028a: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
		artifacts.Clear();
		artifactEdges.Clear();
		float num = CastTimeline.Expansion(age - opening - 0.7f, 1.8f) * visible;
		float num2 = 1f;
		Color val6 = default(Color);
		Color color2 = default(Color);
		for (int i = 0; i < 4; i++)
		{
			float num3 = (float)(35 + i * 90) * (MathF.PI / 180f);
			Vector3 val = new Vector3(Mathf.Cos(num3) * 0.68f, 0.23f + (float)i * 0.025f, Mathf.Sin(num3) * 0.68f) * radius;
			val.y += Mathf.Sin(age * 0.16f + (float)i) * 0.45f;
			Quaternion val2 = Quaternion.Euler((float)(12 + i * 7), age * ((i % 2 == 0) ? 0.65f : (-0.45f)) + (float)(i * 39), (float)(24 - i * 9));
			float num4 = radius * (0.16f + (float)i * 0.017f);
			float num5 = radius * (0.022f + (float)i * 0.0015f);
			Vector3 val3 = val + val2 * Vector3.up * num4 * 0.55f;
			Vector3 val4 = val - val2 * Vector3.up * num4 * 0.6f;
			Vector3 val5 = view - val;
			float num6 = CastTimeline.Expansion(((Vector3)(ref val5)).magnitude - 4f, 9f);
			num2 = Mathf.Min(num2, num6);
			((Color)(ref val6))..ctor(0.028f, 0.018f, 0.035f, num * num6);
			for (int j = 0; j < 4; j++)
			{
				float num7 = (float)j * MathF.PI * 0.5f;
				float num8 = (float)(j + 1) * MathF.PI * 0.5f;
				Vector3 val7 = val + val2 * new Vector3(Mathf.Cos(num7), 0.25f, Mathf.Sin(num7)) * num5;
				Vector3 val8 = val + val2 * new Vector3(Mathf.Cos(num8), 0.25f, Mathf.Sin(num8)) * num5;
				Color color = val6;
				float num9 = 0.55f + (float)j * 0.22f;
				color.r *= num9;
				color.g *= num9;
				color.b *= num9;
				artifacts.Triangle(val3, val7, val8, color);
				artifacts.Triangle(val4, val8, val7, color);
				if (j == i % 4)
				{
					((Color)(ref color2))..ctor(0.9f, 0.018f, 0.053f, num * num6 * 0.32f * intensity);
					artifactEdges.Trail(val7, val3, 0.08f, color2, forward);
					artifactEdges.Trail(val7, val4, 0.05f, color2, forward);
				}
			}
		}
		artifacts.Upload(radius);
		artifactEdges.Upload(radius);
		artifacts.Alpha(1f, num > 0.999f && num2 > 0.999f);
		MeshRenderer renderer = artifacts.Renderer;
		bool enabled = (((Renderer)artifactEdges.Renderer).enabled = num > 0.001f);
		((Renderer)renderer).enabled = enabled;
	}

	private void BuildPool()
	{
		//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)
		for (int i = 0; i < surfaceHits.Length; i++)
		{
			ref Vector4 reference = ref surfaceHits[i];
			reference = new Vector4(0f, 0f, 0f, -999f);
		}
		impactSparks = Layer("Pooled celestial impact spray", additive: true, 3100);
	}

	private void DrawPool(float age, float opening)
	{
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_012a: Unknown result type (might be due to invalid IL or missing references)
		//IL_012d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: 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_0141: 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_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_015c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0161: Unknown result type (might be due to invalid IL or missing references)
		//IL_0178: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_017f: Unknown result type (might be due to invalid IL or missing