Decompiled source of SunBeamMod v1.0.2

SunBeamSpell.dll

Decompiled 5 days ago
using System;
using System.Collections;
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 BepInEx;
using BepInEx.Logging;
using BlackMagicAPI.Enums;
using BlackMagicAPI.Helpers;
using BlackMagicAPI.Managers;
using BlackMagicAPI.Modules.Spells;
using Microsoft.CodeAnalysis;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: AssemblyTitle("SunBeamSpell")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("SunBeamSpell")]
[assembly: AssemblyCopyright("Copyright ©  2025")]
[assembly: AssemblyTrademark("")]
[assembly: ComVisible(false)]
[assembly: Guid("060b1387-58f9-4cc1-8199-8b2405df8a89")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyVersion("1.0.0.0")]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
}
namespace SunBeamMod
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "SunBeamMod";

		public const string PLUGIN_NAME = "SunBeamMod";

		public const string PLUGIN_VERSION = "1.0.0";
	}
	[BepInPlugin("SunBeamMod", "SunBeamMod", "1.0.0")]
	[BepInProcess("MageArena.exe")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class SunBeamPlugin : BaseUnityPlugin
	{
		internal static ManualLogSource Logger;

		public static SunBeamPlugin Instance;

		public static string modsync = "all";

		private void Awake()
		{
			Logger = ((BaseUnityPlugin)this).Logger;
			Logger.LogInfo((object)"ModSync found! Initializing mod...");
			Instance = this;
			SpellManager.RegisterSpell((BaseUnityPlugin)(object)this, typeof(SunBeamSpellData), typeof(SunBeamSpellLogic));
			Logger.LogInfo((object)"Plugin SunBeamMod is loaded!");
			Logger.LogInfo((object)"[Sun Beam] Test Message - Mod is loading with v1.5.0 dependencies!");
		}
	}
	internal class SunBeamSpellData : SpellData
	{
		public override SpellType SpellType => (SpellType)0;

		public override string Name => "Sun Beam";

		public override float Cooldown => 25f;

		public override Color GlowColor => Color.red;

		public override bool CanSpawnInTeamChest => false;

		public override Texture2D? GetMainTexture()
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			string text = Path.Combine(directoryName, "SunBeam_Main.png");
			Texture2D val = Utils.LoadTextureFromDisk(text);
			if ((Object)(object)val == (Object)null)
			{
				SunBeamPlugin.Logger.LogWarning((object)"[Sun Beam] Main texture not found on disk - trying embedded.");
				val = Utils.LoadTextureFromResources(Assembly.GetExecutingAssembly(), "SunBeamMod.Resources.SunBeamMain.png");
			}
			if ((Object)(object)val == (Object)null)
			{
				SunBeamPlugin.Logger.LogWarning((object)"[Sun Beam] No texture found - using fallback.");
				return new Texture2D(1, 1);
			}
			return val;
		}

		public override Texture2D? GetEmissionTexture()
		{
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Expected O, but got Unknown
			string directoryName = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
			string text = Path.Combine(directoryName, "SunBeam_Emission.png");
			Texture2D val = Utils.LoadTextureFromDisk(text);
			if ((Object)(object)val == (Object)null)
			{
				SunBeamPlugin.Logger.LogWarning((object)"[Sun Beam] Emission texture not found on disk - trying embedded.");
				val = Utils.LoadTextureFromResources(Assembly.GetExecutingAssembly(), "SunBeamMod.Resources.SunBeamEmission.png");
			}
			if ((Object)(object)val == (Object)null)
			{
				SunBeamPlugin.Logger.LogWarning((object)"[Sun Beam] No emission texture found - using fallback.");
				return new Texture2D(1, 1);
			}
			return val;
		}
	}
	internal class SunBeamSpellLogic : SpellLogic
	{
		[CompilerGenerated]
		private sealed class <CreateBeam>d__3 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public GameObject casterObj;

			public Vector3 targetPoint;

			public SunBeamSpellLogic <>4__this;

			private string <modPath>5__1;

			private string <diskSoundPath>5__2;

			private Vector3 <skyPosition>5__3;

			private GameObject <beam>5__4;

			private Renderer <renderer>5__5;

			private Material <material>5__6;

			private string <texturePath>5__7;

			private ParticleSystem <outerParticles>5__8;

			private MainModule <outerMain>5__9;

			private EmissionModule <outerEmission>5__10;

			private ShapeModule <outerShape>5__11;

			private ParticleSystemRenderer <outerRendererParticle>5__12;

			private Material <outerParticleMaterial>5__13;

			private GameObject <fogObject>5__14;

			private ParticleSystem <fogParticles>5__15;

			private MainModule <fogMain>5__16;

			private EmissionModule <fogEmission>5__17;

			private ShapeModule <fogShape>5__18;

			private ParticleSystemRenderer <fogRendererParticle>5__19;

			private Material <fogParticleMaterial>5__20;

			private Vector3 <initialScale>5__21;

			private Vector3 <finalScale>5__22;

			private float <duration>5__23;

			private float <elapsed>5__24;

			private Texture2D <texture>5__25;

			private Texture2D <gradientTexture>5__26;

			private int <y>5__27;

			private float <alpha>5__28;

			private float <t>5__29;

			private Collider[] <hits>5__30;

			private Collider[] <>s__31;

			private int <>s__32;

			private Collider <col>5__33;

			private PlayerMovement <player>5__34;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <CreateBeam>d__3(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				//IL_0037: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: Unknown result type (might be due to invalid IL or missing references)
				//IL_004f: Unknown result type (might be due to invalid IL or missing references)
				//IL_0077: Unknown result type (might be due to invalid IL or missing references)
				//IL_0083: 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)
				<modPath>5__1 = null;
				<diskSoundPath>5__2 = null;
				<beam>5__4 = null;
				<renderer>5__5 = null;
				<material>5__6 = null;
				<texturePath>5__7 = null;
				<outerParticles>5__8 = null;
				<outerMain>5__9 = default(MainModule);
				<outerEmission>5__10 = default(EmissionModule);
				<outerShape>5__11 = default(ShapeModule);
				<outerRendererParticle>5__12 = null;
				<outerParticleMaterial>5__13 = null;
				<fogObject>5__14 = null;
				<fogParticles>5__15 = null;
				<fogMain>5__16 = default(MainModule);
				<fogEmission>5__17 = default(EmissionModule);
				<fogShape>5__18 = default(ShapeModule);
				<fogRendererParticle>5__19 = null;
				<fogParticleMaterial>5__20 = null;
				<texture>5__25 = null;
				<gradientTexture>5__26 = null;
				<hits>5__30 = null;
				<>s__31 = null;
				<col>5__33 = null;
				<player>5__34 = null;
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Expected O, but got Unknown
				//IL_0184: Unknown result type (might be due to invalid IL or missing references)
				//IL_0189: Unknown result type (might be due to invalid IL or missing references)
				//IL_0193: Unknown result type (might be due to invalid IL or missing references)
				//IL_0198: 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_01ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_01bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ce: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_0168: Unknown result type (might be due to invalid IL or missing references)
				//IL_0172: Expected O, but got Unknown
				//IL_023a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0244: Expected O, but got Unknown
				//IL_013d: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
				//IL_00da: Unknown result type (might be due to invalid IL or missing references)
				//IL_00df: Unknown result type (might be due to invalid IL or missing references)
				//IL_033d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0347: Expected O, but got Unknown
				//IL_07ed: Unknown result type (might be due to invalid IL or missing references)
				//IL_07f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_07fe: Unknown result type (might be due to invalid IL or missing references)
				//IL_0833: Unknown result type (might be due to invalid IL or missing references)
				//IL_0849: Unknown result type (might be due to invalid IL or missing references)
				//IL_0861: Unknown result type (might be due to invalid IL or missing references)
				//IL_0871: Unknown result type (might be due to invalid IL or missing references)
				//IL_0395: Unknown result type (might be due to invalid IL or missing references)
				//IL_0416: Unknown result type (might be due to invalid IL or missing references)
				//IL_041b: Unknown result type (might be due to invalid IL or missing references)
				//IL_042b: Unknown result type (might be due to invalid IL or missing references)
				//IL_0441: Unknown result type (might be due to invalid IL or missing references)
				//IL_0457: Unknown result type (might be due to invalid IL or missing references)
				//IL_047c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0481: Unknown result type (might be due to invalid IL or missing references)
				//IL_04b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_04c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_04cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_04dc: Unknown result type (might be due to invalid IL or missing references)
				//IL_04ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_04f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_055e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0568: Expected O, but got Unknown
				//IL_0582: Unknown result type (might be due to invalid IL or missing references)
				//IL_05b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_05bb: Expected O, but got Unknown
				//IL_05c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_05ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_05ef: Unknown result type (might be due to invalid IL or missing references)
				//IL_05ff: Unknown result type (might be due to invalid IL or missing references)
				//IL_061a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0630: Unknown result type (might be due to invalid IL or missing references)
				//IL_0655: Unknown result type (might be due to invalid IL or missing references)
				//IL_065a: Unknown result type (might be due to invalid IL or missing references)
				//IL_068e: Unknown result type (might be due to invalid IL or missing references)
				//IL_06a0: Unknown result type (might be due to invalid IL or missing references)
				//IL_06a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_06b5: Unknown result type (might be due to invalid IL or missing references)
				//IL_06c7: Unknown result type (might be due to invalid IL or missing references)
				//IL_06cc: Unknown result type (might be due to invalid IL or missing references)
				//IL_06f3: Unknown result type (might be due to invalid IL or missing references)
				//IL_0735: Unknown result type (might be due to invalid IL or missing references)
				//IL_073f: Expected O, but got Unknown
				//IL_0759: 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_0797: Unknown result type (might be due to invalid IL or missing references)
				//IL_079e: Unknown result type (might be due to invalid IL or missing references)
				//IL_07a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_07ad: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<modPath>5__1 = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
					<>2__current = (object)new WaitForSeconds(1f);
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					<diskSoundPath>5__2 = Path.Combine(<modPath>5__1, "SunBeam.wav");
					if (File.Exists(<diskSoundPath>5__2))
					{
						beamSound = Utils.LoadWavFromDisk(<diskSoundPath>5__2);
						if ((Object)(object)beamSound != (Object)null)
						{
							PlaySpatialSoundAtPosition(targetPoint, beamSound);
							ManualLogSource logger = SunBeamPlugin.Logger;
							Vector3 val = targetPoint;
							logger.LogInfo((object)("[Sun Beam] Sound started 0.5s before beam at: " + ((object)(Vector3)(ref val)).ToString()));
						}
						else
						{
							SunBeamPlugin.Logger.LogWarning((object)("[Sun Beam] Invalid WAV file at: " + <diskSoundPath>5__2 + " - skipping."));
						}
					}
					else if (!isLoading)
					{
						isLoading = true;
						<>2__current = ((MonoBehaviour)<>4__this).StartCoroutine(LoadAndPlaySound(targetPoint));
						<>1__state = 2;
						return true;
					}
					goto IL_0162;
				case 2:
					<>1__state = -1;
					goto IL_0162;
				case 3:
					<>1__state = -1;
					<skyPosition>5__3 = targetPoint + Vector3.up * 100f;
					<beam>5__4 = GameObject.CreatePrimitive((PrimitiveType)2);
					<beam>5__4.transform.position = targetPoint + Vector3.up * 50f;
					<beam>5__4.transform.localScale = new Vector3(10f, 50f, 10f);
					<beam>5__4.GetComponent<Collider>().isTrigger = true;
					<renderer>5__5 = <beam>5__4.GetComponent<Renderer>();
					<material>5__6 = new Material(Shader.Find("HDRP/Unlit") ?? Shader.Find("Unlit/Color"));
					<material>5__6.SetFloat("_SurfaceType", 1f);
					<material>5__6.EnableKeyword("_SURFACE_TYPE_TRANSPARENT");
					<material>5__6.renderQueue = 3000;
					<material>5__6.SetInt("_Cull", 0);
					<texturePath>5__7 = Path.Combine(<modPath>5__1, "SunBeam_BeamTexture.png");
					if (File.Exists(<texturePath>5__7))
					{
						<texture>5__25 = Utils.LoadTextureFromDisk(<texturePath>5__7);
						if ((Object)(object)<texture>5__25 != (Object)null)
						{
							<material>5__6.mainTexture = (Texture)(object)<texture>5__25;
							SunBeamPlugin.Logger.LogInfo((object)("[Sun Beam] Applied beam texture from: " + <texturePath>5__7));
						}
						<texture>5__25 = null;
					}
					else
					{
						SunBeamPlugin.Logger.LogWarning((object)("[Sun Beam] Beam texture file not found at: " + <texturePath>5__7 + " - using gradient."));
						<gradientTexture>5__26 = new Texture2D(1, 256);
						<y>5__27 = 0;
						while (<y>5__27 < 256)
						{
							<alpha>5__28 = Mathf.Lerp(0.5f, 0f, (float)<y>5__27 / 255f);
							<gradientTexture>5__26.SetPixel(0, <y>5__27, new Color(1f, 1f, 0f, <alpha>5__28));
							<y>5__27++;
						}
						<gradientTexture>5__26.Apply();
						<material>5__6.mainTexture = (Texture)(object)<gradientTexture>5__26;
						<gradientTexture>5__26 = null;
					}
					<renderer>5__5.material = <material>5__6;
					<outerParticles>5__8 = <beam>5__4.AddComponent<ParticleSystem>();
					<outerMain>5__9 = <outerParticles>5__8.main;
					((MainModule)(ref <outerMain>5__9)).startLifetime = MinMaxCurve.op_Implicit(5f);
					((MainModule)(ref <outerMain>5__9)).startSpeed = MinMaxCurve.op_Implicit(-5f);
					((MainModule)(ref <outerMain>5__9)).startSize = MinMaxCurve.op_Implicit(0.02f);
					((MainModule)(ref <outerMain>5__9)).startColor = MinMaxGradient.op_Implicit(new Color(1f, 0.8f, 0f, 0.7f));
					((MainModule)(ref <outerMain>5__9)).maxParticles = 1500;
					((MainModule)(ref <outerMain>5__9)).simulationSpace = (ParticleSystemSimulationSpace)1;
					((MainModule)(ref <outerMain>5__9)).gravityModifier = MinMaxCurve.op_Implicit(0.5f);
					<outerEmission>5__10 = <outerParticles>5__8.emission;
					((EmissionModule)(ref <outerEmission>5__10)).rateOverTime = MinMaxCurve.op_Implicit(300f);
					<outerShape>5__11 = <outerParticles>5__8.shape;
					((ShapeModule)(ref <outerShape>5__11)).shapeType = (ParticleSystemShapeType)4;
					((ShapeModule)(ref <outerShape>5__11)).angle = 10f;
					((ShapeModule)(ref <outerShape>5__11)).radius = 3f;
					<outerRendererParticle>5__12 = ((Component)<outerParticles>5__8).GetComponent<ParticleSystemRenderer>();
					<outerRendererParticle>5__12.renderMode = (ParticleSystemRenderMode)0;
					<outerParticleMaterial>5__13 = new Material(Shader.Find("Legacy Shaders/Particles/Alpha Blended Premultiply") ?? Shader.Find("Unlit/Color"));
					<outerParticleMaterial>5__13.color = new Color(1f, 0.8f, 0f, 0.7f);
					((Renderer)<outerRendererParticle>5__12).material = <outerParticleMaterial>5__13;
					<outerParticles>5__8.Play();
					<fogObject>5__14 = new GameObject("SunBeamFog");
					<fogObject>5__14.transform.position = targetPoint;
					<fogParticles>5__15 = <fogObject>5__14.AddComponent<ParticleSystem>();
					<fogMain>5__16 = <fogParticles>5__15.main;
					((MainModule)(ref <fogMain>5__16)).startLifetime = MinMaxCurve.op_Implicit(5f);
					((MainModule)(ref <fogMain>5__16)).startSpeed = new MinMaxCurve(0f, 0.1f);
					((MainModule)(ref <fogMain>5__16)).startSize = MinMaxCurve.op_Implicit(0.8f);
					((MainModule)(ref <fogMain>5__16)).startColor = MinMaxGradient.op_Implicit(new Color(1f, 0.2f, 0f, 0.3f));
					((MainModule)(ref <fogMain>5__16)).maxParticles = 8000;
					((MainModule)(ref <fogMain>5__16)).simulationSpace = (ParticleSystemSimulationSpace)1;
					((MainModule)(ref <fogMain>5__16)).gravityModifier = MinMaxCurve.op_Implicit(0f);
					<fogEmission>5__17 = <fogParticles>5__15.emission;
					((EmissionModule)(ref <fogEmission>5__17)).rateOverTime = MinMaxCurve.op_Implicit(1500f);
					<fogShape>5__18 = <fogParticles>5__15.shape;
					((ShapeModule)(ref <fogShape>5__18)).shapeType = (ParticleSystemShapeType)5;
					((ShapeModule)(ref <fogShape>5__18)).scale = new Vector3(30f, 15f, 30f);
					<fogRendererParticle>5__19 = ((Component)<fogParticles>5__15).GetComponent<ParticleSystemRenderer>();
					<fogRendererParticle>5__19.renderMode = (ParticleSystemRenderMode)0;
					<fogParticleMaterial>5__20 = new Material(Shader.Find("Legacy Shaders/Particles/Alpha Blended Premultiply") ?? Shader.Find("Unlit/Color"));
					<fogParticleMaterial>5__20.color = new Color(1f, 1f, 0f, 0.3f);
					((Renderer)<fogRendererParticle>5__19).material = <fogParticleMaterial>5__20;
					<fogParticles>5__15.Play();
					<initialScale>5__21 = new Vector3(10f, 50f, 10f);
					<finalScale>5__22 = <initialScale>5__21 * 5f;
					<duration>5__23 = 5f;
					<elapsed>5__24 = 0f;
					break;
				case 4:
					{
						<>1__state = -1;
						<hits>5__30 = null;
						break;
					}
					IL_0162:
					<>2__current = (object)new WaitForSeconds(0.5f);
					<>1__state = 3;
					return true;
				}
				if (<elapsed>5__24 < <duration>5__23)
				{
					<t>5__29 = <elapsed>5__24 / <duration>5__23;
					<beam>5__4.transform.localScale = Vector3.Lerp(<initialScale>5__21, <finalScale>5__22, <t>5__29);
					<material>5__6.color = new Color(1f, 1f, 0f, Mathf.Lerp(1f, 0f, <t>5__29));
					<beam>5__4.transform.Rotate(Vector3.up, 90f * Time.deltaTime);
					<hits>5__30 = Physics.OverlapSphere(targetPoint, <beam>5__4.transform.localScale.x / 2f, LayerMask.GetMask(new string[1] { "Player" }));
					<>s__31 = <hits>5__30;
					for (<>s__32 = 0; <>s__32 < <>s__31.Length; <>s__32++)
					{
						<col>5__33 = <>s__31[<>s__32];
						<player>5__34 = ((Component)<col>5__33).GetComponent<PlayerMovement>();
						if ((Object)(object)<player>5__34 != (Object)null)
						{
							<player>5__34.DamagePlayer(25f * Time.deltaTime, casterObj, "Sun Beam");
							SunBeamPlugin.Logger.LogInfo((object)("[Sun Beam] Applied damage to " + ((Object)((Component)<player>5__34).gameObject).name));
						}
						<player>5__34 = null;
						<col>5__33 = null;
					}
					<>s__31 = null;
					<elapsed>5__24 += Time.deltaTime;
					<>2__current = null;
					<>1__state = 4;
					return true;
				}
				Object.Destroy((Object)(object)<beam>5__4);
				Object.Destroy((Object)(object)<fogObject>5__14);
				return false;
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		[CompilerGenerated]
		private sealed class <LoadAndPlaySound>d__5 : IEnumerator<object>, IDisposable, IEnumerator
		{
			private int <>1__state;

			private object <>2__current;

			public Vector3 position;

			object IEnumerator<object>.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			object IEnumerator.Current
			{
				[DebuggerHidden]
				get
				{
					return <>2__current;
				}
			}

			[DebuggerHidden]
			public <LoadAndPlaySound>d__5(int <>1__state)
			{
				this.<>1__state = <>1__state;
			}

			[DebuggerHidden]
			void IDisposable.Dispose()
			{
				<>1__state = -2;
			}

			private bool MoveNext()
			{
				//IL_0040: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					beamSound = Resources.Load<AudioClip>("SunBeamMod.Resources.SunBeam.wav");
					if ((Object)(object)beamSound != (Object)null)
					{
						PlaySpatialSoundAtPosition(position, beamSound);
					}
					else
					{
						SunBeamPlugin.Logger.LogWarning((object)"[Sun Beam] Embedded sound not found - skipping.");
					}
					isLoading = false;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					return false;
				}
			}

			bool IEnumerator.MoveNext()
			{
				//ILSpy generated this explicit interface implementation from .override directive in MoveNext
				return this.MoveNext();
			}

			[DebuggerHidden]
			void IEnumerator.Reset()
			{
				throw new NotSupportedException();
			}
		}

		private static AudioClip beamSound;

		private static bool isLoading;

		public override void CastSpell(GameObject casterObj, Vector3 spawnPos, Vector3 direction, int level)
		{
			//IL_0017: 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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: 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_0046: 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_0048: 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_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			SunBeamPlugin.Logger.LogInfo((object)"[Sun Beam] CastSpell called - attempting raycast.");
			float num = 100f;
			Vector3 val = ((spawnPos != Vector3.zero) ? spawnPos : (casterObj.transform.position + Vector3.up * 1.5f));
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(val, direction, ref val2, num))
			{
				ManualLogSource logger = SunBeamPlugin.Logger;
				Vector3 point = ((RaycastHit)(ref val2)).point;
				logger.LogInfo((object)("[Sun Beam] Raycast hit at point: " + ((object)(Vector3)(ref point)).ToString()));
				Vector3 point2 = ((RaycastHit)(ref val2)).point;
				((MonoBehaviour)SunBeamPlugin.Instance).StartCoroutine(CreateBeam(casterObj, point2));
			}
			else
			{
				SunBeamPlugin.Logger.LogWarning((object)"[Sun Beam] No raycast hit - nothing spawned.");
			}
		}

		[IteratorStateMachine(typeof(<CreateBeam>d__3))]
		private IEnumerator CreateBeam(GameObject casterObj, Vector3 targetPoint)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <CreateBeam>d__3(0)
			{
				<>4__this = this,
				casterObj = casterObj,
				targetPoint = targetPoint
			};
		}

		private static void PlaySpatialSoundAtPosition(Vector3 position, AudioClip clip)
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Expected O, but got Unknown
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)clip == (Object)null))
			{
				GameObject val = new GameObject("SunBeamAudio");
				val.transform.position = position;
				AudioSource val2 = val.AddComponent<AudioSource>();
				val2.clip = clip;
				val2.volume = 1.5f;
				val2.spatialBlend = 1f;
				val2.rolloffMode = (AudioRolloffMode)1;
				val2.minDistance = 5f;
				val2.maxDistance = 350f;
				val2.Play();
				Object.Destroy((Object)(object)val, clip.length + 0.1f);
			}
		}

		[IteratorStateMachine(typeof(<LoadAndPlaySound>d__5))]
		private static IEnumerator LoadAndPlaySound(Vector3 position)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <LoadAndPlaySound>d__5(0)
			{
				position = position
			};
		}
	}
}