Decompiled source of Plasma v0.3.0

BepInEx/plugins/HR-Plasma/HR.Plasma.dll

Decompiled 15 hours 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 BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.SurvivorPod;
using HG.Reflection;
using KinematicCharacterController;
using MonoMod.RuntimeDetour;
using R2API;
using RoR2;
using RoR2.CharacterAI;
using RoR2.ContentManagement;
using RoR2.Projectile;
using RoR2.Skills;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.ResourceManagement.AsyncOperations;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: AssemblyVersion("0.0.0.0")]
namespace HR.Plasma;

internal static class PlasmaAbilityVisuals
{
	private static Mesh sphere;

	private static Material core;

	private static Material particles;

	internal static Material Material => PrismaticSweep.SurfaceMaterial();

	internal static Material Core
	{
		get
		{
			//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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)core))
			{
				core = new Material(Material)
				{
					name = "PlasmaEnergyCore",
					mainTexture = (Texture)(object)Texture2D.whiteTexture
				};
				core.SetColor("_TintColor", new Color(0.85f, 0.96f, 1f, 1f));
			}
			return core;
		}
	}

	internal static Transform Muzzle(CharacterBody body)
	{
		ModelLocator val = (Object.op_Implicit((Object)(object)body) ? ((Component)body).GetComponent<ModelLocator>() : null);
		ChildLocator val2 = ((Object.op_Implicit((Object)(object)val) && Object.op_Implicit((Object)(object)val.modelTransform)) ? ((Component)val.modelTransform).GetComponent<ChildLocator>() : null);
		if (!Object.op_Implicit((Object)(object)val2))
		{
			return null;
		}
		return val2.FindChild("PlasmaMuzzle");
	}

	internal static LineRenderer Line(Transform parent, string name, float width, bool white = false)
	{
		//IL_0001: Unknown result type (might be due to invalid IL or missing references)
		//IL_0006: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject(name);
		val.transform.SetParent(parent, false);
		LineRenderer obj = val.AddComponent<LineRenderer>();
		((Renderer)obj).sharedMaterial = (white ? Core : Material);
		obj.useWorldSpace = true;
		obj.alignment = (LineAlignment)0;
		obj.widthMultiplier = width;
		obj.numCapVertices = 3;
		obj.numCornerVertices = 2;
		((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
		((Renderer)obj).receiveShadows = false;
		return obj;
	}

	internal static void Fade(Renderer renderer, float alpha, MaterialPropertyBlock block)
	{
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		block.SetFloat("_ExternalAlpha", alpha);
		block.SetFloat("_Fade", alpha);
		block.SetColor("_TintColor", new Color(1f, 1f, 1f, alpha));
		renderer.SetPropertyBlock(block);
	}

	internal static Transform Orb(Transform parent, string name)
	{
		//IL_016b: 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_017d: Unknown result type (might be due to invalid IL or missing references)
		//IL_018d: Unknown result type (might be due to invalid IL or missing references)
		//IL_012c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0131: Unknown result type (might be due to invalid IL or missing references)
		//IL_013c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0156: Expected O, but got Unknown
		//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_00b3: 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)
		if (!Object.op_Implicit((Object)(object)sphere))
		{
			Vector3[] array = (Vector3[])(object)new Vector3[325];
			Vector2[] array2 = (Vector2[])(object)new Vector2[array.Length];
			int[] array3 = new int[1728];
			int num = 0;
			for (int i = 0; i <= 12; i++)
			{
				for (int j = 0; j <= 24; j++)
				{
					float num2 = (float)j / 24f;
					float num3 = (float)i / 12f;
					float num4 = num2 * (float)Math.PI * 2f;
					float num5 = num3 * (float)Math.PI;
					int num6 = i * 25 + j;
					array[num6] = new Vector3(Mathf.Sin(num5) * Mathf.Cos(num4), Mathf.Cos(num5), Mathf.Sin(num5) * Mathf.Sin(num4));
					array2[num6] = new Vector2(num2, num3);
					if (i != 12 && j != 24)
					{
						int num7 = num6 + 24 + 1;
						array3[num++] = num6;
						array3[num++] = num7;
						array3[num++] = num7 + 1;
						array3[num++] = num6;
						array3[num++] = num7 + 1;
						array3[num++] = num6 + 1;
					}
				}
			}
			sphere = new Mesh
			{
				name = "PlasmaEnergySphere",
				vertices = array,
				uv = array2,
				triangles = array3
			};
			sphere.RecalculateNormals();
			sphere.RecalculateBounds();
		}
		GameObject val = new GameObject(name);
		val.transform.SetParent(parent, false);
		val.AddComponent<MeshFilter>().sharedMesh = sphere;
		MeshRenderer obj = val.AddComponent<MeshRenderer>();
		((Renderer)obj).sharedMaterial = Material;
		((Renderer)obj).shadowCastingMode = (ShadowCastingMode)0;
		((Renderer)obj).receiveShadows = false;
		return val.transform;
	}

	internal static void Sparks(Transform parent, float rate)
	{
		//IL_004e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0074: Unknown result type (might be due to invalid IL or missing references)
		//IL_0085: Unknown result type (might be due to invalid IL or missing references)
		//IL_0096: 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_00c3: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0119: Unknown result type (might be due to invalid IL or missing references)
		//IL_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0128: Unknown result type (might be due to invalid IL or missing references)
		//IL_012f: Expected O, but got Unknown
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_0143: Unknown result type (might be due to invalid IL or missing references)
		//IL_0148: Unknown result type (might be due to invalid IL or missing references)
		//IL_014f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0159: Unknown result type (might be due to invalid IL or missing references)
		//IL_015e: 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_017a: 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_0190: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0026: Expected O, but got Unknown
		if (!Object.op_Implicit((Object)(object)particles))
		{
			particles = new Material(Material)
			{
				name = "PlasmaRisingSparks"
			};
			particles.SetFloat("_VertexAlphaOn", 1f);
			particles.EnableKeyword("VERTEXALPHA");
		}
		GameObject val = new GameObject("Rising prismatic sparks");
		val.transform.SetParent(parent, false);
		ParticleSystem val2 = val.AddComponent<ParticleSystem>();
		MainModule main = val2.main;
		((MainModule)(ref main)).startLifetime = MinMaxCurve.op_Implicit(0.65f);
		((MainModule)(ref main)).startSize = MinMaxCurve.op_Implicit(0.055f);
		((MainModule)(ref main)).startSpeed = MinMaxCurve.op_Implicit(1.6f);
		((MainModule)(ref main)).maxParticles = 40;
		((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
		((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-0.08f);
		EmissionModule emission = val2.emission;
		((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(rate);
		ShapeModule shape = val2.shape;
		((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)4;
		((ShapeModule)(ref shape)).angle = 8f;
		((ShapeModule)(ref shape)).radius = 0.55f;
		((ShapeModule)(ref shape)).rotation = new Vector3(-90f, 0f, 0f);
		ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime;
		((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
		Gradient val3 = new Gradient();
		val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
		{
			new GradientColorKey(Color.white, 0f),
			new GradientColorKey(Color.white, 1f)
		}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
		{
			new GradientAlphaKey(0f, 0f),
			new GradientAlphaKey(0.8f, 0.15f),
			new GradientAlphaKey(0f, 1f)
		});
		((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val3);
		ParticleSystemRenderer component = ((Component)val2).GetComponent<ParticleSystemRenderer>();
		((Renderer)component).sharedMaterial = particles;
		((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
		((Renderer)component).receiveShadows = false;
		val2.Play();
	}

	internal static void Beam(CharacterBody body, Ray aim)
	{
		//IL_0017: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_002a: Unknown result type (might be due to invalid IL or missing references)
		//IL_002d: Unknown result type (might be due to invalid IL or missing references)
		//IL_004c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_005d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0041: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)body) && NetworkClient.active)
		{
			Vector3 point = ((Ray)(ref aim)).GetPoint(180f);
			Ray val = aim;
			LayerIndex world = LayerIndex.world;
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(val, ref val2, 180f, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)1))
			{
				point = ((RaycastHit)(ref val2)).point;
			}
			new GameObject("Plasma piercing beam").AddComponent<PlasmaBeamFlash>().Initialize(((Ray)(ref aim)).origin, point, 0.45f + 0.2f * OutputController.Power(body));
		}
	}
}
public sealed class PlasmaChargeOrb : MonoBehaviour
{
	private CharacterBody body;

	private Transform anchor;

	private Transform orb;

	private float age;

	private float duration;

	public static PlasmaChargeOrb Spawn(CharacterBody body, float duration)
	{
		//IL_0016: Unknown result type (might be due to invalid IL or missing references)
		//IL_001c: Expected O, but got Unknown
		if (!Object.op_Implicit((Object)(object)body) || !NetworkClient.active)
		{
			return null;
		}
		GameObject val = new GameObject("Plasma palm charge");
		PlasmaChargeOrb plasmaChargeOrb = val.AddComponent<PlasmaChargeOrb>();
		plasmaChargeOrb.body = body;
		plasmaChargeOrb.duration = Mathf.Max(0.04f, duration);
		plasmaChargeOrb.anchor = PlasmaAbilityVisuals.Muzzle(body);
		plasmaChargeOrb.orb = PlasmaAbilityVisuals.Orb(val.transform, "Pearl charge");
		return plasmaChargeOrb;
	}

	private void LateUpdate()
	{
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_007f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0099: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)body))
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
			return;
		}
		age += Time.deltaTime;
		if (age > duration + 0.5f)
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
			return;
		}
		Vector3 val = (Object.op_Implicit((Object)(object)body.inputBank) ? body.inputBank.aimDirection : ((Component)body).transform.forward);
		((Component)this).transform.position = (Object.op_Implicit((Object)(object)anchor) ? anchor.position : body.corePosition) + val * 0.12f;
		float num = Mathf.Lerp(0.025f, 0.15f, Mathf.SmoothStep(0f, 1f, age / duration));
		orb.localScale = Vector3.one * num;
		orb.Rotate(0f, Time.deltaTime * 100f, Time.deltaTime * 40f);
	}
}
public sealed class PlasmaBeamFlash : MonoBehaviour
{
	private LineRenderer outer;

	private LineRenderer core;

	private Transform tip;

	private float age;

	private float width;

	private readonly MaterialPropertyBlock block = new MaterialPropertyBlock();

	internal void Initialize(Vector3 start, Vector3 end, float size)
	{
		//IL_0070: Unknown result type (might be due to invalid IL or missing references)
		//IL_0077: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		width = size;
		outer = PlasmaAbilityVisuals.Line(((Component)this).transform, "Prismatic beam", width);
		core = PlasmaAbilityVisuals.Line(((Component)this).transform, "White core", width * 0.22f, white: true);
		LineRenderer[] array = (LineRenderer[])(object)new LineRenderer[2] { outer, core };
		foreach (LineRenderer obj in array)
		{
			obj.positionCount = 2;
			obj.SetPosition(0, start);
			obj.SetPosition(1, end);
		}
		tip = PlasmaAbilityVisuals.Orb(((Component)this).transform, "Impact flash");
		tip.position = end;
		tip.localScale = Vector3.one * 0.18f;
	}

	private void Update()
	{
		//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
		age += Time.deltaTime;
		float num = age / 0.26f;
		if (num >= 1f)
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
			return;
		}
		float alpha = 1f - Mathf.SmoothStep(0f, 1f, num);
		outer.widthMultiplier = width * Mathf.Lerp(1f, 0.2f, num);
		core.widthMultiplier = outer.widthMultiplier * 0.22f;
		PlasmaAbilityVisuals.Fade((Renderer)(object)outer, alpha, block);
		PlasmaAbilityVisuals.Fade((Renderer)(object)core, alpha, block);
		tip.localScale = Vector3.one * Mathf.Lerp(0.18f, 0.04f, num);
		PlasmaAbilityVisuals.Fade(((Component)tip).GetComponent<Renderer>(), alpha, block);
	}
}
public sealed class PlasmaDashWake : MonoBehaviour
{
	private CharacterBody body;

	private LineRenderer left;

	private LineRenderer right;

	private readonly Vector3[] history = (Vector3[])(object)new Vector3[10];

	private float age;

	private float sample;

	private float ghost;

	private int ghosts;

	private readonly MaterialPropertyBlock block = new MaterialPropertyBlock();

	public static void Spawn(CharacterBody body)
	{
		//IL_0015: Unknown result type (might be due to invalid IL or missing references)
		//IL_001b: Expected O, but got Unknown
		//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)body) && NetworkClient.active)
		{
			GameObject val = new GameObject("Plasma dash wake");
			PlasmaDashWake plasmaDashWake = val.AddComponent<PlasmaDashWake>();
			plasmaDashWake.body = body;
			plasmaDashWake.left = PlasmaAbilityVisuals.Line(val.transform, "Prism wake", 0.17f);
			plasmaDashWake.right = PlasmaAbilityVisuals.Line(val.transform, "Pearl wake", 0.11f, white: true);
			LineRenderer[] array = (LineRenderer[])(object)new LineRenderer[2] { plasmaDashWake.left, plasmaDashWake.right };
			for (int i = 0; i < array.Length; i++)
			{
				array[i].positionCount = plasmaDashWake.history.Length;
			}
			for (int j = 0; j < plasmaDashWake.history.Length; j++)
			{
				plasmaDashWake.history[j] = body.corePosition;
			}
		}
	}

	private void LateUpdate()
	{
		//IL_0125: 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_0147: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: 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_0165: 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_016b: Unknown result type (might be due to invalid IL or missing references)
		//IL_009f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)body))
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
			return;
		}
		age += Time.deltaTime;
		if (age > 0.46f)
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
			return;
		}
		sample -= Time.deltaTime;
		ghost -= Time.deltaTime;
		if (age < 0.27f && sample <= 0f)
		{
			for (int num = history.Length - 1; num > 0; num--)
			{
				history[num] = history[num - 1];
			}
			history[0] = body.corePosition;
			sample = 0.025f;
		}
		if (age < 0.24f && ghosts < 2 && ghost <= 0f)
		{
			PlasmaDashGhost.Capture(body);
			ghosts++;
			ghost = 0.12f;
		}
		Vector3 val = ((Component)body).transform.right * 0.25f;
		for (int i = 0; i < history.Length; i++)
		{
			left.SetPosition(i, history[i] + val);
			right.SetPosition(i, history[i] - val);
		}
		float alpha = 1f - Mathf.Clamp01((age - 0.24f) / 0.22f);
		PlasmaAbilityVisuals.Fade((Renderer)(object)left, alpha, block);
		PlasmaAbilityVisuals.Fade((Renderer)(object)right, alpha, block);
	}
}
public sealed class PlasmaDashGhost : MonoBehaviour
{
	private readonly List<Mesh> meshes = new List<Mesh>();

	private readonly List<Renderer> renderers = new List<Renderer>();

	private float age;

	private readonly MaterialPropertyBlock block = new MaterialPropertyBlock();

	internal static void Capture(CharacterBody body)
	{
		//IL_0005: Unknown result type (might be due to invalid IL or missing references)
		//IL_000b: Expected O, but got Unknown
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0089: Expected O, but got Unknown
		//IL_00a4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: 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_00d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_00df: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		GameObject val = new GameObject("Plasma dash afterimage");
		PlasmaDashGhost plasmaDashGhost = val.AddComponent<PlasmaDashGhost>();
		int num = 0;
		SkinnedMeshRenderer[] componentsInChildren = ((Component)body).GetComponentsInChildren<SkinnedMeshRenderer>();
		foreach (SkinnedMeshRenderer val2 in componentsInChildren)
		{
			if (((Renderer)val2).enabled && Object.op_Implicit((Object)(object)val2.sharedMesh) && (!(((Object)val2).name != "Model_Fur") || !(((Object)val2).name != "Model_Armor") || !(((Object)val2).name != "Body_Armor")))
			{
				Mesh val3 = new Mesh();
				val2.BakeMesh(val3);
				plasmaDashGhost.meshes.Add(val3);
				GameObject val4 = new GameObject("Ghost silhouette");
				val4.transform.SetParent(val.transform, false);
				val4.transform.position = ((Component)val2).transform.position;
				val4.transform.rotation = ((Component)val2).transform.rotation;
				val4.transform.localScale = ((Component)val2).transform.lossyScale;
				val4.AddComponent<MeshFilter>().sharedMesh = val3;
				MeshRenderer val5 = val4.AddComponent<MeshRenderer>();
				((Renderer)val5).sharedMaterial = PlasmaAbilityVisuals.Material;
				((Renderer)val5).shadowCastingMode = (ShadowCastingMode)0;
				((Renderer)val5).receiveShadows = false;
				plasmaDashGhost.renderers.Add((Renderer)(object)val5);
				if (++num >= 3)
				{
					break;
				}
			}
		}
		if (num == 0)
		{
			Object.Destroy((Object)(object)val);
		}
	}

	private void Update()
	{
		age += Time.deltaTime;
		if (age > 0.24f)
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
			return;
		}
		foreach (Renderer renderer in renderers)
		{
			PlasmaAbilityVisuals.Fade(renderer, 0.4f * (1f - age / 0.24f), block);
		}
	}

	private void OnDestroy()
	{
		foreach (Mesh mesh in meshes)
		{
			if (Object.op_Implicit((Object)(object)mesh))
			{
				Object.Destroy((Object)(object)mesh);
			}
		}
	}
}
[DefaultExecutionOrder(20040)]
public sealed class PlasmaOutputAura : MonoBehaviour
{
	private CharacterBody body;

