Decompiled source of Megaron v1.3.11

plugins/Megaron/MegaronMod.dll

Decompiled a day ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using KinematicCharacterController;
using Microsoft.CodeAnalysis;
using R2API;
using R2API.Networking;
using R2API.Networking.Interfaces;
using R2API.Utils;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.ContentManagement;
using RoR2.ExpansionManagement;
using RoR2.Skills;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.EventSystems;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.ResourceManagement.AsyncOperations;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyFileVersion("1.3.11.0")]
[assembly: AssemblyVersion("1.3.11.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
public sealed class TU1MegaBombModBridge : IDisposable
{
	public const string PrefabAssetPath = "Assets/TU1MegaBomb/Prefabs/TU1_MegaBomb_VisualsOnly.prefab";

	private AssetBundle bundle;

	private GameObject prefab;

	public TU1MegaBombModBridge(string bundlePath)
	{
		if (string.IsNullOrEmpty(bundlePath))
		{
			throw new ArgumentException("Supply the built Mega Bomb bundle path.", "bundlePath");
		}
		if (!File.Exists(bundlePath))
		{
			throw new FileNotFoundException("Build and install tu1megabomb_vfx first.", bundlePath);
		}
		bundle = AssetBundle.LoadFromFile(bundlePath);
		if ((Object)(object)bundle == (Object)null)
		{
			throw new InvalidOperationException("Could not load the Mega Bomb bundle. Check the game/editor version and target platform.");
		}
		prefab = bundle.LoadAsset<GameObject>("Assets/TU1MegaBomb/Prefabs/TU1_MegaBomb_VisualsOnly.prefab");
		if ((Object)(object)prefab == (Object)null)
		{
			bundle.Unload(true);
			bundle = null;
			throw new InvalidOperationException("The visuals-only Mega Bomb prefab is missing. Rebuild with the included Unity menu.");
		}
	}

	public TU1MegaBombEffect Spawn(Vector3 detonationPosition, float effectsVolume, float effectScale = 1f)
	{
		//IL_0071: Unknown result type (might be due to invalid IL or missing references)
		//IL_0072: Unknown result type (might be due to invalid IL or missing references)
		//IL_0083: 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)
		if ((Object)(object)prefab == (Object)null)
		{
			throw new ObjectDisposedException("TU1MegaBombModBridge");
		}
		if (float.IsNaN(effectScale) || float.IsInfinity(effectScale) || effectScale <= 0f)
		{
			throw new ArgumentOutOfRangeException("effectScale");
		}
		if (float.IsNaN(effectsVolume) || float.IsInfinity(effectsVolume))
		{
			throw new ArgumentOutOfRangeException("effectsVolume");
		}
		GameObject val = Object.Instantiate<GameObject>(prefab, detonationPosition, Quaternion.identity);
		val.transform.localScale = Vector3.one * effectScale;
		TU1MegaBombEffect tU1MegaBombEffect = val.AddComponent<TU1MegaBombEffect>();
		tU1MegaBombEffect.playOnStart = false;
		tU1MegaBombEffect.destroyWhenComplete = true;
		tU1MegaBombEffect.effectsVolume = Mathf.Clamp01(effectsVolume);
		tU1MegaBombEffect.Play();
		return tU1MegaBombEffect;
	}

	public void Dispose()
	{
		prefab = null;
		if ((Object)(object)bundle != (Object)null)
		{
			bundle.Unload(false);
			bundle = null;
		}
	}
}
[DisallowMultipleComponent]
public sealed class TU1MegaBombEffect : MonoBehaviour
{
	[Header("Playback")]
	public bool playOnStart = true;

	public bool destroyWhenComplete = false;

	[Range(0.1f, 1f)]
	public float particleDensity = 1f;

	public int particleSeed = 9137;

	[Header("Exactly four early translucent rays")]
	[Range(1f, 10f)]
	public float rayLifetime = 5.2f;

	[Range(-90f, 90f)]
	public float rayRotationDegreesPerSecond = 34f;

	[Range(0f, 1f)]
	public float rayOpacity = 1f;

	[Header("Faint blue pulses around both body sections")]
	[Range(0f, 2f)]
	public float blueDiskOpacity = 1f;

	[Range(0.2f, 3f)]
	public float blueDiskRadius = 1f;

	[Header("Audio")]
	[Range(0f, 1f)]
	public float effectsVolume = 1f;

	public float blastWallSoundDelay = 2.7f;

	private Transform _outer;

	private Transform _inner;

	private Transform _collar;

	private Transform _streaks;

	private Transform _ground;

	private Transform _column;

	private Transform _rays;

	private Transform[] _caps;

	private Renderer[] _capRenderers;

	private Transform[] _pressure;

	private Transform[] _blue;

	private Renderer[] _pressureRenderers;

	private Renderer[] _blueRenderers;

	private Transform[] _bodyPulses;

	private Renderer[] _bodyPulseRenderers;

	private Transform[] _bodies;

	private Renderer[] _bodyRenderers;

	private Mesh[] _bodyMeshes;

	private Vector3[][] _bodyPositions;

	private Renderer _outerRenderer;

	private Renderer _innerRenderer;

	private Renderer _collarRenderer;

	private Renderer _streakRenderer;

	private Renderer _groundRenderer;

	private Renderer _columnRenderer;

	private Renderer _rayRenderer;

	private ParticleSystem[] _systems;

	private Particle[][] _buffers;

	private Mesh _columnMesh;

	private Mesh _rayMesh;

	private Mesh _domeMesh;

	private Vector3[] _columnPositions;

	private Vector3[] _rayPositions;

	private Light[] _lights;

	private AudioSource _nuke;

	private AudioSource _wallSound;

	private MaterialPropertyBlock _block;

	private bool _playing;

	private bool _wallPlayed;

	private float _time;

	public float Elapsed => _time;

	public bool RaysVisible => (Object)(object)_rayRenderer != (Object)null && _rayRenderer.enabled;

	public int LiveParticleCount
	{
		get
		{
			int num = 0;
			if (_systems != null)
			{
				ParticleSystem[] systems = _systems;
				foreach (ParticleSystem val in systems)
				{
					if ((Object)(object)val != (Object)null)
					{
						num += val.particleCount;
					}
				}
			}
			return num;
		}
	}

	private Transform Child(string path)
	{
		return ((Component)this).transform.Find(path);
	}

	private static Renderer RendererOf(Transform t)
	{
		return ((Object)(object)t != (Object)null) ? ((Component)t).GetComponent<Renderer>() : null;
	}

	private void Awake()
	{
		//IL_0540: Unknown result type (might be due to invalid IL or missing references)
		//IL_054a: Expected O, but got Unknown
		_outer = Child("Subtype5_A/BLAST_WALL_Outer");
		_inner = Child("Subtype5_B/BLAST_WALL_Inner");
		_collar = Child("Subtype5_A/BLAST_COLLAR");
		_streaks = Child("Subtype5_A/STREAKS");
		_ground = Child("Subtype5_A/Continuous_White_Wave");
		_column = Child("Subtype2/Reconstructed_FlameColumn");
		_rays = Child("Four_Rotating_Rays");
		_caps = (Transform[])(object)new Transform[3];
		_capRenderers = (Renderer[])(object)new Renderer[3];
		for (int i = 0; i < 3; i++)
		{
			_caps[i] = Child("Subtype2/Late_Expanding_Cap_" + i);
			_capRenderers[i] = RendererOf(_caps[i]);
		}
		_pressure = (Transform[])(object)new Transform[4];
		_pressureRenderers = (Renderer[])(object)new Renderer[_pressure.Length];
		for (int j = 0; j < _pressure.Length; j++)
		{
			_pressure[j] = Child("Subtype2/Anchored_Pulse_Disk_" + j);
			_pressureRenderers[j] = RendererOf(_pressure[j]);
		}
		_blue = (Transform[])(object)new Transform[10];
		_blueRenderers = (Renderer[])(object)new Renderer[_blue.Length];
		for (int k = 0; k < _blue.Length; k++)
		{
			_blue[k] = Child("Subtype5_A/Flat_Blue_Shockwave_" + k);
			_blueRenderers[k] = RendererOf(_blue[k]);
		}
		_bodyPulses = (Transform[])(object)new Transform[8];
		_bodyPulseRenderers = (Renderer[])(object)new Renderer[_bodyPulses.Length];
		for (int l = 0; l < _bodyPulses.Length; l++)
		{
			_bodyPulses[l] = Child("Subtype2/Blue_Body_Pulse_" + l);
			_bodyPulseRenderers[l] = RendererOf(_bodyPulses[l]);
		}
		_bodies = (Transform[])(object)new Transform[2];
		_bodyRenderers = (Renderer[])(object)new Renderer[2];
		_bodyMeshes = (Mesh[])(object)new Mesh[2];
		_bodyPositions = new Vector3[2][];
		for (int m = 0; m < 2; m++)
		{
			_bodies[m] = Child("Subtype2/" + ((m == 0) ? "Lower_Fireball" : "Upper_Fireball"));
			_bodyRenderers[m] = RendererOf(_bodies[m]);
			if ((Object)(object)_bodies[m] != (Object)null)
			{
				_bodyMeshes[m] = TU1MegaBombGeometry.Body(m == 1);
				((Component)_bodies[m]).GetComponent<MeshFilter>().sharedMesh = _bodyMeshes[m];
				_bodyPositions[m] = (Vector3[])(object)new Vector3[_bodyMeshes[m].vertexCount];
			}
		}
		if ((Object)(object)_outer != (Object)null)
		{
			_domeMesh = TU1MegaBombGeometry.Dome();
			((Component)_outer).GetComponent<MeshFilter>().sharedMesh = _domeMesh;
		}
		_outerRenderer = RendererOf(_outer);
		_innerRenderer = RendererOf(_inner);
		_collarRenderer = RendererOf(_collar);
		_streakRenderer = RendererOf(_streaks);
		_groundRenderer = RendererOf(_ground);
		_columnRenderer = RendererOf(_column);
		_rayRenderer = RendererOf(_rays);
		if ((Object)(object)_column != (Object)null)
		{
			_columnMesh = TU1MegaBombGeometry.Column();
			((Component)_column).GetComponent<MeshFilter>().sharedMesh = _columnMesh;
			_columnPositions = (Vector3[])(object)new Vector3[_columnMesh.vertexCount];
		}
		if ((Object)(object)_rays != (Object)null)
		{
			_rayMesh = TU1MegaBombGeometry.Rays();
			((Component)_rays).GetComponent<MeshFilter>().sharedMesh = _rayMesh;
			_rayPositions = (Vector3[])(object)new Vector3[_rayMesh.vertexCount];
		}
		_systems = (ParticleSystem[])(object)new ParticleSystem[8];
		_buffers = new Particle[_systems.Length][];
		string[] array = new string[8] { "Particles/Gold_White_Sparks", "Particles/Pink_Rising_Sparks", "Particles/WhiteHot_Fire", "Particles/AfterSmoke", "Particles/Detached_Hot_Cloud", "Particles/Wave_Spray", "Particles/Ignition_Flare", "Particles/Fireball_Halo" };
		for (int n = 0; n < _systems.Length; n++)
		{
			Transform val = Child(array[n]);
			_systems[n] = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<ParticleSystem>() : null);
			_buffers[n] = (Particle[])(object)new Particle[TU1MegaBombPlan.Capacities[n]];
		}
		_lights = ((Component)this).GetComponentsInChildren<Light>(true);
		_block = new MaterialPropertyBlock();
		Transform val2 = Child("OriginalAudio_nuke.wav");
		Transform val3 = Child("OriginalAudio_BLAST_WALL.wav");
		_nuke = (((Object)(object)val2 != (Object)null) ? ((Component)val2).GetComponent<AudioSource>() : null);
		_wallSound = (((Object)(object)val3 != (Object)null) ? ((Component)val3).GetComponent<AudioSource>() : null);
		Stop();
	}

	private void Start()
	{
		if (playOnStart && !_playing)
		{
			Play();
		}
	}

	public void Play()
	{
		Stop();
		_playing = true;
		_time = 0f;
		_wallPlayed = false;
		ParticleSystem[] systems = _systems;
		foreach (ParticleSystem val in systems)
		{
			if ((Object)(object)val != (Object)null)
			{
				val.Play(false);
			}
		}
		if ((Object)(object)_nuke != (Object)null)
		{
			_nuke.volume = effectsVolume;
			_nuke.Play();
		}
		Animate(0f);
	}

	public void Stop()
	{
		_playing = false;
		if (_systems != null)
		{
			ParticleSystem[] systems = _systems;
			foreach (ParticleSystem val in systems)
			{
				if ((Object)(object)val != (Object)null)
				{
					val.Stop(false, (ParticleSystemStopBehavior)0);
				}
			}
		}
		if ((Object)(object)_nuke != (Object)null)
		{
			_nuke.Stop();
		}
		if ((Object)(object)_wallSound != (Object)null)
		{
			_wallSound.Stop();
		}
		if (_lights != null)
		{
			Light[] lights = _lights;
			foreach (Light val2 in lights)
			{
				if ((Object)(object)val2 != (Object)null)
				{
					((Behaviour)val2).enabled = false;
				}
			}
		}
		Renderer[][] array = new Renderer[5][] { _capRenderers, _pressureRenderers, _blueRenderers, _bodyRenderers, _bodyPulseRenderers };
		foreach (Renderer[] array2 in array)
		{
			if (array2 == null)
			{
				continue;
			}
			Renderer[] array3 = array2;
			foreach (Renderer val3 in array3)
			{
				if ((Object)(object)val3 != (Object)null)
				{
					val3.enabled = false;
				}
			}
		}
		Renderer[] array4 = (Renderer[])(object)new Renderer[7] { _outerRenderer, _innerRenderer, _collarRenderer, _streakRenderer, _groundRenderer, _columnRenderer, _rayRenderer };
		foreach (Renderer val4 in array4)
		{
			if ((Object)(object)val4 != (Object)null)
			{
				val4.enabled = false;
			}
		}
	}

	private void Update()
	{
		if (!_playing)
		{
			return;
		}
		_time += Time.deltaTime;
		Animate(_time);
		if (!_wallPlayed && _time >= blastWallSoundDelay)
		{
			_wallPlayed = true;
			if ((Object)(object)_wallSound != (Object)null)
			{
				_wallSound.volume = effectsVolume;
				_wallSound.Play();
			}
		}
		if (_time >= 27.757235f)
		{
			Stop();
			if (destroyWhenComplete)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}

	private void Animate(float time)
	{
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0121: Unknown result type (might be due to invalid IL or missing references)
		//IL_0136: Unknown result type (might be due to invalid IL or missing references)
		//IL_0193: Unknown result type (might be due to invalid IL or missing references)
		//IL_019f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0221: Unknown result type (might be due to invalid IL or missing references)
		//IL_022d: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
		//IL_03bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_037c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0485: Unknown result type (might be due to invalid IL or missing references)
		//IL_0496: Unknown result type (might be due to invalid IL or missing references)
		//IL_045a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0554: Unknown result type (might be due to invalid IL or missing references)
		//IL_0559: Unknown result type (might be due to invalid IL or missing references)
		//IL_0531: Unknown result type (might be due to invalid IL or missing references)
		//IL_0740: Unknown result type (might be due to invalid IL or missing references)
		//IL_0752: Unknown result type (might be due to invalid IL or missing references)
		//IL_0645: Unknown result type (might be due to invalid IL or missing references)
		//IL_0617: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_064a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0656: Unknown result type (might be due to invalid IL or missing references)
		//IL_0665: Unknown result type (might be due to invalid IL or missing references)
		//IL_082c: Unknown result type (might be due to invalid IL or missing references)
		//IL_085a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0864: Unknown result type (might be due to invalid IL or missing references)
		//IL_0871: Unknown result type (might be due to invalid IL or missing references)
		//IL_0880: Unknown result type (might be due to invalid IL or missing references)
		//IL_0885: Unknown result type (might be due to invalid IL or missing references)
		//IL_08a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_08e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_08e9: Unknown result type (might be due to invalid IL or missing references)
		TU1MegaBombPlan.Frame f = TU1MegaBombPlan.Sample(time, rayLifetime, rayRotationDegreesPerSecond);
		Scale(_outer, f.BlueRadius, f.BlueHeight, f.BlueRadius);
		Scale(_inner, f.BlueRadius * 0.88f / 0.918f, f.BlueHeight * 0.85f / 0.413f, f.BlueRadius * 0.88f / 0.918f);
		Appearance(_outerRenderer, new Color(0.035f, 0.12f, 1f, f.BlueAlpha), new Vector2(0f, (0f - time) * 0.9f));
		Appearance(_innerRenderer, new Color(0.06f, 0.07f, 1f, 0f), new Vector2(time * 0.1f, (0f - time) * 0.7f));
		Scale(_ground, f.GroundRadius, f.GroundHeight, f.GroundRadius);
		Appearance(_groundRenderer, new Color(1.1f, 1.1f, 1.02f, f.GroundAlpha), new Vector2((0f - time) * 0.18f, (0f - time) * 0.8f));
		Scale(_collar, f.GroundRadius * 0.98f, f.GroundHeight * 1.5f, f.GroundRadius * 0.98f);
		Appearance(_collarRenderer, new Color(1f, 0.85f, 0.9f, f.GroundAlpha * 0.12f), new Vector2(0f, 0f - time));
		Scale(_streaks, f.CapRadius, f.CapHeight * 0.1f, f.CapRadius);
		if ((Object)(object)_streaks != (Object)null)
		{
			_streaks.localPosition = new Vector3(0f, f.CapY, 0f);
		}
		Appearance(_streakRenderer, new Color(1f, 1f, 0.9f, f.CapAlpha * 0.015f), new Vector2(0f, 0f - time));
		for (int i = 0; i < 3; i++)
		{
			float num = f.CapRadius * (0.9f + (float)i * 0.055f);
			Scale(_caps[i], num, f.CapHeight, num);
			if ((Object)(object)_caps[i] != (Object)null)
			{
				_caps[i].localPosition = new Vector3(0f, f.CapY + (float)i * 0.1f, 0f);
			}
			Appearance(_capRenderers[i], new Color(1.05f, 1.05f, 0.98f, f.CapAlpha * (0.26f - (float)i * 0.05f)), new Vector2(0f, (0f - time) * 0.7f));
		}
		for (int j = 0; j < _pressure.Length; j++)
		{
			TU1MegaBombPlan.Ring ring = TU1MegaBombPlan.PressureDisk(j, time);
			Scale(_pressure[j], ring.Radius, ring.Height, ring.Radius);
			if ((Object)(object)_pressure[j] != (Object)null)
			{
				_pressure[j].localPosition = new Vector3(0f, ring.Y, 0f);
			}
			Appearance(_pressureRenderers[j], new Color(1f, 0.85f + (float)j * 0.04f, 0.55f + (float)j * 0.12f, ring.Alpha), new Vector2((0f - time) * 0.24f, 0f));
		}
		for (int k = 0; k < _blue.Length; k++)
		{
			TU1MegaBombPlan.Ring ring2 = TU1MegaBombPlan.BlueWave(k, time);
			Scale(_blue[k], ring2.Radius, ring2.Height, ring2.Radius);
			if ((Object)(object)_blue[k] != (Object)null)
			{
				_blue[k].localPosition = new Vector3(0f, ring2.Y, 0f);
			}
			Appearance(_blueRenderers[k], new Color(0.1f, 0.24f, 1f, ring2.Alpha), new Vector2(time * 0.17f, 0f));
		}
		for (int l = 0; l < _bodyPulses.Length; l++)
		{
			TU1MegaBombPlan.Ring ring3 = TU1MegaBombPlan.BodyPulse(l, time);
			Scale(_bodyPulses[l], ring3.Radius * blueDiskRadius, ring3.Height, ring3.Radius * blueDiskRadius);
			if ((Object)(object)_bodyPulses[l] != (Object)null)
			{
				_bodyPulses[l].localPosition = new Vector3(0f, ring3.Y, 0f);
			}
			Appearance(_bodyPulseRenderers[l], TU1MegaBombPlan.BodyPulseTint(ring3.Alpha * blueDiskOpacity), Vector2.zero);
		}
		for (int m = 0; m < 2; m++)
		{
			if ((Object)(object)_bodyMeshes[m] != (Object)null)
			{
				TU1MegaBombGeometry.WriteBody(f, _bodyPositions[m], m == 1);
				_bodyMeshes[m].vertices = _bodyPositions[m];
				_bodyMeshes[m].RecalculateNormals();
				_bodyMeshes[m].RecalculateBounds();
				float num2 = TU1MegaBombPlan.Smooth(17f, 22f, time);
				Color tint = ((m == 0) ? new Color(1f, 1f - num2 * 0.75f, 0.94f - num2 * 0.78f, f.LowerAlpha) : new Color(1f, 1f, 0.95f, f.UpperAlpha));
				Appearance(_bodyRenderers[m], tint, new Vector2(0f, (0f - time) * 0.46f));
			}
		}
		if ((Object)(object)_columnMesh != (Object)null)
		{
			TU1MegaBombGeometry.WriteColumn(f, _columnPositions);
			_columnMesh.vertices = _columnPositions;
			_columnMesh.RecalculateNormals();
			_columnMesh.RecalculateBounds();
		}
		float num3 = TU1MegaBombPlan.Smooth(17f, 20f, time);
		float num4 = TU1MegaBombPlan.Smooth(22f, 25f, time);
		Appearance(_columnRenderer, new Color(1f, Mathf.Lerp(1f, 0.7f, num3) * (1f - num4 * 0.85f), Mathf.Lerp(0.94f, 0.22f, num3) * (1f - num4 * 0.6f), f.CoreAlpha), new Vector2(0f, (0f - time) * 0.38f));
		if ((Object)(object)_rayMesh != (Object)null)
		{
			TU1MegaBombGeometry.WriteRays(f, _rayPositions);
			_rayMesh.vertices = _rayPositions;
			_rayMesh.RecalculateBounds();
		}
		Appearance(_rayRenderer, TU1MegaBombPlan.RayTint(f.RayAlpha * rayOpacity), Vector2.zero);
		for (int n = 0; n < _systems.Length; n++)
		{
			ParticleSystem val = _systems[n];
			if ((Object)(object)val == (Object)null)
			{
				continue;
			}
			int num5 = 0;
			int num6 = Mathf.Clamp(Mathf.RoundToInt((float)TU1MegaBombPlan.Capacities[n] * particleDensity), 1, TU1MegaBombPlan.Capacities[n]);
			for (int num7 = 0; num7 < num6; num7++)
			{
				TU1MegaBombPlan.Particle particle = TU1MegaBombPlan.SampleParticle(n, num7, time, particleSeed);
				if (!(particle.Color.a < 0.002f))
				{
					Particle[] obj = _buffers[n];
					int num8 = num5++;
					Particle val2 = default(Particle);
					((Particle)(ref val2)).position = particle.Position;
					((Particle)(ref val2)).velocity = Vector3.zero;
					((Particle)(ref val2)).startColor = Color32.op_Implicit(particle.Color);
					((Particle)(ref val2)).startSize3D = new Vector3(particle.Width, particle.Height, particle.Width);
					((Particle)(ref val2)).rotation = particle.Rotation;
					((Particle)(ref val2)).startLifetime = 60f;
					((Particle)(ref val2)).remainingLifetime = 60f;
					((Particle)(ref val2)).randomSeed = (uint)(num7 + 1);
					obj[num8] = val2;
				}
			}
			val.SetParticles(_buffers[n], num5);
		}
		for (int num9 = 0; num9 < _lights.Length; num9++)
		{
			Light val3 = _lights[num9];
			if (!((Object)(object)val3 == (Object)null))
			{
				((Behaviour)val3).enabled = f.CoreAlpha > 0.01f || f.LowerAlpha > 0.01f;
				val3.range = 128f;
				val3.intensity = (f.Fade * ((num9 == 0) ? 3.5f : 2f) + f.Flash * 8f) * (0.8f + 0.2f * TU1MegaBombPlan.Noise((int)(time * 8f), 19));
			}
		}
		if ((Object)(object)_nuke != (Object)null)
		{
			_nuke.volume = effectsVolume;
		}
		if ((Object)(object)_wallSound != (Object)null)
		{
			_wallSound.volume = effectsVolume;
		}
	}

	private void Appearance(Renderer r, Color tint, Vector2 scroll)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0039: Unknown result type (might be due to invalid IL or missing references)
		//IL_004b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		if (!((Object)(object)r == (Object)null))
		{
			r.enabled = tint.a > 0.0001f;
			_block.Clear();
			_block.SetColor("_TintColor", tint);
			_block.SetVector("_UvScroll", new Vector4(scroll.x, scroll.y, 0f, 0f));
			r.SetPropertyBlock(_block);
		}
	}

	private static void Scale(Transform t, float x, float y, float z)
	{
		//IL_0010: Unknown result type (might be due to invalid IL or missing references)
		if ((Object)(object)t != (Object)null)
		{
			t.localScale = new Vector3(x, y, z);
		}
	}

	private void OnDisable()
	{
		Stop();
	}

	private void OnDestroy()
	{
		if ((Object)(object)_domeMesh != (Object)null)
		{
			Object.Destroy((Object)(object)_domeMesh);
		}
		if ((Object)(object)_columnMesh != (Object)null)
		{
			Object.Destroy((Object)(object)_columnMesh);
		}
		if ((Object)(object)_rayMesh != (Object)null)
		{
			Object.Destroy((Object)(object)_rayMesh);
		}
		if (_bodyMeshes == null)
		{
			return;
		}
		Mesh[] bodyMeshes = _bodyMeshes;
		foreach (Mesh val in bodyMeshes)
		{
			if ((Object)(object)val != (Object)null)
			{
				Object.Destroy((Object)(object)val);
			}
		}
	}
}
public static class TU1MegaBombGeometry
{
	public const int ColumnRows = 40;

	public const int ColumnSides = 48;

	public static Mesh Column()
	{
		//IL_006e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0073: Unknown result type (might be due to invalid IL or missing references)
		//IL_0080: Expected O, but got Unknown
		//IL_003a: Unknown result type (might be due to invalid IL or missing references)
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		int num = 2009;
		Vector3[] vertices = (Vector3[])(object)new Vector3[num];
		Vector2[] array = (Vector2[])(object)new Vector2[num];
		for (int i = 0; i <= 40; i++)
		{
			for (int j = 0; j <= 48; j++)
			{
				array[i * 49 + j] = new Vector2((float)j / 48f, (float)i / 40f);
			}
		}
		Mesh val = new Mesh
		{
			name = "V6_MorphingWhiteHotColumn"
		};
		val.MarkDynamic();
		val.vertices = vertices;
		val.uv = array;
		val.triangles = GridTriangles(40, 48);
		WhiteColors(val);
		return val;
	}

	private static int[] GridTriangles(int rows, int sides)
	{
		int[] array = new int[rows * sides * 6];
		int num = 0;
		for (int i = 0; i < rows; i++)
		{
			for (int j = 0; j < sides; j++)
			{
				int num2 = i * (sides + 1) + j;
				int num3 = num2 + sides + 1;
				array[num++] = num2;
				array[num++] = num3;
				array[num++] = num2 + 1;
				array[num++] = num2 + 1;
				array[num++] = num3;
				array[num++] = num3 + 1;
			}
		}
		return array;
	}

	public static void WriteColumn(TU1MegaBombPlan.Frame f, Vector3[] positions)
	{
		//IL_002d: 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)
		for (int i = 0; i <= 40; i++)
		{
			for (int j = 0; j <= 48; j++)
			{
				positions[i * 49 + j] = TU1MegaBombPlan.ColumnPoint(f, (float)i / 40f, (float)j * MathF.PI * 2f / 48f);
			}
		}
	}

	public static Mesh Dome()
	{
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		Mesh val = Column();
		((Object)val).name = "Early_Expanding_Blue_Dome";
		Vector3[] vertices = val.vertices;
		for (int i = 0; i <= 40; i++)
		{
			for (int j = 0; j <= 48; j++)
			{
				float num = (float)i / 40f;
				float num2 = (float)j * MathF.PI * 2f / 48f;
				float num3 = (float)Math.Sqrt(Math.Max(0f, 1f - num * num));
				vertices[i * 49 + j] = new Vector3((float)Math.Cos(num2) * num3, num, (float)Math.Sin(num2) * num3);
			}
		}
		val.vertices = vertices;
		val.RecalculateBounds();
		return val;
	}

	public static Mesh Body(bool upper)
	{
		Mesh val = Column();
		((Object)val).name = (upper ? "Independent_Rising_Upper_Fireball" : "Independent_Lower_Fireball");
		return val;
	}

	public static void WriteBody(TU1MegaBombPlan.Frame f, Vector3[] positions, bool upper)
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0033: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 0; i <= 40; i++)
		{
			for (int j = 0; j <= 48; j++)
			{
				positions[i * 49 + j] = TU1MegaBombPlan.BodyPoint(f, (float)i / 40f, (float)j * MathF.PI * 2f / 48f, upper);
			}
		}
	}

	public static Mesh Rays()
	{
		//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Expected O, but got Unknown
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		Vector3[] array = (Vector3[])(object)new Vector3[48];
		Vector2[] array2 = (Vector2[])(object)new Vector2[array.Length];
		int[] array3 = new int[144];
		int[] array4 = GridTriangles(3, 2);
		for (int i = 0; i < 4; i++)
		{
			for (int j = 0; j <= 3; j++)
			{
				for (int k = 0; k <= 2; k++)
				{
					array2[i * 12 + j * 3 + k] = new Vector2((float)k / 2f, (float)j / 3f);
				}
			}
			for (int l = 0; l < array4.Length; l++)
			{
				array3[i * array4.Length + l] = i * 12 + array4[l];
			}
		}
		Mesh val = new Mesh
		{
			name = "ExactlyFourTranslucentEpicenterRays"
		};
		val.MarkDynamic();
		val.vertices = array;
		val.uv = array2;
		val.triangles = array3;
		WhiteColors(val);
		return val;
	}

	public static void WriteRays(TU1MegaBombPlan.Frame f, Vector3[] positions)
	{
		//IL_009b: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		for (int i = 0; i < 4; i++)
		{
			float num = (f.RayAngle + (float)(90 * i)) * MathF.PI / 180f;
			float num2 = (float)Math.Cos(num);
			float num3 = (float)Math.Sin(num);
			for (int j = 0; j <= 3; j++)
			{
				for (int k = 0; k <= 2; k++)
				{
					float num4 = (float)j / 3f;
					float num5 = num4 * f.RayLength;
					float num6 = (float)(k - 1) * (0.15f + num4 * 10f);
					positions[i * 12 + j * 3 + k] = new Vector3(num2 * num5 - num3 * num6, 3f + num5 * 0.17f, num3 * num5 + num2 * num6);
				}
			}
		}
	}

	public static Mesh GroundRing(int sides = 128)
	{
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_007c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0081: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_01a8: Expected O, but got Unknown
		//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
		Vector3[] array = (Vector3[])(object)new Vector3[(sides + 1) * 4];
		Vector2[] array2 = (Vector2[])(object)new Vector2[array.Length];
		int[] array3 = new int[sides * 18];
		int num = 0;
		for (int i = 0; i <= sides; i++)
		{
			float num2 = (float)i * MathF.PI * 2f / (float)sides;
			float num3 = (float)Math.Cos(num2);
			float num4 = (float)Math.Sin(num2);
			array[i * 4] = new Vector3(num3, 0f, num4);
			array[i * 4 + 1] = new Vector3(num3, 1f, num4);
			array[i * 4 + 2] = new Vector3(num3 * 0.93f, 1f, num4 * 0.93f);
			array[i * 4 + 3] = new Vector3(num3 * 0.93f, 0f, num4 * 0.93f);
			for (int j = 0; j < 4; j++)
			{
				array2[i * 4 + j] = new Vector2((float)i / (float)sides * 12f, (float)j / 3f);
			}
			if (i != sides)
			{
				for (int k = 0; k < 3; k++)
				{
					int num5 = i * 4 + k;
					array3[num++] = num5;
					array3[num++] = num5 + 4;
					array3[num++] = num5 + 1;
					array3[num++] = num5 + 1;
					array3[num++] = num5 + 4;
					array3[num++] = num5 + 5;
				}
			}
		}
		Mesh val = new Mesh
		{
			name = "ContinuousWhiteWave_Rim"
		};
		val.vertices = array;
		val.uv = array2;
		val.triangles = array3;
		val.RecalculateBounds();
		WhiteColors(val);
		return val;
	}

	public static Mesh PulseDisk(int sides = 128, int rings = 16)
	{
		//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_0212: Expected O, but got Unknown
		//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
		//IL_0149: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		int num = sides + 1;
		int num2 = (rings + 1) * num;
		Vector3[] array = (Vector3[])(object)new Vector3[num2 * 2];
		Vector2[] array2 = (Vector2[])(object)new Vector2[array.Length];
		Color[] array3 = (Color[])(object)new Color[array.Length];
		int[] array4 = new int[rings * sides * 12];
		int num3 = 0;
		for (int i = 0; i < 2; i++)
		{
			for (int j = 0; j <= rings; j++)
			{
				for (int k = 0; k <= sides; k++)
				{
					float num4 = (float)j / (float)rings;
					float num5 = (float)k * MathF.PI * 2f / (float)sides;
					float num6 = (float)Math.Cos(num5);
					float num7 = (float)Math.Sin(num5);
					int num8 = i * num2 + j * num + k;
					array[num8] = new Vector3(num6 * num4, (i == 0) ? (-0.5f) : 0.5f, num7 * num4);
					array2[num8] = new Vector2(0.5f + num6 * num4 * 0.5f, 0.5f + num7 * num4 * 0.5f);
					float num9 = (float)Math.Exp(0.0 - Math.Pow((num4 - 0.67f) / 0.23f, 2.0));
					float num10 = (0.24f + 0.65f * num9) * (1f - TU1MegaBombPlan.Smooth(0.77f, 1f, num4));
					array3[num8] = new Color(1f, 1f, 1f, num10);
					if (j != rings && k != sides)
					{
						int num11 = num8 + num;
						array4[num3++] = num8;
						array4[num3++] = num11;
						array4[num3++] = num8 + 1;
						array4[num3++] = num8 + 1;
						array4[num3++] = num11;
						array4[num3++] = num11 + 1;
					}
				}
			}
		}
		Mesh val = new Mesh
		{
			name = "Filled_Feathered_Blue_Pulse_Disk"
		};
		val.vertices = array;
		val.uv = array2;
		val.colors = array3;
		val.triangles = array4;
		val.RecalculateBounds();
		return val;
	}

	private static void WhiteColors(Mesh mesh)
	{
		//IL_0013: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		Color[] array = (Color[])(object)new Color[mesh.vertexCount];
		for (int i = 0; i < array.Length; i++)
		{
			array[i] = Color.white;
		}
		mesh.colors = array;
	}
}
public static class TU1MegaBombPlan
{
	public struct Frame
	{
		public float Time;

