Decompiled source of HexingChaos v1.1.3

HexingChaos.dll

Decompiled a week 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 System.Text.RegularExpressions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.Gup;
using HG;
using HG.Reflection;
using HexingChaos.Items;
using HexingChaos.Modules;
using IL.EntityStates;
using IL.RoR2;
using IL.RoR2.Projectile;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using On.EntityStates.Gup;
using On.RoR2;
using On.RoR2.Items;
using On.RoR2.Projectile;
using R2API;
using R2API.Utils;
using RainrotSharedUtils;
using RoR2;
using RoR2.CharacterAI;
using RoR2.EntitlementManagement;
using RoR2.ExpansionManagement;
using RoR2.Items;
using RoR2.Projectile;
using RoR2BepInExPack.GameAssetPaths;
using RoR2BepInExPack.GameAssetPathsBetter;
using SwanSongExtended;
using SwanSongExtended.Storms;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.Default | DebuggableAttribute.DebuggingModes.DisableOptimizations | DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints | DebuggableAttribute.DebuggingModes.EnableEditAndContinue)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = "")]
[assembly: AssemblyCompany("HexingChaos")]
[assembly: AssemblyConfiguration("Debug")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("HexingChaos")]
[assembly: AssemblyTitle("HexingChaos")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace HexingChaos
{
	public abstract class SharedBase
	{
		public virtual int loadOrder => 0;

		public virtual bool forcePrerequisites { get; } = false;

		public abstract string ConfigName { get; }

		public virtual bool isEnabled { get; } = true;

		public static ManualLogSource Logger => Log._logSource;

		public abstract AssetBundle assetBundle { get; }

		public abstract void Hooks();

		public abstract void Lang();

		public virtual bool GetPrerequisites()
		{
			return true;
		}

		public virtual void Init()
		{
			ConfigManager.HandleConfigAttributes(GetType(), ConfigName, Config.MyConfig);
			Hooks();
			Lang();
			MoreHexesPlugin.onPluginLoaded += PostInit;
		}

		public T Bind<T>(T defaultValue, string configName, string configDesc = "")
		{
			return ConfigManager.DualBindToConfig(ConfigName, Config.MyConfig, configName, defaultValue, configDesc);
		}

		public virtual void PostInit()
		{
		}

		public static float GetHyperbolic(float firstStack, float cap, float chance)
		{
			if (firstStack >= cap)
			{
				return cap * (chance / firstStack);
			}
			float num = chance / firstStack;
			float num2 = 100f * firstStack / (cap - firstStack);
			return cap * (1f - 100f / (num * num2 + 100f));
		}

		public static ExpansionDef SotvExpansionDef()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			return Addressables.LoadAssetAsync<ExpansionDef>((object)"RoR2/DLC1/Common/DLC1.asset").WaitForCompletion();
		}
	}
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[NetworkCompatibility(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("com.duckduckgreyduck.HexingChaos", "HexingChaos", "1.1.3")]
	public class MoreHexesPlugin : BaseUnityPlugin
	{
		public static PluginInfo PInfo;

		public const string guid = "com.duckduckgreyduck.HexingChaos";

		public const string teamName = "duckduckgreyduck";

		public const string modName = "HexingChaos";

		public const string version = "1.1.3";

		private static AssetBundle _mainAssetBundle;

		public static AssetBundle mainAssetBundle
		{
			get
			{
				if ((Object)(object)_mainAssetBundle == (Object)null)
				{
					_mainAssetBundle = Assets.LoadAssetBundle("hexingchaos");
				}
				return _mainAssetBundle;
			}
			set
			{
				_mainAssetBundle = value;
			}
		}

		public static bool isSwanSongLoaded => Tools.isLoaded("com.RiskOfBrainrot.SwanSongExtended");

		public static bool isDamageSourceLoaded => Tools.isLoaded("Lordryn.DamageSourceForEnemies");

		internal static event Action onPluginLoaded;

		public static ExpansionDef GetExpansionBypass(ExpansionDef ex)
		{
			if (Bindings.BypassExpansionRequirement)
			{
				return SharedUtilsPlugin.dlc4;
			}
			return ex;
		}

		private void Awake()
		{
			PInfo = ((BaseUnityPlugin)this).Info;
			Config.Init();
			CommonAssets.Init();
			Materials.SwapShadersFromMaterialsInBundle(mainAssetBundle);
			Type[] types = Assembly.GetExecutingAssembly().GetTypes();
			BeginInitializing<ItemBase>(types, "HexingChaos.txt");
			Config.Save();
		}

		private void BeginInitializing<T>(Type[] allTypes, string fileName = "") where T : SharedBase
		{
			Type baseType = typeof(T);
			if (!baseType.IsAbstract)
			{
				Log.Error(Log.Combine() + "Incorrect BaseType: " + baseType.Name);
				return;
			}
			IEnumerable<Type> source = allTypes.Where((Type type) => !type.IsAbstract && type.IsSubclassOf(baseType));
			if (source.Count() <= 0)
			{
				return;
			}
			IEnumerable<SharedBase> enumerable = from objType in source
				select (T)Activator.CreateInstance(objType) into sharedBase
				orderby sharedBase.loadOrder
				select sharedBase;
			Log.Debug(Log.Combine(baseType.Name) + "Initializing");
			foreach (SharedBase item in enumerable)
			{
				string text = Log.Combine(baseType.Name, item.ConfigName);
				if (ValidateBaseType(item))
				{
					Log.Debug(text + "Validated");
					InitializeBaseType(item);
					Log.Debug(text + "Initialized");
				}
			}
		}

		private bool ValidateBaseType(SharedBase obj)
		{
			bool isEnabled = obj.isEnabled;
			if (obj.forcePrerequisites)
			{
				return isEnabled && obj.GetPrerequisites();
			}
			return obj.Bind(isEnabled, "Should This Content Be Enabled") && obj.GetPrerequisites();
		}

		private void InitializeBaseType(SharedBase obj)
		{
			obj.Init();
		}

		public static bool GetConfigBool(bool defaultValue, string packetTitle, string desc = "")
		{
			return ConfigManager.DualBindToConfig(packetTitle, Config.MyConfig, "Should This Content Be Enabled", defaultValue, desc);
		}

		public static Sprite TryLoadSpriteFromBundle(string path, AssetBundle assetBundle = null, bool fallBackOnWrench = false)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			Sprite val = MoreHexesPlugin.TryLoadFromBundle<Sprite>(path, assetBundle);
			if (Object.op_Implicit((Object)(object)val))
			{
				return val;
			}
			return Addressables.LoadAssetAsync<Sprite>((object)(fallBackOnWrench ? RoR2_Base_Core.texNullIcon_png : RoR2_Base_Common_MiscIcons.texWIPIcon_png)).WaitForCompletion();
		}

		public static T TryLoadFromBundle<T>(string path, AssetBundle assetBundle = null) where T : Object
		{
			if ((Object)(object)assetBundle == (Object)null)
			{
				assetBundle = mainAssetBundle;
			}
			if (Object.op_Implicit((Object)(object)assetBundle) && !string.IsNullOrWhiteSpace(path) && assetBundle.Contains(path))
			{
				return assetBundle.LoadAsset<T>(path);
			}
			return default(T);
		}
	}
}
namespace HexingChaos.Modules
{
	public static class CommonAssets
	{
		public static void Init()
		{
		}

		private static void CreateGloopRechargeIndication()
		{
		}

		private static void CreateAegisFortification()
		{
		}
	}
	[AttributeUsage(AttributeTargets.Field, AllowMultiple = false)]
	public class AutoConfigAttribute : Attribute
	{
		public string name;

		public string desc;

		public object defaultValue;

		public AutoConfigAttribute(string name, object defaultValue)
		{
			Init(name, string.Empty, defaultValue);
		}

		public AutoConfigAttribute(string name, string desc, object defaultValue)
		{
			Init(name, desc, defaultValue);
		}

		public void Init(string name, string desc, object defaultValue)
		{
			this.name = name;
			this.desc = desc;
			this.defaultValue = defaultValue;
		}
	}
	public static class Config
	{
		public static ConfigFile MyConfig;

		public static ConfigFile BackupConfig;

		public static void Init()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Expected O, but got Unknown
			MyConfig = new ConfigFile(Paths.ConfigPath + "\\HexingChaos.cfg", true);
			MyConfig.SaveOnConfigSet = false;
			BackupConfig = new ConfigFile(Paths.ConfigPath + "\\HexingChaos.Backup.cfg", true);
			BackupConfig.SaveOnConfigSet = false;
			BackupConfig.Bind<string>(": DO NOT MODIFY THIS FILES CONTENTS :", ": DO NOT MODIFY THIS FILES CONTENTS :", ": DO NOT MODIFY THIS FILES CONTENTS :", ": DO NOT MODIFY THIS FILES CONTENTS :");
			Bindings.Init();
		}

		public static void Save()
		{
			MyConfig.SaveOnConfigSet = true;
			MyConfig.Save();
			BackupConfig.SaveOnConfigSet = true;
			BackupConfig.Save();
		}

		public static ConfigEntry<bool> SectionEnableConfig(string sectionName, string description = "", bool enabledByDefault = true)
		{
			if (string.IsNullOrEmpty(description))
			{
				description = "Set to false to disable this type of content. Note that this will prevent the content from appearing in-game, but in some cases it will not stop the content from being generated and applying hooks - use individual configs to disable these if needed.";
			}
			return BindAndOptions(": Full Section Config", "Enable " + sectionName, enabledByDefault, description);
		}

		public static ConfigEntry<T> BindAndOptions<T>(string section, string name, T defaultValue, string description = "", bool restartRequired = true)
		{
			return BindAndOptions(section, name, defaultValue, 0f, 20f, description, restartRequired);
		}