	private Highlight outline;

	private readonly List<Renderer> sources = new List<Renderer>();

	private readonly List<Renderer> visible = new List<Renderer>();

	private float age;

	private float opacity;

	private bool stopping;

	public static PlasmaOutputAura Spawn(CharacterBody body)
	{
		//IL_0053: Unknown result type (might be due to invalid IL or missing references)
		//IL_0059: Expected O, but got Unknown
		//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)body) || !NetworkClient.active)
		{
			return null;
		}
		ModelLocator component = ((Component)body).GetComponent<ModelLocator>();
		PlasmaPose plasmaPose = ((Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.modelTransform)) ? ((Component)component.modelTransform).GetComponent<PlasmaPose>() : null);
		if (!Object.op_Implicit((Object)(object)plasmaPose) || plasmaPose.renderers == null)
		{
			return null;
		}
		GameObject val = new GameObject("Plasma Output aura");
		PlasmaOutputAura plasmaOutputAura = val.AddComponent<PlasmaOutputAura>();
		plasmaOutputAura.body = body;
		Renderer[] renderers = plasmaPose.renderers;
		foreach (Renderer val2 in renderers)
		{
			if (Object.op_Implicit((Object)(object)val2))
			{
				plasmaOutputAura.sources.Add(val2);
			}
		}
		if (plasmaOutputAura.sources.Count == 0)
		{
			Object.Destroy((Object)(object)val);
			return null;
		}
		plasmaOutputAura.outline = val.AddComponent<Highlight>();
		plasmaOutputAura.outline.useForPingHighlight = false;
		plasmaOutputAura.outline.highlightColor = (HighlightColor)3;
		plasmaOutputAura.outline.strength = 0f;
		plasmaOutputAura.outline.isOn = true;
		plasmaOutputAura.outline.SetTargetRendererList(plasmaOutputAura.sources);
		Plugin.Log.LogDebug((object)("Output aura follows " + plasmaOutputAura.sources.Count + " model renderers."));
		return plasmaOutputAura;
	}

	internal void Stop()
	{
		stopping = true;
	}

	private void LateUpdate()
	{
		//IL_0110: 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_0146: Unknown result type (might be due to invalid IL or missing references)
		//IL_014b: Unknown result type (might be due to invalid IL or missing references)
		//IL_014c: Unknown result type (might be due to invalid IL or missing references)
		//IL_014d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0157: Unknown result type (might be due to invalid IL or missing references)
		//IL_015c: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e6: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)outline))
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
			return;
		}
		age += Time.deltaTime;
		if (!body.HasBuff(Plugin.Release) || !Object.op_Implicit((Object)(object)body.healthComponent) || !body.healthComponent.alive || age > 8.5f)
		{
			stopping = true;
		}
		opacity = Mathf.MoveTowards(opacity, (float)((!stopping) ? 1 : 0), Time.deltaTime / 0.22f);
		if (stopping && opacity <= 0f)
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
			return;
		}
		float num = Mathf.Clamp01(OutputController.Power(body) / 1.25f);
		float num2 = 0.96f + 0.04f * Mathf.Sin(age * 2.4f);
		Color val = Color.Lerp(new Color(0.72f, 0.91f, 1f), new Color(1f, 0.8f, 0.94f), 0.5f + 0.5f * Mathf.Sin(age * 0.65f));
		val = Color.Lerp(val, Color.white, 0.48f);
		visible.Clear();
		foreach (Renderer source in sources)
		{
			if (Object.op_Implicit((Object)(object)source) && source.enabled && ((Component)source).gameObject.activeInHierarchy && !source.forceRenderingOff)
			{
				visible.Add(source);
			}
		}
		outline.SetTargetRendererList(visible);
		outline.CustomColor = val;
		outline.strength = opacity * num2 * (1f + 0.25f * num);
	}

	private void OnDisable()
	{
		if (Object.op_Implicit((Object)(object)outline))
		{
			outline.isOn = false;
		}
	}
}
public abstract class PlasmaArrivalState : BaseState
{
	private bool previousIgnoreFall;

	private float protectionTimer;

	public float Elapsed => ((EntityState)this).age;

	private void LockWeapon()
	{
		if (((EntityState)this).isAuthority)
		{
			EntityStateMachine val = EntityStateMachine.FindByCustomName(((EntityState)this).gameObject, "Weapon");
			if (Object.op_Implicit((Object)(object)val) && val.state != null && !(val.state is PlasmaArrivalWeaponLock))
			{
				val.SetInterruptState((EntityState)(object)new PlasmaArrivalWeaponLock(), (InterruptPriority)7);
			}
		}
	}