		public float Height;

		public float Width;

		public float CoreAlpha;

		public float GroundRadius;

		public float GroundHeight;

		public float GroundAlpha;

		public float BlueRadius;

		public float BlueHeight;

		public float BlueAlpha;

		public float HeadY;

		public float HeadRadius;

		public float HeadAlpha;

		public float CapRadius;

		public float CapHeight;

		public float CapY;

		public float CapAlpha;

		public float RayAlpha;

		public float RayAngle;

		public float RayLength;

		public float Afterburn;

		public float Fade;

		public float LowerRadius;

		public float LowerHeight;

		public float LowerAlpha;

		public float UpperBaseY;

		public float UpperHeight;

		public float UpperRadius;

		public float UpperAlpha;

		public float Flash;
	}

	public struct Ring
	{
		public float Radius;

		public float Height;

		public float Y;

		public float Alpha;
	}

	public struct Particle
	{
		public Vector3 Position;

		public float Width;

		public float Height;

		public float Rotation;

		public Color Color;
	}

	public const float Duration = 27.757235f;

	public const float LowerRadiusScale = 1.18f;

	public const float LowerHeightScale = 1.12f;

	public const float DomeSpeed = 1.18f;

	public const float WhiteWallHeightScale = 2f;

	public const float BaseSizeScale = 2f;

