Decompiled source of TerrariaCards v0.1.3

TerrariaCards.dll

Decompiled 10 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Text;
using BepInEx;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Photon.Pun;
using Photon.Realtime;
using Sonigon;
using TerrariaCards.Audio;
using TerrariaCards.Cards;
using TerrariaCards.Patches;
using TerrariaCards.Projectiles;
using TerrariaCards.Weapons;
using UnboundLib.Cards;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: AssemblyTitle("TerrariaCards")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("TerrariaCards")]
[assembly: AssemblyCopyright("Copyright ©  2026")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("3cee60c5-5186-424f-bd93-8773718078a0")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace TerrariaCards
{
	[BepInPlugin("com.terrariacards.rounds", "Terraria Cards", "0.1.2")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		private void Start()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			new Harmony("com.terrariacards.rounds").PatchAll();
			((Component)this).gameObject.AddComponent<CursedBurnNetwork>();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Terraria Cards v0.1.2 loaded successfully.");
			CustomCard.BuildCard<TerraBlade>();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Terra Blade registered!");
			CustomCard.BuildCard<Minishark>();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Minishark registered!");
			CustomCard.BuildCard<Megashark>();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Megashark registered!");
			CustomCard.BuildCard<LastPrism>();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Last Prism registered!");
			CustomCard.BuildCard<MeteorShot>();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Meteor Shot registered!");
			CustomCard.BuildCard<CrystalBullets>();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Crystal Bullets registered!");
			CustomCard.BuildCard<CursedBullets>();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Cursed Bullets registered!");
			CustomCard.BuildCard<ChlorophyteBullets>();
			CustomCard.BuildCard<DaedalusStormbow>();
		}
	}
}
namespace TerrariaCards.Weapons
{
	public class LastPrismController : MonoBehaviour, IOnEventCallback
	{
		private class BeamPathResult
		{
			public List<Vector3> points = new List<Vector3>();

			public bool hitSomething;

			public Vector3 hitPoint;

			public Vector3 hitNormal;
		}

		private static readonly ManualLogSource PrismLog = Logger.CreateLogSource("Last Prism");

		private GeneralInput input;

		private CharacterData data;

		private WeaponHandler weaponHandler;

		private float chargeTime;

		private const float MaxChargeTime = 3f;

		private const float BeamLength = 40f;

		private const float DamageInterval = 0.1f;

		private float damageTimer;

		private float slowTimer;

		private const float SlowInterval = 0.1f;

		private float knockbackTimer;

		private const float KnockbackInterval = 0.2f;

		private readonly Dictionary<Player, float> stunCooldowns = new Dictionary<Player, float>();

		private const float StunCooldown = 0.5f;

		private readonly Dictionary<Player, float> poisonCooldowns = new Dictionary<Player, float>();

		private readonly LineRenderer[] beams = (LineRenderer[])(object)new LineRenderer[6];

		private LineRenderer coreBeam;

		private LineRenderer outerBeam;

		private AudioSource prismAudio;

		private AudioClip prismSound;

		private AudioSource surgeAudio;

		private AudioClip surgeClip;

		private AudioSource shatterAudio;

		private AudioClip shatterClip;

		private AudioSource ambienceAudio;

		private AudioClip ambienceClip;

		private float ambienceFadeVolume;

		private const float AmbienceMaxVolume = 0.25f;

		private const float AmbienceFadeInSpeed = 1.5f;

		private const float AmbienceFadeOutSpeed = 2f;

		private float resonanceTimer;

		private float resonancePitch = 1f;

		private float resonancePitchTarget = 1f;

		private float resonanceVolume = 1f;

		private float resonanceVolumeTarget = 1f;

		private AudioSource crystalAudio;

		private AudioClip crystalChimeClip;

		private float crystalChimeTimer;

		private int crystalChimeIndex;

		private bool wasFullyCharged;

		private float chargeSurgeTimer;

		private const float ChargeSurgeDuration = 0.35f;

		private const float ChargeSurgeStrength = 0.65f;

		private GameObject muzzleGlowObject;

		private SpriteRenderer muzzleGlow;

		private Sprite muzzleGlowSprite;

		private Texture2D muzzleGlowTexture;

		private const int PrismParticleCount = 18;

		private readonly SpriteRenderer[] prismParticles = (SpriteRenderer[])(object)new SpriteRenderer[18];

		private readonly Transform[] prismParticleTransforms = (Transform[])(object)new Transform[18];

		private readonly float[] prismParticleOffsets = new float[18];

		private readonly float[] prismParticleSpeeds = new float[18];

		private float prismParticleTime;

		private Material beamMaterial;

		private SpriteRenderer chargeFlash;

		private Transform chargeFlashTransform;

		private SpriteRenderer shockwaveRing;

		private Transform shockwaveTransform;

		private float chargeFlashTimer;

		private const float ChargeFlashDuration = 0.4f;

		private Texture2D shockwaveTexture;

		private Sprite shockwaveSprite;

		private readonly GameObject[] impactEffects = (GameObject[])(object)new GameObject[6];

		private readonly SpriteRenderer[] impactRenderers = (SpriteRenderer[])(object)new SpriteRenderer[6];

		private const int SparksPerImpact = 6;

		private readonly SpriteRenderer[,] impactSparks = new SpriteRenderer[6, 6];

		private const int MaxVisualBounces = 10;

		private readonly SpriteRenderer[,] bounceGlows = new SpriteRenderer[6, 10];

		private const int SparksPerBounce = 4;

		private readonly SpriteRenderer[,,] bounceSparks = new SpriteRenderer[6, 10, 4];

		private const byte PrismStateEventCode = 175;

		private const float NetworkSendInterval = 0.08f;

		private const float NetworkStateTimeout = 0.45f;

		private bool networkIsFiring;

		private float networkChargeTime;

		private Vector3 networkAimDirection = Vector3.right;

		private Vector3 networkBeamOrigin = Vector3.zero;

		private float networkLastUpdateTime = -100f;

		private float networkSendTimer;

		private bool networkWasFiring;

		private void Awake()
		{
			input = ((Component)this).GetComponent<GeneralInput>();
			data = ((Component)this).GetComponent<CharacterData>();
			weaponHandler = ((Component)this).GetComponent<WeaponHandler>();
		}

		private void OnEnable()
		{
			PhotonNetwork.AddCallbackTarget((object)this);
		}

		private void OnDisable()
		{
			if (networkWasFiring)
			{
				BroadcastPrismState(isFiring: false);
			}
			PhotonNetwork.RemoveCallbackTarget((object)this);
		}

		private void Update()
		{
			UpdateAmbienceFade();
			if ((Object)(object)input == (Object)null || (Object)(object)data == (Object)null || (Object)(object)weaponHandler == (Object)null || (Object)(object)weaponHandler.gun == (Object)null)
			{
				HideBeams();
				return;
			}
			bool num = (Object)(object)GameManager.instance != (Object)null && GameManager.instance.battleOngoing && data.isPlaying && !data.dead && !data.isSilenced;
			bool flag = (Object)(object)data.view != (Object)null && data.view.IsMine;
			if (!flag && Time.realtimeSinceStartup - networkLastUpdateTime > 0.45f)
			{
				networkIsFiring = false;
			}
			bool flag2 = num && (flag ? input.shootIsPressed : networkIsFiring);
			if (flag)
			{
				BroadcastPrismState(flag2);
			}
			if (!flag2)
			{
				damageTimer = 0f;
				chargeTime = 0f;
				HideBeams();
				return;
			}
			if (flag)
			{
				chargeTime = Mathf.Min(chargeTime + TimeHandler.deltaTime, 3f);
			}
			else
			{
				chargeTime = Mathf.Clamp(networkChargeTime, 0f, 3f);
			}
			CreateBeams();
			UpdateBeams();
			if (!flag)
			{
				damageTimer = 0f;
				return;
			}
			Gun gun = weaponHandler.gun;
			float num2 = 0.3f / Mathf.Max(0.01f, gun.attackSpeed);
			num2 *= gun.attackSpeedMultiplier;
			num2 = Mathf.Clamp(num2, 0.25f, 4f);
			float num3 = 0.1f / num2;
			damageTimer += TimeHandler.deltaTime;
			int num4 = 0;
			slowTimer += TimeHandler.deltaTime;
			knockbackTimer += TimeHandler.deltaTime;
			while (damageTimer >= num3 && num4 < 4)
			{
				damageTimer -= num3;
				DetectLaserTargets();
				num4++;
			}
			damageTimer = Mathf.Min(damageTimer, num3 * 4f);
			if (slowTimer >= 0.1f)
			{
				slowTimer = 0f;
			}
			if (knockbackTimer >= 0.2f)
			{
				knockbackTimer = 0f;
			}
		}

		private void BroadcastPrismState(bool isFiring)
		{
			//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_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Expected O, but got Unknown
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0141: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			if (!PhotonNetwork.InRoom || PhotonNetwork.OfflineMode || (Object)(object)data == (Object)null || (Object)(object)data.view == (Object)null || !data.view.IsMine)
			{
				return;
			}
			bool flag = isFiring != networkWasFiring;
			networkSendTimer += Time.unscaledDeltaTime;
			if (!flag && (!isFiring || networkSendTimer < 0.08f))
			{
				return;
			}
			networkSendTimer = 0f;
			networkWasFiring = isFiring;
			Vector3 val = Vector3.zero;
			Vector3 val2 = Vector3.right;
			if ((Object)(object)weaponHandler != (Object)null && (Object)(object)weaponHandler.gun != (Object)null)
			{
				Gun gun = weaponHandler.gun;
				val = (((Object)(object)gun.shootPosition != (Object)null) ? gun.shootPosition.position : ((Component)gun).transform.position);
				val2 = (((Object)(object)gun.shootPosition != (Object)null) ? gun.shootPosition.forward : ((Component)gun).transform.up);
				val2.z = 0f;
				if (((Vector3)(ref val2)).sqrMagnitude < 0.001f)
				{
					val2 = ((Component)gun).transform.up;
					val2.z = 0f;
				}
				if (((Vector3)(ref val2)).sqrMagnitude > 0.001f)
				{
					((Vector3)(ref val2)).Normalize();
				}
				else
				{
					val2 = Vector3.right;
				}
			}
			object[] array = new object[8]
			{
				data.view.ViewID,
				isFiring,
				isFiring ? chargeTime : 0f,
				val2.x,
				val2.y,
				val.x,
				val.y,
				val.z
			};
			PhotonNetwork.RaiseEvent((byte)175, (object)array, new RaiseEventOptions
			{
				Receivers = (ReceiverGroup)0
			}, flag ? SendOptions.SendReliable : SendOptions.SendUnreliable);
		}