	public override void OnEnter()
	{
		//IL_001a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0022: Invalid comparison between Unknown and I4
		//IL_0030: Unknown result type (might be due to invalid IL or missing references)
		//IL_0036: Unknown result type (might be due to invalid IL or missing references)
		//IL_0037: Unknown result type (might be due to invalid IL or missing references)
		((BaseState)this).OnEnter();
		if (Object.op_Implicit((Object)(object)((EntityState)this).characterBody))
		{
			previousIgnoreFall = (((EntityState)this).characterBody.bodyFlags & 1) > 0;
			CharacterBody characterBody = ((EntityState)this).characterBody;
			characterBody.bodyFlags = (BodyFlags)(characterBody.bodyFlags | 1);
			CharacterBody characterBody2 = ((EntityState)this).characterBody;
			characterBody2.suspendEquipmentInputCount++;
			CharacterBody characterBody3 = ((EntityState)this).characterBody;
			characterBody3.suspendKeyItemInputCount++;
		}
		LockWeapon();
	}

	public override void FixedUpdate()
	{
		//IL_007a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008a: Unknown result type (might be due to invalid IL or missing references)
		//IL_008f: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_00af: Unknown result type (might be due to invalid IL or missing references)
		((EntityState)this).FixedUpdate();
		LockWeapon();
		protectionTimer -= Time.fixedDeltaTime;
		if (NetworkServer.active && Object.op_Implicit((Object)(object)((EntityState)this).characterBody) && protectionTimer <= 0f)
		{
			((EntityState)this).characterBody.AddTimedBuff(Buffs.HiddenInvincibility, 0.5f);
			protectionTimer = 0.4f;
		}
		if (((EntityState)this).isAuthority && Object.op_Implicit((Object)(object)((EntityState)this).characterMotor))
		{
			((EntityState)this).characterMotor.moveDirection = Vector3.zero;
			Vector3 velocity = ((EntityState)this).characterMotor.velocity;
			velocity.x = 0f;
			velocity.z = 0f;
			((EntityState)this).characterMotor.velocity = velocity;
		}
	}

	public override void OnExit()
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)((EntityState)this).characterBody))
		{
			if (!previousIgnoreFall)
			{
				CharacterBody characterBody = ((EntityState)this).characterBody;
				characterBody.bodyFlags = (BodyFlags)(characterBody.bodyFlags & -2);
			}
			CharacterBody characterBody2 = ((EntityState)this).characterBody;
			characterBody2.suspendEquipmentInputCount--;
			CharacterBody characterBody3 = ((EntityState)this).characterBody;
			characterBody3.suspendKeyItemInputCount--;
		}
		((EntityState)this).OnExit();
	}

	public override InterruptPriority GetMinimumInterruptPriority()
	{
		return (InterruptPriority)7;
	}
}
public sealed class PlasmaSpawnGate : PlasmaArrivalState
{
	private static Run trackedRun;

	private static readonly HashSet<int> enteredMasters = new HashSet<int>();

	private bool prepared;

	private bool changedGravity;

	private float height;

	private float previousGravity;

	private float visibleAge;

	internal static bool MarkArrived(CharacterBody body)
	{
		Run instance = Run.instance;
		if ((Object)(object)trackedRun != (Object)(object)instance)
		{
			trackedRun = instance;
			enteredMasters.Clear();
		}
		if (Object.op_Implicit((Object)(object)body) && Object.op_Implicit((Object)(object)body.master))
		{
			return enteredMasters.Add(((Object)body.master).GetInstanceID());
		}
		return false;
	}

	public override void FixedUpdate()
	{
		//IL_019a: 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_011e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0123: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_015b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0160: Unknown result type (might be due to invalid IL or missing references)
		base.FixedUpdate();
		if (!((EntityState)this).isAuthority || (Object.op_Implicit((Object)(object)((EntityState)this).characterBody) && Object.op_Implicit((Object)(object)((EntityState)this).characterBody.currentVehicle)) || ((EntityState)this).fixedAge < 0.75f)
		{
			return;
		}
		if (!prepared)
		{
			CharacterMaster val = (Object.op_Implicit((Object)(object)((EntityState)this).characterBody) ? ((EntityState)this).characterBody.master : null);
			if ((!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)Run.instance)) && ((EntityState)this).fixedAge < 1f)
			{
				return;
			}
			Run instance = Run.instance;
			if (!Object.op_Implicit((Object)(object)instance) || instance.stageClearCount != 0 || !Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.playerCharacterMasterController) || !MarkArrived(((EntityState)this).characterBody))
			{
				((EntityState)this).outer.SetNextStateToMain();
				return;
			}
			height = PlasmaFallingSpawn.MeasureDropHeight(((EntityState)this).characterBody, 10f);
			if (Object.op_Implicit((Object)(object)((EntityState)this).characterMotor))
			{
				previousGravity = ((EntityState)this).characterMotor.gravityScale;
				changedGravity = true;
				((EntityState)this).characterMotor.gravityScale = 0f;
				((EntityState)this).characterMotor.velocity = Vector3.zero;
				if (height > 0.5f)
				{
					((BaseCharacterController)((EntityState)this).characterMotor).Motor.SetPosition(((BaseCharacterController)((EntityState)this).characterMotor).Motor.TransientPosition + Vector3.up * height, true);
				}
				((BaseCharacterController)((EntityState)this).characterMotor).Motor.ForceUnground(0.12f);
			}
			prepared = true;
		}
		if (Object.op_Implicit((Object)(object)((EntityState)this).characterMotor))
		{
			((EntityState)this).characterMotor.velocity = Vector3.zero;
		}
		bool flag = false;
		foreach (CameraRigController readOnlyInstances in CameraRigController.readOnlyInstancesList)
		{
			if (Object.op_Implicit((Object)(object)readOnlyInstances) && readOnlyInstances.localUserViewer != null && (Object)(object)readOnlyInstances.targetBody == (Object)(object)((EntityState)this).characterBody)
			{
				flag = true;
				break;
			}
		}
		if (flag && FadeToBlackManager.GetFadeAmount() < 0.05f)
		{
			visibleAge += Time.fixedDeltaTime;
		}
		else
		{
			visibleAge = 0f;
		}
		if (visibleAge >= 0.2f || ((EntityState)this).fixedAge >= 8f)
		{
			Plugin.Log.LogInfo((object)((visibleAge >= 0.2f) ? "Plasma initial body state: camera ready, beginning falling entrance." : "Plasma camera wait timed out; releasing entrance to restore control."));
			if (height > 0.5f)
			{
				((EntityState)this).outer.SetNextState((EntityState)(object)new PlasmaFallingSpawn
				{
					dropHeight = height,
					alreadyRaised = true
				});
			}
			else
			{
				((EntityState)this).outer.SetNextState((EntityState)(object)new PlasmaLanding());
			}
		}
	}

	public override void OnExit()
	{
		if (changedGravity && Object.op_Implicit((Object)(object)((EntityState)this).characterMotor))
		{
			((EntityState)this).characterMotor.gravityScale = previousGravity;
		}
		base.OnExit();
	}
}
public sealed class PlasmaArrivalWeaponLock : EntityState
{
	public override void FixedUpdate()
	{
		((EntityState)this).FixedUpdate();
		EntityStateMachine val = EntityStateMachine.FindByCustomName(((EntityState)this).gameObject, "Body");
		if (((EntityState)this).isAuthority && (!Object.op_Implicit((Object)(object)val) || (!(val.state is PlasmaArrivalState) && !(val.state is PlasmaPodSeated))))
		{
			base.outer.SetNextStateToMain();
		}
	}

	public override InterruptPriority GetMinimumInterruptPriority()
	{
		return (InterruptPriority)7;
	}
}
public sealed class PlasmaFallingSpawn : PlasmaArrivalState
{
	public const float Duration = 0.95f;

	public float dropHeight = 10f;

	public bool alreadyRaised;

	private float previousGravity;

	private bool changedGravity;

	private bool seenAirborne;

	public bool HasLanded
	{
		get
		{
			if (seenAirborne && Object.op_Implicit((Object)(object)((EntityState)this).characterMotor))
			{
				return ((EntityState)this).characterMotor.isGrounded;
			}
			return false;
		}
	}

	internal static float MeasureDropHeight(CharacterBody body, float maximum)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		float num = Mathf.Max(0.25f, body.radius);
		Vector3 corePosition = body.corePosition;
		Vector3 up = Vector3.up;
		float num2 = maximum + 1f;
		LayerIndex world = LayerIndex.world;
		RaycastHit val = default(RaycastHit);
		if (!Physics.SphereCast(corePosition, num, up, ref val, num2, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)1))
		{
			return maximum;
		}
		return Mathf.Clamp(((RaycastHit)(ref val)).distance - 1f, 0f, maximum);
	}

	public override void OnEnter()
	{
		//IL_0097: Unknown result type (might be due to invalid IL or missing references)
		//IL_009c: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_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)
		base.OnEnter();
		if (NetworkServer.active && Object.op_Implicit((Object)(object)((EntityState)this).characterBody))
		{
			((EntityState)this).characterBody.AddTimedBuff(Buffs.HiddenInvincibility, 5.2f);
		}
		if (!((EntityState)this).isAuthority || !Object.op_Implicit((Object)(object)((EntityState)this).characterMotor))
		{
			return;
		}
		if (!alreadyRaised)
		{
			dropHeight = MeasureDropHeight(((EntityState)this).characterBody, dropHeight);
		}
		previousGravity = ((EntityState)this).characterMotor.gravityScale;
		changedGravity = true;
		((EntityState)this).characterMotor.gravityScale = 0f;
		((EntityState)this).characterMotor.velocity = Vector3.zero;
		if (dropHeight > 0.5f)
		{
			if (!alreadyRaised)
			{
				((BaseCharacterController)((EntityState)this).characterMotor).Motor.SetPosition(((BaseCharacterController)((EntityState)this).characterMotor).Motor.TransientPosition + Vector3.up * dropHeight, true);
			}
			((BaseCharacterController)((EntityState)this).characterMotor).Motor.ForceUnground(0.12f);
		}
		else
		{
			((EntityState)this).outer.SetNextState((EntityState)(object)new PlasmaLanding());
		}
	}

	public override void FixedUpdate()
	{
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		base.FixedUpdate();
		if (Object.op_Implicit((Object)(object)((EntityState)this).characterMotor) && !((EntityState)this).characterMotor.isGrounded)
		{
			seenAirborne = true;
		}
		if (!((EntityState)this).isAuthority)
		{
			return;
		}
		if (HasLanded)
		{
			((EntityState)this).outer.SetNextState((EntityState)(object)new PlasmaLanding());
			return;
		}
		if (Object.op_Implicit((Object)(object)((EntityState)this).characterMotor))
		{
			float num = 2f * dropHeight / 0.9025f;
			((EntityState)this).characterMotor.velocity = Vector3.down * (num * Mathf.Min(((EntityState)this).fixedAge, 1.35f));
		}
		if (((EntityState)this).fixedAge >= 1.45f)
		{
			((EntityState)this).outer.SetNextState((EntityState)(object)new PlasmaLanding());
		}
	}

	public override void OnExit()
	{
		if (changedGravity && Object.op_Implicit((Object)(object)((EntityState)this).characterMotor))
		{
			((EntityState)this).characterMotor.gravityScale = previousGravity;
		}
		base.OnExit();
	}

	public override void OnSerialize(NetworkWriter writer)
	{
		((EntityState)this).OnSerialize(writer);
		writer.Write(dropHeight);
		writer.Write(alreadyRaised);
	}

	public override void OnDeserialize(NetworkReader reader)
	{
		((EntityState)this).OnDeserialize(reader);
		dropHeight = reader.ReadSingle();
		alreadyRaised = reader.ReadBoolean();
	}
}
public sealed class PlasmaLanding : PlasmaArrivalState
{
	public const float HoldDuration = 2.1f;

