Decompiled source of PillarRevive v1.1.1

PillarRevive.dll

Decompiled 3 months ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using Dolso;
using Dolso.RiskofOptions;
using HG.GeneralSerializer;
using HG.Reflection;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.ResourceManagement.AsyncOperations;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("PillarRevive")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0+4ad3b01245adf599ca61cff31f87e7e697caf274")]
[assembly: AssemblyProduct("PillarRevive")]
[assembly: AssemblyTitle("PillarRevive")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
namespace Dolso
{
	internal static class log
	{
		private static ManualLogSource logger;

		internal static void start(ManualLogSource logSource)
		{
			logger = logSource;
		}

		internal static void start(string name)
		{
			logger = Logger.CreateLogSource(name);
		}

		internal static void debug(object data)
		{
			logger.LogDebug(data);
		}

		internal static void info(object data)
		{
			logger.LogInfo(data);
		}

		internal static void message(object data)
		{
			logger.LogMessage(data);
		}

		internal static void warning(object data)
		{
			logger.LogWarning(data);
		}

		internal static void error(object data)
		{
			logger.LogError(data);
		}

		internal static void fatal(object data)
		{
			logger.LogFatal(data);
		}

		internal static void LogError(this ILCursor c, object data)
		{
			logger.LogError((object)string.Format($"ILCursor failure: {data}\n{c}"));
		}

		internal static void LogErrorCaller(this ILCursor c, object data, [CallerMemberName] string callerName = "")
		{
			logger.LogError((object)string.Format($"ILCursor failure in {callerName}: {data}\n{c}"));
		}
	}
	internal static class HookManager
	{
		internal const BindingFlags allFlags = BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic;

		private static readonly List<IDetour> hooks = new List<IDetour>();

		private static ILHookConfig ilHookConfig = new ILHookConfig
		{
			ManualApply = true
		};

		private static HookConfig onHookConfig = new HookConfig
		{
			ManualApply = true
		};

		internal static void Hook(Type typeFrom, string methodFrom, Manipulator ilHook)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			try
			{
				ILHook val = new ILHook((MethodBase)typeFrom.GetMethod(methodFrom, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), ilHook, ref ilHookConfig);
				try
				{
					val.Apply();
					hooks.Add((IDetour)(object)val);
				}
				catch (Exception ex)
				{
					log.error($"Failed to apply ILHook: {val.Method.DeclaringType}.{val.Method.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex}");
				}
			}
			catch (Exception ex2)
			{
				log.error($"Failed to make ILHook {typeFrom}.{methodFrom} - {((Delegate)(object)ilHook).Method.Name}\n{ex2}");
			}
		}

		internal static void Hook(MethodBase methodFrom, Manipulator ilHook)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			try
			{
				ILHook val = new ILHook(methodFrom, ilHook, ref ilHookConfig);
				try
				{
					val.Apply();
					hooks.Add((IDetour)(object)val);
				}
				catch (Exception ex)
				{
					log.error($"Failed to apply ILHook: {val.Method.DeclaringType}.{val.Method.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex}");
				}
			}
			catch (Exception ex2)
			{
				log.error($"Failed to make ILHook {methodFrom.DeclaringType}.{methodFrom.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex2}");
			}
		}

		internal static void Hook(Delegate from, Manipulator ilHook)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			try
			{
				ILHook val = new ILHook((MethodBase)from.Method, ilHook, ref ilHookConfig);
				try
				{
					val.Apply();
					hooks.Add((IDetour)(object)val);
				}
				catch (Exception ex)
				{
					log.error($"Failed to apply ILHook: {val.Method.DeclaringType}.{val.Method.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex}");
				}
			}
			catch (Exception ex2)
			{
				log.error($"Failed to make ILHook {from.Method.DeclaringType}.{from.Method.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex2}");
			}
		}

		internal static void Hook<T>(Expression<Action<T>> from, Manipulator ilHook)
		{
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Expected O, but got Unknown
			MethodInfo method = ((MethodCallExpression)from.Body).Method;
			try
			{
				ILHook val = new ILHook((MethodBase)method, ilHook, ref ilHookConfig);
				try
				{
					val.Apply();
					hooks.Add((IDetour)(object)val);
				}
				catch (Exception ex)
				{
					log.error($"Failed to apply ILHook: {val.Method.DeclaringType}.{val.Method.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex}");
				}
			}
			catch (Exception ex2)
			{
				log.error($"Failed to make ILHook: {method.DeclaringType}.{method.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex2}");
			}
		}

		internal static void Hook(Type typeFrom, string methodFrom, Delegate onHook)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			try
			{
				Hook val = new Hook((MethodBase)typeFrom.GetMethod(methodFrom, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), onHook, ref onHookConfig);
				try
				{
					val.Apply();
					hooks.Add((IDetour)(object)val);
				}
				catch (Exception ex)
				{
					log.error($"Failed to apply onHook: {val.Method.DeclaringType}.{val.Method.Name} - {onHook.Method.Name}\n{ex}");
				}
			}
			catch (Exception ex2)
			{
				log.error($"Failed to make onHook {typeFrom}.{methodFrom} - {onHook.Method.Name}\n{ex2}");
			}
		}

		internal static void Hook(MethodInfo methodFrom, MethodInfo onHook)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			try
			{
				Hook val = new Hook((MethodBase)methodFrom, onHook, ref onHookConfig);
				try
				{
					val.Apply();
					hooks.Add((IDetour)(object)val);
				}
				catch (Exception ex)
				{
					log.error($"Failed to apply onHook: {val.Method.DeclaringType}.{val.Method.Name} - {val.Target.Name}\n{ex}");
				}
			}
			catch (Exception ex2)
			{
				log.error($"Failed to make onHook {methodFrom.DeclaringType}.{methodFrom.Name} - {onHook.Name}\n{ex2}");
			}
		}

		internal static void Hook(MethodBase methodFrom, Delegate onHook)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			try
			{
				Hook val = new Hook(methodFrom, onHook, ref onHookConfig);
				try
				{
					val.Apply();
					hooks.Add((IDetour)(object)val);
				}
				catch (Exception ex)
				{
					log.error($"Failed to apply onHook: {val.Method.DeclaringType}.{val.Method.Name} - {onHook.Method.Name}\n{ex}");
				}
			}
			catch (Exception ex2)
			{
				log.error($"Failed to make onHook {methodFrom.DeclaringType}.{methodFrom.Name} - {onHook.Method.Name}\n{ex2}");
			}
		}

		internal static void Hook(Delegate from, Delegate onHook)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			try
			{
				Hook val = new Hook((MethodBase)from.Method, onHook, ref onHookConfig);
				try
				{
					val.Apply();
					hooks.Add((IDetour)(object)val);
				}
				catch (Exception ex)
				{
					log.error($"Failed to apply onHook: {val.Method.DeclaringType}.{val.Method.Name} - {onHook.Method.Name}\n{ex}");
				}
			}
			catch (Exception ex2)
			{
				log.error($"Failed to make onHook {from.Method.DeclaringType}.{from.Method.Name} - {onHook.Method.Name}\n{ex2}");
			}
		}

		internal static void Hook<T>(Expression<Action<T>> from, Delegate onto)
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			try
			{
				Hook val = new Hook((MethodBase)((MethodCallExpression)from.Body).Method, onto, ref onHookConfig);
				try
				{
					val.Apply();
					hooks.Add((IDetour)(object)val);
				}
				catch (Exception ex)
				{
					log.error($"Failed to apply onHook: {val.Method.DeclaringType}.{val.Method.Name} - {onto.Method.Name}\n{ex}");
				}
			}
			catch (Exception ex2)
			{
				log.error($"Failed to make onHook {((MethodCallExpression)from.Body).Method.DeclaringType}.{((MethodCallExpression)from.Body).Method.Name} - {onto.Method.Name}\n{ex2}");
			}
		}

		internal static void Hook(Type typeFrom, string methodFrom, Delegate onHook, object instance)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			try
			{
				Hook val = new Hook((MethodBase)typeFrom.GetMethod(methodFrom, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), onHook.Method, instance, ref onHookConfig);
				try
				{
					val.Apply();
					hooks.Add((IDetour)(object)val);
				}
				catch (Exception ex)
				{
					log.error($"Failed to apply onHook: {val.Method.DeclaringType}.{val.Method.Name} - {onHook.Method.Name}\n{ex}");
				}
			}
			catch (Exception ex2)
			{
				log.error($"Failed to make onHook {typeFrom}.{methodFrom} - {onHook.Method.Name}\n{ex2}");
			}
		}

		internal static void HookConfig<T>(this ConfigEntry<T> configEntry, Func<bool> enabled, Type typeFrom, string methodFrom, Manipulator ilHook)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			try
			{
				configEntry.AddHookConfig<T>(enabled, (IDetour)new ILHook((MethodBase)typeFrom.GetMethod(methodFrom, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), ilHook, ref ilHookConfig));
			}
			catch (Exception ex)
			{
				log.error($"Failed to ILHook {typeFrom}.{methodFrom} - {((Delegate)(object)ilHook).Method.Name}\n{ex}");
			}
		}

		internal static void HookConfig<T>(this ConfigEntry<T> configEntry, Func<bool> enabled, MethodBase methodFrom, Manipulator ilHook)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			try
			{
				configEntry.AddHookConfig<T>(enabled, (IDetour)new ILHook(methodFrom, ilHook, ref ilHookConfig));
			}
			catch (Exception ex)
			{
				log.error($"Failed to ILHook {methodFrom.DeclaringType}.{methodFrom.Name} - {((Delegate)(object)ilHook).Method.Name}\n{ex}");
			}
		}

		internal static void HookConfig<T>(this ConfigEntry<T> configEntry, Func<bool> enabled, Type typeFrom, string methodFrom, Delegate onHook)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			try
			{
				configEntry.AddHookConfig<T>(enabled, (IDetour)new Hook((MethodBase)typeFrom.GetMethod(methodFrom, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), onHook, ref onHookConfig));
			}
			catch (Exception ex)
			{
				log.error($"Failed to onHook {typeFrom}.{methodFrom} - {onHook.Method.Name}\n{ex}");
			}
		}

		internal static void HookConfig<T>(this ConfigEntry<T> configEntry, Func<bool> enabled, MethodBase methodFrom, Delegate onHook)
		{
			//IL_0009: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Expected O, but got Unknown
			try
			{
				configEntry.AddHookConfig<T>(enabled, (IDetour)new Hook(methodFrom, onHook, ref onHookConfig));
			}
			catch (Exception ex)
			{
				log.error($"Failed to onHook {methodFrom.DeclaringType}.{methodFrom.Name} - {onHook.Method.Name}\n{ex}");
			}
		}

		internal static void HookConfig(this ConfigEntry<bool> configEntry, Type typeFrom, string methodFrom, Manipulator ilHook)
		{
			configEntry.HookConfig<bool>(() => configEntry.Value, typeFrom, methodFrom, ilHook);
		}

		internal static void HookConfig(this ConfigEntry<bool> configEntry, MethodBase methodFrom, Manipulator ilHook)
		{
			configEntry.HookConfig<bool>(() => configEntry.Value, methodFrom, ilHook);
		}

		internal static void HookConfig(this ConfigEntry<bool> configEntry, Type typeFrom, string methodFrom, Delegate onHook)
		{
			configEntry.HookConfig<bool>(() => configEntry.Value, typeFrom, methodFrom, onHook);
		}

		internal static void HookConfig(this ConfigEntry<bool> configEntry, MethodBase methodFrom, Delegate onHook)
		{
			configEntry.HookConfig<bool>(() => configEntry.Value, methodFrom, onHook);
		}

		private static void AddHookConfig<T>(this ConfigEntry<T> configEntry, Func<bool> enabled, IDetour detour)
		{
			hooks.Add(detour);
			configEntry.SettingChanged += delegate
			{
				UpdateHook(detour, enabled());
			};
			if (enabled())
			{
				detour.Apply();
			}
		}

		private static void UpdateHook(IDetour hook, bool enabled)
		{
			if (enabled)
			{
				if (!hook.IsApplied)
				{
					hook.Apply();
				}
			}
			else if (hook.IsApplied)
			{
				hook.Undo();
			}
		}

		internal static void PriorityFirst()
		{
			ilHookConfig.Before = new string[1] { "*" };
			onHookConfig.Before = new string[1] { "*" };
		}

		internal static void PriorityLast()
		{
			ilHookConfig.After = new string[1] { "*" };
			onHookConfig.After = new string[1] { "*" };
		}

		internal static void PriorityNormal()
		{
			ilHookConfig.Before = null;
			onHookConfig.Before = null;
			ilHookConfig.After = null;
			onHookConfig.After = null;
		}

		internal static IDetour ManualDetour(Type typeFrom, string methodFrom, Delegate onHook)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			try
			{
				return (IDetour)new Hook((MethodBase)typeFrom.GetMethod(methodFrom, BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic), onHook, ref onHookConfig);
			}
			catch (Exception ex)
			{
				log.error($"Failed to make onHook {typeFrom}.{methodFrom} - {onHook.Method.Name}\n{ex}");
			}
			return null;
		}
	}
	internal static class Utilities
	{
		private static GameObject _prefabParent;

		internal static GameObject CreatePrefab(GameObject gameObject)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)_prefabParent))
			{
				_prefabParent = new GameObject("DolsoPrefabs");
				Object.DontDestroyOnLoad((Object)(object)_prefabParent);
				((Object)_prefabParent).hideFlags = (HideFlags)61;
				_prefabParent.SetActive(false);
			}
			return Object.Instantiate<GameObject>(gameObject, _prefabParent.transform);
		}

		internal static GameObject CreatePrefab(GameObject gameObject, string name)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)_prefabParent))
			{
				_prefabParent = new GameObject("DolsoPrefabs");
				Object.DontDestroyOnLoad((Object)(object)_prefabParent);
				((Object)_prefabParent).hideFlags = (HideFlags)61;
				_prefabParent.SetActive(false);
			}
			return Object.Instantiate<GameObject>(gameObject, _prefabParent.transform);
		}

		internal static MethodInfo GetGenericMethod<T>(this Type type, string methodName, params Type[] parameters)
		{
			return type.GetMethod(methodName, parameters).MakeGenericMethod(typeof(T));
		}

		internal static AssetBundle LoadAssetBundle(string bundlePathName)
		{
			AssetBundle result = null;
			try
			{
				result = AssetBundle.LoadFromFile(Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), bundlePathName));
			}
			catch (Exception ex)
			{
				log.error("Failed to load assetbundle\n" + ex);
			}
			return result;
		}

		internal static Obj GetAddressable<Obj>(string addressable) where Obj : Object
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return Addressables.LoadAssetAsync<Obj>((object)addressable).WaitForCompletion();
		}

		internal static GameObject GetAddressable(string addressable)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return Addressables.LoadAssetAsync<GameObject>((object)addressable).WaitForCompletion();
		}

		internal static void GetAddressable<Obj>(string addressable, Action<AsyncOperationHandle<Obj>> callback) where Obj : Object
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			AsyncOperationHandle<Obj> val = Addressables.LoadAssetAsync<Obj>((object)addressable);
			val.Completed += callback;
		}

		internal static void GetAddressable(string addressable, Action<AsyncOperationHandle<GameObject>> callback)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)addressable);
			val.Completed += callback;
		}

		internal static void AddressableAddComp<Comp>(string addressable) where Comp : Component
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)addressable);
			val.Completed += delegate(AsyncOperationHandle<GameObject> a)
			{
				a.Result.AddComponent<Comp>();
			};
		}

		internal static void AddressableAddCompSingle<Comp>(string addressable) where Comp : Component
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			AsyncOperationHandle<GameObject> val = Addressables.LoadAssetAsync<GameObject>((object)addressable);
			val.Completed += delegate(AsyncOperationHandle<GameObject> a)
			{
				if (!Object.op_Implicit((Object)(object)a.Result.GetComponent<Comp>()))
				{
					a.Result.AddComponent<Comp>();
				}
			};
		}

		internal static void SetStateConfigIndex(this EntityStateConfiguration stateConfig, string fieldName, string newValue)
		{
			ref SerializedField[] serializedFields = ref stateConfig.serializedFieldsCollection.serializedFields;
			for (int i = 0; i < serializedFields.Length; i++)
			{
				if (serializedFields[i].fieldName == fieldName)
				{
					serializedFields[i].fieldValue.stringValue = newValue;
					return;
				}
			}
			log.error("failed to find " + fieldName + " for " + ((Object)stateConfig).name);
		}

		internal static void SetStateConfigIndex(this EntityStateConfiguration stateConfig, string fieldName, Object newValue)
		{
			ref SerializedField[] serializedFields = ref stateConfig.serializedFieldsCollection.serializedFields;
			for (int i = 0; i < serializedFields.Length; i++)
			{
				if (serializedFields[i].fieldName == fieldName)
				{
					serializedFields[i].fieldValue.objectValue = newValue;
					return;
				}
			}
			log.error("failed to find " + fieldName + " for " + ((Object)stateConfig).name);
		}
	}
}
namespace Dolso.RiskofOptions
{
	internal static class RiskofOptions
	{
		internal const string rooGuid = "com.rune580.riskofoptions";