		public void OnEvent(EventData photonEvent)
		{
			//IL_0136: 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_0150: Unknown result type (might be due to invalid IL or missing references)
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01db: 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_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			if (photonEvent.Code != 175 || (Object)(object)data == (Object)null || (Object)(object)data.view == (Object)null || data.view.IsMine || !(photonEvent.CustomData is object[] array) || array.Length != 8 || !(array[0] is int) || !(array[1] is bool) || !(array[2] is float) || !(array[3] is float) || !(array[4] is float) || !(array[5] is float) || !(array[6] is float) || !(array[7] is float))
			{
				return;
			}
			int num = (int)array[0];
			if (data.view.ViewID != num || data.view.OwnerActorNr != photonEvent.Sender)
			{
				return;
			}
			float num2 = (float)array[2];
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor((float)array[3], (float)array[4], 0f);
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor((float)array[5], (float)array[6], (float)array[7]);
			if (!float.IsNaN(num2) && !float.IsInfinity(num2) && !float.IsNaN(val.x) && !float.IsInfinity(val.x) && !float.IsNaN(val.y) && !float.IsInfinity(val.y) && !float.IsNaN(val2.x) && !float.IsInfinity(val2.x) && !float.IsNaN(val2.y) && !float.IsInfinity(val2.y) && !float.IsNaN(val2.z) && !float.IsInfinity(val2.z))
			{
				if (((Vector3)(ref val)).sqrMagnitude > 0.001f)
				{
					networkAimDirection = ((Vector3)(ref val)).normalized;
				}
				networkBeamOrigin = val2;
				networkChargeTime = Mathf.Clamp(num2, 0f, 3f);
				networkIsFiring = (bool)array[1];
				networkLastUpdateTime = Time.realtimeSinceStartup;
			}
		}

		private void CreateBeams()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_017a: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: 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_01e3: Expected O, but got Unknown
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c7: Expected O, but got Unknown
			//IL_05a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05ae: Expected O, but got Unknown
			//IL_05fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0633: Unknown result type (might be due to invalid IL or missing references)
			//IL_0644: Unknown result type (might be due to invalid IL or missing references)
			//IL_064e: Unknown result type (might be due to invalid IL or missing references)
			//IL_069b: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_074e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0755: Expected O, but got Unknown
			//IL_07fe: 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)
			if ((Object)(object)beams[0] != (Object)null)
			{
				return;
			}
			Shader val = Shader.Find("Sprites/Default");
			beamMaterial = new Material(val);
			for (int i = 0; i < beams.Length; i++)
			{
				GameObject val2 = new GameObject("Last Prism Beam " + i);
				val2.transform.SetParent(((Component)this).transform);
				LineRenderer val3 = val2.AddComponent<LineRenderer>();
				((Renderer)val3).material = beamMaterial;
				val3.positionCount = 2;
				val3.useWorldSpace = true;
				((Renderer)val3).sortingOrder = 20;
				val3.startWidth = 0.09f;
				val3.endWidth = 0.09f;
				Color endColor = (val3.startColor = Color.HSVToRGB((float)i / 6f, 1f, 1f));
				val3.endColor = endColor;
				beams[i] = val3;
			}
			GameObject val5 = new GameObject("LastPrism_WhiteCore");
			val5.transform.SetParent(((Component)this).transform, false);
			coreBeam = val5.AddComponent<LineRenderer>();
			((Renderer)coreBeam).sortingOrder = 10;
			((Renderer)coreBeam).sortingLayerID = ((Renderer)beams[2]).sortingLayerID;
			((Renderer)coreBeam).material = beamMaterial;
			((Renderer)coreBeam).material.renderQueue = 3100;
			coreBeam.useWorldSpace = true;
			coreBeam.positionCount = 2;
			coreBeam.startColor = Color.white;
			coreBeam.endColor = Color.white;
			coreBeam.startWidth = 0.01f;
			coreBeam.endWidth = 0.01f;
			coreBeam.numCapVertices = 8;
			coreBeam.numCornerVertices = 8;
			((Renderer)coreBeam).enabled = false;
			GameObject val6 = new GameObject("LastPrism_RainbowOuter");
			val6.transform.SetParent(((Component)this).transform, false);
			outerBeam = val6.AddComponent<LineRenderer>();
			((Renderer)outerBeam).material = beamMaterial;
			outerBeam.useWorldSpace = true;
			outerBeam.positionCount = 2;
			outerBeam.startColor = Color.magenta;
			outerBeam.endColor = Color.cyan;
			outerBeam.startWidth = 0.01f;
			outerBeam.endWidth = 0.01f;
			outerBeam.numCapVertices = 8;
			outerBeam.numCornerVertices = 8;
			((Renderer)outerBeam).sortingLayerID = ((Renderer)coreBeam).sortingLayerID;
			((Renderer)outerBeam).sortingOrder = ((Renderer)coreBeam).sortingOrder - 1;
			((Renderer)outerBeam).enabled = false;
			GameObject val7 = new GameObject("LastPrism_Audio");
			val7.transform.SetParent(((Component)this).transform, false);
			prismAudio = val7.AddComponent<AudioSource>();
			prismAudio.playOnAwake = false;
			prismAudio.loop = true;
			prismAudio.spatialBlend = 0f;
			prismAudio.volume = 0.15f;
			prismAudio.pitch = 0.8f;
			int num = 44100;
			int num2 = num * 8;
			float[] array = new float[num2];
			for (int j = 0; j < num2; j++)
			{
				float num3 = (float)j / (float)num;
				float num4 = (float)Math.PI * 2f;
				float num5 = Mathf.Sin(num4 * 110f * num3) * 0.3f;
				float num6 = Mathf.Sin(num4 * 220f * num3) * 0.18f + Mathf.Sin(num4 * 330f * num3) * 0.12f;
				float num7 = Mathf.Sin(num4 * 660f * num3) * 0.09f + Mathf.Sin(num4 * 990f * num3) * 0.06f + Mathf.Sin(num4 * 1320f * num3) * 0.035f;
				float num8 = 0.6f + 0.18f * Mathf.Sin(num4 * 2.17f * num3) + 0.12f * Mathf.Sin(num4 * 3.71f * num3 + 1.3f) + 0.1f * Mathf.Sin(num4 * 5.23f * num3 + 2.1f);
				float num9 = 0.14f * Mathf.Sin(num4 * 1.37f * num3) + 0.09f * Mathf.Sin(num4 * 2.83f * num3 + 0.7f) + 0.06f * Mathf.Sin(num4 * 4.19f * num3 + 1.9f);
				float num10 = Mathf.Sin(num4 * (440f * num3 + num9)) * 0.08f;
				float num11 = num5 + num6 + num7 * num8 + num10;
				float num12 = 1f;
				float num13 = 0.03f;
				float num14 = (float)num2 / (float)num;
				if (num3 < num13)
				{
					num12 = Mathf.Clamp01(num3 / num13);
				}
				else if (num3 > num14 - num13)
				{
					num12 = Mathf.Clamp01((num14 - num3) / num13);
				}
				num11 *= num12;
				array[j] = Mathf.Clamp(num11 * 0.55f, -1f, 1f);
			}
			prismSound = AudioClip.Create("LastPrism_MagicalCharge", num2, 1, num, false);
			prismSound.SetData(array, 0);
			prismAudio.clip = prismSound;
			CreateMuzzleGlow();
			CreatePrismParticles();
			CreateChargeEffects();
			CreateCrystalChimes();
			CreateMagicalSurge();
			CreateMagicalShatter();
			CreateMagicalAmbience();
			for (int k = 0; k < beams.Length; k++)
			{
				GameObject val8 = new GameObject("PrismImpact_" + k);
				val8.transform.SetParent(((Component)this).transform);
				SpriteRenderer val9 = val8.AddComponent<SpriteRenderer>();
				val9.sprite = muzzleGlowSprite;
				((Renderer)val9).sortingLayerID = ((Renderer)muzzleGlow).sortingLayerID;
				((Renderer)val9).sortingOrder = ((Renderer)muzzleGlow).sortingOrder;
				val9.color = Color.white;
				val9.sprite = muzzleGlowSprite;
				((Renderer)val9).sortingLayerID = ((Renderer)coreBeam).sortingLayerID;
				((Renderer)val9).sortingOrder = 1000;
				val9.color = Color.white;
				val8.transform.localScale = Vector3.one * 0.35f;
				val8.SetActive(false);
				impactEffects[k] = val8;
				impactRenderers[k] = val9;
				for (int l = 0; l < 6; l++)
				{
					GameObject val10 = new GameObject("PrismImpact_Spark_" + k + "_" + l);
					val10.transform.SetParent(val8.transform, false);
					SpriteRenderer val11 = val10.AddComponent<SpriteRenderer>();
					val11.sprite = muzzleGlowSprite;
					((Renderer)val11).sortingLayerID = ((Renderer)val9).sortingLayerID;
					((Renderer)val11).sortingOrder = ((Renderer)val9).sortingOrder + 1;
					((Renderer)val11).enabled = false;
					impactSparks[k, l] = val11;
				}
			}
			for (int m = 0; m < beams.Length; m++)
			{
				for (int n = 0; n < 10; n++)
				{
					GameObject val12 = new GameObject("LastPrism_BounceGlow_" + m + "_" + n);
					val12.transform.SetParent(((Component)this).transform, false);
					SpriteRenderer val13 = val12.AddComponent<SpriteRenderer>();
					val13.sprite = muzzleGlowSprite;
					((Renderer)val13).sortingLayerID = ((Renderer)coreBeam).sortingLayerID;
					((Renderer)val13).sortingOrder = 1001;
					((Renderer)val13).enabled = false;
					bounceGlows[m, n] = val13;
					for (int num15 = 0; num15 < 4; num15++)
					{
						GameObject val14 = new GameObject("LastPrism_BounceSpark_" + m + "_" + n + "_" + num15);
						val14.transform.SetParent(val12.transform, false);
						SpriteRenderer val15 = val14.AddComponent<SpriteRenderer>();
						val15.sprite = muzzleGlowSprite;
						((Renderer)val15).sortingLayerID = ((Renderer)val13).sortingLayerID;
						((Renderer)val15).sortingOrder = ((Renderer)val13).sortingOrder + 1;
						((Renderer)val15).enabled = false;
						bounceSparks[m, n, num15] = val15;
					}
				}
			}
		}

