Decompiled source of Event Horizon v1.0.1

plugins/EventHorizon/EventHorizon.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using HarmonyLib;
using RoR2;
using RoR2.ConVar;
using RoR2.ContentManagement;
using RoR2.Projectile;
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 EventHorizon;

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 static class DomainRules
{
	internal static float DamageStretch(float duration, float budget)
	{
		return Math.Max(0.01f, duration) / Math.Max(0.01f, budget);
	}

	internal static bool SegmentIntersectsSphere(float ax, float ay, float az, float bx, float by, float bz, float radius)
	{
		if (radius <= 0f)
		{
			return false;
		}
		float num = bx - ax;
		float num2 = by - ay;
		float num3 = bz - az;
		float num4 = num * num + num2 * num2 + num3 * num3;
		float num5 = ((num4 > 1E-06f) ? Math.Max(0f, Math.Min(1f, (0f - (ax * num + ay * num2 + az * num3)) / num4)) : 0f);
		float num6 = ax + num * num5;
		float num7 = ay + num2 * num5;
		float num8 = az + num3 * num5;
		return num6 * num6 + num7 * num7 + num8 * num8 <= radius * radius;
	}
}
internal static class DomainStun
{
	private static readonly FieldInfo controllers = AccessTools.Field(typeof(SetStateOnHurt), "buffDurationControllers");

	internal static void Apply(SetStateOnHurt hurt, float duration)
	{
		if (controllers != null && controllers.GetValue(hurt) == null)
		{
			controllers.SetValue(hurt, ((Component)hurt).GetComponents<AlterBuffDuration>());
		}
		hurt.SetStun(duration);
	}
}
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 = "Event Horizon Photon 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 HorizonAudio : MonoBehaviour
{
	private static HorizonWaveAsset hitClip;

	private static HorizonWaveAsset loopClip;

	private HorizonWaveVoice hit;

	private HorizonWaveVoice music;

	private float start;

	private float windup;

	private float duration;

	private bool closing;

	private bool hitStarted;

	private bool warned;

	internal static HorizonAudio Create(Transform parent, float age, float windup, float duration, float collapse)
	{
		//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("Event Horizon supplied soundtrack");
		val.transform.SetParent(parent, false);
		HorizonAudio horizonAudio = val.AddComponent<HorizonAudio>();
		horizonAudio.start = Time.time - age;
		horizonAudio.windup = windup;
		horizonAudio.duration = duration;
		horizonAudio.hitStarted = age > 0.3f;
		horizonAudio.Tick();
		return horizonAudio;
	}

	internal void Unstable()
	{
	}

	internal void Collapse(float elapsed)
	{
		closing = true;
		Stop();
	}

	private void Update()
	{
		Tick();
	}

	private void Tick()
	{
		float num = Time.time - start;
		if (closing || num >= windup + duration)
		{
			Stop();
			return;
		}
		if (!Plugin.SoundEnabled.Value || Plugin.SoundVolume.Value <= 0f)
		{
			hitStarted = true;
			Stop();
			return;
		}
		try
		{
			float num2 = Plugin.Clamp(Plugin.SoundVolume.Value, 0f, 1f);
			if (!hitStarted)
			{
				hitStarted = true;
				if (hitClip == null)
				{
					hitClip = HorizonWaveAsset.Load("SurvivorDomains.HorizonHit");
				}
				hit = new HorizonWaveVoice(hitClip, loop: false, Mathf.Max(0f, num), num2);
			}
			if (num >= windup && music == null)
			{
				if (loopClip == null)
				{
					loopClip = HorizonWaveAsset.Load("SurvivorDomains.HorizonLoop");
				}
				music = new HorizonWaveVoice(loopClip, loop: true, num - windup, num2 * 0.65f);
			}
			if (music != null)
			{
				HorizonMusicMix.Acquire(this);
			}
			bool value = Time.timeScale <= 0f;
			if (hit != null)
			{
				hit.Pause(value);
			}
			if (music != null)
			{
				music.Pause(value);
			}
		}
		catch (Exception ex)
		{
			Stop();
			closing = true;
			if (!warned)
			{
				warned = true;
				Plugin.Log.LogWarning((object)("Event Horizon supplied audio: " + ex.Message));
			}
		}
	}

	private void Stop()
	{
		try
		{
			if (hit != null)
			{
				hit.Dispose();
				hit = null;
			}
			if (music != null)
			{
				music.Dispose();
				music = null;
			}
		}
		finally
		{
			HorizonMusicMix.Release(this);
		}
	}

	private void OnDisable()
	{
		Stop();
	}

	private void OnDestroy()
	{
		Stop();
	}
}
internal sealed class HorizonBlackHole : IDisposable
{
	internal readonly Transform Anchor;

	private readonly HorizonVisual owner;

	private readonly float radius;

	private readonly Quaternion diskRotation;

	private readonly Mesh sphere;

	private readonly Mesh disk;

	private readonly Mesh ring;

	private readonly Mesh halo;

	private readonly Material darkness;

	private readonly Material plasma;

	private readonly Material plasmaVeil;

	private readonly Material photon;

	private readonly Material glow;

	private readonly int colorPass;

	private readonly Texture2D flow;

	private readonly MaterialPropertyBlock properties = new MaterialPropertyBlock();

