Decompiled source of VoidFiendNexus v0.1.0

BepInEx/plugins/GigaMod_AllMerged.dll

Decompiled 4 days ago
using System;
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 BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.VoidSurvivor.CorruptMode;
using EntityStates.VoidSurvivor.Weapon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using On.EntityStates.VoidSurvivor.Weapon;
using On.RoR2;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Skills;
using RoR2.UI;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.SceneManagement;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("GigaMod_AllMerged")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+1a2875b51e224937bfa1a18b56d638eda3da2ef3")]
[assembly: AssemblyProduct("GigaMod_AllMerged")]
[assembly: AssemblyTitle("GigaMod_AllMerged")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
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;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.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;
		}
	}
}
[BepInPlugin("com.yourname.voidmodemuzzleflash", "Void Mode Muzzleflash Ramp Swap", "1.0.0")]
public class VoidModeMuzzleflashPlugin : BaseUnityPlugin
{
	private static Texture2D customRampTexture;

	private static Texture originalRampTexture;

	private static Material targetMaterial;

	private static VoidSurvivorController currentVoidController;

	private static BuffDef corruptedBuffDef;

	public void Awake()
	{
		//IL_003f: Unknown result type (might be due to invalid IL or missing references)
		//IL_0049: Expected O, but got Unknown
		//IL_0051: Unknown result type (might be due to invalid IL or missing references)
		//IL_005b: Expected O, but got Unknown
		//IL_0063: Unknown result type (might be due to invalid IL or missing references)
		//IL_006d: Expected O, but got Unknown
		LoadCustomTexture();
		if ((Object)(object)customRampTexture != (Object)null)
		{
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, new Action(OnGameLoad));
			CharacterBody.Start += new hook_Start(CharacterBody_Start);
			CharacterBody.AddBuff_BuffIndex += new hook_AddBuff_BuffIndex(CharacterBody_AddBuff);
			CharacterBody.RemoveBuff_BuffIndex += new hook_RemoveBuff_BuffIndex(CharacterBody_RemoveBuff);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Void Mode Muzzleflash Ramp Swap initialized successfully!");
		}
		else
		{
			((BaseUnityPlugin)this).Logger.LogError((object)"Failed to load custom ramp texture. The mod will not function.");
		}
	}

	private void LoadCustomTexture()
	{
		//IL_0058: Unknown result type (might be due to invalid IL or missing references)
		//IL_0062: Expected O, but got Unknown
		Assembly executingAssembly = Assembly.GetExecutingAssembly();
		string text = "template.OmnisparkRed.png";
		try
		{
			using Stream stream = executingAssembly.GetManifestResourceStream(text);
			if (stream == null)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)("Embedded resource not found: " + text));
				return;
			}
			byte[] array = new byte[stream.Length];
			stream.Read(array, 0, array.Length);
			customRampTexture = new Texture2D(2, 2, (TextureFormat)4, false);
			ImageConversion.LoadImage(customRampTexture, array);
			Object.DontDestroyOnLoad((Object)(object)customRampTexture);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Successfully loaded custom ramp texture.");
		}
		catch (Exception arg)
		{
			((BaseUnityPlugin)this).Logger.LogError((object)$"Error loading embedded resource: {arg}");
		}
	}

	private void OnGameLoad()
	{
		string targetMaterialName = "matOmniHitsparkVoid";
		targetMaterial = ((IEnumerable<Material>)Resources.FindObjectsOfTypeAll<Material>()).FirstOrDefault((Func<Material, bool>)((Material mat) => ((Object)mat).name == targetMaterialName));
		if (Object.op_Implicit((Object)(object)targetMaterial))
		{
			originalRampTexture = targetMaterial.GetTexture("_RemapTex");
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Found material '" + targetMaterialName + "' and cached original texture."));
		}
		else
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not find material '" + targetMaterialName + "'."));
		}
		corruptedBuffDef = ((IEnumerable<BuffDef>)Resources.FindObjectsOfTypeAll<BuffDef>()).FirstOrDefault((Func<BuffDef, bool>)((BuffDef buff) => ((Object)buff).name.Contains("VoidSurvivorCorrupt") || ((Object)buff).name.Contains("bdVoidSurvivorCorruptMode")));
		if (Object.op_Implicit((Object)(object)corruptedBuffDef))
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)("Found corrupted buff: " + ((Object)corruptedBuffDef).name));
		}
		else
		{
			((BaseUnityPlugin)this).Logger.LogWarning((object)"Could not find Void Survivor corruption buff.");
		}
	}

	private void CharacterBody_Start(orig_Start orig, CharacterBody self)
	{
		orig.Invoke(self);
		if (!self.isPlayerControlled || !(self.baseNameToken == "VOIDSURVIVOR_BODY_NAME"))
		{
			return;
		}
		currentVoidController = ((Component)self).GetComponent<VoidSurvivorController>();
		if (Object.op_Implicit((Object)(object)currentVoidController))
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Detected Void Fiend spawn - monitoring corruption state.");
			if ((Object)(object)corruptedBuffDef == (Object)null && (Object)(object)currentVoidController.corruptedBuffDef != (Object)null)
			{
				corruptedBuffDef = currentVoidController.corruptedBuffDef;
				((BaseUnityPlugin)this).Logger.LogInfo((object)("Got corrupted buff from controller: " + ((Object)corruptedBuffDef).name));
			}
		}
	}

	private void CharacterBody_AddBuff(orig_AddBuff_BuffIndex orig, CharacterBody self, BuffIndex buffIndex)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: 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)
		orig.Invoke(self, buffIndex);
		if ((Object)(object)corruptedBuffDef != (Object)null && buffIndex == corruptedBuffDef.buffIndex && self.isPlayerControlled && self.baseNameToken == "VOIDSURVIVOR_BODY_NAME")
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Void mode entered - swapping to custom muzzleflash texture!");
			SwapToCustomTexture();
		}
	}

	private void CharacterBody_RemoveBuff(orig_RemoveBuff_BuffIndex orig, CharacterBody self, BuffIndex buffIndex)
	{
		//IL_0003: Unknown result type (might be due to invalid IL or missing references)
		//IL_0017: 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)
		orig.Invoke(self, buffIndex);
		if ((Object)(object)corruptedBuffDef != (Object)null && buffIndex == corruptedBuffDef.buffIndex && self.isPlayerControlled && self.baseNameToken == "VOIDSURVIVOR_BODY_NAME")
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Void mode exited - restoring original muzzleflash texture!");
			RestoreOriginalTexture();
		}
	}

	private void SwapToCustomTexture()
	{
		if (Object.op_Implicit((Object)(object)targetMaterial) && Object.op_Implicit((Object)(object)customRampTexture))
		{
			targetMaterial.SetTexture("_RemapTex", (Texture)(object)customRampTexture);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Successfully applied custom ramp texture.");
		}
	}

	private void RestoreOriginalTexture()
	{
		if (Object.op_Implicit((Object)(object)targetMaterial) && Object.op_Implicit((Object)(object)originalRampTexture))
		{
			targetMaterial.SetTexture("_RemapTex", originalRampTexture);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Successfully restored original ramp texture.");
		}
	}

	private void OnDestroy()
	{
		RestoreOriginalTexture();
	}
}
namespace VoidSurvivorColorMod
{
	[BepInPlugin("com.bartek.voidsurvivorcolormod", "VoidSurvivorColorMod", "1.0.0")]
	public class VoidSurvivorColorModPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "com.bartek.voidsurvivorcolormod";

		public const string PluginName = "VoidSurvivorColorMod";

		public const string PluginVersion = "1.0.0";

		private static readonly Color pointLightColor = new Color(0.6f, 0f, 1f, 0.15f);

		private static readonly Color brightFlashColor = new Color(1f, 0.2968f, 1f, 1f);

		private static readonly Color muzzleflashPointLightColor = new Color(0.6f, 0f, 1f, 0.15f);

		private static readonly Color chargeCrushHealthPointLightColor = new Color(1f, 0f, 0f, 1f);

		private static readonly Color megaBlasterBigGhostPointLightColor = new Color(0.6f, 0f, 1f, 0.15f);

		private static readonly Color chargeMegaBlasterPointLightColor = new Color(0.6f, 0f, 1f, 0.15f);

		private static readonly Color readyMegaBlasterPointLightColor = new Color(0.6f, 0f, 1f, 0.15f);

		private static readonly Color voidBlinkVfxPointLightColor = new Color(0.6f, 0f, 1f, 0.15f);

		private static readonly Color megaBlasterSmallGhostPointLightColor = new Color(0.6f, 0f, 1f, 0.15f);

		private readonly Dictionary<Light, Color> originalLightColors = new Dictionary<Light, Color>();

		private readonly Dictionary<ParticleSystem, Color> originalParticleStartColors = new Dictionary<ParticleSystem, Color>();

		private readonly Dictionary<ParticleSystem, MinMaxGradient> originalParticleGradients = new Dictionary<ParticleSystem, MinMaxGradient>();