	public const float RiseDuration = 1.65f;

	public const float Duration = 3.75f;

	public override void OnEnter()
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		base.OnEnter();
		if (((EntityState)this).isAuthority && Object.op_Implicit((Object)(object)((EntityState)this).characterMotor))
		{
			((EntityState)this).characterMotor.velocity = Vector3.zero;
		}
	}

	public override void FixedUpdate()
	{
		base.FixedUpdate();
		if (((EntityState)this).fixedAge >= 3.75f && ((EntityState)this).isAuthority)
		{
			((EntityState)this).outer.SetNextStateToMain();
		}
	}
}
public sealed class PlasmaArrivalPod : MonoBehaviour, ICameraStateProvider
{
	private VehicleSeat seat;

	private EntityStateMachine machine;

	private Animator animator;

	private SurvivorPodController cinematic;

	private bool released;

	private float emptyAge;

	private float fuelCheckTimer;

	private bool seenAirborne;

	private bool impact;

	private float impactTime;

	private CharacterBody trackedBody;

	private Transform focusHip;

	private Transform focusChest;

	public float Progress
	{
		get
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)machine) && !(machine.state is Descent))
			{
				return 1f;
			}
			if (!Object.op_Implicit((Object)(object)animator))
			{
				return 0f;
			}
			AnimatorStateInfo currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(0);
			return Mathf.Clamp01(((AnimatorStateInfo)(ref currentAnimatorStateInfo)).normalizedTime);
		}
	}

	public bool HasLanded
	{
		get
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			if (impact)
			{
				return true;
			}
			if (!Object.op_Implicit((Object)(object)seat) || !Object.op_Implicit((Object)(object)seat.seatPosition) || !Object.op_Implicit((Object)(object)seat.exitPosition))
			{
				return false;
			}
			if (ContactReached(Vector3.Dot(seat.seatPosition.position - seat.exitPosition.position, Vector3.up), Object.op_Implicit((Object)(object)machine) && machine.state is Landed, ref seenAirborne))
			{
				impact = true;
				impactTime = Time.time;
			}
			return impact;
		}
	}

	public float GroundedAge
	{
		get
		{
			if (!HasLanded)
			{
				return 0f;
			}
			return Mathf.Max(0f, Time.time - impactTime);
		}
	}

	public Vector3 GroundPosition
	{
		get
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)seat) || !Object.op_Implicit((Object)(object)seat.exitPosition))
			{
				return ((Component)this).transform.position;
			}
			return seat.exitPosition.position;
		}
	}

	internal static GameObject Create(GameObject original)
	{
		//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
		//IL_0168: Unknown result type (might be due to invalid IL or missing references)
		//IL_016d: Unknown result type (might be due to invalid IL or missing references)
		//IL_017d: 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)
		if (!Object.op_Implicit((Object)(object)original))
		{
			return null;
		}
		GameObject val = PrefabAPI.InstantiateClone(original, "HRPlasmaArrivalPod", true);
		VehicleSeat component = val.GetComponent<VehicleSeat>();
		ModelLocator component2 = val.GetComponent<ModelLocator>();
		ChildLocator val2 = ((Object.op_Implicit((Object)(object)component2) && Object.op_Implicit((Object)(object)component2.modelTransform)) ? ((Component)component2.modelTransform).GetComponent<ChildLocator>() : val.GetComponentInChildren<ChildLocator>());
		Transform val3 = (Object.op_Implicit((Object)(object)val2) ? val2.FindChild("Travel") : null);
		if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)val3))
		{
			throw new InvalidOperationException("Plasma arrival needs the survivor pod's Travel bone and VehicleSeat.");
		}
		HideShell(val);
		SuppressFuelArray(val);
		((Behaviour)val.GetComponent<SurvivorPodController>()).enabled = false;
		Animator[] componentsInChildren = val.GetComponentsInChildren<Animator>(true);
		for (int i = 0; i < componentsInChildren.Length; i++)
		{
			componentsInChildren[i].cullingMode = (AnimatorCullingMode)0;
		}
		Transform transform = new GameObject("PlasmaFlightSeat").transform;
		transform.SetParent(val3, false);
		transform.position = val.transform.position;
		Transform transform2 = new GameObject("PlasmaLandingPoint").transform;
		transform2.SetParent(val.transform, false);
		component.seatPosition = transform;
		component.exitPosition = transform2;
		component.hidePassenger = false;
		component.disableInteraction = true;
		component.shouldProximityHighlight = false;
		component.disablePassengerMotor = true;
		component.smoothPassengerPosition = true;
		component.inheritRotation = false;
		component.isEquipmentActivationAllowed = false;
		component.isKeyItemActivationAllowed = false;
		component.shouldSetIdle = false;
		component.exitVelocityFraction = 0f;
		component.additionalExitVelocity = Vector3.zero;
		component.passengerState = new SerializableEntityStateType(typeof(PlasmaPodSeated));
		val.AddComponent<PlasmaArrivalPod>();
		return val;
	}

	private void Awake()
	{
		seat = ((Component)this).GetComponent<VehicleSeat>();
		machine = ((Component)this).GetComponent<EntityStateMachine>();
		cinematic = ((Component)this).GetComponent<SurvivorPodController>();
		if (Object.op_Implicit((Object)(object)cinematic))
		{
			((Behaviour)cinematic).enabled = false;
		}
		ModelLocator component = ((Component)this).GetComponent<ModelLocator>();
		animator = ((Object.op_Implicit((Object)(object)component) && Object.op_Implicit((Object)(object)component.modelTransform)) ? ((Component)component.modelTransform).GetComponent<Animator>() : ((Component)this).GetComponentInChildren<Animator>());
		HideShell(((Component)this).gameObject);
		SuppressFuelArray(((Component)this).gameObject);
		if (Object.op_Implicit((Object)(object)seat))
		{
			seat.onPassengerExit += PassengerExit;
		}
	}

	private void PassengerExit(GameObject passenger)
	{
		ReleaseCameras();
		CharacterBody val = (Object.op_Implicit((Object)(object)passenger) ? passenger.GetComponent<CharacterBody>() : null);
		if (Object.op_Implicit((Object)(object)val) && val.hasEffectiveAuthority && Object.op_Implicit((Object)(object)val.healthComponent) && val.healthComponent.alive)
		{
			EntityStateMachine val2 = EntityStateMachine.FindByCustomName(passenger, "Body");
			if (Object.op_Implicit((Object)(object)val2))
			{
				val2.SetNextState((EntityState)(object)new PlasmaLanding());
			}
		}
	}

	private void OnDestroy()
	{
		ReleaseCameras();
		if (Object.op_Implicit((Object)(object)seat))
		{
			seat.onPassengerExit -= PassengerExit;
		}
	}

	private void OnDisable()
	{
		ReleaseCameras();
	}

	private void ReleaseCameras()
	{
		foreach (CameraRigController readOnlyInstances in CameraRigController.readOnlyInstancesList)
		{
			if (Object.op_Implicit((Object)(object)readOnlyInstances) && readOnlyInstances.IsOverrideCam((ICameraStateProvider)(object)this))
			{
				readOnlyInstances.SetOverrideCam((ICameraStateProvider)null, 0.45f);
			}
		}
	}

	private void Update()
	{
		CharacterBody val = (Object.op_Implicit((Object)(object)seat) ? seat.currentPassengerBody : null);
		foreach (CameraRigController readOnlyInstances in CameraRigController.readOnlyInstancesList)
		{
			if (!Object.op_Implicit((Object)(object)readOnlyInstances))
			{
				continue;
			}
			if (Object.op_Implicit((Object)(object)val) && readOnlyInstances.localUserViewer != null && (Object)(object)readOnlyInstances.target == (Object)(object)((Component)val).gameObject)
			{
				if (!readOnlyInstances.IsOverrideCam((ICameraStateProvider)(object)this))
				{
					readOnlyInstances.SetOverrideCam((ICameraStateProvider)(object)this, 0.1f);
				}
			}
			else if (readOnlyInstances.IsOverrideCam((ICameraStateProvider)(object)this))
			{
				readOnlyInstances.SetOverrideCam((ICameraStateProvider)null, 0.45f);
			}
		}
	}

	public void GetCameraState(CameraRigController rig, ref CameraState state)
	{
		//IL_0021: Unknown result type (might be due to invalid IL or missing references)
		//IL_0026: Unknown result type (might be due to invalid IL or missing references)
		//IL_0043: Unknown result type (might be due to invalid IL or missing references)
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0060: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0066: Unknown result type (might be due to invalid IL or missing references)
		//IL_0067: Unknown result type (might be due to invalid IL or missing references)
		//IL_006f: Unknown result type (might be due to invalid IL or missing references)
		//IL_007d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0086: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00c7: 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_00c9: 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_00d5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00db: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0101: Unknown result type (might be due to invalid IL or missing references)
		//IL_0103: Unknown result type (might be due to invalid IL or missing references)
		//IL_009a: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)seat) || !Object.op_Implicit((Object)(object)seat.seatPosition))
		{
			state = rig.currentCameraState;
			return;
		}
		float num = Mathf.SmoothStep(0f, 1f, Progress);
		Vector3 val = PassengerFocus();
		Vector3 val2 = CameraOffset(Progress);
		Vector3 val3 = ((Component)this).transform.rotation * val2;
		Vector3 normalized = ((Vector3)(ref val3)).normalized;
		float magnitude = ((Vector3)(ref val3)).magnitude;
		LayerIndex world = LayerIndex.world;
		RaycastHit val4 = default(RaycastHit);
		if (Physics.SphereCast(val, 0.2f, normalized, ref val4, magnitude, LayerMask.op_Implicit(((LayerIndex)(ref world)).mask), (QueryTriggerInteraction)1))
		{
			val3 = ((Vector3)(ref val3)).normalized * Mathf.Max(0.3f, ((RaycastHit)(ref val4)).distance - 0.15f);
		}
		state = new CameraState
		{
			position = val + val3,
			rotation = Quaternion.LookRotation(-val3, Vector3.up),
			fov = Mathf.Lerp(52f, 60f, num)
		};
	}

	internal static Vector3 CameraOffset(float progress)
	{
		//IL_000f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0038: Unknown result type (might be due to invalid IL or missing references)
		return Vector3.Lerp(new Vector3(1.2f, 1.8f, -3.6f), new Vector3(3f, 3f, -7.4f), Mathf.SmoothStep(0f, 1f, progress));
	}

	private Vector3 PassengerFocus()
	{
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_010e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0118: Unknown result type (might be due to invalid IL or missing references)
		//IL_011d: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
		//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
		CharacterBody currentPassengerBody = seat.currentPassengerBody;
		if ((Object)(object)currentPassengerBody != (Object)(object)trackedBody)
		{
			trackedBody = currentPassengerBody;
			focusHip = null;
			focusChest = null;
			PlasmaGameplayPose plasmaGameplayPose = (Object.op_Implicit((Object)(object)currentPassengerBody) ? ((Component)currentPassengerBody).GetComponentInChildren<PlasmaGameplayPose>() : null);
			if (Object.op_Implicit((Object)(object)plasmaGameplayPose) && Object.op_Implicit((Object)(object)plasmaGameplayPose.visual))
			{
				Transform[] componentsInChildren = ((Component)plasmaGameplayPose.visual).GetComponentsInChildren<Transform>(true);
				foreach (Transform val in componentsInChildren)
				{
					if (((Object)val).name == "hip")
					{
						focusHip = val;
					}
					if (((Object)val).name == "upperchest")
					{
						focusChest = val;
					}
				}
			}
		}
		if (Object.op_Implicit((Object)(object)currentPassengerBody) && Object.op_Implicit((Object)(object)focusHip))
		{
			if (!Object.op_Implicit((Object)(object)focusChest))
			{
				return focusHip.position;
			}
			return Vector3.Lerp(focusHip.position, focusChest.position, 0.35f);
		}
		return seat.seatPosition.position + Vector3.up * 0.9f;
	}

	public bool IsUserLookAllowed(CameraRigController rig)
	{
		return false;
	}

	public bool IsUserControlAllowed(CameraRigController rig)
	{
		return false;
	}

	public bool IsHudAllowed(CameraRigController rig)
	{
		return true;
	}

	private static bool IsFuel(string name)
	{
		if (!string.IsNullOrEmpty(name))
		{
			return name.IndexOf("QuestVolatileBattery", StringComparison.OrdinalIgnoreCase) >= 0;
		}
		return false;
	}

	private static bool IsPodAttachment(string name)
	{
		if (!IsFuel(name))
		{
			if (!string.IsNullOrEmpty(name))
			{
				return name.IndexOf("SurvivorPodBatteryPanel", StringComparison.OrdinalIgnoreCase) >= 0;
			}
			return false;
		}
		return true;
	}

	private static void SuppressFuelArray(GameObject root)
	{
		InstantiatePrefabBehavior[] componentsInChildren = root.GetComponentsInChildren<InstantiatePrefabBehavior>(true);
		foreach (InstantiatePrefabBehavior val in componentsInChildren)
		{
			if (Object.op_Implicit((Object)(object)val.prefab) && IsPodAttachment(((Object)val.prefab).name))
			{
				val.instantiateOnStart = false;
				((Behaviour)val).enabled = false;
				val.prefab = null;
			}
		}
		PrefabSpawner[] componentsInChildren2 = root.GetComponentsInChildren<PrefabSpawner>(true);
		foreach (PrefabSpawner val2 in componentsInChildren2)
		{
			if (Object.op_Implicit((Object)(object)val2.prefabToSpawn) && IsPodAttachment(((Object)val2.prefabToSpawn).name))
			{
				val2.spawnOnStart = false;
				((Behaviour)val2).enabled = false;
				val2.prefabToSpawn = null;
			}
		}
		ChildLocator[] componentsInChildren3 = root.GetComponentsInChildren<ChildLocator>(true);
		for (int i = 0; i < componentsInChildren3.Length; i++)
		{
			Transform val3 = componentsInChildren3[i].FindChild("BatteryAttachmentPoint");
			if (Object.op_Implicit((Object)(object)val3))
			{
				((Component)val3).gameObject.SetActive(false);
			}
		}
		GenericPickupController[] componentsInChildren4 = root.GetComponentsInChildren<GenericPickupController>(true);
		foreach (GenericPickupController val4 in componentsInChildren4)
		{
			if (IsFuel(((Object)val4).name))
			{
				((Behaviour)val4).enabled = false;
				((Component)val4).gameObject.SetActive(false);
				if (NetworkServer.active && Object.op_Implicit((Object)(object)((Component)val4).GetComponent<NetworkIdentity>()))
				{
					NetworkServer.Destroy(((Component)val4).gameObject);
				}
			}
		}
	}

	private static void HideShell(GameObject root)
	{
		Renderer[] componentsInChildren = root.GetComponentsInChildren<Renderer>(true);
		foreach (Renderer val in componentsInChildren)
		{
			if ((val is MeshRenderer || val is SkinnedMeshRenderer) && !Object.op_Implicit((Object)(object)((Component)val).GetComponentInParent<CharacterBody>()))
			{
				val.forceRenderingOff = true;
				val.enabled = false;
				SkinnedMeshRenderer val2 = (SkinnedMeshRenderer)(object)((val is SkinnedMeshRenderer) ? val : null);
				if (Object.op_Implicit((Object)(object)val2))
				{
					val2.sharedMesh = null;
				}
				MeshFilter component = ((Component)val).GetComponent<MeshFilter>();
				if (Object.op_Implicit((Object)(object)component))
				{
					component.sharedMesh = null;
				}
			}
		}
	}

	internal static bool ContactReached(float height, bool landedState, ref bool seenAirborne)
	{
		if (height > 0.75f)
		{
			seenAirborne = true;
		}
		if (!landedState)
		{
			if (seenAirborne)
			{
				return height <= 0.2f;
			}
			return false;
		}
		return true;
	}

	private void FixedUpdate()
	{
		fuelCheckTimer -= Time.fixedDeltaTime;
		if (fuelCheckTimer <= 0f)
		{
			SuppressFuelArray(((Component)this).gameObject);
			fuelCheckTimer = 0.25f;
		}
		if (!NetworkServer.active)
		{
			return;
		}
		if (released)
		{
			emptyAge += Time.fixedDeltaTime;
			if (emptyAge > 1f)
			{
				NetworkServer.Destroy(((Component)this).gameObject);
			}
		}
		else
		{
			if (!Object.op_Implicit((Object)(object)seat) || !Object.op_Implicit((Object)(object)machine) || !HasLanded)
			{
				return;
			}
			if (!Object.op_Implicit((Object)(object)seat.currentPassengerBody))
			{
				emptyAge += Time.fixedDeltaTime;
				if (emptyAge > 2f)
				{
					NetworkServer.Destroy(((Component)this).gameObject);
				}
				return;
			}
			seat.EjectPassenger();
			Collider[] componentsInChildren = ((Component)this).GetComponentsInChildren<Collider>();
			for (int i = 0; i < componentsInChildren.Length; i++)
			{
				componentsInChildren[i].enabled = false;
			}
			released = true;
		}
	}
}
public sealed class PlasmaPodSeated : GenericCharacterVehicleSeated
{
	private PlasmaArrivalPod pod;