		public static ConfigEntry<T> BindAndOptions<T>(string section, string name, T defaultValue, float min, float max, string description = "", bool restartRequired = true)
		{
			if (string.IsNullOrEmpty(description))
			{
				description = name;
			}
			if (restartRequired)
			{
				description += " (restart required)";
			}
			ConfigEntry<T> val = MyConfig.Bind<T>(section, name, defaultValue, description);
			if (Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions"))
			{
				TryRegisterOption<T>(val, min, max, restartRequired);
			}
			return val;
		}

		public static ConfigEntry<float> BindAndOptionsSlider(string section, string name, float defaultValue, string description, float min = 0f, float max = 20f, bool restartRequired = true)
		{
			return BindAndOptions(section, name, defaultValue, min, max, description, restartRequired);
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private static void TryRegisterOption<T>(ConfigEntry<T> entry, float min, float max, bool restartRequired)
		{
		}

		public static bool GetKeyPressed(KeyboardShortcut entry)
		{
			//IL_0012: 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_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			foreach (KeyCode modifier in ((KeyboardShortcut)(ref entry)).Modifiers)
			{
				if (!Input.GetKey(modifier))
				{
					return false;
				}
			}
			return Input.GetKeyDown(((KeyboardShortcut)(ref entry)).MainKey);
		}
	}
	public class ConfigManager
	{
		internal static bool ConfigChanged;

		internal static bool VersionChanged;

		public static void HandleConfigAttributes(Type type, string section, ConfigFile config)
		{
			TypeInfo typeInfo = type.GetTypeInfo();
			FieldInfo[] fields = typeInfo.GetFields();
			foreach (FieldInfo fieldInfo in fields)
			{
				if (fieldInfo.IsStatic)
				{
					Type fieldType = fieldInfo.FieldType;
					AutoConfigAttribute customAttribute = fieldInfo.GetCustomAttribute<AutoConfigAttribute>();
					if (customAttribute != null)
					{
						string name = customAttribute.name;
						object defaultValue = customAttribute.defaultValue;
						string desc = customAttribute.desc;
						fieldInfo.SetValue(null, DualBindToConfig(fieldType, section, config, name, defaultValue, desc));
					}
				}
			}
		}

		private static object DualBindToConfig(Type t, string section, ConfigFile config, string configName, object defaultValue, string configDesc)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Expected O, but got Unknown
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Expected O, but got Unknown
			if (string.IsNullOrWhiteSpace(section) || string.IsNullOrWhiteSpace(configName))
			{
				return defaultValue;
			}
			ConfigDescription val = new ConfigDescription(configDesc, (AcceptableValueBase)null, Array.Empty<object>());
			MethodInfo methodInfo = (from x in typeof(ConfigFile).GetMethods()
				where x.Name == "Bind"
				select x).First();
			methodInfo = methodInfo.MakeGenericMethod(t);
			ConfigEntryBase val2 = (ConfigEntryBase)methodInfo.Invoke(config, new object[3]
			{
				(object)new ConfigDefinition(section, configName),
				defaultValue,
				val
			});
			ConfigEntryBase val3 = (ConfigEntryBase)methodInfo.Invoke(Config.BackupConfig, new object[3]
			{
				(object)new ConfigDefinition(Regex.Replace(config.ConfigFilePath, "\\W", "") + " : " + section, configName),
				defaultValue,
				val
			});
			if (!ConfigEqual(val3.DefaultValue, val3.BoxedValue))
			{
				bool flag = true;
				Log.Warning("Syncing config to new version");
				val2.BoxedValue = val2.DefaultValue;
				val3.BoxedValue = val3.DefaultValue;
			}
			if (!ConfigEqual(val2.DefaultValue, val2.BoxedValue))
			{
				ConfigChanged = true;
			}
			return val2.BoxedValue;
		}

		public static T DualBindToConfig<T>(string section, ConfigFile config, string configName, T defaultValue, string configDesc)
		{
			return (T)DualBindToConfig(typeof(T), section, config, configName, defaultValue, configDesc);
		}

		private static bool ConfigEqual(object a, object b)
		{
			if (a.Equals(b))
			{
				return true;
			}
			if (float.TryParse(a.ToString(), out var result) && float.TryParse(b.ToString(), out var result2) && (double)Mathf.Abs(result - result2) < 0.0001)
			{
				return true;
			}
			return false;
		}
	}
	internal static class Language
	{
		public static string TokensOutput = "";

		public static bool usingLanguageFolder = false;

		public static bool printingEnabled = false;

		public static void Init()
		{
			if (usingLanguageFolder)
			{
				Language.collectLanguageRootFolders += Language_collectLanguageRootFolders;
			}
		}

		private static void Language_collectLanguageRootFolders(List<string> obj)
		{
			string text = Path.Combine(Path.GetDirectoryName(MoreHexesPlugin.PInfo.Location), "Language");
			if (Directory.Exists(text))
			{
				obj.Add(text);
			}
		}

		public static void Add(string token, string text)
		{
			if (!usingLanguageFolder)
			{
				LanguageAPI.Add(token, text);
			}
			if (printingEnabled)
			{
				TokensOutput = TokensOutput + "\n    \"" + token + "\" : \"" + text.Replace(Environment.NewLine, "\\n").Replace("\n", "\\n") + "\",";
			}
		}

		public static void TryPrintOutput(string fileName = "")
		{
			if (usingLanguageFolder && printingEnabled)
			{
				PrintOutput(fileName);
			}
		}

		public static void PrintOutput(string fileName = "")
		{
			if (printingEnabled)
			{
				string text = "{\n    strings:\n    {" + TokensOutput + "\n    }\n}";
				Log.Message(fileName + ": \n" + text);
				if (!string.IsNullOrEmpty(fileName))
				{
					string path = Path.Combine(Directory.GetParent(MoreHexesPlugin.PInfo.Location).FullName, "Language", "en", fileName);
					File.WriteAllText(path, text);
				}
				TokensOutput = "";
			}
		}
	}
	internal static class Log
	{
		public static bool enableDebugging;

		internal static ManualLogSource _logSource;

		public static void DebugBreakpoint(string methodName, int breakpointNumber = -1)
		{
			string text = "HexingChaos: " + methodName + " IL hook failed!";
			if (breakpointNumber >= 0)
			{
				text += $" (breakpoint {breakpointNumber})";
			}
			Error(text);
		}

		internal static void Init(ManualLogSource logSource)
		{
			enableDebugging = ConfigManager.DualBindToConfig("Swan Song", Config.MyConfig, "Enable Debugging", defaultValue: false, "Enable debug outputs to the log for troubleshooting purposes. Enabling this will slow down the game.");
			_logSource = logSource;
		}

		internal static string Combine(params string[] parameters)
		{
			string text = "HexingChaos : ";
			foreach (string text2 in parameters)
			{
				text = text + text2 + " : ";
			}
			return text;
		}

		internal static void Debug(object data)
		{
			if (enableDebugging)
			{
				_logSource.LogDebug(data);
			}
		}

		internal static void Error(object data)
		{
			_logSource.LogError(data);
		}

		internal static void ErrorAssetBundle(string assetName, string bundleName)
		{
			Error("failed to load asset, " + assetName + ", because it does not exist in asset bundle, " + bundleName);
		}

		internal static void Fatal(object data)
		{
			_logSource.LogFatal(data);
		}

		internal static void Info(object data)
		{
			_logSource.LogInfo(data);
		}