	internal HorizonBlackHole(HorizonVisual owner, Vector3 offset, float radius, Vector3 angles)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Unknown result type (might be due to invalid IL or missing references)
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Expected O, but got Unknown
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0167: Unknown result type (might be due to invalid IL or missing references)
		this.owner = owner;
		this.radius = radius;
		diskRotation = Quaternion.Euler(angles);
		GameObject val = new GameObject("Event Horizon - physical singularity");
		Anchor = val.transform;
		Anchor.SetParent(((Component)owner).transform, false);
		Anchor.localPosition = offset;
		try
		{
			darkness = Material("Perfect black physical event horizon", additive: false, depth: true);
			plasma = Material("Turbulent accretion disk", additive: true, depth: false);
			plasmaVeil = Material("Counter-flow plasma filaments", additive: true, depth: false);
			photon = Material("Violet-white photon rim", additive: true, depth: false);
			glow = Material("Soft photon atmosphere", additive: true, depth: false);
			colorPass = darkness.passCount - 1;
			if (colorPass < 0 || darkness.GetPassName(colorPass) == "ShadowCaster")
			{
				throw new InvalidOperationException("Physical singularity has no visible color pass");
			}
			Plugin.Log.LogInfo((object)("Event Horizon singularity color pass=" + colorPass + " / " + darkness.passCount + " shader=" + ((Object)darkness.shader).name + "; fixed world anchor=" + Anchor.position));
			flow = PlasmaTexture();
			plasma.SetTexture("_MainTex", (Texture)(object)flow);
			plasmaVeil.SetTexture("_MainTex", (Texture)(object)flow);
			sphere = Sphere();
			disk = Disk();
			ring = Rim(soft: false);
			halo = Rim(soft: true);
			Attach("Black sphere", sphere);
			Attach("Tilted accretion disk", disk);
			Attach("Photon ring", ring);
		}
		catch
		{
			Dispose();
			throw;
		}
	}

	private void Attach(string name, Mesh mesh)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0007: Expected O, but got Unknown
		GameObject val = new GameObject(name);
		val.transform.SetParent(Anchor, false);
		val.AddComponent<MeshFilter>().sharedMesh = mesh;
	}

	private static Material Material(string name, bool additive, bool depth)
	{
		Material val = DomainVisual.CreateGlowMaterial();
		if (!Object.op_Implicit((Object)(object)val))
		{
			throw new InvalidOperationException("Native unlit mesh material unavailable");
		}
		((Object)val).name = name;
		val.SetInt("_SrcBlend", 5);
		val.SetInt("_DstBlend", additive ? 1 : 10);
		val.SetInt("_ZWrite", depth ? 1 : 0);
		val.SetInt("_ZTest", 4);
		val.SetInt("_Cull", 0);
		return val;
	}

	private static Mesh Make(string name, List<Vector3> vertices, List<Vector2> uv, List<Color> colors, List<int> triangles)
	{
		//IL_0000: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Expected O, but got Unknown
		Mesh val = new Mesh();
		((Object)val).name = name;
		Mesh val2 = val;
		val2.SetVertices(vertices);
		val2.SetUVs(0, uv);
		val2.SetColors(colors);
		val2.SetTriangles(triangles, 0);
		val2.RecalculateBounds();
		return val2;
	}

	private static Mesh Sphere()
	{
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		List<Vector3> list = new List<Vector3>();
		List<Vector2> list2 = new List<Vector2>();
		List<Color> list3 = new List<Color>();
		List<int> list4 = new List<int>();
		for (int i = 0; i <= 64; i++)
		{
			for (int j = 0; j <= 128; j++)
			{
				float num = MathF.PI * (float)i / 64f;
				float num2 = MathF.PI * 2f * (float)j / 128f;
				list.Add(new Vector3(Mathf.Sin(num) * Mathf.Cos(num2), Mathf.Cos(num), Mathf.Sin(num) * Mathf.Sin(num2)));
				list2.Add(Vector2.zero);
				list3.Add(new Color(0f, 0f, 0f, 1f));
				if (j < 128 && i < 64)
				{
					int num3 = i * 129 + j;
					int num4 = num3 + 128 + 1;
					list4.Add(num3);
					list4.Add(num4);
					list4.Add(num3 + 1);
					list4.Add(num3 + 1);
					list4.Add(num4);
					list4.Add(num4 + 1);
				}
			}
		}
		return Make("Smooth 128x64 event horizon", list, list2, list3, list4);
	}

	private static Mesh Disk()
	{
		//IL_008d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		List<Vector3> list = new List<Vector3>();
		List<Vector2> list2 = new List<Vector2>();
		List<Color> list3 = new List<Color>();
		List<int> list4 = new List<int>();
		for (int i = 0; i <= 20; i++)
		{
			for (int j = 0; j <= 256; j++)
			{
				float num = (float)i / 20f;
				float num2 = MathF.PI * 2f * (float)j / 256f;
				float num3 = Mathf.Lerp(1.08f, 2.9f, num);
				list.Add(new Vector3(Mathf.Cos(num2) * num3, 0.025f * Mathf.Sin(num2 * 3f) * Mathf.Sin(num * MathF.PI), Mathf.Sin(num2) * num3));
				list2.Add(new Vector2((float)j / 256f, num));
				list3.Add(Color.white);
				if (j < 256 && i < 20)
				{
					int num4 = i * 257 + j;
					int num5 = num4 + 256 + 1;
					list4.Add(num4);
					list4.Add(num4 + 1);
					list4.Add(num5);
					list4.Add(num4 + 1);
					list4.Add(num5 + 1);
					list4.Add(num5);
				}
			}
		}
		return Make("Physical warped plasma annulus", list, list2, list3, list4);
	}

	private static Mesh Rim(bool soft)
	{
		//IL_00bd: 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_00ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		List<Vector3> list = new List<Vector3>();
		List<Vector2> list2 = new List<Vector2>();
		List<Color> list3 = new List<Color>();
		List<int> list4 = new List<int>();
		for (int i = 0; i <= 12; i++)
		{
			for (int j = 0; j <= 256; j++)
			{
				float num = (float)i / 12f;
				float num2 = MathF.PI * 2f * (float)j / 256f;
				float num3 = (soft ? Mathf.Lerp(0.997f, 1.22f, num) : Mathf.Lerp(1.005f, 1.05f, num));
				float num4 = (soft ? (Mathf.Pow(1f - num, 4f) * 0.18f) : Mathf.Pow(Mathf.Sin(num * MathF.PI), 2f));
				list.Add(new Vector3(Mathf.Cos(num2) * num3, Mathf.Sin(num2) * num3, 0f));
				list2.Add(Vector2.zero);
				list3.Add(soft ? new Color(0.52f, 0.09f, 1.2f, num4) : new Color(2.4f, 1.35f, 3.4f, num4));
				if (j < 256 && i < 12)
				{
					int num5 = i * 257 + j;
					int num6 = num5 + 256 + 1;
					list4.Add(num5);
					list4.Add(num5 + 1);
					list4.Add(num6);
					list4.Add(num5 + 1);
					list4.Add(num6 + 1);
					list4.Add(num6);
				}
			}
		}
		return Make(soft ? "Atmospheric photon glow" : "Antialiased photon band", list, list2, list3, list4);
	}

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

	private static float FlowNoise(float x, float y)
	{
		int num = (int)Math.Floor(x);
		int num2 = (int)Math.Floor(y);
		float num3 = x - (float)num;
		float num4 = y - (float)num2;
		num3 = num3 * num3 * (3f - 2f * num3);
		num4 = num4 * num4 * (3f - 2f * num4);
		return Mathf.Lerp(Mathf.Lerp(Cell(num, num2), Cell(num + 1, num2), num3), Mathf.Lerp(Cell(num, num2 + 1), Cell(num + 1, num2 + 1), num3), num4);
	}

	private static Texture2D PlasmaTexture()
	{
		//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ed: Expected O, but got Unknown
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_015d: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0195: Unknown result type (might be due to invalid IL or missing references)
		//IL_019a: 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_01b6: Unknown result type (might be due to invalid IL or missing references)
		Color[] array = (Color[])(object)new Color[65536];
		for (int i = 0; i < 128; i++)
		{
			for (int j = 0; j < 512; j++)
			{
				float num = (float)i / 127f;
				float num2 = MathF.PI * 2f * (float)j / 512f;
				float num3 = num2 + num * 6f;
				float num4 = Mathf.Cos(num3);
				float num5 = Mathf.Sin(num3);
				float num6 = FlowNoise(num4 * 2.1f + 7f + num * 4f, num5 * 2.1f + 11f);
				float num7 = FlowNoise(num4 * 11f + num * 29f + 3f, num5 * 11f + 19f);
				float num8 = Mathf.Pow(Mathf.Clamp01(0.5f + 0.5f * Mathf.Sin(num * 96f + num6 * 18f + num7 * 8f)), 3f);
				float num9 = CastTimeline.Expansion(num, 0.045f) * (1f - CastTimeline.Expansion(num - 0.58f, 0.42f));
				float a = (0.04f + 0.55f * num6 * num6 + 0.75f * num8 * num6) * num9 * Mathf.Pow(1f - num, 1.6f);
				Color val = Color.Lerp(new Color(0.16f, 0.12f, 0.62f), new Color(0.82f, 0.09f, 0.64f), num6);
				val = Color.Lerp(val, new Color(0.76f, 0.6f, 1f), num8 * Mathf.Pow(1f - num, 1.6f));
				val.a = a;
				array[i * 512 + j] = val;
			}
		}
		Texture2D val2 = new Texture2D(512, 128, (TextureFormat)4, true, true);
		((Object)val2).name = "Periodic turbulent plasma";
		((Texture)val2).wrapModeU = (TextureWrapMode)0;
		((Texture)val2).wrapModeV = (TextureWrapMode)1;
		((Texture)val2).filterMode = (FilterMode)2;
		((Texture)val2).anisoLevel = 4;
		Texture2D val3 = val2;
		val3.SetPixels(array);
		val3.Apply(true, true);
		return val3;
	}

	internal void Record(CommandBuffer commands, Camera camera, float weight)
	{
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: 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_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_0129: Unknown result type (might be due to invalid IL or missing references)
		//IL_012e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0176: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_0211: Unknown result type (might be due to invalid IL or missing references)
		//IL_0213: Unknown result type (might be due to invalid IL or missing references)
		//IL_0224: Unknown result type (might be due to invalid IL or missing references)
		//IL_0229: Unknown result type (might be due to invalid IL or missing references)
		//IL_022e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0234: 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_0277: 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_02b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b5: 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_02d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ec: 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_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_0348: 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_036c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0365: Unknown result type (might be due to invalid IL or missing references)
		//IL_0371: Unknown result type (might be due to invalid IL or missing references)
		//IL_0376: Unknown result type (might be due to invalid IL or missing references)
		//IL_0393: Unknown result type (might be due to invalid IL or missing references)
		//IL_03b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cc: 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_03d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03df: Unknown result type (might be due to invalid IL or missing references)
		//IL_0400: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)Anchor) || weight <= 0.001f)
		{
			return;
		}
		float num = CastTimeline.Expansion(owner.RealmAge - owner.RealmOpening * 0.5f, owner.RealmOpening * 0.5f);
		float num2 = 1f - CastTimeline.Expansion(owner.CollapseProgress - 0.03f, 0.52f);
		float num3 = radius * num * num2;
		if (!(num3 < 0.01f))
		{
			Vector3 position = Anchor.position;
			float realmAge = owner.RealmAge;
			float num4 = realmAge * 4f + owner.CollapseProgress * owner.CollapseProgress * 220f;
			properties.Clear();
			properties.SetColor("_Color", new Color(1f, 1f, 1f, weight));
			properties.SetColor("_TintColor", new Color(1f, 1f, 1f, weight));
			commands.DrawMesh(sphere, Matrix4x4.TRS(position, Quaternion.identity, Vector3.one * num3), darkness, 0, colorPass, properties);
			plasma.SetTextureOffset("_MainTex", new Vector2((0f - realmAge) * 0.035f - owner.CollapseProgress * 0.6f, 0f));
			plasmaVeil.SetTextureOffset("_MainTex", new Vector2(realmAge * 0.017f + owner.CollapseProgress * 0.4f, 0.07f));
			properties.SetColor("_Color", new Color(1.6f, 1.1f, 2f, weight * 0.92f));
			properties.SetColor("_TintColor", new Color(1.6f, 1.1f, 2f, weight * 0.92f));
			commands.DrawMesh(disk, Matrix4x4.TRS(position, diskRotation * Quaternion.Euler(0f, num4, 0f), Vector3.one * num3), plasma, 0, colorPass, properties);
			properties.SetColor("_Color", new Color(0.55f, 0.75f, 1.6f, weight * 0.24f));
			properties.SetColor("_TintColor", new Color(0.55f, 0.75f, 1.6f, weight * 0.24f));
			commands.DrawMesh(disk, Matrix4x4.TRS(position, diskRotation * Quaternion.Euler(0f, (0f - num4) * 0.63f, 0f), Vector3.one * num3 * 1.03f), plasmaVeil, 0, colorPass, properties);
			Vector3 val = ((Component)camera).transform.position - position;
			float magnitude = ((Vector3)(ref val)).magnitude;
			if (!(magnitude <= num3 * 1.1f))
			{
				float num5 = num3 * magnitude / Mathf.Sqrt(magnitude * magnitude - num3 * num3);
				Quaternion val2 = Quaternion.LookRotation(((Vector3)(ref val)).normalized, (Mathf.Abs(((Vector3)(ref val)).normalized.y) > 0.98f) ? Vector3.forward : Vector3.up);
				properties.SetColor("_Color", new Color(1f, 1f, 1f, weight));
				properties.SetColor("_TintColor", new Color(1f, 1f, 1f, weight));
				Matrix4x4 val3 = Matrix4x4.TRS(position, val2, Vector3.one * num5);
				commands.DrawMesh(halo, val3, glow, 0, colorPass, properties);
				commands.DrawMesh(ring, val3, photon, 0, colorPass, properties);
			}
		}
	}

	public void Dispose()
	{
		Object[] array = (Object[])(object)new Object[10]
		{
			(Object)sphere,
			(Object)disk,
			(Object)ring,
			(Object)halo,
			(Object)darkness,
			(Object)plasma,
			(Object)plasmaVeil,
			(Object)photon,
			(Object)glow,
			(Object)flow
		};
		foreach (Object val in array)
		{
			if (Object.op_Implicit(val))
			{
				Object.Destroy(val);
			}
		}
		if (Object.op_Implicit((Object)(object)Anchor))
		{
			Object.Destroy((Object)(object)((Component)Anchor).gameObject);
		}
	}
}
internal sealed class HorizonBurnTimer
{
	private float next = -1f;

