Decompiled source of Computational Facility v1.0.1

plugins/ComputationalFacility/ComputationalFacility.dll

Decompiled 12 hours 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 EntityStates;
using EntityStates.Drone;
using EntityStates.Turret1;
using HarmonyLib;
using KinematicCharacterController;
using RoR2;
using RoR2.CharacterAI;
using RoR2.ContentManagement;
using RoR2.Projectile;
using RoR2.Skills;
using RoR2.UI;
using UnityEngine;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.Rendering.PostProcessing;
using UnityEngine.SceneManagement;

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

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);
		}
	}
}
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 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(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 static class DomainVisual
{
	private static Material glowTemplate;

	private static bool EnsureMaterial()
	{
		//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Expected O, but got Unknown
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0142: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)glowTemplate))
		{
			return true;
		}
		Shader[] array = Resources.FindObjectsOfTypeAll<Shader>();
		string[] array2 = new string[4] { "Particles/Standard Unlit", "Legacy Shaders/Particles/Additive", "Particles/Additive", "Sprites/Default" };
		Shader val = null;
		string[] array3 = array2;
		foreach (string text in array3)
		{
			Shader[] array4 = array;
			foreach (Shader val2 in array4)
			{
				if (Object.op_Implicit((Object)(object)val2) && ((Object)val2).name == text && val2.isSupported)
				{
					val = val2;
					break;
				}
			}
			if (Object.op_Implicit((Object)(object)val))
			{
				break;
			}
		}
		if (!Object.op_Implicit((Object)(object)val))
		{
			return false;
		}
		Material val3 = new Material(val);
		((Object)val3).name = "Computational Facility Glow";
		val3.renderQueue = 3100;
		glowTemplate = val3;
		if (glowTemplate.HasProperty("_MainTex"))
		{
			glowTemplate.SetTexture("_MainTex", (Texture)(object)Texture2D.whiteTexture);
		}
		if (glowTemplate.HasProperty("_Color"))
		{
			glowTemplate.SetColor("_Color", Color.white);
		}
		if (glowTemplate.HasProperty("_TintColor"))
		{
			glowTemplate.SetColor("_TintColor", Color.white);
		}
		if (glowTemplate.HasProperty("_Mode"))
		{
			glowTemplate.SetFloat("_Mode", 4f);
		}
		if (glowTemplate.HasProperty("_ColorMode"))
		{
			glowTemplate.SetFloat("_ColorMode", 0f);
		}
		glowTemplate.SetInt("_SrcBlend", 5);
		glowTemplate.SetInt("_DstBlend", 1);
		glowTemplate.SetInt("_ZWrite", 0);
		glowTemplate.SetInt("_Cull", 0);
		glowTemplate.DisableKeyword("_ALPHATEST_ON");
		glowTemplate.DisableKeyword("_ALPHAPREMULTIPLY_ON");
		glowTemplate.DisableKeyword("_ALPHAMODULATE_ON");
		glowTemplate.DisableKeyword("SOFTPARTICLES_ON");
		glowTemplate.DisableKeyword("FADING_ON");
		glowTemplate.EnableKeyword("_ALPHABLEND_ON");
		Plugin.Log.LogInfo((object)("Domain visual shader resolved: " + ((Object)val).name + " supported=" + val.isSupported));
		return true;
	}

	internal static Material CreateGlowMaterial()
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Expected O, but got Unknown
		if (!EnsureMaterial())
		{
			return null;
		}
		return new Material(glowTemplate);
	}

	internal static void Clear()
	{
		if (Object.op_Implicit((Object)(object)glowTemplate))
		{
			Object.Destroy((Object)(object)glowTemplate);
		}
		glowTemplate = null;
	}
}
internal sealed class FacilityArchitecture
{
	private RealmMesh frames;

	private RealmMesh panels;

	private RealmMesh signals;

	private readonly Vector3[] racks = (Vector3[])(object)new Vector3[8];

	private readonly Quaternion[] rotations = (Quaternion[])(object)new Quaternion[8];

	private readonly bool[] grounded = new bool[8];

	private readonly float radius;

	private readonly float unit;

	private static readonly Quaternion identity = Quaternion.Euler(0f, 0f, 0f);