	public const float ConnectorWidthScale = 1.15f;

	public const int RayCount = 4;

	public const int ParticleKinds = 8;

	public const int PressureDiskCount = 4;

	public const int BlueWaveCount = 10;

	public const int BodyPulseCount = 8;

	public static readonly int[] Capacities = new int[8] { 3000, 2400, 640, 240, 360, 1000, 192, 288 };

	private static readonly float[] Heights = new float[30]
	{
		0f, 3f, 0.4f, 10f, 0.8f, 24f, 1.5f, 47f, 2.4f, 50f,
		3.2f, 34f, 4f, 30f, 5f, 25f, 8f, 22f, 12f, 22f,
		16f, 20f, 20f, 23f, 24f, 16f, 26f, 6f, 27.757235f, 0f
	};

	private static readonly float[] LowerRadii = new float[28]
	{
		0f, 2f, 0.25f, 4f, 0.8f, 6.5f, 1.5f, 8.5f, 2.7f, 8.8f,
		3.5f, 9.5f, 5f, 11f, 7.5f, 12.5f, 11f, 14f, 16f, 13f,
		18f, 11f, 22f, 5f, 25f, 2f, 27.757235f, 0f
	};

	private static readonly float[] LowerHeights = new float[28]
	{
		0f, 3f, 0.5f, 9f, 0.8f, 21f, 1.5f, 46f, 2.4f, 48f,
		3.2f, 32f, 4.2f, 23f, 5.5f, 18f, 7.5f, 15f, 11f, 13f,
		16f, 12f, 19f, 19f, 24f, 13f, 27.757235f, 0f
	};