	private uint cast;

	internal void Reset()
	{
		next = -1f;
		cast = 0u;
	}

	internal bool Step(float now, bool inside, uint id, float interval)
	{
		if (!inside || float.IsNaN(now) || float.IsInfinity(now))
		{
			Reset();
			return false;
		}
		interval = Math.Max(0.25f, interval);
		if (next < 0f || cast != id)
		{
			cast = id;
			next = now + interval;
			return false;
		}
		if (now + 1E-05f < next)
		{
			return false;
		}
		next = now + interval;
		return true;
	}
}
internal static class HorizonClutterNames
{
	internal static bool Decoration(string name)
	{
		if (string.IsNullOrEmpty(name))
		{
			return false;
		}
		string text = name.ToLowerInvariant();
		if (!text.Contains("grass") && !text.Contains("foliage") && !text.Contains("speedtree") && !text.Contains("nature/") && !text.Contains("bush") && !text.Contains("fern") && !text.Contains("leaves") && !text.Contains("leaf") && !text.Contains("flower") && !text.Contains("cable") && !text.Contains("rope"))
		{
			return text.Contains("vine");
		}
		return true;
	}
}
internal static class HorizonCombat
{
	private sealed class Capture
	{
		internal CharacterBody Body;

		internal CharacterMotor Motor;

		internal Rigidbody Rigidbody;

		internal VoidFiendDomain Field;

		internal float Entered;

		internal VoidFiendDomain BurnField;

		internal readonly HorizonBurnTimer BurnTimer = new HorizonBurnTimer();

		internal Vector3 BeforeMove;
	}

	[HarmonyPatch(typeof(CharacterMotor), "PreMove")]
	private static class CapturedMotor
	{
		private static void Prefix(CharacterMotor __instance)
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			if (NetworkServer.active)
			{
				CharacterBody component = ((Component)__instance).GetComponent<CharacterBody>();
				if (Object.op_Implicit((Object)(object)component) && targets.TryGetValue(component, out var value))
				{
					value.BeforeMove = __instance.velocity;
				}
			}
		}

		private static void Postfix(CharacterMotor __instance, float deltaTime)
		{
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active || HorizonSettings.Pull.Value <= 0f)
			{
				return;
			}
			CharacterBody component = ((Component)__instance).GetComponent<CharacterBody>();
			if (Object.op_Implicit((Object)(object)component) && targets.TryGetValue(component, out var value) && CanMove(value))
			{
				float num = 0.03f;
				Vector3 velocity = __instance.velocity;
				Vector3 val = velocity - value.BeforeMove;
				velocity.x = value.BeforeMove.x + val.x * num;
				velocity.z = value.BeforeMove.z + val.z * num;
				if (HorizonSettings.Lift.Value > 0f)
				{
					velocity.y = value.BeforeMove.y + val.y * num;
				}
				__instance.velocity = velocity;
				Apply(value, deltaTime);
			}
		}
	}

	private static readonly Dictionary<CharacterBody, Capture> targets = new Dictionary<CharacterBody, Capture>();

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

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

	private static float nextScan;

	internal static VoidFiendDomain Field(Vector3 p, TeamIndex team)
	{
		//IL_0027: Unknown result type (might be due to invalid IL or missing references)
		//IL_0028: Unknown result type (might be due to invalid IL or missing references)
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0032: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		//IL_003c: Unknown result type (might be due to invalid IL or missing references)
		VoidFiendDomain result = null;
		float num = float.MaxValue;
		foreach (VoidFiendDomain item in VoidFiendDomain.Live)
		{
			if (Object.op_Implicit((Object)(object)item) && item.Contains(p, team))
			{
				Vector3 val = p - item.Center;
				float num2 = ((Vector3)(ref val)).sqrMagnitude / (item.Radius * item.Radius);
				if (num2 < num)
				{
					result = item;
					num = num2;
				}
			}
		}
		return result;
	}

	private static bool Valid(CharacterBody b)
	{
		if (Object.op_Implicit((Object)(object)b) && ((Behaviour)b).isActiveAndEnabled && Object.op_Implicit((Object)(object)b.healthComponent) && b.healthComponent.alive && Object.op_Implicit((Object)(object)b.teamComponent) && !b.isPlayerControlled)
		{
			return !Object.op_Implicit((Object)(object)b.currentVehicle);
		}
		return false;
	}

	private static bool Movable(CharacterBody b)
	{
		//IL_0009: 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)
		if (Valid(b) && (b.bodyFlags & 0x10000) == 0)
		{
			return !b.healthComponent.IsImmuneToPhysicsForces();
		}
		return false;
	}

	internal static void Refresh()
	{
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		if (!NetworkServer.active)
		{
			Clear();
			return;
		}
		stale.Clear();
		foreach (KeyValuePair<CharacterBody, Capture> target in targets)
		{
			CharacterBody key = target.Key;
			VoidFiendDomain voidFiendDomain = (Valid(key) ? Field(key.corePosition, key.teamComponent.teamIndex) : null);
			if (!Object.op_Implicit((Object)(object)voidFiendDomain))
			{
				stale.Add(key);
			}
			else
			{
				target.Value.Field = voidFiendDomain;
			}
		}
		foreach (CharacterBody item in stale)
		{
			HorizonContent.Exposure(item, 0);
			targets.Remove(item);
		}
		bool flag = false;
		foreach (VoidFiendDomain item2 in VoidFiendDomain.Live)
		{
			if (Object.op_Implicit((Object)(object)item2) && item2.Active)
			{
				flag = true;
				break;
			}
		}
		if (!flag)
		{
			return;
		}
		foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList)
		{
			if (!Valid(readOnlyInstances))
			{
				continue;
			}
			VoidFiendDomain voidFiendDomain2 = Field(readOnlyInstances.corePosition, readOnlyInstances.teamComponent.teamIndex);
			if (Object.op_Implicit((Object)(object)voidFiendDomain2))
			{
				if (!targets.TryGetValue(readOnlyInstances, out var value))
				{
					Capture capture = new Capture();
					capture.Body = readOnlyInstances;
					capture.Motor = readOnlyInstances.characterMotor;
					capture.Rigidbody = ((Component)readOnlyInstances).GetComponent<Rigidbody>();
					capture.Field = voidFiendDomain2;
					capture.Entered = Time.time;
					value = capture;
					targets.Add(readOnlyInstances, value);
				}
				HorizonContent.Exposure(readOnlyInstances, HorizonSettings.Debuff.Value ? HorizonRules.Stacks(Time.time - value.Entered, HorizonSettings.Exposure.Value) : 0);
				Incapacitate(value);
			}
		}
	}

	private static void Incapacitate(Capture capture)
	{
		if (!HorizonSettings.Incapacitate.Value)
		{
			return;
		}
		CharacterBody body = capture.Body;
		SetStateOnHurt component = ((Component)body).GetComponent<SetStateOnHurt>();
		if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.targetStateMachine) || component.idleStateMachine == null || component.targetStateMachine.HasPendingState() || component.targetStateMachine.state is FrozenState)
		{
			return;
		}
		bool canBeStunned = component.canBeStunned;
		try
		{
			component.canBeStunned = true;
			DomainStun.Apply(component, 0.35f);
		}
		finally
		{
			component.canBeStunned = canBeStunned;
		}
	}

	internal static void Tick()
	{
		if (!NetworkServer.active)
		{
			Clear();
			return;
		}
		if (Time.time >= nextScan)
		{
			nextScan = Time.time + 0.1f;
			Refresh();
		}
		foreach (Capture value in targets.Values)
		{
			Burn(value);
			if (!Object.op_Implicit((Object)(object)value.Motor))
			{
				Apply(value, Time.fixedDeltaTime);
			}
		}
	}

	private static void Burn(Capture c)
	{
		//IL_004e: 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_0086: 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_0096: Unknown result type (might be due to invalid IL or missing references)
		CharacterBody body = c.Body;
		VoidFiendDomain voidFiendDomain = null;
		float num = float.MaxValue;
		if (Valid(body) && HorizonSettings.BurnMultiplier.Value > 0f)
		{
			foreach (VoidFiendDomain item in VoidFiendDomain.Live)
			{
				if (Object.op_Implicit((Object)(object)item) && item.Contains(body.corePosition, body.teamComponent.teamIndex) && Object.op_Implicit((Object)(object)item.Body))
				{
					float num2 = item.BlackHoleRadius + HorizonSettings.BurnRange.Value;
					Vector3 val = body.corePosition - item.PullCenter;
					float sqrMagnitude = ((Vector3)(ref val)).sqrMagnitude;
					if (sqrMagnitude <= num2 * num2 && sqrMagnitude < num)
					{
						voidFiendDomain = item;
						num = sqrMagnitude;
					}
				}
			}
		}
		if ((Object)(object)c.BurnField != (Object)(object)voidFiendDomain)
		{
			c.BurnTimer.Reset();
			c.BurnField = voidFiendDomain;
		}
		if (c.BurnTimer.Step(Time.time, Object.op_Implicit((Object)(object)voidFiendDomain), Object.op_Implicit((Object)(object)voidFiendDomain) ? voidFiendDomain.CastId : 0u, HorizonSettings.BurnInterval.Value))
		{
			DotController.InflictDot(((Component)body).gameObject, ((Component)voidFiendDomain.Body).gameObject, (HurtBox)null, (DotIndex)1, HorizonSettings.BurnDuration.Value, HorizonSettings.BurnMultiplier.Value, (uint?)null);
		}
	}

	private static bool CanMove(Capture c)
	{
		//IL_0023: 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_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0078: Invalid comparison between Unknown and I4
		CharacterBody body = c.Body;
		if (!Movable(body) || !Object.op_Implicit((Object)(object)c.Field) || !c.Field.Contains(body.corePosition, body.teamComponent.teamIndex) || !body.hasEffectiveAuthority)
		{
			return false;
		}
		if (Object.op_Implicit((Object)(object)c.Rigidbody) && ((!Object.op_Implicit((Object)(object)c.Motor) && c.Rigidbody.isKinematic) || (int)c.Rigidbody.constraints == 126))
		{
			return false;
		}
		SetStateOnHurt component = ((Component)body).GetComponent<SetStateOnHurt>();
		if (Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.targetStateMachine))
		{
			return !(component.targetStateMachine.state is FrozenState);
		}
		return true;
	}

	private static void Apply(Capture c, float dt)
	{
		//IL_004a: 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_004f: 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_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_007e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: 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_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_0119: 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_0122: 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_0154: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a4: 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_01d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01db: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0201: Unknown result type (might be due to invalid IL or missing references)
		CharacterBody body = c.Body;
		if (CanMove(c) && (Object.op_Implicit((Object)(object)c.Motor) || Object.op_Implicit((Object)(object)c.Rigidbody)))
		{
			Vector3 val = (Object.op_Implicit((Object)(object)c.Motor) ? c.Motor.velocity : c.Rigidbody.velocity);
			Vector3 val2 = c.Field.PullCenter - body.corePosition;
			float magnitude = ((Vector3)(ref val2)).magnitude;
			Vector3 val3 = ((magnitude > 0.02f) ? (val2 / magnitude) : Vector3.right);
			float num = HorizonRules.Strength(magnitude, c.Field.Radius);
			float num2 = (body.isBoss ? HorizonSettings.Boss.Value : 1f);
			float num3 = (HorizonSettings.Debuff.Value ? Mathf.Clamp01((Time.time - c.Entered) / HorizonSettings.Exposure.Value) : 0f);
			float value = HorizonSettings.Speed.Value;
			Vector3 val4 = val3 * (value * (0.5f + 0.5f * num) * Mathf.Clamp01(magnitude / 5f));
			val4 += Vector3.Cross(Vector3.up, val3) * HorizonSettings.Orbit.Value * (1f - Mathf.Clamp01(magnitude / (c.Field.Radius * 0.6f)));
			val4 *= num2;
			val4 = Vector3.ClampMagnitude(val4, value * num2);
			val4.y = Mathf.Clamp(val4.y, 0f - HorizonSettings.Lift.Value, HorizonSettings.Lift.Value);
			Vector3 force = Vector3.ClampMagnitude(val4 - val, HorizonSettings.Pull.Value * num * (1f + num3 * 0.25f) * num2 * Mathf.Min(dt, 0.05f));
			PhysForceInfo val5 = PhysForceInfo.Create();
			val5.force = force;
			((PhysForceInfo)(ref val5)).massIsOne = true;
			((PhysForceInfo)(ref val5)).ignoreGroundStick = true;
			body.healthComponent.TakeDamageForce(val5);
		}
	}

	internal static void Shock(CharacterBody owner, Vector3 center, float radius, float strength, float coefficient)
	{
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Expected O, but got Unknown
		//IL_0177: Unknown result type (might be due to invalid IL or missing references)
		//IL_017c: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_00f0: 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_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0113: 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)
		if (!NetworkServer.active || !Object.op_Implicit((Object)(object)owner) || !Object.op_Implicit((Object)(object)owner.teamComponent))
		{
			return;
		}
		shockTargets.Clear();
		foreach (CharacterBody readOnlyInstances in CharacterBody.readOnlyInstancesList)
		{
			if (Valid(readOnlyInstances) && TeamManager.IsTeamEnemy(owner.teamComponent.teamIndex, readOnlyInstances.teamComponent.teamIndex))
			{
				shockTargets.Add(readOnlyInstances);
			}
		}
		foreach (CharacterBody shockTarget in shockTargets)
		{
			if (!Valid(shockTarget))
			{
				continue;
			}
			if (Movable(shockTarget))
			{
				Vector3 val = shockTarget.corePosition - center;
				val.y = 0f;
				if (((Vector3)(ref val)).sqrMagnitude < 0.01f)
				{
					val = Vector3.forward;
				}
				PhysForceInfo val2 = PhysForceInfo.Create();
				val2.force = ((Vector3)(ref val)).normalized * strength * (shockTarget.isBoss ? HorizonSettings.Boss.Value : 1f);
				((PhysForceInfo)(ref val2)).massIsOne = true;
				((PhysForceInfo)(ref val2)).doNotExceed = true;
				shockTarget.healthComponent.TakeDamageForce(val2);
			}
			if (coefficient > 0f)
			{
				HealthComponent healthComponent = shockTarget.healthComponent;
				DamageInfo val3 = new DamageInfo();
				val3.attacker = ((Component)owner).gameObject;
				val3.inflictor = ((Component)owner).gameObject;
				val3.damage = owner.damage * coefficient;
				val3.position = shockTarget.corePosition;
				val3.procCoefficient = 0f;
				val3.crit = false;
				healthComponent.TakeDamage(val3);
			}
		}
		shockTargets.Clear();
	}

	internal static void Clear()
	{
		foreach (CharacterBody key in targets.Keys)
		{
			HorizonContent.Exposure(key, 0);
		}
		targets.Clear();
		nextScan = 0f;
	}
}
internal sealed class HorizonContent : IContentPackProvider
{
	[HarmonyPatch(typeof(CharacterBody), "RecalculateStats")]
	private static class Stats
	{
		private static readonly PropertyInfo Move = AccessTools.Property(typeof(CharacterBody), "moveSpeed");

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