	internal FacilityArchitecture(Transform parent, float radius)
	{
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: 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_0121: 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_0138: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: 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_0156: Unknown result type (might be due to invalid IL or missing references)
		//IL_0185: Unknown result type (might be due to invalid IL or missing references)
		//IL_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_019d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_0205: Unknown result type (might be due to invalid IL or missing references)
		//IL_0221: Unknown result type (might be due to invalid IL or missing references)
		//IL_022c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0231: 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_023b: Unknown result type (might be due to invalid IL or missing references)
		//IL_023d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0266: 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_026d: 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_029b: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d3: 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_03d1: 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_03ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_03f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0406: Unknown result type (might be due to invalid IL or missing references)
		//IL_0411: Unknown result type (might be due to invalid IL or missing references)
		//IL_0416: Unknown result type (might be due to invalid IL or missing references)
		//IL_0418: 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_0436: Unknown result type (might be due to invalid IL or missing references)
		//IL_0441: Unknown result type (might be due to invalid IL or missing references)
		//IL_0446: Unknown result type (might be due to invalid IL or missing references)
		//IL_045a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0465: Unknown result type (might be due to invalid IL or missing references)
		//IL_046a: Unknown result type (might be due to invalid IL or missing references)
		//IL_046c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0479: Unknown result type (might be due to invalid IL or missing references)
		//IL_048a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0495: Unknown result type (might be due to invalid IL or missing references)
		//IL_049a: Unknown result type (might be due to invalid IL or missing references)
		//IL_04ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_04b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_04be: Unknown result type (might be due to invalid IL or missing references)
		//IL_04c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_030b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0310: Unknown result type (might be due to invalid IL or missing references)
		//IL_0315: Unknown result type (might be due to invalid IL or missing references)
		//IL_031a: 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_0348: Unknown result type (might be due to invalid IL or missing references)
		//IL_034d: 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_035c: Unknown result type (might be due to invalid IL or missing references)
		//IL_035e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0368: Unknown result type (might be due to invalid IL or missing references)
		//IL_0373: Unknown result type (might be due to invalid IL or missing references)
		//IL_0378: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03a8: Unknown result type (might be due to invalid IL or missing references)
		this.radius = radius;
		unit = radius / 62.5f;
		try
		{
			frames = new RealmMesh(parent, "Facility graphite server chassis", additive: false, 3020);
			panels = new RealmMesh(parent, "Facility cyan rack faces and assembly gantry", additive: true, 3102);
			signals = new RealmMesh(parent, "Facility bounded data traffic", additive: true, 3107);
			Vector3 val = default(Vector3);
			for (int i = 0; i < 8; i++)
			{
				float num = ((float)i + 0.5f) * MathF.PI / 4f;
				((Vector3)(ref val))..ctor(Mathf.Sin(num) * radius * 0.65f, 0f, Mathf.Cos(num) * radius * 0.65f);
				Quaternion val2 = Quaternion.Euler(0f, num * 180f / MathF.PI, 0f);
				if (MachineryGrounding.TryPlace(parent.position, val, val2, 6f * unit, 3.6f * unit, 20.25f * unit, radius, out var foot, out var foundation))
				{
					val = foot;
					grounded[i] = true;
					racks[i] = val;
					rotations[i] = val2;
					MachineryGrounding.Foundation(frames, val, val2, 6f * unit, 3.6f * unit, foundation, new Color(0.026f, 0.052f, 0.076f, 0.9f));
					Rack(val, rotations[i]);
				}
			}
			Color color = default(Color);
			((Color)(ref color))..ctor(0.035f, 0.07f, 0.095f, 0.9f);
			Color color2 = default(Color);
			((Color)(ref color2))..ctor(0.07f, 0.8f, 1.3f, 0.65f);
			for (int j = 0; j < 4; j++)
			{
				Quaternion val3 = Quaternion.Euler(0f, (float)(j * 90), 0f);
				for (int k = 0; k < 3; k++)
				{
					Vector3 val4 = new Vector3(0f, (float)(25 + k * 2), 9f) * unit;
					frames.Box(val3 * val4, new Vector3(20f * unit, 0.65f * unit, 1.4f * unit), val3, color);
					panels.Box(val3 * (val4 + new Vector3(0f, -0.36f * unit, -0.35f * unit)), new Vector3(18f * unit, 0.07f * unit, 0.12f * unit), val3, color2);
					for (int l = 0; l < 7; l++)
					{
						Vector3 val5 = val3 * (val4 + new Vector3((float)(l - 3) * 2.5f * unit, 0.6f * unit, 0f));
						frames.Box(val5, new Vector3(1.2f * unit, 0.55f * unit, 0.7f * unit), val3, color);
						panels.Box(val5 + Vector3.up * 0.31f * unit, new Vector3(0.85f * unit, 0.035f * unit, 0.3f * unit), val3, color2);
					}
				}
				frames.Box(val3 * (new Vector3(9f, 27f, 9f) * unit), new Vector3(0.8f, 7f, 0.8f) * unit, val3, color);
				frames.Box(val3 * (new Vector3(0f, 29f, 23f) * unit), new Vector3(1f, 0.55f, 26f) * unit, val3, color);
				panels.Box(val3 * (new Vector3(0f, 28.7f, 23f) * unit), new Vector3(0.1f, 0.07f, 26f) * unit, val3, color2);
			}
			frames.Upload(radius);
			panels.Upload(radius);
			frames.Alpha(0f, depth: false);
			panels.Alpha(0f, depth: false);
			signals.Alpha(0f, depth: false);
		}
		catch
		{
			Dispose();
			throw;
		}
	}