	private static readonly float[] UpperCentre = new float[26]
	{
		0f, 24f, 3.5f, 24f, 4.2f, 30f, 5f, 38f, 7f, 52f,
		9f, 67f, 12f, 77f, 14f, 82f, 16f, 87f, 18f, 94f,
		21f, 109f, 24f, 123f, 27.757235f, 130f
	};

	private static readonly float[] UpperHeights = new float[28]
	{
		0f, 0f, 3.5f, 0f, 4.2f, 12f, 5f, 30f, 7f, 64f,
		9f, 92f, 12f, 110f, 14f, 105f, 16f, 94f, 17.5f, 76f,
		19f, 48f, 21f, 32f, 24f, 14f, 27.757235f, 0f
	};

	private static readonly float[] UpperRadii = new float[26]
	{
		0f, 0f, 3.5f, 0.1f, 4.2f, 2f, 5f, 6f, 6.5f, 12f,
		8.5f, 19f, 11f, 22f, 14f, 22f, 16f, 20f, 18f, 17f,
		21f, 14f, 24f, 11f, 27.757235f, 0f
	};

	public static Color RayTint(float alpha)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		return new Color(1.4f, 0.065f, 0.09f, alpha);
	}

	public static Color BodyPulseTint(float alpha)
	{
		//IL_0011: Unknown result type (might be due to invalid IL or missing references)
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		return new Color(0.035f, 0.14f, 1f, alpha);
	}

	public static float Saturate(float x)
	{
		return Math.Max(0f, Math.Min(1f, x));
	}

	public static float Smooth(float a, float b, float t)
	{
		float num = Saturate((t - a) / (b - a));
		return num * num * (3f - 2f * num);
	}

	public static float Mix(float a, float b, float u)
	{
		return a + (b - a) * Saturate(u);
	}

	public static float Noise(int i, int seed)
	{
		uint num = (uint)(i * 374761393 + seed * 668265263);
		num = (num ^ (num >> 13)) * 1274126177;
		return (float)(num ^ (num >> 16)) / 4.2949673E+09f;
	}

	private static float Curve(float t, float[] a)
	{
		for (int i = 2; i < a.Length; i += 2)
		{
			if (t <= a[i])
			{
				return Mix(a[i - 1], a[i + 1], Smooth(a[i - 2], a[i], t));
			}
		}
		return a[^1];
	}

	public static Frame Sample(float time, float raySeconds = 5.2f, float raySpeed = 34f)
	{
		float num = Math.Max(0f, Math.Min(27.757235f, time));
		float num2 = 1f - Smooth(24.2f, 27.757235f, num);
		float num3 = Smooth(16.9f, 18.5f, num) * num2;
		float u = Smooth(0.25f, 1.4f, num);
		float t = num * 1.18f;
		float num4 = Curve(num, LowerRadii) * Mix(1f, 1.18f, u);
		float num5 = Curve(num, LowerHeights) * Mix(1f, 1.12f, u);
		float num6 = num5 * 1f;
		float num7 = Curve(num, UpperCentre) - Curve(num, UpperHeights) * 0.5f + num6;
		float num8 = Smooth(3.6f, 4.4f, num) * (1f - Smooth(16.4f, 18.2f, num));
		float num9 = 6f + 8.8f * num + 0.13f * num * num;
		return new Frame
		{
			Time = num,
			Height = Mix(Curve(num, Heights), num7 + 7f, num8),
			Width = Mix(8f, 3f, Smooth(3f, 19f, num)) * 1.15f,
			CoreAlpha = Math.Max(num8 * 0.78f, num3 * 0.65f) * num2,
			GroundRadius = num9,
			GroundHeight = 2f * (0.35f + 2.4f * Smooth(0f, 16f, num)),
			GroundAlpha = Smooth(0f, 0.2f, num) * (1f - Smooth(17.5f, 23f, num)),
			BlueRadius = Mix(4f, 110f, Smooth(0f, 3.1f, t)),
			BlueHeight = Mix(3f, 78f, Smooth(0f, 3.1f, t)),
			BlueAlpha = 0.24f * Smooth(0.1f, 0.45f, t) * (1f - Smooth(2.7f, 3.7f, t)),
			HeadY = Mix(88f, 132f, Smooth(16.8f, 24f, num)) + num6,
			HeadRadius = Mix(17f, 24f, Smooth(16.4f, 21f, num)),
			HeadAlpha = Smooth(16.4f, 17.8f, num) * (1f - Smooth(21.5f, 25f, num)),
			CapRadius = num9 * (1.02f + 0.22f * Smooth(15.7f, 17.9f, num)),
			CapHeight = 0.2f + 0.5f * Smooth(15.7f, 18f, num),
			CapY = 0.35f,
			CapAlpha = 0.35f * Smooth(15.7f, 16.5f, num) * (1f - Smooth(18f, 20.5f, num)),
			RayAlpha = 0.31f * Smooth(0f, 0.12f, num) * (1f - Smooth(Math.Max(0.2f, raySeconds - 1.5f), Math.Max(0.3f, raySeconds), num)),
			RayAngle = 32f + num * raySpeed,
			RayLength = Mix(100f, 235f, Smooth(0f, 2.1f, num)),
			Afterburn = num3,
			Fade = num2,
			LowerRadius = num4 * 2f,
			LowerHeight = num5 * 2f,
			LowerAlpha = Smooth(0f, 0.12f, num) * num2,
			UpperBaseY = num7,
			UpperHeight = Curve(num, UpperHeights),
			UpperRadius = Curve(num, UpperRadii),
			UpperAlpha = Smooth(3.5f, 4.35f, num) * (1f - Smooth(16.3f, 18.9f, num)),
			Flash = Smooth(0f, 0.08f, num) * (1f - Smooth(0.28f, 0.85f, num))
		};
	}

	public static Ring PressureDisk(int index, float time)
	{
		Frame frame = Sample(time);
		float num = 0.5f + 0.5f * (float)Math.Sin(time * 5.4f - (float)index * 0.85f);
		return new Ring
		{
			Radius = frame.LowerRadius * (1.04f + (float)index * 0.075f) * (0.96f + 0.09f * num),
			Height = 0.38f + (float)index * 0.08f,
			Y = 0.5f + frame.LowerHeight * (0.09f + (float)index * 0.205f),
			Alpha = (0.24f + 0.4f * num) * Smooth(1.5f + (float)index * 0.12f, 2.3f + (float)index * 0.16f, time) * (1f - Smooth(17f, 22f, time)) * frame.Fade
		};
	}

	public static Ring BlueWave(int index, float time)
	{
		float num = 0.18f + (float)index * 0.72f;
		float num2 = time - num;
		if (num2 < 0f)
		{
			return default(Ring);
		}
		float num3 = (float)Math.Floor(num2 / 7.2f);
		float num4 = num2 - num3 * 7.2f;
		float num5 = time - num4;
		Frame frame = Sample(num5);
		float num6 = Smooth(0f, 11f, num5);
		float num7 = Smooth(0f, 0.18f, num4) * (1f - Smooth(4.9f, 7.2f, num4)) * (1f - Smooth(16f, 23f, time));
		if (num5 > 17.8f)
		{
			num7 = 0f;
		}
		return new Ring
		{
			Radius = 6f + frame.LowerRadius * 0.5f + num4 * (34f + num6 * 22f),
			Height = 0.14f + 0.26f * (1f - num4 / 7.2f),
			Y = 0.5f + frame.LowerHeight * (float)(index % 3) * 0.1f,
			Alpha = num7 * (0.08f + 0.12f * num6)
		};
	}

	public static float ColumnRadius(float time, float h)
	{
		float num = Saturate(h);
		float a = (0.7f + 0.06f * (float)Math.Sin(num * 18f - time * 3f)) * (1f - Smooth(0.85f, 1f, num));
		float u = Smooth(3.6f, 4.4f, time) * (1f - Smooth(17.3f, 18.1f, time));
		float num2 = 0.82f + 0.18f * (1f - Smooth(0.1f, 0.4f, num)) + 0.55f * Smooth(0.55f, 0.91f, num);
		a = Mix(a, num2 * (1f - Smooth(0.95f, 1f, num)), u);
		return Math.Max(0f, a);
	}

	public static Vector3 ColumnPoint(Frame f, float h, float a)
	{
		//IL_0065: Unknown result type (might be due to invalid IL or missing references)
		//IL_006a: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Unknown result type (might be due to invalid IL or missing references)
		float num = ColumnRadius(f.Time, h) * f.Width;
		float num2 = 1f + 0.09f * (float)Math.Sin(a * 7f + h * 25f - f.Time * 6f);
		return new Vector3((float)Math.Cos(a) * num * num2, h * f.Height, (float)Math.Sin(a) * num * num2);
	}

	public static Ring BodyPulse(int index, float time)
	{
		if (index < 0 || index >= 8 || time < 0f || time >= 27.757235f)
		{
			return default(Ring);
		}
		bool flag = index >= 4;
		int num = index % 4;
		int num2 = num / 2;
		int num3 = num % 2;
		float num4 = (flag ? 3.6f : 1.5f) + (float)num3 * 3.6f * 0.5f + (float)num2 * 0.55f;
		float num5 = time - num4;
		if (num5 < 0f)
		{
			return default(Ring);
		}
		float num6 = (float)Math.Floor(num5 / 3.6f);
		float num7 = num5 - num6 * 3.6f;
		float num8 = time - num7;
		Frame frame = Sample(time);
		Frame frame2 = Sample(num8);
		float num9 = Smooth(1.5f, 12f, num8);
		float radius = (flag ? (frame2.UpperRadius * 1.25f) : (frame2.LowerRadius * 1.4f)) + num7 * ((float)(flag ? 36 : 32) + num9 * (float)(flag ? 15 : 14));
		float num10 = Smooth(0f, 0.22f, num7) * (1f - Smooth(2f, 3.6f, num7));
		float num11 = (flag ? (Smooth(3.5f, 4.4f, time) * (1f - Smooth(17.5f, 20.5f, time))) : (Smooth(1.5f, 2.5f, time) * (1f - Smooth(19f, 23f, time))));
		if (num8 > (flag ? 18.4f : 19.5f))
		{
			num11 = 0f;
		}
		return new Ring
		{
			Radius = radius,
			Height = 0.38f,
			Y = (flag ? (frame.UpperBaseY + frame.UpperHeight * (0.14f + (float)num2 * 0.4f)) : (0.6f + frame.LowerHeight * (0.35f + (float)num2 * 0.45f))),
			Alpha = 0.085f * num10 * num11 * frame.Fade
		};
	}

	public static Vector3 BodyPoint(Frame f, float h, float a, bool upper)
	{
		//IL_02b7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02bc: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c0: Unknown result type (might be due to invalid IL or missing references)
		float num;
		float num2;
		float num3;
		float a3;
		if (upper)
		{
			num = f.UpperRadius;
			num2 = f.UpperHeight;
			num3 = f.UpperBaseY;
			float u = Smooth(9.5f, 14.5f, f.Time);
			float a2 = 3.08f * (float)(Math.Pow(Math.Max(0f, h), 0.55) * Math.Pow(Math.Max(0f, 1f - h), 1.3));
			float b = (float)Math.Pow(Math.Max(0.0, Math.Sin(Math.PI * (double)h)), 0.48);
			a3 = Mix(a2, b, u);
			float num4 = Mix(3.08f * (float)(Math.Pow(0.28, 0.55) * Math.Pow(0.72, 1.3)), (float)Math.Pow(Math.Sin(0.8796459430051422), 0.48), u);
			float b2 = num4 * Saturate(h / 0.28f);
			a3 = Mix(a3, b2, 0.3f * (1f - Smooth(0.18f, 0.34f, h)));
		}
		else
		{
			num = f.LowerRadius;
			num2 = f.LowerHeight;
			num3 = 0f;
			float num5 = Smooth(3.5f, 6f, f.Time);
			float num6 = (0.11f - 0.065f * num5) * (float)Math.Sin(h * 17f - f.Time * 2.8f) * Smooth(0f, 0.1f, h);
			float num7 = 0.76f + 0.11f * (float)Math.Exp(0.0 - Math.Pow((h - 0.3f) / 0.3f, 2.0)) + num6;
			float num8 = 0.35f * (1f - Smooth(0f, 0.16f, h));
			float num9 = 1f - Smooth(Mix(0.82f, 0.94f, num5), 1f, h);
			a3 = (num7 + num8) * num9;
		}
		float num10 = 0.035f * (float)Math.Sin(a * 9f + h * 27f - f.Time * 5f) + 0.018f * (float)Math.Sin(a * 17f - h * 49f + f.Time * 7f);
		float num11 = num * a3 * (1f + num10);
		return new Vector3((float)Math.Cos(a) * num11, num3 + h * num2, (float)Math.Sin(a) * num11);
	}

	public static float SparkCurlSeconds(int slot, int seed = 9137)
	{
		return 0.65f + 0.25f * Noise(slot, seed + 82);
	}

	public static float SparkCurlAngle(int slot, int seed = 9137)
	{
		return 0.35f + 0.25f * Noise(slot, seed + 127);
	}

	public static Vector3 SparkPath(int slot, float age, float birth, int cycle = 0, int seed = 9137)
	{
		//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0134: Unknown result type (might be due to invalid IL or missing references)
		//IL_01bd: Unknown result type (might be due to invalid IL or missing references)
		float num = Noise(slot, seed + 82);
		float num2 = Noise(slot, seed + 127);
		float num3 = SparkCurlSeconds(slot, seed);
		float num4 = SparkCurlAngle(slot, seed);
		Frame frame = Sample(Math.Max(0f, birth));
		float num5 = Noise(slot, cycle + seed + 73) * MathF.PI * 2f;
		float num6 = Mix(frame.LowerHeight * 0.72f, frame.UpperBaseY + frame.UpperHeight * 0.7f, frame.UpperAlpha * 0.85f);
		float num7 = frame.LowerRadius * (0.04f + num * 0.08f);
		float num8 = num7 + 0.7f + num2 * 0.8f;
		float num9 = 40f + num2 * 14f;
		float u = Saturate(age / num3);
		float num10 = num5 + num4 * Smooth(0f, num3, age);
		float num11 = (float)Math.Cos(num10);
		float num12 = (float)Math.Sin(num10);
		if (age <= num3)
		{
			float num13 = Mix(num7, num8, u);
			return new Vector3(num11 * num13, num6 + age * num9, num12 * num13);
		}
		float num14 = age - num3;
		float num15 = 7f + num2 * 12f;
		float num16 = 1.5f + num * 3.5f;
		return new Vector3(num11 * num8 + num14 * (num11 * num15 - num12 * num16), Math.Max(0.15f, num6 + num3 * num9 + num14 * (9f + num * 7f) - 7.5f * num14 * num14), num12 * num8 + num14 * (num12 * num15 + num11 * num16));
	}

	public static Particle SampleParticle(int kind, int slot, float time, int seed = 9137)
	{
		//IL_04a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_04a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0366: Unknown result type (might be due to invalid IL or missing references)
		//IL_036b: Unknown result type (might be due to invalid IL or missing references)
		//IL_05b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_05bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_05e6: Unknown result type (might be due to invalid IL or missing references)
		//IL_05eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d68: Unknown result type (might be due to invalid IL or missing references)
		//IL_0d6a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0da0: Unknown result type (might be due to invalid IL or missing references)
		//IL_0da2: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b1a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0aff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0b1f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bc6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0bcb: Unknown result type (might be due to invalid IL or missing references)
		//IL_0cca: Unknown result type (might be due to invalid IL or missing references)
		//IL_0caf: Unknown result type (might be due to invalid IL or missing references)
		//IL_0ccf: Unknown result type (might be due to invalid IL or missing references)
		float num = Noise(slot, seed + kind * 37);
		float num2 = Noise(slot, seed + 82);
		float num3 = Noise(slot, seed + 127);
		float num4 = kind switch
		{
			6 => 0.5f + num * 0.4f, 
			5 => 1.1f + num * 1.1f, 
			4 => 2.3f + num * 2f, 
			3 => 3f + num * 3f, 
			2 => 0.9f + num * 1.1f, 
			1 => 3.2f + num * 1f, 
			0 => 1.3f + num * 1.7f, 
			_ => 1.2f + num, 
		};
		float num5 = time + num * num4;
		float num6 = (float)Math.Floor(num5 / num4);
		float num7 = num5 - num6 * num4;
		float num8 = time - num7;
		float num9 = num7 / num4;
		float num10 = Noise(slot, (int)num6 + seed + kind * 73);
		float num11 = num10 * MathF.PI * 2f;
		Frame f = Sample(time);
		Frame f2 = Sample(Math.Max(0f, num8));
		float num12 = Smooth(0f, 0.06f, num9) * (1f - Smooth(0.7f, 1f, num9));
		float num13 = Smooth(0f, 0.25f, num8) * (1f - Smooth(22f, 25f, num8));
		if (kind == 1)
		{
			num13 = Smooth(1.5f, 1.8f, num8) * (1f - Smooth(3f, 4.1f, num8)) + 0.3f * Smooth(4f, 7f, num8) * (1f - Smooth(16.5f, 20f, num8));
		}
		if (kind == 3)
		{
			num13 *= Smooth(13f, 17f, num8);
		}
		if (kind == 4)
		{
			num13 = Smooth(16.2f, 17.2f, num8) * (1f - Smooth(18.8f, 20.8f, num8)) * (1f - Smooth(19.2f, 22.3f, time));
		}
		if (kind == 5)
		{
			num13 *= 1f - Smooth(17.5f, 21.5f, num8);
		}
		if (kind == 6)
		{
			num8 = num * 0.22f;
			num7 = time - num8;
			num9 = Saturate(num7 / num4);
			num13 = ((num7 >= 0f && num7 < num4) ? 1 : 0);
			num12 = Smooth(0f, 0.08f, num9) * (1f - Smooth(0.35f, 1f, num9));
		}
		if (num8 < 0f || time >= 27.757235f || time < 0f)
		{
			num13 = 0f;
		}
		float num14 = 1f;
		Vector3 position = default(Vector3);
		float num16;
		Color color = default(Color);
		switch (kind)
		{
		case 0:
			if (slot % 4 != 0)
			{
				float h2 = (num2 + num9 * 0.4f) % 1f;
				bool flag4 = f.UpperAlpha > 0.3f && slot % 3 != 0;
				position = BodyPoint(f, h2, num11 + time * 0.6f, flag4);
				position.x *= 1.02f;
				position.z *= 1.02f;
				if (!flag4 && time < 3f)
				{
					position.y += num9 * f2.Height * 0.4f;
				}
			}
			else
			{
				float num24 = 2f + num7 * (9f + num2 * 35f);
				((Vector3)(ref position))..ctor((float)Math.Cos(num11) * num24, Math.Max(0.15f, 1f + num7 * (16f + num3 * 31f) - 4.9f * num7 * num7), (float)Math.Sin(num11) * num24);
			}
			num16 = ((slot % 11 == 0) ? (1.7f + num3 * 1.8f) : (0.4f + num3 * 1f)) * (1f - 0.4f * num9);
			((Color)(ref color))..ctor(1f, 0.9f + num2 * 0.1f, 0.65f + num2 * 0.35f, 1f);
			break;
		case 1:
		{
			position = SparkPath(slot, num7, num8, (int)num6, seed);
			num16 = (1f + num2 * 1.05f) * (1f - num9 * 0.35f);
			num14 = 1f + num3 * 0.5f;
			float u = Smooth(SparkCurlSeconds(slot, seed) + 0.05f, SparkCurlSeconds(slot, seed) + 0.65f, num7);
			float a = ((Noise(slot, seed + 211) > 0.66f) ? 1f : (0.08f + num2 * 0.15f));
			float a2 = ((Noise(slot, seed + 211) > 0.66f) ? 0.93f : (0.55f + num3 * 0.3f));
			((Color)(ref color))..ctor(1f, Mix(a, 1f, u), Mix(a2, 0.95f, u), 1f);
			break;
		}
		case 2:
		{
			bool flag3 = f2.UpperAlpha > 0.2f && slot % 3 != 0;
			float h = num2 * 0.94f;
			position = BodyPoint(f2, h, num11, flag3);
			if (num8 < 3.5f)
			{
				position = BodyPoint(f2, 0.12f + num2 * 0.78f, num11, upper: false);
				float num22 = (0.2f + 0.65f * (float)Math.Sqrt(num3)) * (1f - 0.22f * num9);
				position.x *= num22;
				position.z *= num22;
				position.x += (float)Math.Sin(num8 * 3.2f + num7 * 2f + num2 * 0.8f) * num7;
				position.z += (float)Math.Cos(num8 * 2.7f + num7 * 1.8f + num2) * num7 * 0.7f;
				position.y += num7 * (12f + num3 * 9f);
				num16 = (5.5f + num2 * 5f) * (1f + 0.15f * Smooth(0f, 0.5f, num7)) * (1f - 0.35f * num9);
				num14 = 0.9f + num3 * 0.75f;
				((Color)(ref color))..ctor(1f, 0.99f, 0.95f, 0.32f);
				if (slot % 8 == 0)
				{
					((Color)(ref color))..ctor(1f, 0.12f, 0.5f, 0.08f);
				}
			}
			else
			{
				float num23 = 1f + num7 * 0.08f;
				position.x *= num23;
				position.z *= num23;
				position.y += num7 * (5f + num3 * 10f);
				num16 = (2.2f + num2 * 4.6f) * (1f - 0.5f * num9);
				num14 = 1.6f + num3 * 1.8f;
				((Color)(ref color))..ctor(1f, 0.83f + (1f - num9) * 0.17f, 0.65f + (1f - num9) * 0.3f, 0.27f);
				if (slot % 4 == 0)
				{
					((Color)(ref color))..ctor(1f, 0.08f, 0.5f, 0.25f);
				}
			}
			if (flag3)
			{
				color.a *= f.UpperAlpha;
			}
			break;
		}
		case 3:
		{
			float num21 = (f.UpperRadius + 3f) * (0.4f + num2) + num7 * 2f;
			((Vector3)(ref position))..ctor((float)Math.Cos(num11) * num21, 8f + num2 * (f.UpperBaseY + f.UpperHeight) + num7 * 5f, (float)Math.Sin(num11) * num21);
			num16 = (6f + num2 * 11f) * (1f + num9 * 0.5f);
			((Color)(ref color))..ctor(0.38f, 0.08f, 0.32f, 0.1f);
			break;
		}
		case 4:
		{
			float num25 = f.HeadRadius * (0.15f + num2 * 0.85f) * (1f + num9 * 0.25f);
			((Vector3)(ref position))..ctor((float)Math.Cos(num11) * num25, f.HeadY + (num3 - 0.5f) * f.HeadRadius * 1.5f + num7, (float)Math.Sin(num11) * num25);
			num16 = (8f + num2 * 14f) * (1f + num9 * 0.25f);
			float u2 = 1f - Smooth(16.4f, 18f, time);
			((Color)(ref color))..ctor(1f, Mix(0.03f, 1f, u2), Mix(0.46f, 0.95f, u2), 0.35f);
			break;
		}
		case 5:
		{
			float num20 = f2.GroundRadius + num7 * (12f + num3 * 9f);
			((Vector3)(ref position))..ctor((float)Math.Cos(num11) * num20, Math.Max(0.15f, 0.2f + num7 * (4f + num2 * 7f) - 2.8f * num7 * num7), (float)Math.Sin(num11) * num20);
			num16 = (0.35f + num2 * 1.2f) * (1f - 0.5f * num9);
			num14 = 1.1f + num3;
			((Color)(ref color))..ctor(1f, 1f, 0.9f, 0.8f);
			break;
		}
		case 6:
		{
			float num19 = num7 * (8f + num2 * 24f);
			((Vector3)(ref position))..ctor((float)Math.Cos(num11) * num19, 1f + num7 * (3f + num3 * 14f), (float)Math.Sin(num11) * num19);
			num16 = (4f + num2 * 7f) * (1f - num9 * 0.4f);
			color = ((slot % 3 == 0) ? new Color(1f, 1f, 0.9f, 0.7f) : new Color(1f, 0.1f, 0.48f, 0.35f));
			break;
		}
		default:
		{
			bool flag = time > 4f && slot % 3 != 0;
			bool flag2 = f.UpperAlpha > 0.05f && slot % 6 == 0;
			if (flag2)
			{
				float num15 = 0.4f + num3 * 1.3f;
				((Vector3)(ref position))..ctor((float)Math.Cos(num11) * num15, Mix(f.LowerHeight, f.UpperBaseY, num2), (float)Math.Sin(num11) * num15);
				num16 = 7f + num2 * 9f;
				num14 = 1.5f;
			}
			else
			{
				position = BodyPoint(f, num2 * 0.94f, num11, flag);
				position.x *= 1.04f;
				position.z *= 1.04f;
				num16 = (flag ? (10f + num2 * 10f) : (8f + num2 * 8f));
				num14 = 1.3f;
			}
			float num17 = (flag ? (0.65f + 0.25f * num2) : 0.4f) * Smooth(3.2f, 5f, time) * (1f - Smooth(17f, 19f, time));
			float num18 = (flag ? 0f : Smooth(18f, 23f, time));
			color = (flag2 ? new Color(1f, 0.05f, 0.35f, 0.18f) : new Color(1f, 0.015f + num17 * 0.75f, (0.42f - num17 * 0.37f) * (1f - num18 * 0.88f), 0.24f));
			if (flag)
			{
				color.a *= f.UpperAlpha;
			}
			break;
		}
		}
		float num26 = ((kind < 2) ? (0.45f + 0.55f * (float)Math.Pow(0.5 + 0.5 * Math.Sin(time * (18f + num2 * 16f) + (float)(slot * 11)), 3.0)) : 1f);
		color.a *= num13 * num12 * num26 * f.Fade;
		return new Particle
		{
			Position = position,
			Width = num16,
			Height = num16 * num14,
			Rotation = (float)Math.Sin((float)(slot * 7) + time) * 12f,
			Color = color
		};
	}
}
namespace Megaron
{
	[DisallowMultipleComponent]
	public sealed class MegaronVisualRig : MonoBehaviour
	{
		public Transform turretYaw;