		internal static void Message(object data)
		{
			_logSource.LogMessage(data);
		}

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}
	}
	internal static class Materials
	{
		private static List<Material> cachedMaterials = new List<Material>();

		internal static Shader hotpoo = LegacyResourcesAPI.Load<Shader>("Shaders/Deferred/HGStandard");

		public static List<Material> MaterialsWithSwappedShaders { get; } = new List<Material>();

		internal static void GetMaterial(GameObject model, string childObject, Color color, ref Material material, float scaleMultiplier = 1f, bool replaceAll = false)
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			Renderer[] componentsInChildren = model.GetComponentsInChildren<Renderer>();
			Renderer[] array = componentsInChildren;
			foreach (Renderer val in array)
			{
				Renderer val2 = val;
				if (string.Equals(((Object)val).name, childObject))
				{
					if (color == Color.clear)
					{
						Object.Destroy((Object)(object)val);
						break;
					}
					if ((Object)(object)material == (Object)null)
					{
						material = new Material(val.material);
						material.mainTexture = val.material.mainTexture;
						material.shader = val.material.shader;
						material.color = color;
					}
					val.material = material;
					Transform transform = ((Component)val).transform;
					transform.localScale *= scaleMultiplier;
					if (!replaceAll)
					{
						break;
					}
				}
			}
		}

		internal static void DebugMaterial(GameObject model)
		{
			Renderer[] componentsInChildren = model.GetComponentsInChildren<Renderer>();
			Renderer[] array = componentsInChildren;
			foreach (Renderer val in array)
			{
				Renderer val2 = val;
				Debug.Log((object)("Material: " + ((Object)val2).name.ToString()));
			}
		}

		public static void SwapShadersFromMaterialsInBundle(AssetBundle bundle)
		{
			SwapAllShaders(bundle);
		}

		internal static void SwapAllShaders(AssetBundle assetBundle)
		{
			Material[] array = assetBundle.LoadAllAssets<Material>();
			foreach (Material val in array)
			{
				Log.Debug("Trying to swap shader for " + ((Object)val).name);
				TrySwapShader(val);
			}
		}

		internal static void TrySwapShader(Material material)
		{
			//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_0105: Unknown result type (might be due to invalid IL or missing references)
			string name = ((Object)material.shader).name;
			if (name.Contains("Stubbed"))
			{
				name = name.Replace("Stubbed", string.Empty) + ".shader";
				Shader val = Addressables.LoadAssetAsync<Shader>((object)name).WaitForCompletion();
				if ((Object)(object)val != (Object)null)
				{
					material.shader = val;
				}
				else
				{
					Log.Error("Failed to load shader " + name);
				}
			}
			else if (name == "Standard")
			{
				Texture texture = material.GetTexture("_BumpMap");
				float num = material.GetFloat("_BumpScale");
				Texture texture2 = material.GetTexture("_EmissionMap");
				material.shader = Resources.Load<Shader>("Shaders/Deferred/HGStandard");
				material.SetTexture("_NormalMap", texture);
				material.SetFloat("_NormalStrength", num);
				material.SetTexture("_EmTex", texture2);
				material.SetColor("_EmColor", new Color(0.2f, 0.2f, 0.2f));
				material.SetFloat("_EmPower", 0.15f);
			}
		}

		private static void SwapShader(Material material)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			string text = ((Object)material.shader).name.Substring("Stubbed".Length);
			string text2 = text + ".shader";
			Shader shader = Addressables.LoadAssetAsync<Shader>((object)text2).WaitForCompletion();
			material.shader = shader;
			MaterialsWithSwappedShaders.Add(material);
		}

		public static Material LoadMaterial(this AssetBundle assetBundle, string materialName)
		{
			return assetBundle.CreateHopooMaterialFromBundle(materialName);
		}

		public static Material CreateHopooMaterialFromBundle(this AssetBundle assetBundle, string materialName)
		{
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			Material val = cachedMaterials.Find(delegate(Material mat)
			{
				materialName.Replace(" (Instance)", "");
				return ((Object)mat).name.Contains(materialName);
			});
			if (Object.op_Implicit((Object)(object)val))
			{
				Log.Debug(((Object)val).name + " has already been loaded. returning cached");
				return val;
			}
			val = assetBundle.LoadAsset<Material>(materialName);
			if (!Object.op_Implicit((Object)(object)val))
			{
				Log.ErrorAssetBundle(materialName, ((Object)assetBundle).name);
				return new Material(hotpoo);
			}
			return val.ConvertDefaultShaderToHopoo();
		}

		public static Material SetHopooMaterial(this Material tempMat)
		{
			return tempMat.ConvertDefaultShaderToHopoo();
		}

		public static Material ConvertDefaultShaderToHopoo(this Material tempMat)
		{
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			if (cachedMaterials.Contains(tempMat))
			{
				Log.Debug(((Object)tempMat).name + " has already been loaded. returning cached");
				return tempMat;
			}
			float? num = null;
			Color? val = null;
			if (tempMat.IsKeywordEnabled("_NORMALMAP"))
			{
				num = tempMat.GetFloat("_BumpScale");
			}
			if (tempMat.IsKeywordEnabled("_EMISSION"))
			{
				val = tempMat.GetColor("_EmissionColor");
			}
			tempMat.shader = hotpoo;
			tempMat.SetTexture("_EmTex", tempMat.GetTexture("_EmissionMap"));
			tempMat.EnableKeyword("DITHER");
			if (num.HasValue)
			{
				tempMat.SetFloat("_NormalStrength", num.Value);
				tempMat.SetTexture("_NormalTex", tempMat.GetTexture("_BumpMap"));
			}
			if (val.HasValue)
			{
				tempMat.SetColor("_EmColor", val.Value);
				tempMat.SetFloat("_EmPower", 1f);
			}
			if (tempMat.IsKeywordEnabled("NOCULL"))
			{
				tempMat.SetInt("_Cull", 0);
			}
			if (tempMat.IsKeywordEnabled("LIMBREMOVAL"))
			{
				tempMat.SetInt("_LimbRemovalOn", 1);
			}
			cachedMaterials.Add(tempMat);
			return tempMat;
		}

		public static Material MakeUnique(this Material material)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			if (cachedMaterials.Contains(material))
			{
				return new Material(material);
			}
			return material;
		}

		public static Material SetColor(this Material material, Color color)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			material.SetColor("_Color", color);
			return material;
		}

		public static Material SetNormal(this Material material, float normalStrength = 1f)
		{
			material.SetFloat("_NormalStrength", normalStrength);
			return material;
		}

		public static Material SetEmission(this Material material)
		{
			return material.SetEmission(1f);
		}

		public static Material SetEmission(this Material material, float emission)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			return material.SetEmission(emission, Color.white);
		}

		public static Material SetEmission(this Material material, float emission, Color emissionColor)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			material.SetFloat("_EmPower", emission);
			material.SetColor("_EmColor", emissionColor);
			return material;
		}

		public static Material SetCull(this Material material, bool cull = false)
		{
			material.SetInt("_Cull", cull ? 1 : 0);
			return material;
		}

		public static Material SetSpecular(this Material material, float strength)
		{
			material.SetFloat("_SpecularStrength", strength);
			return material;
		}

		public static Material SetSpecular(this Material material, float strength, float exponent)
		{
			material.SetFloat("_SpecularStrength", strength);
			material.SetFloat("SpecularExponent", exponent);
			return material;
		}
	}
	internal static class Particles
	{
		internal static void GetParticle(GameObject model, string childObject, Color color, float sizeMultiplier = 1f, bool replaceAll = false)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			ParticleSystem[] componentsInChildren = model.GetComponentsInChildren<ParticleSystem>();
			ParticleSystem[] array = componentsInChildren;
			foreach (ParticleSystem val in array)
			{
				ParticleSystem val2 = val;
				MainModule main = val2.main;
				ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime;
				ColorBySpeedModule colorBySpeed = val2.colorBySpeed;
				if (string.Equals(((Object)val2).name, childObject))
				{
					((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(color);
					((MainModule)(ref main)).startSizeMultiplier = ((MainModule)(ref main)).startSizeMultiplier * sizeMultiplier;
					((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(color);
					((ColorBySpeedModule)(ref colorBySpeed)).color = MinMaxGradient.op_Implicit(color);
					if (!replaceAll)
					{
						break;
					}
				}
			}
		}

		internal static void DebugParticleSystem(GameObject model)
		{
			ParticleSystem[] componentsInChildren = model.GetComponentsInChildren<ParticleSystem>();
			ParticleSystem[] array = componentsInChildren;
			foreach (ParticleSystem val in array)
			{
				ParticleSystem val2 = val;
				Debug.Log((object)("Particle: " + ((Object)val2).name.ToString()));
			}
		}
	}
	public static class Extensions
	{
		public static void AddPersistentListener(this UnityEvent unityEvent, UnityAction action)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_004c: 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)
			PersistentCallGroup persistentCalls = ((UnityEventBase)unityEvent).m_PersistentCalls;
			PersistentCall val = new PersistentCall();
			ref Object target = ref val.m_Target;
			object? target2 = ((Delegate)(object)action).Target;
			target = (Object)((target2 is Object) ? target2 : null);
			val.m_TargetAssemblyTypeName = UnityEventTools.TidyAssemblyTypeName(((Delegate)(object)action).Method.DeclaringType.AssemblyQualifiedName);
			val.m_MethodName = ((Delegate)(object)action).Method.Name;
			val.m_CallState = (UnityEventCallState)2;
			val.m_Mode = (PersistentListenerMode)0;
			persistentCalls.AddListener(val);
		}
	}
	public static class Tools
	{
		internal static bool isLoaded(string modguid)
		{
			foreach (KeyValuePair<string, PluginInfo> pluginInfo in Chainloader.PluginInfos)
			{
				string key = pluginInfo.Key;
				PluginInfo value = pluginInfo.Value;
				if (key == modguid)
				{
					return true;
				}
			}
			return false;
		}
	}
	public static class Assets
	{
		internal static Dictionary<string, AssetBundle> loadedBundles = new Dictionary<string, AssetBundle>();

		internal static AssetBundle LoadAssetBundle(string bundleName)
		{
			if (loadedBundles.ContainsKey(bundleName))
			{
				return loadedBundles[bundleName];
			}
			AssetBundle val = null;
			val = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(MoreHexesPlugin.PInfo.Location), bundleName));
			loadedBundles[bundleName] = val;
			return val;
		}
	}
	public static class Bindings
	{
		internal static bool BypassExpansionRequirement;

		public static bool BindSection(string sectionName)
		{
			return ConfigManager.DualBindToConfig(": Full Section Config", Config.MyConfig, sectionName, defaultValue: true, "Vanilla is FALSE. Set to false if you wish to disable changes made to an entire item or group of items.");
		}

		public static void Init()
		{
			string text = "";
			BypassExpansionRequirement = ConfigManager.DualBindToConfig(": Hexing Chaos", Config.MyConfig, "Bypass Expansion Requirements", defaultValue: false, "If set to true, some Hexes that don't technically rely on DLC assets will be made available to the Hallowed Concepts Expansion without requiring other Expansions or Mods.");
		}
	}
}
namespace HexingChaos.Items
{
	public abstract class ItemBase<T> : ItemBase where T : ItemBase<T>
	{
		public static T instance { get; private set; }

		public ItemBase()
		{
			if (instance != null)
			{
				throw new InvalidOperationException("Singleton class \"" + typeof(T).Name + "\" inheriting ItemBoilerplate/Item was instantiated twice");
			}
			instance = this as T;
		}
	}
	public abstract class ItemBase : SharedBase
	{
		public static Dictionary<string, ItemDef> DefDictionary = new Dictionary<string, ItemDef>();

		public ItemDef ItemsDef;

		public override AssetBundle assetBundle => MoreHexesPlugin.mainAssetBundle;

		public override string ConfigName => "Items : " + ItemName;

		public abstract string ItemName { get; }

		public abstract string ItemLangTokenName { get; }

		public abstract string ItemPickupDesc { get; }

		public abstract string ItemFullDescription { get; }

		public abstract string ItemLore { get; }

		public abstract ItemTier Tier { get; }

		public abstract ItemTag[] ItemTags { get; }

		public abstract GameObject ItemModel { get; }

		public abstract Sprite ItemIcon { get; }

		public virtual bool CanRemove { get; } = false;

		public virtual bool IsHidden { get; } = false;

		public virtual ExpansionDef RequiredExpansion { get; } = null;

		public virtual bool HalcyonShrineBias { get; } = false;

		public virtual bool CanBeTemporary { get; } = true;

		public virtual bool CanBeRental { get; } = true;

		public override void Init()
		{
			CreateItem();
			base.Init();
		}

		internal static bool CheckDLC1Entitlement()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			EntitlementDef expansion = Addressables.LoadAssetAsync<EntitlementDef>((object)"RoR2/DLC1/Common/entitlementDLC1.asset").WaitForCompletion();
			return CheckDLCEntitlement(expansion);
		}

		internal static bool CheckDLCEntitlement(EntitlementDef expansion)
		{
			if (EntitlementAbstractions.VerifyLocalSteamUser(expansion))
			{
				return true;
			}
			return false;
		}

		internal static void CloneVanillaDisplayRules(Object newDef, Object vanillaDef)
		{
			Debug.LogError((object)"Unable to clone vanilla display rules!");
		}

		public override void Lang()
		{
			DoLangForItem(ItemsDef, ItemName, ItemPickupDesc, ItemFullDescription, ItemLore);
		}

		public abstract ItemDisplayRuleDict CreateItemDisplayRules();