	private void Rack(Vector3 p, Quaternion q)
	{
		//IL_0043: 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_0057: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: 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_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_009d: Unknown result type (might be due to invalid IL or missing references)
		//IL_009e: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c6: 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_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0102: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: 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_0142: 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_014f: 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_0164: 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_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_018e: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b1: 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_01bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_0215: 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_0231: Unknown result type (might be due to invalid IL or missing references)
		//IL_023c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0241: Unknown result type (might be due to invalid IL or missing references)
		//IL_0246: Unknown result type (might be due to invalid IL or missing references)
		//IL_025a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0265: Unknown result type (might be due to invalid IL or missing references)
		//IL_026a: 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_0277: 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_0299: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a4: 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_02ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cd: 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_02d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ed: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_030a: Unknown result type (might be due to invalid IL or missing references)
		//IL_030f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0314: 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_0333: 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_034d: Unknown result type (might be due to invalid IL or missing references)
		Color color = default(Color);
		((Color)(ref color))..ctor(0.026f, 0.052f, 0.076f, 0.9f);
		Color color2 = default(Color);
		((Color)(ref color2))..ctor(0.045f, 0.72f, 1.15f, 0.6f);
		for (int i = -1; i <= 1; i += 2)
		{
			frames.Box(p + q * (new Vector3((float)i * 2.6f, 10f, 0f) * unit), new Vector3(0.45f, 20f, 2.8f) * unit, q, color);
			panels.Box(p + q * (new Vector3((float)i * 2.66f, 10f, -1.45f) * unit), new Vector3(0.07f, 19f, 0.09f) * unit, q, color2);
		}
		frames.Box(p + Vector3.up * 20f * unit, new Vector3(5.6f, 0.5f, 3f) * unit, q, color);
		frames.Box(p + Vector3.up * 0.4f * unit, new Vector3(6f, 0.8f, 3.6f) * unit, q, color);
		for (int j = 0; j < 12; j++)
		{
			float num = 1.6f + (float)j * 1.48f;
			frames.Box(p + q * (new Vector3(0f, num, 0f) * unit), new Vector3(4.7f, 1.15f, 2.3f) * unit, q, color);
			for (int k = -1; k <= 1; k += 2)
			{
				for (int l = 0; l < 3; l++)
				{
					panels.Box(p + q * (new Vector3(-1.5f + (float)l * 1.4f, num, (float)k * 1.17f) * unit), new Vector3(0.92f, 0.06f, 0.025f) * unit, q, color2);
					panels.Box(p + q * (new Vector3(-1.5f + (float)l * 1.4f, num - 0.25f, (float)k * 1.17f) * unit), new Vector3(0.38f, 0.035f, 0.025f) * unit, q, color2);
				}
				panels.Box(p + q * (new Vector3(2f, num, (float)k * 1.17f) * unit), new Vector3(0.09f, 0.23f, 0.025f) * unit, q, new Color(0.9f, 0.48f, 0.1f, 0.55f));
			}
		}
	}

	internal void Update(float age, float opening, float fade, float intensity, Vector3 view)
	{
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0227: Unknown result type (might be due to invalid IL or missing references)
		//IL_022c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0252: Unknown result type (might be due to invalid IL or missing references)
		//IL_0260: 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_0270: Unknown result type (might be due to invalid IL or missing references)
		//IL_0275: Unknown result type (might be due to invalid IL or missing references)
		//IL_0277: Unknown result type (might be due to invalid IL or missing references)
		//IL_0285: Unknown result type (might be due to invalid IL or missing references)
		//IL_0290: Unknown result type (might be due to invalid IL or missing references)
		//IL_0295: Unknown result type (might be due to invalid IL or missing references)
		//IL_029a: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02da: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_031b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0320: 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_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0111: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_013b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0140: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_016e: 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_0183: Unknown result type (might be due to invalid IL or missing references)
		//IL_0188: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: 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_01b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
		float num = CastTimeline.Expansion(age - opening * 0.35f, Mathf.Max(0.1f, opening * 0.5f)) * fade;
		frames.Alpha(num, depth: false);
		panels.Alpha(num * intensity, depth: false);
		signals.Alpha(num * intensity, depth: false);
		signals.Clear();
		Vector3 val5 = default(Vector3);
		for (int i = 0; i < 8; i++)
		{
			if (grounded[i])
			{
				Vector3 val = racks[i];
				Quaternion val2 = rotations[i];
				for (int j = 0; j < 4; j++)
				{
					float num2 = (age * 0.19f + (float)j * 0.25f + (float)i * 0.113f) % 1f;
					Vector3 val3 = val + val2 * (new Vector3(-2.7f, 1f + num2 * 17f, -1.5f) * unit);
					signals.Line(val3, val3 + Vector3.up * 1.1f * unit, 0.1f * unit, new Color(0.25f, 1.5f, 2f, 0.7f), view);
				}
				float num3 = (age * 0.11f + (float)i * 0.137f) % 1f;
				Vector3 val4 = val + Vector3.up * 20f * unit;
				((Vector3)(ref val5))..ctor(0f, 29f * unit, 0f);
				signals.Line(Vector3.Lerp(val4, val5, num3), Vector3.Lerp(val4, val5, Mathf.Min(1f, num3 + 0.035f)), 0.12f * unit, new Color(0.18f, 1.4f, 1.8f, 0.55f), view);
			}
		}
		for (int k = 0; k < 4; k++)
		{
			Quaternion val6 = Quaternion.Euler(0f, (float)(k * 90), 0f);
			float num4 = 22.5f + Mathf.Sin(age * 0.65f + (float)k * 0.7f) * 1.3f;
			Vector3 val7 = val6 * (new Vector3(-7f, num4, 7f) * unit);
			Vector3 b = val6 * (new Vector3(7f, num4, 7f) * unit);
			signals.Line(val7, b, 0.055f * unit, new Color(0.1f, 0.9f, 1.4f, 0.48f), view);
			signals.Line(val7, val7 + Vector3.up * 1.3f * unit, 0.06f * unit, new Color(0.2f, 1.1f, 1.8f, 0.5f), view);
		}
		signals.Upload(radius);
	}