		public Transform gunPitch;

		public Transform gunRecoil;

		public Transform muzzle;

		public Transform barrelFace;

		[Min(1f)]
		public float yawDegreesPerSecond = 100f;

		[Min(1f)]
		public float pitchDegreesPerSecond = 70f;

		public float minimumElevation = -10f;

		public float maximumElevation = 30f;

		[Min(0f)]
		public float recoilSourceUnits = 1f;

		[Min(0.01f)]
		public float recoilReturnSourceUnitsPerSecond = 7f;

		private float targetYaw;

		private float targetPitch;

		private float yaw;

		private float pitch;

		private float recoil;

		private Vector3 restRecoil;

		private bool bound;

		private void Awake()
		{
			Bind();
		}

		public void Bind()
		{
			//IL_013e: 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_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			turretYaw = (Object.op_Implicit((Object)(object)turretYaw) ? turretYaw : Find(((Component)this).transform, "TurretYaw"));
			gunPitch = (Object.op_Implicit((Object)(object)gunPitch) ? gunPitch : Find(((Component)this).transform, "GunPitch"));
			gunRecoil = (Object.op_Implicit((Object)(object)gunRecoil) ? gunRecoil : Find(((Component)this).transform, "GunRecoil"));
			muzzle = (Object.op_Implicit((Object)(object)muzzle) ? muzzle : Find(((Component)this).transform, "muzzle"));
			barrelFace = (Object.op_Implicit((Object)(object)barrelFace) ? barrelFace : Find(((Component)this).transform, "BarrelFace"));
			bound = Object.op_Implicit((Object)(object)turretYaw) && Object.op_Implicit((Object)(object)gunPitch) && Object.op_Implicit((Object)(object)gunRecoil) && Object.op_Implicit((Object)(object)muzzle);
			if (!bound)
			{
				Debug.LogError((object)"Megaron visual rig is missing named transforms.", (Object)(object)this);
				((Behaviour)this).enabled = false;
				return;
			}
			restRecoil = gunRecoil.localPosition;
			yaw = Mathf.DeltaAngle(0f, turretYaw.localEulerAngles.y);
			pitch = Mathf.DeltaAngle(0f, gunPitch.localEulerAngles.x);
			targetYaw = yaw;
			targetPitch = pitch;
		}