		private void Awake()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Plugin com.bartek.voidsurvivorcolormod is loaded!");
			EffectCatalog.Init += new hook_Init(EffectCatalog_Init);
		}

		private void EffectCatalog_Init(orig_Init orig)
		{
			orig.Invoke();
			ModifyVoidSurvivorBeamImpact();
			ModifyVoidSurvivorChargeCrushHealth();
			ModifyVoidSurvivorMegaBlasterBigGhost();
			ModifyVoidSurvivorChargeMegaBlaster();
			ModifyVoidSurvivorReadyMegaBlaster();
			ModifyVoidBlinkVfx();
			ModifyVoidSurvivorMegaBlasterSmallGhost();
		}

		private void ModifyVoidSurvivorBeamImpact()
		{
			GameObject val = FindVoidSurvivorBeamImpactPrefab();
			if ((Object)(object)val != (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Found VoidSurvivorBeamImpact prefab, applying color changes...");
				ModifyPointLight(val);
				ModifyBrightFlashParticles(val);
				((BaseUnityPlugin)this).Logger.LogInfo((object)"VoidSurvivorBeamImpact color modifications applied successfully!");
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Could not find VoidSurvivorBeamImpact prefab!");
			}
			ModifyVoidSurvivorBeamMuzzleflash();
		}

		private GameObject FindVoidSurvivorBeamImpactPrefab()
		{
			GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
			GameObject[] array2 = array;
			foreach (GameObject val in array2)
			{
				if (((Object)val).name == "VoidSurvivorBeamImpact")
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)("Found VoidSurvivorBeamImpact via Resources: " + ((Object)val).name));
					return val;
				}
			}
			for (int j = 0; j < EffectCatalog.effectCount; j++)
			{
				EffectDef effectDef = EffectCatalog.GetEffectDef((EffectIndex)j);
				object obj;
				if (effectDef == null)
				{
					obj = null;
				}
				else
				{
					GameObject prefab = effectDef.prefab;
					obj = ((prefab != null) ? ((Object)prefab).name : null);
				}
				if ((string?)obj == "VoidSurvivorBeamImpact")
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)$"Found VoidSurvivorBeamImpact in EffectCatalog at index {j}");
					return effectDef.prefab;
				}
			}
			((BaseUnityPlugin)this).Logger.LogWarning((object)"VoidSurvivorBeamImpact prefab not found in standard locations, searching all effects...");
			for (int k = 0; k < EffectCatalog.effectCount; k++)
			{
				EffectDef effectDef2 = EffectCatalog.GetEffectDef((EffectIndex)k);
				if ((Object)(object)((effectDef2 != null) ? effectDef2.prefab : null) != (Object)null && ((Object)effectDef2.prefab).name.ToLower().Contains("void"))
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)("Found void-related effect: " + ((Object)effectDef2.prefab).name));
					if (((Object)effectDef2.prefab).name.Contains("BeamImpact"))
					{
						((BaseUnityPlugin)this).Logger.LogInfo((object)("Found beam impact effect, checking: " + ((Object)effectDef2.prefab).name));
						return effectDef2.prefab;
					}
				}
			}
			return null;
		}

		private void ModifyPointLight(GameObject prefab)
		{
			//IL_0060: 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_0087: 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)
			Transform val = FindChildByName(prefab.transform, "Point Light");
			if ((Object)(object)val != (Object)null)
			{
				Light component = ((Component)val).GetComponent<Light>();
				if ((Object)(object)component != (Object)null)
				{
					if (!originalLightColors.ContainsKey(component))
					{
						originalLightColors[component] = component.color;
					}
					component.color = pointLightColor;
					((BaseUnityPlugin)this).Logger.LogInfo((object)$"Changed Point Light color from {originalLightColors[component]} to {pointLightColor}");
				}
				else
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)"Point Light component not found on Point Light GameObject");
				}
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"Point Light child object not found");
			}
		}

		private void ModifyBrightFlashParticles(GameObject prefab)
		{
			//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_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_00b8: 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_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0102: Expected O, but got Unknown
			//IL_0112: Unknown result type (might be due to invalid IL or missing references)
			//IL_0117: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			Transform val = FindChildByName(prefab.transform, "BrightFlash");
			if ((Object)(object)val != (Object)null)
			{
				ParticleSystem component = ((Component)val).GetComponent<ParticleSystem>();
				if ((Object)(object)component != (Object)null)
				{
					MainModule main = component.main;
					if (!originalParticleStartColors.ContainsKey(component))
					{
						Dictionary<ParticleSystem, Color> dictionary = originalParticleStartColors;
						MinMaxGradient startColor = ((MainModule)(ref main)).startColor;
						dictionary[component] = ((MinMaxGradient)(ref startColor)).color;
					}
					((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(brightFlashColor);
					((BaseUnityPlugin)this).Logger.LogInfo((object)$"Changed BrightFlash particle system color from {originalParticleStartColors[component]} to {brightFlashColor}");
					ColorOverLifetimeModule colorOverLifetime = component.colorOverLifetime;
					if (((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled)
					{
						if (!originalParticleGradients.ContainsKey(component))
						{
							originalParticleGradients[component] = ((ColorOverLifetimeModule)(ref colorOverLifetime)).color;
						}
						Gradient val2 = new Gradient();
						GradientColorKey[] array = (GradientColorKey[])(object)new GradientColorKey[2];
						array[0].color = brightFlashColor;
						array[0].time = 0f;
						array[1].color = brightFlashColor;
						array[1].time = 1f;
						GradientAlphaKey[] array2 = (GradientAlphaKey[])(object)new GradientAlphaKey[2];
						array2[0].alpha = 1f;
						array2[0].time = 0f;
						array2[1].alpha = 0f;
						array2[1].time = 1f;
						val2.SetKeys(array, array2);
						((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val2);
						((BaseUnityPlugin)this).Logger.LogInfo((object)"Updated BrightFlash color over lifetime gradient");
					}
				}
				else
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)"ParticleSystem component not found on BrightFlash GameObject");
				}
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"BrightFlash child object not found");
			}
		}

		private void ModifyVoidSurvivorBeamMuzzleflash()
		{
			GameObject val = FindVoidSurvivorBeamMuzzleflashPrefab();
			if ((Object)(object)val != (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Found VoidSurvivorBeamMuzzleflash prefab, applying color changes...");
				ModifyMuzzleflashPointLight(val);
				((BaseUnityPlugin)this).Logger.LogInfo((object)"VoidSurvivorBeamMuzzleflash color modifications applied successfully!");
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Could not find VoidSurvivorBeamMuzzleflash prefab!");
			}
		}

		private GameObject FindVoidSurvivorBeamMuzzleflashPrefab()
		{
			GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
			GameObject[] array2 = array;
			foreach (GameObject val in array2)
			{
				if (((Object)val).name == "VoidSurvivorBeamMuzzleflash")
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)("Found VoidSurvivorBeamMuzzleflash via Resources: " + ((Object)val).name));
					return val;
				}
			}
			for (int j = 0; j < EffectCatalog.effectCount; j++)
			{
				EffectDef effectDef = EffectCatalog.GetEffectDef((EffectIndex)j);
				object obj;
				if (effectDef == null)
				{
					obj = null;
				}
				else
				{
					GameObject prefab = effectDef.prefab;
					obj = ((prefab != null) ? ((Object)prefab).name : null);
				}
				if ((string?)obj == "VoidSurvivorBeamMuzzleflash")
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)$"Found VoidSurvivorBeamMuzzleflash in EffectCatalog at index {j}");
					return effectDef.prefab;
				}
			}
			((BaseUnityPlugin)this).Logger.LogWarning((object)"VoidSurvivorBeamMuzzleflash prefab not found in standard locations, searching all effects...");
			for (int k = 0; k < EffectCatalog.effectCount; k++)
			{
				EffectDef effectDef2 = EffectCatalog.GetEffectDef((EffectIndex)k);
				if ((Object)(object)((effectDef2 != null) ? effectDef2.prefab : null) != (Object)null && ((Object)effectDef2.prefab).name.ToLower().Contains("muzzle"))
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)("Found muzzle-related effect: " + ((Object)effectDef2.prefab).name));
					if (((Object)effectDef2.prefab).name.Contains("VoidSurvivor"))
					{
						((BaseUnityPlugin)this).Logger.LogInfo((object)("Found VoidSurvivor muzzle effect, checking: " + ((Object)effectDef2.prefab).name));
						return effectDef2.prefab;
					}
				}
			}
			return null;
		}

		private void ModifyMuzzleflashPointLight(GameObject prefab)
		{
			//IL_0060: 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_0087: 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)
			Transform val = FindChildByName(prefab.transform, "Point Light");
			if ((Object)(object)val != (Object)null)
			{
				Light component = ((Component)val).GetComponent<Light>();
				if ((Object)(object)component != (Object)null)
				{
					if (!originalLightColors.ContainsKey(component))
					{
						originalLightColors[component] = component.color;
					}
					component.color = muzzleflashPointLightColor;
					((BaseUnityPlugin)this).Logger.LogInfo((object)$"Changed VoidSurvivorBeamMuzzleflash Point Light color from {originalLightColors[component]} to {muzzleflashPointLightColor}");
				}
				else
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)"Point Light component not found on VoidSurvivorBeamMuzzleflash Point Light GameObject");
				}
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)"Point Light child object not found in VoidSurvivorBeamMuzzleflash");
			}
		}

		private void ModifyVoidSurvivorChargeCrushHealth()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = FindEffectPrefab("VoidSurvivorChargeCrushHealth");
			if ((Object)(object)val != (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Found VoidSurvivorChargeCrushHealth prefab, applying color changes...");
				ModifySpecificPointLight(val, "Point Light", chargeCrushHealthPointLightColor, "VoidSurvivorChargeCrushHealth");
				((BaseUnityPlugin)this).Logger.LogInfo((object)"VoidSurvivorChargeCrushHealth color modifications applied successfully!");
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Could not find VoidSurvivorChargeCrushHealth prefab!");
			}
		}

		private void ModifyVoidSurvivorMegaBlasterBigGhost()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = FindEffectPrefab("VoidSurvivorMegaBlasterBigGhost");
			if ((Object)(object)val != (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Found VoidSurvivorMegaBlasterBigGhost prefab, applying color changes...");
				ModifySpecificPointLight(val, "Point Light", megaBlasterBigGhostPointLightColor, "VoidSurvivorMegaBlasterBigGhost");
				((BaseUnityPlugin)this).Logger.LogInfo((object)"VoidSurvivorMegaBlasterBigGhost color modifications applied successfully!");
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Could not find VoidSurvivorMegaBlasterBigGhost prefab!");
			}
		}

		private void ModifyVoidSurvivorChargeMegaBlaster()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = FindEffectPrefab("VoidSurvivorChargeMegaBlaster");
			if ((Object)(object)val != (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Found VoidSurvivorChargeMegaBlaster prefab, applying color changes...");
				ModifySpecificPointLight(val, "Point Light", chargeMegaBlasterPointLightColor, "VoidSurvivorChargeMegaBlaster");
				((BaseUnityPlugin)this).Logger.LogInfo((object)"VoidSurvivorChargeMegaBlaster color modifications applied successfully!");
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Could not find VoidSurvivorChargeMegaBlaster prefab!");
			}
		}

		private void ModifyVoidSurvivorReadyMegaBlaster()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = FindEffectPrefab("VoidSurvivorReadyMegaBlaster");
			if ((Object)(object)val != (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Found VoidSurvivorReadyMegaBlaster prefab, applying color changes...");
				ModifySpecificPointLight(val, "Point Light", readyMegaBlasterPointLightColor, "VoidSurvivorReadyMegaBlaster");
				((BaseUnityPlugin)this).Logger.LogInfo((object)"VoidSurvivorReadyMegaBlaster color modifications applied successfully!");
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Could not find VoidSurvivorReadyMegaBlaster prefab!");
			}
		}

		private void ModifyVoidBlinkVfx()
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = FindEffectPrefab("VoidBlinkVfx");
			if ((Object)(object)val != (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Found VoidBlinkVfx prefab, applying color changes...");
				Transform val2 = val.transform.Find("Core");
				if ((Object)(object)val2 != (Object)null)
				{
					ModifySpecificPointLight(((Component)val2).gameObject, "Point Light", voidBlinkVfxPointLightColor, "VoidBlinkVfx/Core");
				}
				else
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)"Core child object not found in VoidBlinkVfx");
				}
				((BaseUnityPlugin)this).Logger.LogInfo((object)"VoidBlinkVfx color modifications applied successfully!");
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Could not find VoidBlinkVfx prefab!");
			}
		}

		private void ModifyVoidSurvivorMegaBlasterSmallGhost()
		{
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = FindEffectPrefab("VoidSurvivorMegaBlasterSmallGhost");
			if ((Object)(object)val != (Object)null)
			{
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Found VoidSurvivorMegaBlasterSmallGhost prefab, applying color changes...");
				ModifySpecificPointLight(val, "Point Light", megaBlasterSmallGhostPointLightColor, "VoidSurvivorMegaBlasterSmallGhost");
				((BaseUnityPlugin)this).Logger.LogInfo((object)"VoidSurvivorMegaBlasterSmallGhost color modifications applied successfully!");
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogError((object)"Could not find VoidSurvivorMegaBlasterSmallGhost prefab!");
			}
		}

		private GameObject FindEffectPrefab(string prefabName)
		{
			GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
			GameObject[] array2 = array;
			foreach (GameObject val in array2)
			{
				if (((Object)val).name == prefabName)
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)("Found " + prefabName + " via Resources: " + ((Object)val).name));
					return val;
				}
			}
			for (int j = 0; j < EffectCatalog.effectCount; j++)
			{
				EffectDef effectDef = EffectCatalog.GetEffectDef((EffectIndex)j);
				object obj;
				if (effectDef == null)
				{
					obj = null;
				}
				else
				{
					GameObject prefab = effectDef.prefab;
					obj = ((prefab != null) ? ((Object)prefab).name : null);
				}
				if ((string?)obj == prefabName)
				{
					((BaseUnityPlugin)this).Logger.LogInfo((object)$"Found {prefabName} in EffectCatalog at index {j}");
					return effectDef.prefab;
				}
			}
			((BaseUnityPlugin)this).Logger.LogWarning((object)(prefabName + " prefab not found in standard locations"));
			return null;
		}

		private void ModifySpecificPointLight(GameObject prefab, string pointLightChildName, Color newColor, string prefabContext)
		{
			//IL_005c: 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_0081: 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)
			Transform val = FindChildByName(prefab.transform, pointLightChildName);
			if ((Object)(object)val != (Object)null)
			{
				Light component = ((Component)val).GetComponent<Light>();
				if ((Object)(object)component != (Object)null)
				{
					if (!originalLightColors.ContainsKey(component))
					{
						originalLightColors[component] = component.color;
					}
					component.color = newColor;
					((BaseUnityPlugin)this).Logger.LogInfo((object)$"Changed {prefabContext} Point Light color from {originalLightColors[component]} to {newColor}");
				}
				else
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)("Point Light component not found on " + prefabContext + " " + pointLightChildName + " GameObject"));
				}
			}
			else
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)(pointLightChildName + " child object not found in " + prefabContext));
			}
		}

		private void OnDestroy()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0057: 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_00b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			EffectCatalog.Init -= new hook_Init(EffectCatalog_Init);
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Restoring original colors to all modified assets...");
			foreach (KeyValuePair<Light, Color> originalLightColor in originalLightColors)
			{
				if ((Object)(object)originalLightColor.Key != (Object)null)
				{
					originalLightColor.Key.color = originalLightColor.Value;
				}
			}
			foreach (KeyValuePair<ParticleSystem, Color> originalParticleStartColor in originalParticleStartColors)
			{
				if ((Object)(object)originalParticleStartColor.Key != (Object)null)
				{
					MainModule main = originalParticleStartColor.Key.main;
					((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(originalParticleStartColor.Value);
				}
			}
			foreach (KeyValuePair<ParticleSystem, MinMaxGradient> originalParticleGradient in originalParticleGradients)
			{
				if ((Object)(object)originalParticleGradient.Key != (Object)null)
				{
					ColorOverLifetimeModule colorOverLifetime = originalParticleGradient.Key.colorOverLifetime;
					((ColorOverLifetimeModule)(ref colorOverLifetime)).color = originalParticleGradient.Value;
				}
			}
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Original asset colors restored.");
		}

		private Transform FindChildByName(Transform root, string desiredName)
		{
			if ((Object)(object)root == (Object)null || string.IsNullOrEmpty(desiredName))
			{
				return null;
			}
			Transform[] componentsInChildren = ((Component)root).GetComponentsInChildren<Transform>(true);
			foreach (Transform val in componentsInChildren)
			{
				string text = ((Object)val).name;
				int num = text.IndexOf(" (");
				if (num >= 0)
				{
					text = text.Substring(0, num);
				}
				if (string.Equals(text, desiredName, StringComparison.OrdinalIgnoreCase))
				{
					return val;
				}
			}
			return null;
		}
	}
}
namespace VoidSurvivorCustomFlame
{
	[BepInPlugin("com.yourname.voidsurvivor.customflame", "VoidSurvivor Custom Flame Texture", "1.0.0")]
	public class VoidSurvivorCustomFlamePlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "com.yourname.voidsurvivor.customflame";