		protected void CreateItem()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			string text = ((object)Tier/*cast due to .constrained prefix*/).ToString();
			if (!text.Contains("Tier"))
			{
				text += "Tier";
			}
			ItemsDef = CreateNewItem(ItemLangTokenName, ItemModel, ItemIcon, Tier, ItemTags, RequiredExpansion, IsHidden, CanBeTemporary, CanBeRental);
			ItemDisplayRuleDict val = CreateItemDisplayRules();
			if (val == null)
			{
				val = new ItemDisplayRuleDict(Array.Empty<ItemDisplayRule>());
			}
		}

		public static ItemDef CreateNewItem(string langTokenName, GameObject modelPrefab, Sprite iconSprite, ItemTier tier, ItemTag[] itemTags = null, ExpansionDef requiredExpansion = null, bool isHidden = false, bool canBeTemporary = true, bool canBeRental = true)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			ItemDef val = CreateNewUntieredItem(langTokenName, iconSprite, tier, itemTags, isHidden, canBeTemporary, canBeRental);
			val.pickupModelPrefab = modelPrefab;
			val.requiredExpansion = requiredExpansion;
			return val;
		}

		public static ItemDef CreateNewUntieredItem(string langTokenName, Sprite iconSprite, ItemTier tier = (ItemTier)5, ItemTag[] itemTags = null, bool isHidden = false, bool canBeTemporary = false, bool canBeRental = false)
		{
			//IL_0079: 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_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Invalid comparison between Unknown and I4
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			ItemDef val = ScriptableObject.CreateInstance<ItemDef>();
			((Object)val).name = "ITEM_" + langTokenName;
			val.nameToken = "ITEM_" + langTokenName + "_NAME";
			val.pickupToken = "ITEM_" + langTokenName + "_PICKUP";
			val.descriptionToken = "ITEM_" + langTokenName + "_DESCRIPTION";
			val.loreToken = "ITEM_" + langTokenName + "_LORE";
			val.pickupIconSprite = iconSprite;
			val.tier = tier;
			val.deprecatedTier = tier;
			val.hidden = isHidden;
			if (itemTags != null && itemTags.Length != 0)
			{
				val.tags = itemTags;
				if ((int)tier != 3)
				{
					int num = val.tags.Length;
					if (canBeTemporary)
					{
						ref ItemTag[] tags = ref val.tags;
						ItemTag val2 = (ItemTag)31;
						ArrayUtils.ArrayAppend<ItemTag>(ref tags, ref num, ref val2);
					}
					if (canBeRental)
					{
						ref ItemTag[] tags2 = ref val.tags;
						ItemTag val2 = (ItemTag)40;
						ArrayUtils.ArrayAppend<ItemTag>(ref tags2, ref num, ref val2);
					}
				}
			}
			ContentAddition.AddItemDef(val);
			return val;
		}

		public void AddVoidItemRelationship(string itemToCorruptGuid)
		{
			AddVoidItemRelationship(itemToCorruptGuid, ItemsDef);
		}

		public static void AddVoidItemRelationship(string itemToCorruptGuid, ItemDef itemThatCorrupts)
		{
			SharedUtilsPlugin.LoadAsync<ItemDef>(itemToCorruptGuid, (Action<ItemDef>)delegate(ItemDef itemToCorrupt)
			{
				AddVoidItemRelationship(itemToCorrupt, itemThatCorrupts);
			});
		}

		public void AddVoidItemRelationship(ItemDef itemToCorrupt)
		{
			AddVoidItemRelationship(itemToCorrupt, ItemsDef);
		}

		internal static void AddVoidItemRelationship(ItemDef itemToCorrupt, ItemDef itemThatCorrupts)
		{
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0047: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			ItemRelationshipProvider val = ScriptableObject.CreateInstance<ItemRelationshipProvider>();
			((Object)val).name = ((Object)itemThatCorrupts).name + ((Object)itemToCorrupt).name + "Relationship";
			val.relationshipType = Addressables.LoadAssetAsync<ItemRelationshipType>((object)"RoR2/DLC1/Common/ContagiousItem.asset").WaitForCompletion();
			val.relationships = (Pair[])(object)new Pair[1]
			{
				new Pair
				{
					itemDef1 = itemToCorrupt,
					itemDef2 = itemThatCorrupts
				}
			};
			ContentAddition.AddItemRelationshipProvider(val);
		}

		internal static void AddBuffDef(BuffDef buffDef)
		{
			ContentAddition.AddBuffDef(buffDef);
		}

		internal static BuffDef CreateAndAddBuff(string buffName, Sprite buffIcon, Color buffColor, bool canStack, bool isDebuff, StackingDisplayMethod stackingDisplayMethod = (StackingDisplayMethod)0, bool isHidden = false)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			BuffDef val = ScriptableObject.CreateInstance<BuffDef>();
			((Object)val).name = buffName;
			val.buffColor = buffColor;
			val.canStack = canStack;
			val.isDebuff = isDebuff;
			val.eliteDef = null;
			val.iconSprite = buffIcon;
			val.stackingDisplayMethod = stackingDisplayMethod;
			val.isHidden = isHidden;
			AddBuffDef(val);
			return val;
		}

		public static void DoLangForItem(ItemDef itemDef, string name, string pickupDesc, string fullDesc = "", string lore = "")
		{
			LanguageAPI.Add(itemDef.nameToken, name);
			LanguageAPI.Add(itemDef.pickupToken, pickupDesc);
			LanguageAPI.Add(itemDef.descriptionToken, string.IsNullOrWhiteSpace(fullDesc) ? pickupDesc : fullDesc);
			LanguageAPI.Add(itemDef.loreToken, lore);
		}

		public int GetCount(CharacterBody body, bool permanentOnly = false)
		{
			if ((Object)(object)body == (Object)null)
			{
				return 0;
			}
			return GetCount(body.inventory, permanentOnly);
		}

		public int GetCount(Inventory inventory, bool permanentOnly = false)
		{
			if ((Object)(object)inventory == (Object)null)
			{
				return 0;
			}
			if (permanentOnly)
			{
				return inventory.GetItemCountPermanent(ItemsDef);
			}
			return inventory.GetItemCountEffective(ItemsDef);
		}

		public int GetCount(CharacterMaster master, bool permanentOnly = false)
		{
			if ((Object)(object)master == (Object)null)
			{
				return 0;
			}
			return GetCount(master.inventory, permanentOnly);
		}

		public static int GetCountSpecific(CharacterBody body, ItemDef itemIndex)
		{
			if (!Object.op_Implicit((Object)(object)body) || !Object.op_Implicit((Object)(object)body.inventory))
			{
				return 0;
			}
			return body.inventory.GetItemCountEffective(itemIndex);
		}

		public static float GetStackValue(float baseValue, float stackValue, int itemCount)
		{
			return baseValue + stackValue * (float)(itemCount - 1);
		}

		public static GameObject LoadDropPrefab(string prefabName = "", AssetBundle bundle = null)
		{
			return Extensions.FixItemModel(MoreHexesPlugin.TryLoadFromBundle<GameObject>("Assets/Models/DropPrefabs/Item/" + prefabName + ".prefab", bundle));
		}

		public static GameObject LoadDisplayPrefab(string prefabName = "", AssetBundle bundle = null)
		{
			return MoreHexesPlugin.TryLoadFromBundle<GameObject>("Assets/Models/DisplayPrefabs/Item/" + prefabName + ".prefab", bundle) ?? Resources.Load<GameObject>("prefabs/NullModel");
		}

		public static Sprite LoadItemIcon(string spriteName = "", AssetBundle bundle = null, bool fallBackOnWrench = false)
		{
			return MoreHexesPlugin.TryLoadSpriteFromBundle("Assets/Textures/Icons/Item/" + spriteName + ".png", bundle, fallBackOnWrench);
		}

		public static Sprite LoadBuffIcon(string spriteName = "", AssetBundle bundle = null, bool fallBackOnWrench = false)
		{
			return MoreHexesPlugin.TryLoadSpriteFromBundle("Assets/Textures/Icons/Buff/" + spriteName + ".png", bundle, fallBackOnWrench);
		}
	}
	public class CollectiveEulogy : ItemBase<CollectiveEulogy>
	{
		public static float corruptChanceBase = 0.05f;

		public static float corruptChanceStack = 0.05f;

		public override string ItemName => "Hex of Corruption";

		public override string ItemLangTokenName => "CURSEEULOGY";

		public override string ItemPickupDesc => "Items and equipment have a small chance to " + Styling.HexTierColor("transform into a random Hex") + " instead.";

		public override string ItemFullDescription => "Items have a " + Styling.UtilityColor(Styling.AsPercent(corruptChanceBase)) + " " + Styling.StackText("+" + Styling.AsPercent(corruptChanceStack)) + " chance to become a random " + Styling.HexTierColor("Hex") + " instead.";

		public override string ItemLore => "";

		public override ItemTier Tier => (ItemTier)13;

		public override ItemTag[] ItemTags
		{
			get
			{
				ItemTag[] array = new ItemTag[7];
				RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				return (ItemTag[])(object)array;
			}
		}

		public override GameObject ItemModel => ItemBase.LoadDropPrefab("PickupCurseEulogy");

		public override Sprite ItemIcon => ItemBase.LoadItemIcon("texIconHexCorruption");

		public override ExpansionDef RequiredExpansion => MoreHexesPlugin.GetExpansionBypass(SharedUtilsPlugin.dlc3);

		public override ItemDisplayRuleDict CreateItemDisplayRules()
		{
			return null;
		}

		public override void Hooks()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			RandomlyLunarUtils.CheckForLunarReplacement_UniquePickup_Xoroshiro128Plus += new hook_CheckForLunarReplacement_UniquePickup_Xoroshiro128Plus(RandomlyHex);
			OutsideInteractableLocker.UnlockAll += new hook_UnlockAll(LockThoseHexedTerminals);
		}

		private void LockThoseHexedTerminals(orig_UnlockAll orig, OutsideInteractableLocker self)
		{
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Invalid comparison between Unknown and I4
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: Invalid comparison between Unknown and I4
			Dictionary<IInteractableLockable, GameObject> dictionary = new Dictionary<IInteractableLockable, GameObject>(self.lockInteractableMap);
			ShopTerminalBehavior val = default(ShopTerminalBehavior);
			foreach (KeyValuePair<IInteractableLockable, GameObject> item in dictionary)
			{
				IInteractableLockable key = item.Key;
				if (key == null)
				{
					continue;
				}
				GameObject gameObject = key.GetGameObject();
				if (!((Object)(object)gameObject == (Object)null) && gameObject.TryGetComponent<ShopTerminalBehavior>(ref val))
				{
					PickupDef pickupDef = PickupCatalog.GetPickupDef(val.CurrentPickup().pickupIndex);
					if (pickupDef != null && (int)pickupDef.equipmentIndex == -1 && (int)pickupDef.itemTier == 13)
					{
						self.lockInteractableMap.Remove(key);
					}
				}
			}
			orig.Invoke(self);
		}

		private void LockHexedTerminals(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			ILLabel val2 = default(ILLabel);
			bool flag = val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<KeyValuePair<IInteractableLockable, GameObject>>(x, "Key"),
				(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref val2)
			});
		}

		private UniquePickup RandomlyHex(orig_CheckForLunarReplacement_UniquePickup_Xoroshiro128Plus orig, UniquePickup uniquePickup, Xoroshiro128Plus rng)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			PickupDef pickupDef = PickupCatalog.GetPickupDef(uniquePickup.pickupIndex);
			if (RandomlyLunarUtils.CanReplace(pickupDef))
			{
				GetTotalItemCountFromTeamArgs val = default(GetTotalItemCountFromTeamArgs);
				((GetTotalItemCountFromTeamArgs)(ref val))..ctor(ItemsDef.itemIndex);
				val.requiresAlive = false;
				val.requiredTeam = null;
				val.requiresConnected = false;
				val.onlyPlayerControlledCharacters = true;
				int totalItemCountFromTeam = Util.GetTotalItemCountFromTeam(val);
				if (totalItemCountFromTeam > 0)
				{
					List<PickupIndex> availableHexTierDropList = Run.instance.availableHexTierDropList;
					if (availableHexTierDropList != null && availableHexTierDropList.Count > 0 && rng.nextNormalizedFloat < ItemBase.GetStackValue(corruptChanceBase, corruptChanceStack, totalItemCountFromTeam))
					{
						int index = rng.RangeInt(0, availableHexTierDropList.Count);
						return ((UniquePickup)(ref uniquePickup)).WithPickupIndex(availableHexTierDropList[index]);
					}
				}
			}
			return orig.Invoke(uniquePickup, rng);
		}
	}
	public class CollectiveExodus : ItemBase<CollectiveExodus>
	{
		public static string[] exodusLeaveText = new string[9] { "Wait, where'd it go!?", "Is your fridge running..?", "Something is off...", "Must've been the wind?", "L8r!", "What's a 'Hallowed' item?", "Butterfingers!", "Am I forgetting something?", "My people need me!!" };

		internal static bool canExodusGlobal;

		public static BuffDef ExodusHolderBuff;

		public static GameObject exodusProjectilePrefab;

		public static float exodusInterval = 10f;

		public static float exodusChanceBase = 40f;

		public static float exodusChanceStack = 5f;

		public static float yawSpread = 270f;

		private static bool projectileCapacityHookApplied = false;

		private string pickupName => "ItemIndex.ITEM_" + ItemLangTokenName;

		public override string ItemName => "Hex of Exodus";

		public override string ItemLangTokenName => "CURSEEXODUS";

		public override string ItemPickupDesc => "Does " + Styling.HexTierColor("nothing..?");

		public override string ItemFullDescription => "Does " + Styling.HexTierColor("nothing..?") + " " + Styling.UtilityColor("Unaffected by luck") + ".";

		public override string ItemLore => "";

		public override ItemTier Tier => (ItemTier)13;

		public override ItemTag[] ItemTags => (ItemTag[])(object)new ItemTag[1] { (ItemTag)13 };

		public override GameObject ItemModel => ItemBase.LoadDropPrefab("PickupCurseExodus");

		public override Sprite ItemIcon => ItemBase.LoadItemIcon("texIconHexExodus");

		public override ExpansionDef RequiredExpansion => SharedUtilsPlugin.dlc3;

		public override ItemDisplayRuleDict CreateItemDisplayRules()
		{
			return null;
		}

		public override void Init()
		{
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			base.Init();
			SharedUtilsPlugin.LoadAsync<GameObject>(RoR2_DLC3_Items_TransferDebuffOnHit.TransferDebuffOnHitProjectile_prefab, (Action<GameObject>)CreateExodusProjectile);
			ExodusHolderBuff = ItemBase.CreateAndAddBuff("bdExodusHolder", ItemBase.LoadBuffIcon("texBuffExodusHolder"), Color.white, canStack: true, isDebuff: false, (StackingDisplayMethod)0);
		}

		private void CreateExodusProjectile(GameObject transferDebuffOnHitProjectile)
		{
			//IL_0063: 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_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Expected O, but got Unknown
			exodusProjectilePrefab = PrefabAPI.InstantiateClone(transferDebuffOnHitProjectile, "HexExodusProjectile", true);
			ProjectileControllerTrigger pct = default(ProjectileControllerTrigger);
			if (exodusProjectilePrefab.TryGetComponent<ProjectileControllerTrigger>(ref pct))
			{
				SharedUtilsPlugin.LoadAsync<GameObject>(RoR2_DLC3_Items_TransferDebuffOnHit.TransferDebuffOnHitProjectileGhost_prefab, (Action<GameObject>)delegate(GameObject transferDebuffOnHitProjectileGhost)
				{
					//IL_00ad: 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)
					GameObject val12 = PrefabAPI.InstantiateClone(transferDebuffOnHitProjectileGhost, "HexExodusProjectileGhost", false);
					((ProjectileController)pct).ghostPrefab = val12;
					((ProjectileController)pct).ghostPrefabAddress = null;
					Transform child = val12.transform.GetChild(0);
					Transform child2 = child.GetChild(0);
					((Component)child2.GetChild(0)).gameObject.SetActive(false);
					Object.Instantiate<GameObject>(ItemModel, child2);
					Transform child3 = val12.transform.GetChild(1);
					Transform child4 = child3.GetChild(0);
					MeshRenderer val13 = default(MeshRenderer);
					if (((Component)child4).gameObject.TryGetComponent<MeshRenderer>(ref val13))
					{
						Material val14 = Object.Instantiate<Material>(((Renderer)val13).material);
						val14.SetColor("_TintColor", Color32.op_Implicit(new Color32((byte)0, (byte)160, (byte)34, byte.MaxValue)));
						((Renderer)val13).sharedMaterials = (Material[])(object)new Material[1] { val14 };
						((Renderer)val13).material = val14;
					}
				});
			}
			ProjectileTransferItem val = default(ProjectileTransferItem);
			if (exodusProjectilePrefab.TryGetComponent<ProjectileTransferItem>(ref val))
			{
				SerializablePickupIndex val2 = new SerializablePickupIndex
				{
					pickupName = pickupName
				};
				val.pickupName = val2;
				val.maxCapacity = 1;
				val.destroyOnGrant = true;
			}
			ProjectileDeployToOwner val3 = default(ProjectileDeployToOwner);
			if (exodusProjectilePrefab.TryGetComponent<ProjectileDeployToOwner>(ref val3))
			{
				((Behaviour)val3).enabled = false;
			}
			Deployable val4 = default(Deployable);
			if (exodusProjectilePrefab.TryGetComponent<Deployable>(ref val4))
			{
				((Behaviour)val4).enabled = false;
			}
			ProjectileSphereTargetFinder val5 = default(ProjectileSphereTargetFinder);
			if (exodusProjectilePrefab.TryGetComponent<ProjectileSphereTargetFinder>(ref val5))
			{
				((Behaviour)val5).enabled = false;
			}
			ProjectileDirectionalTargetFinder val6 = default(ProjectileDirectionalTargetFinder);
			if (exodusProjectilePrefab.TryGetComponent<ProjectileDirectionalTargetFinder>(ref val6))
			{
				((Behaviour)val6).enabled = false;
			}
			ProjectileSteerTowardTarget val7 = default(ProjectileSteerTowardTarget);
			if (exodusProjectilePrefab.TryGetComponent<ProjectileSteerTowardTarget>(ref val7))
			{
				((Behaviour)val7).enabled = false;
			}
			ProjectileTargetComponent val8 = default(ProjectileTargetComponent);
			if (exodusProjectilePrefab.TryGetComponent<ProjectileTargetComponent>(ref val8))
			{
				((Behaviour)val8).enabled = false;
			}
			ProjectileFuse val9 = default(ProjectileFuse);
			if (exodusProjectilePrefab.TryGetComponent<ProjectileFuse>(ref val9))
			{
				((Behaviour)val9).enabled = true;
				val9.fuse = 1.33f;
				if ((Object)(object)val != (Object)null)
				{
					((UnityEventBase)val9.onFuse).RemoveAllListeners();
					val9.onFuse.AddPersistentListener(new UnityAction(val.DropItem));
				}
			}
			CharacterController val10 = exodusProjectilePrefab.AddComponent<CharacterController>();
			((Collider)val10).contactOffset = 0.01f;
			val10.radius = 0.1f;
			val10.height = 0.5f;
			val10.slopeLimit = 80f;
			val10.stepOffset = 0.3f;
			val10.skinWidth = 0.08f;
			val10.minMoveDistance = 0.001f;
			val10.detectCollisions = true;
			val10.enableOverlapRecovery = true;
			ProjectileCharacterController val11 = exodusProjectilePrefab.AddComponent<ProjectileCharacterController>();
			val11.velocity = 10f;
			ContentAddition.AddProjectile(exodusProjectilePrefab);
		}

		public override void Hooks()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			ProjectileTransferItem.DropItem += new hook_DropItem(ProjectileTransferItem_DropItem);
			ProjectileTransferItem.Start += new Manipulator(ProjectileTransferItem_Start);
			GlobalEventManager.onCharacterDeathServer += ExodusOnDeath;
			Stage.onStageStartGlobal += EnableExodus2;
			TeleporterInteraction.onTeleporterFinishGlobal += DisableExodus;
			TeleporterInteraction.onIdleToChargingStateSelected += DisableExodus2;
			TeleporterInteraction.onTeleporterBeginChargingGlobal += EnableExodus;
		}

		private void EnableExodus2(Stage obj)
		{
			canExodusGlobal = true;
		}

		private void EnableExodus(TeleporterInteraction obj)
		{
			canExodusGlobal = true;
		}

		private void DisableExodus(TeleporterInteraction obj)
		{
			canExodusGlobal = false;
		}

		private void DisableExodus2(BaseTeleporterState obj)
		{
			canExodusGlobal = false;
		}

		private void ExodusOnDeath(DamageReport damageReport)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody victimBody = damageReport.victimBody;
			int count = GetCount(victimBody);
			if (count > 0)
			{
				InputBankTest inputBank = victimBody.inputBank;
				FireExodusProjectile(victimBody, (inputBank != null) ? inputBank.aimDirection : victimBody.transform.forward);
			}
		}

		private void ProjectileTransferItem_Start(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			if (!val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<ProjectileTransferItem>(x, "maxCapacity"),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(Mathf).FullName, "Max")
			}))
			{
				SharedUtilsPlugin.DebugBreakpoint("ProjectileTransferItem_Start", -1);
				return;
			}
			int index = val.Index;
			val.Index = index + 1;
			val.Remove();
			val.EmitDelegate<Func<int, int, int>>((Func<int, int, int>)Mathf.Min);
			projectileCapacityHookApplied = true;
		}

		private void ProjectileTransferItem_DropItem(orig_DropItem orig, ProjectileTransferItem self)
		{
			orig.Invoke(self);
			if (NetworkServer.active)
			{
				self.hasGivenItem = true;
			}
		}

		internal static void FireExodusProjectile(CharacterBody sourceBody, Vector3 forward)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Expected O, but got Unknown
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_016f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_019d: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			Inventory inventory = sourceBody.inventory;
			if (!Object.op_Implicit((Object)(object)inventory))
			{
				return;
			}
			int itemCountPermanent = inventory.GetItemCountPermanent(ItemBase<CollectiveExodus>.instance.ItemsDef);
			if (itemCountPermanent <= 0)
			{
				return;
			}
			CustomOverrideInfo val = new CustomOverrideInfo
			{
				descriptionText = exodusLeaveText[Random.RandomRangeInt(0, exodusLeaveText.Length)]
			};
			CharacterMasterNotificationQueue.SendCustomNotification(sourceBody.master, ItemBase<CollectiveExodus>.instance.ItemsDef.itemIndex, val);
			forward.y = 0f;
			forward = Util.ApplySpread(Vector3.Normalize(forward), -45f, 45f, 1f, 0f, 0f, 0f);
			if (!projectileCapacityHookApplied || itemCountPermanent == 1)
			{
				FireProjectileInfo val2 = new FireProjectileInfo
				{
					projectilePrefab = exodusProjectilePrefab,
					owner = ((Component)sourceBody).gameObject,
					target = null,
					position = sourceBody.corePosition,
					rotation = Util.QuaternionSafeLookRotation(forward)
				};
				ProjectileManager.instance.FireProjectile(val2);
				return;
			}
			float num = yawSpread / (float)(itemCountPermanent + 1);
			for (int i = 0; i < itemCountPermanent; i++)
			{
				float num2 = num * ((float)i + 1f) - yawSpread / 2f;
				Vector3 val3 = Util.ApplySpread(forward, -15f, 15f, 1f, 0f, num2, 0f);
				FireProjectileInfo val4 = new FireProjectileInfo
				{
					projectilePrefab = exodusProjectilePrefab,
					owner = ((Component)sourceBody).gameObject,
					target = null,
					position = sourceBody.corePosition,
					rotation = Util.QuaternionSafeLookRotation(val3)
				};
				ProjectileManager.instance.FireProjectile(val4);
			}
		}
	}
	public class CollectiveExodusBehavior : BaseItemBodyBehavior
	{
		public bool canExodus = true;

		public float exodusCountdown = 0f;

		[ItemDefAssociation(useOnServer = true, useOnClient = false)]
		private static ItemDef GetItemDef()
		{
			return ItemBase<CollectiveExodus>.instance?.ItemsDef ?? null;
		}

		private void OnEnable()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Invalid comparison between Unknown and I4
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Invalid comparison between Unknown and I4
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Invalid comparison between Unknown and I4
			canExodus = (int)Stage.instance.sceneDef.sceneType == 1 || (int)Stage.instance.sceneDef.sceneType == 5 || (int)Stage.instance.sceneDef.sceneType == 4;
			exodusCountdown = CollectiveExodus.exodusInterval;
		}

		private void OnDisable()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			((BaseItemBodyBehavior)this).body.SetBuffCount(CollectiveExodus.ExodusHolderBuff.buffIndex, 0);
		}

		public override void OnInventoryRefresh()
		{
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			((BaseItemBodyBehavior)this).OnInventoryRefresh();
			((BaseItemBodyBehavior)this).body.SetBuffCount(CollectiveExodus.ExodusHolderBuff.buffIndex, base.stack);
		}

		private void FixedUpdate()
		{
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			if (!canExodus || !CollectiveExodus.canExodusGlobal)
			{
				return;
			}
			if (exodusCountdown > 0f)
			{
				exodusCountdown -= Time.fixedDeltaTime;
				return;
			}
			exodusCountdown = CollectiveExodus.exodusInterval;
			float stackValue = ItemBase.GetStackValue(CollectiveExodus.exodusChanceBase, CollectiveExodus.exodusChanceStack, base.stack);
			if (Util.CheckRoll(stackValue, 0f, (CharacterMaster)null))
			{
				Debug.LogError((object)"Exodus!!");
				CharacterBody body = ((BaseItemBodyBehavior)this).body;
				InputBankTest inputBank = ((BaseItemBodyBehavior)this).body.inputBank;
				CollectiveExodus.FireExodusProjectile(body, (inputBank != null) ? inputBank.aimDirection : ((BaseItemBodyBehavior)this).body.transform.forward);
			}
		}
	}
	public class ImmortalGupHelper : ItemBase<ImmortalGupHelper>
	{
		public static BuffDef ImmortalSnailBuff;

		public const string theImmortalNamePrefix = "The Immortal {0}";

		public const string theImmortalNamePrefixToken = "DDGD_IMMORTAL_MODIFIER";

		public override int loadOrder => -1;

		public override bool forcePrerequisites => true;

		public override bool isEnabled => true;

		public override string ItemName => "You Are The Immortal Snail";

		public override string ItemLangTokenName => "IMMORTALSNAILHELPER";

		public override string ItemPickupDesc => "You Are The Immortal Snail";

		public override string ItemFullDescription => "You Are The Immortal Snail";

		public override string ItemLore => "You Are The Immortal Snail";

		public override ItemTier Tier => (ItemTier)5;

		public override ItemTag[] ItemTags => (ItemTag[])(object)new ItemTag[0];

		public override GameObject ItemModel => ItemBase.LoadDropPrefab();

		public override Sprite ItemIcon => ItemBase.LoadItemIcon();

		public override bool GetPrerequisites()
		{
			return true;
		}

		public override ItemDisplayRuleDict CreateItemDisplayRules()
		{
			return null;
		}

		public override void Init()
		{
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			base.Init();
			ImmortalSnailBuff = ItemBase.CreateAndAddBuff("bdImmortalSnail", ItemBase.LoadBuffIcon("texBuffImmortalSnail"), Color.white, canStack: false, isDebuff: false, (StackingDisplayMethod)0);
			LanguageAPI.Add("DDGD_IMMORTAL_MODIFIER", "The Immortal {0}");
		}

		public override void Hooks()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			RecalculateStatsAPI.GetStatCoefficients += new StatHookEventHandler(ImmortalGupHelper_GetStatCoefficients);
		}

		private void ImmortalGupHelper_GetStatCoefficients(CharacterBody sender, StatHookEventArgs args)
		{
			int count = GetCount(sender);
			if (count > 0)
			{
				args.moveSpeedMultAdd += ItemBase.GetStackValue(VoidImmortalGup.gipSpeedBase - 1f, VoidImmortalGup.gipSpeedStack * VoidImmortalGup.gipSpeedBase, count);
				args.baseRegenAdd += 50f + 10f * sender.level;
			}
		}
	}
	public class ImmortalGupHelperBehavior : BaseItemBodyBehavior
	{
		[ItemDefAssociation(useOnServer = true, useOnClient = false)]
		private static ItemDef GetItemDef()
		{
			return ItemBase<ImmortalGupHelper>.instance?.ItemsDef ?? null;
		}

		private void OnEnable()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			CharacterBody body = ((BaseItemBodyBehavior)this).body;
			body.bodyFlags = (BodyFlags)(body.bodyFlags | 0x800010);
			((BaseItemBodyBehavior)this).body.AddTimedBuff(Buffs.Nullified, 5f);
			((BaseItemBodyBehavior)this).body.AddTimedBuff(Buffs.DisableAllSkills, 5f);
			((BaseItemBodyBehavior)this).body.AddBuff(ImmortalGupHelper.ImmortalSnailBuff);
		}

		private void FixedUpdate()
		{
		}

		private void OnDisable()
		{
			((BaseItemBodyBehavior)this).body.master.TrueKill();
		}
	}
	public class StormDistortion : ItemBase<StormDistortion>
	{
		public static float corruptionInterval = 20f;

		public static float corruptionIntervalStack = 10f;

		public static float corruptionIntervalMin = 0f;

		public static float corruptionDuration = 10f;

		public override string ItemName => "Hex of Distortion";

		public override string ItemLangTokenName => "CURSEDISTORTION";

		public override string ItemPickupDesc => string.Format("Lock a {0} for {1} seconds.", Styling.HexTierColor("random skill"), corruptionDuration);

		public override string ItemFullDescription => "Lock a " + Styling.HexTierColor("random skill") + " every " + Styling.UtilityColor(corruptionInterval.ToString()) + " " + Styling.StackText("-" + corruptionIntervalStack) + " seconds. Lasts for " + Styling.UtilityColor(corruptionDuration.ToString()) + " seconds.";

		public override string ItemLore => "";

		public override ItemTier Tier => (ItemTier)13;

		public override ItemTag[] ItemTags => (ItemTag[])(object)new ItemTag[0];

		public override GameObject ItemModel => ItemBase.LoadDropPrefab("PickupCurseDistortion");

		public override Sprite ItemIcon => ItemBase.LoadItemIcon("texIconHexDistortion");

		public override ExpansionDef RequiredExpansion => MoreHexesPlugin.GetExpansionBypass(SharedUtilsPlugin.dlc2);

		public override ItemDisplayRuleDict CreateItemDisplayRules()
		{
			return null;
		}

		public override void Hooks()
		{
		}
	}
	public class StormDistortionBehavior : BaseItemBodyBehavior
	{
		private SkillLocator skillLocator;

		private GenericSkill targetSkill;

		private bool isSkillLocked = false;

		private float stateChangeCountdown;

		[ItemDefAssociation(useOnServer = true, useOnClient = true)]
		private static ItemDef GetItemDef()
		{
			return ItemBase<StormDistortion>.instance?.ItemsDef ?? null;
		}

		private void OnEnable()
		{
			skillLocator = ((BaseItemBodyBehavior)this).body.skillLocator;
			targetSkill = PickRandomSkill();
			SetSkillLocked(newState: true);
			stateChangeCountdown = GetTimeUntilUnlock();
		}

		private GenericSkill PickRandomSkill()
		{
			int num = Random.RandomRangeInt(0, 4);
			if ((Object)(object)Run.instance != (Object)null)
			{
				num = Mathf.FloorToInt(Run.instance.runRNG.nextNormalizedFloat * 4f);
			}
			return (GenericSkill)(num switch
			{
				1 => skillLocator.secondary, 
				2 => skillLocator.utility, 
				3 => skillLocator.special, 
				_ => skillLocator.primary, 
			});
		}

		private float GetTimeUntilLock()
		{
			return Mathf.Max(0f, ItemBase.GetStackValue(StormDistortion.corruptionInterval, 0f - StormDistortion.corruptionIntervalStack, base.stack));
		}

		private float GetTimeUntilUnlock()
		{
			return StormDistortion.corruptionDuration;
		}

		private void OnDisable()
		{
			SetSkillLocked(newState: false);
		}

		private void SetSkillLocked(bool newState)
		{
			if (newState == isSkillLocked)
			{
				return;
			}
			isSkillLocked = newState;
			if (((BaseItemBodyBehavior)this).body.hasEffectiveAuthority)
			{
				if (isSkillLocked)
				{
					targetSkill.SetSkillOverride((object)this, CommonAssets.disabledSkill, (SkillOverridePriority)4);
				}
				else
				{
					targetSkill.UnsetSkillOverride((object)this, CommonAssets.disabledSkill, (SkillOverridePriority)4);
				}
			}
		}

		private void FixedUpdate()
		{
			stateChangeCountdown -= Time.fixedDeltaTime;
			if (stateChangeCountdown <= 0f && isSkillLocked)
			{
				SetSkillLocked(newState: false);
				stateChangeCountdown = GetTimeUntilLock();
			}
			if (stateChangeCountdown <= 0f && !isSkillLocked)
			{
				targetSkill = PickRandomSkill();
				SetSkillLocked(newState: true);
				stateChangeCountdown = GetTimeUntilUnlock();
			}
		}
	}
	public class StormLightning : ItemBase<StormLightning>
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static hook_SetParticipantMasterId <>9__29_1;

			public static hook_OnControlEnd <>9__29_2;

			internal void <Hooks>b__29_1(orig_SetParticipantMasterId orig, NetworkUIPromptController self, NetworkInstanceId newMasterObjectInstanceId)
			{
				//IL_000a: Unknown result type (might be due to invalid IL or missing references)
				CharacterMaster currentParticipantMaster = self.currentParticipantMaster;
				orig.Invoke(self, newMasterObjectInstanceId);
				<Hooks>g__BootlegPickupPickerPanelProtection|29_3(currentParticipantMaster, self.currentParticipantMaster);
			}

			internal void <Hooks>b__29_2(orig_OnControlEnd orig, NetworkUIPromptController self)
			{
				orig.Invoke(self);
				self.ClearParticipant();
			}
		}

		public static BuffDef NoLightningBuff;

		private static DamageTypeCombo lightningDamageTypeMeridian = new DamageTypeCombo(DamageTypeCombo.op_Implicit((DamageType)1073741824), (DamageTypeExtended)805306368, (DamageSource)0);

		private static DamageTypeCombo lightningDamageTypeNonMeridian = new DamageTypeCombo(DamageTypeCombo.op_Implicit((DamageType)1073741824), (DamageTypeExtended)268435456, (DamageSource)0);

		private static bool isMeridian = false;

		public static float strikeInterval = 4f;

		public static float strikeDelay = 1f;

		public static float strikeIntervalStack = 0.5f;

		public override string ItemName => "Hex of Flux";

		public override string ItemLangTokenName => "CURSELIGHTNING";

		public override string ItemPickupDesc => Styling.HexTierColor("Ruinous lightning") + " periodically strikes on your position.";

		public override string ItemFullDescription => "Every " + Styling.UtilityColor((strikeInterval + strikeDelay).ToString()) + " " + Styling.StackText("-" + Styling.AsPercent(strikeIntervalStack)) + " seconds, " + Styling.HexTierColor("ruinous lightning") + " strikes on your position.";

		public override string ItemLore => "";

		public override ItemTier Tier => (ItemTier)13;

		public override ItemTag[] ItemTags => (ItemTag[])(object)new ItemTag[0];

		public override GameObject ItemModel => ItemBase.LoadDropPrefab("PickupCurseLightning");

		public override Sprite ItemIcon => ItemBase.LoadItemIcon("texIconHexLightning");

		public override ExpansionDef RequiredExpansion => SharedUtilsPlugin.dlc2;

		public override ItemDisplayRuleDict CreateItemDisplayRules()
		{
			return null;
		}

		public override void Init()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			base.Init();
			NoLightningBuff = ItemBase.CreateAndAddBuff("bdHexLightningProtection", null, Color.white, canStack: false, isDebuff: false, (StackingDisplayMethod)0, isHidden: true);
		}

		public override void Hooks()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Expected O, but got Unknown
			Stage.onServerStageBegin += SwitchLightningDamageType;
			object obj = <>c.<>9__29_1;
			if (obj == null)
			{
				hook_SetParticipantMasterId val = delegate(orig_SetParticipantMasterId orig, NetworkUIPromptController self, NetworkInstanceId newMasterObjectInstanceId)
				{
					//IL_000a: Unknown result type (might be due to invalid IL or missing references)
					CharacterMaster currentParticipantMaster = self.currentParticipantMaster;
					orig.Invoke(self, newMasterObjectInstanceId);
					BootlegPickupPickerPanelProtection(currentParticipantMaster, self.currentParticipantMaster);
				};
				<>c.<>9__29_1 = val;
				obj = (object)val;
			}
			NetworkUIPromptController.SetParticipantMasterId += (hook_SetParticipantMasterId)obj;
			object obj2 = <>c.<>9__29_2;
			if (obj2 == null)
			{
				hook_OnControlEnd val2 = delegate(orig_OnControlEnd orig, NetworkUIPromptController self)
				{
					orig.Invoke(self);
					self.ClearParticipant();
				};
				<>c.<>9__29_2 = val2;
				obj2 = (object)val2;
			}
			NetworkUIPromptController.OnControlEnd += (hook_OnControlEnd)obj2;
			static void BootlegPickupPickerPanelProtection(CharacterMaster currentParticipantMaster, CharacterMaster newParticipantMaster)
			{
				//IL_003b: Unknown result type (might be due to invalid IL or missing references)
				//IL_004e: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
				//IL_0068: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00db: Unknown result type (might be due to invalid IL or missing references)
				if (NetworkServer.active)
				{
					if ((Object)(object)currentParticipantMaster != (Object)null && (Object)(object)newParticipantMaster != (Object)(object)currentParticipantMaster)
					{
						CharacterBody body = currentParticipantMaster.GetBody();
						if ((Object)(object)body != (Object)null && body.HasBuff(GetBuffIndex()))
						{
							body.ClearTimedBuffs(GetBuffIndex());
							while (body.HasBuff(GetBuffIndex()))
							{
								body.RemoveBuff(GetBuffIndex());
							}
						}
					}
					if ((Object)(object)newParticipantMaster != (Object)null)
					{
						CharacterBody body2 = newParticipantMaster.GetBody();
						if ((Object)(object)body2 != (Object)null && body2.isPlayerControlled)
						{
							body2.ClearTimedBuffs(GetBuffIndex());
							while (body2.HasBuff(GetBuffIndex()))
							{
								body2.RemoveBuff(GetBuffIndex());
							}
							body2.AddBuff(GetBuffIndex());
						}
					}
				}
			}
			static BuffIndex GetBuffIndex()
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				return NoLightningBuff.buffIndex;
			}
		}

		private void SwitchLightningDamageType(Stage obj)
		{
			isMeridian = obj.sceneDef.baseSceneName == "meridian";
		}

		private void LightningStormController_FireLightningBolt_Vector3(orig_FireLightningBolt_Vector3 orig, Vector3 position)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			if (!LightningStormController.instance.stormActive)
			{
				SendLightningStrike(position, LightningStormController.lightningPrefab);
			}
			orig.Invoke(position);
		}

		public static void SendLightningStrike(Vector3 position, GameObject lightningPrefab, BlastAttack _blastInfo = null)
		{
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				return;
			}
			LightningStrikeInstance val = null;
			if ((Object)(object)LightningStormController.instance != (Object)null)
			{
				val = LightningStormController.GetPooledLightningStrike(lightningPrefab);
			}
			if ((Object)(object)val == (Object)null)
			{
				GameObject val2 = Addressables.LoadAssetAsync<GameObject>((object)RoR2_DLC2_meridian_DisableSkillsLightning.LightningStrikeInstance_prefab).WaitForCompletion();
				GameObject val3 = Object.Instantiate<GameObject>(val2, position, Quaternion.identity);
				if (!val3.TryGetComponent<LightningStrikeInstance>(ref val))
				{
					return;
				}
			}
			val.blastDamageType = (isMeridian ? lightningDamageTypeMeridian : lightningDamageTypeNonMeridian);
			val.Initialize(position, _blastInfo, strikeDelay, true);
			LightningStormController.ReportLightningStrike(position);
		}

		[CompilerGenerated]
		internal static BuffIndex <Hooks>g__GetBuffIndex|29_0()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			return NoLightningBuff.buffIndex;
		}

		[CompilerGenerated]
		internal static void <Hooks>g__BootlegPickupPickerPanelProtection|29_3(CharacterMaster currentParticipantMaster, CharacterMaster newParticipantMaster)
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00db: Unknown result type (might be due to invalid IL or missing references)
			if (!NetworkServer.active)
			{
				return;
			}
			if ((Object)(object)currentParticipantMaster != (Object)null && (Object)(object)newParticipantMaster != (Object)(object)currentParticipantMaster)
			{
				CharacterBody body = currentParticipantMaster.GetBody();
				if ((Object)(object)body != (Object)null && body.HasBuff(<Hooks>g__GetBuffIndex|29_0()))
				{
					body.ClearTimedBuffs(<Hooks>g__GetBuffIndex|29_0());
					while (body.HasBuff(<Hooks>g__GetBuffIndex|29_0()))
					{
						body.RemoveBuff(<Hooks>g__GetBuffIndex|29_0());
					}
				}
			}
			if (!((Object)(object)newParticipantMaster != (Object)null))
			{
				return;
			}
			CharacterBody body2 = newParticipantMaster.GetBody();
			if ((Object)(object)body2 != (Object)null && body2.isPlayerControlled)
			{
				body2.ClearTimedBuffs(<Hooks>g__GetBuffIndex|29_0());
				while (body2.HasBuff(<Hooks>g__GetBuffIndex|29_0()))
				{
					body2.RemoveBuff(<Hooks>g__GetBuffIndex|29_0());
				}
				body2.AddBuff(<Hooks>g__GetBuffIndex|29_0());
			}
		}
	}
	public class StormLightningBehavior : BaseItemBodyBehavior
	{
		public bool canStrike = true;

		public float strikeCountdown = 0f;

		[ItemDefAssociation(useOnServer = false, useOnClient = true)]
		private static ItemDef GetItemDef()
		{
			return ItemBase<StormLightning>.instance?.ItemsDef ?? null;
		}

		private void OnEnable()
		{
			canStrike = true;
			strikeCountdown = 3f;
			TeleporterInteraction.onTeleporterFinishGlobal += DisableExodus;
		}

		private void OnDisable()
		{
			TeleporterInteraction.onTeleporterFinishGlobal -= DisableExodus;
		}

		private void DisableExodus(TeleporterInteraction obj)
		{
			canStrike = false;
		}

		private float GetInterval()
		{
			return StormLightning.strikeDelay + StormLightning.strikeInterval * Util.ConvertAmplificationPercentageIntoReductionNormalizedInverted((float)(base.stack - 1) * StormLightning.strikeIntervalStack);
		}

		private void FixedUpdate()
		{
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			if (canStrike)
			{
				if (((BaseItemBodyBehavior)this).body.HasBuff(Buffs.HiddenRejectAllDamage) || ((BaseItemBodyBehavior)this).body.HasBuff(StormLightning.NoLightningBuff))
				{
					strikeCountdown = Mathf.Max(strikeCountdown, 1f);
				}
				if (strikeCountdown > 0f)
				{
					strikeCountdown -= Time.fixedDeltaTime;
					return;
				}
				strikeCountdown = GetInterval();
				StormLightning.SendLightningStrike(((BaseItemBodyBehavior)this).body.footPosition, LightningStormController.lightningPrefab);
			}
		}
	}
	public class SwanEliteSpread : ItemBase<SwanEliteSpread>
	{
		public static int spreadCtBase = 2;

		public static int spreadCtStack = 1;

		public static float spreadRangeBase = 30f;

		public static float spreadRangeStack = 10f;

		public static float spreadDurationBase = 8f;

		public static float spreadDurationStack = 5f;

		public static bool blacklistVoidtouched = true;

		public override string ItemName => "Hex of Power";

		public override string ItemLangTokenName => "CURSEELITESPREAD";

		public override string ItemPickupDesc => "Slain elites " + Styling.HexTierColor("transfer their power") + " to other nearby enemies.";

		public override string ItemFullDescription => "Slain Elites " + Styling.HexTierColor("empower") + " up to " + Styling.UtilityColor(spreadCtBase.ToString()) + " " + Styling.StackText("+" + spreadCtStack) + " nearby enemies. Empowered enemies gain the " + Styling.DamageColor("power") + " of the killed elite monster for " + Styling.DamageColor(spreadDurationBase.ToString()) + " " + Styling.StackText("+" + spreadDurationStack) + ".";

		public override string ItemLore => "";

		public override ItemTier Tier => (ItemTier)13;

		public override ItemTag[] ItemTags => (ItemTag[])(object)new ItemTag[0];

		public override GameObject ItemModel => ItemBase.LoadDropPrefab("PickupCurseEliteSpread");

		public override Sprite ItemIcon => ItemBase.LoadItemIcon("texIconHexEliteSpread");

		public override ExpansionDef RequiredExpansion => MoreHexesPlugin.GetExpansionBypass(SwanSongPlugin.expansionDefSS2);

		public override bool GetPrerequisites()
		{
			return Bindings.BypassExpansionRequirement || MoreHexesPlugin.isSwanSongLoaded;
		}

		public override ItemDisplayRuleDict CreateItemDisplayRules()
		{
			return null;
		}

		public override void Hooks()
		{
			GlobalEventManager.onCharacterDeathServer += SpreadElitePower;
		}

		private void SpreadElitePower(DamageReport damageReport)
		{
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0246: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_0272: Expected O, but got Unknown
			if (((Object)(object)damageReport.victimBody == (Object)null && (Object)(object)damageReport.attackerBody == (Object)null) || !damageReport.victimIsElite)
			{
				return;
			}
			int count = GetCount(damageReport.attackerBody);
			if (count <= 0)
			{
				return;
			}
			float stackValue = ItemBase.GetStackValue(spreadCtBase, spreadCtStack, count);
			float stackValue2 = ItemBase.GetStackValue(spreadRangeBase, spreadRangeStack, count);
			float stackValue3 = ItemBase.GetStackValue(spreadDurationBase, spreadDurationStack, count);
			SphereSearch val = new SphereSearch
			{
				mask = ((LayerIndex)(ref LayerIndex.entityPrecise)).mask,
				origin = damageReport.victimBody.transform.position,
				queryTriggerInteraction = (QueryTriggerInteraction)2,
				radius = stackValue2
			};
			TeamMask enemyTeams = TeamMask.GetEnemyTeams(damageReport.attackerTeamIndex);
			List<HurtBox> list = new List<HurtBox>();
			val.RefreshCandidates().FilterCandidatesByHurtBoxTeam(enemyTeams).FilterCandidatesByDistinctHurtBoxEntities()
				.OrderCandidatesByDistance()
				.GetHurtBoxes(list);
			int count2 = list.Count;
			if (count2 <= 0)
			{
				return;
			}
			BuffDef[] array = (from buffIndex in damageReport.victimBody.activeBuffsList
				select BuffCatalog.GetBuffDef(buffIndex) into buffDef
				where buffDef.isElite && (!blacklistVoidtouched || buffDef.buffIndex != Buffs.EliteVoid.buffIndex)
				select buffDef).ToArray();
			int num = 0;
			for (int num2 = 0; num2 < count2; num2++)
			{
				if ((float)num >= stackValue)
				{
					break;
				}
				HurtBox val2 = list[num2];
				if ((Object)(object)val2 == (Object)null)
				{
					continue;
				}
				HealthComponent healthComponent = val2.healthComponent;
				CharacterBody body = healthComponent.body;
				if ((Object)(object)body == (Object)null || (Object)(object)body == (Object)(object)damageReport.victimBody)
				{
					continue;
				}
				bool flag = false;
				BuffDef[] array2 = array;
				foreach (BuffDef val3 in array2)
				{
					if (!body.HasBuff(val3))
					{
						body.AddTimedBuff(val3, stackValue3);
						flag = true;
					}
				}
				if (flag)
				{
					EffectManager.SpawnEffect(LegacyResourcesAPI.Load<GameObject>("prefabs/effects/JellyfishNova"), new EffectData
					{
						origin = body.corePosition,
						scale = body.bestFitRadius + 4f
					}, true);
					num++;
				}
			}
		}
	}
	public class SwanFasterStorm : ItemBase<SwanFasterStorm>
	{
		public static float stormTimeReductionSeconds = 40f;

		public static float stormTimeReductionSecondsStack = 20f;

		public static float strikeIntervalStack = 0.5f;

		public override string ItemName => "Hex of Pressure";

		public override string ItemLangTokenName => "CURSEFASTERSTORM";

		public override string ItemPickupDesc => "The Storm will appear " + Styling.HexTierColor(stormTimeReductionSeconds + " seconds sooner") + ".";

		public override string ItemFullDescription => "The Storm will appear " + Styling.HexTierColor(stormTimeReductionSeconds + " seconds") + " " + Styling.StackText("-" + stormTimeReductionSecondsStack) + " sooner.";

		public override string ItemLore => "";

		public override ItemTier Tier => (ItemTier)13;

		public override ItemTag[] ItemTags
		{
			get
			{
				ItemTag[] array = new ItemTag[7];
				RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				return (ItemTag[])(object)array;
			}
		}

		public override GameObject ItemModel => ItemBase.LoadDropPrefab("PickupCurseFasterStorm");

		public override Sprite ItemIcon => ItemBase.LoadItemIcon("texIconHexFasterStorms");

		public override ExpansionDef RequiredExpansion => SwanSongPlugin.expansionDefSS2;

		public override bool GetPrerequisites()
		{
			if (!MoreHexesPlugin.isSwanSongLoaded)
			{
				return false;
			}
			return GetStormsEnabled();
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		private static bool GetStormsEnabled()
		{
			return StormsCore.stormsEnabled;
		}

		public override ItemDisplayRuleDict CreateItemDisplayRules()
		{
			return null;
		}

		public override void Hooks()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			if (StormsCore.stormsEnabled)
			{
				StormsCore.GetStormDelayModifierSeconds += new StormDelayModifierEventHandler(StormDelayer);
			}
		}

		private void StormDelayer(StormController sender, ref float delayModifier)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			float stackValue = ItemBase.GetStackValue(stormTimeReductionSeconds, stormTimeReductionSecondsStack, Util.GetItemCountForTeam((TeamIndex)1, ItemsDef.itemIndex, true, true));
			delayModifier -= stackValue;
		}
	}
	public class SwanSmallerTp : ItemBase<SwanSmallerTp>
	{
		public static float shrinkAmt = 0.3f;

		public override string ItemName => "Hex of Convergence";

		public override string ItemLangTokenName => "CURSECONVERGENCE";

		public override string ItemPickupDesc => Styling.HexTierColor("Reduce") + " the size of the Teleporter's radius.";

		public override string ItemFullDescription => "Reduce the size of the Teleporter and 'Holdout Zones' such as the Void Fields by " + Styling.HexTierColor(Styling.AsPercent(shrinkAmt)) + " " + Styling.StackText("-" + Styling.AsPercent(shrinkAmt)) + ".";

		public override string ItemLore => "";

		public override ItemTier Tier => (ItemTier)13;

		public override ItemTag[] ItemTags
		{
			get
			{
				ItemTag[] array = new ItemTag[7];
				RuntimeHelpers.InitializeArray(array, (RuntimeFieldHandle)/*OpCode not supported: LdMemberToken*/);
				return (ItemTag[])(object)array;
			}
		}

		public override GameObject ItemModel => ItemBase.LoadDropPrefab("PickupCurseSmallerTp");

		public override Sprite ItemIcon => ItemBase.LoadItemIcon("texIconHexConvergence");

		public override ExpansionDef RequiredExpansion => MoreHexesPlugin.GetExpansionBypass(SwanSongPlugin.expansionDefSS2);

		public override bool GetPrerequisites()
		{
			return Bindings.BypassExpansionRequirement || MoreHexesPlugin.isSwanSongLoaded;
		}

		public override ItemDisplayRuleDict CreateItemDisplayRules()
		{
			return null;
		}

		public override void Hooks()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			HoldoutZoneController.Start += new hook_Start(HoldoutZoneController_Start);
		}

		private void HoldoutZoneController_Start(orig_Start orig, HoldoutZoneController self)
		{
			orig.Invoke(self);
			if (self.applyFocusConvergence)
			{
				((Component)self).gameObject.AddComponent<HexConvergenceController>();
			}
		}
	}
	public class HexConvergenceController : MonoBehaviour
	{
		private static readonly float convergenceRadiusDivisor = 2f;

		private static readonly float convergenceChargeRateBonus = 0.3f;

		private static readonly Color convergenceMaterialColor = Color32.op_Implicit(new Color32((byte)0, (byte)160, (byte)34, byte.MaxValue));

		private static readonly float rampUpTime = 5f;

		private static readonly float startupDelay = 3f;

		private static readonly int cap = 3;

		private float currentValue;

		private HoldoutZoneController holdoutZoneController;

		private int currentFocusConvergenceCount;

		private FixedTimeStamp enabledTime;

		private static readonly AnimationCurve colorCurve = AnimationCurve.EaseInOut(0f, 0f, 1f, 1f);

		private void Awake()
		{
			holdoutZoneController = ((Component)this).GetComponent<HoldoutZoneController>();
		}

		private void OnEnable()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			enabledTime = FixedTimeStamp.now;
			holdoutZoneController.calcRadius += new CalcRadiusDelegate(ApplyRadius);
			holdoutZoneController.calcColor += new CalcColorDelegate(ApplyColor);
		}

		private void OnDisable()
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			holdoutZoneController.calcColor -= new CalcColorDelegate(ApplyColor);
			holdoutZoneController.calcRadius -= new CalcRadiusDelegate(ApplyRadius);
		}

		private void ApplyRadius(ref float radius)
		{
			if (currentFocusConvergenceCount > 0)
			{
				radius /= 1f + (float)currentFocusConvergenceCount * SwanSmallerTp.shrinkAmt;
			}
		}

		private void ApplyColor(ref Color color)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			color = Color.Lerp(color, convergenceMaterialColor, colorCurve.Evaluate(currentValue));
		}

		private void Update()
		{
			DoUpdate(Time.deltaTime);
		}

		private void DoUpdate(float deltaTime)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			GetTotalItemCountFromTeamArgs val = default(GetTotalItemCountFromTeamArgs);
			((GetTotalItemCountFromTeamArgs)(ref val))..ctor(ItemBase<SwanSmallerTp>.instance.ItemsDef.itemIndex);
			val.requiresAlive = true;
			val.requiredTeam = holdoutZoneController.chargingTeam;
			val.requiresConnected = false;
			currentFocusConvergenceCount = Util.GetTotalItemCountFromTeam(val);
			if (((FixedTimeStamp)(ref enabledTime)).timeSince < FocusConvergenceController.startupDelay)
			{
				currentFocusConvergenceCount = 0;
			}
			currentFocusConvergenceCount = Mathf.Min(currentFocusConvergenceCount, FocusConvergenceController.cap);
			float num = (((float)currentFocusConvergenceCount > 0f) ? 1f : 0f);
			float num2 = Mathf.MoveTowards(currentValue, num, FocusConvergenceController.rampUpTime * deltaTime);
			if (currentValue <= 0f && num2 > 0f)
			{
				Util.PlaySound("Play_item_lunar_focusedConvergence", ((Component)this).gameObject);
			}
			currentValue = num2;
		}
	}
	public class VoidImmortalGup : ItemBase<VoidImmortalGup>
	{
		public static float gipSpeedBase = 0.75f;

		public static float gipSpeedStack = 0.2f;

		private static bool gupDamageSourceSet = false;

		public override string ItemName => "Hex of Inevitability";

		public override string ItemLangTokenName => "CURSEIMMORTALGUP";

		public override string ItemPickupDesc => "You are chased by an " + Styling.HexTierColor("immortal Gip") + ".";

		public override string ItemFullDescription => "You are chased by an " + Styling.HexTierColor("immortal Gip") + " that will " + Styling.HexTierColor("instantly kill you") + ". The " + Styling.HexTierColor("immortal Gip") + " moves " + Styling.UtilityColor("0%") + " faster " + Styling.StackText("+" + Styling.AsPercent(gipSpeedStack)) + ".";

		public override string ItemLore => "";

		public override ItemTier Tier => (ItemTier)13;

		public override ItemTag[] ItemTags => (ItemTag[])(object)new ItemTag[1] { (ItemTag)13 };

		public override GameObject ItemModel => ItemBase.LoadDropPrefab("PickupCurseImmortalGup");

		public override Sprite ItemIcon => ItemBase.LoadItemIcon("texIconHexImmortalGup");

		public override ExpansionDef RequiredExpansion => SharedUtilsPlugin.dlc1;

		public override ItemDisplayRuleDict CreateItemDisplayRules()
		{
			return null;
		}

		public override void Hooks()
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: 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_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Expected O, but got Unknown
			Util.GetBestBodyName += new hook_GetBestBodyName(TheImmortalNameModifier);
			CharacterModel.UpdateOverlays += new Manipulator(TheImmortalOverlay);
			HealthComponent.TakeDamageProcess += new hook_TakeDamageProcess(HealthComponent_TakeDamageProcess);
			gupDamageSourceSet = MoreHexesPlugin.isDamageSourceLoaded;
			if (!gupDamageSourceSet)
			{
				BasicMeleeAttack.OnEnter += new Manipulator(GupDamageType);
				gupDamageSourceSet = true;
			}
		}

		private void TheImmortalOverlay(ILContext il)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0008: Expected O, but got Unknown
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Buffs).FullName, "HealingDisabled"),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(x, "HasBuff")
			}))
			{
				SharedUtilsP