	internal void Dispose()
	{
		if (frames != null)
		{
			frames.Dispose();
		}
		if (panels != null)
		{
			panels.Dispose();
		}
		if (signals != null)
		{
			signals.Dispose();
		}
	}
}
internal sealed class FacilityAudio : MonoBehaviour
{
	private readonly GameObject[] emitters = (GameObject[])(object)new GameObject[4];

	private readonly uint[] playing = new uint[4];

	private float start;

	private float opening;

	private float collapse;

	private float closing = -1f;

	private bool awakeCue;

	private bool crystalCue;

	private bool loop;

	internal static FacilityAudio Create(Transform parent, float age, float opening, float collapse)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Expected O, but got Unknown
		GameObject val = new GameObject("Computational Facility positional audio");
		val.transform.SetParent(parent, false);
		FacilityAudio facilityAudio = val.AddComponent<FacilityAudio>();
		facilityAudio.start = Time.time - age;
		facilityAudio.opening = opening;
		facilityAudio.collapse = collapse;
		facilityAudio.awakeCue = age >= opening;
		facilityAudio.crystalCue = age >= opening - 1f;
		for (int i = 0; i < 4; i++)
		{
			GameObject val2 = new GameObject("Facility voice " + i);
			val2.transform.SetParent(val.transform, false);
			val2.AddComponent<AkGameObj>();
			facilityAudio.emitters[i] = val2;
		}
		if (age < 0.3f)
		{
			facilityAudio.Play(0, "Play_majorConstruct_spawn_rumble");
		}
		return facilityAudio;
	}

	private float Gain(int slot)
	{
		return Plugin.Clamp(Plugin.SoundVolume.Value, 0f, 1f) * slot switch
		{
			3 => 0.2f, 
			1 => 0.13f, 
			_ => 0.45f, 
		} * ((closing < 0f) ? 1f : (1f - CastTimeline.Expansion(Time.time - closing, collapse)));
	}

	private void Play(int slot, string name)
	{
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		if (!Plugin.SoundEnabled.Value || !AkSoundEngine.IsInitialized())
		{
			return;
		}
		if (playing[slot] != 0)
		{
			AkSoundEngine.StopPlayingID(playing[slot], 80);
		}
		foreach (AkAudioListener listener in ((BaseListenerList)AkAudioListener.DefaultListeners).ListenerList)
		{
			if (Object.op_Implicit((Object)(object)listener) && ((Behaviour)listener).isActiveAndEnabled)
			{
				AkSoundEngine.SetGameObjectOutputBusVolume(emitters[slot], ((Component)listener).gameObject, Gain(slot));
			}
		}
		playing[slot] = Util.PlaySound(name, emitters[slot]);
	}

	internal void Materialize(Vector3 position)
	{
		//IL_000d: Unknown result type (might be due to invalid IL or missing references)
		emitters[3].transform.position = position;
		Play(3, "Play_bellBody_impact");
	}

	internal void Collapse()
	{
		if (!(closing >= 0f))
		{
			closing = Time.time;
			if (playing[1] != 0)
			{
				AkSoundEngine.StopPlayingID(playing[1], 250);
				playing[1] = 0u;
			}
			Play(0, "Play_lunar_wisp_attack1_windDown");
			Play(2, "Play_char_glass_death");
		}
	}

	private void Update()
	{
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		if (!Plugin.SoundEnabled.Value)
		{
			Stop();
		}
		else
		{
			if (!AkSoundEngine.IsInitialized())
			{
				return;
			}
			float num = Time.time - start;
			if (closing < 0f)
			{
				if (!loop)
				{
					loop = true;
					Play(1, "Play_env_ship_pulsing_energy_loop");
				}
				if (!crystalCue && num >= opening - 1f)
				{
					crystalCue = true;
					Play(2, "Play_char_glass_death");
				}
				if (!awakeCue && num >= opening)
				{
					awakeCue = true;
					Play(0, "Play_golem_spawn");
				}
			}
			foreach (AkAudioListener listener in ((BaseListenerList)AkAudioListener.DefaultListeners).ListenerList)
			{
				if (Object.op_Implicit((Object)(object)listener) && ((Behaviour)listener).isActiveAndEnabled)
				{
					for (int i = 0; i < 4; i++)
					{
						AkSoundEngine.SetGameObjectOutputBusVolume(emitters[i], ((Component)listener).gameObject, Gain(i));
					}
				}
			}
		}
	}

	private void Stop()
	{
		for (int i = 0; i < 4; i++)
		{
			if (playing[i] != 0)
			{
				AkSoundEngine.StopPlayingID(playing[i], 0);
				playing[i] = 0u;
			}
		}
		loop = false;
	}

	private void OnDisable()
	{
		Stop();
	}
}
public sealed class FacilityDroneLease : MonoBehaviour
{
	internal OperatorDomain Owner;

	private bool removing;