		public const string PluginName = "VoidSurvivor Custom Flame Texture";

		public const string PluginVersion = "1.0.0";

		private const string PrefabName = "VoidSurvivorMegaBlasterExplosionSmall";

		private const string ChildName = "BillboardFire";

		private const string OriginalRampName = "texRampVoidSurvivorCorrupted2";

		private const string ReplacementRampName = "texRampVoidSurvivorBase1";

		private static Texture2D customFlameTexture;

		private readonly List<Material> createdMaterials = new List<Material>();

		private readonly List<Texture2D> createdTextures = new List<Texture2D>();

		private readonly HashSet<int> modifiedPrefabs = new HashSet<int>();

		private readonly Dictionary<int, Material> originalSharedMaterials = new Dictionary<int, Material>();

		public void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"VoidSurvivor Custom Flame Texture v1.0.0 loaded.");
			LoadCustomTexture();
			ReplaceRampOnPrefabs();
			SceneManager.sceneLoaded += OnSceneLoaded;
		}

		private void OnDestroy()
		{
			SceneManager.sceneLoaded -= OnSceneLoaded;
			try
			{
				GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
				GameObject[] array2 = array;
				foreach (GameObject val in array2)
				{
					if ((Object)(object)val == (Object)null)
					{
						continue;
					}
					int instanceID = ((Object)val).GetInstanceID();
					if (!modifiedPrefabs.Contains(instanceID))
					{
						continue;
					}
					Transform val2 = val.transform.Find("BillboardFire");
					if (!((Object)(object)val2 == (Object)null))
					{
						ParticleSystemRenderer component = ((Component)val2).GetComponent<ParticleSystemRenderer>();
						if (!((Object)(object)component == (Object)null) && originalSharedMaterials.TryGetValue(instanceID, out Material value) && (Object)(object)value != (Object)null)
						{
							((Renderer)component).sharedMaterial = value;
						}
					}
				}
			}
			catch (Exception arg)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)$"Error while restoring original materials: {arg}");
			}
			try
			{
				foreach (Material createdMaterial in createdMaterials)
				{
					if ((Object)(object)createdMaterial != (Object)null)
					{
						Object.Destroy((Object)(object)createdMaterial);
					}
				}
				createdMaterials.Clear();
				foreach (Texture2D createdTexture in createdTextures)
				{
					if ((Object)(object)createdTexture != (Object)null)
					{
						Object.Destroy((Object)(object)createdTexture);
					}
				}
				createdTextures.Clear();
				modifiedPrefabs.Clear();
				originalSharedMaterials.Clear();
			}
			catch (Exception arg2)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)$"Error while destroying created resources: {arg2}");
			}
		}

		private void OnSceneLoaded(Scene scene, LoadSceneMode mode)
		{
			try
			{
				ReplaceRampOnPrefabs();
			}
			catch (Exception arg)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)$"Error in OnSceneLoaded: {arg}");
			}
		}

		private void LoadCustomTexture()
		{
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			try
			{
				Assembly executingAssembly = Assembly.GetExecutingAssembly();
				string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
				string text = null;
				string[] array = manifestResourceNames;
				foreach (string text2 in array)
				{
					if (text2.IndexOf("custombillboardflame", StringComparison.OrdinalIgnoreCase) >= 0 && text2.EndsWith(".png", StringComparison.OrdinalIgnoreCase))
					{
						text = text2;
						break;
					}
				}
				if (text != null)
				{
					using Stream stream = executingAssembly.GetManifestResourceStream(text);
					if (stream != null)
					{
						using MemoryStream memoryStream = new MemoryStream();
						stream.CopyTo(memoryStream);
						byte[] array2 = memoryStream.ToArray();
						Texture2D val = new Texture2D(2, 2);
						if (ImageConversion.LoadImage(val, array2))
						{
							((Object)val).name = "CustomBillboardFlame";
							customFlameTexture = val;
							((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded embedded CustomBillboardFlame texture.");
							return;
						}
					}
				}
				string path = Path.GetDirectoryName(executingAssembly.Location) ?? string.Empty;
				string text3 = Path.Combine(path, "Custombillboardflame.png");
				if (File.Exists(text3))
				{
					byte[] array3 = File.ReadAllBytes(text3);
					Texture2D val2 = new Texture2D(2, 2);
					if (ImageConversion.LoadImage(val2, array3))
					{
						((Object)val2).name = "CustomBillboardFlame";
						customFlameTexture = val2;
						((BaseUnityPlugin)this).Logger.LogInfo((object)("Loaded CustomBillboardFlame from file: " + text3));
						return;
					}
				}
				((BaseUnityPlugin)this).Logger.LogInfo((object)"No custom billboard flame texture found (embedded or file). Will fallback to in-game texture if available.");
			}
			catch (Exception arg)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)$"Failed to load custom texture: {arg}");
			}
		}

		private void ReplaceRampOnPrefabs()
		{
			//IL_03ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_03f1: Expected O, but got Unknown
			//IL_042c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0431: Unknown result type (might be due to invalid IL or missing references)
			//IL_0437: Unknown result type (might be due to invalid IL or missing references)
			//IL_043c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0442: Unknown result type (might be due to invalid IL or missing references)
			//IL_044e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d1: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Texture2D val = FindTextureByName("texRampVoidSurvivorBase1");
				Texture2D val2 = customFlameTexture ?? val;
				if ((Object)(object)val2 == (Object)null)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)"Replacement ramp texture not found (custom or 'texRampVoidSurvivorBase1').");
					return;
				}
				GameObject[] array = Resources.FindObjectsOfTypeAll<GameObject>();
				int num = 0;
				GameObject[] array2 = array;
				foreach (GameObject val3 in array2)
				{
					if ((Object)(object)val3 == (Object)null || !((Object)val3).name.Contains("VoidSurvivorMegaBlasterExplosionSmall"))
					{
						continue;
					}
					int instanceID = ((Object)val3).GetInstanceID();
					if (modifiedPrefabs.Contains(instanceID))
					{
						continue;
					}
					Transform val4 = val3.transform.Find("BillboardFire");
					if ((Object)(object)val4 == (Object)null)
					{
						continue;
					}
					ParticleSystemRenderer component = ((Component)val4).GetComponent<ParticleSystemRenderer>();
					if ((Object)(object)component == (Object)null)
					{
						continue;
					}
					Material sharedMaterial = ((Renderer)component).sharedMaterial;
					if ((Object)(object)sharedMaterial == (Object)null)
					{
						continue;
					}
					string[] texturePropertyNames = sharedMaterial.GetTexturePropertyNames();
					bool flag = false;
					string[] array3 = texturePropertyNames;
					foreach (string text in array3)
					{
						Texture texture = sharedMaterial.GetTexture(text);
						if ((Object)(object)texture != (Object)null && ((Object)(object)texture == (Object)(object)val2 || ((Object)(object)customFlameTexture != (Object)null && ((Object)texture).name == "CustomBillboardFlame")))
						{
							flag = true;
							break;
						}
					}
					if (flag)
					{
						continue;
					}
					((BaseUnityPlugin)this).Logger.LogInfo((object)("Applying replacement ramp to prefab asset '" + ((Object)val3).name + "' (material '" + ((Object)sharedMaterial).name + "')."));
					string[] texturePropertyNames2 = sharedMaterial.GetTexturePropertyNames();
					string text2 = null;
					string[] array4 = texturePropertyNames2;
					foreach (string text3 in array4)
					{
						Texture texture2 = sharedMaterial.GetTexture(text3);
						if ((Object)(object)texture2 != (Object)null && ((Object)texture2).name != null && ((Object)texture2).name.IndexOf("texRampVoidSurvivorCorrupted2", StringComparison.OrdinalIgnoreCase) >= 0)
						{
							text2 = text3;
							break;
						}
					}
					if (text2 == null)
					{
						string[] array5 = new string[6] { "remap", "palette", "ramp", "remaptex", "_Remap", "_Palette" };
						string[] array6 = texturePropertyNames2;
						foreach (string text4 in array6)
						{
							string[] array7 = array5;
							foreach (string value in array7)
							{
								if (text4.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0)
								{
									text2 = text4;
									break;
								}
							}
							if (text2 != null)
							{
								break;
							}
						}
					}
					if (text2 == null && texturePropertyNames2.Length != 0)
					{
						text2 = texturePropertyNames2[0];
					}
					if (text2 == null)
					{
						((BaseUnityPlugin)this).Logger.LogWarning((object)("Could not determine texture property to replace on material '" + ((Object)sharedMaterial).name + "'."));
						continue;
					}
					Texture2D val5 = val2;
					Texture texture3 = sharedMaterial.GetTexture(text2);
					Texture2D val6 = (Texture2D)(object)((texture3 is Texture2D) ? texture3 : null);
					if ((Object)(object)val6 != (Object)null && (Object)(object)val2 != (Object)null)
					{
						try
						{
							val5 = Object.Instantiate<Texture2D>(val2);
							((Object)val5).name = (((Object)(object)customFlameTexture != (Object)null) ? "CustomBillboardFlame_Clone" : (((Object)val2).name + "_Clone"));
							createdTextures.Add(val5);
							((Texture)val5).filterMode = ((Texture)val6).filterMode;
							((Texture)val5).wrapMode = ((Texture)val6).wrapMode;
						}
						catch (Exception)
						{
							val5 = val2;
						}
					}
					Material val7 = new Material(sharedMaterial);
					((Object)val7).name = ((Object)sharedMaterial).name + " (CustomRamp)";
					val7.renderQueue = sharedMaterial.renderQueue;
					val7.enableInstancing = sharedMaterial.enableInstancing;
					Vector2 textureScale = sharedMaterial.GetTextureScale(text2);
					Vector2 textureOffset = sharedMaterial.GetTextureOffset(text2);
					val7.SetTextureScale(text2, textureScale);
					val7.SetTextureOffset(text2, textureOffset);
					val7.SetTexture(text2, (Texture)(object)val5);
					((Renderer)component).sharedMaterial = val7;
					createdMaterials.Add(val7);
					originalSharedMaterials[instanceID] = sharedMaterial;
					modifiedPrefabs.Add(instanceID);
					((BaseUnityPlugin)this).Logger.LogInfo((object)("Replaced ramp on prefab '" + ((Object)val3).name + "' material '" + ((Object)sharedMaterial).name + "' property '" + text2 + "' with '" + (((Object)(object)customFlameTexture != (Object)null) ? "CustomBillboardFlame" : "texRampVoidSurvivorBase1") + "'."));
					num++;
				}
				if (num == 0)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)"No prefabs named 'VoidSurvivorMegaBlasterExplosionSmall' were found to apply the ramp replacement.");
				}
			}
			catch (Exception arg)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)$"Error while replacing ramps on prefabs: {arg}");
			}
		}

		private Texture2D FindTextureByName(string name)
		{
			Texture2D[] array = Resources.FindObjectsOfTypeAll<Texture2D>();
			Texture2D[] array2 = array;
			foreach (Texture2D val in array2)
			{
				if ((Object)(object)val != (Object)null && ((Object)val).name != null && ((Object)val).name.Equals(name, StringComparison.OrdinalIgnoreCase))
				{
					return val;
				}
			}
			return null;
		}
	}
}
namespace VoidRampSwitcher
{
	[BepInPlugin("com.renovice.voidramp", "Void Ramp Switcher", "1.0.0")]
	public class VoidRampSwitcher : BaseUnityPlugin
	{
		[HarmonyPatch(typeof(CorruptMode), "OnEnter")]
		public static class CorruptMode_OnEnter_Patch
		{
			private static void Postfix()
			{
				VoidRampSwitcher voidRampSwitcher = InstanceFinder.FindInstance<VoidRampSwitcher>();
				if ((Object)(object)voidRampSwitcher != (Object)null)
				{
					voidRampSwitcher.ReplaceVoidSurvivorRamps();
					((BaseUnityPlugin)voidRampSwitcher).Logger.LogInfo((object)"VOID MODE - Applied all ramp swaps");
				}
			}
		}

