Decompiled source of Touhou Weapons v1.0.0

TouhouWeapons.dll

Decompiled 5 hours ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using UnityEngine;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.7.2", FrameworkDisplayName = ".NET Framework 4.7.2")]
[assembly: AssemblyCompany("TouhouWeapons")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("My first plugin")]
[assembly: AssemblyTitle("TouhouWeapons")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace TouhouWeapons
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "TouhouWeapons";

		public const string PLUGIN_NAME = "My first plugin";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace TouhouWeaponsMod
{
	[BepInPlugin("com.tokhi.touhouweapons", "Touhou Weapons", "1.0.0")]
	public class Plugin : BaseUnityPlugin
	{
		public static GameObject MiniHakkeroPrefab;

		public static GameObject GoheiPrefab;

		public static GameObject DanmakuOrbPrefab;

		public static Sprite HakkeroIcon;

		public static Sprite HakkeroGlowIcon;

		public static Sprite GoheiIcon;

		public static Sprite GoheiGlowIcon;

		public static GameObject SakuyaHandPrefab;

		public static GameObject SakuyaKnifePrefab;

		public static Sprite KnifeIcon;

		public static Sprite KnifeGlowIcon;

		public static GameObject OkuuRodPrefab;

		public static GameObject OkuuBeamPrefab;

		public static Sprite OkuuIcon;

		public static Sprite OkuuGlowIcon;

		private void Awake()
		{
			//IL_0410: Unknown result type (might be due to invalid IL or missing references)
			//IL_0377: Unknown result type (might be due to invalid IL or missing references)
			//IL_0386: Unknown result type (might be due to invalid IL or missing references)
			//IL_029b: Unknown result type (might be due to invalid IL or missing references)
			//IL_02aa: Unknown result type (might be due to invalid IL or missing references)
			AssetBundle val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "touhouweapons"));
			if ((Object)(object)val != (Object)null)
			{
				GameObject[] array = val.LoadAllAssets<GameObject>();
				foreach (GameObject val2 in array)
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)("[TouhouWeapons] Found Prefab: " + ((Object)val2).name));
					string text = ((Object)val2).name.ToLower();
					SpriteRenderer component = val2.GetComponent<SpriteRenderer>();
					if ((Object)(object)component != (Object)null && (Object)(object)component.sprite != (Object)null)
					{
						((Object)component.sprite).name = ((Object)val2).name;
						AssignLoadedSprite(component.sprite);
						((BaseUnityPlugin)this).Logger.LogInfo((object)("[TouhouWeapons] Extracted Icon Sprite from Prefab: " + ((Object)val2).name));
					}
					else if (text.Contains("hakkero"))
					{
						MiniHakkeroPrefab = val2;
					}
					else if (text.Contains("gohei"))
					{
						GoheiPrefab = val2;
					}
					else if (text.Contains("danmaku") || text.Contains("orb"))
					{
						DanmakuOrbPrefab = val2;
					}
					else if (text.Contains("sakuyahand") || text.Contains("handknife"))
					{
						SakuyaHandPrefab = val2;
					}
					else if (text.Contains("sakuyathrown") || text.Contains("thrownknife"))
					{
						SakuyaKnifePrefab = val2;
					}
					else if (text.Contains("okuurod") || text.Contains("controlrod"))
					{
						OkuuRodPrefab = val2;
					}
					else if (text.Contains("okuubeam") || text.Contains("nuclearbeam"))
					{
						OkuuBeamPrefab = val2;
					}
				}
				Sprite[] array2 = val.LoadAllAssets<Sprite>();
				foreach (Sprite val3 in array2)
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)("[TouhouWeapons] Found Sprite: " + ((Object)val3).name));
					AssignLoadedSprite(val3);
				}
				if ((Object)(object)HakkeroIcon == (Object)null)
				{
					Texture2D[] array3 = val.LoadAllAssets<Texture2D>();
					foreach (Texture2D val4 in array3)
					{
						string text2 = ((Object)val4).name.ToLower();
						if (text2.Contains("hakkero") || text2.Contains("gohei") || text2.Contains("icon") || text2.Contains("glow"))
						{
							((BaseUnityPlugin)this).Logger.LogInfo((object)("[TouhouWeapons] Converted Texture2D to Sprite: " + ((Object)val4).name));
							Sprite obj = Sprite.Create(val4, new Rect(0f, 0f, (float)((Texture)val4).width, (float)((Texture)val4).height), new Vector2(0.5f, 0.5f));
							((Object)obj).name = ((Object)val4).name;
							AssignLoadedSprite(obj);
						}
					}
				}
			}
			if ((Object)(object)HakkeroIcon == (Object)null)
			{
				Texture2D[] array3 = val.LoadAllAssets<Texture2D>();
				foreach (Texture2D val5 in array3)
				{
					string text3 = ((Object)val5).name.ToLower();
					if (text3.Contains("hakkero") || text3.Contains("gohei") || text3.Contains("icon") || text3.Contains("glow"))
					{
						((BaseUnityPlugin)this).Logger.LogInfo((object)("[TouhouWeapons] Converting Texture2D to Sprite: " + ((Object)val5).name));
						Sprite obj2 = Sprite.Create(val5, new Rect(0f, 0f, (float)((Texture)val5).width, (float)((Texture)val5).height), new Vector2(0.5f, 0.5f));
						((Object)obj2).name = ((Object)val5).name;
						AssignLoadedSprite(obj2);
					}
				}
			}
			if ((Object)(object)val != (Object)null)
			{
				MiniHakkeroPrefab = val.LoadAsset<GameObject>("MiniHakkeroWeapon");
				GoheiPrefab = val.LoadAsset<GameObject>("GoheiWeapon");
				DanmakuOrbPrefab = val.LoadAsset<GameObject>("DanmakuOrb");
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded MiniHakkero, Gohei, and DanmakuOrb from touhouweapons!");
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load 'touhouweapons' AssetBundle!");
			}
			new Harmony("com.tokhi.touhouweapons").PatchAll();
		}

		private static void AssignLoadedSprite(Sprite s)
		{
			if ((Object)(object)s == (Object)null)
			{
				return;
			}
			string text = ((Object)s).name.ToLower();
			if (text.Contains("knife") || text.Contains("sakuya"))
			{
				if (text.Contains("glow"))
				{
					if ((Object)(object)KnifeGlowIcon == (Object)null)
					{
						KnifeGlowIcon = s;
					}
				}
				else if ((Object)(object)KnifeIcon == (Object)null)
				{
					KnifeIcon = s;
				}
			}
			else if (text.Contains("gohei"))
			{
				if (text.Contains("glow"))
				{
					if ((Object)(object)GoheiGlowIcon == (Object)null)
					{
						GoheiGlowIcon = s;
					}
				}
				else if ((Object)(object)GoheiIcon == (Object)null)
				{
					GoheiIcon = s;
				}
			}
			else if (text.Contains("okuu") || text.Contains("nuclear"))
			{
				if (text.Contains("glow"))
				{
					if ((Object)(object)OkuuGlowIcon == (Object)null)
					{
						OkuuGlowIcon = s;
					}
				}
				else if ((Object)(object)OkuuIcon == (Object)null)
				{
					OkuuIcon = s;
				}
			}
			else
			{
				if (!text.Contains("hakkero"))
				{
					return;
				}
				if (text.Contains("glow"))
				{
					if ((Object)(object)HakkeroGlowIcon == (Object)null)
					{
						HakkeroGlowIcon = s;
					}
				}
				else if ((Object)(object)HakkeroIcon == (Object)null)
				{
					HakkeroIcon = s;
				}
			}
		}
	}
	[HarmonyPatch(typeof(GunControl), "NoWeapon")]
	public static class GunControl_NoWeapon_Patch
	{
		private static void Postfix()
		{
			GunControl_Start_Patch.IsSlot7Equipped = false;
			GunControl_Start_Patch.IsSlot8Equipped = false;
			if ((Object)(object)GunControl_Start_Patch.ActiveHakkero != (Object)null)
			{
				GunControl_Start_Patch.ActiveHakkero.SetActive(false);
			}
			if ((Object)(object)GunControl_Start_Patch.ActiveGohei != (Object)null)
			{
				GunControl_Start_Patch.ActiveGohei.SetActive(false);
			}
			if ((Object)(object)GunControl_Start_Patch.ActiveKnives != (Object)null)
			{
				GunControl_Start_Patch.ActiveKnives.SetActive(false);
			}
			if ((Object)(object)GunControl_Start_Patch.ActiveOkuuRod != (Object)null)
			{
				GunControl_Start_Patch.ActiveOkuuRod.SetActive(false);
			}
		}
	}
	[HarmonyPatch(typeof(GunControl), "Start")]
	public static class GunControl_Start_Patch
	{
		public static GameObject ActiveHakkero;

		public static GameObject ActiveGohei;

		public static bool IsSlot7Equipped;

		public static int Slot7Variation;

		public static GameObject ActiveKnives;

		public static GameObject ActiveOkuuRod;

		public static bool IsSlot8Equipped;

		public static GameObject MaliciousExplosionPrefab;

		private static void Postfix(GunControl __instance)
		{
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: 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_03a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0403: Unknown result type (might be due to invalid IL or missing references)
			//IL_040d: Unknown result type (might be due to invalid IL or missing references)
			//IL_016e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)__instance == (Object)null || (Object)(object)((Component)__instance).transform == (Object)null)
			{
				return;
			}
			IsSlot7Equipped = false;
			Slot7Variation = 0;
			ActiveHakkero = null;
			ActiveGohei = null;
			IsSlot8Equipped = false;
			ActiveOkuuRod = null;
			if ((Object)(object)MaliciousExplosionPrefab == (Object)null)
			{
				GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
				foreach (GameObject val in array)
				{
					if ((Object)(object)val != (Object)null && ((Object)val).name.ToLower().Contains("explosion") && ((Object)val).name.ToLower().Contains("malicious"))
					{
						MaliciousExplosionPrefab = val;
						break;
					}
				}
			}
			if ((Object)(object)Plugin.OkuuRodPrefab != (Object)null)
			{
				ActiveOkuuRod = CreateCustomWeaponRoot(__instance, "OkuuControlRodWeapon", Plugin.OkuuRodPrefab, new Vector3(0.42f, -0.35f, 0.7f));
				if ((Object)(object)ActiveOkuuRod != (Object)null)
				{
					ActiveOkuuRod.AddComponent<OkuuControlRodController>().modelTransform = ActiveOkuuRod.transform.Find("WeaponModel");
					Sprite val2 = (((Object)(object)Plugin.OkuuIcon != (Object)null) ? Plugin.OkuuIcon : Plugin.HakkeroIcon);
					if ((Object)(object)val2 != (Object)null)
					{
						CustomHUDIconKeeper customHUDIconKeeper = ActiveOkuuRod.AddComponent<CustomHUDIconKeeper>();
						customHUDIconKeeper.mainIcon = val2;
						customHUDIconKeeper.glowIcon = (((Object)(object)Plugin.OkuuGlowIcon != (Object)null) ? Plugin.OkuuGlowIcon : Plugin.HakkeroGlowIcon);
						customHUDIconKeeper.hudColor = new Color(1f, 0.45f, 0.1f);
					}
					ActiveOkuuRod.SetActive(false);
				}
			}
			if ((Object)(object)Plugin.SakuyaHandPrefab != (Object)null)
			{
				ActiveKnives = CreateCustomWeaponRoot(__instance, "SakuyaKnivesWeapon", Plugin.SakuyaHandPrefab, new Vector3(0.35f, -0.3f, 0.6f));
				if ((Object)(object)ActiveKnives != (Object)null)
				{
					ActiveKnives.AddComponent<SakuyaKnivesController>().modelTransform = ActiveKnives.transform.Find("WeaponModel");
					Sprite val3 = (((Object)(object)Plugin.KnifeIcon != (Object)null) ? Plugin.KnifeIcon : Plugin.HakkeroIcon);
					if ((Object)(object)val3 != (Object)null)
					{
						CustomHUDIconKeeper customHUDIconKeeper2 = ActiveKnives.AddComponent<CustomHUDIconKeeper>();
						customHUDIconKeeper2.mainIcon = val3;
						customHUDIconKeeper2.glowIcon = (((Object)(object)Plugin.KnifeGlowIcon != (Object)null) ? Plugin.KnifeGlowIcon : Plugin.HakkeroGlowIcon);
						customHUDIconKeeper2.hudColor = new Color(0.25f, 1f, 0.4f);
					}
					ActiveKnives.SetActive(false);
				}
			}
			if ((Object)(object)Plugin.MiniHakkeroPrefab != (Object)null)
			{
				ActiveHakkero = CreateCustomWeaponRoot(__instance, "MiniHakkeroWeapon", Plugin.MiniHakkeroPrefab, new Vector3(0.35f, -0.28f, 0.65f));
				if ((Object)(object)ActiveHakkero != (Object)null)
				{
					Transform[] componentsInChildren = ActiveHakkero.GetComponentsInChildren<Transform>(true);
					foreach (Transform val4 in componentsInChildren)
					{
						if (!((Object)(object)val4 == (Object)null))
						{
							string text = ((Object)val4).name.ToLower();
							if (text.Contains("inner") || text.Contains("outer") || text.Contains("beam"))
							{
								((Component)val4).gameObject.SetActive(false);
							}
						}
					}
					ActiveHakkero.AddComponent<MasterSparkHold>().modelTransform = ActiveHakkero.transform.Find("WeaponModel");
					if ((Object)(object)Plugin.HakkeroIcon != (Object)null)
					{
						CustomHUDIconKeeper customHUDIconKeeper3 = ActiveHakkero.AddComponent<CustomHUDIconKeeper>();
						customHUDIconKeeper3.mainIcon = Plugin.HakkeroIcon;
						customHUDIconKeeper3.glowIcon = Plugin.HakkeroGlowIcon;
					}
					ActiveHakkero.SetActive(false);
				}
			}
			if (!((Object)(object)Plugin.GoheiPrefab != (Object)null))
			{
				return;
			}
			ActiveGohei = CreateCustomWeaponRoot(__instance, "GoheiWeapon", Plugin.GoheiPrefab, new Vector3(0.42f, -0.35f, 0.75f));
			if ((Object)(object)ActiveGohei != (Object)null)
			{
				GoheiWeaponController goheiWeaponController = ActiveGohei.AddComponent<GoheiWeaponController>();
				goheiWeaponController.modelTransform = ActiveGohei.transform.Find("WeaponModel");
				if ((Object)(object)goheiWeaponController.modelTransform != (Object)null)
				{
					goheiWeaponController.modelTransform.localScale = Vector3.one * 2.4f;
				}
				Sprite val5 = (((Object)(object)Plugin.GoheiIcon != (Object)null) ? Plugin.GoheiIcon : Plugin.HakkeroIcon);
				if ((Object)(object)val5 != (Object)null)
				{
					CustomHUDIconKeeper customHUDIconKeeper4 = ActiveGohei.AddComponent<CustomHUDIconKeeper>();
					customHUDIconKeeper4.mainIcon = val5;
					customHUDIconKeeper4.glowIcon = (((Object)(object)Plugin.GoheiGlowIcon != (Object)null) ? Plugin.GoheiGlowIcon : Plugin.HakkeroGlowIcon);
				}
				ActiveGohei.SetActive(false);
			}
		}

		private static GameObject CreateCustomWeaponRoot(GunControl gc, string rootName, GameObject prefab, Vector3 modelOffset)
		{
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Expected O, but got Unknown
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0244: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)gc == (Object)null || (Object)(object)((Component)gc).transform == (Object)null || (Object)(object)prefab == (Object)null)
			{
				return null;
			}
			GameObject val = new GameObject(rootName);
			val.transform.SetParent(((Component)gc).transform, false);
			GameObject val2 = Object.Instantiate<GameObject>(prefab, val.transform);
			if ((Object)(object)val2 != (Object)null)
			{
				((Object)val2).name = "WeaponModel";
				val2.transform.localPosition = modelOffset;
				val2.transform.localRotation = Quaternion.identity;
			}
			if (gc.slots != null && gc.slots.Count > 0 && gc.slots.ElementAt(0) != null && gc.slots.ElementAt(0).Count > 0)
			{
				GameObject val3 = gc.slots.ElementAt(0).ElementAt(0);
				if ((Object)(object)val3 != (Object)null)
				{
					GameObject val4 = Object.Instantiate<GameObject>(val3, val.transform);
					((Object)val4).name = "V1RightArm";
					val4.SetActive(true);
					MonoBehaviour[] componentsInChildren = val4.GetComponentsInChildren<MonoBehaviour>(true);
					foreach (MonoBehaviour val5 in componentsInChildren)
					{
						if ((Object)(object)val5 != (Object)null)
						{
							Object.DestroyImmediate((Object)(object)val5);
						}
					}
					AudioSource[] componentsInChildren2 = val4.GetComponentsInChildren<AudioSource>(true);
					foreach (AudioSource val6 in componentsInChildren2)
					{
						if ((Object)(object)val6 != (Object)null)
						{
							Object.DestroyImmediate((Object)(object)val6);
						}
					}
					Canvas[] componentsInChildren3 = val4.GetComponentsInChildren<Canvas>(true);
					foreach (Canvas val7 in componentsInChildren3)
					{
						if ((Object)(object)val7 != (Object)null && (Object)(object)((Component)val7).gameObject != (Object)null)
						{
							Object.DestroyImmediate((Object)(object)((Component)val7).gameObject);
						}
					}
					Light[] componentsInChildren4 = val4.GetComponentsInChildren<Light>(true);
					foreach (Light val8 in componentsInChildren4)
					{
						if ((Object)(object)val8 != (Object)null)
						{
							Object.DestroyImmediate((Object)(object)val8);
						}
					}
					Animator[] componentsInChildren5 = val4.GetComponentsInChildren<Animator>(true);
					foreach (Animator val9 in componentsInChildren5)
					{
						if ((Object)(object)val9 != (Object)null)
						{
							((Behaviour)val9).enabled = true;
							val9.speed = 0f;
						}
					}
					val4.transform.localPosition = new Vector3(0.02f, -0.08f, 0.05f);
					val4.transform.localRotation = Quaternion.identity;
					MeshRenderer[] componentsInChildren6 = val4.GetComponentsInChildren<MeshRenderer>(true);
					foreach (MeshRenderer val10 in componentsInChildren6)
					{
						if ((Object)(object)val10 != (Object)null)
						{
							((Renderer)val10).enabled = false;
						}
					}
					SkinnedMeshRenderer[] componentsInChildren7 = val4.GetComponentsInChildren<SkinnedMeshRenderer>(true);
					foreach (SkinnedMeshRenderer val11 in componentsInChildren7)
					{
						if ((Object)(object)val11 != (Object)null)
						{
							((Renderer)val11).enabled = ((Object)val11).name.Contains("RightArm");
						}
					}
				}
			}
			return val;
		}
	}
	[HarmonyPatch(typeof(GunControl), "Update")]
	public static class GunControl_Update_Patch
	{
		private static void Postfix(GunControl __instance)
		{
			//IL_01ac: Unknown result type (might be due to invalid IL or missing references)
			bool flag = (Object)(object)MonoSingleton<NewMovement>.Instance != (Object)null && MonoSingleton<NewMovement>.Instance.dead;
			if ((Object)(object)__instance == (Object)null || __instance.noWeapons || flag)
			{
				if (GunControl_Start_Patch.IsSlot7Equipped || GunControl_Start_Patch.IsSlot8Equipped)
				{
					GunControl_Start_Patch.IsSlot7Equipped = false;
					GunControl_Start_Patch.IsSlot8Equipped = false;
					HideSlot7();
					if ((Object)(object)GunControl_Start_Patch.ActiveOkuuRod != (Object)null)
					{
						GunControl_Start_Patch.ActiveOkuuRod.SetActive(false);
					}
				}
				return;
			}
			bool keyDown = Input.GetKeyDown((KeyCode)55);
			bool keyDown2 = Input.GetKeyDown((KeyCode)56);
			bool flag2 = Input.GetKeyDown((KeyCode)101) || ((Object)(object)MonoSingleton<InputManager>.Instance != (Object)null && MonoSingleton<InputManager>.Instance.InputSource.NextVariation.WasPerformedThisFrame);
			if (keyDown2 && (Object)(object)GunControl_Start_Patch.ActiveOkuuRod != (Object)null && !GunControl_Start_Patch.IsSlot8Equipped)
			{
				GunControl_Start_Patch.IsSlot7Equipped = false;
				GunControl_Start_Patch.IsSlot8Equipped = true;
				HideSlot7();
				if ((Object)(object)__instance.currentWeapon != (Object)null)
				{
					__instance.currentWeapon.SetActive(false);
				}
				GunControl_Start_Patch.ActiveOkuuRod.SetActive(true);
			}
			else if (keyDown)
			{
				if (GunControl_Start_Patch.IsSlot8Equipped)
				{
					GunControl_Start_Patch.IsSlot8Equipped = false;
					if ((Object)(object)GunControl_Start_Patch.ActiveOkuuRod != (Object)null)
					{
						GunControl_Start_Patch.ActiveOkuuRod.SetActive(false);
					}
				}
				if (!GunControl_Start_Patch.IsSlot7Equipped)
				{
					GunControl_Start_Patch.IsSlot7Equipped = true;
					UpdateSlot7ActiveState(__instance);
				}
				else
				{
					GunControl_Start_Patch.Slot7Variation = (GunControl_Start_Patch.Slot7Variation + 1) % 2;
					UpdateSlot7ActiveState(__instance);
				}
			}
			else if (GunControl_Start_Patch.IsSlot7Equipped && flag2)
			{
				GunControl_Start_Patch.Slot7Variation = (GunControl_Start_Patch.Slot7Variation + 1) % 2;
				UpdateSlot7ActiveState(__instance);
			}
			else if ((GunControl_Start_Patch.IsSlot7Equipped || GunControl_Start_Patch.IsSlot8Equipped) && (Input.GetKeyDown((KeyCode)49) || Input.GetKeyDown((KeyCode)50) || Input.GetKeyDown((KeyCode)51) || Input.GetKeyDown((KeyCode)52) || Input.GetKeyDown((KeyCode)53) || Input.GetKeyDown((KeyCode)54) || Input.mouseScrollDelta.y != 0f))
			{
				GunControl_Start_Patch.IsSlot7Equipped = false;
				GunControl_Start_Patch.IsSlot8Equipped = false;
				HideSlot7();
				if ((Object)(object)GunControl_Start_Patch.ActiveOkuuRod != (Object)null)
				{
					GunControl_Start_Patch.ActiveOkuuRod.SetActive(false);
				}
				if ((Object)(object)__instance.currentWeapon != (Object)null)
				{
					__instance.currentWeapon.SetActive(true);
				}
			}
			else if (GunControl_Start_Patch.IsSlot7Equipped)
			{
				UpdateSlot7ActiveState(__instance);
			}
			else if (GunControl_Start_Patch.IsSlot8Equipped && (Object)(object)GunControl_Start_Patch.ActiveOkuuRod != (Object)null)
			{
				if ((Object)(object)__instance.currentWeapon != (Object)null && __instance.currentWeapon.activeSelf)
				{
					__instance.currentWeapon.SetActive(false);
				}
				if (!GunControl_Start_Patch.ActiveOkuuRod.activeSelf)
				{
					GunControl_Start_Patch.ActiveOkuuRod.SetActive(true);
				}
			}
		}

		private static void HideSlot7()
		{
			if ((Object)(object)GunControl_Start_Patch.ActiveHakkero != (Object)null)
			{
				GunControl_Start_Patch.ActiveHakkero.SetActive(false);
			}
			if ((Object)(object)GunControl_Start_Patch.ActiveGohei != (Object)null)
			{
				GunControl_Start_Patch.ActiveGohei.SetActive(false);
			}
			if ((Object)(object)GunControl_Start_Patch.ActiveKnives != (Object)null)
			{
				GunControl_Start_Patch.ActiveKnives.SetActive(false);
			}
		}

		public static void UpdateSlot7ActiveState(GunControl gc)
		{
			if ((Object)(object)gc != (Object)null && (Object)(object)gc.currentWeapon != (Object)null && gc.currentWeapon.activeSelf)
			{
				gc.currentWeapon.SetActive(false);
			}
			if ((Object)(object)GunControl_Start_Patch.ActiveHakkero != (Object)null)
			{
				GunControl_Start_Patch.ActiveHakkero.SetActive(GunControl_Start_Patch.Slot7Variation == 0);
			}
			if ((Object)(object)GunControl_Start_Patch.ActiveGohei != (Object)null)
			{
				GunControl_Start_Patch.ActiveGohei.SetActive(GunControl_Start_Patch.Slot7Variation == 1);
			}
			if ((Object)(object)GunControl_Start_Patch.ActiveKnives != (Object)null)
			{
				GunControl_Start_Patch.ActiveKnives.SetActive(GunControl_Start_Patch.Slot7Variation == 2);
			}
		}
	}
	public class MasterSparkHold : MonoBehaviour
	{
		public Transform modelTransform;

		public float damagePerSecond = 10f;

		public float tickRate = 0.1f;

		public float beamRadius = 2.6f;

		public float maxRange = 100f;

		public float rainbowSpeed = 3.5f;

		public float pulseSpeed = 25f;

		public Vector3 recoilOffset = new Vector3(0f, 0f, -0.2f);

		private Transform innerBeam;

		private Transform outerBeam;

		private Renderer outerRenderer;

		private AudioSource audioSource;

		private Vector3 innerBaseScale;

		private Vector3 outerBaseScale;

		private Vector3 originalModelPos;

		private float tickTimer;

		private bool isFiring;

		private LayerMask enemyLayer;

		private void Start()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)modelTransform == (Object)null)
			{
				modelTransform = ((Component)this).transform;
			}
			originalModelPos = modelTransform.localPosition;
			enemyLayer = LayerMask.op_Implicit(5120);
			Transform[] componentsInChildren = ((Component)this).GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				string text = ((Object)val).name.ToLower();
				if (text.Contains("inner"))
				{
					innerBeam = val;
					innerBaseScale = val.localScale;
					((Component)val).gameObject.SetActive(false);
				}
				else if (text.Contains("outer"))
				{
					outerBeam = val;
					outerBaseScale = val.localScale;
					outerRenderer = ((Component)val).GetComponent<Renderer>();
					((Component)val).gameObject.SetActive(false);
				}
			}
			audioSource = ((Component)this).GetComponentInChildren<AudioSource>(true);
		}

		private void OnDisable()
		{
			StopFiring();
		}

		private void Update()
		{
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			bool flag = Input.GetMouseButton(0) || Input.GetButton("Fire1");
			if ((Object)(object)MonoSingleton<InputManager>.Instance != (Object)null && MonoSingleton<InputManager>.Instance.InputSource.Fire1.IsPressed)
			{
				flag = true;
			}
			if (flag && Time.timeScale > 0f)
			{
				if (!isFiring)
				{
					StartFiring();
				}
				UpdateFiring();
			}
			else if (isFiring)
			{
				StopFiring();
			}
			if (!isFiring && (Object)(object)modelTransform != (Object)null)
			{
				modelTransform.localPosition = Vector3.Lerp(modelTransform.localPosition, originalModelPos, Time.deltaTime * 10f);
			}
		}

		private void StartFiring()
		{
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			isFiring = true;
			tickTimer = tickRate;
			if ((Object)(object)innerBeam != (Object)null)
			{
				((Component)innerBeam).gameObject.SetActive(true);
			}
			if ((Object)(object)outerBeam != (Object)null)
			{
				((Component)outerBeam).gameObject.SetActive(true);
			}
			if ((Object)(object)audioSource != (Object)null)
			{
				audioSource.Play();
			}
			if ((Object)(object)MonoSingleton<NewMovement>.Instance != (Object)null && (Object)(object)MonoSingleton<CameraController>.Instance != (Object)null)
			{
				MonoSingleton<NewMovement>.Instance.Launch(-((Component)MonoSingleton<CameraController>.Instance).transform.forward * 12f, 8f, false);
			}
		}

		private void UpdateFiring()
		{
			//IL_0057: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_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_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0163: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			float num = 1f + Mathf.Sin(Time.time * pulseSpeed) * 0.12f;
			if ((Object)(object)innerBeam != (Object)null)
			{
				innerBeam.localScale = new Vector3(innerBaseScale.x * num, innerBaseScale.y * num, innerBaseScale.z);
			}
			if ((Object)(object)outerBeam != (Object)null)
			{
				float num2 = 1f + Mathf.Cos(Time.time * pulseSpeed) * 0.15f;
				outerBeam.localScale = new Vector3(outerBaseScale.x * num2, outerBaseScale.y * num2, outerBaseScale.z);
			}
			if ((Object)(object)outerRenderer != (Object)null)
			{
				Color color = Color.HSVToRGB(Mathf.Repeat(Time.time * rainbowSpeed, 1f), 0.9f, 1f);
				color.a = 0.55f;
				outerRenderer.material.color = color;
			}
			if ((Object)(object)modelTransform != (Object)null)
			{
				Vector3 val = Random.insideUnitSphere * 0.02f;
				modelTransform.localPosition = Vector3.Lerp(modelTransform.localPosition, originalModelPos + recoilOffset, Time.deltaTime * 12f) + val;
			}
			if ((Object)(object)MonoSingleton<CameraController>.Instance != (Object)null)
			{
				MonoSingleton<CameraController>.Instance.CameraShake(0.45f);
			}
			tickTimer += Time.deltaTime;
			if (tickTimer >= tickRate)
			{
				tickTimer = 0f;
				DamageAndIgnite();
			}
		}

		private void StopFiring()
		{
			isFiring = false;
			if ((Object)(object)innerBeam != (Object)null)
			{
				((Component)innerBeam).gameObject.SetActive(false);
			}
			if ((Object)(object)outerBeam != (Object)null)
			{
				((Component)outerBeam).gameObject.SetActive(false);
			}
			if ((Object)(object)audioSource != (Object)null && audioSource.isPlaying)
			{
				audioSource.Stop();
			}
		}

		private void DamageAndIgnite()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: 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_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)MonoSingleton<CameraController>.Instance == (Object)null)
			{
				return;
			}
			Transform transform = ((Component)MonoSingleton<CameraController>.Instance).transform;
			RaycastHit[] array = Physics.SphereCastAll(transform.position, beamRadius, transform.forward, maxRange, LayerMask.op_Implicit(enemyLayer));
			float num = damagePerSecond * tickRate;
			RaycastHit[] array2 = array;
			for (int i = 0; i < array2.Length; i++)
			{
				RaycastHit val = array2[i];
				EnemyIdentifier componentInParent = ((Component)((RaycastHit)(ref val)).collider).GetComponentInParent<EnemyIdentifier>();
				if ((Object)(object)componentInParent != (Object)null && !componentInParent.dead)
				{
					bool num2 = !componentInParent.dead;
					componentInParent.DeliverDamage(((Component)componentInParent).gameObject, transform.forward * 8f, ((RaycastHit)(ref val)).point, num, true, 0f, ((Component)this).gameObject, false, false);
					Flammable componentInChildren = ((Component)componentInParent).GetComponentInChildren<Flammable>();
					if ((Object)(object)componentInChildren != (Object)null)
					{
						componentInChildren.Burn(4f, false);
					}
					if (num2 && componentInParent.dead && (Object)(object)MonoSingleton<StyleHUD>.Instance != (Object)null)
					{
						MonoSingleton<StyleHUD>.Instance.AddPoints(150, "<color=#d142f5>MASTER SPARKED</color><color=#FFFFFF>", ((Component)this).gameObject, componentInParent, -1, "", "");
					}
				}
			}
		}
	}
	public class GoheiWeaponController : MonoBehaviour
	{
		public Transform modelTransform;

		public float swingCooldown = 0.4f;

		public float danmakuCooldown = 0.32f;

		public float meleeDamage = 5f;

		public float meleeRange = 4.5f;

		public float parryRadius = 3.8f;

		private float swingTimer;

		private float danmakuTimer;

		private Quaternion restRotation;

		private Quaternion targetRotation;

		private AudioSource audioSource;

		private LayerMask enemyLayer;

		private void Start()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)modelTransform == (Object)null)
			{
				modelTransform = ((Component)this).transform;
			}
			restRotation = modelTransform.localRotation;
			targetRotation = restRotation;
			enemyLayer = LayerMask.op_Implicit(5120);
			audioSource = ((Component)this).GetComponentInChildren<AudioSource>(true);
		}

		private void Update()
		{
			//IL_003d: 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_0053: 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_0065: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			if (!(Time.timeScale <= 0f))
			{
				swingTimer -= Time.deltaTime;
				danmakuTimer -= Time.deltaTime;
				modelTransform.localRotation = Quaternion.Slerp(modelTransform.localRotation, targetRotation, Time.deltaTime * 20f);
				targetRotation = Quaternion.Slerp(targetRotation, restRotation, Time.deltaTime * 9f);
				if ((Input.GetMouseButtonDown(0) || ((Object)(object)MonoSingleton<InputManager>.Instance != (Object)null && MonoSingleton<InputManager>.Instance.InputSource.Fire1.WasPerformedThisFrame)) && swingTimer <= 0f)
				{
					swingTimer = swingCooldown;
					PerformGoheiSwingAndParry();
				}
				if ((Input.GetMouseButton(1) || ((Object)(object)MonoSingleton<InputManager>.Instance != (Object)null && MonoSingleton<InputManager>.Instance.InputSource.Fire2.IsPressed)) && danmakuTimer <= 0f)
				{
					danmakuTimer = danmakuCooldown;
					FireDanmakuWave();
				}
			}
		}

		private void PerformGoheiSwingAndParry()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: 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_005e: 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)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_017f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			targetRotation = restRotation * Quaternion.Euler(40f, -85f, 45f);
			if ((Object)(object)audioSource != (Object)null)
			{
				audioSource.Play();
			}
			if ((Object)(object)MonoSingleton<CameraController>.Instance == (Object)null)
			{
				return;
			}
			Transform transform = ((Component)MonoSingleton<CameraController>.Instance).transform;
			Vector3 val = transform.position + transform.forward * 2.2f;
			Collider[] array = Physics.OverlapSphere(val, parryRadius);
			for (int i = 0; i < array.Length; i++)
			{
				Projectile component = ((Component)array[i]).GetComponent<Projectile>();
				if ((Object)(object)component != (Object)null && !component.friendly && !component.undeflectable)
				{
					component.friendly = true;
					component.playerBullet = true;
					component.speed *= 2.5f;
					component.damage *= 2f;
					component.explosionEffect = component.explosionEffect;
					((Component)component).transform.forward = transform.forward;
					if ((Object)(object)MonoSingleton<TimeController>.Instance != (Object)null)
					{
						MonoSingleton<TimeController>.Instance.ParryFlash();
					}
					if ((Object)(object)MonoSingleton<NewMovement>.Instance != (Object)null)
					{
						MonoSingleton<NewMovement>.Instance.GetHealth(999, false, false, true);
					}
					if ((Object)(object)MonoSingleton<StyleHUD>.Instance != (Object)null)
					{
						MonoSingleton<StyleHUD>.Instance.AddPoints(100, "<color=#6c14c9>LUNATIC PARRY</color><color=#FFFFFF>", ((Component)this).gameObject, (EnemyIdentifier)null, -1, "", "");
					}
				}
			}
			array = Physics.OverlapSphere(val, meleeRange, LayerMask.op_Implicit(enemyLayer));
			foreach (Collider val2 in array)
			{
				EnemyIdentifier componentInParent = ((Component)val2).GetComponentInParent<EnemyIdentifier>();
				if ((Object)(object)componentInParent != (Object)null && !componentInParent.dead)
				{
					bool num = !componentInParent.dead;
					componentInParent.DeliverDamage(((Component)componentInParent).gameObject, transform.forward * 30f, val2.ClosestPoint(transform.position), meleeDamage, true, 0f, ((Component)this).gameObject, false, false);
					if ((Object)(object)MonoSingleton<NewMovement>.Instance != (Object)null)
					{
						MonoSingleton<NewMovement>.Instance.GetHealth(15, true, false, true);
					}
					if (num && componentInParent.dead && (Object)(object)MonoSingleton<StyleHUD>.Instance != (Object)null)
					{
						MonoSingleton<StyleHUD>.Instance.AddPoints(120, "<color=#6316ab>PURIFIED</color><color=#FFFFFF>", ((Component)this).gameObject, componentInParent, -1, "", "");
					}
				}
			}
		}

		private void FireDanmakuWave()
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: 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)
			if (!((Object)(object)Plugin.DanmakuOrbPrefab == (Object)null) && !((Object)(object)MonoSingleton<CameraController>.Instance == (Object)null))
			{
				Transform transform = ((Component)MonoSingleton<CameraController>.Instance).transform;
				float[] array = new float[5] { -16f, -8f, 0f, 8f, 16f };
				foreach (float num in array)
				{
					Quaternion val = transform.rotation * Quaternion.Euler(0f, num, 0f);
					GameObject obj = Object.Instantiate<GameObject>(Plugin.DanmakuOrbPrefab, transform.position + transform.forward * 0.9f, val);
					obj.transform.localScale = Vector3.one * 2.5f;
					obj.AddComponent<DanmakuOrbProjectile>();
				}
			}
		}
	}
	public class DanmakuOrbProjectile : MonoBehaviour
	{
		public float speed = 55f;

		public float damage = 1.2f;

		public float lifeTime = 3.5f;

		private void Start()
		{
			Object.Destroy((Object)(object)((Component)this).gameObject, lifeTime);
		}

		private void Update()
		{
			//IL_0007: 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_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			Transform transform = ((Component)this).transform;
			transform.position += ((Component)this).transform.forward * speed * Time.deltaTime;
		}

		private void OnTriggerEnter(Collider other)
		{
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			if (((Component)other).gameObject.layer == 2 || (Object)(object)((Component)other).GetComponent<DanmakuOrbProjectile>() != (Object)null)
			{
				return;
			}
			EnemyIdentifier componentInParent = ((Component)other).GetComponentInParent<EnemyIdentifier>();
			if ((Object)(object)componentInParent != (Object)null && !componentInParent.dead)
			{
				bool num = !componentInParent.dead;
				componentInParent.DeliverDamage(((Component)componentInParent).gameObject, ((Component)this).transform.forward * 6f, ((Component)this).transform.position, damage, false, 0f, ((Component)this).gameObject, false, false);
				if (num && componentInParent.dead && (Object)(object)MonoSingleton<StyleHUD>.Instance != (Object)null)
				{
					MonoSingleton<StyleHUD>.Instance.AddPoints(100, "<color=#ff1212>BULLET HELL</color><color=#FFFFFF>", ((Component)this).gameObject, componentInParent, -1, "", "");
				}
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
			else if (!other.isTrigger)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
	public class SakuyaKnivesController : MonoBehaviour
	{
		public Transform modelTransform;

		public float throwCooldown = 0.28f;

		public float suspendInterval = 0.08f;

		public int maxSuspendedKnives = 12;

		private float throwTimer;

		private float suspendTimer;

		private bool isChargingTimeStop;

		private Vector3 restPos;

		private AudioSource audioSource;

		private List<SakuyaKnifeProjectile> suspendedKnives = new List<SakuyaKnifeProjectile>();

		private void Start()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)modelTransform == (Object)null)
			{
				modelTransform = ((Component)this).transform;
			}
			restPos = modelTransform.localPosition;
			audioSource = ((Component)this).GetComponentInChildren<AudioSource>(true);
		}

		private void OnDisable()
		{
			if (isChargingTimeStop)
			{
				ReleaseSuspendedKnives();
			}
		}

		private void Update()
		{
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			if (Time.timeScale <= 0f)
			{
				return;
			}
			throwTimer -= Time.deltaTime;
			suspendTimer -= Time.deltaTime;
			if ((Object)(object)modelTransform != (Object)null)
			{
				modelTransform.localPosition = Vector3.Lerp(modelTransform.localPosition, restPos, Time.deltaTime * 15f);
			}
			if ((Input.GetMouseButton(0) || ((Object)(object)MonoSingleton<InputManager>.Instance != (Object)null && MonoSingleton<InputManager>.Instance.InputSource.Fire1.IsPressed)) && throwTimer <= 0f && !isChargingTimeStop)
			{
				throwTimer = throwCooldown;
				ThrowFanKnives();
			}
			if (Input.GetMouseButton(1) || ((Object)(object)MonoSingleton<InputManager>.Instance != (Object)null && MonoSingleton<InputManager>.Instance.InputSource.Fire2.IsPressed))
			{
				isChargingTimeStop = true;
				if (suspendTimer <= 0f && suspendedKnives.Count < maxSuspendedKnives)
				{
					suspendTimer = suspendInterval;
					SpawnSuspendedKnife();
				}
			}
			else if (isChargingTimeStop)
			{
				ReleaseSuspendedKnives();
			}
		}

		private void ThrowFanKnives()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: 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_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Plugin.SakuyaKnifePrefab == (Object)null) && !((Object)(object)MonoSingleton<CameraController>.Instance == (Object)null))
			{
				Transform transform = ((Component)MonoSingleton<CameraController>.Instance).transform;
				if ((Object)(object)modelTransform != (Object)null)
				{
					modelTransform.localPosition = restPos + new Vector3(0f, 0f, 0.25f);
				}
				if ((Object)(object)audioSource != (Object)null)
				{
					audioSource.Play();
				}
				float[] array = new float[3] { -7f, 0f, 7f };
				foreach (float num in array)
				{
					Quaternion val = transform.rotation * Quaternion.Euler(0f, num, 0f);
					SakuyaKnifeProjectile sakuyaKnifeProjectile = Object.Instantiate<GameObject>(Plugin.SakuyaKnifePrefab, transform.position + transform.forward * 0.9f, val).AddComponent<SakuyaKnifeProjectile>();
					sakuyaKnifeProjectile.isSuspended = false;
					sakuyaKnifeProjectile.isKillingDoll = false;
				}
			}
		}

		private void SpawnSuspendedKnife()
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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: 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_0094: 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)
			//IL_009a: 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_00a2: 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_00c6: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)Plugin.SakuyaKnifePrefab == (Object)null) && !((Object)(object)MonoSingleton<CameraController>.Instance == (Object)null))
			{
				Transform transform = ((Component)MonoSingleton<CameraController>.Instance).transform;
				float num = (float)suspendedKnives.Count / (float)maxSuspendedKnives * (float)Math.PI * 2f;
				Vector3 val = (transform.right * Mathf.Cos(num) + transform.up * Mathf.Sin(num)) * 1.1f;
				Vector3 val2 = transform.position + transform.forward * 1.6f + val;
				SakuyaKnifeProjectile sakuyaKnifeProjectile = Object.Instantiate<GameObject>(Plugin.SakuyaKnifePrefab, val2, transform.rotation).AddComponent<SakuyaKnifeProjectile>();
				sakuyaKnifeProjectile.isSuspended = true;
				sakuyaKnifeProjectile.isKillingDoll = true;
				sakuyaKnifeProjectile.holdOffset = val;
				suspendedKnives.Add(sakuyaKnifeProjectile);
			}
		}

		private void ReleaseSuspendedKnives()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: 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_00ca: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			isChargingTimeStop = false;
			if ((Object)(object)MonoSingleton<CameraController>.Instance == (Object)null)
			{
				return;
			}
			Transform transform = ((Component)MonoSingleton<CameraController>.Instance).transform;
			Vector3 val = transform.position + transform.forward * 2.5f;
			Vector3 val2 = transform.position + transform.forward * 60f;
			RaycastHit val3 = default(RaycastHit);
			if (Physics.Raycast(val, transform.forward, ref val3, 100f, -1, (QueryTriggerInteraction)1) && ((RaycastHit)(ref val3)).distance > 7.5f)
			{
				val2 = ((RaycastHit)(ref val3)).point;
			}
			if ((Object)(object)audioSource != (Object)null)
			{
				audioSource.Play();
			}
			foreach (SakuyaKnifeProjectile suspendedKnife in suspendedKnives)
			{
				if ((Object)(object)suspendedKnife != (Object)null)
				{
					Vector3 val4 = val2 - ((Component)suspendedKnife).transform.position;
					Vector3 normalized = ((Vector3)(ref val4)).normalized;
					((Component)suspendedKnife).transform.rotation = Quaternion.LookRotation(normalized);
					suspendedKnife.isSuspended = false;
					AudioSource component = ((Component)suspendedKnife).GetComponent<AudioSource>();
					if ((Object)(object)component != (Object)null)
					{
						component.Play();
					}
				}
			}
			suspendedKnives.Clear();
		}
	}
	public class SakuyaKnifeProjectile : MonoBehaviour
	{
		public bool isSuspended;

		public bool isKillingDoll;

		public Vector3 holdOffset;

		public float speed = 85f;

		public float damage = 1.4f;

		public float lifeTime = 4f;

		private float aliveTimer;

		private void Update()
		{
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006f: 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)
			if (isSuspended)
			{
				if ((Object)(object)MonoSingleton<CameraController>.Instance != (Object)null)
				{
					Transform transform = ((Component)MonoSingleton<CameraController>.Instance).transform;
					((Component)this).transform.position = transform.position + transform.forward * 1.6f + transform.rotation * new Vector3(holdOffset.x, holdOffset.y, 0f);
					((Component)this).transform.rotation = transform.rotation;
				}
			}
			else
			{
				aliveTimer += Time.deltaTime;
				if (aliveTimer >= lifeTime)
				{
					Object.Destroy((Object)(object)((Component)this).gameObject);
					return;
				}
				Transform transform2 = ((Component)this).transform;
				transform2.position += ((Component)this).transform.forward * speed * Time.deltaTime;
			}
		}

		private void OnTriggerEnter(Collider other)
		{
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			if (isSuspended || ((Component)other).gameObject.layer == 2 || (Object)(object)((Component)other).GetComponent<SakuyaKnifeProjectile>() != (Object)null)
			{
				return;
			}
			EnemyIdentifier componentInParent = ((Component)other).GetComponentInParent<EnemyIdentifier>();
			if ((Object)(object)componentInParent != (Object)null && !componentInParent.dead)
			{
				bool num = !componentInParent.dead;
				componentInParent.DeliverDamage(((Component)componentInParent).gameObject, ((Component)this).transform.forward * 8f, ((Component)this).transform.position, damage, false, 0f, ((Component)this).gameObject, false, false);
				if (num && componentInParent.dead && (Object)(object)MonoSingleton<StyleHUD>.Instance != (Object)null)
				{
					string text = (isKillingDoll ? "<color=#55FF88>KILLING DOLL</color><color=#FFFFFF>" : "<color=#AAFFCC>SILVER KNIFE</color><color=#FFFFFF>");
					MonoSingleton<StyleHUD>.Instance.AddPoints(isKillingDoll ? 140 : 85, text, ((Component)this).gameObject, componentInParent, -1, "", "");
				}
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
			else if (!other.isTrigger)
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
			}
		}
	}
	public class OkuuControlRodController : MonoBehaviour
	{
		public Transform modelTransform;

		public float chargeDuration = 1.6f;

		public float cooldownDuration = 15f;

		public float directBeamDamage = 25f;

		public float maxRange = 120f;

		private float nextFireTime;

		private bool isCharging;

		private Vector3 restPos;

		private AudioSource alarmAudio;

		private AudioSource blastAudio;

		private LayerMask enemyLayer;

		private void Start()
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			if ((Object)(object)modelTransform == (Object)null)
			{
				modelTransform = ((Component)this).transform;
			}
			restPos = modelTransform.localPosition;
			enemyLayer = LayerMask.op_Implicit(5120);
			AudioSource[] componentsInChildren = ((Component)this).GetComponentsInChildren<AudioSource>(true);
			if (componentsInChildren.Length != 0)
			{
				alarmAudio = componentsInChildren.ElementAt(0);
			}
			if (componentsInChildren.Length > 1)
			{
				blastAudio = componentsInChildren.ElementAt(1);
			}
		}

		private void OnDisable()
		{
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			isCharging = false;
			if ((Object)(object)alarmAudio != (Object)null && alarmAudio.isPlaying)
			{
				alarmAudio.Stop();
			}
			if ((Object)(object)modelTransform != (Object)null)
			{
				modelTransform.localPosition = restPos;
			}
		}

		private void Update()
		{
			if (Time.timeScale <= 0f)
			{
				return;
			}
			float num = nextFireTime - Time.time;
			if ((Input.GetMouseButtonDown(0) || ((Object)(object)MonoSingleton<InputManager>.Instance != (Object)null && MonoSingleton<InputManager>.Instance.InputSource.Fire1.WasPerformedThisFrame)) && !isCharging)
			{
				if (num <= 0f)
				{
					((MonoBehaviour)this).StartCoroutine(ChargeAndFireNuclearBeam());
				}
				else if ((Object)(object)MonoSingleton<SubtitleController>.Instance != (Object)null)
				{
					MonoSingleton<SubtitleController>.Instance.DisplaySubtitle($"COOLING: {num:F1}s", (AudioSource)null, false);
				}
			}
		}

		private IEnumerator ChargeAndFireNuclearBeam()
		{
			isCharging = true;
			if ((Object)(object)alarmAudio != (Object)null)
			{
				alarmAudio.Play();
			}
			float elapsed = 0f;
			while (elapsed < chargeDuration)
			{
				elapsed += Time.deltaTime;
				if ((Object)(object)modelTransform != (Object)null)
				{
					float num = Mathf.Lerp(0.01f, 0.045f, elapsed / chargeDuration);
					Vector3 val = Random.insideUnitSphere * num;
					modelTransform.localPosition = restPos + new Vector3(0f, 0f, -0.15f * (elapsed / chargeDuration)) + val;
				}
				if ((Object)(object)MonoSingleton<CameraController>.Instance != (Object)null)
				{
					MonoSingleton<CameraController>.Instance.CameraShake(0.3f);
				}
				yield return null;
			}
			if ((Object)(object)alarmAudio != (Object)null && alarmAudio.isPlaying)
			{
				alarmAudio.Stop();
			}
			FireNuclearBlast();
			if ((Object)(object)modelTransform != (Object)null)
			{
				modelTransform.localPosition = restPos;
			}
			nextFireTime = Time.time + cooldownDuration;
			isCharging = false;
		}

		private void FireNuclearBlast()
		{
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: 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_007c: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: 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_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: 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_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: 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_00cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: 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_00fc: 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_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0116: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_039a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: 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)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_031f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0261: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0406: Unknown result type (might be due to invalid IL or missing references)
			//IL_040b: Unknown result type (might be due to invalid IL or missing references)
			//IL_040c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0411: Unknown result type (might be due to invalid IL or missing references)
			//IL_0415: Unknown result type (might be due to invalid IL or missing references)
			//IL_041a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0424: Unknown result type (might be due to invalid IL or missing references)
			//IL_0429: Unknown result type (might be due to invalid IL or missing references)
			//IL_042e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0439: Unknown result type (might be due to invalid IL or missing references)
			//IL_0440: Unknown result type (might be due to invalid IL or missing references)
			//IL_0445: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)blastAudio != (Object)null)
			{
				blastAudio.Play();
			}
			if ((Object)(object)MonoSingleton<CameraController>.Instance == (Object)null)
			{
				return;
			}
			Transform transform = ((Component)MonoSingleton<CameraController>.Instance).transform;
			MonoSingleton<CameraController>.Instance.CameraShake(3.5f);
			if ((Object)(object)MonoSingleton<NewMovement>.Instance != (Object)null)
			{
				MonoSingleton<NewMovement>.Instance.Launch(-transform.forward * 30f, 8f, false);
			}
			Vector3 position = transform.position;
			Vector3 val = position + transform.forward * maxRange;
			int num = -16389;
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(position, transform.forward, ref val2, maxRange, num, (QueryTriggerInteraction)1))
			{
				val = ((RaycastHit)(ref val2)).point - transform.forward * 0.25f;
			}
			float num2 = Vector3.Distance(position, val);
			if ((Object)(object)Plugin.OkuuBeamPrefab != (Object)null)
			{
				Vector3 val3 = transform.position + transform.forward * 1f - transform.up * 0.2f;
				GameObject val4 = Object.Instantiate<GameObject>(Plugin.OkuuBeamPrefab, val3, Quaternion.LookRotation(val - val3));
				val4.transform.localScale = new Vector3(1f, 1f, num2 / 100f);
				Transform[] componentsInChildren = val4.GetComponentsInChildren<Transform>(true);
				Color color = default(Color);
				foreach (Transform val5 in componentsInChildren)
				{
					if (((Object)val5).name.ToLower().Contains("outer"))
					{
						Renderer component = ((Component)val5).GetComponent<Renderer>();
						if ((Object)(object)component != (Object)null)
						{
							((Color)(ref color))..ctor(1f, 0.35f, 0.05f, 0.45f);
							component.material.color = color;
						}
					}
				}
				((MonoBehaviour)this).StartCoroutine(FadeOutBeam(val4, 0.65f));
			}
			RaycastHit[] array = Physics.SphereCastAll(position, 2.2f, transform.forward, num2, LayerMask.op_Implicit(enemyLayer));
			for (int i = 0; i < array.Length; i++)
			{
				RaycastHit val6 = array[i];
				EnemyIdentifier componentInParent = ((Component)((RaycastHit)(ref val6)).collider).GetComponentInParent<EnemyIdentifier>();
				if ((Object)(object)componentInParent != (Object)null && !componentInParent.dead)
				{
					bool num3 = !componentInParent.dead;
					componentInParent.DeliverDamage(((Component)componentInParent).gameObject, transform.forward * 50f, ((RaycastHit)(ref val6)).point, directBeamDamage, true, 0f, ((Component)this).gameObject, false, false);
					Flammable componentInChildren = ((Component)componentInParent).GetComponentInChildren<Flammable>();
					if ((Object)(object)componentInChildren != (Object)null)
					{
						componentInChildren.Burn(8f, false);
					}
					if (num3 && componentInParent.dead && (Object)(object)MonoSingleton<StyleHUD>.Instance != (Object)null)
					{
						MonoSingleton<StyleHUD>.Instance.AddPoints(250, "<color=#FF6600>SUBTERRANEAN SUN</color><color=#FFFFFF>", ((Component)this).gameObject, componentInParent, -1, "", "");
					}
				}
			}
			if ((Object)(object)GunControl_Start_Patch.MaliciousExplosionPrefab != (Object)null)
			{
				GameObject obj = Object.Instantiate<GameObject>(GunControl_Start_Patch.MaliciousExplosionPrefab, val, Quaternion.identity);
				obj.transform.localScale = Vector3.one * 2.8f;
				Explosion[] componentsInChildren2 = obj.GetComponentsInChildren<Explosion>(true);
				foreach (Explosion obj2 in componentsInChildren2)
				{
					obj2.maxSize *= 2.8f;
					obj2.speed *= 1.5f;
					obj2.damage = Mathf.RoundToInt((float)obj2.damage * 2.8f);
					obj2.enemyDamageMultiplier = 3f;
					obj2.playerDamageOverride = 0;
				}
			}
			else
			{
				((MonoBehaviour)this).StartCoroutine(SpawnFallbackNuclearDome(val, 18f, 0.6f));
			}
			Collider[] array2 = Physics.OverlapSphere(val, 18f, LayerMask.op_Implicit(enemyLayer));
			for (int i = 0; i < array2.Length; i++)
			{
				EnemyIdentifier componentInParent2 = ((Component)array2[i]).GetComponentInParent<EnemyIdentifier>();
				if ((Object)(object)componentInParent2 != (Object)null && !componentInParent2.dead)
				{
					bool num4 = !componentInParent2.dead;
					Vector3 val7 = ((Component)componentInParent2).transform.position - val;
					Vector3 val8 = ((Vector3)(ref val7)).normalized + Vector3.up * 0.4f;
					componentInParent2.DeliverDamage(((Component)componentInParent2).gameObject, val8 * 45f, val, directBeamDamage * 0.85f, true, 0f, ((Component)this).gameObject, false, false);
					Flammable componentInChildren2 = ((Component)componentInParent2).GetComponentInChildren<Flammable>();
					if ((Object)(object)componentInChildren2 != (Object)null)
					{
						componentInChildren2.Burn(8f, false);
					}
					if (num4 && componentInParent2.dead && (Object)(object)MonoSingleton<StyleHUD>.Instance != (Object)null)
					{
						MonoSingleton<StyleHUD>.Instance.AddPoints(250, "<color=#FF6600>NUCLEAR FUSION</color><color=#FFFFFF>", ((Component)this).gameObject, componentInParent2, -1, "", "");
					}
				}
			}
		}

		private IEnumerator FadeOutBeam(GameObject beam, float duration)
		{
			if ((Object)(object)beam == (Object)null)
			{
				yield break;
			}
			Vector3 startScale = beam.transform.localScale;
			float elapsed = 0f;
			Transform[] componentsInChildren = beam.GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				if (((Object)val).name.ToLower().Contains("outer"))
				{
					Renderer component = ((Component)val).GetComponent<Renderer>();
					if ((Object)(object)component != (Object)null)
					{
						component.material.shader = Shader.Find("Sprites/Default");
						component.material.color = new Color(1f, 0.35f, 0.05f, 0.22f);
					}
				}
			}
			while (elapsed < duration && (Object)(object)beam != (Object)null)
			{
				elapsed += Time.deltaTime;
				float num = elapsed / duration;
				float num2 = Mathf.Lerp(1f, 0f, num * num);
				beam.transform.localScale = new Vector3(startScale.x * num2, startScale.y * num2, startScale.z);
				yield return null;
			}
			if ((Object)(object)beam != (Object)null)
			{
				Object.Destroy((Object)(object)beam);
			}
		}

		private IEnumerator SpawnFallbackNuclearDome(Vector3 center, float maxRadius, float duration)
		{
			//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)
			GameObject dome = GameObject.CreatePrimitive((PrimitiveType)0);
			Object.Destroy((Object)(object)dome.GetComponent<Collider>());
			dome.transform.position = center;
			Renderer r = dome.GetComponent<Renderer>();
			if ((Object)(object)r != (Object)null)
			{
				r.material = new Material(Shader.Find("Sprites/Default"));
				r.material.color = new Color(1f, 0.25f, 0.05f, 0.7f);
			}
			float elapsed = 0f;
			while (elapsed < duration && (Object)(object)dome != (Object)null)
			{
				elapsed += Time.deltaTime;
				float num = elapsed / duration;
				float num2 = Mathf.Lerp(1f, maxRadius * 2f, 1f - Mathf.Pow(1f - num, 3f));
				dome.transform.localScale = Vector3.one * num2;
				if ((Object)(object)r != (Object)null)
				{
					Color color = r.material.color;
					color.a = Mathf.Lerp(0.75f, 0f, num);
					r.material.color = color;
				}
				yield return null;
			}
			if ((Object)(object)dome != (Object)null)
			{
				Object.Destroy((Object)(object)dome);
			}
		}
	}
	public class CustomHUDIconKeeper : MonoBehaviour
	{
		public Sprite mainIcon;

		public Sprite glowIcon;

		public Color hudColor = Color.white;

		private Image mainImg;

		private Image glowImg;

		private void OnEnable()
		{
			if ((Object)(object)mainIcon == (Object)null)
			{
				return;
			}
			WeaponHUD[] array = Object.FindObjectsOfType<WeaponHUD>(true);
			foreach (WeaponHUD val in array)
			{
				if ((Object)(object)val == (Object)null)
				{
					continue;
				}
				Image[] componentsInChildren = ((Component)val).GetComponentsInChildren<Image>(true);
				foreach (Image val2 in componentsInChildren)
				{
					if (!((Object)(object)val2 == (Object)null))
					{
						if (((Object)((Component)val2).gameObject).name == "Image (1)")
						{
							glowImg = val2;
						}
						else if (((Object)((Component)val2).gameObject).name == "Image")
						{
							mainImg = val2;
						}
					}
				}
			}
		}

		private void LateUpdate()
		{
			//IL_0035: 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)
			if (!((Object)(object)mainIcon == (Object)null))
			{
				if ((Object)(object)mainImg != (Object)null)
				{
					mainImg.sprite = mainIcon;
					((Graphic)mainImg).color = hudColor;
				}
				if ((Object)(object)glowImg != (Object)null)
				{
					glowImg.sprite = (((Object)(object)glowIcon != (Object)null) ? glowIcon : mainIcon);
					((Graphic)glowImg).color = hudColor;
				}
			}
		}
	}
}