Decompiled source of ServerSider v1.6.1

plugins/ServerSider/ServerSider.dll

Decompiled 3 months 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;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HG;
using HG.Reflection;
using IL.RoR2;
using Microsoft.CodeAnalysis;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using MonoMod.RuntimeDetour;
using On.RoR2;
using On.RoR2.UI;
using RoR2;
using RoR2.Navigation;
using RoR2.UI;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.Events;
using UnityEngine.Networking;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: OptIn]
[assembly: TargetFramework(".NETStandard,Version=v2.0", FrameworkDisplayName = ".NET Standard 2.0")]
[assembly: AssemblyCompany("ServerSider")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.6.1.0")]
[assembly: AssemblyInformationalVersion("1.6.1+a5b04e4cb0aceb23c6683bdd87ec38d3980028ec")]
[assembly: AssemblyProduct("ServerSider")]
[assembly: AssemblyTitle("ServerSider")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.6.1.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace ServerSider
{
	[BepInPlugin("itsschwer.ServerSider", "ServerSider", "1.6.1")]
	public sealed class Plugin : BaseUnityPlugin
	{
		public const string GUID = "itsschwer.ServerSider";

		public const string Author = "itsschwer";

		public const string Name = "ServerSider";

		public const string Version = "1.6.1";

		private static Plugin Instance;

		internal static ManualLogSource Logger { get; private set; }

		public static TweakManager Tweaks { get; private set; }

		internal static bool Enabled
		{
			get
			{
				if (Object.op_Implicit((Object)(object)Instance))
				{
					return ((Behaviour)Instance).enabled;
				}
				return false;
			}
		}

		private void Awake()
		{
			Logger.Sources.Remove((ILogSource)(object)((BaseUnityPlugin)this).Logger);
			Logger = Logger.CreateLogSource("itsschwer.ServerSider");
			Tweaks = new TweakManager(((BaseUnityPlugin)this).Config);
			Instance = this;
			Run.onRunStartGlobal += SetPluginActiveState;
			Run.onRunDestroyGlobal += Disable;
			SetPluginActiveState();
			Logger.LogMessage((object)"~awake.");
		}

		private void OnEnable()
		{
			Logger.LogMessage((object)("Reloading " + ((BaseUnityPlugin)this).Config.ConfigFilePath.Substring(((BaseUnityPlugin)this).Config.ConfigFilePath.LastIndexOf(Path.DirectorySeparatorChar) + 1)));
			((BaseUnityPlugin)this).Config.Reload();
			Tweaks.Refresh();
			Logger.LogMessage((object)"~enabled.");
		}

		private void OnDisable()
		{
			Tweaks.Refresh();
			Logger.LogMessage((object)"~disabled.");
		}

		private void SetPluginActiveState(Run _ = null)
		{
			SetActive(NetworkServer.active);
		}

		private void SetActive(bool value)
		{
			((Behaviour)this).enabled = value;
			Logger.LogMessage((object)("~" + (value ? "active" : "inactive") + "."));
		}

		private void Disable(Run _)
		{
			SetActive(value: false);
		}
	}
	public class TweakManager
	{
		public readonly List<TweakBase> managedTweaks;

		public readonly RescueShipLoopPortal RescueShipLoopPortal;

		public readonly PressurePlateTweak PressurePlateTweak;

		public readonly QuitToLobbyButton QuitToLobbyButton;

		public readonly VoidPickupConfirmAll VoidPickupConfirmAll;

		public readonly VoidFieldFogTweak VoidFieldFogTweak;

		public readonly SendItemCostInChat SendItemCostInChat;

		public readonly ChanceDollMessage ChanceDollMessage;

		public readonly TeleportOutOfBoundsPickups TeleportOutOfBoundsPickups;

		public readonly PreventEarlyHalcyonShrineActivation PreventEarlyHalcyonShrineActivation;

		internal TweakManager(ConfigFile config)
		{
			managedTweaks = new List<TweakBase>();
			RescueShipLoopPortal = new RescueShipLoopPortal(config);
			managedTweaks.Add(RescueShipLoopPortal);
			PressurePlateTweak = new PressurePlateTweak(config);
			managedTweaks.Add(PressurePlateTweak);
			QuitToLobbyButton = new QuitToLobbyButton(config);
			managedTweaks.Add(QuitToLobbyButton);
			VoidPickupConfirmAll = new VoidPickupConfirmAll(config);
			managedTweaks.Add(VoidPickupConfirmAll);
			VoidFieldFogTweak = new VoidFieldFogTweak(config);
			managedTweaks.Add(VoidFieldFogTweak);
			SendItemCostInChat = new SendItemCostInChat(config);
			managedTweaks.Add(SendItemCostInChat);
			ChanceDollMessage = new ChanceDollMessage(config);
			managedTweaks.Add(ChanceDollMessage);
			TeleportOutOfBoundsPickups = new TeleportOutOfBoundsPickups(config);
			managedTweaks.Add(TeleportOutOfBoundsPickups);
			PreventEarlyHalcyonShrineActivation = new PreventEarlyHalcyonShrineActivation(config);
			managedTweaks.Add(PreventEarlyHalcyonShrineActivation);
		}

		internal void Refresh()
		{
			for (int i = 0; i < managedTweaks.Count; i++)
			{
				managedTweaks[i].Disable();
				if (managedTweaks[i].allowed)
				{
					managedTweaks[i].Enable();
				}
			}
		}
	}
	public class ChanceDollMessage : TweakBase
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static Manipulator <0>__ShrineChanceBehavior_AddShrineStack;
		}

		private readonly ConfigEntry<bool> chanceDollMessage;

		private static readonly FieldInfo chanceDollWin = typeof(ShrineChanceBehavior).GetField("chanceDollWin", BindingFlags.Instance | BindingFlags.NonPublic);

		public override bool allowed
		{
			get
			{
				if (Plugin.Enabled)
				{
					return chanceDollMessage.Value;
				}
				return false;
			}
		}

		internal ChanceDollMessage(ConfigFile config)
		{
			chanceDollMessage = config.Bind<bool>("Tweaks", "chanceDollMessage", false, "Reword the Shrine of Chance success message to indicate if a Chance Doll affected the reward.\n\nThis tweak is redundant after RoR2v1.3.6 [Seekers of the Storm Roadmap Phase 1 — Items & Elites], as this is now implemented in vanilla.");
		}

		protected override void Hook()
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Expected O, but got Unknown
			if (chanceDollWin == null)
			{
				Plugin.Logger.LogWarning((object)"ChanceDollMessage> Cannot hook: no chanceDollWin field.");
				return;
			}
			object obj = <>O.<0>__ShrineChanceBehavior_AddShrineStack;
			if (obj == null)
			{
				Manipulator val = ShrineChanceBehavior_AddShrineStack;
				<>O.<0>__ShrineChanceBehavior_AddShrineStack = val;
				obj = (object)val;
			}
			ShrineChanceBehavior.AddShrineStack += (Manipulator)obj;
			Plugin.Logger.LogDebug((object)("ChanceDollMessage> Hooked by " + TweakBase.GetExecutingMethod()));
		}

		protected override void Unhook()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__ShrineChanceBehavior_AddShrineStack;
			if (obj == null)
			{
				Manipulator val = ShrineChanceBehavior_AddShrineStack;
				<>O.<0>__ShrineChanceBehavior_AddShrineStack = val;
				obj = (object)val;
			}
			ShrineChanceBehavior.AddShrineStack -= (Manipulator)obj;
			Plugin.Logger.LogDebug((object)("ChanceDollMessage> Unhooked by " + TweakBase.GetExecutingMethod()));
		}

		private static void ShrineChanceBehavior_AddShrineStack(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			Func<Instruction, bool>[] array = new Func<Instruction, bool>[8]
			{
				(Instruction x) => ILPatternMatchingExt.MatchNewobj<SubjectFormatChatMessage>(x),
				(Instruction x) => ILPatternMatchingExt.MatchDup(x),
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 1),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<SubjectChatMessage>(x, "set_subjectAsCharacterBody"),
				(Instruction x) => ILPatternMatchingExt.MatchDup(x),
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 4),
				(Instruction x) => ILPatternMatchingExt.MatchStfld<SubjectChatMessage>(x, "baseToken"),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(Chat), "SendBroadcastChat")
			};
			if (val.TryGotoNext(array))
			{
				ILLabel val2 = val.MarkLabel();
				val.Emit(OpCodes.Ldarg_0);
				val.Emit<ShrineChanceBehavior>(OpCodes.Ldfld, "chanceDollWin");
				val.Emit(OpCodes.Brfalse_S, (object)val2);
				val.Emit(OpCodes.Ldloc_1);
				val.Emit(OpCodes.Ldloc, 4);
				val.EmitDelegate<Action<CharacterBody, string>>((Action<CharacterBody, string>)delegate(CharacterBody activator, string baseToken)
				{
					//IL_0016: Unknown result type (might be due to invalid IL or missing references)
					//IL_001b: Unknown result type (might be due to invalid IL or missing references)
					//IL_0049: Expected O, but got Unknown
					string stringFormatted = Language.GetStringFormatted(baseToken, new object[1] { activator.GetUserName() });
					Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
					{
						baseToken = stringFormatted.Replace("!", (Language.currentLanguage == Language.english) ? " greatly!" : "!+")
					});
				});
				ILLabel val3 = val.MarkLabel();
				val.Emit(OpCodes.Br_S, (object)val3);
				val.MarkLabel(val2);
				val.GotoNext((MoveType)2, array);
				val.MarkLabel(val3);
			}
			else
			{
				Plugin.Logger.LogError((object)"ChanceDollMessage> Cannot hook: failed to match IL instructions.");
			}
		}
	}
	public class PressurePlateTweak : TweakBase
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_SetSwitch <0>__PressurePlateController_SetSwitch;
		}

		private static ConfigEntry<float> pressurePlateGracePeriod;

		private static readonly Dictionary<PressurePlateController, float> platePressTimestamps = new Dictionary<PressurePlateController, float>(2);

		public override bool allowed
		{
			get
			{
				if (Plugin.Enabled)
				{
					return pressurePlateGracePeriod.Value != 0f;
				}
				return false;
			}
		}

		internal PressurePlateTweak(ConfigFile config)
		{
			pressurePlateGracePeriod = config.Bind<float>("Tweaks", "pressurePlateGracePeriod", 30f, "The length of time (in seconds) that a pressure plate will remain pressed after being activated.\nZero disables time functionality (reverts to vanilla behaviour). Negative values prevent pressure plates from releasing once activated.");
		}

		protected override void Hook()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__PressurePlateController_SetSwitch;
			if (obj == null)
			{
				hook_SetSwitch val = PressurePlateController_SetSwitch;
				<>O.<0>__PressurePlateController_SetSwitch = val;
				obj = (object)val;
			}
			PressurePlateController.SetSwitch += (hook_SetSwitch)obj;
			PressurePlateController.FixedUpdate += new hook_FixedUpdate(PressurePlateController_FixedUpdate);
			Plugin.Logger.LogDebug((object)("PressurePlateTweak> Hooked by " + TweakBase.GetExecutingMethod()));
		}

		protected override void Unhook()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__PressurePlateController_SetSwitch;
			if (obj == null)
			{
				hook_SetSwitch val = PressurePlateController_SetSwitch;
				<>O.<0>__PressurePlateController_SetSwitch = val;
				obj = (object)val;
			}
			PressurePlateController.SetSwitch -= (hook_SetSwitch)obj;
			PressurePlateController.FixedUpdate -= new hook_FixedUpdate(PressurePlateController_FixedUpdate);
			platePressTimestamps.Clear();
			Plugin.Logger.LogDebug((object)("PressurePlateTweak> Unhooked by " + TweakBase.GetExecutingMethod()));
		}

		private static void PressurePlateController_SetSwitch(orig_SetSwitch orig, PressurePlateController self, bool switchIsDown)
		{
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			//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_004a: Expected O, but got Unknown
			if (switchIsDown)
			{
				if (switchIsDown != self.switchDown)
				{
					string text = (((double)Random.value <= 0.2) ? "Press your plate!" : "A pressure plate is pressed..");
					Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
					{
						baseToken = "<style=cEvent>" + text + "</style>"
					});
				}
				orig.Invoke(self, switchIsDown);
				platePressTimestamps[self] = Time.time;
			}
			else if (pressurePlateGracePeriod.Value >= 0f && !platePressTimestamps.ContainsKey(self))
			{
				if (switchIsDown != self.switchDown)
				{
					Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
					{
						baseToken = "<style=cEvent>A pressure plate releases...</style>"
					});
				}
				orig.Invoke(self, switchIsDown);
			}
		}

		private void PressurePlateController_FixedUpdate(orig_FixedUpdate orig, PressurePlateController self)
		{
			orig.Invoke(self);
			if (self.enableOverlapSphere && platePressTimestamps.TryGetValue(self, out var value) && Time.time - value >= pressurePlateGracePeriod.Value)
			{
				platePressTimestamps.Remove(self);
			}
		}
	}
	public class PreventEarlyHalcyonShrineActivation : TweakBase
	{
		private readonly ConfigEntry<bool> preventEarlyHalcyonShrineActivation;

		private static readonly Type targetType;

		private static readonly MethodInfo targetMethod;

		private static readonly ILHook hook;

		public override bool allowed
		{
			get
			{
				if (Plugin.Enabled)
				{
					return preventEarlyHalcyonShrineActivation.Value;
				}
				return false;
			}
		}

		static PreventEarlyHalcyonShrineActivation()
		{
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: 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_007f: Expected O, but got Unknown
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Expected O, but got Unknown
			targetType = typeof(PurchaseInteraction).Assembly.GetType("RoR2.GoldSiphonNearbyBodyController");
			targetMethod = targetType?.GetMethod("DrainGold", BindingFlags.Instance | BindingFlags.NonPublic);
			if (targetMethod == null)
			{
				Plugin.Logger.LogWarning((object)"PreventEarlyHalcyonShrineActivation> Cannot hook: no RoR2.GoldSiphonNearbyBodyController.DrainGold method.");
				return;
			}
			hook = new ILHook((MethodBase)targetMethod, new Manipulator(GoldSiphonNearbyBodyController_DrainGold), new ILHookConfig
			{
				ManualApply = true
			});
		}

		internal PreventEarlyHalcyonShrineActivation(ConfigFile config)
		{
			preventEarlyHalcyonShrineActivation = config.Bind<bool>("Tweaks", "preventEarlyHalcyonShrineActivation", true, "Disable the \"Pray to Halcyon Shrine\" prompt to prevent activating the shrine before it is fully charged.");
		}

		protected override void Hook()
		{
			if (hook != null)
			{
				hook.Apply();
				Plugin.Logger.LogDebug((object)("PreventEarlyHalcyonShrineActivation> Hooked by " + TweakBase.GetExecutingMethod()));
			}
		}

		protected override void Unhook()
		{
			if (hook != null)
			{
				hook.Undo();
				Plugin.Logger.LogDebug((object)("PreventEarlyHalcyonShrineActivation> Unhooked by " + TweakBase.GetExecutingMethod()));
			}
		}

		private static void GoldSiphonNearbyBodyController_DrainGold(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			Func<Instruction, bool>[] array = new Func<Instruction, bool>[4]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld(x, targetType, "purchaseInteraction"),
				(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 1),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<PurchaseInteraction>(x, "SetAvailable")
			};
			if (val.TryGotoNext(array))
			{
				val.RemoveRange(array.Length);
			}
			else
			{
				Plugin.Logger.LogError((object)"PreventEarlyHalcyonShrineActivation> Cannot hook: failed to match IL instructions.");
			}
		}
	}
	public class QuitToLobbyButton : TweakBase
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Awake <0>__PauseScreenController_Awake;
		}

		private readonly ConfigEntry<bool> quitToLobbyButton;

		private const string commandName = "itsschwer_run_end";

		public override bool allowed
		{
			get
			{
				if (Plugin.Enabled)
				{
					return quitToLobbyButton.Value;
				}
				return false;
			}
		}

		internal QuitToLobbyButton(ConfigFile config)
		{
			quitToLobbyButton = config.Bind<bool>("Tweaks", "quitToLobbyButton", true, "Add a \"Quit to Lobby\" button to the Run pause menu.\n\nUseful in multiplayer for changing characters/survivors, difficulty, or artifacts without disconnecting everyone from the lobby.");
		}

		protected override void Hook()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__PauseScreenController_Awake;
			if (obj == null)
			{
				hook_Awake val = PauseScreenController_Awake;
				<>O.<0>__PauseScreenController_Awake = val;
				obj = (object)val;
			}
			PauseScreenController.Awake += (hook_Awake)obj;
			Plugin.Logger.LogDebug((object)("QuitToLobbyButton> Hooked by " + TweakBase.GetExecutingMethod()));
		}

		protected override void Unhook()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__PauseScreenController_Awake;
			if (obj == null)
			{
				hook_Awake val = PauseScreenController_Awake;
				<>O.<0>__PauseScreenController_Awake = val;
				obj = (object)val;
			}
			PauseScreenController.Awake -= (hook_Awake)obj;
			Plugin.Logger.LogDebug((object)("QuitToLobbyButton> Unhooked by " + TweakBase.GetExecutingMethod()));
		}

		private static void PauseScreenController_Awake(orig_Awake orig, PauseScreenController self)
		{
			orig.Invoke(self);
			if ((Object)(object)Run.instance != (Object)null)
			{
				PauseScreenController_Awake(self);
			}
		}

		private static void PauseScreenController_Awake(PauseScreenController __instance)
		{
			GameObject obj = Object.Instantiate<GameObject>(__instance.exitGameButton, __instance.exitGameButton.transform.parent);
			Object.DestroyImmediate((Object)(object)obj.GetComponent<LanguageTextMeshController>());
			((Object)obj).name = "GenericMenuButton (Quit to Lobby)";
			((TMP_Text)obj.GetComponentInChildren<HGTextMeshProUGUI>()).text = "Quit to Lobby";
			((UnityEventBase)((Button)obj.GetComponent<HGButton>()).onClick).m_PersistentCalls.GetListener(0).arguments.stringArgument = "quit_confirmed_command \"itsschwer_run_end\"";
		}

		[ConCommand(/*Could not decode attribute arguments.*/)]
		private static void CCRunEndUnpause(ConCommandArgs args)
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			Console.instance.RunCmd(CmdSender.op_Implicit(LocalUserManager.GetFirstLocalUser()), "run_end", new List<string>());
			if (PauseScreenController.instancesList.Count != 0)
			{
				Object.Destroy((Object)(object)((Component)PauseScreenController.instancesList[0]).gameObject);
			}
		}
	}
	public class RescueShipLoopPortal : TweakBase
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_Start <0>__HoldoutZoneController_Start;
		}

		private readonly ConfigEntry<bool> rescueShipPortal;

		public override bool allowed
		{
			get
			{
				if (Plugin.Enabled)
				{
					return rescueShipPortal.Value;
				}
				return false;
			}
		}

		internal RescueShipLoopPortal(ConfigFile config)
		{
			rescueShipPortal = config.Bind<bool>("Tweaks", "rescueShipPortal", true, "Spawn a portal in the Rescue Ship to allow looping after defeating Mithrix.");
		}

		protected override void Hook()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__HoldoutZoneController_Start;
			if (obj == null)
			{
				hook_Start val = HoldoutZoneController_Start;
				<>O.<0>__HoldoutZoneController_Start = val;
				obj = (object)val;
			}
			HoldoutZoneController.Start += (hook_Start)obj;
			Plugin.Logger.LogDebug((object)("RescueShipLoopPortal> Hooked by " + TweakBase.GetExecutingMethod()));
		}

		protected override void Unhook()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			object obj = <>O.<0>__HoldoutZoneController_Start;
			if (obj == null)
			{
				hook_Start val = HoldoutZoneController_Start;
				<>O.<0>__HoldoutZoneController_Start = val;
				obj = (object)val;
			}
			HoldoutZoneController.Start -= (hook_Start)obj;
			Plugin.Logger.LogDebug((object)("RescueShipLoopPortal> Unhooked by " + TweakBase.GetExecutingMethod()));
		}

		private static void HoldoutZoneController_Start(orig_Start orig, HoldoutZoneController self)
		{
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: 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_009c: 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_00a8: 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_00b2: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self);
			if (self.inBoundsObjectiveToken == "OBJECTIVE_MOON_CHARGE_DROPSHIP")
			{
				Transform val = null;
				try
				{
					val = ((Component)self).transform.parent.parent.Find("RescueshipMoon/escapeship/DropshipMesh");
				}
				catch (NullReferenceException arg)
				{
					Plugin.Logger.LogError((object)string.Format("{0}> {1}", "RescueShipLoopPortal", arg));
				}
				if ((Object)(object)val == (Object)null)
				{
					Plugin.Logger.LogError((object)"RescueShipLoopPortal> Failed to find \"Moon2DropshipZone/RescueshipMoon/escapeship/DropshipMesh\"");
				}
				else
				{
					InstantiatePortal(val.position + val.up * 7f + val.forward * 14f, Quaternion.LookRotation(val.forward, -val.up));
				}
			}
		}

		internal static void InstantiatePortal(Vector3 position, Quaternion rotation)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: 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_0018: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Expected O, but got Unknown
			GameObject obj = Object.Instantiate<GameObject>(((SpawnCard)Addressables.LoadAssetAsync<InteractableSpawnCard>((object)"RoR2/DLC1/GameModes/InfiniteTowerRun/InfiniteTowerAssets/iscInfiniteTowerPortal.asset").WaitForCompletion()).prefab, position, rotation);
			obj.GetComponent<SceneExitController>().useRunNextStageScene = true;
			NetworkServer.Spawn(obj);
			Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
			{
				baseToken = "<size=120%><style=cIsVoid>The Void calls...</style></size>"
			});
		}
	}
	public class SendItemCostInChat : TweakBase
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_PayCost <0>__CostTypeDef_PayCost;

			public static hook_BeginScrapping <1>__ScrapperController_BeginScrapping;
		}

		private readonly ConfigEntry<bool> sendItemCostInChat;

		private static ConfigEntry<bool> includeScrapInItemCost;

		public override bool allowed
		{
			get
			{
				if (Plugin.Enabled)
				{
					return sendItemCostInChat.Value;
				}
				return false;
			}
		}

		internal SendItemCostInChat(ConfigFile config)
		{
			sendItemCostInChat = config.Bind<bool>("Chat", "sendItemCostInChat", true, "Send a chat notification listing the items that are consumed when a Scrapper, 3D Printer, Cleansing Pool, or Cauldron is used.");
			includeScrapInItemCost = config.Bind<bool>("Chat", "includeScrapInItemCost", false, "Include Item Scrap in the list printed by sendItemCostInChat.");
		}

		protected override void Hook()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			object obj = <>O.<0>__CostTypeDef_PayCost;
			if (obj == null)
			{
				hook_PayCost val = CostTypeDef_PayCost;
				<>O.<0>__CostTypeDef_PayCost = val;
				obj = (object)val;
			}
			CostTypeDef.PayCost += (hook_PayCost)obj;
			object obj2 = <>O.<1>__ScrapperController_BeginScrapping;
			if (obj2 == null)
			{
				hook_BeginScrapping val2 = ScrapperController_BeginScrapping;
				<>O.<1>__ScrapperController_BeginScrapping = val2;
				obj2 = (object)val2;
			}
			ScrapperController.BeginScrapping += (hook_BeginScrapping)obj2;
			Plugin.Logger.LogDebug((object)("SendItemCostInChat> Hooked by " + TweakBase.GetExecutingMethod()));
		}

		protected override void Unhook()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			object obj = <>O.<0>__CostTypeDef_PayCost;
			if (obj == null)
			{
				hook_PayCost val = CostTypeDef_PayCost;
				<>O.<0>__CostTypeDef_PayCost = val;
				obj = (object)val;
			}
			CostTypeDef.PayCost -= (hook_PayCost)obj;
			object obj2 = <>O.<1>__ScrapperController_BeginScrapping;
			if (obj2 == null)
			{
				hook_BeginScrapping val2 = ScrapperController_BeginScrapping;
				<>O.<1>__ScrapperController_BeginScrapping = val2;
				obj2 = (object)val2;
			}
			ScrapperController.BeginScrapping -= (hook_BeginScrapping)obj2;
			Plugin.Logger.LogDebug((object)("SendItemCostInChat> Unhooked by " + TweakBase.GetExecutingMethod()));
		}

		private static PayCostResults CostTypeDef_PayCost(orig_PayCost orig, CostTypeDef self, int cost, Interactor activator, GameObject purchasedObject, Xoroshiro128Plus rng, ItemIndex avoidedItemIndex)
		{
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			PayCostResults val = orig.Invoke(self, cost, activator, purchasedObject, rng, avoidedItemIndex);
			try
			{
				CostTypeDef_PayCost(val, activator, purchasedObject);
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)ex);
			}
			return val;
		}

		private static void CostTypeDef_PayCost(PayCostResults __result, Interactor activator, GameObject purchasedObject)
		{
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: 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_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			PurchaseInteraction val = ((purchasedObject != null) ? purchasedObject.GetComponent<PurchaseInteraction>() : null);
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			string purchaseInteractionVerb = GetPurchaseInteractionVerb(val);
			if (string.IsNullOrEmpty(purchaseInteractionVerb))
			{
				return;
			}
			object obj;
			if (activator == null)
			{
				obj = null;
			}
			else
			{
				CharacterBody component = ((Component)activator).GetComponent<CharacterBody>();
				if (component == null)
				{
					obj = null;
				}
				else
				{
					CharacterMaster master = component.master;
					if (master == null)
					{
						obj = null;
					}
					else
					{
						PlayerCharacterMasterController playerCharacterMasterController = master.playerCharacterMasterController;
						obj = ((playerCharacterMasterController != null) ? playerCharacterMasterController.networkUser : null);
					}
				}
			}
			NetworkUser val2 = (NetworkUser)obj;
			if ((Object)(object)val2 == (Object)null)
			{
				return;
			}
			Dictionary<PickupDef, int> dictionary = new Dictionary<PickupDef, int>();
			foreach (ItemIndex item in __result.itemsTaken)
			{
				if (includeScrapInItemCost.Value || !IsScrap(item))
				{
					PickupDef pickupDef = PickupCatalog.GetPickupDef(PickupCatalog.FindPickupIndex(item));
					if (!dictionary.ContainsKey(pickupDef))
					{
						dictionary[pickupDef] = 0;
					}
					dictionary[pickupDef]++;
				}
			}
			foreach (EquipmentIndex item2 in __result.equipmentTaken)
			{
				PickupDef pickupDef2 = PickupCatalog.GetPickupDef(PickupCatalog.FindPickupIndex(item2));
				if (!dictionary.ContainsKey(pickupDef2))
				{
					dictionary[pickupDef2] = 0;
				}
				dictionary[pickupDef2]++;
			}
			AnnounceExchangedItems(dictionary, val2, purchaseInteractionVerb);
		}

		private static void ScrapperController_BeginScrapping(orig_BeginScrapping orig, ScrapperController self, int intPickupIndex)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			PickupDef pickupDef;
			CharacterBody component;
			int itemCount;
			try
			{
				pickupDef = PickupCatalog.GetPickupDef(new PickupIndex(intPickupIndex));
				component = ((Component)self.interactor).GetComponent<CharacterBody>();
				itemCount = component.inventory.GetItemCount(pickupDef.itemIndex);
			}
			catch (Exception ex)
			{
				Plugin.Logger.LogError((object)ex);
				return;
			}
			finally
			{
				orig.Invoke(self, intPickupIndex);
			}
			object obj;
			if (component == null)
			{
				obj = null;
			}
			else
			{
				CharacterMaster master = component.master;
				if (master == null)
				{
					obj = null;
				}
				else
				{
					PlayerCharacterMasterController playerCharacterMasterController = master.playerCharacterMasterController;
					obj = ((playerCharacterMasterController != null) ? playerCharacterMasterController.networkUser : null);
				}
			}
			NetworkUser val = (NetworkUser)obj;
			if (!((Object)(object)val == (Object)null))
			{
				int itemCount2 = component.inventory.GetItemCount(pickupDef.itemIndex);
				AnnounceExchangedItems(new Dictionary<PickupDef, int> { 
				{
					pickupDef,
					itemCount - itemCount2
				} }, val, "scrapped");
			}
		}

		private static void AnnounceExchangedItems(Dictionary<PickupDef, int> exchanged, NetworkUser user, string action)
		{
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Expected O, but got Unknown
			if (exchanged.Count <= 0)
			{
				return;
			}
			StringBuilder stringBuilder = new StringBuilder();
			List<PickupDef> list = exchanged.Keys.ToList();
			for (int i = 0; i < list.Count; i++)
			{
				PickupDef val = list[i];
				stringBuilder.Append(Util.GenerateColoredString(Language.GetString(val.nameToken), Color32.op_Implicit(val.baseColor)));
				if (exchanged[val] != 1)
				{
					stringBuilder.Append($"({exchanged[val]})");
				}
				int num = list.Count - i;
				if (num > 2)
				{
					stringBuilder.Append(", ");
				}
				else if (num > 1)
				{
					stringBuilder.Append((list.Count > 2) ? ", and " : " and ");
				}
			}
			Chat.SendBroadcastChat((ChatMessageBase)new SimpleChatMessage
			{
				baseToken = $"<style=cEvent>{user.userName} {action} {stringBuilder}</color>"
			});
		}

		private static bool IsScrap(ItemIndex itemIndex)
		{
			//IL_0000: 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_0013: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			if (itemIndex != Items.ScrapWhite.itemIndex && itemIndex != Items.ScrapGreen.itemIndex && itemIndex != Items.ScrapRed.itemIndex && itemIndex != Items.ScrapYellow.itemIndex)
			{
				return itemIndex == Items.RegeneratingScrap.itemIndex;
			}
			return true;
		}

		private static string GetPurchaseInteractionVerb(PurchaseInteraction purchaseInteraction)
		{
			switch (purchaseInteraction.displayNameToken)
			{
			default:
				return "";
			case "BAZAAR_CAULDRON_NAME":
				return "reforged";
			case "SHRINE_CLEANSE_NAME":
				return "cleansed themself of";
			case "DUPLICATOR_NAME":
			case "DUPLICATOR_MILITARY_NAME":
			case "DUPLICATOR_WILD_NAME":
				return "gave up";
			}
		}
	}
	public class TeleportOutOfBoundsPickups : TweakBase
	{
		private class OutOfBoundsPickupHelper : MonoBehaviour
		{
			public Vector3 origin { get; private set; }

			public bool attempted { get; internal set; }

			private void OnEnable()
			{
				//IL_0007: Unknown result type (might be due to invalid IL or missing references)
				origin = ((Component)this).transform.position;
				attempted = false;
			}
		}

		[CompilerGenerated]
		private static class <>O
		{
			public static hook_TryZoneStart <0>__MapZone_TryZoneStart;
		}

		private readonly ConfigEntry<bool> teleportOutOfBoundsPickups;

		private bool vanillaIgnoreLayerCollision;

		private static SpawnCard _scTeleportHelper;

		public override bool allowed
		{
			get
			{
				if (Plugin.Enabled)
				{
					return teleportOutOfBoundsPickups.Value;
				}
				return false;
			}
		}

		private static SpawnCard scTeleportHelper
		{
			get
			{
				//IL_0024: 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)
				if ((Object)(object)_scTeleportHelper == (Object)null)
				{
					SpawnCard obj = ScriptableObject.CreateInstance<SpawnCard>();
					obj.prefab = LegacyResourcesAPI.Load<GameObject>("SpawnCards/HelperPrefab");
					obj.nodeGraphType = (GraphType)0;
					obj.hullSize = (HullClassification)0;
					_scTeleportHelper = obj;
				}
				return _scTeleportHelper;
			}
		}

		internal TeleportOutOfBoundsPickups(ConfigFile config)
		{
			teleportOutOfBoundsPickups = config.Bind<bool>("Tweaks", "teleportOutOfBoundsPickups", true, "Teleport items that fall off the map to the nearest valid ground node.");
		}

		protected override void Hook()
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Expected O, but got Unknown
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_007b: Expected O, but got Unknown
			//IL_0049: 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_0054: Expected O, but got Unknown
			vanillaIgnoreLayerCollision = Physics.GetIgnoreLayerCollision(LayerMask.NameToLayer("CollideWithCharacterHullOnly"), PickupDropletController.pickupDropletPrefab.layer);
			Physics.IgnoreLayerCollision(LayerMask.NameToLayer("CollideWithCharacterHullOnly"), PickupDropletController.pickupDropletPrefab.layer, false);
			object obj = <>O.<0>__MapZone_TryZoneStart;
			if (obj == null)
			{
				hook_TryZoneStart val = MapZone_TryZoneStart;
				<>O.<0>__MapZone_TryZoneStart = val;
				obj = (object)val;
			}
			MapZone.TryZoneStart += (hook_TryZoneStart)obj;
			PickupDropletController.Start += new hook_Start(PickupDropletController_Start);
			GenericPickupController.Start += new hook_Start(GenericPickupController_Start);
			Plugin.Logger.LogDebug((object)("TeleportOutOfBoundsPickups> Hooked by " + TweakBase.GetExecutingMethod()));
		}

		protected override void Unhook()
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_002f: 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_003a: Expected O, but got Unknown
			Physics.IgnoreLayerCollision(LayerMask.NameToLayer("CollideWithCharacterHullOnly"), PickupDropletController.pickupDropletPrefab.layer, vanillaIgnoreLayerCollision);
			object obj = <>O.<0>__MapZone_TryZoneStart;
			if (obj == null)
			{
				hook_TryZoneStart val = MapZone_TryZoneStart;
				<>O.<0>__MapZone_TryZoneStart = val;
				obj = (object)val;
			}
			MapZone.TryZoneStart -= (hook_TryZoneStart)obj;
			PickupDropletController.Start -= new hook_Start(PickupDropletController_Start);
			GenericPickupController.Start -= new hook_Start(GenericPickupController_Start);
			Plugin.Logger.LogDebug((object)("TeleportOutOfBoundsPickups> Unhooked by " + TweakBase.GetExecutingMethod()));
		}

		private void GenericPickupController_Start(orig_Start orig, GenericPickupController self)
		{
			orig.Invoke(self);
			((Component)self).gameObject.AddComponent<OutOfBoundsPickupHelper>();
		}

		private void PickupDropletController_Start(orig_Start orig, PickupDropletController self)
		{
			orig.Invoke(self);
			((Component)self).gameObject.AddComponent<OutOfBoundsPickupHelper>();
		}

		private static void MapZone_TryZoneStart(orig_TryZoneStart orig, MapZone self, Collider other)
		{
			//IL_0009: 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_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: 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_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			orig.Invoke(self, other);
			if ((int)self.zoneType != 0)
			{
				return;
			}
			StringBuilder stringBuilder = new StringBuilder("TeleportOutOfBoundsPickups> ");
			OutOfBoundsPickupHelper outOfBoundsPickupHelper = default(OutOfBoundsPickupHelper);
			if (((Component)other).TryGetComponent<OutOfBoundsPickupHelper>(ref outOfBoundsPickupHelper))
			{
				if (!outOfBoundsPickupHelper.attempted)
				{
					Vector3 origin = outOfBoundsPickupHelper.origin;
					TeleportHelper.TeleportGameObject(((Component)other).gameObject, origin);
					if (Object.op_Implicit((Object)(object)other.attachedRigidbody))
					{
						other.attachedRigidbody.velocity = Vector3.zero;
					}
					outOfBoundsPickupHelper.attempted = true;
					stringBuilder.AppendLine($"Teleported pickup to {origin}");
					stringBuilder.AppendLine("\tentered " + ((Object)((Component)self).gameObject).name);
					Plugin.Logger.LogDebug((object)stringBuilder.ToString());
				}
				else
				{
					Vector3? val = TeleportToNearestNode(other);
					if (val.HasValue)
					{
						stringBuilder.AppendLine($"Teleported pickup to {val.Value}");
						stringBuilder.AppendLine("\tentered " + ((Object)((Component)self).gameObject).name);
						Plugin.Logger.LogDebug((object)stringBuilder.ToString());
					}
				}
				return;
			}
			PickupDropletController val2 = default(PickupDropletController);
			bool flag = ((Component)other).TryGetComponent<PickupDropletController>(ref val2);
			GenericPickupController val3 = default(GenericPickupController);
			bool flag2 = ((Component)other).TryGetComponent<GenericPickupController>(ref val3);
			PickupPickerController val4 = default(PickupPickerController);
			bool flag3 = ((Component)other).TryGetComponent<PickupPickerController>(ref val4);
			string text = string.Format("{{ {0}: {1}, {2}: {3}, {4}: {5} }}", "hasPickupDropletController", flag, "hasGenericPickupController", flag2, "hasPickupPickerController", flag3);
			if (flag || flag2 || flag3)
			{
				Vector3? val5 = TeleportToNearestNode(other);
				if (val5.HasValue)
				{
					stringBuilder.AppendLine($"Teleported pickup to {val5.Value}");
					stringBuilder.AppendLine("\tentered " + ((Object)((Component)self).gameObject).name);
					stringBuilder.AppendLine("\t" + text);
					Plugin.Logger.LogDebug((object)stringBuilder.ToString());
				}
				else
				{
					stringBuilder.AppendLine($"Failed to find a node to teleport to (from {((Component)other).transform.position})");
					stringBuilder.AppendLine("\tentered " + ((Object)((Component)self).gameObject).name);
					Plugin.Logger.LogDebug((object)stringBuilder.ToString());
				}
			}
		}

		private static Vector3? TeleportToNearestNode(Collider other)
		{
			//IL_000a: 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_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_0031: 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_0046: 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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0074: 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_008d: Unknown result type (might be due to invalid IL or missing references)
			GameObject val = DirectorCore.instance.TrySpawnObject(new DirectorSpawnRequest(scTeleportHelper, new DirectorPlacementRule
			{
				placementMode = (PlacementMode)3,
				position = ((Component)other).transform.position
			}, RoR2Application.rng));
			if ((Object)(object)val != (Object)null)
			{
				Vector3 position = val.transform.position;
				Vector3 up = Vector3.up;
				Bounds bounds = other.bounds;
				Vector3 val2 = position + up * ((Bounds)(ref bounds)).extents.y;
				TeleportHelper.TeleportGameObject(((Component)other).gameObject, val2);
				if (Object.op_Implicit((Object)(object)other.attachedRigidbody))
				{
					other.attachedRigidbody.velocity = Vector3.zero;
				}
				Object.Destroy((Object)(object)val);
				return val2;
			}
			return null;
		}
	}
	public abstract class TweakBase
	{
		private bool _hooked;

		public abstract bool allowed { get; }

		public bool Enable()
		{
			if (_hooked)
			{
				return false;
			}
			_hooked = true;
			Hook();
			return true;
		}

		public bool Disable()
		{
			if (!_hooked)
			{
				return false;
			}
			_hooked = false;
			Unhook();
			return true;
		}

		protected abstract void Hook();

		protected abstract void Unhook();

		protected static string GetExecutingMethod(int index = 0)
		{
			MethodBase method = new StackTrace().GetFrame(index + 3).GetMethod();
			return $"{method.DeclaringType}::{method.Name}";
		}
	}
	public class VoidFieldFogTweak : TweakBase
	{
		[CompilerGenerated]
		private static class <>O
		{
			public static hook_OnStartServer <0>__ArenaMissionController_OnStartServer;

			public static hook_BeginRound <1>__ArenaMissionController_BeginRound;
		}

		private readonly ConfigEntry<bool> voidFieldFogAltStart;

		public override bool allowed
		{
			get
			{
				if (Plugin.Enabled)
				{
					return voidFieldFogAltStart.Value;
				}
				return false;
			}
		}

		internal VoidFieldFogTweak(ConfigFile config)
		{
			voidFieldFogAltStart = config.Bind<bool>("Tweaks", "voidFieldFogAltStart", false, "Change the Void Fields fog to only become active once a Cell Vent has been activated.");
		}

		protected override void Hook()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			object obj = <>O.<0>__ArenaMissionController_OnStartServer;
			if (obj == null)
			{
				hook_OnStartServer val = ArenaMissionController_OnStartServer;
				<>O.<0>__ArenaMissionController_OnStartServer = val;
				obj = (object)val;
			}
			ArenaMissionController.OnStartServer += (hook_OnStartServer)obj;
			object obj2 = <>O.<1>__ArenaMissionController_BeginRound;
			if (obj2 == null)
			{
				hook_BeginRound val2 = ArenaMissionController_BeginRound;
				<>O.<1>__ArenaMissionController_BeginRound = val2;
				obj2 = (object)val2;
			}
			ArenaMissionController.BeginRound += (hook_BeginRound)obj2;
			Plugin.Logger.LogDebug((object)("VoidFieldFogTweak> Hooked by " + TweakBase.GetExecutingMethod()));
		}

		protected override void Unhook()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Expected O, but got Unknown
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: Expected O, but got Unknown
			object obj = <>O.<0>__ArenaMissionController_OnStartServer;
			if (obj == null)
			{
				hook_OnStartServer val = ArenaMissionController_OnStartServer;
				<>O.<0>__ArenaMissionController_OnStartServer = val;
				obj = (object)val;
			}
			ArenaMissionController.OnStartServer -= (hook_OnStartServer)obj;
			object obj2 = <>O.<1>__ArenaMissionController_BeginRound;
			if (obj2 == null)
			{
				hook_BeginRound val2 = ArenaMissionController_BeginRound;
				<>O.<1>__ArenaMissionController_BeginRound = val2;
				obj2 = (object)val2;
			}
			ArenaMissionController.BeginRound -= (hook_BeginRound)obj2;
			Plugin.Logger.LogDebug((object)("VoidFieldFogTweak> Unhooked by " + TweakBase.GetExecutingMethod()));
		}

		private static void ArenaMissionController_OnStartServer(orig_OnStartServer orig, ArenaMissionController self)
		{
			orig.Invoke(self);
			SetFogActive(self, value: false);
		}

		private static void ArenaMissionController_BeginRound(orig_BeginRound orig, ArenaMissionController self)
		{
			orig.Invoke(self);
			if (self.currentRound == 1)
			{
				SetFogActive(self, value: true);
			}
		}

		private static void SetFogActive(ArenaMissionController controller, bool value)
		{
			GameObject fogDamageInstance = controller.fogDamageInstance;
			if (fogDamageInstance != null)
			{
				fogDamageInstance.SetActive(value);
			}
			controller.clearedEffect.SetActive(!value);
		}
	}
	public class VoidPickupConfirmAll : TweakBase
	{
		private readonly ConfigEntry<bool> voidPickupConfirmAll;

		private static readonly Dictionary<ItemTier, PickupRules> originalRules = new Dictionary<ItemTier, PickupRules>();

		public override bool allowed
		{
			get
			{
				if (Plugin.Enabled)
				{
					return voidPickupConfirmAll.Value;
				}
				return false;
			}
		}

		internal VoidPickupConfirmAll(ConfigFile config)
		{
			voidPickupConfirmAll = config.Bind<bool>("Tweaks", "voidPickupConfirmAll", true, "Always require confirmation to pick up void items.");
		}

		protected override void Hook()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: 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_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Invalid comparison between Unknown and I4
			//IL_0046: 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_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Invalid comparison between Unknown and I4
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: Invalid comparison between Unknown and I4
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Invalid comparison between Unknown and I4
			Enumerator<ItemTierDef> enumerator = ItemTierCatalog.allItemTierDefs.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					ItemTierDef current = enumerator.Current;
					if ((int)current.tier == 6 || (int)current.tier == 7 || (int)current.tier == 8 || (int)current.tier == 9)
					{
						originalRules[current.tier] = current.pickupRules;
						current.pickupRules = (PickupRules)2;
						Plugin.Logger.LogDebug((object)string.Format("{0}> Changed pickup rule for item tier {1} from {2} to {3}", "VoidPickupConfirmAll", current.tier, originalRules[current.tier], current.pickupRules));
					}
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
			Plugin.Logger.LogDebug((object)("VoidPickupConfirmAll> Hooked by " + TweakBase.GetExecutingMethod()));
		}

		protected override void Unhook()
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: 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_001e: 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_002e: Unknown result type (might be due to invalid IL or missing references)
			Enumerator<ItemTierDef> enumerator = ItemTierCatalog.allItemTierDefs.GetEnumerator();
			try
			{
				while (enumerator.MoveNext())
				{
					ItemTierDef current = enumerator.Current;
					if (originalRules.TryGetValue(current.tier, out var value))
					{
						current.pickupRules = value;
					}
				}
			}
			finally
			{
				((IDisposable)enumerator).Dispose();
			}
			originalRules.Clear();
			Plugin.Logger.LogDebug((object)("VoidPickupConfirmAll> Unhooked by " + TweakBase.GetExecutingMethod()));
		}
	}
}