		[HarmonyPatch(typeof(CorruptMode), "OnExit")]
		public static class CorruptMode_OnExit_Patch
		{
			private static void Postfix()
			{
				VoidRampSwitcher voidRampSwitcher = InstanceFinder.FindInstance<VoidRampSwitcher>();
				if ((Object)(object)voidRampSwitcher != (Object)null)
				{
					voidRampSwitcher.RestoreAllOriginalTextures();
					((BaseUnityPlugin)voidRampSwitcher).Logger.LogInfo((object)"NORMAL MODE - Restored all original ramps");
				}
			}
		}

		private Texture2D texRampVoidSurvivorBase1;

		private Texture2D texRampVoidSurvivorBase2;

		private Texture2D texRampVoidSurvivorCorrupted1;

		private Texture2D texRampVoidSurvivorCorrupted2;

		private Harmony harmony;

		private Dictionary<Material, Texture2D> originalTextures = new Dictionary<Material, Texture2D>();

		public void Awake()
		{
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Void Ramp Switcher loaded!");
			RoR2Application.onLoad = (Action)Delegate.Combine(RoR2Application.onLoad, (Action)delegate
			{
				//IL_0015: Unknown result type (might be due to invalid IL or missing references)
				//IL_001f: Expected O, but got Unknown
				LoadAllTextures();
				FindAndStoreOriginalTextures();
				harmony = new Harmony("com.renovice.voidramp");
				harmony.PatchAll();
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Ready to swap all ramps on void mode change");
			});
		}

		private void OnDestroy()
		{
			Harmony obj = harmony;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
			RestoreAllOriginalTextures();
		}

		private void LoadAllTextures()
		{
			Texture2D[] textures = Resources.FindObjectsOfTypeAll<Texture2D>();
			texRampVoidSurvivorBase1 = FindTextureByExactName(textures, "texRampVoidSurvivorBase1");
			texRampVoidSurvivorBase2 = FindTextureByExactName(textures, "texRampVoidSurvivorBase2");
			texRampVoidSurvivorCorrupted1 = FindTextureByExactName(textures, "texRampVoidSurvivorCorrupted1");
			texRampVoidSurvivorCorrupted2 = FindTextureByExactName(textures, "texRampVoidSurvivorCorrupted2");
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Loaded all textures successfully");
		}

		private Texture2D FindTextureByExactName(Texture2D[] textures, string name)
		{
			foreach (Texture2D val in textures)
			{
				if (((Object)val).name.Equals(name, StringComparison.OrdinalIgnoreCase))
				{
					return val;
				}
			}
			return null;
		}

		private void FindAndStoreOriginalTextures()
		{
			Material[] array = Resources.FindObjectsOfTypeAll<Material>();
			Material[] array2 = array;
			foreach (Material val in array2)
			{
				if (val.HasProperty("_RemapTex"))
				{
					Texture texture = val.GetTexture("_RemapTex");
					Texture2D val2 = (Texture2D)(object)((texture is Texture2D) ? texture : null);
					if ((Object)(object)val2 == (Object)(object)texRampVoidSurvivorBase1 || (Object)(object)val2 == (Object)(object)texRampVoidSurvivorBase2)
					{
						originalTextures[val] = val2;
						((BaseUnityPlugin)this).Logger.LogInfo((object)("Stored VoidSurvivor texture: " + ((Object)val).name + " -> " + ((Object)val2).name));
					}
				}
			}
		}

		private void RestoreAllOriginalTextures()
		{
			foreach (KeyValuePair<Material, Texture2D> originalTexture in originalTextures)
			{
				if (Object.op_Implicit((Object)(object)originalTexture.Key) && Object.op_Implicit((Object)(object)originalTexture.Value))
				{
					originalTexture.Key.SetTexture("_RemapTex", (Texture)(object)originalTexture.Value);
				}
			}
		}