		internal static bool enabled => Chainloader.PluginInfos.ContainsKey("com.rune580.riskofoptions");

		internal static void SetSprite(Sprite sprite)
		{
			ModSettingsManager.SetModIcon(sprite);
		}

		internal static void SetSpriteDefaultIcon()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			//IL_007d: 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)
			DirectoryInfo directoryInfo = new DirectoryInfo(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location));
			string path = ((!(directoryInfo.Name == "plugins")) ? directoryInfo.FullName : directoryInfo.Parent.FullName);
			Texture2D val = new Texture2D(256, 256);
			if (ImageConversion.LoadImage(val, File.ReadAllBytes(Path.Combine(path, "icon.png"))))
			{
				ModSettingsManager.SetModIcon(Sprite.Create(val, new Rect(0f, 0f, (float)((Texture)val).width, (float)((Texture)val).height), new Vector2(0.5f, 0.5f)));
			}
			else
			{
				log.error("Failed to load icon.png");
			}
		}

		internal static void AddBool(ConfigEntry<bool> entry)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry, new CheckBoxConfig
			{
				description = ((ConfigEntryBase)(object)entry).DescWithDefault()
			}));
		}

		internal static void AddBool(ConfigEntry<bool> entry, string categoryName, string name)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(entry, new CheckBoxConfig
			{
				category = categoryName,
				name = name,
				description = ((ConfigEntryBase)(object)entry).DescWithDefault()
			}));
		}

		internal static void AddEnum<T>(ConfigEntry<T> entry) where T : Enum
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)entry, new ChoiceConfig
			{
				description = ((ConfigEntryBase)(object)entry).DescWithDefault()
			}));
		}

		internal static void AddColor(ConfigEntry<Color> entry)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new ColorOption(entry, new ColorOptionConfig
			{
				description = ((ConfigEntryBase)(object)entry).DescWithDefault()
			}));
		}

		internal static void AddKey(ConfigEntry<KeyboardShortcut> entry)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new KeyBindOption(entry, new KeyBindConfig
			{
				description = ((ConfigEntryBase)(object)entry).DescWithDefault()
			}));
		}

		internal static void AddFloat(ConfigEntry<float> entry, float min, float max, string format = "{0:f2}")
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Expected O, but got Unknown
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new SliderOption(entry, new SliderConfig
			{
				min = min,
				max = max,
				formatString = format,
				description = ((ConfigEntryBase)(object)entry).DescWithDefault(format)
			}));
		}

		internal static void AddFloat(ConfigEntry<float> entry, string categoryName, float min, float max, string format = "{0:f2}")
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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
			ModSettingsManager.AddOption((BaseOption)new SliderOption(entry, new SliderConfig
			{
				min = min,
				max = max,
				formatString = format,
				category = categoryName,
				description = ((ConfigEntryBase)(object)entry).DescWithDefault(format)
			}));
		}

		internal static void AddFloatField(ConfigEntry<float> entry, float min = float.MinValue, float max = float.MaxValue, string format = "{0:f2}")
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Expected O, but got Unknown
			FloatFieldConfig val = new FloatFieldConfig();
			((NumericFieldConfig<float>)val).Min = min;
			((NumericFieldConfig<float>)val).Max = max;
			((BaseOptionConfig)val).description = ((ConfigEntryBase)(object)entry).DescWithDefault(format);
			ModSettingsManager.AddOption((BaseOption)new FloatFieldOption(entry, val));
		}

		internal static void AddInt(ConfigEntry<int> entry, int min = int.MinValue, int max = int.MaxValue)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			IntFieldConfig val = new IntFieldConfig();
			((NumericFieldConfig<int>)val).Min = min;
			((NumericFieldConfig<int>)val).Max = max;
			((BaseOptionConfig)val).description = ((ConfigEntryBase)(object)entry).DescWithDefault();
			ModSettingsManager.AddOption((BaseOption)new IntFieldOption(entry, val));
		}

		internal static void AddIntSlider(ConfigEntry<int> entry, int min, int max)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(entry, new IntSliderConfig
			{
				min = min,
				max = max,
				description = ((ConfigEntryBase)(object)entry).DescWithDefault()
			}));
		}

		internal static void AddIntSlider(ConfigEntry<int> entry, string categoryName, int min, int max)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new IntSliderOption(entry, new IntSliderConfig
			{
				min = min,
				max = max,
				category = categoryName,
				description = ((ConfigEntryBase)(object)entry).DescWithDefault()
			}));
		}

		internal static void AddString(ConfigEntry<string> entry)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: 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_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Expected O, but got Unknown
			ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(entry, new InputFieldConfig
			{
				submitOn = (SubmitEnum)6,
				lineType = (LineType)0,
				description = ((ConfigEntryBase)(object)entry).DescWithDefault()
			}));
		}

		internal static void AddOption(ConfigEntry<bool> entry)
		{
			AddBool(entry);
		}

		internal static void AddOption(ConfigEntry<bool> entry, string categoryName, string name)
		{
			AddBool(entry, categoryName, name);
		}

		internal static void AddOption<T>(ConfigEntry<T> entry) where T : Enum
		{
			AddEnum<T>(entry);
		}

		internal static void AddOption(ConfigEntry<Color> entry)
		{
			AddColor(entry);
		}

		internal static void AddOption(ConfigEntry<KeyboardShortcut> entry)
		{
			AddKey(entry);
		}

		internal static void AddOption(ConfigEntry<int> entry)
		{
			AddInt(entry);
		}

		internal static void AddOption(ConfigEntry<string> entry)
		{
			AddString(entry);
		}

		private static string DescWithDefault(this ConfigEntryBase entry)
		{
			return $"{entry.Description.Description}\n[Default: {entry.DefaultValue}]";
		}

		private static string DescWithDefault(this ConfigEntryBase entry, string format)
		{
			return string.Format("{1}\n[Default: " + format + "]", entry.DefaultValue, entry.Description.Description);
		}
	}
}
namespace PillarRevive
{
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInPlugin("dolso.pillarrevive", "PillarRevive", "1.1.1")]
	public class Main : BaseUnityPlugin
	{
		private void Awake()
		{
			log.start(((BaseUnityPlugin)this).Logger);
			PRConfig.DoConfig(((BaseUnityPlugin)this).Config);
			Prefab.CreatePillarPrefabs();
			TeleporterInteraction.onTeleporterChargedGlobal += OnTeleporterChargedGlobal_RevivePlayers;
			HookManager.Hook(typeof(GlobalEventManager), "OnPlayerCharacterDeath", (Delegate)new Action<Action<GlobalEventManager, DamageReport, NetworkUser>, GlobalEventManager, DamageReport, NetworkUser>(On_GlobalEventManager_OnPlayerDeath));
		}

		private void On_GlobalEventManager_OnPlayerDeath(Action<GlobalEventManager, DamageReport, NetworkUser> orig, GlobalEventManager self, DamageReport damagereport, NetworkUser networkuser)
		{
			orig(self, damagereport, networkuser);
			if (PRConfig.enabled.Value)
			{
				((MonoBehaviour)this).StartCoroutine(TrySpawnPillar(damagereport, networkuser));
			}
		}

		private void OnTeleporterChargedGlobal_RevivePlayers(TeleporterInteraction obj)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			if (!PRConfig.onTeleRespawn.Value || !NetworkServer.active)
			{
				return;
			}
			foreach (PlayerCharacterMasterController instance in PlayerCharacterMasterController.instances)
			{
				if (instance.isConnected && instance.master.IsDeadAndOutOfLivesServer())
				{
					CharacterBody val = instance.master.Respawn(instance.master.deathFootPosition, default(Quaternion), false);
					for (int i = 0; i < PRConfig.curseStacks.Value; i++)
					{
						val.AddBuff(Buffs.PermanentCurse);
					}
				}
			}
		}

		private IEnumerator TrySpawnPillar(DamageReport damagereport, NetworkUser networkuser)
		{
			yield return (object)new WaitForSeconds(1.5f);
			if (!Object.op_Implicit((Object)(object)networkuser) || !Object.op_Implicit((Object)(object)networkuser.master) || !networkuser.master.IsDeadAndOutOfLivesServer() || Run.instance.isGameOverServer)
			{
				yield break;
			}
			GameObject val = SpawnPillar(damagereport.victimMaster);
			PlayerRevive component = val.GetComponent<PlayerRevive>();
			component.SetNetworkUser(networkuser);
			if (Object.op_Implicit((Object)(object)TeleporterInteraction.instance))
			{
				if (Run.instance.stageClearCount == 0 && TeleporterInteraction.instance.currentState is IdleState)
				{
					HoldoutZoneController component2 = val.GetComponent<HoldoutZoneController>();
					component2.baseChargeDuration *= PRConfig.earlyGameDivider.Value;
					CombatDirector component3 = val.GetComponent<CombatDirector>();
					component3.monsterCredit *= PRConfig.earlyGameDivider.Value;
					log.info("Applied early game boost");
				}
				else if (TeleporterInteraction.instance.currentState is ChargedState)
				{
					HoldoutZoneController component4 = val.GetComponent<HoldoutZoneController>();
					component4.baseChargeDuration *= PRConfig.postTeleDivider.Value;
					CombatDirector component5 = val.GetComponent<CombatDirector>();
					component5.monsterCredit *= PRConfig.postTeleDivider.Value;
					component.setTeleFinished = true;
					log.info("Applied post teleporter boost");
				}
			}
		}

		private GameObject SpawnPillar(CharacterMaster master)
		{
			//IL_0001: 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_0026: 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_004e: 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_0057: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = (Vector3)(((??)TeleportHelper.FindSafeTeleportDestination(master.deathFootPosition, master.bodyPrefab.GetComponent<CharacterBody>(), RoR2Application.rng)) ?? master.deathFootPosition);
			GameObject obj = Object.Instantiate<GameObject>(Prefab.pillarSelection.Evaluate(Run.instance.stageRng.nextNormalizedFloat), val, default(Quaternion));
			NetworkServer.Spawn(obj);
			return obj;
		}
	}
	internal class PlayerRevive : MonoBehaviour
	{
		private static readonly List<PlayerRevive> instances = new List<PlayerRevive>();

		public Pillar pillarIndex;

		private NetworkUser networkUser;

		private bool didRespawn;

		public bool setTeleFinished;

		public void SetNetworkUser(NetworkUser networkUser)
		{
			this.networkUser = networkUser;
			PurchaseInteraction component = ((Component)this).GetComponent<PurchaseInteraction>();
			component.NetworkdisplayNameToken = $"{networkUser.userName}'s {Prefab.pillarNames[(int)pillarIndex]}";
			component.NetworkcontextToken = "Reform " + networkUser.userName;
			if (PRConfig.autoPing.Value)
			{
				((MonoBehaviour)this).Invoke("PingPillar", 3f);
			}
		}

		private void OnEnable()
		{
			if (NetworkServer.active)
			{
				((UnityEvent<HoldoutZoneController>)(object)((Component)this).GetComponent<HoldoutZoneController>().onCharged).AddListener((UnityAction<HoldoutZoneController>)OnCharged);
				instances.Add(this);
			}
		}

		private void OnDisable()
		{
			if (NetworkServer.active)
			{
				instances.Remove(this);
			}
		}

		private void OnCharged(HoldoutZoneController holdout)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Expected O, but got Unknown
			//IL_0041: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			if (!Object.op_Implicit((Object)(object)networkUser) || !Object.op_Implicit((Object)(object)networkUser.master))
			{
				Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
				{
					baseToken = "<color=red>Player not found</color>"
				});
				return;
			}
			CharacterMaster master = networkUser.master;
			CharacterBody val = master.Respawn(master.deathFootPosition, default(Quaternion), false);
			for (int i = 0; i < PRConfig.curseStacks.Value; i++)
			{
				val.AddBuff(Buffs.PermanentCurse);
			}
			didRespawn = true;
			Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
			{
				baseToken = "<style=cLunarObjective>Reformed " + networkUser.userName + "</style>"
			});
			((MonoBehaviour)this).Invoke("DestroySelf", 60f);
		}

		private void FixedUpdate()
		{
			if (!NetworkServer.active)
			{
				return;
			}
			bool flag = !Object.op_Implicit((Object)(object)networkUser) || !Object.op_Implicit((Object)(object)networkUser.master);
			if (!flag)
			{
				if (!didRespawn)
				{
					CharacterBody currentBody = networkUser.GetCurrentBody();
					if (currentBody != null && currentBody.healthComponent.alive)
					{
						goto IL_0055;
					}
				}
				if (!setTeleFinished && Object.op_Implicit((Object)(object)TeleporterInteraction.instance) && TeleporterInteraction.instance.currentState is ChargedState)
				{
					HoldoutZoneController component = ((Component)this).GetComponent<HoldoutZoneController>();
					component.baseChargeDuration *= PRConfig.postTeleDivider.Value;
					CombatDirector component2 = ((Component)this).GetComponent<CombatDirector>();
					component2.monsterCredit *= PRConfig.postTeleDivider.Value;
					setTeleFinished = true;
					log.info("Applied post teleporter boost");
				}
				return;
			}
			goto IL_0055;
			IL_0055:
			if (flag)
			{
				log.info("Pillar detected player missing, removing self");
			}
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

		private void PingPillar()
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Unknown result type (might be due to invalid IL or missing references)
			PingInfo val = default(PingInfo);
			val.active = true;
			val.origin = ((Component)this).transform.position;
			val.normal = Vector3.zero;
			val.targetNetworkIdentity = ((Component)this).GetComponent<NetworkIdentity>();
			PingInfo currentPing = val;
			LocalUserManager.GetFirstLocalUser().cachedMasterObject.GetComponent<PingerController>().SetCurrentPing(currentPing);
		}

		private void DestroySelf()
		{
			Object.Destroy((Object)(object)((Component)this).gameObject);
		}

		internal static void DestroyAll()
		{
			for (int num = instances.Count - 1; num >= 0; num--)
			{
				instances[num].DestroySelf();
			}
		}
	}
	internal static class PRConfig
	{
		internal class PillarConfig
		{
			public ConfigEntry<float> weight;

			public ConfigEntry<float> chargeDuration;

			public ConfigEntry<float> monsterCredits;

			private int index;

			public PillarConfig(int index)
			{
				//IL_004a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0054: Expected O, but got Unknown
				this.index = index;
				string text = Prefab.pillarNames[index];
				weight = configFile.Bind<float>(text, "Weight", 1f, new ConfigDescription("Spawn weighting of " + text + " Pillar", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 10f), Array.Empty<object>()));
				chargeDuration = configFile.Bind<float>(text, "Charge duration", (float)((Pillar)index switch
				{
					Pillar.Blood => 10, 
					Pillar.Mass => 60, 
					_ => 30, 
				}), "Charge duration of " + text + " Pillar");
				monsterCredits = configFile.Bind<float>(text, "Monster Credits", (float)((index != 3) ? 700 : 0), "How many monsters to spawn on pillar activation");
				weight.SettingChanged += delegate
				{
					Prefab.pillarSelection.ModifyChoiceWeight(this.index, weight.Value);
				};
				chargeDuration.SettingChanged += delegate
				{
					Prefab.pillarSelection.choices[this.index].value.GetComponent<HoldoutZoneController>().baseChargeDuration = chargeDuration.Value;
				};
				monsterCredits.SettingChanged += delegate
				{
					Prefab.pillarSelection.choices[this.index].value.GetComponent<CombatDirector>().monsterCredit = monsterCredits.Value;
				};
			}
		}

		public static ConfigFile configFile;

		public static ConfigEntry<bool> enabled;

		public static ConfigEntry<int> curseStacks;

		public static ConfigEntry<bool> healingNova;

		public static ConfigEntry<float> earlyGameDivider;

		public static ConfigEntry<float> postTeleDivider;

		public static ConfigEntry<bool> autoPing;

		public static ConfigEntry<bool> onTeleRespawn;

		public static PillarConfig[] pillars;

		public static void DoConfig(ConfigFile bepConfigFile)
		{
			configFile = bepConfigFile;
			enabled = configFile.Bind<bool>("_Main", "Enable Mod", true, "Enables mod. Toggle in-game with pillarrevivetoggle command");
			onTeleRespawn = configFile.Bind<bool>("_Main", "On Teleporter Completion Revive", false, "If should automatically revive dead players on teleporter completion");
			curseStacks = configFile.Bind<int>("_Main", "Curse Stacks", 25, "Give n stacks of curse to the revived player, set to 0 to disable");
			earlyGameDivider = configFile.Bind<float>("_Main", "Early game pillar difficulty", 0.3f, "On stage 1 and teleporter has not been hit, multiply monster credits and charge duration by this number");
			postTeleDivider = configFile.Bind<float>("_Main", "Tele finished pillar difficulty", 0.1f, "After teleporter has been fully completed, spawn this many less monsters and charge pillar faster");
			autoPing = configFile.Bind<bool>("_Main", "Auto ping pillars", true, "Have host automatically ping pillars when they spawn. This is so that they can be highlighted for everyone");
			healingNova = configFile.Bind<bool>("_Main", "Use Lepton Daisy", true, "If revive pillars should use Lepton Daisies");
			pillars = new PillarConfig[Prefab.pillarNames.Length];
			for (int i = 0; i < pillars.Length; i++)
			{
				pillars[i] = new PillarConfig(i);
			}
			if (RiskofOptions.enabled)
			{
				DoRiskOfOptions();
			}
			enabled.SettingChanged += delegate
			{
				if (!enabled.Value)
				{
					PlayerRevive.DestroyAll();
				}
			};
			healingNova.SettingChanged += delegate
			{
				//IL_0011: Unknown result type (might be due to invalid IL or missing references)
				ChoiceInfo<GameObject>[] choices = Prefab.pillarSelection.choices;
				for (int j = 0; j < choices.Length; j++)
				{
					choices[j].value.GetComponent<HoldoutZoneController>().applyHealingNova = healingNova.Value;
				}
			};
		}

		private static void DoRiskOfOptions()
		{
			RiskofOptions.SetSpriteDefaultIcon();
			RiskofOptions.AddOption(enabled);
			RiskofOptions.AddOption(onTeleRespawn);
			RiskofOptions.AddIntSlider(curseStacks, 0, 100);
			RiskofOptions.AddFloat(earlyGameDivider, 0f, 1f);
			RiskofOptions.AddFloat(postTeleDivider, 0f, 1f);
			RiskofOptions.AddOption(autoPing);
			RiskofOptions.AddOption(healingNova);
			for (int i = 0; i < pillars.Length; i++)
			{
				RiskofOptions.AddFloatField(pillars[i].monsterCredits, 0f);
				RiskofOptions.AddFloat(pillars[i].chargeDuration, 0f, 120f, "{0:0.0}");
				RiskofOptions.AddFloat(pillars[i].weight, 0f, 10f, "{0:0.0}");
			}
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void PRPillarConfigReload(ConCommandArgs args)
		{
			configFile.Reload();
			Debug.Log((object)"Reloaded PillarRevive's config");
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void PRPillarToggle(ConCommandArgs args)
		{
			if (enabled.Value)
			{
				Debug.Log((object)"Disabled new pillars from spawning");
			}
			else
			{
				Debug.Log((object)"Enabled PillarRevive");
			}
			enabled.Value = !enabled.Value;
		}
	}
	public static class Prefab
	{
		public static readonly string[] pillarNames = new string[4] { "Blood", "Design", "Mass", "Soul" };

		public static WeightedSelection<GameObject> pillarSelection;

		public static void CreatePillarPrefabs()
		{
			//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)
			if (pillarSelection == null)
			{
				pillarSelection = new WeightedSelection<GameObject>(8);
				for (int i = 0; i < pillarNames.Length; i++)
				{
					string text = pillarNames[i];
					GameObject val = Utilities.CreatePrefab(Addressables.LoadAssetAsync<GameObject>((object)("RoR2/Base/moon2/MoonBattery" + text + ".prefab")).WaitForCompletion());
					((Object)val).name = text + "Pillar";
					val.AddComponent<PlayerRevive>().pillarIndex = (Pillar)i;
					pillarSelection.AddChoice(val, 1f);
				}
			}
			for (int j = 0; j < pillarSelection.Count; j++)
			{
				pillarSelection.ModifyChoiceWeight(j, PRConfig.pillars[j].weight.Value);
				GameObject value = pillarSelection.choices[j].value;
				HoldoutZoneController component = value.GetComponent<HoldoutZoneController>();
				component.applyHealingNova = PRConfig.healingNova.Value;
				component.baseChargeDuration = PRConfig.pillars[j].chargeDuration.Value;
				CombatDirector component2 = value.GetComponent<CombatDirector>();
				component2.expRewardCoefficient = 0f;
				component2.goldRewardCoefficient = 0f;
				component2.monsterCredit = PRConfig.pillars[j].monsterCredits.Value;
			}
		}
	}
	internal enum Pillar
	{
		Blood,
		Desgin,
		Mass,
		Soul
	}
}