	internal void BodyStarted(CharacterBody body)
	{
		if (Object.op_Implicit((Object)(object)body) && !Object.op_Implicit((Object)(object)((Component)body).GetComponent<FacilityDroneBodyLease>()))
		{
			((Component)body).gameObject.AddComponent<FacilityDroneBodyLease>();
		}
	}

	private void FixedUpdate()
	{
		if (NetworkServer.active && !removing)
		{
			CharacterMaster component = ((Component)this).GetComponent<CharacterMaster>();
			component.destroyOnBodyDeath = true;
			if (!Object.op_Implicit((Object)(object)Owner) || !((Behaviour)Owner).isActiveAndEnabled)
			{
				FacilityDrones.Remove(component);
			}
		}
	}

	internal bool BeginRemoval()
	{
		if (removing)
		{
			return false;
		}
		removing = true;
		return true;
	}
}
public sealed class FacilityDroneBodyLease : MonoBehaviour
{
}
internal static class FacilityDrones
{
	private static bool Grounded(GameObject prefab)
	{
		if (Object.op_Implicit((Object)(object)prefab))
		{
			return ((Object)prefab).name == "Turret1Master";
		}
		return false;
	}

	private static float Clearance(GameObject prefab)
	{
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0075: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: 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_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		CharacterMaster val = (Object.op_Implicit((Object)(object)prefab) ? prefab.GetComponent<CharacterMaster>() : null);
		CharacterBody val2 = ((Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.bodyPrefab)) ? val.bodyPrefab.GetComponent<CharacterBody>() : null);
		if (!Object.op_Implicit((Object)(object)val2))
		{
			return 2f;
		}
		float num = Mathf.Max(1.5f, val2.radius + 0.75f);
		CapsuleCollider component = ((Component)val2).GetComponent<CapsuleCollider>();
		SphereCollider component2 = ((Component)val2).GetComponent<SphereCollider>();
		Vector3 lossyScale = ((Component)val2).transform.lossyScale;
		float num2 = Mathf.Max(Mathf.Abs(lossyScale.x), Mathf.Max(Mathf.Abs(lossyScale.y), Mathf.Abs(lossyScale.z)));
		if (Object.op_Implicit((Object)(object)component))
		{
			float num3 = num;
			Vector3 center = component.center;
			num = Mathf.Max(num3, (((Vector3)(ref center)).magnitude + Mathf.Max(component.radius, component.height * 0.5f)) * num2 + 0.5f);
		}
		if (Object.op_Implicit((Object)(object)component2))
		{
			float num4 = num;
			Vector3 center2 = component2.center;
			num = Mathf.Max(num4, (((Vector3)(ref center2)).magnitude + component2.radius) * num2 + 0.5f);
		}
		return num;
	}

	internal static bool Clear(Vector3 point, GameObject prefab)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		//IL_001e: 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_0023: 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_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_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0040: Unknown result type (might be due to invalid IL or missing references)
		float num = Clearance(prefab);
		Vector3 val = (Grounded(prefab) ? (point + Vector3.up * num) : point);
		LayerIndex world = LayerIndex.world;
		int num2 = LayerMask.op_Implicit(((LayerIndex)(ref world)).mask);
		LayerIndex entityPrecise = LayerIndex.entityPrecise;
		return !Physics.CheckSphere(val, num, num2 | LayerMask.op_Implicit(((LayerIndex)(ref entityPrecise)).mask), (QueryTriggerInteraction)1);
	}

	internal static bool FindPoint(Vector3 center, float radius, Vector3 owner, GameObject prefab, out Vector3 result)
	{
		//IL_000e: 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_001e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		//IL_005a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: 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)
		//IL_0150: 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_00a4: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: 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_010d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0112: Unknown result type (might be due to invalid IL or missing references)
		//IL_0117: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_0135: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: Unknown result type (might be due to invalid IL or missing references)
		float num = Clearance(prefab);
		RaycastHit val4 = default(RaycastHit);
		for (int i = 0; i < 12; i++)
		{
			Vector2 val = Random.insideUnitCircle * radius * 0.78f;
			Vector3 val2 = center + new Vector3(val.x, Random.Range(4f, Mathf.Min(20f, radius * 0.45f)), val.y);
			Vector3 val3 = val2 + Vector3.up * 12f;
			Vector3 down = Vector3.down;
			float num2 = radius + 24f;
			LayerIndex world = LayerIndex.world;
			if (!Physics.Raycast(val3, down, ref val4, num2, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)1) || (Grounded(prefab) && ((RaycastHit)(ref val4)).normal.y < 0.85f))
			{
				continue;
			}
			val2.y = ((RaycastHit)(ref val4)).point.y + (Grounded(prefab) ? 0.15f : Random.Range(num + 1f, num + 10f));
			Vector3 val5 = val2 - center;
			if (!(((Vector3)(ref val5)).magnitude + num >= radius) && Clear(val2, prefab))
			{
				Vector3 val6 = owner + Vector3.up;
				Vector3 val7 = val2;
				LayerIndex world2 = LayerIndex.world;
				if (!Physics.Linecast(val6, val7, LayerMask.op_Implicit(((LayerIndex)(ref world2)).mask), (QueryTriggerInteraction)1))
				{
					result = val2;
					return true;
				}
			}
		}
		result = Vector3.zero;
		return false;
	}

	internal static void Remove(CharacterMaster master)
	{
		if (!NetworkServer.active || !Object.op_Implicit((Object)(object)master))
		{
			return;
		}
		FacilityDroneLease component = ((Component)master).GetComponent<FacilityDroneLease>();
		if (Object.op_Implicit((Object)(object)component) && component.BeginRemoval())
		{
			DroneRepairMaster component2 = ((Component)master).GetComponent<DroneRepairMaster>();
			if (Object.op_Implicit((Object)(object)component2))
			{
				component2.DoNotRepair = true;
			}
			master.cannotRevive = true;
			CharacterBody body = master.GetBody();
			if (Object.op_Implicit((Object)(object)body))
			{
				NetworkServer.Destroy(((Component)body).gameObject);
			}
			NetworkServer.Destroy(((Component)master).gameObject);
		}
	}
}
[HarmonyPatch(typeof(DroneRepairMaster), "RespawnBrokenBody")]
internal static class FacilityNoRepair
{
	private static bool Prefix(DroneRepairMaster __instance)
	{
		return !Object.op_Implicit((Object)(object)((Component)__instance).GetComponent<FacilityDroneLease>());
	}
}
[HarmonyPatch(typeof(DeathState), "OnImpactServer")]
internal static class FacilityNoWreck
{
	private static bool Prefix(DeathState __instance)
	{
		if (Object.op_Implicit((Object)(object)((EntityState)__instance).outer))
		{
			return !Object.op_Implicit((Object)(object)((Component)((EntityState)__instance).outer).GetComponent<FacilityDroneBodyLease>());
		}
		return true;
	}
}
[HarmonyPatch(typeof(DeathState), "OnEnter")]
internal static class FacilityNoTurretWreck
{
	private static void Prefix(DeathState __instance)
	{
		if (Object.op_Implicit((Object)(object)((EntityState)__instance).outer) && Object.op_Implicit((Object)(object)((Component)((EntityState)__instance).outer).GetComponent<FacilityDroneBodyLease>()))
		{
			__instance.deadFormToSpawnOnDeath = null;
		}
	}
}
[HarmonyPatch(typeof(CharacterMotor), "PreMove")]
internal static class FacilityGravity
{
	private static void Prefix(CharacterMotor __instance, out float __state)
	{
		__state = __instance.velocity.y;
	}