		private static void Postfix(CharacterBody __instance)
		{
			if (Object.op_Implicit((Object)(object)Corruption))
			{
				float num = Mathf.Clamp01((float)__instance.GetBuffCount(Corruption) / 5f);
				if (num > 0f)
				{
					Move.SetValue(__instance, __instance.moveSpeed * (1f - MoveReduction * num), null);
					Attack.SetValue(__instance, __instance.attackSpeed * (1f - AttackReduction * num), null);
				}
			}
			if (Object.op_Implicit((Object)(object)Buff) && __instance.HasBuff(Buff))
			{
				VoidFiendDomain component = ((Component)__instance).GetComponent<VoidFiendDomain>();
				if (Object.op_Implicit((Object)(object)component) && component.Attuned)
				{
					Move.SetValue(__instance, __instance.moveSpeed * (1f + component.MoveBonus), null);
				}
			}
		}
	}

	[HarmonyPatch(typeof(CharacterMotor), "PreMove")]
	private static class AttunedFall
	{
		private static void Postfix(CharacterMotor __instance)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			if (!__instance.hasEffectiveAuthority || __instance.isGrounded)
			{
				return;
			}
			VoidFiendDomain component = ((Component)__instance).GetComponent<VoidFiendDomain>();
			if (Object.op_Implicit((Object)(object)component) && component.Attuned)
			{
				Vector3 velocity = __instance.velocity;
				if (velocity.y < 0f - component.FallSpeed)
				{
					velocity.y = 0f - component.FallSpeed;
					__instance.velocity = velocity;
				}
			}
		}
	}

	internal static BuffDef Buff;

	internal static BuffDef Corruption;

	internal static float MoveReduction = 0.2f;

	internal static float AttackReduction = 0.15f;

	private readonly ContentPack pack = new ContentPack();

	public string identifier => "wreckzog.eventhorizon";

	internal static void Register(AddContentPackProviderDelegate add)
	{
		add.Invoke((IContentPackProvider)(object)new HorizonContent());
	}

	public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
	{
		Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false);
		((Object)val).name = "Singularity Attunement";
		((Texture)val).filterMode = (FilterMode)1;
		((Texture)val).wrapMode = (TextureWrapMode)1;
		Texture2D val2 = val;
		Color[] array = (Color[])(object)new Color[4096];
		Vector2 val3 = default(Vector2);
		for (int i = 0; i < 64; i++)
		{
			for (int j = 0; j < 64; j++)
			{
				((Vector2)(ref val3))..ctor(((float)j - 31.5f) / 32f, ((float)i - 31.5f) / 32f);
				float magnitude = ((Vector2)(ref val3)).magnitude;
				Vector2 val4 = new Vector2(val3.x, val3.y * 3f);
				float magnitude2 = ((Vector2)(ref val4)).magnitude;
				float num = Mathf.Exp((0f - Mathf.Abs(magnitude - 0.4f)) * 65f) + Mathf.Exp((0f - Mathf.Abs(magnitude2 - 0.7f)) * 25f) * 0.7f;
				ref Color reference = ref array[i * 64 + j];
				reference = ((magnitude < 0.36f) ? new Color(0.008f, 0.002f, 0.02f, 1f) : new Color(0.55f + num * 0.35f, 0.18f + num * 0.45f, 0.94f, Mathf.Clamp01(num)));
			}
		}
		val2.SetPixels(array);
		val2.Apply(false, false);
		Sprite icon = Sprite.Create(val2, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 64f);
		Buff = Create("SINGULARITY ATTUNEMENT", icon, debuff: false);
		Corruption = Create("VOID GRAVITATIONAL EXPOSURE", icon, debuff: true);
		pack.buffDefs.Add((BuffDef[])(object)new BuffDef[2] { Buff, Corruption });
		args.ReportProgress(1f);
		yield break;
	}

	private static BuffDef Create(string name, Sprite icon, bool debuff)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		BuffDef val = ScriptableObject.CreateInstance<BuffDef>();
		((Object)val).name = name;
		val.iconSprite = icon;
		val.buffColor = Color.white;
		val.canStack = debuff;
		val.isDebuff = debuff;
		val.isHidden = false;
		val.ignoreGrowthNectar = true;
		val.flags = (Flags)5;
		return val;
	}

	public IEnumerator GenerateContentPackAsync(GetContentPackAsyncArgs args)
	{
		ContentPack.Copy(pack, args.output);
		args.ReportProgress(1f);
		yield break;
	}

	public IEnumerator FinalizeAsync(FinalizeAsyncArgs args)
	{
		args.ReportProgress(1f);
		yield break;
	}

	internal static void Sync(CharacterBody body, float remaining)
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Invalid comparison between Unknown and I4
		if (NetworkServer.active && Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)Buff) && (int)Buff.buffIndex != -1 && !(remaining <= 0f))
		{
			if (!body.HasBuff(Buff))
			{
				body.AddTimedBuff(Buff, remaining);
			}
			body.SetTimedBuffDurationIfPresent(Buff, remaining, true);
		}
	}

	internal static void Remove(CharacterBody body)
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Invalid comparison between Unknown and I4
		if (NetworkServer.active && Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)Buff) && (int)Buff.buffIndex != -1)
		{
			body.ClearTimedBuffs(Buff);
		}
	}

	internal static void Exposure(CharacterBody body, int count)
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Invalid comparison between Unknown and I4
		//IL_003d: Unknown result type (might be due to invalid IL or missing references)
		if (NetworkServer.active && Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)Corruption) && (int)Corruption.buffIndex != -1 && body.GetBuffCount(Corruption) != count)
		{
			body.SetBuffCount(Corruption.buffIndex, count);
			body.MarkAllStatsDirty();
		}
	}
}
[HarmonyPatch(typeof(RampFogRenderer), "Render")]
internal static class HorizonFog
{
	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;
		}
		HorizonVisual horizonVisual = HorizonVisual.ForCamera(camera);
		if (Object.op_Implicit((Object)(object)horizonVisual) && horizonVisual.VisualWeight(camera) > 0.001f)
		{
			return HorizonProjection.Supported;
		}
		return false;
	}

	[HarmonyBefore(new string[] { "local.alienskies.fog" })]
	[HarmonyPriority(800)]
	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 HorizonAlienFog
{
	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 && HorizonFog.OwnsCamera(context))
		{
			__result = false;
		}
	}
}
internal static class HorizonMusicMix
{
	[HarmonyPatch(typeof(AkSoundEngine), "SetRTPCValue", new Type[]
	{
		typeof(string),
		typeof(float)
	})]
	private static class PreserveRequestedGain
	{
		private static void Prefix(string __0, ref float __1)
		{
			if (!writing && muted && __0 == "Volume_MSX")
			{
				requested = __1;
				__1 = 0f;
			}
		}
	}