		private void UpdateBeams()
		{
			//IL_002d: 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_0032: 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_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0437: Unknown result type (might be due to invalid IL or missing references)
			//IL_0438: Unknown result type (might be due to invalid IL or missing references)
			//IL_0476: Unknown result type (might be due to invalid IL or missing references)
			//IL_04d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_04de: Unknown result type (might be due to invalid IL or missing references)
			//IL_04f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0502: Unknown result type (might be due to invalid IL or missing references)
			//IL_08bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0813: 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_084e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0877: Unknown result type (might be due to invalid IL or missing references)
			//IL_087c: 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_06ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_0776: Unknown result type (might be due to invalid IL or missing references)
			//IL_077b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0792: Unknown result type (might be due to invalid IL or missing references)
			//IL_079f: Unknown result type (might be due to invalid IL or missing references)
			//IL_05cf: 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_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)
			Gun gun = weaponHandler.gun;
			Vector3 val = (((Object)(object)gun.shootPosition != (Object)null) ? gun.shootPosition.position : ((Component)gun).transform.position);
			Vector3 val2 = (((Object)(object)gun.shootPosition != (Object)null) ? gun.shootPosition.forward : ((Component)gun).transform.up);
			val2.z = 0f;
			if (((Vector3)(ref val2)).sqrMagnitude < 0.001f)
			{
				val2 = ((Component)gun).transform.up;
				val2.z = 0f;
			}
			((Vector3)(ref val2)).Normalize();
			if ((Object)(object)data != (Object)null && (Object)(object)data.view != (Object)null && !data.view.IsMine)
			{
				val = networkBeamOrigin;
				val2 = networkAimDirection;
			}
			float num = Mathf.Clamp01(chargeTime / 3f);
			float num2 = Mathf.SmoothStep(0f, 1f, num);
			if ((Object)(object)crystalAudio != (Object)null && (Object)(object)crystalChimeClip != (Object)null)
			{
				crystalChimeTimer -= TimeHandler.deltaTime;
				if (crystalChimeTimer <= 0f)
				{
					float[] array = new float[6] { 0.85f, 0.92f, 1f, 1.08f, 0.96f, 1.14f };
					crystalAudio.pitch = array[crystalChimeIndex];
					float num3 = Mathf.Lerp(0.04f, 0.09f, num2);
					float num4 = Mathf.SmoothStep(0f, 1f, Mathf.InverseLerp(0.9f, 1f, num));
					crystalAudio.volume = num3 * Mathf.Lerp(1f, 0.35f, num4);
					crystalAudio.PlayOneShot(crystalChimeClip);
					crystalChimeIndex = (crystalChimeIndex + 1) % array.Length;
					crystalChimeTimer = Mathf.Lerp(0.75f, 0.35f, num2);
				}
			}
			bool flag = num >= 0.999f;
			if (flag && !wasFullyCharged)
			{
				chargeSurgeTimer = 0.35f;
				chargeFlashTimer = 0.4f;
				if ((Object)(object)shatterAudio != (Object)null && (Object)(object)shatterClip != (Object)null)
				{
					shatterAudio.Stop();
					shatterAudio.pitch = 1f;
					shatterAudio.volume = 1f;
					shatterAudio.Play();
				}
			}
			wasFullyCharged = flag;
			if (chargeSurgeTimer > 0f)
			{
				chargeSurgeTimer = Mathf.Max(0f, chargeSurgeTimer - TimeHandler.deltaTime);
			}
			if (chargeFlashTimer > 0f)
			{
				chargeFlashTimer = Mathf.Max(0f, chargeFlashTimer - TimeHandler.deltaTime);
			}
			float num5 = chargeSurgeTimer / 0.35f;
			float num6 = num5 * num5;
			float num7 = (flag ? (Mathf.Sin(Time.time * 12f) * 0.06f) : 0f);
			if ((Object)(object)prismAudio != (Object)null && (Object)(object)data != (Object)null && data.isPlaying && !data.dead && (Object)(object)input != (Object)null && (((Object)(object)data.view != (Object)null && data.view.IsMine) ? input.shootIsPressed : networkIsFiring))
			{
				if (!prismAudio.isPlaying)
				{
					prismAudio.Play();
				}
				UpdateMagicalResonance(num2);
			}
			float num8 = Mathf.Lerp(25f, 0f, num2);
			float num9 = Mathf.Lerp(0.09f, 0.28f, num);
			for (int i = 0; i < beams.Length; i++)
			{
				float num10 = ((float)i - 2.5f) * num8 / 2.5f;
				Vector3 direction = Quaternion.Euler(0f, 0f, num10) * val2;
				LineRenderer obj = beams[i];
				((Renderer)obj).enabled = true;
				obj.startWidth = num9;
				obj.endWidth = num9;
				int maxBounces = Mathf.Clamp(weaponHandler.gun.reflects, 0, 10);
				BeamPathResult beamPathResult = CalculateBeamPath(val, direction, maxBounces);
				beams[i].positionCount = beamPathResult.points.Count;
				for (int j = 0; j < beamPathResult.points.Count; j++)
				{
					beams[i].SetPosition(j, beamPathResult.points[j]);
				}
				UpdateImpactEffect(i, beamPathResult, num);
				float num11 = Mathf.InverseLerp(0.65f, 1f, num);
				num11 = Mathf.SmoothStep(0f, 1f, num11);
				float a = 1f - num11;
				Color startColor = beams[i].startColor;
				startColor.a = a;
				beams[i].startColor = startColor;
				beams[i].endColor = startColor;
				UpdateBounceGlows(i, beamPathResult.points, num);
			}
			if ((Object)(object)coreBeam != (Object)null)
			{
				float num12 = Mathf.InverseLerp(0.35f, 1f, num);
				num12 = Mathf.SmoothStep(0f, 1f, num12);
				((Renderer)coreBeam).enabled = num12 > 0.01f;
				if (((Renderer)coreBeam).enabled)
				{
					LineRenderer val3 = beams[2];
					if ((Object)(object)val3 != (Object)null && val3.positionCount >= 2)
					{
						coreBeam.positionCount = val3.positionCount;
						for (int k = 0; k < val3.positionCount; k++)
						{
							coreBeam.SetPosition(k, val3.GetPosition(k));
						}
						float num13 = Mathf.Lerp(0.01f, 0.24f, num12);
						num13 *= 1f + num6 * 0.65f + num7;
						coreBeam.startWidth = num13;
						coreBeam.endWidth = num13;
						Color white = Color.white;
						white.a = num12;
						coreBeam.startColor = white;
						coreBeam.endColor = white;
					}
				}
			}
			if ((Object)(object)outerBeam != (Object)null && (Object)(object)coreBeam != (Object)null)
			{
				((Renderer)outerBeam).enabled = ((Renderer)coreBeam).enabled;
				if (((Renderer)outerBeam).enabled)
				{
					outerBeam.positionCount = coreBeam.positionCount;
					for (int l = 0; l < coreBeam.positionCount; l++)
					{
						outerBeam.SetPosition(l, coreBeam.GetPosition(l));
					}
					float num14 = Mathf.InverseLerp(0.35f, 1f, num);
					num14 = Mathf.SmoothStep(0f, 1f, num14);
					float num15 = Mathf.Lerp(0.02f, 0.5f, num14);
					num15 *= 1f + num6 * 0.97499996f + num7 * 1.5f;
					outerBeam.startWidth = num15;
					outerBeam.endWidth = num15;
					Color val4 = Color.HSVToRGB(Mathf.Repeat(Time.time * 0.25f, 1f), 1f, 1f);
					val4.a = num14 * 0.75f;
					outerBeam.startColor = val4;
					outerBeam.endColor = val4;
				}
			}
			if ((Object)(object)muzzleGlow != (Object)null)
			{
				float num16 = Mathf.SmoothStep(0f, 1f, num);
				float num17 = num6 * 1.4f;
				float num18 = (flag ? (1f + Mathf.Sin(Time.time * 12f) * 0.12f) : 1f);
				((Renderer)muzzleGlow).enabled = true;
				muzzleGlowObject.transform.position = val;
				float num19 = Mathf.Lerp(0.2f, 0.8f, num16);
				num19 *= (1f + num17) * num18;
				muzzleGlowObject.transform.localScale = Vector3.one * num19;
				Color color = Color.HSVToRGB(Mathf.Repeat(Time.time * 0.2f, 1f), 0.45f, 1f);
				color.a = Mathf.Lerp(0.35f, 0.95f, num16);
				muzzleGlow.color = color;
			}
			if ((Object)(object)muzzleGlowObject != (Object)null)
			{
				UpdatePrismParticles(muzzleGlowObject.transform.position, num, flag, num6);
			}
			if ((Object)(object)muzzleGlowObject != (Object)null)
			{
				UpdateChargeEffects(muzzleGlowObject.transform.position);
			}
			if (!((Object)(object)ambienceAudio != (Object)null) || !((Object)(object)ambienceClip != (Object)null))
			{
				return;
			}
			if (!ambienceAudio.isPlaying)
			{
				if (ambienceAudio.time > 0.01f)
				{
					ambienceAudio.UnPause();
				}
				else
				{
					ambienceAudio.Play();
				}
			}
			float num20 = Mathf.Lerp(0.06f, 0.25f, num2);
			ambienceFadeVolume = Mathf.MoveTowards(ambienceFadeVolume, num20, 1.5f * TimeHandler.deltaTime);
			ambienceAudio.volume = ambienceFadeVolume;
		}