	private static void Postfix(CharacterMotor __instance, float deltaTime, float __state)
	{
		//IL_0064: Unknown result type (might be due to invalid IL or missing references)
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0091: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: 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_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_0104: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_011a: 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_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01db: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_01ef: 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_020f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0258: 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_0281: 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_029b: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02db: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fa: 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)
		if (OperatorDomain.Live.Count == 0)
		{
			return;
		}
		CharacterBody component = ((Component)__instance).GetComponent<CharacterBody>();
		if (!__instance.hasEffectiveAuthority || !Object.op_Implicit((Object)(object)component) || component.isFlying || __instance.isFlying || !__instance.useGravity || !Object.op_Implicit((Object)(object)((BaseCharacterController)__instance).Motor) || !((Behaviour)((BaseCharacterController)__instance).Motor).enabled || Object.op_Implicit((Object)(object)component.currentVehicle) || (component.bodyFlags & 0x14000) != 0)
		{
			return;
		}
		OperatorDomain component2 = ((Component)component).GetComponent<OperatorDomain>();
		if (Object.op_Implicit((Object)(object)component2) && component2.FloatOwner(component))
		{
			Vector3 val = __instance.velocity;
			if (!__instance.isGrounded)
			{
				val.y = FacilityRules.PlayerVertical(__state, val.y);
				if (!__instance.disableAirControlUntilCollision)
				{
					Vector3 val2 = __instance.moveDirection;
					val2.y = 0f;
					float magnitude = ((Vector3)(ref val2)).magnitude;
					if (component.isSprinting && magnitude > 0f && magnitude < 1f)
					{
						val2 /= magnitude;
					}
					Vector3 val3 = val2 * __instance.walkSpeed;
					val3.y = val.y;
					val = Vector3.MoveTowards(val, val3, FacilityRules.ExtraAirAcceleration(__instance.acceleration, __instance.airControl) * deltaTime);
				}
			}
			__instance.velocity = val;
			return;
		}
		OperatorDomain operatorDomain = null;
		foreach (OperatorDomain item in OperatorDomain.Live)
		{
			if (Object.op_Implicit((Object)(object)item) && ((Behaviour)item).isActiveAndEnabled && item.Contains(component) && (!Object.op_Implicit((Object)(object)operatorDomain) || item.Height > operatorDomain.Height))
			{
				operatorDomain = item;
			}
		}
		if (!Object.op_Implicit((Object)(object)operatorDomain))
		{
			return;
		}
		float num = (component.isBoss ? 0.5f : 1f);
		float clearance = operatorDomain.Height * num;
		Vector3 val4 = component.footPosition + Vector3.up * 0.25f;
		Vector3 down = Vector3.down;
		float num2 = operatorDomain.Height * num + 20f;
		LayerIndex world = LayerIndex.world;
		RaycastHit val5 = default(RaycastHit);
		if (Physics.Raycast(val4, down, ref val5, num2, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)1))
		{
			clearance = Mathf.Max(0f, ((RaycastHit)(ref val5)).distance - 0.25f);
		}
		float num3 = FacilityRules.Drift(clearance, operatorDomain.Height * num, operatorDomain.Speed * num);
		if (component.corePosition.y > operatorDomain.Ceiling)
		{
			num3 = -0.75f;
		}
		if (num3 > 0f)
		{
			Vector3 corePosition = component.corePosition;
			Vector3 up = Vector3.up;
			float num4 = component.radius + 1f;
			LayerIndex world2 = LayerIndex.world;
			if (Physics.Raycast(corePosition, up, num4, LayerMask.op_Implicit(((LayerIndex)(ref world2)).mask), (QueryTriggerInteraction)1))
			{
				num3 = 0f;
			}
		}
		if (__instance.isGrounded && num3 > 0f)
		{
			((BaseCharacterController)__instance).Motor.ForceUnground(0.1f);
		}
		Vector3 velocity = __instance.velocity;
		velocity.y = Mathf.MoveTowards(velocity.y, num3, 80f * deltaTime);
		__instance.velocity = velocity;
	}
}
[HarmonyPatch(typeof(RampFogRenderer), "Render")]
internal static class FacilityFog
{
	internal static bool OwnsCamera(PostProcessRenderContext context)
	{
		Camera camera = context.camera;
		if (!Object.op_Implicit((Object)(object)camera) || ((Object)camera).name != "Scene Camera" || camera.stereoEnabled || camera.orthographic)
		{
			return false;
		}
		FacilityVisual facilityVisual = FacilityVisual.ForCamera(camera);
		if (Object.op_Implicit((Object)(object)facilityVisual) && facilityVisual.VisualWeight(camera) > 0.001f)
		{
			return FacilityProjection.Supported;
		}
		return false;
	}