	[HarmonyPatch]
	private static class PreserveMusicPreference
	{
		private static MethodBase TargetMethod()
		{
			return AccessTools.Method(typeof(AudioManager).GetNestedType("VolumeConVar", BindingFlags.Public | BindingFlags.NonPublic), "GetString", (Type[])null, (Type[])null);
		}

		private static bool Prefix(object __instance, ref string __result)
		{
			if (!muted || !object.ReferenceEquals(__instance, MusicVolume))
			{
				return true;
			}
			__result = requested.ToString(CultureInfo.InvariantCulture);
			return false;
		}
	}

	private const string MusicRtpc = "Volume_MSX";

	private static readonly FieldInfo musicField = AccessTools.Field(typeof(AudioManager), "cvVolumeMsx");

	private static readonly HashSet<object> owners = new HashSet<object>();

	private static bool writing;

	private static bool muted;

	private static float requested;

	private static BaseConVar MusicVolume
	{
		get
		{
			if (!(musicField == null))
			{
				object? value = musicField.GetValue(null);
				return (BaseConVar)((value is BaseConVar) ? value : null);
			}
			return null;
		}
	}

	internal static void Acquire(object owner)
	{
		owners.Add(owner);
		Refresh();
	}

	internal static void Refresh()
	{
		if (owners.Count != 0 && !muted && AkSoundEngine.IsInitialized())
		{
			BaseConVar musicVolume = MusicVolume;
			if (musicVolume != null && float.TryParse(musicVolume.GetString(), NumberStyles.Float, CultureInfo.InvariantCulture, out var result))
			{
				requested = result;
				muted = Write(0f);
			}
		}
	}

	internal static void Release(object owner)
	{
		if (owners.Remove(owner) && owners.Count == 0)
		{
			Restore();
		}
	}

	private static bool Write(float gain)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Invalid comparison between Unknown and I4
		if (!AkSoundEngine.IsInitialized())
		{
			return false;
		}
		writing = true;
		try
		{
			return (int)AkSoundEngine.SetRTPCValue("Volume_MSX", gain) == 1;
		}
		finally
		{
			writing = false;
		}
	}

	private static void Restore()
	{
		if (muted)
		{
			Write(requested);
			muted = false;
		}
	}

	internal static void Shutdown()
	{
		owners.Clear();
		Restore();
	}
}
internal static class HorizonProjectileRegistry
{
	[HarmonyPatch(typeof(ProjectileController), "Awake")]
	private static class Register
	{
		private static void Postfix(ProjectileController __instance)
		{
			Projectiles.Add(__instance);
		}
	}

	[HarmonyPatch(typeof(ProjectileController), "OnDestroy")]
	private static class Remove
	{
		private static void Prefix(ProjectileController __instance)
		{
			Projectiles.Remove(__instance);
		}
	}

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

	internal static void Initialize()
	{
		ProjectileController[] array = Object.FindObjectsOfType<ProjectileController>();
		foreach (ProjectileController item in array)
		{
			Projectiles.Add(item);
		}
	}
}
internal static class HorizonProjectiles
{
	private sealed class Shot
	{
		internal ProjectileController Controller;

		internal ProjectileSimple Simple;

		internal Rigidbody Body;

		internal float Speed;

		internal Vector3 Applied;
	}

	[HarmonyPatch(typeof(ProjectileSimple), "FixedUpdate")]
	private static class CurveAfterNativeUpdate
	{
		private static void Postfix(ProjectileSimple __instance)
		{
			Bend(__instance);
		}
	}

	[HarmonyPatch(typeof(ProjectileController), "OnDisable")]
	private static class ForgetDisabled
	{
		private static void Prefix(ProjectileController __instance)
		{
			ProjectileSimple component = ((Component)__instance).GetComponent<ProjectileSimple>();
			if (Object.op_Implicit((Object)(object)component))
			{
				shots.Remove(component);
			}
		}
	}

	private static readonly Dictionary<ProjectileSimple, Shot> shots = new Dictionary<ProjectileSimple, Shot>();

	private static readonly List<ProjectileSimple> stale = new List<ProjectileSimple>();

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

	private static float nextScan;

	private static bool Eligible(ProjectileController p)
	{
		//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)
		if (Object.op_Implicit((Object)(object)p) && ((Behaviour)p).isActiveAndEnabled && !p.isPrediction)
		{
			NetworkInstanceId netId = ((NetworkBehaviour)p).netId;
			if (!((NetworkInstanceId)(ref netId)).IsEmpty())
			{
				return Object.op_Implicit((Object)(object)p.teamFilter);
			}
		}
		return false;
	}

	private static bool Supported(ProjectileController p, ProjectileSimple simple, Rigidbody rb)
	{
		if (!Object.op_Implicit((Object)(object)simple) || !((Behaviour)simple).enabled || !Object.op_Implicit((Object)(object)rb) || rb.isKinematic || simple.enableVelocityOverLifetime || simple.oscillate || simple.desiredForwardSpeed < 0f)
		{
			return false;
		}
		MonoBehaviour[] components = ((Component)p).GetComponents<MonoBehaviour>();
		foreach (MonoBehaviour val in components)
		{
			if (!Object.op_Implicit((Object)(object)val))
			{
				continue;
			}
			Type type = ((object)val).GetType();
			if (val is EntityStateMachine)
			{
				return false;
			}
			if (!(type == typeof(AkGameObj)) && !(type == typeof(AkEvent)) && !(type.Namespace == "UnityEngine.Networking") && !(type.Name == "TeamFilter") && !(type.Name == "NetworkIdentity"))
			{
				if (type.Namespace != "RoR2.Projectile")
				{
					return false;
				}
				if (type != typeof(ProjectileController) && type != typeof(ProjectileSimple) && type != typeof(ProjectileDamage) && type != typeof(ProjectileImpactExplosion) && type.Name != "ProjectileSingleTargetImpact" && type.Name != "ProjectileNetworkTransform")
				{
					return false;
				}
			}
		}
		return true;
	}

	private static void Release(Shot s)
	{
		//IL_003b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_0088: Unknown result type (might be due to invalid IL or missing references)
		//IL_0093: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)s.Controller) || !((Behaviour)s.Controller).isActiveAndEnabled || !Object.op_Implicit((Object)(object)s.Body) || s.Body.isKinematic)
		{
			return;
		}
		Vector3 val = s.Body.velocity - s.Applied;
		if (((Vector3)(ref val)).sqrMagnitude < 0.001f)
		{
			Vector3 velocity = s.Body.velocity;
			if (((Vector3)(ref velocity)).sqrMagnitude > 0.001f)
			{
				Rigidbody body = s.Body;
				Vector3 velocity2 = s.Body.velocity;
				body.velocity = ((Vector3)(ref velocity2)).normalized * s.Speed;
			}
		}
	}