	private float protectionTimer;

	private bool wasIgnoreFall;

	public float Elapsed => ((EntityState)this).age;

	public float Progress
	{
		get
		{
			if (!Object.op_Implicit((Object)(object)pod))
			{
				return Mathf.Clamp01(((EntityState)this).age / 4f);
			}
			return pod.Progress;
		}
	}

	public bool HasLanded
	{
		get
		{
			if (Object.op_Implicit((Object)(object)pod))
			{
				return pod.HasLanded;
			}
			return false;
		}
	}

	public float GroundedAge
	{
		get
		{
			if (!Object.op_Implicit((Object)(object)pod))
			{
				return 0f;
			}
			return pod.GroundedAge;
		}
	}

	public Vector3 GroundPosition
	{
		get
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			if (!Object.op_Implicit((Object)(object)pod))
			{
				return ((EntityState)this).characterBody.footPosition;
			}
			return pod.GroundPosition;
		}
	}

	public override void OnEnter()
	{
		//IL_004c: 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_0054: Invalid comparison between Unknown and I4
		//IL_0062: Unknown result type (might be due to invalid IL or missing references)
		//IL_0068: Unknown result type (might be due to invalid IL or missing references)
		//IL_0069: Unknown result type (might be due to invalid IL or missing references)
		((GenericCharacterVehicleSeated)this).OnEnter();
		if (((EntityState)this).isAuthority)
		{
			PlasmaSpawnGate.MarkArrived(((EntityState)this).characterBody);
		}
		if (Object.op_Implicit((Object)(object)((GenericCharacterVehicleSeated)this).vehicleSeat))
		{
			pod = ((Component)((GenericCharacterVehicleSeated)this).vehicleSeat).GetComponent<PlasmaArrivalPod>();
		}
		if (Object.op_Implicit((Object)(object)((EntityState)this).characterBody))
		{
			wasIgnoreFall = (((EntityState)this).characterBody.bodyFlags & 1) > 0;
			CharacterBody characterBody = ((EntityState)this).characterBody;
			characterBody.bodyFlags = (BodyFlags)(characterBody.bodyFlags | 1);
		}
		LockWeapon();
	}

	private void LockWeapon()
	{
		if (((EntityState)this).isAuthority)
		{
			EntityStateMachine val = EntityStateMachine.FindByCustomName(((EntityState)this).gameObject, "Weapon");
			if (Object.op_Implicit((Object)(object)val) && !(val.state is PlasmaArrivalWeaponLock))
			{
				val.SetInterruptState((EntityState)(object)new PlasmaArrivalWeaponLock(), (InterruptPriority)8);
			}
		}
	}

	public override void FixedUpdate()
	{
		((EntityState)this).FixedUpdate();
		LockWeapon();
		if (!Object.op_Implicit((Object)(object)pod) && Object.op_Implicit((Object)(object)((EntityState)this).characterBody) && Object.op_Implicit((Object)(object)((EntityState)this).characterBody.currentVehicle))
		{
			pod = ((Component)((EntityState)this).characterBody.currentVehicle).GetComponent<PlasmaArrivalPod>();
		}
		if (((EntityState)this).isAuthority)
		{
			PlasmaSpawnGate.MarkArrived(((EntityState)this).characterBody);
		}
		protectionTimer -= Time.fixedDeltaTime;
		if (NetworkServer.active && Object.op_Implicit((Object)(object)((EntityState)this).characterBody) && protectionTimer <= 0f)
		{
			((EntityState)this).characterBody.AddTimedBuff(Buffs.HiddenInvincibility, 0.5f);
			protectionTimer = 0.4f;
		}
		if (((EntityState)this).isAuthority && ((EntityState)this).fixedAge > 0.3f && Object.op_Implicit((Object)(object)((EntityState)this).characterBody) && !Object.op_Implicit((Object)(object)((EntityState)this).characterBody.currentVehicle))
		{
			((EntityState)this).outer.SetNextState((EntityState)(object)new PlasmaLanding());
		}
	}

	public override void OnExit()
	{
		//IL_001c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0024: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)((EntityState)this).characterBody) && !wasIgnoreFall)
		{
			CharacterBody characterBody = ((EntityState)this).characterBody;
			characterBody.bodyFlags = (BodyFlags)(characterBody.bodyFlags & -2);
		}
		if (((EntityState)this).isAuthority && Object.op_Implicit((Object)(object)((EntityState)this).characterBody) && Object.op_Implicit((Object)(object)((EntityState)this).characterBody.healthComponent) && ((EntityState)this).characterBody.healthComponent.alive)
		{
			PlasmaArrivalRecovery plasmaArrivalRecovery = ((EntityState)this).gameObject.GetComponent<PlasmaArrivalRecovery>();
			if (!Object.op_Implicit((Object)(object)plasmaArrivalRecovery))
			{
				plasmaArrivalRecovery = ((EntityState)this).gameObject.AddComponent<PlasmaArrivalRecovery>();
			}
			plasmaArrivalRecovery.pending = true;
		}
		((EntityState)this).OnExit();
	}
}
public sealed class PlasmaArrivalRecovery : MonoBehaviour
{
	public bool pending;