	[HarmonyPriority(800)]
	[HarmonyBefore(new string[] { "local.alienskies.fog" })]
	private static bool Prefix(PostProcessRenderContext context)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		if (!OwnsCamera(context))
		{
			return true;
		}
		RuntimeUtilities.BlitFullscreenTriangle(context.command, context.source, context.destination, false, (Rect?)null);
		return false;
	}
}
[HarmonyPatch]
internal static class FacilityAlienFog
{
	private static bool Prepare()
	{
		return TargetMethod() != null;
	}

	private static MethodBase TargetMethod()
	{
		Type type = AccessTools.TypeByName("AlienSkies.Plugin");
		if (!(type == null))
		{
			return AccessTools.Method(type, "FogActive", new Type[1] { typeof(PostProcessRenderContext) }, (Type[])null);
		}
		return null;
	}

	private static void Postfix(PostProcessRenderContext context, ref bool __result)
	{
		if (__result && FacilityFog.OwnsCamera(context))
		{
			__result = false;
		}
	}
}
internal static class FacilityProjection
{
	private sealed class Frame
	{
		internal Camera Camera;

		internal PostProcessLayer Layer;

		internal FacilityVisual Owner;

		internal bool AddedDepth;

		internal bool Reported;

		internal CommandBuffer Commands;

		internal PropertySheetFactory Sheets;
	}

	[HarmonyPatch(typeof(PostProcessLayer), "OnPreCull")]
	private static class PrepareCamera
	{
		[HarmonyPriority(800)]
		private static void Prefix(PostProcessLayer __instance)
		{
			Camera component = ((Component)__instance).GetComponent<Camera>();
			if (Object.op_Implicit((Object)(object)component) && !(((Object)component).name != "Scene Camera"))
			{
				FacilityVisual facilityVisual = ((component.stereoEnabled || component.orthographic) ? null : FacilityVisual.ForCamera(component));
				frames.TryGetValue(component, out var value);
				if ((Object)(object)value?.Owner != (Object)(object)facilityVisual)
				{
					__instance.OnVolumeSettingsChanged();
				}
			}
		}

		[HarmonyPriority(0)]
		private static void Postfix(PostProcessLayer __instance)
		{
			try
			{
				Prepare(((Component)__instance).GetComponent<Camera>(), __instance);
			}
			catch (Exception ex)
			{
				if (!reported)
				{
					reported = true;
					Plugin.Log.LogError((object)("Computational Facility camera setup failed: " + ex));
				}
				Release();
				attempted = true;
			}
		}
	}

	private static readonly Dictionary<Camera, Frame> frames = new Dictionary<Camera, Frame>();

	private static Shader projection;

	private static Shader sceneryShader;

	private static Material sceneryCoverage;

	private static readonly int sceneryMask = Shader.PropertyToID("_FacSceneryMask");

	private static readonly int temp = Shader.PropertyToID("_FacilitySource");

	private static bool attempted;

	private static bool reported;

	internal static bool Supported
	{
		get
		{
			Ensure();
			return Object.op_Implicit((Object)(object)projection);
		}
	}