		private void CreateMagicalSurge()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			GameObject val = new GameObject("LastPrism_MagicalSurge");
			val.transform.SetParent(((Component)this).transform, false);
			surgeAudio = val.AddComponent<AudioSource>();
			surgeAudio.playOnAwake = false;
			surgeAudio.loop = false;
			surgeAudio.spatialBlend = 0f;
			surgeAudio.volume = 0.4f;
			int num = Mathf.RoundToInt(66150f);
			float[] array = new float[num];
			Random random = new Random(438);
			float num2 = 0f;
			float num3 = 0f;
			for (int i = 0; i < num; i++)
			{
				float num4 = (float)i / 44100f;
				float num5 = (float)Math.PI * 2f;
				float num6 = Mathf.Clamp01(num4 / 0.008f) * Mathf.Exp((0f - num4) * 3f);
				float num7 = Mathf.Sin(num5 * (155f * num4 - 38f * num4 * num4)) * 0.8f;
				float num8 = Mathf.Sin(num5 * (70f * num4 - 12f * num4 * num4)) * 0.45f;
				float num9 = Mathf.Sin(num5 * 261.63f * num4) * 0.2f + Mathf.Sin(num5 * 523.25f * num4) * 0.18f + Mathf.Sin(num5 * 784f * num4) * 0.12f;
				float num10 = (float)(random.NextDouble() * 2.0 - 1.0);
				num2 += (num10 - num2) * 0.12f;
				num3 += (num10 - num3) * 0.008f;
				float num11 = (num2 - num3) * Mathf.Exp((0f - num4) * 4f) * 1.3f;
				float num12 = Mathf.Sin(num5 * (1046f * num4 + 0.2f * Mathf.Sin(num5 * 6f * num4))) * Mathf.Exp((0f - num4) * 2f) * 0.18f;
				float num13 = (num7 + num8 + num9 + num11 + num12) * num6;
				array[i] = (float)Math.Tanh(num13 * 0.8f);
			}
			surgeClip = AudioClip.Create("LastPrism_PowerfulSurge", num, 1, 44100, false);
			surgeClip.SetData(array, 0);
			surgeAudio.clip = surgeClip;
		}

		private void CreateMagicalShatter()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			GameObject val = new GameObject("LastPrism_CrystalShatter");
			val.transform.SetParent(((Component)this).transform, false);
			shatterAudio = val.AddComponent<AudioSource>();
			shatterAudio.playOnAwake = false;
			shatterAudio.loop = false;
			shatterAudio.spatialBlend = 0f;
			shatterAudio.volume = 0.2f;
			try
			{
				shatterClip = WavLoader.LoadEmbedded("TerrariaCards.Sounds.LastPrism_Shatter.wav");
				shatterAudio.clip = shatterClip;
				PrismLog.LogInfo((object)"[Last Prism] Embedded shatter sound loaded.");
			}
			catch (Exception ex)
			{
				PrismLog.LogError((object)("[Last Prism] Failed to load shatter: " + ex));
			}
		}

		private void UpdateMagicalResonance(float smoothCharge)
		{
			if (!((Object)(object)prismAudio == (Object)null))
			{
				float deltaTime = TimeHandler.deltaTime;
				resonanceTimer -= deltaTime;
				if (resonanceTimer <= 0f)
				{
					resonancePitchTarget = Random.Range(0.94f, 1.06f);
					resonanceVolumeTarget = Random.Range(0.88f, 1.12f);
					resonanceTimer = Random.Range(0.45f, 1.2f);
				}
				float num = 1f - Mathf.Exp((0f - deltaTime) * 3f);
				resonancePitch = Mathf.Lerp(resonancePitch, resonancePitchTarget, num);
				resonanceVolume = Mathf.Lerp(resonanceVolume, resonanceVolumeTarget, num);
				float num2 = Mathf.Lerp(0.85f, 1.3f, smoothCharge);
				float num3 = Mathf.Lerp(0.0035f, 0.09f, smoothCharge);
				float num4 = Mathf.Lerp(0.25f, 1f, smoothCharge);
				float num5 = Mathf.Lerp(1f, resonancePitch, num4);
				float num6 = Mathf.Lerp(1f, resonanceVolume, num4);
				prismAudio.pitch = num2 * num5;
				prismAudio.volume = num3 * num6;
			}
		}

		private void UpdateImpactEffect(int beamIndex, BeamPathResult result, float charge)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e6: 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_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0210: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0238: Unknown result type (might be due to invalid IL or missing references)
			//IL_0242: Unknown result type (might be due to invalid IL or missing references)
			//IL_0275: Unknown result type (might be due to invalid IL or missing references)
			//IL_027a: Unknown result type (might be due to invalid IL or missing references)
			//IL_029e: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = impactEffects[beamIndex];
			SpriteRenderer val2 = impactRenderers[beamIndex];
			if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
			{
				return;
			}
			if (!result.hitSomething)
			{
				val.SetActive(false);
				return;
			}
			val.SetActive(true);
			val.transform.position = result.hitPoint;
			float num = Mathf.Atan2(result.hitNormal.y, result.hitNormal.x) * 57.29578f;
			val.transform.rotation = Quaternion.Euler(0f, 0f, num);
			float num2 = 1f + Mathf.Sin(Time.time * 18f + (float)beamIndex) * 0.15f;
			float num3 = Mathf.Lerp(0.35f, 1.1f, charge) * num2;
			val.transform.localScale = Vector3.one * num3;
			Color color = Color.HSVToRGB(Mathf.Repeat(Time.time * 0.4f + (float)beamIndex / 6f, 1f), 0.45f, 1f);
			color.a = Mathf.Lerp(0.75f, 1f, charge);
			val2.color = color;
			for (int i = 0; i < 6; i++)
			{
				SpriteRenderer val3 = impactSparks[beamIndex, i];
				if (!((Object)(object)val3 == (Object)null))
				{
					float num4 = Mathf.Repeat(Time.time * (2f + (float)i * 0.18f) + (float)i / 6f + (float)beamIndex * 0.13f, 1f);
					float num5 = (float)i * (float)Math.PI * 2f / 6f + Mathf.Sin(Time.time * 2f + (float)i) * 0.25f;
					float num6 = Mathf.Lerp(0.08f, Mathf.Lerp(0.75f, 1.35f, charge), num4);
					Vector3 val4 = new Vector3(Mathf.Cos(num5), Mathf.Sin(num5), 0f) * num6;
					float num7 = Mathf.Max(0.01f, val.transform.localScale.x);
					((Component)val3).transform.localPosition = val4 / num7;
					float num8 = Mathf.Lerp(0.2f, 0.035f, num4);
					((Component)val3).transform.localScale = Vector3.one * (num8 / num7);
					Color color2 = Color.HSVToRGB(Mathf.Repeat(Time.time * 0.2f + (float)i / 6f, 1f), 0.8f, 1f);
					color2.a = (1f - num4) * Mathf.Lerp(0.6f, 1f, charge);
					val3.color = color2;
					((Renderer)val3).enabled = true;
				}
			}
		}

		private void UpdateBounceGlows(int beamIndex, List<Vector3> beamPoints, float charge)
		{
			//IL_0092: 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_00e3: 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_013d: Unknown result type (might be due to invalid IL or missing references)
			if (beamPoints == null)
			{
				return;
			}
			int num = Mathf.Min(beamPoints.Count - 2, 10);
			for (int i = 0; i < 10; i++)
			{
				SpriteRenderer val = bounceGlows[beamIndex, i];
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				if (i >= num)
				{
					((Renderer)val).enabled = false;
					for (int j = 0; j < 4; j++)
					{
						if ((Object)(object)bounceSparks[beamIndex, i, j] != (Object)null)
						{
							((Renderer)bounceSparks[beamIndex, i, j]).enabled = false;
						}
					}
				}
				else
				{
					((Renderer)val).enabled = true;
					((Component)val).transform.position = beamPoints[i + 1];
					float num2 = 1f + Mathf.Sin(Time.time * 16f + (float)i * 1.5f) * 0.12f;
					float num3 = Mathf.Lerp(0.28f, 0.94f, charge) * num2;
					((Component)val).transform.localScale = Vector3.one * num3;
					Color color = Color.HSVToRGB(Mathf.Repeat(Time.time * 0.3f + (float)beamIndex / 6f + (float)i * 0.1f, 1f), 0.55f, 1f);
					color.a = Mathf.Lerp(0.8f, 1f, charge);
					val.color = color;
					UpdateBounceSparks(beamIndex, i, charge, num3);
				}
			}
		}

		private void HideBeams()
		{
			//IL_0039: 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_0092: 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)
			for (int i = 0; i < beams.Length; i++)
			{
				if ((Object)(object)beams[i] != (Object)null)
				{
					((Renderer)beams[i]).enabled = false;
					beams[i].positionCount = 2;
					beams[i].SetPosition(0, Vector3.zero);
					beams[i].SetPosition(1, Vector3.zero);
				}
			}
			if ((Object)(object)coreBeam != (Object)null)
			{
				((Renderer)coreBeam).enabled = false;
				coreBeam.positionCount = 2;
				coreBeam.SetPosition(0, Vector3.zero);
				coreBeam.SetPosition(1, Vector3.zero);
			}
			if ((Object)(object)outerBeam != (Object)null)
			{
				((Renderer)outerBeam).enabled = false;
				outerBeam.positionCount = 0;
			}
			if ((Object)(object)prismAudio != (Object)null && prismAudio.isPlaying)
			{
				prismAudio.Stop();
			}
			if ((Object)(object)crystalAudio != (Object)null)
			{
				crystalAudio.Stop();
			}
			crystalChimeTimer = 0f;
			crystalChimeIndex = 0;
			wasFullyCharged = false;
			chargeSurgeTimer = 0f;
			if ((Object)(object)muzzleGlow != (Object)null)
			{
				((Renderer)muzzleGlow).enabled = false;
			}
			for (int j = 0; j < 18; j++)
			{
				if ((Object)(object)prismParticles[j] != (Object)null)
				{
					((Renderer)prismParticles[j]).enabled = false;
				}
			}
			prismParticleTime = 0f;
			chargeFlashTimer = 0f;
			if ((Object)(object)chargeFlash != (Object)null)
			{
				((Renderer)chargeFlash).enabled = false;
			}
			if ((Object)(object)shockwaveRing != (Object)null)
			{
				((Renderer)shockwaveRing).enabled = false;
			}
			HideImpactEffects();
			for (int k = 0; k < beams.Length; k++)
			{
				for (int l = 0; l < 10; l++)
				{
					if ((Object)(object)bounceGlows[k, l] != (Object)null)
					{
						((Renderer)bounceGlows[k, l]).enabled = false;
					}
					for (int m = 0; m < 4; m++)
					{
						if ((Object)(object)bounceSparks[k, l, m] != (Object)null)
						{
							((Renderer)bounceSparks[k, l, m]).enabled = false;
						}
					}
				}
			}
			resonanceTimer = 0f;
			resonancePitch = 1f;
			resonancePitchTarget = 1f;
			resonanceVolume = 1f;
			resonanceVolumeTarget = 1f;
			if ((Object)(object)surgeAudio != (Object)null && surgeAudio.isPlaying)
			{
				surgeAudio.Stop();
			}
			if ((Object)(object)shatterAudio != (Object)null && shatterAudio.isPlaying)
			{
				shatterAudio.Stop();
			}
		}

		private void HideImpactEffects()
		{
			for (int i = 0; i < impactEffects.Length; i++)
			{
				if ((Object)(object)impactEffects[i] != (Object)null)
				{
					impactEffects[i].SetActive(false);
				}
			}
		}

		private BeamPathResult CalculateBeamPath(Vector3 origin, Vector3 direction, int maxBounces)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: 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_00fb: 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)
			//IL_0105: 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_00a6: 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_0127: 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_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: 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_014d: Unknown result type (might be due to invalid IL or missing references)
			BeamPathResult beamPathResult = new BeamPathResult();
			beamPathResult.points.Add(origin);
			Vector2 val = Vector2.op_Implicit(origin);
			Vector2 val2 = Vector2.op_Implicit(direction);
			Vector2 normalized = ((Vector2)(ref val2)).normalized;
			float num = 40f;
			for (int i = 0; i <= maxBounces; i++)
			{
				RaycastHit2D[] array = Physics2D.RaycastAll(val, normalized, num);
				float num2 = num;
				RaycastHit2D val3 = default(RaycastHit2D);
				bool flag = false;
				RaycastHit2D[] array2 = array;
				for (int j = 0; j < array2.Length; j++)
				{
					RaycastHit2D val4 = array2[j];
					if (!((Object)(object)((RaycastHit2D)(ref val4)).collider == (Object)null) && !((RaycastHit2D)(ref val4)).collider.isTrigger && !((Object)(object)((Component)((RaycastHit2D)(ref val4)).collider).GetComponentInParent<Player>() != (Object)null) && ((RaycastHit2D)(ref val4)).distance < num2)
					{
						num2 = ((RaycastHit2D)(ref val4)).distance;
						val3 = val4;
						flag = true;
					}
				}
				Vector2 val5 = val + normalized * num2;
				beamPathResult.points.Add(Vector2.op_Implicit(val5));
				num -= num2;
				if (flag)
				{
					beamPathResult.hitSomething = true;
					beamPathResult.hitPoint = Vector2.op_Implicit(val5);
					beamPathResult.hitNormal = Vector2.op_Implicit(((RaycastHit2D)(ref val3)).normal);
				}
				else
				{
					beamPathResult.hitSomething = false;
				}
				if (!flag || i >= maxBounces || num <= 0.01f)
				{
					break;
				}
				val2 = Vector2.Reflect(normalized, ((RaycastHit2D)(ref val3)).normal);
				normalized = ((Vector2)(ref val2)).normalized;
				val = val5 + normalized * 0.01f;
				num -= 0.01f;
			}
			return beamPathResult;
		}

		private void DetectLaserTargets()
		{
			//IL_0082: 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_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_00c5: 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_0207: Unknown result type (might be due to invalid IL or missing references)
			//IL_020e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0213: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_0220: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0203: 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_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_0285: Unknown result type (might be due to invalid IL or missing references)
			//IL_035c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_036f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0374: Unknown result type (might be due to invalid IL or missing references)
			//IL_0389: Unknown result type (might be due to invalid IL or missing references)
			Player component = ((Component)this).GetComponent<Player>();
			if ((Object)(object)component == (Object)null || (Object)(object)component.data == (Object)null || (Object)(object)component.data.view == (Object)null || !component.data.view.IsMine)
			{
				return;
			}
			HashSet<Player> hashSet = new HashSet<Player>();
			LineRenderer[] array = beams;
			foreach (LineRenderer val in array)
			{
				if ((Object)(object)val == (Object)null || !((Renderer)val).enabled)
				{
					continue;
				}
				for (int j = 0; j < val.positionCount - 1; j++)
				{
					Vector2 val2 = Vector2.op_Implicit(val.GetPosition(j));
					Vector2 val3 = Vector2.op_Implicit(val.GetPosition(j + 1)) - val2;
					float magnitude = ((Vector2)(ref val3)).magnitude;
					if (magnitude < 0.001f)
					{
						continue;
					}
					Vector2 normalized = ((Vector2)(ref val3)).normalized;
					RaycastHit2D[] array2 = Physics2D.RaycastAll(val2, normalized, magnitude);
					for (int k = 0; k < array2.Length; k++)
					{
						RaycastHit2D val4 = array2[k];
						if (!((Object)(object)((RaycastHit2D)(ref val4)).collider == (Object)null))
						{
							Player componentInParent = ((Component)((RaycastHit2D)(ref val4)).collider).GetComponentInParent<Player>();
							if (!((Object)(object)componentInParent == (Object)null) && !((Object)(object)componentInParent == (Object)(object)component) && !((Object)(object)componentInParent.data == (Object)null) && !componentInParent.data.dead)
							{
								hashSet.Add(componentInParent);
							}
						}
					}
				}
			}
			foreach (Player item in hashSet)
			{
				HealthHandler component2 = ((Component)item).GetComponent<HealthHandler>();
				if ((Object)(object)component2 == (Object)null)
				{
					continue;
				}
				float num = Mathf.Clamp01(chargeTime / 3f);
				float num2 = Mathf.Lerp(1f, 2.5f, num) * weaponHandler.gun.damage;
				Vector2 val5 = Vector2.op_Implicit(((Component)item).transform.position - ((Component)component).transform.position);
				if (((Vector2)(ref val5)).sqrMagnitude < 0.001f)
				{
					val5 = Vector2.right;
				}
				Vector2 val6 = ((Vector2)(ref val5)).normalized * num2;
				((Damagable)component2).CallTakeDamage(val6, Vector2.op_Implicit(((Component)item).transform.position), ((Component)weaponHandler.gun).gameObject, component, true);
				if (knockbackTimer >= 0.2f)
				{
					float knockback = weaponHandler.gun.knockback;
					if (knockback > 0f)
					{
						Vector2 val7 = ((Vector2)(ref val5)).normalized * knockback * 20f;
						component2.CallTakeForce(val7, (ForceMode2D)1, false, false, 0f);
					}
				}
				ObjectsToSpawn[] objectsToSpawn;
				if (PhotonNetwork.OfflineMode && weaponHandler.gun.objectsToSpawn != null)
				{
					RayHitPoison val8 = null;
					objectsToSpawn = weaponHandler.gun.objectsToSpawn;
					foreach (ObjectsToSpawn val9 in objectsToSpawn)
					{
						if (val9 != null && !((Object)(object)val9.AddToProjectile == (Object)null))
						{
							val8 = val9.AddToProjectile.GetComponentInChildren<RayHitPoison>(true);
							if ((Object)(object)val8 != (Object)null)
							{
								break;
							}
						}
					}
					if ((Object)(object)val8 != (Object)null && (!poisonCooldowns.TryGetValue(item, out var value) || Time.time >= value))
					{
						DamageOverTime component3 = ((Component)item).GetComponent<DamageOverTime>();
						if ((Object)(object)component3 != (Object)null)
						{
							float num3 = num2 * 5f;
							component3.TakeDamageOverTime(((Vector2)(ref val5)).normalized * num3, Vector2.op_Implicit(((Component)item).transform.position), val8.time, val8.interval, val8.color, (SoundEvent)null, ((Component)weaponHandler.gun).gameObject, component, true);
							poisonCooldowns[item] = Time.time + Mathf.Max(0.1f, val8.time);
						}
					}
				}
				float slow = weaponHandler.gun.slow;
				if (slow > 0f && slowTimer >= 0.1f && (Object)(object)item.data != (Object)null && (Object)(object)item.data.view != (Object)null && (Object)(object)item.data.block != (Object)null && !item.data.block.IsBlocking())
				{
					item.data.view.RPC("RPCA_AddSlow", (RpcTarget)0, new object[2] { slow, false });
				}
				if (!PhotonNetwork.OfflineMode || weaponHandler.gun.objectsToSpawn == null)
				{
					continue;
				}
				objectsToSpawn = weaponHandler.gun.objectsToSpawn;
				foreach (ObjectsToSpawn val10 in objectsToSpawn)
				{
					if (val10 == null || (Object)(object)val10.effect == (Object)null)
					{
						continue;
					}
					StunPlayer componentInChildren = val10.effect.GetComponentInChildren<StunPlayer>(true);
					if ((Object)(object)componentInChildren == (Object)null)
					{
						continue;
					}
					if ((!stunCooldowns.TryGetValue(item, out var value2) || Time.time >= value2) && (Object)(object)item.data != (Object)null && (Object)(object)item.data.stunHandler != (Object)null)
					{
						float num4 = Mathf.Clamp(componentInChildren.time, 0f, 0.3f);
						if (num4 > 0f)
						{
							item.data.stunHandler.AddStun(num4);
							stunCooldowns[item] = Time.time + 0.5f;
						}
					}
					break;
				}
			}
		}

		private void UpdateBounceSparks(int beamIndex, int bounceIndex, float charge, float glowScale)
		{
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: 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_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: 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_0154: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			float num = Mathf.Max(0.01f, glowScale);
			for (int i = 0; i < 4; i++)
			{
				SpriteRenderer val = bounceSparks[beamIndex, bounceIndex, i];
				if (!((Object)(object)val == (Object)null))
				{
					float num2 = Mathf.Repeat(Time.time * (1.8f + (float)i * 0.15f) + (float)i / 4f + (float)bounceIndex * 0.17f + (float)beamIndex * 0.11f, 1f);
					float num3 = (float)i * (float)Math.PI * 2f / 4f + (float)bounceIndex * 0.7f + Mathf.Sin(Time.time * 3f + (float)i) * 0.3f;
					float num4 = Mathf.Lerp(0.04f, Mathf.Lerp(0.3f, 0.65f, charge), num2);
					Vector3 val2 = new Vector3(Mathf.Cos(num3), Mathf.Sin(num3), 0f) * num4;
					((Component)val).transform.localPosition = val2 / num;
					float num5 = Mathf.Lerp(0.12f, 0.025f, num2);
					((Component)val).transform.localScale = Vector3.one * (num5 / num);
					Color color = Color.HSVToRGB(Mathf.Repeat(Time.time * 0.25f + (float)i / 4f + (float)beamIndex / 6f, 1f), 0.85f, 1f);
					color.a = (1f - num2) * Mathf.Lerp(0.55f, 0.95f, charge);
					val.color = color;
					((Renderer)val).enabled = true;
				}
			}
		}

		private void CreateMuzzleGlow()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Expected O, but got Unknown
			//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Expected O, but got Unknown
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: 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_009f: Unknown result type (might be due to invalid IL or missing references)
			muzzleGlowTexture = new Texture2D(64, 64, (TextureFormat)4, false);
			((Texture)muzzleGlowTexture).filterMode = (FilterMode)1;
			((Texture)muzzleGlowTexture).wrapMode = (TextureWrapMode)1;
			Color[] array = (Color[])(object)new Color[4096];
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(31.5f, 31.5f);
			float num = 32f;
			for (int i = 0; i < 64; i++)
			{
				for (int j = 0; j < 64; j++)
				{
					float num2 = Vector2.Distance(new Vector2((float)j, (float)i), val) / num;
					float num3 = Mathf.Pow(Mathf.Clamp01(1f - num2), 2f);
					array[i * 64 + j] = new Color(1f, 1f, 1f, num3);
				}
			}
			muzzleGlowTexture.SetPixels(array);
			muzzleGlowTexture.Apply();
			muzzleGlowSprite = Sprite.Create(muzzleGlowTexture, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 64f);
			muzzleGlowObject = new GameObject("LastPrism_MuzzleGlow");
			muzzleGlowObject.transform.SetParent(((Component)this).transform, false);
			muzzleGlow = muzzleGlowObject.AddComponent<SpriteRenderer>();
			muzzleGlow.sprite = muzzleGlowSprite;
			((Renderer)muzzleGlow).sortingLayerID = ((Renderer)coreBeam).sortingLayerID;
			((Renderer)muzzleGlow).sortingOrder = ((Renderer)coreBeam).sortingOrder + 1;
			((Renderer)muzzleGlow).enabled = false;
		}

		private void CreateChargeEffects()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			GameObject val = new GameObject("LastPrism_ChargeFlash");
			val.transform.SetParent(((Component)this).transform, false);
			chargeFlashTransform = val.transform;
			chargeFlash = val.AddComponent<SpriteRenderer>();
			chargeFlash.sprite = muzzleGlowSprite;
			((Renderer)chargeFlash).sortingLayerID = ((Renderer)muzzleGlow).sortingLayerID;
			((Renderer)chargeFlash).sortingOrder = ((Renderer)muzzleGlow).sortingOrder + 1;
			((Renderer)chargeFlash).enabled = false;
			GameObject val2 = new GameObject("LastPrism_Shockwave");
			val2.transform.SetParent(((Component)this).transform, false);
			shockwaveTransform = val2.transform;
			shockwaveRing = val2.AddComponent<SpriteRenderer>();
			shockwaveRing.sprite = CreateShockwaveSprite();
			((Renderer)shockwaveRing).sortingLayerID = ((Renderer)muzzleGlow).sortingLayerID;
			((Renderer)shockwaveRing).sortingOrder = ((Renderer)muzzleGlow).sortingOrder - 1;
			((Renderer)shockwaveRing).enabled = false;
		}

		private void CreatePrismParticles()
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			for (int i = 0; i < 18; i++)
			{
				GameObject val = new GameObject("LastPrism_Particle_" + i);
				val.transform.SetParent(((Component)this).transform, false);
				SpriteRenderer val2 = val.AddComponent<SpriteRenderer>();
				val2.sprite = muzzleGlowSprite;
				((Renderer)val2).sortingLayerID = ((Renderer)muzzleGlow).sortingLayerID;
				((Renderer)val2).sortingOrder = ((Renderer)muzzleGlow).sortingOrder - 1;
				((Renderer)val2).enabled = false;
				prismParticles[i] = val2;
				prismParticleTransforms[i] = val.transform;
				prismParticleOffsets[i] = (float)i / 18f;
				prismParticleSpeeds[i] = 0.7f + (float)(i % 5) * 0.12f;
			}
		}

		private void UpdatePrismParticles(Vector3 muzzlePosition, float charge, bool fullyCharged, float surgeStrength)
		{
			//IL_00c5: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_015f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			prismParticleTime += TimeHandler.deltaTime;
			float num = Mathf.SmoothStep(0f, 1f, charge);
			for (int i = 0; i < 18; i++)
			{
				SpriteRenderer val = prismParticles[i];
				if (!((Object)(object)val == (Object)null))
				{
					float num2 = Mathf.Repeat(prismParticleTime * prismParticleSpeeds[i] + prismParticleOffsets[i], 1f);
					float num3 = Mathf.Lerp(1.3f, 0.08f, num2);
					float num4 = (float)i / 18f;
					((Renderer)val).enabled = fullyCharged || num > num4;
					if (((Renderer)val).enabled)
					{
						float num5 = num2 * (float)Math.PI * 4f + (float)i * 2.39996f;
						Vector3 val2 = new Vector3(Mathf.Cos(num5), Mathf.Sin(num5), 0f) * num3;
						val2 *= 1f + surgeStrength * 1.6f;
						Transform obj = prismParticleTransforms[i];
						obj.position = muzzlePosition + val2;
						float num6 = Mathf.Lerp(0.07f, 0.025f, num2);
						num6 *= 1f + surgeStrength * 1.8f;
						obj.localScale = Vector3.one * num6;
						Color color = Color.HSVToRGB(Mathf.Repeat(prismParticleTime * 0.18f + prismParticleOffsets[i], 1f), 0.8f, 1f);
						color.a = Mathf.Sin(num2 * (float)Math.PI) * Mathf.Lerp(0.45f, 0.95f, num);
						val.color = color;
					}
				}
			}
		}

		private void UpdateChargeEffects(Vector3 muzzlePosition)
		{
			//IL_007c: 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_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			if (chargeFlashTimer <= 0f)
			{
				if ((Object)(object)chargeFlash != (Object)null)
				{
					((Renderer)chargeFlash).enabled = false;
				}
				if ((Object)(object)shockwaveRing != (Object)null)
				{
					((Renderer)shockwaveRing).enabled = false;
				}
				return;
			}
			float num = 1f - chargeFlashTimer / 0.4f;
			num = Mathf.Clamp01(num);
			if ((Object)(object)chargeFlash != (Object)null)
			{
				((Renderer)chargeFlash).enabled = true;
				chargeFlashTransform.position = muzzlePosition;
				float num2 = Mathf.Lerp(0.4f, 1.8f, Mathf.Sin(num * (float)Math.PI));
				chargeFlashTransform.localScale = Vector3.one * num2;
				Color white = Color.white;
				white.a = (1f - num) * 0.95f;
				chargeFlash.color = white;
			}
			if ((Object)(object)shockwaveRing != (Object)null)
			{
				((Renderer)shockwaveRing).enabled = true;
				shockwaveTransform.position = muzzlePosition;
				float num3 = Mathf.Lerp(0.2f, 2.5f, num);
				shockwaveTransform.localScale = Vector3.one * num3;
				Color color = Color.HSVToRGB(Mathf.Repeat(Time.time * 0.6f, 1f), 0.75f, 1f);
				color.a = Mathf.Pow(1f - num, 1.5f) * 0.85f;
				shockwaveRing.color = color;
			}
		}

		private Sprite CreateShockwaveSprite()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_00ff: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			shockwaveTexture = new Texture2D(128, 128, (TextureFormat)4, false);
			((Texture)shockwaveTexture).filterMode = (FilterMode)1;
			((Texture)shockwaveTexture).wrapMode = (TextureWrapMode)1;
			Color[] array = (Color[])(object)new Color[16384];
			Vector2 val = default(Vector2);
			((Vector2)(ref val))..ctor(63.5f, 63.5f);
			float num = 64f;
			for (int i = 0; i < 128; i++)
			{
				for (int j = 0; j < 128; j++)
				{
					float num2 = Mathf.Abs(Vector2.Distance(new Vector2((float)j, (float)i), val) / num - 0.75f);
					float num3 = Mathf.Exp((0f - num2) * num2 * 500f);
					array[i * 128 + j] = new Color(1f, 1f, 1f, num3);
				}
			}
			shockwaveTexture.SetPixels(array);
			shockwaveTexture.Apply();
			shockwaveSprite = Sprite.Create(shockwaveTexture, new Rect(0f, 0f, 128f, 128f), new Vector2(0.5f, 0.5f), 128f);
			return shockwaveSprite;
		}

		private void CreateCrystalChimes()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			GameObject val = new GameObject("LastPrism_MagicalWhooshes");
			val.transform.SetParent(((Component)this).transform, false);
			crystalAudio = val.AddComponent<AudioSource>();
			crystalAudio.playOnAwake = false;
			crystalAudio.loop = false;
			crystalAudio.spatialBlend = 0f;
			crystalAudio.volume = 0.15f;
			int num = Mathf.RoundToInt(37485f);
			float[] array = new float[num];
			Random random = new Random(436);
			float num2 = 0f;
			float num3 = 0f;
			for (int i = 0; i < num; i++)
			{
				float num4 = (float)i / 44100f;
				float num5 = num4 / 0.85f;
				float num6 = (float)Math.PI * 2f;
				float num7 = Mathf.Pow(Mathf.Sin((float)Math.PI * num5), 1.5f);
				float num8 = (float)(random.NextDouble() * 2.0 - 1.0);
				num2 += (num8 - num2) * 0.08f;
				num3 += (num8 - num3) * 0.006f;
				float num9 = num2 - num3;
				float num10 = Mathf.Sin(num6 * (130f * num4 + 130f * num4 * num4)) * 0.25f;
				float num11 = Mathf.Sin(num6 * (390f * num4 + 40f * num4 * num4)) * 0.12f;
				float num12 = (num9 * 1.7f + num10 + num11) * num7;
				array[i] = Mathf.Clamp(num12 * 0.65f, -1f, 1f);
			}
			crystalChimeClip = AudioClip.Create("LastPrism_MagicalWhoosh", num, 1, 44100, false);
			crystalChimeClip.SetData(array, 0);
			crystalAudio.clip = crystalChimeClip;
		}

		private void CreateMagicalAmbience()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Expected O, but got Unknown
			GameObject val = new GameObject("LastPrism_MagicalAmbience");
			val.transform.SetParent(((Component)this).transform, false);
			ambienceAudio = val.AddComponent<AudioSource>();
			ambienceAudio.playOnAwake = false;
			ambienceAudio.loop = true;
			ambienceAudio.spatialBlend = 0f;
			ambienceAudio.volume = 0f;
			try
			{
				ambienceClip = WavLoader.LoadEmbedded("TerrariaCards.Sounds.LastPrism_Ambience.wav");
				ambienceAudio.clip = ambienceClip;
				PrismLog.LogInfo((object)"[Last Prism] Magical ambience loaded.");
			}
			catch (Exception ex)
			{
				PrismLog.LogError((object)("[Last Prism] Failed to load ambience: " + ex));
			}
		}

		private void UpdateAmbienceFade()
		{
			if (!((Object)(object)ambienceAudio == (Object)null) && !((Object)(object)ambienceClip == (Object)null) && (!((Object)(object)input != (Object)null) || !((Object)(object)data != (Object)null) || !((Object)(object)weaponHandler != (Object)null) || !((Object)(object)weaponHandler.gun != (Object)null) || !((Object)(object)GameManager.instance != (Object)null) || !GameManager.instance.battleOngoing || !data.isPlaying || data.dead || data.isSilenced || !(((Object)(object)data.view != (Object)null && data.view.IsMine) ? input.shootIsPressed : networkIsFiring)))
			{
				ambienceFadeVolume = Mathf.MoveTowards(ambienceFadeVolume, 0f, 2f * TimeHandler.deltaTime);
				ambienceAudio.volume = ambienceFadeVolume;
				if (ambienceFadeVolume <= 0.001f && ambienceAudio.isPlaying)
				{
					ambienceAudio.Pause();
				}
			}
		}

		private void OnDestroy()
		{
			if ((Object)(object)beamMaterial != (Object)null)
			{
				Object.Destroy((Object)(object)beamMaterial);
			}
			if ((Object)(object)prismSound != (Object)null)
			{
				Object.Destroy((Object)(object)prismSound);
			}
			if ((Object)(object)muzzleGlowSprite != (Object)null)
			{
				Object.Destroy((Object)(object)muzzleGlowSprite);
			}
			if ((Object)(object)muzzleGlowTexture != (Object)null)
			{
				Object.Destroy((Object)(object)muzzleGlowTexture);
			}
			if ((Object)(object)shockwaveSprite != (Object)null)
			{
				Object.Destroy((Object)(object)shockwaveSprite);
			}
			if ((Object)(object)shockwaveTexture != (Object)null)
			{
				Object.Destroy((Object)(object)shockwaveTexture);
			}
			if ((Object)(object)crystalChimeClip != (Object)null)
			{
				Object.Destroy((Object)(object)crystalChimeClip);
				crystalChimeClip = null;
			}
			if ((Object)(object)shatterClip != (Object)null)
			{
				Object.Destroy((Object)(object)shatterClip);
				shatterClip = null;
			}
			if ((Object)(object)ambienceClip != (Object)null)
			{
				Object.Destroy((Object)(object)ambienceClip);
				ambienceClip = null;
			}
			if ((Object)(object)surgeClip != (Object)null)
			{
				Object.Destroy((Object)(object)surgeClip);
				surgeClip = null;
			}
		}
	}
	public class LastPrismMarker : MonoBehaviour
	{
	}
}
namespace TerrariaCards.Projectiles
{
	public class ChlorophyteHoming : MonoBehaviour
	{
		private const float TargetRange = 14f;