		public void AimWorld(Vector3 direction)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			if (!(((Vector3)(ref direction)).sqrMagnitude < 1E-05f))
			{
				AimLocal(((Component)this).transform.InverseTransformDirection(((Vector3)(ref direction)).normalized));
			}
		}

		public void AimLocal(Vector3 direction)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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_0049: Unknown result type (might be due to invalid IL or missing references)
			if (!(((Vector3)(ref direction)).sqrMagnitude < 1E-05f))
			{
				targetYaw = Mathf.Atan2(direction.x, direction.z) * 57.29578f;
				float y = direction.y;
				Vector2 val = new Vector2(direction.x, direction.z);
				float num = Mathf.Atan2(y, ((Vector2)(ref val)).magnitude) * 57.29578f;
				targetPitch = 0f - Mathf.Clamp(num, minimumElevation, maximumElevation);
			}
		}

		public void SetAngles(float yawDegrees, float elevationDegrees)
		{
			targetYaw = yawDegrees;
			targetPitch = 0f - Mathf.Clamp(elevationDegrees, minimumElevation, maximumElevation);
		}

		public void FireVisualRecoil()
		{
			recoil = recoilSourceUnits;
		}

		private void LateUpdate()
		{
			//IL_006f: 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_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: 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)
			if (bound)
			{
				yaw = Mathf.MoveTowardsAngle(yaw, targetYaw, yawDegreesPerSecond * Time.deltaTime);
				pitch = Mathf.MoveTowards(pitch, targetPitch, pitchDegreesPerSecond * Time.deltaTime);
				turretYaw.localRotation = Quaternion.Euler(0f, yaw, 0f);
				gunPitch.localRotation = Quaternion.Euler(pitch, 0f, 0f);
				recoil = Mathf.MoveTowards(recoil, 0f, recoilReturnSourceUnitsPerSecond * Time.deltaTime);
				gunRecoil.localPosition = restRecoil + Vector3.back * recoil;
			}
		}

		public static Transform Find(Transform root, string name)
		{
			if (((Object)root).name == name)
			{
				return root;
			}
			for (int i = 0; i < root.childCount; i++)
			{
				Transform val = Find(root.GetChild(i), name);
				if (Object.op_Implicit((Object)(object)val))
				{
					return val;
				}
			}
			return null;
		}
	}
	public static class MegaronRules
	{
		public static bool InSphere(float dx, float dy, float dz, float radius)
		{
			return radius >= 0f && dx * dx + dy * dy + dz * dz <= radius * radius;
		}

		public static bool InRadar(float dx, float dz, float radius)
		{
			return radius > 0f && dx * dx + dz * dz <= radius * radius;
		}

		public static float LightningHash(uint seed, int index)
		{
			uint num = seed ^ (uint)(index * -1640531527);
			num ^= num >> 16;
			num *= 2146121005;
			num ^= num >> 15;
			num *= 2221713035u;
			num ^= num >> 16;
			return (float)(num & 0xFFFFFF) / 16777215f;
		}

		public static bool Finite(float value)
		{
			return !float.IsNaN(value) && !float.IsInfinity(value);
		}

		public static float StormReach(float elapsed, float duration)
		{
			return (duration > 0f) ? Smooth(elapsed / duration) : 1f;
		}

		public static float StormFlare(float t, float distance, float maximum)
		{
			return (float)Math.Sin((double)Math.Max(0f, Math.Min(1f, t)) * Math.PI) * Math.Min(maximum, Math.Max(0f, distance) * 0.18f);
		}

		public static bool SupportedFootprint(float[] heights, float[] normals, float minimumNormal, float maximumSpread)
		{
			if (heights == null || normals == null || heights.Length < 4 || heights.Length != normals.Length)
			{
				return false;
			}
			float num = float.PositiveInfinity;
			float num2 = float.NegativeInfinity;
			for (int i = 0; i < heights.Length; i++)
			{
				if (!Finite(heights[i]) || !Finite(normals[i]) || normals[i] < minimumNormal)
				{
					return false;
				}
				num = Math.Min(num, heights[i]);
				num2 = Math.Max(num2, heights[i]);
			}
			return num2 - num <= maximumSpread;
		}

		public static void MapPoint(float u, float v, float centerX, float centerZ, float halfExtent, out float x, out float z)
		{
			x = centerX + (u - 0.5f) * halfExtent * 2f;
			z = centerZ + (v - 0.5f) * halfExtent * 2f;
		}

		public static void TerrainNormal(float frontLeft, float frontRight, float rearLeft, float rearRight, float width, float length, out float x, out float y, out float z)
		{
			if (width <= 0f || length <= 0f)
			{
				throw new ArgumentOutOfRangeException("width");
			}
			x = (0f - (frontRight + rearRight - frontLeft - rearLeft)) / (2f * width);
			y = 1f;
			z = (0f - (frontLeft + frontRight - rearLeft - rearRight)) / (2f * length);
			float num = (float)Math.Sqrt(x * x + y * y + z * z);
			x /= num;
			y /= num;
			z /= num;
		}

		public static void RadarPoint(float dx, float dz, float headingDegrees, float range, float pixelRadius, out float x, out float y)
		{
			if (range <= 0f || pixelRadius <= 0f)
			{
				throw new ArgumentOutOfRangeException("range");
			}
			double num = (double)headingDegrees * Math.PI / 180.0;
			x = (float)(((double)dx * Math.Cos(num) - (double)dz * Math.Sin(num)) * (double)pixelRadius / (double)range);
			y = (float)(((double)dx * Math.Sin(num) + (double)dz * Math.Cos(num)) * (double)pixelRadius / (double)range);
		}

		public static bool TreadPlane(float[] xs, float[] ys, float[] zs, out float height, out float slopeX, out float slopeZ)
		{
			height = (slopeX = (slopeZ = 0f));
			if (xs == null || ys == null || zs == null || xs.Length != ys.Length || xs.Length != zs.Length)
			{
				return false;
			}
			int num = 0;
			int num2 = 0;
			int num3 = 0;
			double num4 = 0.0;
			double num5 = 0.0;
			double num6 = 0.0;
			for (int i = 0; i < ys.Length; i++)
			{
				if (Finite(ys[i]))
				{
					num++;
					num4 += (double)xs[i];
					num5 += (double)ys[i];
					num6 += (double)zs[i];
					if (xs[i] < 0f)
					{
						num2++;
					}
					else
					{
						num3++;
					}
				}
			}
			if (num < 4 || num2 < 2 || num3 < 2)
			{
				return false;
			}
			num4 /= (double)num;
			num5 /= (double)num;
			num6 /= (double)num;
			double num7 = 0.0;
			double num8 = 0.0;
			double num9 = 0.0;
			double num10 = 0.0;
			double num11 = 0.0;
			for (int j = 0; j < ys.Length; j++)
			{
				if (Finite(ys[j]))
				{
					double num12 = (double)xs[j] - num4;
					double num13 = (double)zs[j] - num6;
					double num14 = (double)ys[j] - num5;
					num7 += num12 * num12;
					num8 += num13 * num13;
					num9 += num12 * num13;
					num10 += num12 * num14;
					num11 += num13 * num14;
				}
			}
			double num15 = num7 * num8 - num9 * num9;
			if (num15 < 0.0001)
			{
				return false;
			}
			slopeX = (float)((num10 * num8 - num11 * num9) / num15);
			slopeZ = (float)((num11 * num7 - num10 * num9) / num15);
			height = (float)(num5 - (double)slopeX * num4 - (double)slopeZ * num6);
			return Finite(height) && Finite(slopeX) && Finite(slopeZ);
		}

		public static void ZoomMap(float u, float v, float half, float scroll, float minimum, float maximum, out float next, out float dx, out float dz)
		{
			minimum = Math.Min(minimum, maximum);
			next = Math.Max(minimum, Math.Min(maximum, half * (float)Math.Exp(scroll * 0.12f)));
			dx = (u * 2f - 1f) * (half - next);
			dz = (v * 2f - 1f) * (half - next);
		}

		public static bool RoundDue(float elapsed, int fired, int count, float spacing)
		{
			return fired >= 0 && fired < count && elapsed + 0.0001f >= (float)fired * Math.Max(0f, spacing);
		}

		public static bool TreadSupport(float[] xs, float[] ys, float[] zs, float maximumSlope, out float height, out float slopeX, out float slopeZ)
		{
			height = (slopeX = (slopeZ = 0f));
			if (!TreadPlane(xs, ys, zs, out var height2, out var slopeX2, out var slopeZ2))
			{
				return false;
			}
			float num = float.PositiveInfinity;
			float num2 = float.NegativeInfinity;
			for (int i = 0; i < ys.Length; i++)
			{
				if (Finite(ys[i]))
				{
					num = Math.Min(num, zs[i]);
					num2 = Math.Max(num2, zs[i]);
				}
			}
			if (num > 0.5f || num2 < -0.5f)
			{
				return false;
			}
			float num3 = float.PositiveInfinity;
			for (int j = 0; j < ys.Length - 2; j++)
			{
				if (!Finite(ys[j]))
				{
					continue;
				}
				for (int k = j + 1; k < ys.Length - 1; k++)
				{
					if (!Finite(ys[k]))
					{
						continue;
					}
					for (int l = k + 1; l < ys.Length; l++)
					{
						if (!Finite(ys[l]))
						{
							continue;
						}
						float num4 = xs[k] - xs[j];
						float num5 = zs[k] - zs[j];
						float num6 = xs[l] - xs[j];
						float num7 = zs[l] - zs[j];
						float num8 = num4 * num7 - num6 * num5;
						if (Math.Abs(num8) < 0.0001f)
						{
							continue;
						}
						float num9 = ((ys[k] - ys[j]) * num7 - (ys[l] - ys[j]) * num5) / num8;
						float num10 = (num4 * (ys[l] - ys[j]) - num6 * (ys[k] - ys[j])) / num8;
						if (num9 * num9 + num10 * num10 > maximumSlope * maximumSlope + 0.0001f)
						{
							continue;
						}
						float num11 = ys[j] - num9 * xs[j] - num10 * zs[j];
						if (num11 >= num3)
						{
							continue;
						}
						bool flag = true;
						for (int m = 0; m < ys.Length; m++)
						{
							if (Finite(ys[m]) && num11 + num9 * xs[m] + num10 * zs[m] < ys[m] - 0.002f)
							{
								flag = false;
								break;
							}
						}
						if (flag)
						{
							num3 = num11;
							slopeX = num9;
							slopeZ = num10;
						}
					}
				}
			}
			if (Finite(num3))
			{
				height = num3;
				return true;
			}
			float num12 = (float)Math.Sqrt(slopeX2 * slopeX2 + slopeZ2 * slopeZ2);
			float num13 = ((num12 > maximumSlope) ? (maximumSlope / num12) : 1f);
			slopeX = slopeX2 * num13;
			slopeZ = slopeZ2 * num13;
			height = TreadClearance(xs, ys, zs, slopeX, slopeZ, height2);
			return Finite(height);
		}

		public static float TreadClearance(float[] xs, float[] ys, float[] zs, float slopeX, float slopeZ, float fallback)
		{
			float num = float.NegativeInfinity;
			for (int i = 0; i < ys.Length; i++)
			{
				if (Finite(ys[i]))
				{
					num = Math.Max(num, ys[i] - slopeX * xs[i] - slopeZ * zs[i]);
				}
			}
			return Finite(num) ? num : fallback;
		}

		public static float Smooth(float t)
		{
			t = Math.Max(0f, Math.Min(1f, t));
			return t * t * (3f - 2f * t);
		}

		public static void EngineGains(float warmup, float speedBlend, out float tone, out float churn, out float drive)
		{
			float num = Smooth(warmup);
			float num2 = Smooth(speedBlend);
			tone = (1f - 0.65f * num) * (1f - num2);
			churn = 0.65f * num * (1f - 0.65f * num2);
			drive = num2;
		}
	}
	public sealed class MegaronStormVisual : MonoBehaviour
	{
		private Transform[] tips;

		private MeshRenderer[] cores;

		private ParticleSystem[] sparks;

		private LineRenderer[] bridges;

		private Mesh chargeMesh;

		private float age;

		private float duration;

		public void Begin(Transform[] anchors, float seconds, Material energy, Material cloud)
		{
			//IL_0189: 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)
			tips = anchors;
			duration = seconds;
			cores = (MeshRenderer[])(object)new MeshRenderer[3];
			sparks = (ParticleSystem[])(object)new ParticleSystem[3];
			bridges = (LineRenderer[])(object)new LineRenderer[3];
			for (int i = 0; i < 3; i++)
			{
				GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
				Collider component = val.GetComponent<Collider>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.enabled = false;
					Object.Destroy((Object)(object)component);
				}
				MeshFilter component2 = val.GetComponent<MeshFilter>();
				if (!Object.op_Implicit((Object)(object)chargeMesh))
				{
					chargeMesh = Object.Instantiate<Mesh>(component2.sharedMesh);
					((Object)chargeMesh).name = "Megaron white vertex charge sphere";
					Color[] array = (Color[])(object)new Color[chargeMesh.vertexCount];
					for (int j = 0; j < array.Length; j++)
					{
						array[j] = Color.white;
					}
					chargeMesh.colors = array;
				}
				component2.sharedMesh = chargeMesh;
				val.transform.SetParent(((Component)this).transform, false);
				cores[i] = val.GetComponent<MeshRenderer>();
				((Renderer)cores[i]).sharedMaterial = energy;
				((Renderer)cores[i]).shadowCastingMode = (ShadowCastingMode)0;
				sparks[i] = StormParticles.Create(((Component)this).transform, "Red spike charge", cloud, 2f, 1f, 50f, burst: false);
				bridges[i] = StormParticles.Line(((Component)this).transform, energy, 0.08f, new Color(1f, 0.035f, 0.1f, 1f));
				bridges[i].positionCount = 13;
			}
			UpdateGeometry(0f);
		}

		private void Update()
		{
			age += Time.deltaTime;
			if (tips == null || age > duration + 0.5f)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
			else
			{
				UpdateGeometry(Mathf.Clamp01(age / duration));
			}
		}

		private void OnDestroy()
		{
			if (Object.op_Implicit((Object)(object)chargeMesh))
			{
				Object.Destroy((Object)(object)chargeMesh);
			}
		}

		private void UpdateGeometry(float progress)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: 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_0072: 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_00b9: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_019c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: 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)
			for (int i = 0; i < 3; i++)
			{
				if (!Object.op_Implicit((Object)(object)tips[i]))
				{
					Object.Destroy((Object)(object)((Component)this).gameObject);
					break;
				}
				Vector3 position = tips[i].position;
				((Component)cores[i]).transform.position = position;
				((Component)cores[i]).transform.localScale = Vector3.one * (0.3f + progress * 1.6f) * (1f + 0.12f * Mathf.Sin(age * 43f + (float)i));
				StormParticles.Tint((Renderer)(object)cores[i], Color.Lerp(new Color(1f, 0f, 0.025f), new Color(1f, 0.7f, 0.8f), progress * progress));
				((Component)sparks[i]).transform.position = position;
				ShapeModule shape = sparks[i].shape;
				((ShapeModule)(ref shape)).radius = 0.25f + progress * 0.9f;
				EmissionModule emission = sparks[i].emission;
				((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(12f + progress * 75f);
				Vector3 position2 = tips[(i + 1) % 3].position;
				((Renderer)bridges[i]).enabled = progress > 0.2f;
				for (int j = 0; j < 13; j++)
				{
					float num = (float)j / 12f;
					Vector3 val = Vector3.Lerp(position, position2, num);
					if (j > 0 && j < 12)
					{
						val += new Vector3(Mathf.Sin((float)(j * 13) + age * 64f), Mathf.Sin((float)(j * 7) + age * 51f), Mathf.Cos((float)(j * 17) + age * 57f)) * (0.1f + 0.45f * progress);
					}
					bridges[i].SetPosition(j, val);
				}
				bridges[i].widthMultiplier = 0.06f + 0.16f * progress;
			}
		}
	}
	public sealed class MegaronStormBolt : MonoBehaviour
	{
		private LineRenderer[] cores;

		private LineRenderer[] halos;

		private Vector3 from;

		private Vector3 to;

		private float age;

		private float flight = 0.65f;

		private float flare = 8f;

		private float radius;

		private float pulseRate = 30f;

		private uint seed;

		private bool ended;

		private bool automaticImpact;

		private Material cloud;

		private float[] intensityPulses;

		private Func<Vector3> sourcePosition;

		private Func<Vector3> targetPosition;

		private static readonly float[] DefaultPulses = new float[9] { 1f, 0.7f, 1f, 1.22f, 1.34f, 0.44f, 1.1f, 1.05f, 1.35f };

		public void Begin(Vector3 origin, Vector3 target, uint variation, float blastRadius, Material energy, Material particles)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			BeginFlight(origin, target, variation, blastRadius, energy, particles, 0.65f, 8f);
			automaticImpact = true;
		}

		public void BeginFlight(Vector3 origin, Vector3 target, uint variation, float blastRadius, Material energy, Material particles, float seconds, float spread, float mainWidth = 2.2f, int branchCount = 4, float flashesPerSecond = 30f, float[] pulses = null, Material haloMaterial = null)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_0179: Unknown result type (might be due to invalid IL or missing references)
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Expected O, but got Unknown
			from = origin;
			to = target;
			seed = variation;
			radius = blastRadius;
			cloud = particles;
			flight = seconds;
			flare = spread;
			pulseRate = flashesPerSecond;
			intensityPulses = ((pulses != null && pulses.Length != 0) ? pulses : DefaultPulses);
			int num = Mathf.Clamp(branchCount, 1, 8) + 1;
			cores = (LineRenderer[])(object)new LineRenderer[num];
			halos = (LineRenderer[])(object)new LineRenderer[num];
			for (int i = 0; i < num; i++)
			{
				float num2 = mainWidth * ((i == 0) ? 1f : (0.4f + 0.2f * MegaronRules.LightningHash(seed, i)));
				cores[i] = StormParticles.Line(((Component)this).transform, energy, num2, Color.white);
				halos[i] = StormParticles.Line(((Component)this).transform, Object.op_Implicit((Object)(object)haloMaterial) ? haloMaterial : energy, num2 * 1.75f, new Color(0.69f, 0.43f, 1f, 0.52f));
				LineRenderer obj = cores[i];
				int positionCount = (halos[i].positionCount = ((i == 0) ? 25 : 13));
				obj.positionCount = positionCount;
				if (i > 0)
				{
					AnimationCurve val = new AnimationCurve((Keyframe[])(object)new Keyframe[3]
					{
						new Keyframe(0f, 0.03f),
						new Keyframe(0.18f, 0.55f),
						new Keyframe(1f, 1.25f)
					});
					LineRenderer obj2 = cores[i];
					AnimationCurve widthCurve = (halos[i].widthCurve = val);
					obj2.widthCurve = widthCurve;
					cores[i].widthMultiplier = num2;
					halos[i].widthMultiplier = num2 * 1.75f;
				}
			}
			UpdateBolt();
		}

		public void Follow(Func<Vector3> source, Func<Vector3> target)
		{
			sourcePosition = source;
			targetPosition = target;
		}

		public void Cancel()
		{
			if (!ended)
			{
				ended = true;
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}

		private void Update()
		{
			//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_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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			if (!ended)
			{
				age += Time.deltaTime;
				if (sourcePosition != null)
				{
					from = sourcePosition();
				}
				if (targetPosition != null)
				{
					to = targetPosition();
				}
				if (automaticImpact && age >= flight)
				{
					new GameObject("Storm impact").AddComponent<MegaronStormImpact>().Begin(to, radius, cloud);
					Cancel();
				}
				else if (age > flight + 1f)
				{
					Cancel();
				}
				else
				{
					UpdateBolt();
				}
			}
		}

		private void UpdateBolt()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: 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_0052: 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_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: 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_017c: 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_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: 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_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: 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_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: 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_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_023a: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0278: Unknown result type (might be due to invalid IL or missing references)
			//IL_027d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = to - from;
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			val = Vector3.Cross(normalized, Vector3.up);
			Vector3 val2 = ((Vector3)(ref val)).normalized;
			if (((Vector3)(ref val2)).sqrMagnitude < 0.01f)
			{
				val2 = Vector3.right;
			}
			val = Vector3.Cross(val2, normalized);
			Vector3 normalized2 = ((Vector3)(ref val)).normalized;
			float num = Vector3.Distance(from, to);
			float num2 = MegaronRules.StormReach(age, flight);
			float num3 = Mathf.Min(1.5f, num * 0.025f);
			int num4 = Mathf.FloorToInt(age * pulseRate);
			float num5 = (((seed & 1) == 0) ? 1 : (-1));
			float num6 = intensityPulses[num4 % intensityPulses.Length];
			for (int i = 0; i < cores.Length; i++)
			{
				bool flag = num4 % 9 != 5 || i < 2;
				LineRenderer obj = cores[i];
				bool enabled = (((Renderer)halos[i]).enabled = flag);
				((Renderer)obj).enabled = enabled;
				float num7 = MegaronRules.LightningHash(seed, i * 19 + 1 + num4 * 307) * MathF.PI * 2f;
				for (int j = 0; j < cores[i].positionCount; j++)
				{
					float num8 = (float)j / (float)(cores[i].positionCount - 1) * num2;
					float num9 = MegaronRules.StormFlare(num8, num, flare);
					Vector3 val3 = Vector3.Lerp(from, to, num8) + val2 * (num9 * num5) + Vector3.up * (num9 * 0.4f);
					if (i > 0)
					{
						val3 += (val2 * Mathf.Cos(num7) + normalized2 * Mathf.Sin(num7)) * num9 * (0.35f + (float)i * 0.12f);
					}
					if (j > 0 && j < cores[i].positionCount - 1)
					{
						val3 += (val2 * (MegaronRules.LightningHash(seed, num4 * 137 + i * 21 + j) - 0.5f) + normalized2 * (MegaronRules.LightningHash(seed, num4 * 233 + i * 23 + j) - 0.5f)) * num3 * 2f;
					}
					cores[i].SetPosition(j, val3);
					halos[i].SetPosition(j, val3);
				}
				StormParticles.Tint((Renderer)(object)cores[i], new Color(num6 * 1.5f, num6 * 1.5f, num6 * 1.5f, 1f));
				StormParticles.Tint((Renderer)(object)halos[i], new Color(0.9f, 0.73f, 1f, Mathf.Clamp01(num6 * 0.55f)));
			}
		}
	}
	public sealed class MegaronStormImpact : MonoBehaviour
	{
		private float age;

		public void Begin(Vector3 point, float radius, Material cloud)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).transform.position = point;
			ParticleSystem val = StormParticles.Create(((Component)this).transform, "Massive white red detonation", cloud, radius * 0.23f, 0.6f, 0f, burst: true);
			MainModule main = val.main;
			((MainModule)(ref main)).startSpeed = new MinMaxCurve(radius * 0.8f, radius * 2.1f);
			((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.45f, 1.75f);
			((MainModule)(ref main)).startSize = new MinMaxCurve(radius * 0.3f, radius * 0.75f);
			val.Emit(64);
		}

		private void Update()
		{
			age += Time.deltaTime;
			if (age > 2.4f)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
	public static class StormParticles
	{
		public static LineRenderer Line(Transform parent, Material material, float width, Color color)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			LineRenderer val = new GameObject("Storm lightning").AddComponent<LineRenderer>();
			((Component)val).transform.SetParent(parent, false);
			((Renderer)val).sharedMaterial = material;
			float startWidth = (val.endWidth = width);
			val.startWidth = startWidth;
			Color startColor = (val.endColor = color);
			val.startColor = startColor;
			((Renderer)val).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)val).receiveShadows = false;
			val.useWorldSpace = true;
			val.numCapVertices = 2;
			return val;
		}

		public static void Tint(Renderer renderer, Color color)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_000d: 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_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			MaterialPropertyBlock val = new MaterialPropertyBlock();
			val.SetColor("_Color", color);
			val.SetColor("_TintColor", color);
			val.SetColor("_EmColor", color);
			val.SetColor("_EmissionColor", color);
			renderer.SetPropertyBlock(val);
		}

		public static ParticleSystem Create(Transform parent, string name, Material material, float size, float lifetime, float rate, bool burst)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: 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_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_0137: Expected O, but got Unknown
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: 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_01b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0226: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_0252: 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_025c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0266: Expected O, but got Unknown
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject(name);
			val.SetActive(false);
			val.transform.SetParent(parent, false);
			ParticleSystem val2 = val.AddComponent<ParticleSystem>();
			val2.Stop(true, (ParticleSystemStopBehavior)0);
			MainModule main = val2.main;
			((MainModule)(ref main)).playOnAwake = false;
			((MainModule)(ref main)).loop = !burst;
			((MainModule)(ref main)).duration = 3f;
			((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
			((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(lifetime);
			((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(size);
			((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(burst ? 8f : 1.5f);
			((MainModule)(ref main)).maxParticles = 256;
			((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit((Color)(burst ? Color.white : new Color(1f, 0.6f, 0.7f, 0.85f)));
			((MainModule)(ref main)).cullingMode = (ParticleSystemCullingMode)3;
			EmissionModule emission = val2.emission;
			((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(rate);
			ShapeModule shape = val2.shape;
			((ShapeModule)(ref shape)).enabled = true;
			((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
			((ShapeModule)(ref shape)).radius = 0.2f;
			ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime;
			((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
			Gradient val3 = new Gradient();
			val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[3]
			{
				new GradientColorKey(Color.white, 0f),
				new GradientColorKey(new Color(1f, 0.05f, 0.1f), 0.55f),
				new GradientColorKey(new Color(0.17f, 0.1f, 0.15f), 1f)
			}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
			{
				new GradientAlphaKey(0.95f, 0f),
				new GradientAlphaKey(0.7f, 0.35f),
				new GradientAlphaKey(0f, 1f)
			});
			((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val3);
			SizeOverLifetimeModule sizeOverLifetime = val2.sizeOverLifetime;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
			((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, new AnimationCurve((Keyframe[])(object)new Keyframe[3]
			{
				new Keyframe(0f, 0.25f),
				new Keyframe(0.2f, 1f),
				new Keyframe(1f, 1.7f)
			}));
			ParticleSystemRenderer component = ((Component)val2).GetComponent<ParticleSystemRenderer>();
			((Renderer)component).sharedMaterial = material;
			component.renderMode = (ParticleSystemRenderMode)0;
			((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
			val.SetActive(true);
			val2.Play();
			return val2;
		}
	}
}
namespace Megaron.RoR2Mod.Runtime1310
{
	internal enum MegaronPlacementCode : byte
	{
		Fits,
		NoGround,
		TooSteep,
		Unsupported,
		Blocked,
		OutOfRange,
		TooClose,
		InvalidPoint
	}
	internal struct MegaronPlacement
	{
		internal MegaronPlacementCode Code;

		internal Vector3 Position;

		internal Vector3 Surface;

		internal Quaternion Rotation;

		internal bool HasGround;

		internal bool Fits => Code == MegaronPlacementCode.Fits;

		internal string Message => Code switch
		{
			MegaronPlacementCode.Fits => "READY — grounded landing; hull and track overhang allowed", 
			MegaronPlacementCode.NoGround => "BLOCKED — no solid ground", 
			MegaronPlacementCode.TooSteep => "BLOCKED — ground too steep", 
			MegaronPlacementCode.Unsupported => "BLOCKED — no landing surface", 
			MegaronPlacementCode.Blocked => "BLOCKED — the movement capsule cannot fit here", 
			MegaronPlacementCode.OutOfRange => "BLOCKED — outside teleport range", 
			MegaronPlacementCode.TooClose => "BLOCKED — destination too close", 
			_ => "BLOCKED — invalid destination", 
		};
	}
	internal static class MegaronTeleportPlacement
	{
		internal const int Columns = 3;

		internal const int Rows = 3;

		internal const float Headroom = 2f;

		internal const float Margin = 0.15f;

		private static readonly RaycastHit[] GroundHits = (RaycastHit[])(object)new RaycastHit[48];

		internal static int GroundMask(CharacterBody owner)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			int num = LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask) | LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.defaultLayer)).mask);
			if (Object.op_Implicit((Object)(object)owner) && Object.op_Implicit((Object)(object)owner.characterMotor) && MegaronApi.Get(((BaseCharacterController)owner.characterMotor).Motor, "CollidableLayers") is LayerMask val)
			{
				num |= ((LayerMask)(ref val)).value;
			}
			return num;
		}

		private static bool LandingCollider(Collider collider, CharacterBody owner)
		{
			return Object.op_Implicit((Object)(object)collider) && !OwnCollider(collider, owner) && !Object.op_Implicit((Object)(object)((Component)collider).GetComponentInParent<CharacterBody>());
		}

		internal static bool OwnCollider(Collider collider, Charact