	private static void Ensure()
	{
		//IL_000e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0014: Invalid comparison between Unknown and I4
		//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Expected O, but got Unknown
		//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
		if (attempted)
		{
			return;
		}
		attempted = true;
		if ((int)SystemInfo.graphicsDeviceType != 2)
		{
			return;
		}
		AssetBundle val = null;
		try
		{
			using (Stream stream = typeof(Plugin).Assembly.GetManifestResourceStream("ComputationalFacility.FacilityProjection"))
			{
				if (stream == null)
				{
					throw new InvalidOperationException("Missing Computational Facility shader resource");
				}
				byte[] array = new byte[(int)stream.Length];
				int i;
				int num;
				for (i = 0; i < array.Length; i += num)
				{
					if ((num = stream.Read(array, i, array.Length - i)) <= 0)
					{
						break;
					}
				}
				if (i != array.Length)
				{
					throw new EndOfStreamException();
				}
				val = AssetBundle.LoadFromMemory(array);
			}
			if (!Object.op_Implicit((Object)(object)val))
			{
				throw new InvalidOperationException("Computational Facility shader bundle did not load");
			}
			projection = val.LoadAsset<Shader>("assets/survivordomains/facilityprojection.shader");
			if (!Object.op_Implicit((Object)(object)projection) || !projection.isSupported)
			{
				throw new InvalidOperationException("Computational Facility shader unsupported");
			}
			try
			{
				using Stream stream2 = typeof(Plugin).Assembly.GetManifestResourceStream("ComputationalFacility.HorizonSceneryMask");
				if (stream2 == null)
				{
					throw new InvalidOperationException("Missing scenery coverage resource");
				}
				byte[] array2 = new byte[(int)stream2.Length];
				int j;
				int num2;
				for (j = 0; j < array2.Length; j += num2)
				{
					if ((num2 = stream2.Read(array2, j, array2.Length - j)) <= 0)
					{
						break;
					}
				}
				if (j != array2.Length)
				{
					throw new EndOfStreamException();
				}
				AssetBundle val2 = AssetBundle.LoadFromMemory(array2);
				if (!Object.op_Implicit((Object)(object)val2))
				{
					throw new InvalidOperationException("Scenery coverage bundle did not load");
				}
				try
				{
					sceneryShader = val2.LoadAsset<Shader>("assets/survivordomains/horizonscenerymask.shader");
				}
				finally
				{
					val2.Unload(false);
				}
				if (!Object.op_Implicit((Object)(object)sceneryShader) || !sceneryShader.isSupported)
				{
					throw new InvalidOperationException("Scenery coverage shader unsupported");
				}
				sceneryCoverage = new Material(sceneryShader);
				sceneryCoverage.SetColor("_EhzMaskWhite", Color.white);
			}
			catch (Exception ex)
			{
				if (Object.op_Implicit((Object)(object)sceneryCoverage))
				{
					Object.Destroy((Object)(object)sceneryCoverage);
				}
				sceneryCoverage = null;
				if (Object.op_Implicit((Object)(object)sceneryShader))
				{
					Object.Destroy((Object)(object)sceneryShader);
				}
				sceneryShader = null;
				Plugin.Log.LogWarning((object)("Computational Facility scenery mask unavailable; retaining machine hall and server racks: " + ex));
			}
			Plugin.Log.LogInfo((object)"Computational Facility visual v2: computational machine hall, protected scenery coverage and native depth preserved.");
		}
		catch (Exception ex2)
		{
			if (Object.op_Implicit((Object)(object)sceneryCoverage))
			{
				Object.Destroy((Object)(object)sceneryCoverage);
			}
			sceneryCoverage = null;
			if (Object.op_Implicit((Object)(object)sceneryShader))
			{
				Object.Destroy((Object)(object)sceneryShader);
			}
			sceneryShader = null;
			if (Object.op_Implicit((Object)(object)projection))
			{
				Object.Destroy((Object)(object)projection);
			}
			projection = null;
			Plugin.Log.LogError((object)("Computational Facility projection unavailable: " + ex2));
		}
		finally
		{
			if (Object.op_Implicit((Object)(object)val))
			{
				val.Unload(false);
			}
		}
	}

	private static void Prepare(Camera camera, PostProcessLayer layer)
	{
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: Expected O, but got Unknown
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Expected O, but got Unknown
		//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: 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_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_0137: Invalid comparison between Unknown and I4
		//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
		//IL_019b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01af: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d2: 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_022b: 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_0251: Unknown result type (might be due to invalid IL or missing references)
		//IL_0257: 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)
		if (!Object.op_Implicit((Object)(object)camera) || ((Object)camera).name != "Scene Camera")
		{
			return;
		}
		FacilityVisual facilityVisual = ((camera.stereoEnabled || camera.orthographic) ? null : FacilityVisual.ForCamera(camera));
		Frame value;
		if (!Object.op_Implicit((Object)(object)facilityVisual) || !Supported)
		{
			if (frames.TryGetValue(camera, out value))
			{
				Dispose(value);
				frames.Remove(camera);
				layer.OnVolumeSettingsChanged();
			}
			return;
		}
		if (!frames.TryGetValue(camera, out value))
		{
			Frame frame = new Frame();
			frame.Camera = camera;
			frame.Layer = layer;
			CommandBuffer val = new CommandBuffer();
			val.name = "Computational Facilit