		private const float TurnDegreesPerSecond = 220f;

		private const float MaxDeviationDegrees = 65f;

		private const float RetargetInterval = 0.08f;

		private const float MinimumSpeed = 0.1f;

		private Vector3 originalDirection;

		private bool directionCaptured;

		private ProjectileHit projectile;

		private MoveTransform movement;

		private Player target;

		private float retargetTimer;

		private void Update()
		{
			//IL_011b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: 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_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01de: 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_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)projectile == (Object)null)
			{
				projectile = ((Component)this).GetComponentInParent<ProjectileHit>();
			}
			if ((Object)(object)movement == (Object)null)
			{
				movement = ((Component)this).GetComponentInParent<MoveTransform>();
			}
			if ((Object)(object)projectile == (Object)null || (Object)(object)movement == (Object)null)
			{
				return;
			}
			Player ownPlayer = projectile.ownPlayer;
			if ((Object)(object)ownPlayer == (Object)null || (Object)(object)ownPlayer.data == (Object)null || (Object)(object)ownPlayer.data.view == (Object)null || !ownPlayer.data.view.IsMine || (Object)(object)GameManager.instance == (Object)null || !GameManager.instance.battleOngoing)
			{
				return;
			}
			float deltaTime = TimeHandler.deltaTime;
			if (deltaTime <= 0f)
			{
				return;
			}
			retargetTimer -= deltaTime;
			if (retargetTimer <= 0f || !IsValidTarget(ownPlayer, target))
			{
				target = FindNearestEnemy(ownPlayer);
				retargetTimer = 0.08f;
			}
			if ((Object)(object)target == (Object)null)
			{
				return;
			}
			Vector3 velocity = movement.velocity;
			velocity.z = 0f;
			float magnitude = ((Vector3)(ref velocity)).magnitude;
			if (!(magnitude < 0.1f))
			{
				if (!directionCaptured)
				{
					originalDirection = ((Vector3)(ref velocity)).normalized;
					directionCaptured = true;
				}
				Vector3 val = ((Component)target).transform.position - ((Component)movement).transform.position;
				val.z = 0f;
				if (!(((Vector3)(ref val)).sqrMagnitude < 0.01f))
				{
					Vector3 val2 = Vector3.RotateTowards(originalDirection, ((Vector3)(ref val)).normalized, (float)Math.PI * 13f / 36f, 0f);
					Vector3 val3 = Vector3.RotateTowards(((Vector3)(ref velocity)).normalized, val2, 3.8397243f * deltaTime, 0f);
					movement.velocity = ((Vector3)(ref val3)).normalized * magnitude;
					movement.velocity = ((Vector3)(ref val3)).normalized * magnitude;
				}
			}
		}