	private float elapsed;

	private void FixedUpdate()
	{
		if (!pending)
		{
			return;
		}
		CharacterBody component = ((Component)this).GetComponent<CharacterBody>();
		if (!Object.op_Implicit((Object)(object)component) || !Object.op_Implicit((Object)(object)component.healthComponent) || !component.healthComponent.alive)
		{
			Object.Destroy((Object)(object)this);
		}
		else
		{
			if (Object.op_Implicit((Object)(object)component.currentVehicle))
			{
				return;
			}
			elapsed += Time.fixedDeltaTime;
			EntityStateMachine val = EntityStateMachine.FindByCustomName(((Component)this).gameObject, "Body");
			if (component.hasEffectiveAuthority && Object.op_Implicit((Object)(object)val) && !(val.state is PlasmaPodSeated))
			{
				pending = false;
				if (!(val.state is PlasmaArrivalState))
				{
					val.SetInterruptState((EntityState)(object)new PlasmaLanding(), (InterruptPriority)8);
				}
				Object.Destroy((Object)(object)this);
			}
			else if (elapsed > 2f)
			{
				Object.Destroy((Object)(object)this);
			}
		}
	}
}
[DefaultExecutionOrder(20030)]
public sealed class PlasmaArrivalPose : MonoBehaviour
{
	[SerializeField]
	private PlasmaGameplayPose gameplay;

	private EntityStateMachine machine;

	private readonly Dictionary<string, Transform> bones = new Dictionary<string, Transform>();

	private SkinnedMeshRenderer[] faces;

	private readonly Dictionary<SkinnedMeshRenderer, float[]> faceRest = new Dictionary<SkinnedMeshRenderer, float[]>();

	private static readonly string[] Expressions = new string[3] { "EyesReplace_o", "Mouth_Open", "Mouth_FrontOpen" };

	private bool showingArrival;

	public bool IsPlaying
	{
		get
		{
			if (Object.op_Implicit((Object)(object)machine))
			{
				if (!(machine.state is PlasmaArrivalState))
				{
					return machine.state is PlasmaPodSeated;
				}
				return true;
			}
			return false;
		}
	}

	public void Configure(PlasmaGameplayPose pose)
	{
		gameplay = pose;
	}

	private void Awake()
	{
		if (!Object.op_Implicit((Object)(object)gameplay))
		{
			gameplay = ((Component)this).GetComponent<PlasmaGameplayPose>();
		}
	}

	private Transform Bone(string name)
	{
		bones.TryGetValue(name, out var value);
		return value;
	}

	private void Initialize()
	{
		machine = EntityStateMachine.FindByCustomName(((Component)gameplay.body).gameObject, "Body");
		PlasmaLobbyAnimation.RestBone[] rest = gameplay.rest;
		for (int i = 0; i < rest.Length; i++)
		{
			PlasmaLobbyAnimation.RestBone restBone = rest[i];
			if (Object.op_Implicit((Object)(object)restBone.bone))
			{
				bones[((Object)restBone.bone).name] = restBone.bone;
			}
		}
		faces = (from r in ((Component)gameplay.visual).GetComponentsInChildren<SkinnedMeshRenderer>(true)
			where Object.op_Implicit((Object)(object)r.sharedMesh) && ((Object)r).name.StartsWith("Body_")
			select r).ToArray();
		SkinnedMeshRenderer[] array = faces;
		foreach (SkinnedMeshRenderer val in array)
		{
			float[] array2 = new float[Expressions.Length];
			for (int num = 0; num < array2.Length; num++)
			{
				int blendShapeIndex = val.sharedMesh.GetBlendShapeIndex(Expressions[num]);
				if (blendShapeIndex >= 0)
				{
					array2[num] = val.GetBlendShapeWeight(blendShapeIndex);
				}
			}
			faceRest[val] = array2;
		}
	}

	private void Start()
	{
		if (Object.op_Implicit((Object)(object)gameplay))
		{
			Initialize();
		}
	}

	private void Expression(float panic)
	{
		SkinnedMeshRenderer[] array = faces;
		foreach (SkinnedMeshRenderer val in array)
		{
			if (!Object.op_Implicit((Object)(object)val) || !Object.op_Implicit((Object)(object)val.sharedMesh))
			{
				continue;
			}
			for (int j = 0; j < Expressions.Length; j++)
			{
				int blendShapeIndex = val.sharedMesh.GetBlendShapeIndex(Expressions[j]);
				if (blendShapeIndex >= 0)
				{
					val.SetBlendShapeWeight(blendShapeIndex, Mathf.Lerp(faceRest[val][j], (float)((j == 0) ? 100 : 65), panic));
				}
			}
			int blendShapeIndex2 = val.sharedMesh.GetBlendShapeIndex("Eyes_Blink");
			if (blendShapeIndex2 >= 0)
			{
				val.SetBlendShapeWeight(blendShapeIndex2, (panic > 0.2f) ? 0f : PlasmaLobbyAnimation.Blink(Time.time));
			}
		}
	}

	private static void Aim(Transform bone, Transform child, Vector3 direction)
	{
		//IL_0012: Unknown result type (might be due to invalid IL or missing references)
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_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_0023: Unknown result type (might be due to invalid IL or missing references)
		//IL_0029: Unknown result type (might be due to invalid IL or missing references)
		//IL_002e: Unknown result type (might be due to invalid IL or missing references)
		if (Object.op_Implicit((Object)(object)bone) && Object.op_Implicit((Object)(object)child))
		{
			bone.rotation = Quaternion.FromToRotation(child.position - bone.position, direction) * bone.rotation;
		}
	}

	internal static void FallAngles(float time, float sign, out float arm, out float elbow, out float thigh, out float knee)
	{
		float num = time * 3.1f + sign * 1.2f;
		arm = 12f + 32f * Mathf.Sin(num);
		elbow = 68f + 18f * Mathf.Sin(num + 0.8f);
		thigh = 22f * Mathf.Sin(num + 1.1f);
		knee = 52f + 22f * Mathf.Sin(num + 0.35f);
	}