	internal static void Refresh()
	{
		//IL_0059: 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_0175: Unknown result type (might be due to invalid IL or missing references)
		//IL_0181: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0204: Unknown result type (might be due to invalid IL or missing references)
		//IL_0222: 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_0249: Unknown result type (might be due to invalid IL or missing references)
		//IL_0250: Unknown result type (might be due to invalid IL or missing references)
		//IL_0255: 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_0276: Unknown result type (might be due to invalid IL or missing references)
		if (!NetworkServer.active)
		{
			Clear();
			return;
		}
		stale.Clear();
		foreach (KeyValuePair<ProjectileSimple, Shot> shot2 in shots)
		{
			Shot value = shot2.Value;
			if (!HorizonSettings.Projectiles.Value || !Eligible(value.Controller) || !Object.op_Implicit((Object)(object)HorizonCombat.Field(((Component)value.Controller).transform.position, value.Controller.teamFilter.teamIndex)))
			{
				stale.Add(shot2.Key);
			}
		}
		foreach (ProjectileSimple item in stale)
		{
			Release(shots[item]);
			shots.Remove(item);
		}
		if (!HorizonSettings.Projectiles.Value)
		{
			return;
		}
		bool flag = false;
		foreach (VoidFiendDomain item2 in VoidFiendDomain.Live)
		{
			if (Object.op_Implicit((Object)(object)item2) && item2.Active)
			{
				flag = true;
				break;
			}
		}
		if (!flag)
		{
			return;
		}
		foreach (ProjectileController projectile in HorizonProjectileRegistry.Projectiles)
		{
			if (!Eligible(projectile))
			{
				continue;
			}
			VoidFiendDomain voidFiendDomain = HorizonCombat.Field(((Component)projectile).transform.position, projectile.teamFilter.teamIndex);
			if (!Object.op_Implicit((Object)(object)voidFiendDomain))
			{
				continue;
			}
			ProjectileSimple component = ((Component)projectile).GetComponent<ProjectileSimple>();
			if (Object.op_Implicit((Object)(object)component) && shots.ContainsKey(component))
			{
				continue;
			}
			Rigidbody component2 = ((Component)projectile).GetComponent<Rigidbody>();
			if (Supported(projectile, component, component2))
			{
				Dictionary<ProjectileSimple, Shot> dictionary = shots;
				Shot shot = new Shot
				{
					Controller = projectile,
					Simple = component,
					Body = component2
				};
				Vector3 velocity = component2.velocity;
				shot.Speed = Mathf.Max(((Vector3)(ref velocity)).magnitude, component.desiredForwardSpeed);
				shot.Applied = component2.velocity;
				dictionary.Add(component, shot);
			}
			else if (flashes.Count < 8)
			{
				Vector3 val = ((Component)projectile).transform.position - voidFiendDomain.Center;
				if (((Vector3)(ref val)).sqrMagnitude < 64f)
				{
					flashes.Add(((Component)projectile).transform.position);
				}
			}
		}
	}

	internal static void Tick()
	{
		if (!NetworkServer.active)
		{
			Clear();
		}
		else if (!(Time.time < nextScan))
		{
			nextScan = Time.time + 0.1f;
			Refresh();
			HorizonSystem.Absorb(flashes);
			flashes.Clear();
		}
	}

	private static void Bend(ProjectileSimple simple)
	{
		//IL_0043: 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_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Invalid comparison between Unknown and I4
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
		//IL_0236: Unknown result type (might be due to invalid IL or missing references)
		//IL_0238: Unknown result type (might be due to invalid IL or missing references)
		//IL_0243: Unknown result type (might be due to invalid IL or missing references)
		//IL_0247: Unknown result type (might be due to invalid IL or missing references)
		//IL_024c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0258: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ee: 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)
		if (!NetworkServer.active || !shots.TryGetValue(simple, out var value))
		{
			return;
		}
		if (!Eligible(value.Controller))
		{
			Release(value);
			shots.Remove(simple);
			return;
		}
		VoidFiendDomain voidFiendDomain = HorizonCombat.Field(((Component)value.Controller).transform.position, value.Controller.teamFilter.teamIndex);
		if (!Object.op_Implicit((Object)(object)voidFiendDomain))
		{
			Release(value);
			shots.Remove(simple);
		}
		else
		{
			if (!Object.op_Implicit((Object)(object)value.Body) || value.Body.isKinematic || (int)value.Body.constraints == 126)
			{
				return;
			}
			Vector3 position = ((Component)value.Controller).transform.position;
			Vector3 pullCenter = voidFiendDomain.PullCenter;
			Vector3 val = pullCenter - position;
			float fixedDeltaTime = Time.fixedDeltaTime;
			Vector3 val2 = position + value.Body.velocity * fixedDeltaTime;
			if (DomainRules.SegmentIntersectsSphere(position.x - pullCenter.x, position.y - pullCenter.y, position.z - pullCenter.z, val2.x - pullCenter.x, val2.y - pullCenter.y, val2.z - pullCenter.z, HorizonSettings.Absorb.Value))
			{
				ProjectileDamage component = ((Component)value.Controller).GetComponent<ProjectileDamage>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.damage = 0f;
				}
				if (flashes.Count < 32)
				{
					flashes.Add(position);
				}
				shots.Remove(simple);
				NetworkServer.Destroy(((Component)value.Controller).gameObject);
			}
			else
			{
				Vector3 val3 = ((Component)value.Controller).transform.forward;
				if (((Vector3)(ref val)).sqrMagnitude > 0.01f)
				{
					val3 = Vector3.RotateTowards(val3, ((Vector3)(ref val)).normalized, HorizonSettings.ProjectileTurn.Value * (MathF.PI / 180f) * fixedDeltaTime, 0f);
				}
				float magnitude = ((Vector3)(ref value.Applied)).magnitude;
				float num = Mathf.MoveTowards(magnitude, value.Speed * HorizonSettings.ProjectileSpeed.Value, Mathf.Max(1f, value.Speed) * fixedDeltaTime * 1.8f);
				value.Body.rotation = Quaternion.LookRotation(val3);
				value.Applied = val3 * num;
				value.Body.velocity = value.Applied;
			}
		}
	}

	internal static void Clear()
	{
		foreach (Shot value in shots.Values)
		{
			Release(value);
		}
		shots.Clear();
		flashes.Clear();
		nextScan = 0f;
	}

	internal static void Yield(ProjectileController projectile)
	{
		ProjectileSimple val = (Object.op_Implicit((Object)(object)projectile) ? ((Component)projectile).GetComponent<ProjectileSimple>() : null);
		if (Object.op_Implicit((Object)(object)val) && shots.TryGetValue(val, out var value))
		{
			Release(value);
			shots.Remove(val);
		}
	}
}
internal static class HorizonProjection
{
	private sealed class Frame
	{
		internal Camera Camera;

		internal PostProcessLayer Layer;