		private bool IsValidTarget(Player owner, Player candidate)
		{
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)candidate == (Object)null || (Object)(object)candidate == (Object)(object)owner || (Object)(object)candidate.data == (Object)null || candidate.data.dead || !candidate.data.isPlaying)
			{
				return false;
			}
			if (candidate.teamID == owner.teamID)
			{
				return false;
			}
			Vector3 val = ((Component)candidate).transform.position - ((Component)movement).transform.position;
			val.z = 0f;
			return ((Vector3)(ref val)).sqrMagnitude <= 196f;
		}

		private Player FindNearestEnemy(Player owner)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: 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)
			Player result = null;
			float num = 196f;
			Player[] array = Object.FindObjectsOfType<Player>();
			foreach (Player val in array)
			{
				if (IsValidTarget(owner, val))
				{
					Vector3 val2 = ((Component)val).transform.position - ((Component)movement).transform.position;
					val2.z = 0f;
					float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
					if (sqrMagnitude < num)
					{
						num = sqrMagnitude;
						result = val;
					}
				}
			}
			return result;
		}
	}
	public class ChlorophyteVisuals : MonoBehaviour
	{
		private static Sprite sharedGlowSprite;

		private static Material sharedMaterial;

		private ProjectileHit projectile;

		private GameObject effectObject;

		private SpriteRenderer glow;

		private SpriteRenderer core;

		private TrailRenderer trail;

		private void LateUpdate()
		{
			//IL_0057: 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_0074: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)projectile == (Object)null)
			{
				projectile = ((Component)this).GetComponentInParent<ProjectileHit>();
			}
			if (!((Object)(object)projectile == (Object)null))
			{
				if ((Object)(object)effectObject == (Object)null)
				{
					CreateVisuals();
				}
				if (!((Object)(object)effectObject == (Object)null))
				{
					Vector3 position = ((Component)projectile).transform.position;
					position.z = -5f;
					effectObject.transform.position = position;
				}
			}
		}

		private static void EnsureSharedAssets()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Expected O, but got Unknown
			//IL_00cf: 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_0095: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)sharedGlowSprite == (Object)null)
			{
				Texture2D val = new Texture2D(64, 64, (TextureFormat)4, false);
				((Texture)val).wrapMode = (TextureWrapMode)1;
				((Texture)val).filterMode = (FilterMode)1;
				for (int i = 0; i < 64; i++)
				{
					for (int j = 0; j < 64; j++)
					{
						float num = ((float)j + 0.5f - 32f) / 32f;
						float num2 = ((float)i + 0.5f - 32f) / 32f;
						float num3 = Mathf.Sqrt(num * num + num2 * num2);
						float num4 = Mathf.Pow(Mathf.Clamp01(1f - num3), 1.5f);
						val.SetPixel(j, i, new Color(1f, 1f, 1f, num4));
					}
				}
				val.Apply();
				sharedGlowSprite = Sprite.Create(val, new Rect(0f, 0f, 64f, 64f), new Vector2(0.5f, 0.5f), 64f);
			}
			if ((Object)(object)sharedMaterial == (Object)null)
			{
				Shader val2 = Shader.Find("Sprites/Default");
				if ((Object)(object)val2 != (Object)null)
				{
					sharedMaterial = new Material(val2);
					sharedMaterial.mainTexture = (Texture)(object)Texture2D.whiteTexture;
				}
			}
		}

		private void CreateVisuals()
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Expected O, but got Unknown
			//IL_0159: 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_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Expected O, but got Unknown
			//IL_0264: Unknown result type (might be due to invalid IL or missing references)
			//IL_026e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0273: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_02b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0300: Unknown result type (might be due to invalid IL or missing references)
			//IL_0305: Unknown result type (might be due to invalid IL or missing references)
			EnsureSharedAssets();
			if (!((Object)(object)sharedGlowSprite == (Object)null) && !((Object)(object)sharedMaterial == (Object)null))
			{
				effectObject = new GameObject("TerrariaCards_ChlorophyteVisual");
				effectObject.transform.SetParent(((Component)this).transform, false);
				Vector3 position = ((Component)projectile).transform.position;
				position.z = -5f;
				effectObject.transform.position = position;
				GameObject val = new GameObject("ChlorophyteGlow");
				val.transform.SetParent(effectObject.transform, false);
				glow = val.AddComponent<SpriteRenderer>();
				glow.sprite = sharedGlowSprite;
				glow.color = new Color(0.18f, 1f, 0.05f, 0.85f);
				((Renderer)glow).sortingOrder = 1001;
				val.transform.localScale = Vector3.one * 0.85f;
				GameObject val2 = new GameObject("ChlorophyteCore");
				val2.transform.SetParent(effectObject.transform, false);
				core = val2.AddComponent<SpriteRenderer>();
				core.sprite = sharedGlowSprite;
				core.color = new Color(0.3f, 1f, 0.05f, 1f);
				((Renderer)core).sortingOrder = 1002;
				val2.transform.localScale = Vector3.one * 0.45f;
				trail = effectObject.AddComponent<TrailRenderer>();
				((Renderer)trail).sharedMaterial = sharedMaterial;
				trail.time = 0.18f;
				trail.startWidth = 0.26f;
				trail.endWidth = 0.02f;
				trail.minVertexDistance = 0.035f;
				trail.numCapVertices = 3;
				trail.numCornerVertices = 3;
				trail.alignment = (LineAlignment)0;
				trail.textureMode = (LineTextureMode)0;
				((Renderer)trail).sortingOrder = 1000;
				trail.autodestruct = false;
				trail.emitting = true;
				Gradient val3 = new Gradient();
				val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[3]
				{
					new GradientColorKey(new Color(0.35f, 1f, 0.08f), 0f),
					new GradientColorKey(new Color(0.15f, 0.95f, 0.05f), 0.5f),
					new GradientColorKey(new Color(0.02f, 0.4f, 0.02f), 1f)
				}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
				{
					new GradientAlphaKey(0.95f, 0f),
					new GradientAlphaKey(0.65f, 0.5f),
					new GradientAlphaKey(0f, 1f)
				});
				trail.colorGradient = val3;
				trail.Clear();
			}
		}
	}
	public class CrystalBulletHitEffect : RayHitEffect
	{
		private float lastImpactTime = -10f;

		public override HasToReturn DoHitEffect(HitInfo hit)
		{
			//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)
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: 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)
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0118: Unknown result type (might be due to invalid IL or missing references)
			if (!(Time.time - lastImpactTime < 0.04f))
			{
				lastImpactTime = Time.time;
				ProjectileHit componentInParent = ((Component)this).GetComponentInParent<ProjectileHit>();
				Player val = (((Object)(object)componentInParent != (Object)null) ? componentInParent.ownPlayer : null);
				GameObject val2 = (((Object)(object)componentInParent != (Object)null) ? componentInParent.ownWeapon : null);
				float damage = (((Object)(object)componentInParent != (Object)null) ? (componentInParent.damage * 0.15f) : 0f);
				bool canDealDamage = (Object)(object)val != (Object)null && (Object)(object)val.data != (Object)null && (Object)(object)val.data.view != (Object)null && val.data.view.IsMine && (Object)(object)val2 != (Object)null;
				Vector2 val3 = hit.normal;
				if (((Vector2)(ref val3)).sqrMagnitude < 0.001f)
				{
					val3 = Vector2.up;
				}
				((Vector2)(ref val3)).Normalize();
				for (int i = 0; i < 3; i++)
				{
					float num = (float)(i - 1) * 35f;
					Vector2 direction = Vector2.op_Implicit(Quaternion.Euler(0f, 0f, num) * Vector2.op_Implicit(val3));
					CreateFragment(Vector2.op_Implicit(hit.point), direction, i, val, val2, damage, canDealDamage);
				}
				return (HasToReturn)1;
			}
			return (HasToReturn)1;
		}

		private void CreateFragment(Vector3 position, Vector2 direction, int index, Player owner, GameObject weapon, float damage, bool canDealDamage)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: 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_0012: 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_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = new GameObject("CrystalBullet_Fragment");
			val.transform.position = position + Vector2.op_Implicit(direction) * 0.06f;
			val.AddComponent<CrystalFragmentVisual>().Initialize(direction, index, owner, weapon, damage, canDealDamage);
		}
	}
	public class CrystalFragmentVisual : MonoBehaviour
	{
		private Vector2 direction;

		private LineRenderer line;

		private Material fragmentMaterial;

		private Player owner;

		private GameObject weapon;

		private float damage;

		private bool canDealDamage;

		private bool hasHitPlayer;

		private const float Lifetime = 0.22f;

		private const float Range = 1.5f;

		private float age;

		private Vector3 startPosition;

		private Vector3 previousTip;

		public void Initialize(Vector2 fragmentDirection, int index, Player fragmentOwner, GameObject sourceWeapon, float fragmentDamage, bool authoritative)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: 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_010e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_013a: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Expected O, but got Unknown
			direction = ((Vector2)(ref fragmentDirection)).normalized;
			owner = fragmentOwner;
			weapon = sourceWeapon;
			damage = fragmentDamage;
			canDealDamage = authoritative;
			startPosition = ((Component)this).transform.position;
			previousTip = startPosition;
			line = ((Component)this).gameObject.AddComponent<LineRenderer>();
			Shader val = Shader.Find("Sprites/Default");
			if ((Object)(object)val != (Object)null)
			{
				fragmentMaterial = new Material(val);
				((Renderer)line).material = fragmentMaterial;
			}
			line.useWorldSpace = true;
			line.positionCount = 2;
			line.startWidth = 0.1f;
			line.endWidth = 0.025f;
			line.numCapVertices = 4;
			((Renderer)line).sortingOrder = 100;
			Color[] array = (Color[])(object)new Color[3]
			{
				new Color(0.3f, 1f, 1f),
				new Color(0.6f, 0.6f, 1f),
				new Color(1f, 0.4f, 1f)
			};
			Color startColor = array[index % array.Length];
			line.startColor = startColor;
			line.endColor = Color.white;
			line.SetPosition(0, startPosition);
			line.SetPosition(1, startPosition);
		}

		private void Update()
		{
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: 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_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: 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_00eb: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)line == (Object)null))
			{
				age += TimeHandler.deltaTime;
				float num = Mathf.Clamp01(age / 0.22f);
				Vector3 val = startPosition + Vector2.op_Implicit(direction) * (num * 1.5f);
				if (canDealDamage && !hasHitPlayer)
				{
					CheckFragmentCollision(previousTip, val);
				}
				previousTip = val;
				Vector3 val2 = Vector3.Lerp(startPosition, val, 0.65f);
				line.SetPosition(0, val2);
				line.SetPosition(1, val);
				float a = 1f - num;
				Color startColor = line.startColor;
				startColor.a = a;
				line.startColor = startColor;
				Color endColor = line.endColor;
				endColor.a = a;
				line.endColor = endColor;
				if (age >= 0.22f)
				{
					Object.Destroy((Object)(object)((Component)this).gameObject);
				}
			}
		}

		private void CheckFragmentCollision(Vector3 from, Vector3 to)
		{
			//IL_002a: 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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: 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)
			if ((Object)(object)owner == (Object)null || (Object)(object)weapon == (Object)null || damage <= 0f)
			{
				return;
			}
			Vector2 val = Vector2.op_Implicit(to - from);
			float magnitude = ((Vector2)(ref val)).magnitude;
			if (magnitude < 0.0001f)
			{
				return;
			}
			RaycastHit2D[] array = Physics2D.RaycastAll(Vector2.op_Implicit(from), ((Vector2)(ref val)).normalized, magnitude);
			Array.Sort(array, (RaycastHit2D a, RaycastHit2D b) => ((RaycastHit2D)(ref a)).distance.CompareTo(((RaycastHit2D)(ref b)).distance));
			RaycastHit2D[] array2 = array;
			for (int num = 0; num < array2.Length; num++)
			{
				RaycastHit2D val2 = array2[num];
				if ((Object)(object)((RaycastHit2D)(ref val2)).collider == (Object)null || ((RaycastHit2D)(ref val2)).collider.isTrigger)
				{
					continue;
				}
				Player componentInParent = ((Component)((RaycastHit2D)(ref val2)).collider).GetComponentInParent<Player>();
				if ((Object)(object)componentInParent == (Object)(object)owner)
				{
					continue;
				}
				if ((Object)(object)componentInParent == (Object)null)
				{
					hasHitPlayer = true;
					break;
				}
				if (!((Object)(object)componentInParent.data == (Object)null) && !componentInParent.data.dead)
				{
					HealthHandler component = ((Component)componentInParent).GetComponent<HealthHandler>();
					if (!((Object)(object)component == (Object)null))
					{
						Vector2 val3 = ((Vector2)(ref direction)).normalized * damage;
						((Damagable)component).CallTakeDamage(val3, ((RaycastHit2D)(ref val2