	private void LateUpdate()
	{
		//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
		//IL_053e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0536: Unknown result type (might be due to invalid IL or missing references)
		//IL_0543: Unknown result type (might be due to invalid IL or missing references)
		//IL_0546: Unknown result type (might be due to invalid IL or missing references)
		//IL_054b: Unknown result type (might be due to invalid IL or missing references)
		//IL_054d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0553: Unknown result type (might be due to invalid IL or missing references)
		//IL_0560: Unknown result type (might be due to invalid IL or missing references)
		//IL_0563: Unknown result type (might be due to invalid IL or missing references)
		//IL_0582: Unknown result type (might be due to invalid IL or missing references)
		//IL_0587: Unknown result type (might be due to invalid IL or missing references)
		//IL_05b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_05b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_05bf: Unknown result type (might be due to invalid IL or missing references)
		//IL_05c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_060b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0610: Unknown result type (might be due to invalid IL or missing references)
		//IL_061a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0620: Unknown result type (might be due to invalid IL or missing references)
		//IL_062d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0632: Unknown result type (might be due to invalid IL or missing references)
		//IL_0638: Unknown result type (might be due to invalid IL or missing references)
		//IL_063d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0643: Unknown result type (might be due to invalid IL or missing references)
		//IL_0650: Unknown result type (might be due to invalid IL or missing references)
		//IL_0655: Unknown result type (might be due to invalid IL or missing references)
		//IL_065c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0661: Unknown result type (might be due to invalid IL or missing references)
		//IL_0664: Unknown result type (might be due to invalid IL or missing references)
		//IL_066e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0674: Unknown result type (might be due to invalid IL or missing references)
		//IL_067e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0683: Unknown result type (might be due to invalid IL or missing references)
		//IL_0689: Unknown result type (might be due to invalid IL or missing references)
		//IL_068e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0698: Unknown result type (might be due to invalid IL or missing references)
		//IL_069e: Unknown result type (might be due to invalid IL or missing references)
		//IL_06a8: Unknown result type (might be due to invalid IL or missing references)
		//IL_06ad: Unknown result type (might be due to invalid IL or missing references)
		//IL_06b3: Unknown result type (might be due to invalid IL or missing references)
		//IL_06c0: Unknown result type (might be due to invalid IL or missing references)
		//IL_06c5: Unknown result type (might be due to invalid IL or missing references)
		//IL_06cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_06d1: Unknown result type (might be due to invalid IL or missing references)
		//IL_06f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0722: Unknown result type (might be due to invalid IL or missing references)
		//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
		//IL_03cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_03d6: Unknown result type (might be due to invalid IL or missing references)
		//IL_03db: Unknown result type (might be due to invalid IL or missing references)
		//IL_0897: Unknown result type (might be due to invalid IL or missing references)
		//IL_089c: Unknown result type (might be due to invalid IL or missing references)
		//IL_08a6: Unknown result type (might be due to invalid IL or missing references)
		//IL_08ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_08b6: Unknown result type (might be due to invalid IL or missing references)
		//IL_08bb: Unknown result type (might be due to invalid IL or missing references)
		//IL_08c1: Unknown result type (might be due to invalid IL or missing references)
		//IL_08ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_08d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_08e2: 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_08f1: Unknown result type (might be due to invalid IL or missing references)
		//IL_08f7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0901: Unknown result type (might be due to invalid IL or missing references)
		//IL_0906: Unknown result type (might be due to invalid IL or missing references)
		//IL_01ff: Unknown result type (might be due to invalid IL or missing references)
		//IL_0204: Unknown result type (might be due to invalid IL or missing references)
		//IL_020a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0211: Unknown result type (might be due to invalid IL or missing references)
		//IL_0216: Unknown result type (might be due to invalid IL or missing references)
		//IL_021b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0223: Unknown result type (might be due to invalid IL or missing references)
		//IL_0228: Unknown result type (might be due to invalid IL or missing references)
		//IL_022d: Unknown result type (might be due to invalid IL or missing references)
		//IL_022f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0234: Unknown result type (might be due to invalid IL or missing references)
		//IL_025a: Unknown result type (might be due to invalid IL or missing references)
		//IL_025d: 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_026c: Unknown result type (might be due to invalid IL or missing references)
		//IL_029a: Unknown result type (might be due to invalid IL or missing references)
		//IL_029d: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a7: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ac: Unknown result type (might be due to invalid IL or missing references)
		//IL_02b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02be: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c4: Unknown result type (might be due to invalid IL or missing references)
		//IL_02c9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_02d3: Unknown result type (might be due to invalid IL or missing references)
		//IL_02f9: Unknown result type (might be due to invalid IL or missing references)
		//IL_02fc: Unknown result type (might be due to invalid IL or missing references)
		//IL_0309: Unknown result type (might be due to invalid IL or missing references)
		//IL_030e: Unknown result type (might be due to invalid IL or missing references)
		//IL_033f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0344: Unknown result type (might be due to invalid IL or missing references)
		//IL_0349: Unknown result type (might be due to invalid IL or missing references)
		//IL_034b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0351: Unknown result type (might be due to invalid IL or missing references)
		//IL_035e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0363: Unknown result type (might be due to invalid IL or missing references)
		//IL_042f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0434: Unknown result type (might be due to invalid IL or missing references)
		//IL_0442: Unknown result type (might be due to invalid IL or missing references)
		//IL_0447: Unknown result type (might be due to invalid IL or missing references)
		//IL_044c: Unknown result type (might be due to invalid IL or missing references)
		//IL_046b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0470: Unknown result type (might be due to invalid IL or missing references)
		//IL_0475: Unknown result type (might be due to invalid IL or missing references)
		//IL_047b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0480: Unknown result type (might be due to invalid IL or missing references)
		//IL_040a: Unknown result type (might be due to invalid IL or missing references)
		//IL_040f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0416: Unknown result type (might be due to invalid IL or missing references)
		//IL_041b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0789: Unknown result type (might be due to invalid IL or missing references)
		//IL_078c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0796: Unknown result type (might be due to invalid IL or missing references)
		//IL_079c: Unknown result type (might be due to invalid IL or missing references)
		//IL_07a9: Unknown result type (might be due to invalid IL or missing references)
		//IL_07ae: Unknown result type (might be due to invalid IL or missing references)
		//IL_07b4: Unknown result type (might be due to invalid IL or missing references)
		//IL_07be: Unknown result type (might be due to invalid IL or missing references)
		//IL_07c3: Unknown result type (might be due to invalid IL or missing references)
		//IL_07cd: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_07d7: Unknown result type (might be due to invalid IL or missing references)
		//IL_0803: Unknown result type (might be due to invalid IL or missing references)
		//IL_0807: Unknown result type (might be due to invalid IL or missing references)
		//IL_080e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0815: Unknown result type (might be due to invalid IL or missing references)
		//IL_081b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0828: Unknown result type (might be due to invalid IL or missing references)
		//IL_082e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0838: Unknown result type (might be due to invalid IL or missing references)
		//IL_083d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0847: Unknown result type (might be due to invalid IL or missing references)
		//IL_084c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0936: Unknown result type (might be due to invalid IL or missing references)
		//IL_093b: Unknown result type (might be due to invalid IL or missing references)
		//IL_093d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0940: Unknown result type (might be due to invalid IL or missing references)
		//IL_094d: Unknown result type (might be due to invalid IL or missing references)
		//IL_0953: Unknown result type (might be due to invalid IL or missing references)
		//IL_0972: Unknown result type (might be due to invalid IL or missing references)
		//IL_0977: Unknown result type (might be due to invalid IL or missing references)
		//IL_0981: Unknown result type (might be due to invalid IL or missing references)
		//IL_0986: Unknown result type (might be due to invalid IL or missing references)
		//IL_098b: Unknown result type (might be due to invalid IL or missing references)
		//IL_09cc: Unknown result type (might be due to invalid IL or missing references)
		//IL_09ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_09d2: Unknown result type (might be due to invalid IL or missing references)
		//IL_09d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_09df: Unknown result type (might be due to invalid IL or missing references)
		//IL_09e4: Unknown result type (might be due to invalid IL or missing references)
		if (!Object.op_Implicit((Object)(object)gameplay) || !Object.op_Implicit((Object)(object)gameplay.body) || gameplay.rest == null)
		{
			return;
		}
		if (bones.Count == 0)
		{
			Initialize();
		}
		if (!IsPlaying)
		{
			if (showingArrival)
			{
				Expression(0f);
				showingArrival = false;
			}
		}
		else
		{
			if (Object.op_Implicit((Object)(object)gameplay.body.healthComponent) && !gameplay.body.healthComponent.alive)
			{
				return;
			}
			showingArrival = true;
			PlasmaLobbyAnimation.RestBone[] rest = gameplay.rest;
			for (int i = 0; i < rest.Length; i++)
			{
				PlasmaLobbyAnimation.RestBone restBone = rest[i];
				if (Object.op_Implicit((Object)(object)restBone.bone))
				{
					restBone.bone.localPosition = restBone.position;
					restBone.bone.localRotation = restBone.rotation;
				}
			}
			Transform visual = gameplay.visual;
			Transform val = Bone("hip");
			if (!Object.op_Implicit((Object)(object)val))
			{
				return;
			}
			PlasmaFallingSpawn plasmaFallingSpawn = machine.state as PlasmaFallingSpawn;
			PlasmaPodSeated plasmaPodSeated = machine.state as PlasmaPodSeated;
			string[] array;
			if ((plasmaPodSeated == null || !plasmaPodSeated.HasLanded) && (plasmaFallingSpawn == null || !plasmaFallingSpawn.HasLanded) && (plasmaFallingSpawn != null || plasmaPodSeated != null || machine.state is PlasmaSpawnGate))
			{
				float num = plasmaPodSeated?.Elapsed ?? plasmaFallingSpawn?.Elapsed ?? 0f;
				float num2 = plasmaPodSeated?.Progress ?? Mathf.Clamp01(num / 0.95f);
				array = new string[2] { "R", "L" };
				foreach (string text in array)
				{
					float num3 = ((text == "R") ? 1 : (-1));
					FallAngles(num, num3, out var arm, out var elbow, out var thigh, out var knee);
					Vector3 val2 = Quaternion.AngleAxis(num3 * arm, visual.forward) * (visual.right * num3);
					Vector3 val3 = Quaternion.AngleAxis(num3 * elbow, visual.forward) * val2;
					Aim(Bone("upper_arm." + text), Bone("forearm." + text), val2 + visual.forward * 0.18f);
					Aim(Bone("forearm." + text), Bone("hand." + text), val3 + visual.forward * 0.18f);
					Vector3 val4 = Quaternion.AngleAxis(thigh, visual.right) * -visual.up;
					Aim(Bone("thigh." + text), Bone("shin." + text), val4 + visual.right * (num3 * 0.14f));
					Aim(Bone("shin." + text), Bone("foot." + text), Quaternion.AngleAxis(knee, visual.right) * val4 + visual.right * (num3 * 0.14f));
				}
				float num4 = Mathf.SmoothStep(0f, 1f, num2);
				Transform val5 = Bone("upperchest");
				Transform val6 = Bone("head");
				if (Object.op_Implicit((Object)(object)val5))
				{
					val5.rotation = Quaternion.AngleAxis(9f * Mathf.Sin(num * 2.4f), visual.up) * val5.rotation;
				}
				if (Object.op_Implicit((Object)(object)val6))
				{
					val6.rotation = Quaternion.AngleAxis(18f * Mathf.Sin(num * 2.1f + 0.4f), visual.up) * val6.rotation;
				}
				val.rotation = Quaternion.AngleAxis(720f * num4, visual.right) * Quaternion.AngleAxis(360f * num4, visual.up) * Quaternion.AngleAxis(28f * Mathf.Sin(num2 * 2f * (float)Math.PI), visual.forward) * val.rotation;
				Expression(1f);
				return;
			}
			float num5 = Mathf.Clamp01(((plasmaPodSeated?.GroundedAge ?? ((plasmaFallingSpawn != null) ? 0f : ((PlasmaLanding)(object)machine.state).Elapsed)) - 2.1f) / 1.65f);
			float num6 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01(num5 / 0.48f));
			float num7 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01((num5 - 0.35f) / 0.65f));
			float num8 = Mathf.SmoothStep(0f, 1f, num5);
			Vector3 val7 = plasmaPodSeated?.GroundPosition ?? gameplay.body.footPosition;
			float num9 = Vector3.Dot(val.position - val7, visual.up);
			val.position = val7 + visual.up * Mathf.Lerp(Mathf.Lerp(0.28599998f, 0.62399995f, num6), num9, num7);
			float num10 = Mathf.Lerp(Mathf.Lerp(85f, 38f, num6), 0f, num7);
			val.rotation = Quaternion.AngleAxis(num10, visual.right) * val.rotation;
			array = new string[2] { "R", "L" };
			foreach (string text2 in array)
			{
				float num11 = ((text2 == "R") ? 1 : (-1));
				Vector3 direction = Vector3.Lerp(-visual.up * 0.45f + visual.right * (num11 * 0.7f), -visual.up + visual.right * (num11 * 0.22f), num7);
				Vector3 direction2 = Vector3.Lerp(visual.forward * 0.78f - visual.up * 0.12f, -visual.up * 0.85f + visual.forward * 0.22f + visual.right * (num11 * 0.2f), num7);
				Aim(Bone("upper_arm." + text2), Bone("forearm." + text2), direction);
				Aim(Bone("forearm." + text2), Bone("hand." + text2), direction2);
				Transform val8 = Bone("upper_arm." + text2);
				Transform val9 = Bone("forearm." + text2);
				Transform val10 = Bone("hand." + text2);
				if (Object.op_Implicit((Object)(object)val8) && Object.op_Implicit((Object)(object)val9) && Object.op_Implicit((Object)(object)val10))
				{
					Vector3 val11 = val7 + (visual.forward * 0.62f + visual.right * (num11 * 0.36f) + visual.up * 0.06f) * 1.3f;
					float num12 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01((num5 - 0.35f) / 0.3f));
					PlasmaLobbyAnimation.Solve(val8, val9, val10, Vector3.Lerp(val11, val10.position, num12), val8.position + (visual.right * (num11 * 0.65f) - visual.forward * 0.2f) * 1.3f);
				}
				Transform val12 = Bone("thigh." + text2);
				Transform val13 = Bone("shin." + text2);
				Transform val14 = Bone("foot." + text2);
				Aim(val12, val13, -visual.forward * 0.95f - visual.up * 0.08f + visual.right * (num11 * 0.15f));
				Aim(val13, val14, -visual.forward * 0.92f + visual.up * 0.14f);
				if (Object.op_Implicit((Object)(object)val12) && Object.op_Implicit((Object)(object)val13) && Object.op_Implicit((Object)(object)val14))
				{
					Vector3 position = val14.position;
					Vector3 val15 = val7 + (visual.right * (num11 * 0.15f) + visual.forward * ((text2 == "R") ? 0.12f : (-0.08f))) * 1.3f;
					float num13 = Mathf.SmoothStep(0f, 1f, Mathf.Clamp01((num5 - ((text2 == "R") ? 0.06f : 0.24f)) / 0.5f));
					PlasmaLobbyAnimation.Solve(val12, val13, val14, Vector3.Lerp(position, val15, num13), val12.position + visual.forward);
				}
			}
			Expression(1f - num8);
		}
	}
}
internal static class PlasmaBeamAim
{
	internal const float Range = 180f;