		internal HorizonVisual 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"))
			{
				HorizonVisual horizonVisual = ((component.stereoEnabled || component.orthographic) ? null : HorizonVisual.ForCamera(component));
				frames.TryGetValue(component, out var value);
				if ((Object)(object)value?.Owner != (Object)(object)horizonVisual)
				{
					__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)("Event Horizon physical 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("_EhzSceneryMask");

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

	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("SurvivorDomains.HorizonProjection"))
			{
				if (stream == null)
				{
					throw new InvalidOperationException("Missing Event Horizon 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("Event Horizon shader bundle did not load");
			}
			projection = val.LoadAsset<Shader>("assets/survivordomains/horizonprojection.shader");
			if (!Object.op_Implicit((Object)(object)projection) || !projection.isSupported)
			{
				throw new InvalidOperationException("Event Horizon shader unsupported");
			}
			try
			{
				using Stream stream2 = typeof(Plugin).Assembly.GetManifestResourceStream("SurvivorDomains.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)("Event Horizon scenery fade unavailable; retaining cosmic sky and physical black hole: " + ex));
			}
			Plugin.Log.LogInfo((object)"Event Horizon map-wide v6: map-wide realm with scenery dissolve; camera-local fog arbitration; physical singularity 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)("Event Horizon 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;
		}
		HorizonVisual horizonVisual = ((camera.stereoEnabled || camera.orthographic) ? null : HorizonVisual.ForCamera(camera));
		Frame value;
		if (!Object.op_Implicit((Object)(object)horizonVisual) || !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 = "Event Horizon sky and physical singularity";
			frame.Commands = val;
			frame.Sheets = new PropertySheetFactory();
			value = frame;
			frames.Add(camera, value);
			camera.AddCommandBuffer((CameraEvent)16, value.Commands);
		}
		if ((Object)(object)value.Owner != (Object)(object)horizonVisual)
		{
			value.Owner = horizonVisual;
			value.Reported = false;
			layer.OnVolumeSettingsChanged();
		}
		if ((camera.depthTextureMode & 1) == 0)
		{
			value.AddedDepth = true;
			camera.depthTextureMode = (DepthTextureMode)(camera.depthTextureMode | 1);
		}
		CommandBuffer commands = value.Commands;
		commands.Clear();
		Upload(value);
		bool flag = Object.op_Implicit((Object)(object)sceneryCoverage) && ((int)camera.actualRenderingPath == 3 || !camera.allowMSAA || QualitySettings.antiAliasing <= 1);
		if (Object.op_Implicit((Object)(object)camera.targetTexture) && camera.targetTexture.antiAliasing > 1)
		{
			flag = false;
		}
		if (flag)
		{
			commands.GetTemporaryRT(sceneryMask, camera.scaledPixelWidth, camera.scaledPixelHeight, 0, (FilterMode)0, (RenderTextureFormat)0);
			commands.SetRenderTarget(new RenderTargetIdentifier(sceneryMask), new RenderTargetIdentifier((BuiltinRenderTextureType)2));
			commands.ClearRenderTarget(false, true, Color.clear);
			HorizonSurfaces.RecordScenery(commands, camera, sceneryCoverage);
			commands.SetGlobalTexture(sceneryMask, new RenderTargetIdentifier(sceneryMask));
		}
		else
		{
			commands.SetGlobalTexture(sceneryMask, RenderTargetIdentifier.op_Implicit((Texture)(object)Texture2D.blackTexture));
		}
		commands.SetRenderTarget(RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)2));
		commands.GetTemporaryRT(temp, camera.scaledPixelWidth, camera.scaledPixelHeight, 0, (FilterMode)1, (RenderTextureFormat)(camera.allowHDR ? 9 : 7));
		RuntimeUtilities.BlitFullscreenTriangle(commands, RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)2), RenderTargetIdentifier.op_Implicit(temp), false, (Rect?)null);
		RuntimeUtilities.BlitFullscreenTriangle(commands, RenderTargetIdentifier.op_Implicit(temp), RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)2), RenderTargetIdentifier.op_Implicit((BuiltinRenderTextureType)2), value.Sheets.Get(projection), 0, false, (Rect?)null);
		commands.ReleaseTemporaryRT(temp);
		if (flag)
		{
			commands.ReleaseTemporaryRT(sceneryMask);
		}
		if (horizonVisual.Singularity != null)
		{
			horizonVisual.Singularity.Record(commands, camera, horizonVisual.VisualWeight(camera));
		}
	}

	private static void Upload(Frame frame)
	{
		//IL_001b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0031: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: 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_0044: Unknown result type (might be due to invalid IL or missing references)
		//IL_0056: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: 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_007b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Unknown result type (might be due to invalid IL or missing references)
		//IL_008e: 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_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b4: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: 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_00df: 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_010f: 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_0118: 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_011c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_0145: 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_0157: 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_0172: Unknown result type (might be due to invalid IL or missing references)
		//IL_0182: Unknown result type (might be due to invalid IL or missing references)
		//IL_0187: Unknown result type (might be due to invalid IL or missing references)
		//IL_01aa: 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_0207: Unknown result type (might be due to invalid IL or missing references)
		//IL_0250: Unknown result type (might be due to invalid IL or missing references)
		//IL_024a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0255: Unknown result type (might be due to invalid IL or missing references)
		//IL_0298: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02dd: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e2: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fd: Unknown result type (might be due to invalid IL or missing references)
		//IL_030d: Unknown result type (might be due to invalid IL or missing references)
		//IL_030e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0339: Unknown result type (might be due to invalid IL or missing references)
		//IL_0377: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
		Camera camera = frame.Camera;
		HorizonVisual owner = frame.Owner;
		CommandBuffer commands = frame.Commands;
		Vector3 forward = ((Component)camera).transform.forward;
		Ray val = camera.ViewportPointToRay(new Vector3(0f, 0f, 0f));
		Vector3 direction = ((Ray)(ref val)).direction;
		Ray val2 = camera.ViewportPointToRay(new Vector3(1f, 0f, 0f));
		Vector3 direction2 = ((Ray)(ref val2)).direction;
		Ray val3 = camera.ViewportPointToRay(new Vector3(0f, 1f, 0f));
		Vector3 direction3 = ((Ray)(ref val3)).direction;
		direction /= Mathf.Max(0.0001f, Vector3.Dot(direction, forward));
		direction2 /= Mathf.Max(0.0001f, Vector3.Dot(direction2, forward));
		direction3 /= Mathf.Max(0.0001f, Vector3.Dot(direction3, forward));
		commands.SetGlobalVector("_EhzRayOrigin", new Vector4(direction.x, direction.y, direction.z, (float)camera.scaledPixelWidth));
		Vector3 val4 = direction2 - direction;
		Vector3 val5 = direction3 - direction;
		commands.SetGlobalVector("_EhzRayRight", new Vector4(val4.x, val4.y, val4.z, (float)camera.scaledPixelHeight));
		commands.SetGlobalVector("_EhzRayUp", Vector4.op_Implicit(val5));
		commands.SetGlobalVector("_EhzCamera", Vector4.op_Implicit(((Component)camera).transform.position));
		Vector3 position = ((Component)owner).transform.position;
		commands.SetGlobalVector("_EhzDomain", new Vector4(position.x, position.y, position.z, owner.RealmRadius));
		commands.SetGlobalVector("_EhzState", new Vector4(owner.RealmAge, owner.VisualWeight(camera), owner.Instability, 0f));
		commands.SetGlobalVector("_EhzCosmic", new Vector4((float)HorizonSettings.Quality.Value, HorizonSettings.Intensity.Value, owner.CollapseProgress, HorizonSettings.Lensing.Value));
		SceneCamera component = ((Component)camera).GetComponent<SceneCamera>();
		CharacterBody val6 = ((Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.cameraRigController)) ? component.cameraRigController.targetBody : null);
		Vector3 val7 = (Object.op_Implicit((Object)(object)val6) ? val6.footPosition : position);
		commands.SetGlobalVector("_EhzFoot", new Vector4(owner.HoleSize, owner.HoleHeight, (float)((Object.op_Implicit((Object)(object)val6) && Object.op_Implicit((Object)(object)val6.characterMotor) && val6.characterMotor.isGrounded) ? 1 : 0), 0f));
		commands.SetGlobalVector("_EhzGrandHit", new Vector4(HorizonSettings.Dust.Value, val7.x, val7.y, val7.z));
		commands.SetGlobalVector("_EhzRight", Vector4.op_Implicit(((Component)camera).transform.right));
		commands.SetGlobalVector("_EhzUp", Vector4.op_Implicit(((Component)camera).transform.up));
		commands.SetGlobalVector("_EhzForward", Vector4.op_Implicit(forward));
		commands.SetGlobalVector("_EhzParams", new Vector4(camera.farClipPlane, owner.RealmOpening, HorizonSettings.Intensity.Value, 0f));
		owner.UploadImpacts(commands);
		if (!frame.Reported)
		{
			frame.Reported = true;
			Plugin.Log.LogInfo((object)string.Concat("Event Horizon map-wide v6 camera configured: path=", camera.actualRenderingPath, "; target=", camera.scaledPixelWidth, "x", camera.scaledPixelHeight, "; map-wide scenery dissolve; native camera depth preserved; physical anchor=", owner.SingularityPosition, "; map-wide fog arbitration active."));
		}
	}

	private static void Dispose(Frame frame)
	{
		//IL_0094: Unknown result type (might be due to invalid IL or missing references)
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0084: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)frame.Camera) && frame.Commands != null)
		{
			frame.Camera.RemoveCommandBuffer((CameraEvent)16, frame.Commands);
		}
		if (frame.Commands != null)
		{
			frame.Commands.Release();
			frame.Commands = null;
		}
		if (frame.Sheets != null)
		{
			frame.Sheets.Release();
			frame.Sheets = null;
		}
		if (frame.AddedDepth && Object.op_Implicit((Object)(object)frame.Camera) && (!Object.op_Implicit((Object)(object)frame.Layer) || (frame.Layer.cameraDepthFlags & 1) == 0))
		{
			Camera camera = frame.Camera;
			camera.depthTextureMode = (DepthTextureMode)(camera.depthTextureMode & -2);
		}
	}

	internal static void ReleaseOwner(HorizonVisual owner)
	{
		List<Camera> list = new List<Camera>();
		foreach (KeyValuePair<Camera, Frame> frame in frames)
		{
			if ((Object)(object)frame.Value.Owner == (Object)(object)owner || !Object.op_Implicit((Object)(object)frame.Key))
			{
				if (Object.op_Implicit((Object)(object)frame.Value.Layer))
				{
					frame.Value.Layer.OnVolumeSettingsChanged();
				}
				Dispose(frame.Value);
				list.Add(frame.Key);
			}
		}
		foreach (Camera item in list)
		{
			frames.Remove(item);
		}
	}

	internal static void Release()
	{
		foreach (Frame value in frames.Values)
		{
			if (Object.op_Implicit((Object)(object)value.Layer))
			{
				value.Layer.OnVolumeSettingsChanged();
			}
			Dispose(value);
		}
		frames.Clear();
		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;
		attempted = false;
	}
}
internal static class HorizonRules
{
	internal const float Scan = 0.1f;

	internal const float StunLease = 0.35f;

	internal static bool InCore(float horizontalSquared, float height, float holeHeight, float radius)
	{
		float num = ((height < 0f) ? (0f - height) : Math.Max(0f, height - holeHeight));
		return horizontalSquared + num * num <= radius * radius;
	}

	internal static bool Active(float age, float windup, float duration)
	{
		if (age >= windup)
		{
			return age < windup + duration;
		}
		return false;
	}

	internal static float Strength(float distance, float radius)
	{
		float num = Math.Max(0f, Math.Min(1f, distance / Math.Max(1f, radius)));
		return 0.18f + 0.82f * (1f - num) * (1f - num);
	}

	internal static int Stacks(float elapsed, float build)
	{
		return Math.Min(5, 1 + (int)(Math.Max(0f, elapsed) / Math.Max(0.1f, build) * 4f));
	}

	internal static float Capture(float distance, float capture)
	{
		return Math.Max(-0.35f, Math.Min(1f, (distance - capture) / Math.Max(1f, capture)));
	}
}
internal static class HorizonSettings
{
	internal static ConfigEntry<float> Radius;