		private void ReplaceVoidSurvivorRamps()
		{
			if ((Object)(object)texRampVoidSurvivorCorrupted1 == (Object)null || (Object)(object)texRampVoidSurvivorCorrupted2 == (Object)null)
			{
				return;
			}
			foreach (Material key in originalTextures.Keys)
			{
				if (Object.op_Implicit((Object)(object)key))
				{
					Texture2D val = originalTextures[key];
					if ((Object)(object)val == (Object)(object)texRampVoidSurvivorBase1)
					{
						key.SetTexture("_RemapTex", (Texture)(object)texRampVoidSurvivorCorrupted1);
					}
					else if ((Object)(object)val == (Object)(object)texRampVoidSurvivorBase2)
					{
						key.SetTexture("_RemapTex", (Texture)(object)texRampVoidSurvivorCorrupted2);
					}
				}
			}
		}
	}
	public static class InstanceFinder
	{
		public static T FindInstance<T>() where T : BaseUnityPlugin
		{
			foreach (PluginInfo value in Chainloader.PluginInfos.Values)
			{
				BaseUnityPlugin instance = value.Instance;
				T val = (T)(object)((instance is T) ? instance : null);
				if (val != null)
				{
					return val;
				}
			}
			return default(T);
		}
	}
}
namespace VoidFiendBeam
{
	[BepInPlugin("com.YourName.VoidFiendBeam", "Void Fiend Beam", "2.3.6")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class VoidFiendBeam : BaseUnityPlugin
	{
		public static ConfigEntry<float> BeamRange;

		public static ConfigEntry<float> BeamVfxXScale;

		public static ConfigEntry<float> BeamVfxYScale;

		public static ConfigEntry<float> BeamVfxZScale;

		public static ConfigEntry<bool> LazerBeamModeRegular;

		public static ConfigEntry<bool> LazerBeamModeCorrupt;

		public static ConfigEntry<bool> EnableDebugLogging;

		public static ConfigEntry<float> VfxSurfaceOffset;

		public static ManualLogSource StaticLogger;

		public static bool isCorruptHandBeamActive;

		public static bool isRegularHandBeamActive;

		private static bool LaserModeEnabledForRegular => LazerBeamModeRegular.Value;

		private static bool LaserModeEnabledForCorrupt => LazerBeamModeCorrupt.Value;

		public void Awake()
		{
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0135: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Expected O, but got Unknown
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0156: Expected O, but got Unknown
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0161: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Expected O, but got Unknown
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Expected O, but got Unknown
			//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_01a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bf: Expected O, but got Unknown
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: Expected O, but got Unknown
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Expected O, but got Unknown
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Expected O, but got Unknown
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_020b: Expected O, but got Unknown
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_021b: Expected O, but got Unknown
			//IL_0221: Unknown result type (might be due to invalid IL or missing references)
			//IL_022b: Expected O, but got Unknown
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			//IL_024c: Unknown result type (might be due to invalid IL or missing references)
			//IL_025d: Expected O, but got Unknown
			//IL_0258: Unknown result type (might be due to invalid IL or missing references)
			//IL_0262: Expected O, but got Unknown
			StaticLogger = ((BaseUnityPlugin)this).Logger;
			BeamRange = ((BaseUnityPlugin)this).Config.Bind<float>("Beam Settings", "Beam Range", 75f, "The effective range of the Corrupt Hand Beam. Base game default is 40.");
			BeamVfxXScale = ((BaseUnityPlugin)this).Config.Bind<float>("Beam Settings", "Beam VFX Width Scale", 1f, "The scale of the beam's visual effects (VFX) on the X-axis. Base game default is 1.");
			BeamVfxYScale = ((BaseUnityPlugin)this).Config.Bind<float>("Beam Settings", "Beam VFX Height Scale", 1f, "The scale of the beam's visual effects (VFX) on the Y-axis. Base game default is 1.");
			BeamVfxZScale = ((BaseUnityPlugin)this).Config.Bind<float>("Beam Settings", "Beam VFX Length Scale", 3.25f, "The scale of the beam's visual effects (VFX) on the Z-axis. Base game default is 1.");
			LazerBeamModeRegular = ((BaseUnityPlugin)this).Config.Bind<bool>("Beam Settings", "Enable Laser Mode (Regular Beam)", false, "Eliminates randomization for the regular hand beam, making it behave like a precise laser.");
			LazerBeamModeCorrupt = ((BaseUnityPlugin)this).Config.Bind<bool>("Beam Settings", "Enable Laser Mode (Corrupt Beam)", false, "Eliminates randomization for the corrupt hand beam, making it behave like a precise laser.");
			EnableDebugLogging = ((BaseUnityPlugin)this).Config.Bind<bool>("Beam Settings", "Enable Debug Logging", false, "Enable detailed logging for troubleshooting.");
			VfxSurfaceOffset = ((BaseUnityPlugin)this).Config.Bind<float>("Beam Settings", "Surface Offset", 0.2f, "How far to push VFX out from terrain surfaces to prevent clipping. Base: 0.2");
			ModSettingsManager.AddOption((BaseOption)new SliderOption(BeamVfxXScale, new SliderConfig
			{
				min = 0.1f,
				max = 20f,
				FormatString = "{0:0.0}"
			}));
			ModSettingsManager.AddOption((BaseOption)new SliderOption(BeamVfxYScale, new SliderConfig
			{
				min = 0.1f,
				max = 20f,
				FormatString = "{0:0.0}"
			}));
			ModSettingsManager.AddOption((BaseOption)new SliderOption(BeamVfxZScale, new SliderConfig
			{
				min = 0.1f,
				max = 20f,
				FormatString = "{0:0.0}"
			}));
			ModSettingsManager.AddOption((BaseOption)new SliderOption(BeamRange, new SliderConfig
			{
				min = 10f,
				max = 300f,
				FormatString = "{0:0}"
			}));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(LazerBeamModeRegular));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(LazerBeamModeCorrupt));
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(EnableDebugLogging));
			ModSettingsManager.AddOption((BaseOption)new SliderOption(VfxSurfaceOffset, new SliderConfig
			{
				min = 0f,
				max = 1f,
				FormatString = "{0:0.00}"
			}));
			SetModIcon();
			ApplyMMHookPatches();
			((BaseUnityPlugin)this).Logger.LogInfo((object)"Void Fiend Beam has awakened with Enhanced Laser Mode (MMHook version)!");
		}

		private void SetModIcon()
		{
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			//IL_00c5: 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)
			try
			{
				Assembly executingAssembly = Assembly.GetExecutingAssembly();
				string text = null;
				string[] manifestResourceNames = executingAssembly.GetManifestResourceNames();
				foreach (string text2 in manifestResourceNames)
				{
					if (text2.EndsWith("icon.png", StringComparison.OrdinalIgnoreCase))
					{
						text = text2;
						break;
					}
				}
				if (text == null)
				{
					return;
				}
				using Stream stream = executingAssembly.GetManifestResourceStream(text);
				if (stream == null)
				{
					return;
				}
				byte[] array = new byte[stream.Length];
				stream.Read(array, 0, array.Length);
				Texture2D val = new Texture2D(2, 2, (TextureFormat)4, false);
				if (!ImageConversion.LoadImage(val, array))
				{
					return;
				}
				Sprite modIcon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
				try
				{
					ModSettingsManager.SetModIcon(modIcon);
					((BaseUnityPlugin)this).Logger.LogInfo((object)"VoidFiendBeam: Mod icon set successfully via SetModIcon().");
				}
				catch (Exception ex)
				{
					((BaseUnityPlugin)this).Logger.LogWarning((object)("VoidFiendBeam: ModSettingsManager.SetModIcon failed: " + ex.Message));
				}
			}
			catch (Exception ex2)
			{
				((BaseUnityPlugin)this).Logger.LogWarning((object)("VoidFiendBeam: failed to load mod icon: " + ex2.Message));
			}
		}

		private void ApplyMMHookPatches()
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Expected O, but got Unknown
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Expected O, but got Unknown
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			try
			{
				CharacterBody.AddSpreadBloom += new hook_AddSpreadBloom(DisableBloomAccumulation_Hook);
				((BaseUnityPlugin)this).Logger.LogInfo((object)"✅ Bloom elimination hook applied");
				BulletAttack.Fire += new hook_Fire(BulletAttack_Fire_Hook);
				((BaseUnityPlugin)this).Logger.LogInfo((object)"✅ BulletAttack Fire hook applied");
				FireCorruptHandBeam.OnEnter += new hook_OnEnter(FireCorruptHandBeam_OnEnter_Tracking);
				FireCorruptHandBeam.OnExit += new hook_OnExit(FireCorruptHandBeam_OnExit_Tracking);
				((BaseUnityPlugin)this).Logger.LogInfo((object)"✅ Corrupt hand beam tracking hooks applied");
				FireHandBeam.OnEnter += new hook_OnEnter(FireHandBeam_OnEnter_Tracking);
				FireHandBeam.OnExit += new hook_OnExit(FireHandBeam_OnExit_Tracking);
				((BaseUnityPlugin)this).Logger.LogInfo((object)"✅ Regular hand beam tracking hooks applied");
				FireCorruptHandBeam.OnEnter += new hook_OnEnter(FireCorruptHandBeam_OnEnter_Modifications);
				FireCorruptHandBeam.FireBullet += new hook_FireBullet(FireCorruptHandBeam_FireBullet_Hook);
				((BaseUnityPlugin)this).Logger.LogInfo((object)"✅ Corrupt hand beam modification hooks applied");
				((BaseUnityPlugin)this).Logger.LogInfo((object)"\ud83c\udfaf All MMHook patches applied successfully!");
			}
			catch (Exception arg)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)$"❌ Failed to apply MMHook patches: {arg}");
			}
		}

		private void DisableBloomAccumulation_Hook(orig_AddSpreadBloom orig, CharacterBody self, float bloom)
		{
			//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)
			if (((LaserModeEnabledForCorrupt && isCorruptHandBeamActive) || (LaserModeEnabledForRegular && isRegularHandBeamActive)) && self.bodyIndex == BodyCatalog.FindBodyIndex("VoidSurvivorBody"))
			{
				if (EnableDebugLogging.Value)
				{
					StaticLogger.LogInfo((object)$"\ud83c\udfaf BLOCKING bloom during active HandBeam ({bloom})");
				}
			}
			else
			{
				orig.Invoke(self, bloom);
			}
		}

		private void BulletAttack_Fire_Hook(orig_Fire orig, BulletAttack self)
		{
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Expected O, but got Unknown
			//IL_006d: 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)
			if ((Object)(object)self.owner != (Object)null)
			{
				CharacterBody component = self.owner.GetComponent<CharacterBody>();
				if ((Object)(object)component != (Object)null && component.bodyIndex == BodyCatalog.FindBodyIndex("VoidSurvivorBody"))
				{
					HitCallback originalCallback = self.hitCallback;
					self.hitCallback = (HitCallback)delegate(BulletAttack attack, ref BulletHit hitInfo)
					{
						//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_0060: 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_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_009b: Unknown result type (might be due to invalid IL or missing references)
						//IL_009e: Unknown result type (might be due to invalid IL or missing references)
						//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
						if ((Object)(object)hitInfo.collider == (Object)null)
						{
							HitCallback obj = originalCallback;
							return obj == null || obj.Invoke(attack, ref hitInfo);
						}
						bool flag = (LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask) & (1 << ((Component)hitInfo.collider).gameObject.layer)) != 0;
						Vector3 val = hitInfo.point + hitInfo.surfaceNormal * VfxSurfaceOffset.Value;
						if (flag)
						{
							if ((Object)(object)attack.hitEffectPrefab != (Object)null)
							{
								EffectManager.SimpleEffect(attack.hitEffectPrefab, val, Quaternion.LookRotation(hitInfo.surfaceNormal), true);
							}
							return false;
						}
						HitCallback obj2 = originalCallback;
						return obj2 == null || obj2.Invoke(attack, ref hitInfo);
					};
					self.hitMask = LayerMask.op_Implicit(LayerMask.op_Implicit(self.hitMask) | LayerMask.op_Implicit(((LayerIndex)(ref LayerIndex.world)).mask));
					if ((LaserModeEnabledForCorrupt && isCorruptHandBeamActive) || (LaserModeEnabledForRegular && isRegularHandBeamActive))
					{
						self.minSpread = 0f;
						self.maxSpread = 0f;
					}
				}
			}
			orig.Invoke(self);
		}

		private void FireCorruptHandBeam_OnEnter_Tracking(orig_OnEnter orig, FireCorruptHandBeam self)
		{
			//IL_0028: 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)
			orig.Invoke(self);
			if (!LaserModeEnabledForCorrupt)
			{
				return;
			}
			CharacterBody characterBody = ((EntityState)self).characterBody;
			if (!((Object)(object)characterBody != (Object)null) || characterBody.bodyIndex != BodyCatalog.FindBodyIndex("VoidSurvivorBody"))
			{
				return;
			}
			VoidSurvivorController component = ((Component)characterBody).GetComponent<VoidSurvivorController>();
			if ((Object)(object)component != (Object)null && component.isCorrupted)
			{
				isCorruptHandBeamActive = true;
				if (EnableDebugLogging.Value)
				{
					StaticLogger.LogInfo((object)"\ud83d\udfe2 Corrupt FireHandBeam STARTED");
				}
			}
		}

		private void FireCorruptHandBeam_OnExit_Tracking(orig_OnExit orig, FireCorruptHandBeam self)
		{
			orig.Invoke(self);
			if (isCorruptHandBeamActive)
			{
				isCorruptHandBeamActive = false;
				if (EnableDebugLogging.Value)
				{
					StaticLogger.LogInfo((object)"\ud83d\udd34 Corrupt FireHandBeam ENDED");
				}
			}
		}

		private void FireHandBeam_OnEnter_Tracking(orig_OnEnter orig, FireHandBeam self)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (LaserModeEnabledForRegular)
			{
				CharacterBody characterBody = ((EntityState)self).characterBody;
				if ((Object)(object)characterBody != (Object)null && characterBody.bodyIndex == BodyCatalog.FindBodyIndex("VoidSurvivorBody"))
				{
					VoidSurvivorController component = ((Component)characterBody).GetComponent<VoidSurvivorController>();
					if ((Object)(object)component != (Object)null && !component.isCorrupted && !isRegularHandBeamActive)
					{
						isRegularHandBeamActive = true;
						if (EnableDebugLogging.Value)
						{
							StaticLogger.LogInfo((object)"\ud83d\udfe2 Regular FireHandBeam STARTED (Pre-Bloom)");
						}
					}
				}
			}
			orig.Invoke(self);
		}

		private void FireHandBeam_OnExit_Tracking(orig_OnExit orig, FireHandBeam self)
		{
			orig.Invoke(self);
			if (LaserModeEnabledForRegular && isRegularHandBeamActive)
			{
				isRegularHandBeamActive = false;
				if (EnableDebugLogging.Value)
				{
					StaticLogger.LogInfo((object)"\ud83d\udd34 Regular FireHandBeam ENDED");
				}
			}
		}

		private void FireCorruptHandBeam_OnEnter_Modifications(orig_OnEnter orig, FireCorruptHandBeam self)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody characterBody = ((EntityState)self).characterBody;
			if ((Object)(object)characterBody != (Object)null && characterBody.bodyIndex == BodyCatalog.FindBodyIndex("VoidSurvivorBody"))
			{
				VoidSurvivorController component = ((Component)characterBody).GetComponent<VoidSurvivorController>();
				if ((Object)(object)component != (Object)null && component.isCorrupted)
				{
					self.maxDistance = BeamRange.Value;
					if ((Object)(object)self.beamVfxPrefab != (Object)null)
					{
						VoidFiendVFXBeam.ScaleBeamVFX(self.beamVfxPrefab, BeamVfxXScale.Value, BeamVfxYScale.Value, BeamVfxZScale.Value);
					}
				}
			}
			orig.Invoke(self);
		}

		private void FireCorruptHandBeam_FireBullet_Hook(orig_FireBullet orig, FireCorruptHandBeam self)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody characterBody = ((EntityState)self).characterBody;
			if ((Object)(object)characterBody != (Object)null && characterBody.bodyIndex == BodyCatalog.FindBodyIndex("VoidSurvivorBody"))
			{
				VoidSurvivorController component = ((Component)characterBody).GetComponent<VoidSurvivorController>();
				if ((Object)(object)component != (Object)null && component.isCorrupted)
				{
					self.minDistance = self.maxDistance;
				}
			}
			orig.Invoke(self);
		}
	}
	public static class VoidFiendVFXBeam
	{
		public static void ScaleBeamVFX(GameObject beamVfxPrefab, float newVfxXScale, float newVfxYScale, float newVfxZScale)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)beamVfxPrefab == (Object)null))
			{
				beamVfxPrefab.transform.localScale = new Vector3(newVfxXScale, newVfxYScale, newVfxZScale);
			}
		}
	}
}
namespace SuppressRework
{
	[BepInPlugin("com.renovice.suppressrework", "VoidFiend Nexus", "1.4.4")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class SuppressRework : BaseUnityPlugin
	{
		public static ConfigEntry<bool> EnableAllOrNothingScaling;

		public static ConfigEntry<bool> EnableEfficientTrades;

		public static ConfigEntry<float> MaxHealthSacrifice;

		public static ConfigEntry<float> FixedTradeValue;

		public static ConfigEntry<int> MaxChargesNormalMode;

		public static ConfigEntry<int> MaxChargesCorruptedMode;

		public static ConfigEntry<bool> InfiniteChargesNormalMode;

		public static ConfigEntry<bool> InfiniteChargesCorruptedMode;

		internal static SkillDef _crushHealthDef;

		internal static SkillDef _crushCorruptionDef;

		internal static ManualLogSource Log;

		public static SuppressRework Instance { get; private set; }

		public void Awake()
		{
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Expected O, but got Unknown
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0146: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			try
			{
				EnableAllOrNothingScaling = ((BaseUnityPlugin)this).Config.Bind<bool>("Supressrework", "Enable All-or-Nothing Scaling", false, "If true, the ability consumes your resource bar for a 1:1 reward. If false, it uses a fixed percentage.");
				EnableEfficientTrades = ((BaseUnityPlugin)this).Config.Bind<bool>("Supressrework", "Enable Efficient Trades", true, "If true, the ability will not spend more resources than needed to fill the target bar.");
				MaxHealthSacrifice = ((BaseUnityPlugin)this).Config.Bind<float>("Supressrework", "Max Health Sacrifice Percent", 50f, "When 'All-or-Nothing' is ON, this is the MAXIMUM percentage of your health you can sacrifice in one go.");
				FixedTradeValue = ((BaseUnityPlugin)this).Config.Bind<float>("Supressrework", "Fixed Trade Percentage", 35f, "When 'All-or-Nothing' is OFF, this is the percentage of health/corruption that will be traded.");
				MaxChargesNormalMode = ((BaseUnityPlugin)this).Config.Bind<int>("Supressrework", "Max Charges - Suppress", 1, "Maximum charges for the suppress ability (spend corruption to heal in normal mode). No cooldown - you get this many per transformation.");
				MaxChargesCorruptedMode = ((BaseUnityPlugin)this).Config.Bind<int>("Supressrework", "Max Charges - Corrupted Suppress", 2, "Maximum charges for the corrupted suppress ability (sacrifice health for corruption in void mode). No cooldown - you get this many per transformation.");
				InfiniteChargesNormalMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Supressrework", "Infinite Charges - Suppress", true, "If true, suppress ability has infinite charges in normal mode.");
				InfiniteChargesCorruptedMode = ((BaseUnityPlugin)this).Config.Bind<bool>("Supressrework", "Infinite Charges - Corrupted Suppress", false, "If true, corrupted suppress ability has infinite charges in void mode.");
				SetupRiskOfOptions();
				Harmony val = new Harmony("com.renovice.suppressrework");
				val.PatchAll();
				SurvivorCatalog.Init += (hook_Init)delegate(orig_Init orig)
				{
					orig.Invoke();
					OnGameLoaded();
				};
				((BaseUnityPlugin)this).Logger.LogInfo((object)"Suppress Rework v1.4.4 - Void Item Corruption Bug Fix loaded successfully!");
			}
			catch (Exception arg)
			{
				((BaseUnityPlugin)this).Logger.LogError((object)$"Error in Awake: {arg}");
			}
		}

		private void SetupRiskOfOptions()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//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_0049: 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_0065: Expected O, but got Unknown
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_0070: 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_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Expected O, but got Unknown
			//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_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Expected O, but got Unknown
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Expected O, but got Unknown
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Expected O, but got Unknown
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Expected O, but got Unknown
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0109: Expected O, but got Unknown
			try
			{
				ModSettingsManager.SetModDescription("A complete overhaul of Voidfiend's Suppress ability with customizable trading mechanics, charge systems, Aegis support, and dynamic tooltips. Now with void item corruption bug fixes!");
				SetModIcon();
				ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(EnableAllOrNothingScaling));
				ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(EnableEfficientTrades));
				ModSettingsManager.AddOption((BaseOption)new SliderOption(MaxHealthSacrifice, new SliderConfig
				{
					min = 1f,
					max = 100f,
					FormatString = "{0:0}%"
				}));
				ModSettingsManager.AddOption((BaseOption)new SliderOption(FixedTradeValue, new SliderConfig
				{
					min = 1f,
					max = 100f,
					FormatString = "{0:0}%"
				}));
				ModSettingsManager.AddOption((BaseOption)new IntSliderOption(MaxChargesNormalMode, new IntSliderConfig
				{
					min = 0,
					max = 20
				}));
				ModSettingsManager.AddOption((BaseOption)new IntSliderOption(MaxChargesCorruptedMode, new IntSliderConfig
				{
					min = 0,
					max = 20
				}));
				ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(InfiniteChargesNormalMode));
				ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(InfiniteChargesCorruptedMode));
				EnableAllOrNothingScaling.SettingChanged += delegate
				{
					OnSettingChanged();
				};
				EnableEfficientTrades.SettingChanged += delegate
				{
					OnSettingChanged();
				};
				MaxHealthSacrifice.SettingChanged += delegate
				{
					OnSettingChanged();
				};
				FixedTradeValue.SettingChanged += delegate
				{
					OnSettingChanged();
				};
				MaxChargesNormalMode.SettingChanged += delegate
				{
					OnSettingChanged();
				};
				MaxChargesCorruptedMode.SettingChanged += delegate
				{
					OnSettingChanged();
				};
				InfiniteChargesNormalMode.SettingChanged += delegate
				{
					OnSettingChanged();
				};
				InfiniteChargesCorruptedMode.SettingChanged += delegate
				{
					OnSettingChanged();
				};
			}
			catch (Exception arg)
			{
				Log.LogError((object)$"Error setting up Risk of Options: {arg}");
			}
		}

		private void SetModIcon()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Expected O, but got Unknown
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				Assembly executingAssembly = Assembly.GetExecutingAssembly();
				using Stream stream = executingAssembly.GetManifestResourceStream("V8_supressrework.icon.png");
				if (stream != null)
				{
					byte[] array = new byte[stream.Length];
					stream.Read(array, 0, array.Length);
					Texture2D val = new Texture2D(2, 2);
					ImageConversion.LoadImage(val, array);
					Sprite modIcon = Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f));
					ModSettingsManager.SetModIcon(modIcon);
					Log.LogInfo((object)"Mod icon set successfully");
				}
			}
			catch (Exception arg)
			{
				Log.LogError((object)$"Failed to set mod icon: {arg}");
			}
		}

		private void OnSettingChanged()
		{
			try
			{
				ModifySkillDefs();
				TooltipRefresher.RefreshTooltipsAfterSettingsChange();
				Log.LogInfo((object)"Settings changed - skill descriptions should update dynamically");
			}
			catch (Exception arg)
			{
				Log.LogError((object)$"Error in OnSettingChanged: {arg}");
			}
		}

		private void OnGameLoaded()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				_crushHealthDef = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/DLC1/VoidSurvivor/CrushHealth.asset").WaitForCompletion();
				_crushCorruptionDef = Addressables.LoadAssetAsync<SkillDef>((object)"RoR2/DLC1/VoidSurvivor/CrushCorruption.asset").WaitForCompletion();
				if ((Object)(object)_crushHealthDef != (Object)null)
				{
					Log.LogInfo((object)("CrushHealth loaded successfully. Token: " + _crushHealthDef.skillDescriptionToken));
				}
				else
				{
					Log.LogError((object)"Failed to load CrushHealth skill definition");
				}
				if ((Object)(object)_crushCorruptionDef != (Object)null)
				{
					Log.LogInfo((object)("CrushCorruption loaded successfully. Token: " + _crushCorruptionDef.skillDescriptionToken));
				}
				else
				{
					Log.LogError((object)"Failed to load CrushCorruption skill definition");
				}
				ModifySkillDefs();
			}
			catch (Exception arg)
			{
				Log.LogError((object)$"Error in OnGameLoaded: {arg}");
			}
		}

		public void ModifySkillDefs()
		{
			try
			{
				if ((Object)(object)_crushHealthDef != (Object)null)
				{
					if (InfiniteChargesCorruptedMode.Value)
					{
						_crushHealthDef.baseMaxStock = 1;
						_crushHealthDef.rechargeStock = 1;
						_crushHealthDef.baseRechargeInterval = 0f;
						Log.LogInfo((object)"Corrupted Suppress: Infinite charges enabled (instant recharge)");
					}
					else
					{
						_crushHealthDef.baseMaxStock = MaxChargesCorruptedMode.Value;
						_crushHealthDef.rechargeStock = 0;
						_crushHealthDef.baseRechargeInterval = 0f;
						Log.LogInfo((object)$"Corrupted Suppress: {MaxChargesCorruptedMode.Value} charges, no recharge");
					}
				}
				if (!((Object)(object)_crushCorruptionDef != (Object)null))
				{
					return;
				}
				if (InfiniteChargesNormalMode.Value)
				{
					_crushCorruptionDef.baseMaxStock = 1;
					_crushCorruptionDef.rechargeStock = 1;
					_crushCorruptionDef.baseRechargeInterval = 0f;
					Log.LogInfo((object)"Suppress: Infinite charges enabled (instant recharge)");
				}
				else
				{
					_crushCorruptionDef.baseMaxStock = MaxChargesNormalMode.Value;
					_crushCorruptionDef.rechargeStock = 0;
					_crushCorruptionDef.baseRechargeInterval = 0f;
					Log.LogInfo((object)$"Suppress: {MaxChargesNormalMode.Value} charges, no recharge");
				}
				if (((object)_crushCorruptionDef).GetType().Name == "VoidSurvivorSkillDef")
				{
					FieldInfo field = ((object)_crushCorruptionDef).GetType().GetField("minimumCorruption");
					FieldInfo field2 = ((object)_crushCorruptionDef).GetType().GetField("maximumCorruption");
					if (field != null)
					{
						field.SetValue(_crushCorruptionDef, 0.1f);
						Log.LogInfo((object)"Set CrushCorruption minimumCorruption to: 0.1");
					}
					if (field2 != null)
					{
						field2.SetValue(_crushCorruptionDef, 100f);
						Log.LogInfo((object)"Set CrushCorruption maximumCorruption to: 100");
					}
				}
			}
			catch (Exception arg)
			{
				Log.LogError((object)$"Error in ModifySkillDefs: {arg}");
			}
		}
	}
	public static class CorruptionHelper
	{
		public static (float current, float minimum, float maximum, float spendable) GetSafeCorruptionValues(VoidSurvivorController voidController)
		{
			if ((Object)(object)voidController == (Object)null)
			{
				return (0f, 0f, 100f, 0f);
			}
			float corruption = voidController.corruption;
			float minimumCorruption = voidController.minimumCorruption;
			float maxCorruption = voidController.maxCorruption;
			float num = 100f;
			float num2 = Mathf.Clamp(corruption, 0f, num);
			float num3 = Mathf.Clamp(minimumCorruption, 0f, num);
			float num4 = Mathf.Max(0f, num2 - num3);
			if (minimumCorruption > maxCorruption || corruption > maxCorruption || corruption < 0f)
			{
				ManualLogSource log = SuppressRework.Log;
				if (log != null)
				{
					log.LogWarning((object)$"CORRUPTION GLITCH DETECTED: Raw values - Current: {corruption:F1}%, Min: {minimumCorruption:F1}%, Max: {maxCorruption:F1}%");
				}
				ManualLogSource log2 = SuppressRework.Log;
				if (log2 != null)
				{
					log2.LogWarning((object)$"USING SAFE VALUES: Current: {num2:F1}%, Min: {num3:F1}%, Max: {num:F1}%, Spendable: {num4:F1}%");
				}
			}
			return (num2, num3, num, num4);
		}

		public static bool IsCorruptionSystemGlitched(VoidSurvivorController voidController)
		{
			if ((Object)(object)voidController == (Object)null)
			{
				return false;
			}
			return voidController.minimumCorruption > voidController.maxCorruption || voidController.corruption > voidController.maxCorruption || voidController.corruption < 0f || voidController.minimumCorruption > 100f;
		}
	}
	[HarmonyPatch(typeof(CrushBase), "OnEnter")]
	public static class CrushBase_OnEnter_Patch
	{
		private static bool Prefix(CrushBase __instance)
		{
			try
			{
				CharacterBody characterBody = ((EntityState)__instance).characterBody;
				if ((Object)(object)characterBody == (Object)null)
				{
					return true;
				}
				VoidSurvivorController component = ((Component)characterBody).GetComponent<VoidSurvivorController>();
				if (!SuppressRework.EnableAllOrNothingScaling.Value)
				{
					float value = SuppressRework.FixedTradeValue.Value;
					if (__instance is CrushHealth)
					{
						HealthComponent healthComponent = characterBody.healthComponent;
						if ((Object)(object)healthComponent != (Object)null && healthComponent.fullHealth > 0f)
						{
							float num = healthComponent.health / healthComponent.fullHealth * 100f;
							if (num < value)
							{
								ManualLogSource log = SuppressRework.Log;
								if (log != null)
								{
									log.LogWarning((object)$"BLOCKED CrushHealth execution: {num:F1}% < {value}% required");
								}
								((EntityState)__instance).outer.SetNextStateToMain();
								return false;
							}
						}
					}
					else if (__instance is CrushCorruption && (Object)(object)component != (Object)null)
					{
						var (num2, num3, num4, num5) = CorruptionHelper.GetSafeCorruptionValues(component);
						if (num5 < value)
						{
							ManualLogSource log2 = SuppressRework.Log;
							if (log2 != null)
							{
								log2.LogWarning((object)$"BLOCKED CrushCorruption execution: Only {num5:F1}% spendable corruption < {value}% required");
							}
							((EntityState)__instance).outer.SetNextStateToMain();
							return false;
						}
					}
				}
				float num6 = 0f;
				float num7 = 0f;
				if (SuppressRework.EnableAllOrNothingScaling.Value)
				{
					if (__instance is CrushHealth)
					{
						HealthComponent healthComponent2 = characterBody.healthComponent;
						if ((Object)(object)healthComponent2 == (Object)null || healthComponent2.fullHealth <= 0f)
						{
							ManualLogSource log3 = SuppressRework.Log;
							if (log3 != null)
							{
								log3.LogWarning((object)"CrushHealth: No health component, aborting");
							}
							((EntityState)__instance).outer.SetNextStateToMain();
							return false;
						}
						float num8 = healthComponent2.health - 1f;
						if (num8 <= 0f)
						{
							ManualLogSource log4 = SuppressRework.Log;
							if (log4 != null)
							{
								log4.LogWarning((object)$"CrushHealth: Insufficient health to sacrifice. Current: {healthComponent2.health:F1}, need at least 2 HP");
							}
							((EntityState)__instance).outer.SetNextStateToMain();
							return false;
						}
						float val = healthComponent2.fullHealth * (SuppressRework.MaxHealthSacrifice.Value / 100f);
						float num9 = Math.Min(num8, val);
						if (num9 <= 0.1f)
						{
							ManualLogSource log5 = SuppressRework.Log;
							if (log5 != null)
							{
								log5.LogWarning((object)$"CrushHealth: Health sacrifice too small ({num9:F2} HP), aborting");
							}
							((EntityState)__instance).outer.SetNextStateToMain();
							return false;
						}
						float num10 = num9 / healthComponent2.fullHealth;
						num6 = 0f - num10;
						num7 = num10 * 100f;
						ManualLogSource log6 = SuppressRework.Log;
						if (log6 != null)
						{
							log6.LogInfo((object)$"CrushHealth All-or-Nothing: Sacrificing {num9:F1} HP ({num10 * 100f:F1}%) for {num7:F1}% corruption");
						}
					}
					else if (__instance is CrushCorruption)
					{
						if ((Object)(object)component == (Object)null)
						{
							ManualLogSource log7 = SuppressRework.Log;
							if (log7 != null)
							{
								log7.LogWarning((object)"CrushCorruption: No void survivor controller, aborting");
							}
							((EntityState)__instance).outer.SetNextStateToMain();
							return false;
						}
						var (num11, num12, num13, num14) = CorruptionHelper.GetSafeCorruptionValues(component);
						if (num14 <= 0.1f)
						{
							ManualLogSource log8 = SuppressRework.Log;
							if (log8 != null)
							{
								log8.LogWarning((object)$"CrushCorruption: Insufficient spendable corruption ({num14:F1}%). Current: {num11:F1}%, Minimum: {num12:F1}%");
							}
							((EntityState)__instance).outer.SetNextStateToMain();
							return false;
						}
						float num15 = num14 / 100f;
						num6 = num15;
						num7 = 0f - num14;
						ManualLogSource log9 = SuppressRework.Log;
						if (log9 != null)
						{
							log9.LogInfo((object)$"CrushCorruption All-or-Nothing: Spending {num14:F1}% corruption (of {num11:F1}% total, min {num12:F1}%) for {num15 * 100f:F1}% heal");
						}
					}
				}
				else
				{
					float value2 = SuppressRework.FixedTradeValue.Value;
					if (__instance is CrushHealth)
					{
						num6 = 0f - value2 / 100f;
						num7 = value2;
						ManualLogSource log10 = SuppressRework.Log;
						if (log10 != null)
						{
							log10.LogInfo((object)$"CrushHealth Fixed: sacrificing {value2}% health for {value2}% corruption");
						}
					}
					else if (__instance is CrushCorruption)
					{
						if ((Object)(object)component != (Object)null)
						{
							(float current, float minimum, float maximum, float spendable) safeCorruptionValues = CorruptionHelper.GetSafeCorruptionValues(component);
							float item = safeCorruptionValues.current;
							float item2 = safeCorruptionValues.minimum;
							float item3 = safeCorruptionValues.maximum;
							float item4 = safeCorruptionValues.spendable;
							float num16 = Math.Min(value2, item4);
							if (num16 <= 0.1f)
							{
								ManualLogSource log11 = SuppressRework.Log;
								if (log11 != null)
								{
									log11.LogWarning((object)$"CrushCorruption Fixed: Emergency abort - trade amount too low ({num16:F1}%)");
								}
								((EntityState)__instance).outer.SetNextStateToMain();
								return false;
							}
							num6 = num16 / 100f;
							num7 = 0f - num16;
							ManualLogSource log12 = SuppressRework.Log;
							if (log12 != null)
							{
								log12.LogInfo((object)$"CrushCorruption Fixed: spending {num16:F1}% corruption (requested {value2}%, available {item4:F1}%) for {num16:F1}% heal");
							}
						}
						else
						{
							num6 = value2 / 100f;
							num7 = 0f - value2;
						}
					}
				}
				if (__instance is CrushHealth)
				{
					if (num6 > 0f || num7 < 0f)
					{
						ManualLogSource log13 = SuppressRework.Log;
						if (log13 != null)
						{
							log13.LogError((object)$"EXPLOIT PREVENTION: CrushHealth attempted invalid trade - heal: {num6:F3}, corruption: {num7:F1}");
						}
						((EntityState)__instance).outer.SetNextStateToMain();
						return false;
					}
				}
				else if (__instance is CrushCorruption && (num6 < 0f || num7 > 0f))
				{
					ManualLogSource log14 = SuppressRework.Log;
					if (log14 != null)
					{
						log14.LogError((object)$"EXPLOIT PREVENTION: CrushCorruption attempted invalid trade - heal: {num6:F3}, corruption: {num7:F1}");
					}
					((EntityState)__instance).outer.SetNextStateToMain();
					return false;
				}
				if (SuppressRework.EnableEfficientTrades.Value)
				{
					if (__instance is CrushHealth && num7 > 0f)
					{
						if ((Object)(object)component != (Object)null)
						{
							(float current, float minimum, float maximum, float spendable) safeCorruptionValues2 = CorruptionHelper.GetSafeCorruptionValues(component);
							float item5 = safeCorruptionValues2.current;
							float item6 = safeCorruptionValues2.minimum;
							float item7 = safeCorruptionValues2.maximum;
							float item8 = safeCorruptionValues2.spendable;
							float num17 = item7 - item5;
							if (num7 > num17)
							{
								float num18 = num17 / num7;
								num7 *= num18;
								num6 *= num18;
								ManualLogSource log15 = SuppressRework.Log;
								if (log15 != null)
								{
									log15.LogInfo((object)$"CrushHealth scaled down due to corruption cap: scale={num18:F2}");
								}
							}
						}
					}
					else if (__instance is CrushCorruption && num6 > 0f)
					{
						HealthComponent healthComponent3 = characterBody.healthComponent;
						if ((Object)(object)healthComponent3 == (Object)null)
						{
							return true;
						}
						if ((Object)(object)characterBody.inventory != (Object)null && characterBody.inventory.GetItemCount(Items.BarrierOnOverHeal) > 0)
						{
							float maxBarrier = characterBody.maxBarrier;
							float barrier = healthComponent3.barrier;
							float num19 = maxBarrier - barrier;
							float num20 = healthComponent3.fullHealth - healthComponent3.health;
							float num21 = num20 + num19 * 2f;
							ManualLogSource log16 = SuppressRework.Log;
							if (log16 != null)
							{
								log16.LogInfo((object)$"Aegis detected: Health room={num20:F1}, Barrier room={num19:F1}, Total room={num21:F1}");
							}
							float num22 = num6 * healthComponent3.fullHealth;
							if (num22 > num21)
							{
								float num23 = num21 / num22;
								num6 *= num23;
								num7 *= num23;
								ManualLogSource log17 = SuppressRework.Log;
								if (log17 != null)
								{
									log17.LogInfo((object)$"CrushCorruption scaled down due to Aegis-aware healing cap: scale={num23:F2}");
								}
							}
						}
						else
						{
							float num24 = healthComponent3.fullHealth - healthComponent3.health;
							float num25 = num24 / healthComponent3.fullHealth;
							if (num6 > num25)
							{
								float num26 = num25 / num6;
								num6 *= num26;
								num7 *= num26;
								ManualLogSource log18 = SuppressRework.Log;
								if (log18 != null)
								{
									log18.LogInfo((object)$"CrushCorruption scaled down due to overheal prevention: scale={num26:F2}");
								}
							}
						}
					}
				}
				__instance.selfHealFraction = num6;
				__instance.corruptionChange = num7;
				return true;
			}
			catch (Exception arg)
			{
				ManualLogSource log19 = SuppressRework.Log;
				if (log19 != null)
				{
					log19.LogError((object)$"Error in CrushBase_OnEnter_Patch: {arg}");
				}
				return true;
			}
		}
	}
	[HarmonyPatch]
	public static class VoidSurvivorSkillDef_HasRequiredCorruption_Patch
	{
		private static MethodBase TargetMethod()
		{
			Type type = AccessTools.TypeByName("RoR2.Skills.VoidSurvivorSkillDef");
			return AccessTools.Method(type, "HasRequiredCorruption", (Type[])null, (Type[])null);
		}

		private static bool Prefix(object __instance, GenericSkill skillSlot, ref bool __result)
		{
			try
			{
				if (SuppressRework.EnableAllOrNothingScaling.Value)
				{
					return true;
				}
				if (__instance == SuppressRework._crushHealthDef)
				{
					CharacterBody val = ((skillSlot != null) ? skillSlot.characterBody : null);
					if ((Object)(object)((val != null) ? val.healthComponent : null) != (Object)null)
					{
						float num = val.healthComponent.health / val.healthComponent.fullHealth * 100f;
						float value = SuppressRework.FixedTradeValue.Value;
						__result = num >= value;
						return false;
					}
				}
				else if (__instance == SuppressRework._crushCorruptionDef)
				{
					CharacterBody val2 = ((skillSlot != null) ? skillSlot.characterBody : null);
					VoidSurvivorController val3 = ((val2 != null) ? ((Component)val2).GetComponent<VoidSurvivorController>() : null);
					if ((Object)(object)val3 != (Object)null)
					{
						(float current, float minimum, float maximum, float spendable) safeCorruptionValues = CorruptionHelper.GetSafeCorruptionValues(val3);
						float item = safeCorruptionValues.current;
						float item2 = safeCorruptionValues.minimum;
						float item3 = safeCorruptionValues.maximum;
						float item4 = safeCorruptionValues.spendable;
						float value2 = SuppressRework.FixedTradeValue.Value;
						__result = item4 >= value2;
						return false;
					}
				}
			}
			catch (Exception arg)
			{
				ManualLogSource log = SuppressRework.Log;
				if (log != null)
				{
					log.LogError((object)$"Error in HasRequiredCorruption patch: {arg}");
				}
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(Language), "GetString", new Type[] { typeof(string) })]
	public static class Language_GetString_Patch
	{
		private static string? _crushHealthToken = null;

		private static string? _crushCorruptionToken = null;

		private static string? _corruptionUpgradeToken = null;

		private static readonly HashSet<string> _voidSurvivorTokens = new HashSet<string> { "VOIDSURVIVOR_PRIMARY_DESCRIPTION", "VOIDSURVIVOR_SECONDARY_DESCRIPTION", "VOIDSURVIVOR_UTILITY_DESCRIPTION", "VOIDSURVIVOR_SPECIAL_DESCRIPTION" };

		private static bool Prefix(string token, ref string __result)
		{
			try
			{
				if (string.IsNullOrEmpty(token) || token.Length < 15)
				{
					return true;
				}
				if (_crushHealthToken == null && (Object)(object)SuppressRework._crushHealthDef != (Object)null)
				{
					_crushHealthToken = SuppressRework._crushHealthDef.skillDescriptionToken;
					_crushCorruptionToken = SuppressRework._crushCorruptionDef?.skillDescriptionToken;
					if (_crushHealthToken != null)
					{
						_voidSurvivorTokens.Add(_crushHealthToken);
					}
					if (_crushCorruptionToken != null)
					{
						_voidSurvivorTokens.Add(_crushCorruptionToken);
					}
				}
				if (_corruptionUpgradeToken == null && token.Length > 25 && token.Contains("Corruption Upgrade") && token.Contains("Transform to crush"))
				{
					_corruptionUpgradeToken = token;
					_voidSurvivorTokens.Add(token);
					ManualLogSource log = SuppressRework.Log;
					if (log != null)
					{
						log.LogInfo((object)("Safely cached corruption upgrade token: " + token));
					}
				}
				if (token == _corruptionUpgradeToken)
				{
					if (SuppressRework.EnableAllOrNothingScaling.Value)
					{
						__result = "<style=cKeywordName>□Corruption Upgrade□</style><style=cSub>Transform to crush a portion of your maximum health to gain an equal percentage of Corruption instead.</style>";
					}
					else
					{
						string text = $"{SuppressRework.FixedTradeValue.Value:0}";
						__result = "<style=cKeywordName>□Corruption Upgrade□</style><style=cSub>Transform to crush " + text + "% health to gain " + text + "% Corruption instead.</style>";
					}
					return false;
				}
				if (!_voidSurvivorTokens.Contains(token))
				{
					return true;
				}
				bool flag = IsPlayerInVoidModeState();
				if (token == _crushCorruptionToken && (Object)(object)SuppressRework._crushCorruptionDef != (Object)null)
				{
					if (flag)
					{
						if (SuppressRework.EnableAllOrNothingScaling.Value)
						{
							__result = "Crush a portion of your <style=cIsHealth>maximum health</style> to gain an equal percentage of <style=cIsVoid>Corruption</style>.";
						}
						else
						{
							string text2 = $"{SuppressRework.FixedTradeValue.Value:0}";
							__result = "Crush <style=cIsHealth>" + text2 + "% maximum health</style> to gain <style=cIsVoid>" + text2 + "% Corruption</style>.";
						}
					}
					else if (SuppressRework.EnableAllOrNothingScaling.Value)
					{
						__result = "Crush your entire <style=cIsVoid>Corruption</style> bar to heal yourself for an equal percentage of <style=cIsHealing>maximum health</style>. <style=cIsUtility>Works with Aegis barrier conversion!</style>";
					}
					else
					{
						string text3 = $"{SuppressRework.FixedTradeValue.Value:0}";
						__result = "Crush <style=cIsVoid>" + text3 + "% Corruption</style> to heal yourself for <style=cIsHealing>" + text3 + "% maximum health</style>. <style=cIsUtility>Works with Aegis barrier conversion!</style>";
					}
					return false;
				}
				switch (token)
				{
				case "VOIDSURVIVOR_PRIMARY_DESCRIPTION":
					__result = (flag ? "Fire a short-range beam for <style=cIsDamage>300% damage</style>." : "Fire a slowing long-range beam for <style=cIsDamage>300% damage</style>.");
					return false;
				case "VOIDSURVIVOR_SECONDARY_DESCRIPTION":
					__result = (flag ? "Fire an arcing plasma bomb for <style=cIsDamage>1100% damage</style>." : "Fire a plasma missile for <style=cIsDamage>600% damage</style>. Fully charge it for an <style=cIsDamage>explosive plasma ball</style> instead, dealing <style=cIsDamage>1100% damage</style>.");
					return false;
				case "VOIDSURVIVOR_UTILITY_DESCRIPTION":
					__result = (flag ? "Disappear into the Void, <style=cIsUtility>cleansing all debuffs</style> while moving at a fast forward angle." : "Disappear into the Void, <style=cIsUtility>cleansing all debuffs</style> while moving in an upward arc.");
					return false;
				default:
					if (token == _crushHealthToken && (Object)(object)SuppressRework._crushHealthDef != (Object)null)
					{
						if (SuppressRework.EnableAllOrNothingScaling.Value)
						{
							__result = "Crush a portion of your <style=cIsHealth>maximum health</style> to gain an equal percentage of <style=cIsVoid>Corruption</style>.";
						}
						else
						{
							string text4 = $"{SuppressRework.FixedTradeValue.Value:0}";
							__result = "Crush <style=cIsHealth>" + text4 + "% maximum health</style> to gain <style=cIsVoid>" + text4 + "% Corruption</style>.";
						}
						return false;
					}
					break;
				}
			}
			catch (Exception arg)
			{
				ManualLogSource log2 = SuppressRework.Log;
				if (log2 != null)
				{
					log2.LogError((object)$"Error in Language_GetString_Patch: {arg}");
				}
			}
			return true;
		}

		private static bool IsPlayerInVoidModeState()
		{
			try
			{
				LocalUser firstLocalUser = LocalUserManager.GetFirstLocalUser();
				object obj;
				if (firstLocalUser == null)
				{
					obj = null;
				}
				else
				{
					PlayerCharacterMasterController cachedMasterController = firstLocalUser.cachedMasterController;
					if (cachedMasterController == null)
					{
						obj = null;
					}
					else
					{
						CharacterMaster master = cachedMasterController.master