	internal static Ray Resolve(CharacterBody body, Ray aim)
	{
		//IL_0000: 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_000e: 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_001f: 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_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_005c: Unknown result type (might be due to invalid IL or missing references)
		//IL_0054: Unknown result type (might be due to invalid IL or missing references)
		//IL_0061: Unknown result type (might be due to invalid IL or missing references)
		//IL_0063: 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_006a: 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_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008c: Unknown result type (might be due to invalid IL or missing references)
		//IL_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)
		float num = default(float);
		Ray val = CameraRigController.ModifyAimRayIfApplicable(aim, ((Component)body).gameObject, ref num);
		RaycastHit val3 = default(RaycastHit);
		Vector3 val2 = (Util.CharacterRaycast(((Component)body).gameObject, val, ref val3, 180f + num, CommonMasks.bullet, (QueryTriggerInteraction)1) ? ((RaycastHit)(ref val3)).point : ((Ray)(ref val)).GetPoint(180f + num));
		Transform val4 = PlasmaAbilityVisuals.Muzzle(body);
		Vector3 val5 = (Object.op_Implicit((Object)(object)val4) ? val4.position : ((Ray)(ref aim)).origin);
		Vector3 val6 = val2 - val5;
		if (((Vector3)(ref val6)).sqrMagnitude < 0.0001f)
		{
			val6 = ((Ray)(ref aim)).direction;
		}
		return new Ray(val5, ((Vector3)(ref val6)).normalized);
	}
}
internal static class PlasmaCommands
{
	internal const string Usage = "plasma_spawn_prismatic [golem|lemurian|beetle] [count: 1]";

	internal static bool Parse(string enemy, string amount, out string path, out int count)
	{
		path = null;
		count = 1;
		switch ((enemy ?? "golem").ToLowerInvariant())
		{
		case "golem":
			path = "RoR2/Base/Golem/cscGolem.asset";
			break;
		case "lemurian":
			path = "RoR2/Base/Lemurian/cscLemurian.asset";
			break;
		case "beetle":
			path = "RoR2/Base/Beetle/cscBeetle.asset";
			break;
		default:
			return false;
		}
		if (amount != null)
		{
			if (int.TryParse(amount, out count))
			{
				return count == 1;
			}
			return false;
		}
		return true;
	}

	[ConCommand(/*Could not decode attribute arguments.*/)]
	private static void SpawnPrismatic(ConCommandArgs args)
	{
		//IL_0007: 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)
		SpawnNearby(((ConCommandArgs)(ref args)).TryGetSenderBody(), args.userArgs.ToArray(), delegate(string message)
		{
			((ConCommandArgs)(ref args)).Log((object)message);
		});
	}

	internal static void QuickSpawn()
	{
		LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
		SpawnNearby((firstLocalUser != null) ? firstLocalUser.cachedBody : null, new string[0], delegate(string message)
		{
			Chat.AddMessage(message);
			Plugin.Log.LogInfo((object)message);
		});
	}

	internal static void SpawnNearby(CharacterBody body, string[] arguments, Action<string> report)
	{
		//IL_0300: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00de: Unknown result type (might be due to invalid IL or missing references)
		//IL_0154: 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_0179: 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_01a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_01a7: 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_01e4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
		//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
		//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
		//IL_0200: Unknown result type (might be due to invalid IL or missing references)
		//IL_020d: Expected O, but got Unknown
		//IL_0216: Unknown result type (might be due to invalid IL or missing references)
		//IL_021b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0227: Unknown result type (might be due to invalid IL or missing references)
		//IL_0230: Expected O, but got Unknown
		if (!NetworkServer.active)
		{
			report("Run this command as the host or in singleplayer.");
			return;
		}
		if (!Object.op_Implicit((Object)(object)Run.instance) || !Object.op_Implicit((Object)(object)DirectorCore.instance))
		{
			report("Start a run first.");
			return;
		}
		if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.healthComponent) || !body.healthComponent.alive)
		{
			report("Your survivor must be alive to spawn an enemy nearby.");
			return;
		}
		string text = ((arguments.Length != 0) ? arguments[0] : null);
		string amount = ((arguments.Length > 1) ? arguments[1] : null);
		if (arguments.Length > 2 || !Parse(text, amount, out var path, out var count))
		{
			report("plasma_spawn_prismatic [golem|lemurian|beetle] [count: 1]");
			return;
		}
		if (!Object.op_Implicit((Object)(object)PrismaticElites.Elite) || !Object.op_Implicit((Object)(object)PrismaticElites.Elite.eliteEquipmentDef))
		{
			report("Prismatic elite content is not loaded.");
			return;
		}
		if (!PrismaticEliteLimit.CanSpawn())
		{
			report("A Prismatic enemy is already alive on this stage.");
			return;
		}
		AsyncOperationHandle<CharacterSpawnCard> val = Addressables.LoadAssetAsync<CharacterSpawnCard>((object)path);
		CharacterSpawnCard val2 = null;
		bool flag = false;
		try
		{
			CharacterSpawnCard val3 = val.WaitForCompletion();
			if (!Object.op_Implicit((Object)(object)val3))
			{
				report("Enemy spawn card could not be loaded.");
				return;
			}
			val2 = Object.Instantiate<CharacterSpawnCard>(val3);
			((Object)val2).name = "HRPrismaticTestSpawn";
			val2.equipmentToGrant = (EquipmentDef[])(object)new EquipmentDef[1] { PrismaticElites.Elite.eliteEquipmentDef };
			val2.itemsToGrant = ((IEnumerable<ItemCountPair>)(((object)val3.itemsToGrant) ?? ((object)new ItemCountPair[0]))).Concat((IEnumerable<ItemCountPair>)(object)new ItemCountPair[2]
			{
				new ItemCountPair
				{
					itemDef = Items.BoostHp,
					count = Mathf.RoundToInt(70f)
				},
				new ItemCountPair
				{
					itemDef = Items.BoostDamage,
					count = Mathf.RoundToInt(20f)
				}
			}).ToArray();
			if (!PrismaticEliteLimit.TryReserve())
			{
				report("A Prismatic enemy is already alive on this stage.");
				return;
			}
			flag = true;
			int num = 0;
			for (int i = 0; i < count; i++)
			{
				DirectorPlacementRule val4 = new DirectorPlacementRule
				{
					placementMode = (PlacementMode)1,
					position = body.footPosition,
					minDistance = 12f,
					maxDistance = 25f
				};
				DirectorSpawnRequest val5 = new DirectorSpawnRequest((SpawnCard)(object)val2, val4, RoR2Application.rng)
				{
					teamIndexOverride = (TeamIndex)2,
					ignoreTeamMemberLimit = true
				};
				if (Object.op_Implicit((Object)(object)DirectorCore.instance.TrySpawnObject(val5)))
				{
					num++;
				}
			}
			report("Spawned " + num + " Prismatic " + (text ?? "golem") + " (requested " + count + ").");
			if (num < count)
			{
				report("Could not find enough nearby spawn positions. Move to open ground and try again.");
			}
		}
		catch (Exception ex)
		{
			report("Prismatic spawn failed: " + ex.Message);
			Plugin.Log.LogError((object)ex);
		}
		finally
		{
			if (flag)
			{
				PrismaticEliteLimit.EndReservation();
			}
			if (Object.op_Implicit((Object)(object)val2))
			{
				Object.Destroy((Object)(object)val2);
			}
			if (val.IsValid())
			{
				Addressables.Release<CharacterSpawnCard>(val);
			}
		}
	}
}
public sealed class PlasmaContent : IContentPackProvider
{
	private readonly ContentPack pack = new ContentPack();

	public string identifier => "com.historysretribution.plasma";

	public IEnumerator LoadStaticContentAsync(LoadStaticContentAsyncArgs args)
	{
		typeof(ContentPack).GetProperty("identifier").SetValue(pack, identifier, null);
		AddLanguage();
		Plugin.Tracer = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Commando/TracerCommandoDefault.prefab").WaitForCompletion();
		Plugin.HitSpark = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Commando/HitsparkCommando.prefab").WaitForCompletion();
		try
		{
			Plugin.SwingMaterial = Addressables.LoadAssetAsync<Material>((object)"RoR2/Base/Loader/matLoaderSwingBasic.mat").WaitForCompletion();
		}
		catch (Exception ex)
		{
			Plugin.Log.LogWarning((object)("Plasma sweep material could not load; attacks will still animate: " + ex.Message));
		}
		Plugin.Output = Buff("PlasmaOutput", stack: true, new Color(0.55f, 0.95f, 1f), Plugin.Icon("Primary"));
		Plugin.Release = Buff("PlasmaRelease", stack: false, new Color(1f, 0.65f, 1f), Plugin.Icon("Special"));
		pack.buffDefs.Add((BuffDef[])(object)new BuffDef[2]
		{
			Plugin.Output,
			Plugin.Release
		});
		PrismaticElites.AddContent(pack);
		WishCrystals.AddContent(pack);
		GameObject val = Addressables.LoadAssetAsync<GameObject>((object)"RoR2/Base/Commando/CommandoBody.prefab").WaitForCompletion();
		GameObject val2 = PrefabAPI.InstantiateClone(val, "HRPlasmaBody", true);
		CharacterBody component = val2.GetComponent<CharacterBody>();
		component.baseNameToken = "HR_PLASMA_NAME";
		component.subtitleNameToken = "HR_PLASMA_SUBTITLE";
		component.baseMaxHealth = 110f;
		component.levelMaxHealth = 33f;
		component.baseRegen = 1f;
		component.levelRegen = 0.2f;
		component.baseDamage = 12f;
		component.levelDamage = 2.4f;
		component.baseMoveSpeed = 7f;
		component.baseArmor = 0f;
		component.bodyColor = new Color(0.65f, 0.9f, 1f);
		component.portraitIcon = (Texture)(object)Plugin.Icon("Portrait").texture;
		component.pr