	internal static ConfigEntry<float> Duration;

	internal static ConfigEntry<float> Windup;

	internal static ConfigEntry<float> Opening;

	internal static ConfigEntry<float> Collapse;

	internal static ConfigEntry<float> Charge;

	internal static ConfigEntry<float> Pull;

	internal static ConfigEntry<float> Lift;

	internal static ConfigEntry<float> Orbit;

	internal static ConfigEntry<float> Speed;

	internal static ConfigEntry<float> Boss;

	internal static ConfigEntry<float> MoveBonus;

	internal static ConfigEntry<float> FallSpeed;

	internal static ConfigEntry<float> Slow;

	internal static ConfigEntry<float> AttackSlow;

	internal static ConfigEntry<float> Exposure;

	internal static ConfigEntry<float> ProjectileSpeed;

	internal static ConfigEntry<float> ProjectileTurn;

	internal static ConfigEntry<float> Absorb;

	internal static ConfigEntry<float> Knockback;

	internal static ConfigEntry<float> Damage;

	internal static ConfigEntry<float> BurnRange;

	internal static ConfigEntry<float> BurnInterval;

	internal static ConfigEntry<float> BurnDuration;

	internal static ConfigEntry<float> BurnMultiplier;

	internal static ConfigEntry<float> Intensity;

	internal static ConfigEntry<float> Lensing;

	internal static ConfigEntry<float> HoleSize;

	internal static ConfigEntry<float> HoleHeight;

	internal static ConfigEntry<float> Dust;

	internal static ConfigEntry<float> CoreRadius;

	internal static ConfigEntry<float> VisualRadius;

	internal static ConfigEntry<float> VisualHeight;

	internal static ConfigEntry<float> VisualX;

	internal static ConfigEntry<float> VisualZ;

	internal static ConfigEntry<float> DiskPitch;

	internal static ConfigEntry<float> DiskYaw;

	internal static ConfigEntry<float> DiskRoll;

	internal static ConfigEntry<bool> Projectiles;

	internal static ConfigEntry<bool> Debuff;

	internal static ConfigEntry<bool> Incapacitate;

	internal static ConfigEntry<int> Quality;

	internal static ConfigEntry<KeyCode> Key;

	internal static void Bind(ConfigFile c)
	{
		//IL_0591: Unknown result type (might be due to invalid IL or missing references)
		//IL_059b: Expected O, but got Unknown
		Radius = F(c, "Radius", 62.5f, 10f, 150f, "Legacy influence scale for pull falloff and orbit; the domain covers the entire current stage.");
		Duration = F(c, "Duration", 22f, 1f, 60f, "Full active seconds after the wind-up, including the rapid visual transition.");
		Windup = F(c, "WindupDuration", 0f, 0f, 3f, "Seconds before the domain reveals and its gameplay begins. The opening hit plays immediately.");
		Opening = F(c, "OpeningDuration", 0.3f, 0.05f, 2f, "Rapid map-wide visual transition in seconds. Begins after WindupDuration.");
		Collapse = F(c, "CollapseDuration", 1f, 0.5f, 8f, "Post-expiry visual dissolution. Instability begins in the last active second.");
		Charge = F(c, "DamageToCharge", 100f, 1f, 10000f, "Level-scaled base damage multiples; charge persists on the master.");
		Pull = F(c, "PullAcceleration", 12f, 0f, 60f, "Bounded acceleration toward the physical black hole, meters/second squared.");
		Lift = F(c, "VerticalLift", 3f, 0f, 12f, "Maximum vertical drift toward the physical black hole; native collisions retained.");
		Orbit = F(c, "OrbitalSpeed", 0.5f, 0f, 10f, "Subtle tangential drift near the physical singularity.");
		Speed = F(c, "MaximumPullSpeed", 4f, 1f, 20f, "Slow capture speed in meters/second; external impulses are not abruptly clamped.");
		Boss = F(c, "BossPullMultiplier", 1f, 0f, 1f, "Boss pull multiplier; native immovable/force immunity flags remain in effect.");
		CoreRadius = F(c, "CoreIncapacitationRadius", 12f, 1f, 30f, "Legacy setting retained; incapacitation now covers every hostile in the current stage.");
		Incapacitate = c.Bind<bool>("VoidFiend", "IncapacitateCapturedEnemies", true, "Incapacitate every hostile throughout the current stage, including stun-resistant bosses. Short native stun leases expire after release; existing freezes and death transitions take priority.");
		BurnRange = F(c, "BlackHoleBurnRange", 12f, 0f, 80f, "Extra meters outside the physical black hole surface that inflict stacking native fire damage. Server authoritative.");
		BurnInterval = F(c, "BlackHoleBurnInterval", 1f, 0.25f, 10f, "Continuous seconds near the black hole per new burn stack. Leaving resets the partial interval.");
		BurnDuration = F(c, "BlackHoleBurnDuration", 4f, 0.5f, 12f, "Seconds each native burn stack lasts, including after leaving the zone or domain expiry.");
		BurnMultiplier = F(c, "BlackHoleBurnDamageMultiplier", 1f, 0f, 5f, "Native Burn damage multiplier per stack (1 = native Burn strength, including native damage caps). Zero disables new burns.");
		MoveBonus = F(c, "MovementSpeedBonus", 0.2f, 0f, 2f, "Singularity Attunement movement bonus.");
		FallSpeed = F(c, "MaximumFallSpeed", 12f, 2f, 60f, "Attuned caster fall-speed cap; leaves corruption and global gravity untouched.");
		Slow = F(c, "CorruptionMovementReduction", 0.2f, 0f, 0.6f, "Maximum movement reduction at full exposure.");
		AttackSlow = F(c, "CorruptionAttackReduction", 0.15f, 0f, 0.5f, "Maximum attack-speed reduction at full exposure.");
		Exposure = F(c, "CorruptionBuildSeconds", 4f, 0.5f, 15f, "Time to build five exposure stacks; removed on exit.");
		ProjectileSpeed = F(c, "ProjectileSpeedMultiplier", 0.55f, 0.1f, 1f, "Supported hostile shots slow gradually; native speed fields remain unchanged.");
		ProjectileTurn = F(c, "ProjectileTurnDegrees", 55f, 0f, 180f, "Maximum degrees/second steering toward the central capture point.");
		Absorb = F(c, "ProjectileAbsorptionRadius", 4f, 1f, 12f, "Core capture radius; bounded violet absorption bursts.");
		Knockback = F(c, "CollapseKnockback", 12f, 0f, 30f, "Single natural-expiry outward impulse; bosses reduced, no vertical launch.");
		Damage = F(c, "CollapseDamageCoefficient", 0f, 0f, 5f, "Optional single burst. Default 0, set 2 for 200%; independent of the near-core burn.");
		Intensity = F(c, "EnvironmentalIntensity", 1f, 0f, 1.5f, "Local cosmic projection strength; no global sky or fog writes.");
		Lensing = F(c, "GravitationalLensing", 0.8f, 0f, 1.5f, "Legacy analytic lensing strength (retained for config compatibility; physical rebuild uses a local photon glow).");
		HoleSize = F(c, "BlackHoleRadiusFraction", 0.12f, 0.07f, 0.24f, "Legacy capture-visual fraction retained for gameplay/network compatibility. Use VisualBlackHoleRadius for the physical mesh.");
		HoleHeight = F(c, "BlackHoleHeightFraction", 0.18f, 0.12f, 0.85f, "Ground-to-core gameplay capture altitude. Independent of the physical sky object.");
		VisualRadius = F(c, "VisualBlackHoleRadius", 12.5f, 4f, 30f, "Physical visual sphere radius in meters; does not change gameplay capture radius. Host synchronized.");
		VisualHeight = F(c, "VisualBlackHoleHeight", 50f, 20f, 150f, "Fixed visual height above cast center; clamped above the disk's lower extent. Host synchronized.");
		VisualX = F(c, "VisualBlackHoleOffsetX", 0f, -80f, 80f, "Fixed world X offset from cast center, in meters. Never follows camera direction.");
		VisualZ = F(c, "VisualBlackHoleOffsetZ", 18.75f, -80f, 80f, "Fixed world Z offset from cast center, in meters.");
		DiskPitch = F(c, "AccretionDiskPitch", -35f, -180f, 180f, "Fixed world-space disk pitch in degrees.");
		DiskYaw = F(c, "AccretionDiskYaw", 0f, -180f, 180f, "Fixed world-space disk yaw in degrees.");
		DiskRoll = F(c, "AccretionDiskRoll", 18f, -180f, 180f, "Fixed world-space disk roll in degrees.");
		Dust = F(c, "CelestialDebrisDensity", 0.3f, 0f, 1f, "Batched local debris/trails; procedural distant stars remain available.");
		Quality = c.Bind<int>("VoidFiend", "VisualQuality", 1, new ConfigDescription("0 low, 1 balanced, 2 high: nebula octaves, stellar layers and debris count.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 2), new object[0]));
		Projectiles = c.Bind<bool>("VoidFiend", "DistortHostileProjectiles", true, "Conservative native ProjectileSimple support. Unsupported movers get cosmetic capture traces only.");
		Debuff = c.Bind<bool>("VoidFiend", "VoidCorruption", true, "Server-authoritative stacking utility debuff, no damage over time.");
		Key = c.Bind<KeyCode>("VoidFiend", "ActivationKey", (KeyCode)116, "Additional charged domain; all normal skills remain available.");
	}

	private static ConfigEntry<float> F(ConfigFile c, string key, float value, float min, float max, string description)
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Expected O, but got Unknown
		return c.Bind<float>("VoidFiend", key, value, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<float>(min, max), new object[0]));
	}
}
internal static class HorizonSurfaces
{
	pr