Decompiled source of Patpack v1.0.0

Patpack.dll

Decompiled 20 minutes ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Reflection.Emit;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using MenuLib;
using MenuLib.MonoBehaviors;
using Microsoft.CodeAnalysis;
using Patpack.CartsCrushEnemies;
using Patpack.ExtractionNoHeightLimit;
using Patpack.FasterStaminaRegen;
using Patpack.LastStand;
using Patpack.MultiplierCart;
using Patpack.SacrificeBomb;
using Patpack.ShrinkCart;
using Patpack.ValuablesInEveryRoom;
using Photon.Pun;
using Photon.Realtime;
using REPOLib.Modules;
using TMPro;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Patpack")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("Patpack")]
[assembly: AssemblyTitle("Patpack")]
[assembly: AssemblyVersion("1.0.0.0")]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Patpack
{
	internal static class PatpackMenu
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static BuilderDelegate <>9__5_0;

			public static BuilderDelegate <>9__5_1;

			public static Func<PatModule, bool> <>9__8_3;

			public static Func<(PatModule module, REPOButton button), PatModule> <>9__8_1;

			internal void <Init>b__5_0(Transform parent)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				AddOpenButton(parent, new Vector2(126f, 65f));
			}

			internal void <Init>b__5_1(Transform parent)
			{
				//IL_000b: Unknown result type (might be due to invalid IL or missing references)
				AddOpenButton(parent, new Vector2(152f, 60f));
			}

			internal bool <OpenMenu>b__8_3(PatModule m)
			{
				if (m.Loaded)
				{
					return m.Entries.Count > 0;
				}
				return false;
			}

			internal PatModule <OpenMenu>b__8_1((PatModule module, REPOButton button) c)
			{
				return c.module;
			}
		}

		private static readonly Color Accent = new Color(1f, 0.55f, 0.1f);

		private const string HighlightHex = "#FFB43C";

		private static REPOPopupPage sidebar;

		private static readonly List<(PatModule module, REPOButton button)> categoryButtons = new List<(PatModule, REPOButton)>();

		private static PatModule current;

		public static void Init()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//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_0043: Expected O, but got Unknown
			object obj = <>c.<>9__5_0;
			if (obj == null)
			{
				BuilderDelegate val = delegate(Transform parent)
				{
					//IL_000b: Unknown result type (might be due to invalid IL or missing references)
					AddOpenButton(parent, new Vector2(126f, 65f));
				};
				<>c.<>9__5_0 = val;
				obj = (object)val;
			}
			MenuAPI.AddElementToEscapeMenu((BuilderDelegate)obj);
			object obj2 = <>c.<>9__5_1;
			if (obj2 == null)
			{
				BuilderDelegate val2 = delegate(Transform parent)
				{
					//IL_000b: Unknown result type (might be due to invalid IL or missing references)
					AddOpenButton(parent, new Vector2(152f, 60f));
				};
				<>c.<>9__5_1 = val2;
				obj2 = (object)val2;
			}
			MenuAPI.AddElementToLobbyMenu((BuilderDelegate)obj2);
		}

		private static void AddOpenButton(Transform parent, Vector2 position)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			REPOButton ours = MenuAPI.CreateREPOButton("Patpack", (Action)OpenMenu, parent, position);
			((MonoBehaviour)PatpackPlugin.Instance).StartCoroutine(PlaceNextToMods(parent, ours));
		}

		private static IEnumerator PlaceNextToMods(Transform parent, REPOButton ours)
		{
			yield return null;
			if (!((Object)(object)ours == (Object)null) && !((Object)(object)parent == (Object)null))
			{
				REPOButton val = ((IEnumerable<REPOButton>)((Component)parent).GetComponentsInChildren<REPOButton>(true)).FirstOrDefault((Func<REPOButton, bool>)((REPOButton b) => (Object)(object)b != (Object)(object)ours && (Object)(object)b.labelTMP != (Object)null && string.Equals(((TMP_Text)b.labelTMP).text.Trim(), "Mods", StringComparison.OrdinalIgnoreCase)));
				if (!((Object)(object)val == (Object)null))
				{
					Vector3 localPosition = ((Transform)((REPOElement)val).rectTransform).localPosition;
					((Transform)((REPOElement)ours).rectTransform).localPosition = new Vector3(localPosition.x + val.GetLabelSize().x + 24f, localPosition.y, localPosition.z);
				}
			}
		}

		private static void OpenMenu()
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Expected O, but got Unknown
			categoryButtons.Clear();
			sidebar = MenuAPI.CreateREPOPopupPage("Patpack", (PresetSide)0, false, true, 0f);
			REPOPopupPage page = sidebar;
			page.AddElement((BuilderDelegate)delegate(Transform parent)
			{
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				MenuAPI.CreateREPOButton("Back", (Action)delegate
				{
					page.ClosePage(true);
				}, parent, new Vector2(66f, 18f));
			});
			foreach (PatModule item in PatpackPlugin.Modules.Where((PatModule patModule3) => patModule3.Loaded && patModule3.Entries.Count > 0))
			{
				PatModule m = item;
				page.AddElementToScrollView((ScrollViewBuilderDelegate)delegate(Transform scrollView)
				{
					//IL_002d: 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)
					REPOButton val = MenuAPI.CreateREPOButton(m.Name, (Action)delegate
					{
						OpenModule(m);
					}, scrollView, default(Vector2));
					categoryButtons.Add((m, val));
					return ((REPOElement)val).rectTransform;
				}, 0f, 0f);
			}
			page.OpenPage(false);
			PatModule patModule2 = ((current != null && current.Loaded) ? current : categoryButtons.Select(((PatModule module, REPOButton button) c) => c.module).FirstOrDefault());
			if (patModule2 != null)
			{
				OpenModule(patModule2);
			}
		}

		private static void HighlightCategory()
		{
			foreach (var (patModule, val) in categoryButtons)
			{
				if (!((Object)(object)val == (Object)null) && !((Object)(object)val.labelTMP == (Object)null))
				{
					((TMP_Text)val.labelTMP).text = ((patModule == current) ? ("<color=#FFB43C>> " + patModule.Name + "</color>") : patModule.Name);
				}
			}
		}

		private static void OpenModule(PatModule module)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Expected O, but got Unknown
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Expected O, but got Unknown
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Expected O, but got Unknown
			current = module;
			HighlightCategory();
			MenuAPI.CloseAllPagesAddedOnTop();
			REPOPopupPage val = MenuAPI.CreateREPOPopupPage(module.Name, (PresetSide)1, false, false, 5f);
			val.AddElement((BuilderDelegate)delegate(Transform parent)
			{
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				MenuAPI.CreateREPOButton("Reset To Default", (Action)delegate
				{
					ConfirmReset(module);
				}, parent, new Vector2(370f, 18f));
			});
			bool flag = module.Entries.Select((ConfigEntryBase key) => module.SectionOf[key]).Distinct().Count() > 1;
			string text = null;
			foreach (ConfigEntryBase entry in module.Entries)
			{
				string text2 = module.SectionOf[entry];
				if (flag && text2 != text)
				{
					text = text2;
					string heading = text2.ToUpperInvariant();
					val.AddElementToScrollView((ScrollViewBuilderDelegate)((Transform sv) => ((REPOElement)MenuAPI.CreateREPOLabel(heading, sv, default(Vector2))).rectTransform), (text == module.SectionOf[module.Entries[0]]) ? 0f : 8f, 0f);
				}
				ConfigEntryBase e = entry;
				val.AddElementToScrollView((ScrollViewBuilderDelegate)((Transform sv) => CreateControl(e, sv)), 0f, 0f);
			}
			val.OpenPage(true);
		}

		private static RectTransform CreateControl(ConfigEntryBase entry, Transform parent)
		{
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0230: Unknown result type (might be due to invalid IL or missing references)
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_0267: Unknown result type (might be due to invalid IL or missing references)
			//IL_026d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: 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)
			string key = entry.Definition.Key;
			ConfigDescription description = entry.Description;
			string text = ((description != null) ? description.Description : null) ?? "";
			ConfigEntry<bool> val = entry as ConfigEntry<bool>;
			if (val == null)
			{
				ConfigEntry<int> val2 = entry as ConfigEntry<int>;
				if (val2 == null)
				{
					ConfigEntry<float> val3 = entry as ConfigEntry<float>;
					if (val3 == null)
					{
						ConfigEntry<string> val4 = entry as ConfigEntry<string>;
						if (val4 != null)
						{
							return ((REPOElement)MenuAPI.CreateREPOInputField(key, (Action<string>)delegate(string v)
							{
								Set(val4, v);
							}, parent, default(Vector2), true, "", val4.Value)).rectTransform;
						}
						return ((REPOElement)MenuAPI.CreateREPOLabel($"{key}: {entry.BoxedValue}", parent, default(Vector2))).rectTransform;
					}
					ConfigDescription description2 = ((ConfigEntryBase)val3).Description;
					AcceptableValueRange<float> obj = ((description2 != null) ? description2.AcceptableValues : null) as AcceptableValueRange<float>;
					float num = obj?.MinValue ?? Mathf.Min(0f, val3.Value);
					float num2 = obj?.MaxValue ?? Mathf.Max(10f, val3.Value * 2f);
					float num3 = num2 - num;
					int num4 = ((num3 <= 1.5f) ? 2 : ((num3 <= 30f) ? 1 : 0));
					return ((REPOElement)MenuAPI.CreateREPOSlider(key, text, (Action<float>)delegate(float v)
					{
						Set(val3, v);
					}, parent, default(Vector2), num, num2, num4, val3.Value, "", "", (BarBehavior)0)).rectTransform;
				}
				ConfigDescription description3 = ((ConfigEntryBase)val2).Description;
				AcceptableValueRange<int> obj2 = ((description3 != null) ? description3.AcceptableValues : null) as AcceptableValueRange<int>;
				int num5 = obj2?.MinValue ?? Math.Min(0, val2.Value);
				int num6 = obj2?.MaxValue ?? Math.Max(100, val2.Value * 2);
				return ((REPOElement)MenuAPI.CreateREPOSlider(key, text, (Action<int>)delegate(int v)
				{
					Set(val2, v);
				}, parent, default(Vector2), num5, num6, val2.Value, "", "", (BarBehavior)0)).rectTransform;
			}
			return ((REPOElement)MenuAPI.CreateREPOToggle(key, (Action<bool>)delegate(bool v)
			{
				Set(val, v);
			}, parent, default(Vector2), "ON", "OFF", val.Value)).rectTransform;
		}

		private static void Set<T>(ConfigEntry<T> entry, T value)
		{
			if (!object.Equals(entry.Value, value))
			{
				entry.Value = value;
				PatpackPlugin.MarkConfigChanged();
			}
		}

		private static void ConfirmReset(PatModule module)
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			MenuAPI.OpenPopup("Reset " + module.Name + "?", Accent, "Put all of this mod's settings back to their defaults?", (Action)delegate
			{
				foreach (ConfigEntryBase entry in module.Entries)
				{
					entry.BoxedValue = entry.DefaultValue;
				}
				PatpackPlugin.MarkConfigChanged();
				OpenModule(module);
			}, (Action)null);
		}
	}
	[BepInPlugin("Patpack", "Patpack", "1.0.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class PatpackPlugin : BaseUnityPlugin
	{
		public const string Guid = "Patpack";

		public const string Name = "Patpack";

		public const string Version = "1.0.0";

		internal static PatpackPlugin Instance;

		internal static ManualLogSource Log;

		internal static readonly List<PatModule> Modules = new List<PatModule>
		{
			new PatModule("LastStand", "Last Stand", Patpack.LastStand.Plugin.Init),
			new PatModule("CartsCrushEnemies", "Carts Crush Enemies", Patpack.CartsCrushEnemies.Plugin.Init),
			new PatModule("SacrificeBomb", "Sacrifice Bomb", Patpack.SacrificeBomb.Plugin.Init),
			new PatModule("MultiplierCart", "Multiplier Cart", Patpack.MultiplierCart.Plugin.Init),
			new PatModule("ShrinkCart", "Shrink Cart", Patpack.ShrinkCart.Plugin.Init),
			new PatModule("FasterStaminaRegen", "Faster Stamina Regen", Patpack.FasterStaminaRegen.Plugin.Init),
			new PatModule("ValuablesInEveryRoom", "Valuables In Every Room", Patpack.ValuablesInEveryRoom.Plugin.Init),
			new PatModule("ExtractionNoHeightLimit", "Extraction No Height Limit", Patpack.ExtractionNoHeightLimit.Plugin.Init)
		};

		private static bool configDirty;

		private static float lastChange;

		private void Awake()
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Expected O, but got Unknown
			Instance = this;
			Log = ((BaseUnityPlugin)this).Logger;
			bool flag = !File.Exists(((BaseUnityPlugin)this).Config.ConfigFilePath);
			((BaseUnityPlugin)this).Config.SaveOnConfigSet = false;
			Harmony harmony = new Harmony("Patpack");
			foreach (PatModule module in Modules)
			{
				try
				{
					ConfigFile val = (flag ? OpenOldConfig(module.Id) : null);
					module.Init(new ModuleConfig(((BaseUnityPlugin)this).Config, module, val), Logger.CreateLogSource("Patpack/" + module.Name));
					PatchModule(harmony, module);
					module.Loaded = true;
					if (val != null)
					{
						Log.LogInfo((object)(module.Name + ": imported your settings from " + module.Id + ".cfg"));
					}
				}
				catch (Exception arg)
				{
					Log.LogError((object)$"{module.Name} failed to load and is turned off: {arg}");
				}
			}
			((BaseUnityPlugin)this).Config.Save();
			PatpackMenu.Init();
			Log.LogInfo((object)string.Format("{0} {1} loaded {2}/{3} mods.", "Patpack", "1.0.0", Modules.Count((PatModule m) => m.Loaded), Modules.Count));
		}

		private static void PatchModule(Harmony harmony, PatModule module)
		{
			string text = "Patpack." + module.Id;
			Type[] types = typeof(PatpackPlugin).Assembly.GetTypes();
			foreach (Type type in types)
			{
				if (!(type.Namespace != text) && type.GetCustomAttributes(typeof(HarmonyPatch), inherit: true).Any())
				{
					try
					{
						harmony.CreateClassProcessor(type).Patch();
					}
					catch (Exception ex)
					{
						Log.LogError((object)(module.Name + ": couldn't apply " + type.Name + " (game update?): " + ex.Message));
					}
				}
			}
		}

		private static ConfigFile OpenOldConfig(string oldGuid)
		{
			//IL_0022: 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_002f: Expected O, but got Unknown
			string text = Path.Combine(Paths.ConfigPath, oldGuid + ".cfg");
			if (!File.Exists(text))
			{
				return null;
			}
			return new ConfigFile(text, false)
			{
				SaveOnConfigSet = false
			};
		}

		internal static void MarkConfigChanged()
		{
			configDirty = true;
			lastChange = Time.unscaledTime;
		}

		private void Update()
		{
			if (configDirty && Time.unscaledTime - lastChange > 0.5f)
			{
				configDirty = false;
				((BaseUnityPlugin)this).Config.Save();
			}
		}

		private void OnApplicationQuit()
		{
			if (configDirty)
			{
				((BaseUnityPlugin)this).Config.Save();
			}
		}
	}
	internal sealed class PatModule
	{
		public readonly string Id;

		public readonly string Name;

		public readonly Action<ModuleConfig, ManualLogSource> Init;

		public readonly List<ConfigEntryBase> Entries = new List<ConfigEntryBase>();

		public readonly Dictionary<ConfigEntryBase, string> SectionOf = new Dictionary<ConfigEntryBase, string>();

		public bool Loaded;

		public PatModule(string id, string name, Action<ModuleConfig, ManualLogSource> init)
		{
			Id = id;
			Name = name;
			Init = init;
		}
	}
	public sealed class ModuleConfig
	{
		private const string HideFromREPOConfig = "HideREPOConfig";

		private readonly ConfigFile file;

		private readonly ConfigFile old;

		private readonly PatModule module;

		internal ModuleConfig(ConfigFile file, PatModule module, ConfigFile old)
		{
			this.file = file;
			this.module = module;
			this.old = old;
		}

		public ConfigEntry<T> Bind<T>(string section, string key, T defaultValue, string description)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			return Bind(section, key, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()));
		}

		public ConfigEntry<T> Bind<T>(string section, string key, T defaultValue, ConfigDescription description)
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Expected O, but got Unknown
			ConfigDescription val = new ConfigDescription(((description != null) ? description.Description : null) ?? "", (description != null) ? description.AcceptableValues : null, new object[1] { "HideREPOConfig" });
			ConfigEntry<T> val2 = file.Bind<T>(module.Name + " - " + section, key, defaultValue, val);
			if (old != null)
			{
				try
				{
					val2.Value = old.Bind<T>(section, key, defaultValue, new ConfigDescription("", (description != null) ? description.AcceptableValues : null, Array.Empty<object>())).Value;
				}
				catch (Exception ex)
				{
					PatpackPlugin.Log.LogWarning((object)(module.Name + ": couldn't import '" + key + "': " + ex.Message));
				}
			}
			module.Entries.Add((ConfigEntryBase)(object)val2);
			module.SectionOf[(ConfigEntryBase)(object)val2] = section;
			return val2;
		}
	}
}
namespace Patpack.ValuablesInEveryRoom
{
	internal static class Plugin
	{
		public const string Guid = "ValuablesInEveryRoom";

		public const string Name = "Valuables In Every Room";

		public const string Version = "1.0.0";

		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<int> MinPerRoom;

		internal static ConfigEntry<int> MaxPerRoom;

		internal static ConfigEntry<bool> IncludeHallways;

		internal static ConfigEntry<bool> LogDetails;

		internal static void Init(ModuleConfig Config, ManualLogSource Logger)
		{
			//IL_003f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			Log = Logger;
			Enabled = Config.Bind("General", "Enabled", defaultValue: true, "Make sure every room has some valuables. Applies from the next level. Only the host needs this mod.");
			MinPerRoom = Config.Bind("General", "Min Valuables Per Room", 1, new ConfigDescription("Every room gets at least this many valuables (counting ones the game already put there).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10), Array.Empty<object>()));
			MaxPerRoom = Config.Bind("General", "Max Valuables Per Room", 2, new ConfigDescription("Each room's minimum is picked at random between Min and this. Rooms the game already filled past it are left alone. If this is lower than Min, Min is used.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 10), Array.Empty<object>()));
			IncludeHallways = Config.Bind("General", "Include Hallways", defaultValue: false, "Also top up hallway/passage pieces, not just rooms.");
			LogDetails = Config.Bind("Debug", "Log Details", defaultValue: false, "Write how many valuables were added to each room to the BepInEx log.");
			Log.LogInfo((object)"Valuables In Every Room 1.0.0 loaded.");
		}
	}
	[HarmonyPatch]
	internal static class SetupHostPatch
	{
		private static MethodBase TargetMethod()
		{
			return AccessTools.EnumeratorMoveNext((MethodBase)AccessTools.Method(typeof(ValuableDirector), "SetupHost", (Type[])null, (Type[])null));
		}

		private static IEnumerable<CodeInstruction> Transpiler(IEnumerable<CodeInstruction> instructions)
		{
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Expected O, but got Unknown
			//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			List<CodeInstruction> list = instructions.ToList();
			MethodInfo isMultiplayer = AccessTools.Method(typeof(SemiFunc), "IsMultiplayer", (Type[])null, (Type[])null);
			int num = list.FindIndex((CodeInstruction c) => c.opcode == OpCodes.Ldstr && c.operand as string == "ValuablesTargetSetRPC");
			int num2 = ((num < 0) ? (-1) : list.FindLastIndex(num, (CodeInstruction c) => CodeInstructionExtensions.Calls(c, isMultiplayer)));
			if (num2 < 0)
			{
				Plugin.Log.LogError((object)"Could not find where the game finishes spawning valuables (game update?). The mod will do nothing.");
				return list;
			}
			CodeInstruction[] array = (CodeInstruction[])(object)new CodeInstruction[2]
			{
				new CodeInstruction(OpCodes.Ldarg_0, (object)null),
				new CodeInstruction(OpCodes.Call, (object)AccessTools.Method(typeof(RoomFiller), "Fill", (Type[])null, (Type[])null))
			};
			CodeInstructionExtensions.MoveLabelsFrom(array[0], list[num2]);
			CodeInstructionExtensions.MoveBlocksFrom(array[0], list[num2]);
			list.InsertRange(num2, array);
			return list;
		}
	}
	internal static class RoomFiller
	{
		private static readonly Func<ValuableDirector, PrefabRef, ValuableVolume, ValuableObject> SpawnValuable = AccessTools.MethodDelegate<Func<ValuableDirector, PrefabRef, ValuableVolume, ValuableObject>>(AccessTools.Method(typeof(ValuableDirector), "SpawnValuable", (Type[])null, (Type[])null), (object)null, true);

		private static readonly FieldRef<Module, bool> IsStartRoom = AccessTools.FieldRefAccess<Module, bool>("StartRoom");

		public static void Fill(object stateMachine)
		{
			try
			{
				FillRooms(stateMachine);
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)$"Skipped filling rooms because of an error: {arg}");
			}
		}

		private static void FillRooms(object stateMachine)
		{
			if (!Plugin.Enabled.Value || !SemiFunc.RunIsLevel())
			{
				return;
			}
			Traverse obj = Traverse.Create(stateMachine);
			ValuableDirector value = obj.Field("<>4__this").GetValue<ValuableDirector>();
			List<ValuableVolume>[] value2 = obj.Field("<_volumes>5__4").GetValue<List<ValuableVolume>[]>();
			List<PrefabRef>[] value3 = obj.Field("<_valuables>5__6").GetValue<List<PrefabRef>[]>();
			int[] value4 = obj.Field("<_volumeIndex>5__7").GetValue<int[]>();
			if ((Object)(object)value == (Object)null || value2 == null || value3 == null || value4 == null)
			{
				Plugin.Log.LogError((object)"Could not read the game's spawn spot lists (game update?). No valuables added.");
				return;
			}
			Dictionary<Module, int> dictionary = new Dictionary<Module, int>();
			HashSet<Module> hashSet = new HashSet<Module>();
			for (int i = 0; i < value2.Length; i++)
			{
				if (value2[i] == null)
				{
					continue;
				}
				for (int j = 0; j < value2[i].Count; j++)
				{
					Module val = (((Object)(object)value2[i][j] != (Object)null) ? value2[i][j].Module : null);
					if (!((Object)(object)val == (Object)null))
					{
						hashSet.Add(val);
						if (j < value4[i])
						{
							dictionary[val] = (dictionary.TryGetValue(val, out var value5) ? value5 : 0) + 1;
						}
					}
				}
			}
			int value6 = Plugin.MinPerRoom.Value;
			int num = Math.Max(value6, Plugin.MaxPerRoom.Value);
			int num2 = 0;
			int num3 = 0;
			foreach (Module item in from _ in hashSet.Where(IsEligible)
				orderby Random.value
				select _)
			{
				int value7;
				int num4 = (dictionary.TryGetValue(item, out value7) ? value7 : 0);
				int num5 = Random.Range(value6, num + 1);
				int num6;
				for (num6 = 0; num4 + num6 < num5; num6++)
				{
					if (!TrySpawnIn(item, value, value2, value3, value4))
					{
						break;
					}
				}
				if (num6 > 0)
				{
					num2 += num6;
					num3++;
					if (Plugin.LogDetails.Value)
					{
						Plugin.Log.LogInfo((object)$"{((Object)item).name}: had {num4}, added {num6}.");
					}
				}
			}
			if (num2 > 0)
			{
				Plugin.Log.LogInfo((object)$"Added {num2} valuables across {num3} rooms.");
			}
		}

		private static bool IsEligible(Module room)
		{
			//IL_001a: 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_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected I4, but got Unknown
			if ((Object)(object)room == (Object)null || IsStartRoom.Invoke(room))
			{
				return false;
			}
			Type type = room.type;
			switch ((int)type)
			{
			case 0:
			case 2:
			case 4:
			case 5:
				return true;
			case 1:
				return Plugin.IncludeHallways.Value;
			default:
				return false;
			}
		}

		private static bool TrySpawnIn(Module room, ValuableDirector director, List<ValuableVolume>[] volumes, List<PrefabRef>[] valuables, int[] used)
		{
			List<(int, int)> list = new List<(int, int)>();
			for (int i = 0; i < volumes.Length; i++)
			{
				if (volumes[i] == null || valuables[i] == null || valuables[i].Count == 0)
				{
					continue;
				}
				for (int j = used[i]; j < volumes[i].Count; j++)
				{
					if ((Object)(object)volumes[i][j] != (Object)null && (Object)(object)volumes[i][j].Module == (Object)(object)room)
					{
						list.Add((i, j));
					}
				}
			}
			if (list.Count == 0)
			{
				return false;
			}
			(int, int) tuple = list[Random.Range(0, list.Count)];
			int item = tuple.Item1;
			int item2 = tuple.Item2;
			List<ValuableVolume> list3;
			List<ValuableVolume> list2 = (list3 = volumes[item]);
			int index = item2;
			List<ValuableVolume> list4 = list2;
			int index2 = used[item];
			ValuableVolume value = list2[used[item]];
			ValuableVolume value2 = list2[item2];
			list3[index] = value;
			list4[index2] = value2;
			ValuableVolume arg = list2[used[item]];
			used[item]++;
			PrefabRef arg2 = valuables[item][Random.Range(0, valuables[item].Count)];
			SpawnValuable(director, arg2, arg);
			return true;
		}
	}
}
namespace Patpack.ShrinkCart
{
	internal static class Plugin
	{
		public const string Guid = "ShrinkCart";

		public const string Name = "Shrink Cart";

		public const string Version = "1.0.0";

		private const string VanillaCartPath = "Items/Item Cart Medium";

		internal const string ShrinkCartName = "Item Cart Shrink";

		internal static ManualLogSource Log;

		internal static ConfigEntry<float> ShrinkSize;

		internal static ConfigEntry<float> ShrinkSpeed;

		internal static ConfigEntry<float> PriceMultiplier;

		internal static void Init(ModuleConfig Config, ManualLogSource Logger)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Expected O, but got Unknown
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Expected O, but got Unknown
			Log = Logger;
			ShrinkSize = Config.Bind("Shrinking", "Shrink Size", 0.5f, new ConfigDescription("How big items become while inside the cart, as a fraction of their normal size. 0.5 = half size.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>()));
			ShrinkSpeed = Config.Bind("Shrinking", "Shrink Speed", 4f, new ConfigDescription("How fast items shrink and grow back. Higher is faster.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 20f), Array.Empty<object>()));
			PriceMultiplier = Config.Bind("Shop", "Price Multiplier", 1.5f, new ConfigDescription("Price compared to the normal medium cart. Takes effect after restarting the game.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>()));
			RegisterShrinkCart();
		}

		private static void RegisterShrinkCart()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			GameObject val = Resources.Load<GameObject>("Items/Item Cart Medium");
			if ((Object)(object)val == (Object)null)
			{
				Log.LogError((object)"Could not find the vanilla cart at Resources/Items/Item Cart Medium. The Shrink Cart was not added.");
				return;
			}
			GameObject val2 = new GameObject("ShrinkCart Templates");
			val2.SetActive(false);
			((Object)val2).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)val2);
			GameObject val3 = Object.Instantiate<GameObject>(val, val2.transform);
			((Object)val3).name = "Item Cart Shrink";
			ItemAttributes component = val3.GetComponent<ItemAttributes>();
			if ((Object)(object)component == (Object)null || (Object)(object)component.item == (Object)null)
			{
				Log.LogError((object)"The vanilla cart has no ItemAttributes/Item. The Shrink Cart was not added.");
				return;
			}
			Item val4 = Object.Instantiate<Item>(component.item);
			((Object)val4).name = "Item Cart Shrink";
			val4.itemName = "Shrink C.A.R.T.";
			val4.itemNameLocalized = null;
			val4.description = "A cart that shrinks whatever you put in it. Items grow back when taken out.";
			if ((Object)(object)val4.value != (Object)null)
			{
				Value val5 = Object.Instantiate<Value>(val4.value);
				val5.valueMin *= PriceMultiplier.Value;
				val5.valueMax *= PriceMultiplier.Value;
				val4.value = val5;
			}
			component.item = val4;
			val3.AddComponent<ShrinkCartBehaviour>();
			Items.RegisterItem(component);
			Log.LogInfo((object)("Shrink Cart 1.0.0 loaded: registered \"" + val4.itemName + "\"."));
		}
	}
	public class ShrinkCartBehaviour : MonoBehaviour
	{
		private static readonly FieldRef<PhysGrabCart, List<PhysGrabObject>> ItemsInCart = AccessTools.FieldRefAccess<PhysGrabCart, List<PhysGrabObject>>("itemsInCart");

		private static readonly FieldRef<PhysGrabObject, bool> IsCart = AccessTools.FieldRefAccess<PhysGrabObject, bool>("isCart");

		private static readonly FieldRef<PhysGrabObject, bool> IsEnemy = AccessTools.FieldRefAccess<PhysGrabObject, bool>("isEnemy");

		private static readonly FieldRef<PhysGrabObject, bool> IsPlayer = AccessTools.FieldRefAccess<PhysGrabObject, bool>("isPlayer");

		private PhysGrabCart cart;

		private PhysGrabObject self;

		private readonly Dictionary<PhysGrabObject, Vector3> originalScales = new Dictionary<PhysGrabObject, Vector3>();

		private readonly HashSet<PhysGrabObject> inside = new HashSet<PhysGrabObject>();

		private void Awake()
		{
			cart = ((Component)this).GetComponent<PhysGrabCart>();
			self = ((Component)this).GetComponent<PhysGrabObject>();
		}

		private void Update()
		{
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)cart == (Object)null)
			{
				return;
			}
			inside.Clear();
			List<PhysGrabObject> list = ItemsInCart.Invoke(cart);
			if (list != null)
			{
				foreach (PhysGrabObject item in list)
				{
					if (CanShrink(item))
					{
						inside.Add(item);
						if (!originalScales.ContainsKey(item))
						{
							originalScales[item] = ((Component)item).transform.localScale;
						}
					}
				}
			}
			float num = Time.deltaTime * Plugin.ShrinkSpeed.Value;
			float value = Plugin.ShrinkSize.Value;
			foreach (PhysGrabObject item2 in originalScales.Keys.ToList())
			{
				if ((Object)(object)item2 == (Object)null)
				{
					originalScales.Remove(item2);
					continue;
				}
				Vector3 val = originalScales[item2];
				Vector3 val2 = (inside.Contains(item2) ? (val * value) : val);
				((Component)item2).transform.localScale = Vector3.Lerp(((Component)item2).transform.localScale, val2, num);
				if (!inside.Contains(item2))
				{
					Vector3 val3 = ((Component)item2).transform.localScale - val;
					if (((Vector3)(ref val3)).sqrMagnitude < 0.0001f)
					{
						((Component)item2).transform.localScale = val;
						originalScales.Remove(item2);
					}
				}
			}
		}

		private bool CanShrink(PhysGrabObject obj)
		{
			if ((Object)(object)obj == (Object)null || (Object)(object)obj == (Object)(object)self)
			{
				return false;
			}
			if (IsCart.Invoke(obj) || IsEnemy.Invoke(obj) || IsPlayer.Invoke(obj))
			{
				return false;
			}
			if ((Object)(object)((Component)obj).GetComponent<PlayerDeathHead>() != (Object)null)
			{
				return false;
			}
			return true;
		}

		private void OnDisable()
		{
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			foreach (KeyValuePair<PhysGrabObject, Vector3> originalScale in originalScales)
			{
				if ((Object)(object)originalScale.Key != (Object)null)
				{
					((Component)originalScale.Key).transform.localScale = originalScale.Value;
				}
			}
			originalScales.Clear();
		}
	}
}
namespace Patpack.SacrificeBomb
{
	internal static class Plugin
	{
		public const string Guid = "SacrificeBomb";

		public const string Name = "Sacrifice Bomb";

		public const string Version = "1.0.0";

		private const string DefaultLines = "I was alive! Now I am not!|I didn't mean to press that!|For my team! For my brothers!|yoyoyoyoyoyoyoyoyo|Like I was never here!|Badabing, bada-";

		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<float> PromptRange;

		internal static ConfigEntry<float> BehindAngle;

		internal static ConfigEntry<string> PromptText;

		internal static ConfigEntry<int> CountdownFrom;

		internal static ConfigEntry<float> SecondsPerCount;

		internal static ConfigEntry<float> FinalLineSeconds;

		internal static ConfigEntry<string> FinalLines;

		internal static ConfigEntry<int> EnemyDamage;

		internal static ConfigEntry<float> ExplosionSize;

		internal static ConfigEntry<bool> HurtTeammates;

		internal static ConfigEntry<float> LatchDistance;

		internal static void Init(ModuleConfig Config, ManualLogSource Logger)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Expected O, but got Unknown
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Expected O, but got Unknown
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Expected O, but got Unknown
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Expected O, but got Unknown
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_0180: Expected O, but got Unknown
			//IL_01ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Expected O, but got Unknown
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_020c: Expected O, but got Unknown
			//IL_0236: Unknown result type (might be due to invalid IL or missing references)
			//IL_023b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0241: Expected O, but got Unknown
			//IL_0241: Unknown result type (might be due to invalid IL or missing references)
			Log = Logger;
			Enabled = Config.Bind("General", "Enabled", defaultValue: true, "Sneak up behind an enemy and press your Interact key (E) to latch on and self-destruct. Everyone in the lobby should have this mod.");
			PromptRange = Config.Bind("General", "Prompt Range", 2.5f, new ConfigDescription("How close (meters) you must be to the enemy.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 6f), Array.Empty<object>()));
			BehindAngle = Config.Bind("General", "Behind Angle", 120f, new ConfigDescription("How wide the 'behind the enemy' zone is, in degrees. 180 = anywhere in the back half.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(30f, 270f), Array.Empty<object>()));
			PromptText = Config.Bind("General", "Prompt Text", "[E] SACRIFICE YOURSELF", "Text shown on screen while you are behind an enemy.");
			LatchDistance = Config.Bind("General", "Latch Distance", 0.9f, new ConfigDescription("How far behind the enemy's center you cling, in meters.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.3f, 3f), Array.Empty<object>()));
			CountdownFrom = Config.Bind("Countdown", "Countdown From", 3, new ConfigDescription("The TTS counts down from this number.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 10), Array.Empty<object>()));
			SecondsPerCount = Config.Bind("Countdown", "Seconds Per Count", 1.2f, new ConfigDescription("Time between each number.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 3f), Array.Empty<object>()));
			FinalLineSeconds = Config.Bind("Countdown", "Final Line Seconds", 2.5f, new ConfigDescription("Time given to the last words before the explosion.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 6f), Array.Empty<object>()));
			FinalLines = Config.Bind("Countdown", "Final Lines", "I was alive! Now I am not!|I didn't mean to press that!|For my team! For my brothers!|yoyoyoyoyoyoyoyoyo|Like I was never here!|Badabing, bada-", "Last words, picked at random. Separate lines with |.");
			EnemyDamage = Config.Bind("Explosion", "Enemy Damage", 400, new ConfigDescription("Damage dealt to the enemy you're latched on (and enemies caught in the blast).", (AcceptableValueBase)(object)new AcceptableValueRange<int>(10, 5000), Array.Empty<object>()));
			ExplosionSize = Config.Bind("Explosion", "Explosion Size", 1.5f, new ConfigDescription("Size of the blast. A normal grenade is 1.2.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.5f, 4f), Array.Empty<object>()));
			HurtTeammates = Config.Bind("Explosion", "Hurt Teammates", defaultValue: false, "Whether the blast also hurts other players standing nearby. You always die either way.");
			SacrificeNetwork.Register();
			GameObject val = new GameObject("SacrificeBomb Runner");
			Object.DontDestroyOnLoad((Object)val);
			((Object)val).hideFlags = (HideFlags)61;
			val.AddComponent<SacrificeController>();
			Log.LogInfo((object)"Sacrifice Bomb 1.0.0 loaded.");
		}

		internal static string RandomLine()
		{
			string[] array = (from l in FinalLines.Value.Split('|')
				select l.Trim() into l
				where l.Length > 0
				select l).ToArray();
			if (array.Length != 0)
			{
				return array[Random.Range(0, array.Length)];
			}
			return null;
		}
	}
	public class SacrificeController : MonoBehaviour
	{
		private static readonly FieldRef<Enemy, EnemyHealth> HealthOf = AccessTools.FieldRefAccess<Enemy, EnemyHealth>("Health");

		private static readonly FieldRef<Enemy, EnemyRigidbody> BodyOf = AccessTools.FieldRefAccess<Enemy, EnemyRigidbody>("Rigidbody");

		private static readonly FieldRef<EnemyHealth, bool> IsDead = AccessTools.FieldRefAccess<EnemyHealth, bool>("dead");

		private static readonly FieldRef<PlayerAvatar, bool> IsDisabled = AccessTools.FieldRefAccess<PlayerAvatar, bool>("isDisabled");

		private static readonly FieldRef<PlayerAvatar, bool> DeadSet = AccessTools.FieldRefAccess<PlayerAvatar, bool>("deadSet");

		private Enemy target;

		private Enemy latchedTo;

		private float scanTimer;

		private GUIStyle style;

		private Enemy lastCandidate;

		private void Update()
		{
			target = null;
			if (!Plugin.Enabled.Value || (Object)(object)latchedTo != (Object)null)
			{
				return;
			}
			PlayerAvatar val = LocalPlayer();
			if (!((Object)(object)val == (Object)null) && SemiFunc.RunIsLevel())
			{
				scanTimer -= Time.deltaTime;
				Enemy val2 = null;
				if (scanTimer <= 0f)
				{
					scanTimer = 0.1f;
					val2 = (lastCandidate = FindEnemyBehind(val));
				}
				else
				{
					val2 = (((Object)(object)lastCandidate != (Object)null && IsBehind(val, lastCandidate)) ? lastCandidate : null);
				}
				target = val2;
				if ((Object)(object)target != (Object)null && SemiFunc.InputDown((InputKey)2))
				{
					((MonoBehaviour)this).StartCoroutine(Sacrifice(val, target));
				}
			}
		}

		private static PlayerAvatar LocalPlayer()
		{
			PlayerController instance = PlayerController.instance;
			PlayerAvatar val = (((Object)(object)instance != (Object)null) ? instance.playerAvatarScript : null);
			if ((Object)(object)val == (Object)null || IsDisabled.Invoke(val) || DeadSet.Invoke(val))
			{
				return null;
			}
			return val;
		}

		private static Enemy FindEnemyBehind(PlayerAvatar me)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			Enemy val = SemiFunc.EnemyGetNearest(((Component)me).transform.position, Plugin.PromptRange.Value, true);
			if (!((Object)(object)val != (Object)null) || !IsBehind(me, val))
			{
				return null;
			}
			return val;
		}

		private static bool IsAlive(Enemy enemy)
		{
			if ((Object)(object)enemy == (Object)null || !((Behaviour)enemy).isActiveAndEnabled)
			{
				return false;
			}
			EnemyHealth val = HealthOf.Invoke(enemy);
			if (!((Object)(object)val == (Object)null))
			{
				return !IsDead.Invoke(val);
			}
			return true;
		}

		private static Transform Body(Enemy enemy)
		{
			EnemyRigidbody val = BodyOf.Invoke(enemy);
			if ((Object)(object)val != (Object)null)
			{
				return ((Component)val).transform;
			}
			if (!((Object)(object)enemy.CenterTransform != (Object)null))
			{
				return ((Component)enemy).transform;
			}
			return enemy.CenterTransform;
		}

		private static Vector3 Center(Enemy enemy)
		{
			//IL_0020: 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)
			if (!((Object)(object)enemy.CenterTransform != (Object)null))
			{
				return Body(enemy).position;
			}
			return enemy.CenterTransform.position;
		}

		private static bool IsBehind(PlayerAvatar me, Enemy enemy)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			if (!IsAlive(enemy))
			{
				return false;
			}
			Vector3 val = ((Component)me).transform.position - Center(enemy);
			val.y = 0f;
			if (((Vector3)(ref val)).magnitude > Plugin.PromptRange.Value + 0.5f)
			{
				return false;
			}
			Vector3 forward = Body(enemy).forward;
			forward.y = 0f;
			if (((Vector3)(ref forward)).sqrMagnitude < 0.0001f || ((Vector3)(ref val)).sqrMagnitude < 0.0001f)
			{
				return false;
			}
			return Vector3.Angle(-((Vector3)(ref forward)).normalized, ((Vector3)(ref val)).normalized) <= Plugin.BehindAngle.Value / 2f;
		}

		private IEnumerator Sacrifice(PlayerAvatar me, Enemy enemy)
		{
			latchedTo = enemy;
			target = null;
			int value = Plugin.CountdownFrom.Value;
			float perCount = Plugin.SecondsPerCount.Value;
			me.ChatMessageSend($"Self destruct in {value}", (string)null);
			float wait = perCount;
			for (int n = value - 1; n >= 0; n--)
			{
				while (wait > 0f)
				{
					if (!StillValid(me, enemy))
					{
						Release();
						yield break;
					}
					wait -= Time.deltaTime;
					yield return null;
				}
				if (n > 0)
				{
					me.ChatMessageSend(n.ToString(), (string)null);
				}
				wait = perCount;
				if (n == 0)
				{
					break;
				}
			}
			string text = Plugin.RandomLine();
			if (text != null)
			{
				me.ChatMessageSend(text, (string)null);
			}
			float lastWords = Plugin.FinalLineSeconds.Value;
			while (lastWords > 0f)
			{
				if (!StillValid(me, enemy))
				{
					Release();
					yield break;
				}
				lastWords -= Time.deltaTime;
				yield return null;
			}
			Vector3 position = Center(enemy);
			SacrificeNetwork.SendExplosion(me, enemy, position);
			yield return null;
			if ((Object)(object)me != (Object)null && (Object)(object)me.playerHealth != (Object)null)
			{
				me.playerHealth.InvincibleSet(0f);
				me.playerHealth.Hurt(9999, false, -1, false);
			}
			Release();
		}

		private bool StillValid(PlayerAvatar me, Enemy enemy)
		{
			if ((Object)(object)me == (Object)null || IsDisabled.Invoke(me) || DeadSet.Invoke(me))
			{
				return false;
			}
			if (!IsAlive(enemy))
			{
				return false;
			}
			return true;
		}

		private void Release()
		{
			latchedTo = null;
		}

		private void FixedUpdate()
		{
			//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_0061: 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_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)latchedTo == (Object)null))
			{
				PlayerController instance = PlayerController.instance;
				if (!((Object)(object)instance == (Object)null) && !((Object)(object)instance.rb == (Object)null))
				{
					Vector3 val = Body(latchedTo).forward;
					val.y = 0f;
					val = ((((Vector3)(ref val)).sqrMagnitude > 0.0001f) ? ((Vector3)(ref val)).normalized : Vector3.forward);
					Vector3 val2 = Center(latchedTo);
					Vector3 val3 = val2 - val * Plugin.LatchDistance.Value;
					val3.y = val2.y - 0.6f;
					instance.InputDisable(0.2f);
					instance.Kinematic(0.2f);
					instance.rb.MovePosition(val3);
					instance.rb.linearVelocity = Vector3.zero;
				}
			}
		}

		private void OnGUI()
		{
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: 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_005d: Expected O, but got Unknown
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			if (!((Object)(object)target == (Object)null) && !((Object)(object)latchedTo != (Object)null))
			{
				if (style == null)
				{
					style = new GUIStyle(GUI.skin.label)
					{
						fontSize = Mathf.Max(18, Screen.height / 30),
						alignment = (TextAnchor)4,
						fontStyle = (FontStyle)1
					};
					style.normal.textColor = new Color(1f, 0.35f, 0.2f);
				}
				Rect val = default(Rect);
				((Rect)(ref val))..ctor(0f, (float)Screen.height * 0.62f, (float)Screen.width, (float)Screen.height * 0.08f);
				Color textColor = style.normal.textColor;
				style.normal.textColor = Color.black;
				GUI.Label(new Rect(((Rect)(ref val)).x + 2f, ((Rect)(ref val)).y + 2f, ((Rect)(ref val)).width, ((Rect)(ref val)).height), Plugin.PromptText.Value, style);
				style.normal.textColor = textColor;
				GUI.Label(val, Plugin.PromptText.Value, style);
			}
		}
	}
	internal static class SacrificeNetwork
	{
		private const byte EventCode = 174;

		private static readonly FieldRef<Enemy, EnemyHealth> HealthOf = AccessTools.FieldRefAccess<Enemy, EnemyHealth>("Health");

		private static readonly FieldRef<ParticleScriptExplosion, GameObject> ExplosionPrefab = AccessTools.FieldRefAccess<ParticleScriptExplosion, GameObject>("explosionPrefab");

		private static ParticleScriptExplosion explosion;

		public static void Register()
		{
			PhotonNetwork.NetworkingClient.EventReceived += OnEvent;
		}

		public static void SendExplosion(PlayerAvatar me, Enemy enemy, Vector3 position)
		{
			//IL_0054: 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_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			if (SemiFunc.IsMultiplayer())
			{
				PhotonView componentInParent = ((Component)enemy).GetComponentInParent<PhotonView>();
				PhotonNetwork.RaiseEvent((byte)174, (object)new object[2]
				{
					position,
					((Object)(object)componentInParent != (Object)null) ? componentInParent.ViewID : (-1)
				}, new RaiseEventOptions
				{
					Receivers = (ReceiverGroup)1
				}, SendOptions.SendReliable);
			}
			else
			{
				Explode(position, enemy);
			}
		}

		private static void OnEvent(EventData e)
		{
			//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_004c: Unknown result type (might be due to invalid IL or missing references)
			if (e.Code != 174)
			{
				return;
			}
			try
			{
				object[] obj = (object[])e.CustomData;
				Vector3 position = (Vector3)obj[0];
				int num = (int)obj[1];
				PhotonView val = ((num >= 0) ? PhotonView.Find(num) : null);
				Enemy enemy = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponentInChildren<Enemy>() : null);
				Explode(position, enemy);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Bad sacrifice message: " + ex.Message));
			}
		}

		private static void Explode(Vector3 position, Enemy enemy)
		{
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			ParticleScriptExplosion val = GetExplosion();
			if ((Object)(object)val != (Object)null)
			{
				int num = (Plugin.HurtTeammates.Value ? 75 : 0);
				val.Spawn(position, Plugin.ExplosionSize.Value, num, Plugin.EnemyDamage.Value, 2f, false, false, 1.5f, 10f);
			}
			if ((Object)(object)enemy != (Object)null && SemiFunc.IsMasterClientOrSingleplayer())
			{
				EnemyHealth val2 = HealthOf.Invoke(enemy);
				if ((Object)(object)val2 != (Object)null)
				{
					val2.Hurt(Plugin.EnemyDamage.Value, Vector3.up);
				}
			}
		}

		private static ParticleScriptExplosion GetExplosion()
		{
			//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_0043: Expected O, but got Unknown
			if ((Object)(object)explosion != (Object)null)
			{
				return explosion;
			}
			ExplosionPreset val = FindGrenadePreset();
			if ((Object)(object)val == (Object)null)
			{
				Plugin.Log.LogError((object)"Couldn't find a grenade explosion to copy; no blast effect will play.");
				return null;
			}
			GameObject val2 = new GameObject("SacrificeBomb Explosion");
			Object.DontDestroyOnLoad((Object)val2);
			explosion = val2.AddComponent<ParticleScriptExplosion>();
			explosion.explosionPreset = val;
			ExplosionPrefab.Invoke(explosion) = Resources.Load<GameObject>("Effects/Part Prefab Explosion");
			return explosion;
		}

		private static ExplosionPreset FindGrenadePreset()
		{
			string[] array = new string[3] { "Items/Item Grenade Explosive", "Items/Item Grenade Duct Taped", "Items/Item Mine Explosive" };
			for (int i = 0; i < array.Length; i++)
			{
				GameObject val = Resources.Load<GameObject>(array[i]);
				ParticleScriptExplosion val2 = (((Object)(object)val != (Object)null) ? val.GetComponentInChildren<ParticleScriptExplosion>(true) : null);
				if ((Object)(object)val2 != (Object)null && (Object)(object)val2.explosionPreset != (Object)null)
				{
					return val2.explosionPreset;
				}
			}
			GameObject[] array2 = Resources.LoadAll<GameObject>("Items");
			for (int i = 0; i < array2.Length; i++)
			{
				ParticleScriptExplosion componentInChildren = array2[i].GetComponentInChildren<ParticleScriptExplosion>(true);
				if ((Object)(object)componentInChildren != (Object)null && (Object)(object)componentInChildren.explosionPreset != (Object)null)
				{
					return componentInChildren.explosionPreset;
				}
			}
			return null;
		}
	}
}
namespace Patpack.MultiplierCart
{
	internal static class Plugin
	{
		public const string Guid = "MultiplierCart";

		public const string Name = "Multiplier Cart";

		public const string Version = "1.0.0";

		private const string VanillaCartPath = "Items/Item Cart Medium";

		internal const string CartName = "Item Cart Multiplier";

		internal static ManualLogSource Log;

		internal static ConfigEntry<float> ValueMultiplier;

		internal static ConfigEntry<bool> KeepBonus;

		internal static ConfigEntry<float> PriceMultiplier;

		internal static void Init(ModuleConfig Config, ManualLogSource Logger)
		{
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008c: Expected O, but got Unknown
			Log = Logger;
			ValueMultiplier = Config.Bind("Value", "Value Multiplier", 2f, new ConfigDescription("Valuables inside the cart are worth this many times their value. Everyone in the lobby should use the same setting.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>()));
			KeepBonus = Config.Bind("Value", "Keep Bonus After Removal", defaultValue: false, "Off: the bonus only lasts while the valuable is in the cart, so extract with it inside. On: a valuable is boosted once, the first time it enters, and keeps the bonus forever.");
			PriceMultiplier = Config.Bind("Shop", "Price Multiplier", 3f, new ConfigDescription("Price compared to the normal medium cart. Takes effect after restarting the game.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 10f), Array.Empty<object>()));
			RegisterCart();
		}

		private static void RegisterCart()
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			GameObject val = Resources.Load<GameObject>("Items/Item Cart Medium");
			if ((Object)(object)val == (Object)null)
			{
				Log.LogError((object)"Could not find the vanilla cart at Resources/Items/Item Cart Medium. The Multiplier Cart was not added.");
				return;
			}
			GameObject val2 = new GameObject("MultiplierCart Templates");
			val2.SetActive(false);
			((Object)val2).hideFlags = (HideFlags)61;
			Object.DontDestroyOnLoad((Object)(object)val2);
			GameObject val3 = Object.Instantiate<GameObject>(val, val2.transform);
			((Object)val3).name = "Item Cart Multiplier";
			ItemAttributes component = val3.GetComponent<ItemAttributes>();
			if ((Object)(object)component == (Object)null || (Object)(object)component.item == (Object)null)
			{
				Log.LogError((object)"The vanilla cart has no ItemAttributes/Item. The Multiplier Cart was not added.");
				return;
			}
			Item val4 = Object.Instantiate<Item>(component.item);
			((Object)val4).name = "Item Cart Multiplier";
			val4.itemName = "Multiplier C.A.R.T.";
			val4.itemNameLocalized = null;
			val4.description = "Valuables inside this cart are worth more.";
			if ((Object)(object)val4.value != (Object)null)
			{
				Value val5 = Object.Instantiate<Value>(val4.value);
				val5.valueMin *= PriceMultiplier.Value;
				val5.valueMax *= PriceMultiplier.Value;
				val4.value = val5;
			}
			component.item = val4;
			val3.AddComponent<MultiplierCartBehaviour>();
			Items.RegisterItem(component);
			Log.LogInfo((object)("Multiplier Cart 1.0.0 loaded: registered \"" + val4.itemName + "\"."));
		}
	}
	public class MultiplierCartBehaviour : MonoBehaviour
	{
		private static readonly FieldRef<PhysGrabCart, List<PhysGrabObject>> ItemsInCart = AccessTools.FieldRefAccess<PhysGrabCart, List<PhysGrabObject>>("itemsInCart");

		private static readonly FieldRef<ValuableObject, float> ValueOriginal = AccessTools.FieldRefAccess<ValuableObject, float>("dollarValueOriginal");

		private static readonly FieldRef<ValuableObject, float> ValueCurrent = AccessTools.FieldRefAccess<ValuableObject, float>("dollarValueCurrent");

		private static readonly FieldRef<ValuableObject, bool> ValueSet = AccessTools.FieldRefAccess<ValuableObject, bool>("dollarValueSet");

		private static readonly Dictionary<ValuableObject, float> Boosted = new Dictionary<ValuableObject, float>();

		private static readonly HashSet<ValuableObject> BoostedForever = new HashSet<ValuableObject>();

		private PhysGrabCart cart;

		private readonly HashSet<ValuableObject> mine = new HashSet<ValuableObject>();

		private readonly HashSet<ValuableObject> inside = new HashSet<ValuableObject>();

		private void Awake()
		{
			cart = ((Component)this).GetComponent<PhysGrabCart>();
		}

		private void Update()
		{
			if ((Object)(object)cart == (Object)null)
			{
				return;
			}
			inside.Clear();
			List<PhysGrabObject> list = ItemsInCart.Invoke(cart);
			if (list != null)
			{
				foreach (PhysGrabObject item in list)
				{
					ValuableObject val = (((Object)(object)item != (Object)null) ? ((Component)item).GetComponent<ValuableObject>() : null);
					if ((Object)(object)val != (Object)null && ValueSet.Invoke(val))
					{
						inside.Add(val);
					}
				}
			}
			float value = Plugin.ValueMultiplier.Value;
			foreach (ValuableObject item2 in inside)
			{
				if (Boosted.ContainsKey(item2) || value <= 1f)
				{
					continue;
				}
				if (Plugin.KeepBonus.Value)
				{
					if (BoostedForever.Add(item2))
					{
						Scale(item2, value);
					}
				}
				else
				{
					Scale(item2, value);
					Boosted[item2] = value;
					mine.Add(item2);
				}
			}
			foreach (ValuableObject item3 in mine.ToList())
			{
				if (!((Object)(object)item3 != (Object)null) || !inside.Contains(item3))
				{
					Unboost(item3);
					mine.Remove(item3);
				}
			}
			Cleanup();
		}

		private static void Scale(ValuableObject valuable, float factor)
		{
			ValueOriginal.Invoke(valuable) *= factor;
			ValueCurrent.Invoke(valuable) *= factor;
		}

		private static void Unboost(ValuableObject valuable)
		{
			if ((Object)(object)valuable == (Object)null)
			{
				Boosted.Remove(valuable);
				return;
			}
			if (Boosted.TryGetValue(valuable, out var value) && value > 0f)
			{
				Scale(valuable, 1f / value);
			}
			Boosted.Remove(valuable);
		}

		private static void Cleanup()
		{
			if (Boosted.Count > 0 && Boosted.Keys.Any((ValuableObject v) => (Object)(object)v == (Object)null))
			{
				foreach (ValuableObject item in Boosted.Keys.Where((ValuableObject v) => (Object)(object)v == (Object)null).ToList())
				{
					Boosted.Remove(item);
				}
			}
			if (BoostedForever.Count > 256)
			{
				BoostedForever.RemoveWhere((ValuableObject v) => (Object)(object)v == (Object)null);
			}
		}

		private void OnDisable()
		{
			foreach (ValuableObject item in mine)
			{
				Unboost(item);
			}
			mine.Clear();
		}
	}
}
namespace Patpack.LastStand
{
	internal static class Plugin
	{
		public const string Guid = "LastStand";

		public const string Name = "Last Stand";

		public const string Version = "1.3.1";

		private const string DefaultLines = "I am alive, I am here, I am trying.|I am alive, but I'm not living.|Even if I'm dying, until I actually die, I am still living.|yoyoyoyoyoyoyoyoyoyo|Resurrection of dumb robot successful|If at first you don’t succeed, then ruuuuuuuuuuuuuuuuuuun!|Please. Have mercy. I’ve been wearing the same underwear since Tuesday.";

		internal static MonoBehaviour Instance;

		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<int> UsesPerLevel;

		internal static ConfigEntry<float> InvincibleSeconds;

		internal static ConfigEntry<int> ReviveHealthPercent;

		internal static ConfigEntry<bool> PlayVoiceLine;

		internal static ConfigEntry<string> VoiceLines;

		internal static ConfigEntry<float> ShieldOpacity;

		internal static ConfigEntry<bool> PlayReviveEffect;

		internal static ConfigEntry<bool> ShowBanner;

		internal static ConfigEntry<float> SpeedMultiplier;

		internal static ConfigEntry<float> JumpMultiplier;

		internal static ConfigEntry<int> ExtraJumps;

		internal static ConfigEntry<float> StaminaRegenMultiplier;

		internal static ConfigEntry<float> StaminaDrainMultiplier;

		internal static ConfigEntry<float> StrengthMultiplier;

		internal static ConfigEntry<float> RangeMultiplier;

		internal static ConfigEntry<float> ThrowMultiplier;

		internal static ConfigEntry<float> HealthRegenPerSecond;

		internal static ConfigEntry<int> DamageReductionPercent;

		internal static ConfigEntry<bool> ImmobilizeImmunity;

		internal static ConfigEntry<bool> RoundStartWhenAlone;

		internal static void Init(ModuleConfig Config, ManualLogSource Logger)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Expected O, but got Unknown
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Expected O, but got Unknown
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Expected O, but got Unknown
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0198: Expected O, but got Unknown
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Expected O, but got Unknown
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fc: Expected O, but got Unknown
			//IL_022a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Expected O, but got Unknown
			//IL_0262: Unknown result type (might be due to invalid IL or missing references)
			//IL_026c: Expected O, but got Unknown
			//IL_029a: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a4: Expected O, but got Unknown
			//IL_02d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Expected O, but got Unknown
			//IL_030a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0314: Expected O, but got Unknown
			//IL_0342: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Expected O, but got Unknown
			//IL_0370: Unknown result type (might be due to invalid IL or missing references)
			//IL_037a: Expected O, but got Unknown
			//IL_03bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03cc: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d2: Expected O, but got Unknown
			//IL_03d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03d9: Unknown result type (might be due to invalid IL or missing references)
			Instance = (MonoBehaviour)(object)PatpackPlugin.Instance;
			Log = Logger;
			Enabled = Config.Bind("General", "Enabled", defaultValue: true, "When the last living player would die, they are revived instead. Everyone in the lobby should have this mod.");
			UsesPerLevel = Config.Bind("General", "Uses Per Level", 1, new ConfigDescription("How many times each player can be saved per level.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 5), Array.Empty<object>()));
			InvincibleSeconds = Config.Bind("General", "Invincibility Seconds", 5f, new ConfigDescription("How long the revived player can't take damage.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 30f), Array.Empty<object>()));
			ReviveHealthPercent = Config.Bind("General", "Revive Health Percent", 50, new ConfigDescription("Health after the revive, as a percent of max health.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(1, 100), Array.Empty<object>()));
			PlayVoiceLine = Config.Bind("Voice", "Play Voice Line", defaultValue: true, "Say a random line in the revived player's own TTS voice.");
			VoiceLines = Config.Bind("Voice", "Voice Lines", "I am alive, I am here, I am trying.|I am alive, but I'm not living.|Even if I'm dying, until I actually die, I am still living.|yoyoyoyoyoyoyoyoyoyo|Resurrection of dumb robot successful|If at first you don’t succeed, then ruuuuuuuuuuuuuuuuuuun!|Please. Have mercy. I’ve been wearing the same underwear since Tuesday.", "Lines to pick from, separated by | characters.");
			ShieldOpacity = Config.Bind("Visuals", "Shield Opacity", 0.35f, new ConfigDescription("How solid the shield bubble looks at the start. It fades out as invincibility runs out.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.05f, 1f), Array.Empty<object>()));
			PlayReviveEffect = Config.Bind("Visuals", "Play Revive Effect", defaultValue: true, "Also play the game's normal revive effect on the player.");
			ShowBanner = Config.Bind("Visuals", "Show Last Standing Banner", defaultValue: true, "Show a big \"LAST STANDING!\" message, then a reminder at the top of the screen while it lasts. Other players see who is last standing.");
			SpeedMultiplier = Config.Bind("Buffs", "Speed Multiplier", 1.5f, new ConfigDescription("Walk, sprint and crouch speed.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 4f), Array.Empty<object>()));
			JumpMultiplier = Config.Bind("Buffs", "Jump Multiplier", 1.5f, new ConfigDescription("Jump height.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 4f), Array.Empty<object>()));
			ExtraJumps = Config.Bind("Buffs", "Extra Jumps", 1, new ConfigDescription("Extra mid-air jumps.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 5), Array.Empty<object>()));
			StaminaRegenMultiplier = Config.Bind("Buffs", "Stamina Regen Multiplier", 1.5f, new ConfigDescription("How much faster stamina refills. 1 = normal.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 5f), Array.Empty<object>()));
			StaminaDrainMultiplier = Config.Bind("Buffs", "Stamina Drain Multiplier", 0.75f, new ConfigDescription("How fast sprinting uses stamina. 1 = normal, 0.5 = half as fast.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0.1f, 1f), Array.Empty<object>()));
			StrengthMultiplier = Config.Bind("Buffs", "Grab Strength Multiplier", 2f, new ConfigDescription("How heavy things you can carry.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>()));
			RangeMultiplier = Config.Bind("Buffs", "Grab Range Multiplier", 1.5f, new ConfigDescription("How far you can grab from.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 4f), Array.Empty<object>()));
			ThrowMultiplier = Config.Bind("Buffs", "Throw Strength Multiplier", 1.5f, new ConfigDescription("How hard you throw.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 5f), Array.Empty<object>()));
			HealthRegenPerSecond = Config.Bind("Buffs", "Health Regen Per Second", 5f, new ConfigDescription("Health restored every second. 0 = off.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 50f), Array.Empty<object>()));
			DamageReductionPercent = Config.Bind("Buffs", "Damage Reduction Percent", 50, new ConfigDescription("Less damage taken after invincibility ends. 0 = off.", (AcceptableValueBase)(object)new AcceptableValueRange<int>(0, 90), Array.Empty<object>()));
			ImmobilizeImmunity = Config.Bind("Buffs", "Immobilization Immunity", defaultValue: true, "Can't be grabbed, knocked over, launched, stunned, slowed, frozen, pulled or have gravity changed. Note: this also stops you getting into vehicles while it lasts.");
			RoundStartWhenAlone = Config.Bind("Round Start", "Activate At Round Start When Alone", defaultValue: true, "If you start a level as the only living player (always true in solo), Last Stand kicks in right away: the banner shows and you get the buffs and immunity, for the whole level in solo. Your one revive per level is still saved for later.");
			LastStandNetwork.Register();
			GameObject val = new GameObject("LastStand Runner")
			{
				hideFlags = (HideFlags)61
			};
			Object.DontDestroyOnLoad((Object)val);
			val.AddComponent<LastStandBuffs>();
			val.AddComponent<LastStandBanner>();
			val.AddComponent<LastStandRoundStart>();
			Log.LogInfo((object)"Last Stand 1.3.1 loaded.");
		}

		internal static string RandomLine()
		{
			string[] array = (from l in VoiceLines.Value.Split('|')
				select l.Trim() into l
				where l.Length > 0
				select l).ToArray();
			if (array.Length != 0)
			{
				return array[Random.Range(0, array.Length)];
			}
			return null;
		}
	}
	internal static class Fields
	{
		internal static readonly FieldRef<PlayerAvatar, bool> IsLocal = AccessTools.FieldRefAccess<PlayerAvatar, bool>("isLocal");

		internal static readonly FieldRef<PlayerAvatar, bool> IsDisabled = AccessTools.FieldRefAccess<PlayerAvatar, bool>("isDisabled");

		internal static readonly FieldRef<PlayerAvatar, bool> DeadSet = AccessTools.FieldRefAccess<PlayerAvatar, bool>("deadSet");

		internal static readonly FieldRef<PlayerAvatar, string> PlayerName = AccessTools.FieldRefAccess<PlayerAvatar, string>("playerName");

		internal static readonly FieldRef<PlayerAvatar, PlayerTumble> Tumble = AccessTools.FieldRefAccess<PlayerAvatar, PlayerTumble>("tumble");

		internal static readonly FieldRef<PlayerTumble, PlayerAvatar> TumbleOwner = AccessTools.FieldRefAccess<PlayerTumble, PlayerAvatar>("playerAvatar");

		internal static readonly FieldRef<PlayerHealth, int> MaxHealth = AccessTools.FieldRefAccess<PlayerHealth, int>("maxHealth");

		internal static readonly FieldRef<PlayerController, int> JumpExtra = AccessTools.FieldRefAccess<PlayerController, int>("JumpExtra");

		internal static readonly FieldRef<PlayerAvatar, bool> Spawned = AccessTools.FieldRefAccess<PlayerAvatar, bool>("spawned");

		internal static bool IsMine(PlayerAvatar player)
		{
			if ((Object)(object)player == (Object)null)
			{
				return false;
			}
			if (IsLocal.Invoke(player))
			{
				return true;
			}
			PlayerController instance = PlayerController.instance;
			if ((Object)(object)instance != (Object)null)
			{
				return (Object)(object)instance.playerAvatarScript == (Object)(object)player;
			}
			return false;
		}

		internal static bool IsAlive(PlayerAvatar player)
		{
			if ((Object)(object)player != (Object)null && !IsDisabled.Invoke(player))
			{
				return !DeadSet.Invoke(player);
			}
			return false;
		}

		internal static bool IsLastStanding(PlayerAvatar player)
		{
			if ((Object)(object)GameDirector.instance == (Object)null)
			{
				return true;
			}
			foreach (PlayerAvatar player2 in GameDirector.instance.PlayerList)
			{
				if (!((Object)(object)player2 == (Object)null) && !((Object)(object)player2 == (Object)(object)player) && IsAlive(player2))
				{
					return false;
				}
			}
			return true;
		}
	}
	internal static class LastStandState
	{
		private static readonly HashSet<PlayerAvatar> Active = new HashSet<PlayerAvatar>();

		public static void SetBuffed(PlayerAvatar player)
		{
			if (!((Object)(object)player == (Object)null))
			{
				Active.RemoveWhere((PlayerAvatar p) => (Object)(object)p == (Object)null);
				Active.Add(player);
			}
		}

		public static bool IsBuffed(PlayerAvatar player)
		{
			if ((Object)(object)player == (Object)null || !Active.Contains(player))
			{
				return false;
			}
			if (SemiFunc.RunIsLevel() && Fields.IsAlive(player) && Fields.IsLastStanding(player))
			{
				return true;
			}
			Active.Remove(player);
			return false;
		}

		public static bool Immune(PlayerAvatar player)
		{
			if (Plugin.ImmobilizeImmunity.Value)
			{
				return IsBuffed(player);
			}
			return false;
		}

		public static bool LocalImmune()
		{
			PlayerController instance = PlayerController.instance;
			if ((Object)(object)instance != (Object)null)
			{
				return Immune(instance.playerAvatarScript);
			}
			return false;
		}
	}
	[HarmonyPatch(typeof(PlayerAvatar), "PlayerDeath")]
	internal static class PlayerDeathPatch
	{
		private static readonly Dictionary<int, int> UsesThisLevel = new Dictionary<int, int>();

		private static int levelId;

		private static bool Prefix(PlayerAvatar __instance)
		{
			try
			{
				if (!ShouldSave(__instance))
				{
					return true;
				}
				Save(__instance);
				return false;
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)$"Last Stand failed, letting the death happen: {arg}");
				return true;
			}
		}

		private static bool ShouldSave(PlayerAvatar player)
		{
			if (!Plugin.Enabled.Value || (Object)(object)player == (Object)null)
			{
				return false;
			}
			if (!SemiFunc.RunIsLevel())
			{
				return false;
			}
			if (!Fields.IsMine(player) || Fields.DeadSet.Invoke(player))
			{
				return false;
			}
			ResetIfNewLevel();
			UsesThisLevel.TryGetValue(((Object)player).GetInstanceID(), out var value);
			if (value >= Plugin.UsesPerLevel.Value)
			{
				return false;
			}
			return Fields.IsLastStanding(player);
		}

		private static void ResetIfNewLevel()
		{
			int num = (((Object)(object)LevelGenerator.Instance != (Object)null) ? ((Object)LevelGenerator.Instance).GetInstanceID() : 0);
			if (num != levelId)
			{
				levelId = num;
				UsesThisLevel.Clear();
			}
		}

		private static void Save(PlayerAvatar player)
		{
			int instanceID = ((Object)player).GetInstanceID();
			UsesThisLevel[instanceID] = (UsesThisLevel.TryGetValue(instanceID, out var value) ? value : 0) + 1;
			float value2 = Plugin.InvincibleSeconds.Value;
			player.playerHealth.InvincibleSet(value2);
			LastStandState.SetBuffed(player);
			Plugin.Instance.StartCoroutine(AfterSave(player));
			if (Plugin.PlayVoiceLine.Value)
			{
				string text = Plugin.RandomLine();
				if (text != null)
				{
					player.ChatMessageSend(text, (string)null);
				}
			}
			LastStandEffects.Show(player, value2);
			LastStandNetwork.SendRevive(player, value2);
			Plugin.Log.LogInfo((object)"Last Stand! The last player standing was revived.");
		}

		private static IEnumerator AfterSave(PlayerAvatar player)
		{
			yield return null;
			if ((Object)(object)player == (Object)null || (Object)(object)player.playerHealth == (Object)null)
			{
				yield break;
			}
			int num = Fields.MaxHealth.Invoke(player.playerHealth);
			int num2 = Mathf.Max(1, Mathf.RoundToInt((float)(num * Plugin.ReviveHealthPercent.Value) / 100f));
			player.playerHealth.Heal(num2, true);
			if (Plugin.ImmobilizeImmunity.Value)
			{
				PlayerTumble val = Fields.Tumble.Invoke(player);
				if ((Object)(object)val != (Object)null)
				{
					val.TumbleRequest(false, false);
				}
			}
		}
	}
	public class LastStandRoundStart : MonoBehaviour
	{
		private const float SettleSeconds = 1.5f;

		private int handledLevel;

		private float readyFor;

		private void Update()
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: Invalid comparison between Unknown and I4
			if (!Plugin.Enabled.Value || !Plugin.RoundStartWhenAlone.Value)
			{
				readyFor = 0f;
				return;
			}
			LevelGenerator instance = LevelGenerator.Instance;
			if (!SemiFunc.RunIsLevel() || (Object)(object)instance == (Object)null || !instance.Generated)
			{
				readyFor = 0f;
			}
			else
			{
				if (((Object)instance).GetInstanceID() == handledLevel)
				{
					return;
				}
				if ((Object)(object)GameDirector.instance == (Object)null || (int)GameDirector.instance.currentState != 2)
				{
					readyFor = 0f;
					return;
				}
				PlayerController instance2 = PlayerController.instance;
				PlayerAvatar val = (((Object)(object)instance2 != (Object)null) ? instance2.playerAvatarScript : null);
				if ((Object)(object)val == (Object)null || !Fields.Spawned.Invoke(val) || !Fields.IsAlive(val))
				{
					readyFor = 0f;
					return;
				}
				readyFor += Time.deltaTime;
				if (!(readyFor < 1.5f))
				{
					handledLevel = ((Object)instance).GetInstanceID();
					readyFor = 0f;
					if (Fields.IsLastStanding(val))
					{
						LastStandState.SetBuffed(val);
						LastStandBanner.Announce(val);
						LastStandNetwork.SendRevive(val, 0f);
						Plugin.Log.LogInfo((object)"Last Stand active from round start (you are the only one alive).");
					}
				}
			}
		}
	}
	public class LastStandBuffs : MonoBehaviour
	{
		private PlayerAvatar applied;

		private float baseJumpForce;

		private float baseGrabRange;

		private float baseThrow;

		private int baseJumpExtra;

		private float regenCarry;

		private float lastEnergy = -1f;

		private void Update()
		{
			PlayerController instance = PlayerController.instance;
			PlayerAvatar val = (((Object)(object)instance != (Object)null) ? instance.playerAvatarScript : null);
			int num;
			if ((Object)(object)val != (Object)null && LastStandState.IsBuffed(val))
			{
				num = ((!Fields.DeadSet.Invoke(val)) ? 1 : 0);
				if (num != 0 && !((Object)(object)val != (Object)(object)applied))
				{
					goto IL_0053;
				}
			}
			else
			{
				num = 0;
			}
			Restore();
			goto IL_0053;
			IL_0053:
			if (num == 0)
			{
				return;
			}
			PhysGrabber physGrabber = val.physGrabber;
			if ((Object)(object)applied == (Object)null)
			{
				applied = val;
				baseJumpForce = instance.JumpForce;
				baseJumpExtra = Fields.JumpExtra.Invoke(instance);
				instance.JumpForce = baseJumpForce * Plugin.JumpMultiplier.Value;
				Fields.JumpExtra.Invoke(instance) = baseJumpExtra + Plugin.ExtraJumps.Value;
				if ((Object)(object)physGrabber != (Object)null)
				{
					baseGrabRange = physGrabber.grabRange;
					baseThrow = physGrabber.throwStrength;
					physGrabber.grabRange = baseGrabRange * Plugin.RangeMultiplier.Value;
					physGrabber.throwStrength = baseThrow * Plugin.ThrowMultiplier.Value;
				}
				regenCarry = 0f;
			}
			instance.OverrideSpeed(Plugin.SpeedMultiplier.Value, 0.25f, 0f);
			if ((Object)(object)physGrabber != (Object)null)
			{
				physGrabber.OverrideGrabStrength(physGrabber.grabStrength * Plugin.StrengthMultiplier.Value, 0.25f);
			}
			float value = Plugin.HealthRegenPerSecond.Value;
			if (value > 0f && (Object)(object)val.playerHealth != (Object)null)
			{
				regenCarry += value * Time.deltaTime;
				if (regenCarry >= 1f)
				{
					int num2 = Mathf.FloorToInt(regenCarry);
					regenCarry -= num2;
					val.playerHealth.Heal(num2, false);
				}
			}
		}

		private void LateUpdate()
		{
			PlayerController instance = PlayerController.instance;
			if ((Object)(object)instance == (Object)null || (Object)(object)applied == (Object)null || (Object)(object)instance.playerAvatarScript != (Object)(object)applied)
			{
				lastEnergy = -1f;
				return;
			}
			float num = instance.EnergyCurrent;
			if (lastEnergy >= 0f)
			{
				float num2 = num - lastEnergy;
				if (Mathf.Abs(num2) < 15f)
				{
					if (num2 > 0f)
					{
						num = lastEnergy + num2 * Plugin.StaminaRegenMultiplier.Value;
					}
					else if (num2 < 0f)
					{
						num = lastEnergy + num2 * Plugin.StaminaDrainMultiplier.Value;
					}
					num = (instance.EnergyCurrent = Mathf.Clamp(num, 0f, instance.EnergyStart));
				}
			}
			lastEnergy = num;
		}

		private void Restore()
		{
			if ((Object)(object)applied == (Object)null)
			{
				return;
			}
			PlayerController instance = PlayerController.instance;
			if ((Object)(object)instance != (Object)null && (Object)(object)instance.playerAvatarScript == (Object)(object)applied)
			{
				instance.JumpForce = baseJumpForce;
				Fields.JumpExtra.Invoke(instance) = baseJumpExtra;
				if ((Object)(object)applied.physGrabber != (Object)null)
				{
					applied.physGrabber.grabRange = baseGrabRange;
					applied.physGrabber.throwStrength = baseThrow;
				}
			}
			applied = null;
		}
	}
	[HarmonyPatch(typeof(PlayerTumble), "TumbleRequest")]
	internal static class BlockTumbleRequest
	{
		private static bool Prefix(PlayerTumble __instance, bool _isTumbling, bool _playerInput)
		{
			if (_isTumbling && !_playerInput)
			{
				return !LastStandState.Immune(Fields.TumbleOwner.Invoke(__instance));
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(PlayerTumble), "TumbleSet")]
	internal static class BlockTumbleSet
	{
		private static bool Prefix(PlayerTumble __instance, bool _isTumbling, bool _playerInput)
		{
			if (_isTumbling && !_playerInput)
			{
				return !LastStandState.Immune(Fields.TumbleOwner.Invoke(__instance));
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(PlayerTumble), "TumbleOverride")]
	internal static class BlockTumbleOverride
	{
		private static bool Prefix(PlayerTumble __instance, bool _active)
		{
			if (_active)
			{
				return !LastStandState.Immune(Fields.TumbleOwner.Invoke(__instance));
			}
			return true;
		}
	}
	[HarmonyPatch]
	internal static class BlockTumbleMisc
	{
		private static IEnumerable<MethodBase> TargetMethods()
		{
			return from m in ((IEnumerable<string>)new string[5] { "TumbleForce", "TumbleTorque", "TumbleStunTime", "TumbleOverrideTime", "DisableCustomGravity" }).Select((Func<string, MethodBase>)((string n) => AccessTools.Method(typeof(PlayerTumble), n, (Type[])null, (Type[])null)))
				where m != null
				select m;
		}

		private static bool Prefix(PlayerTumble __instance)
		{
			return !LastStandState.Immune(Fields.TumbleOwner.Invoke(__instance));
		}
	}
	[HarmonyPatch]
	internal static class BlockControllerEffects
	{
		private static IEnumerable<MethodBase> TargetMethods()
		{
			return from m in ((IEnumerable<string>)new string[3] { "AntiGravity", "MoveForce", "InputDisable" }).Select((Func<string, MethodBase>)((string n) => AccessTools.Method(typeof(PlayerController), n, (Type[])null, (Type[])null)))
				where m != null
				select m;
		}

		private static bool Prefix()
		{
			return !LastStandState.LocalImmune();
		}
	}
	[HarmonyPatch(typeof(PlayerController), "OverrideSpeed")]
	internal static class BlockSlow
	{
		private static bool Prefix(float _speedMulti)
		{
			if (_speedMulti < 1f)
			{
				return !LastStandState.LocalImmune();
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(PlayerHealth), "Hurt")]
	internal static class DamageReduction
	{
		private static readonly FieldRef<PlayerHealth, PlayerAvatar> Owner = AccessTools.FieldRefAccess<PlayerHealth, PlayerAvatar>("playerAvatar");

		private static void Prefix(PlayerHealth __instance, ref int damage)
		{
			int value = Plugin.DamageReductionPercent.Value;
			if (value > 0 && damage > 0 && LastStandState.IsBuffed(Owner.Invoke(__instance)))
			{
				damage = Mathf.Max(1, Mathf.RoundToInt((float)damage * (1f - (float)value / 100f)));
			}
		}
	}
	internal static class LastStandNetwork
	{
		private const byte EventCode = 173;

		public static void Register()
		{
			PhotonNetwork.NetworkingClient.EventReceived += OnEvent;
		}

		public static void SendRevive(PlayerAvatar player, float invincible)
		{
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			if (SemiFunc.IsMultiplayer() && !((Object)(object)player.photonView == (Object)null))
			{
				PhotonNetwork.RaiseEvent((byte)173, (object)new object[2]
				{
					player.photonView.ViewID,
					invincible
				}, new RaiseEventOptions
				{
					Receivers = (ReceiverGroup)0
				}, SendOptions.SendReliable);
			}
		}

		private static void OnEvent(EventData e)
		{
			if (e.Code != 173)
			{
				return;
			}
			try
			{
				object[] array = (object[])e.CustomData;
				PhotonView val = PhotonView.Find((int)array[0]);
				PlayerAvatar val2 = (((Object)(object)val != (Object)null) ? ((Component)val).GetComponent<PlayerAvatar>() : null);
				if (!((Object)(object)val2 == (Object)null))
				{
					float num = (float)array[1];
					LastStandState.SetBuffed(val2);
					if (num > 0f)
					{
						LastStandEffects.Show(val2, num);
					}
					else
					{
						LastStandBanner.Announce(val2);
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("Bad Last Stand message: " + ex.Message));
			}
		}
	}
	internal static class LastStandEffects
	{
		public static void Show(PlayerAvatar player, float invincible)
		{
			if ((Object)(object)player == (Object)null)
			{
				return;
			}
			if (Plugin.PlayReviveEffect.Value && (Object)(object)player.playerReviveEffects != (Object)null)
			{
				try
				{
					player.playerReviveEffects.Trigger();
				}
				catch (Exception ex)
				{
					Plugin.Log.LogWarning((object)("Revive effect failed: " + ex.Message));
				}
			}
			LastStandShield.Attach(player, invincible);
			LastStandBanner.Announce(player);
		}
	}
	public class LastStandBanner : MonoBehaviour
	{
		private const float BigSeconds = 3f;

		private const float OtherSeconds = 4f;

		private static PlayerAvatar shownFor;

		private static float shownAt;

		private static bool isMe;

		private static string playerName;

		private GUIStyle big;

		private GUIStyle small;

		public static void Announce(PlayerAvatar player)
		{
			shownFor = player;
			shownAt = Time.time;
			isMe = Fields.IsMine(player);
			playerName = Fields.PlayerName.Invoke(player);
			if (string.IsNullOrEmpty(playerName))
			{
				playerName = "Someone";
			}
		}

		private void OnGUI()
		{
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0202: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: 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)
			if (!Plugin.ShowBanner.Value || (Object)(object)shownFor == (Object)null)
			{
				return;
			}
			float num = Time.time - shownAt;
			MakeStyles();
			if (isMe)
			{
				if (!LastStandState.IsBuffed(shownFor))
				{
					shownFor = null;
					return;
				}
				if (num < 3f)
				{
					float num2 = ((num < 0.25f) ? Mathf.Lerp(2f, 1f, num / 0.25f) : 1f);
					float num3 = ((num > 2.4f) ? ((3f - num) / 0.6f) : 1f);
					big.fontSize = Mathf.RoundToInt((float)Screen.height / 9f * num2);
					Outlined(new Rect(0f, (float)Screen.height * 0.18f, (float)Screen.width, (float)Screen.height * 0.2f), "LAST STANDING!", big, new Color(1f, 0.82f, 0.2f, num3));
				}
				Outlined(new Rect(0f, (float)Screen.height * 0.08f, (float)Screen.width, (float)Screen.height * 0.06f), color: new Color(1f, 0.82f, 0.2f, 0.8f + 0.2f * Mathf.Sin(Time.time * 3f)), text: (!SemiFunc.IsMultiplayer()) ? "LAST STANDING" : "LAST STANDING  —  REVIVE YOUR TEAM", style: small);
			}
			else if (num > 4f)
			{
				shownFor = null;
			}
			else
			{
				float num4 = ((num > 3.2f) ? ((4f - num) / 0.8f) : 1f);
				Outlined(new Rect(0f, (float)Screen.height * 0.12f, (float)Screen.width, (float)Screen.height * 0.08f), playerName.ToUpper() + " IS LAST STANDING!", small, new Color(1f, 0.82f, 0.2f, num4));
			}
		}

		private void MakeStyles()
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			if (big == null)
			{
				big = new GUIStyle(GUI.skin.label)
				{
					alignment = (TextAnchor)4,
					fontStyle = (FontStyle)1
				};
				small = new GUIStyle(big)
				{
					fontSize = Mathf.Max(18, Screen.height / 28)
				};
			}
		}

		private static void Outlined(Rect r, string text, GUIStyle style, Color color)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: 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_0098: 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_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			Color textColor = default(Color);
			((Color)(ref textColor))..ctor(0f, 0f, 0f, color.a * 0.85f);
			style.normal.textColor = textColor;
			Vector2[] array = (Vector2[])(object)new Vector2[5]
			{
				new Vector2(-2f, 0f),
				new Vector2(2f, 0f),
				new Vector2(0f, -2f),
				new Vector2(0f, 2f),
				new Vector2(3f, 3f)
			};
			foreach (Vector2 val in array)
			{
				GUI.Label(new Rect(((Rect)(ref r)).x + val.x, ((Rect)(ref r)).y + val.y, ((Rect)(ref r)).width, ((Rect)(ref r)).height), text, style);
			}
			style.normal.textColor = color;
			GUI.Label(r, text, style);
		}
	}
	public class LastStandShield : MonoBehaviour
	{
		private static readonly Color ShieldColor = new Color(0.35f, 0.85f, 1f);

		private PlayerAvatar player;

		private bool local;

		private float duration;

		private float timeLeft;

		private Material material;

		public static void Attach(PlayerAvatar player, float seconds)
		{
			LastStandShield[] array = Object.FindObjectsByType<LastStandShield>((FindObjectsSortMode)0);
			foreach (LastStandShield lastStandShield in array)
			{
				if ((Object)(object)lastStandShield.player == (Object)(object)player)
				{
					lastStandShield.Restart(seconds);
					return;
				}
			}
			GameObject val = GameObject.CreatePrimitive((PrimitiveType)0);
			((Object)val).name = "Last Stand Shield";
			Object.Destroy((Object)(object)val.GetComponent<Collider>());
			LastStandShield lastStandShield2 = val.AddComponent<LastStandShield>();
			lastStandShield2.player = player;
			lastStandShield2.local = Fields.IsMine(player);
			lastStandShield2.material = MakeMaterial(val.GetComponent<Renderer>());
			lastStandShield2.Restart(seconds);
			lastStandShield2.LateUpdate();
		}

		private void Restart(float seconds)
		{
			duration = Mathf.Max(0.1f, seconds);
			timeLeft = duration;
		}

		private static Material MakeMaterial(Renderer renderer)
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			Shader val = Shader.Find("Sprites/Default") ?? Shader.Find("UI/Default") ?? Shader.Find("Unlit/Transparent");
			Material result = (renderer.material = (Material)((!((Object)(object)val != (Object)null)) ? ((object)renderer.material) : ((object)new Material(val))));
			renderer.shadowCastingMode = (ShadowCastingMode)0;
			renderer.receiveShadows = false;
			return result;
		}

		private void LateUpdate()
		{
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00de: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a4: Unknown result type (might be due to invalid IL or missing references)
			timeLeft -= Time.deltaTime;
			if ((Object)(object)player == (Object)null || timeLeft <= 0f || Fields.DeadSet.Invoke(player))
			{
				Object.Destroy((Object)(object)((Component)this).gameObject);
				return;
			}
			Camera main = Camera.main;
			if (local && (Object)(object)main != (Object)null)
			{
				((Component)this).transform.position = ((Component)main).transform.position;
				((Component)this).transform.localScale = Vector3.one * 1.4f;
			}
			else
			{
				Transform val = (((Object)(object)player.playerAvatarVisuals != (Object)null) ? ((Component)player.playerAvatarVisuals).transform : ((Component)player).transform);
				((Component)this).transform.position = val.position + Vector3.up * 0.9f;
				((Component)this).transform.localScale = Vector3.one * 2.2f;
			}
			float num = timeLeft / duration;
			float num2 = 0.85f + 0.15f * Mathf.Sin(Time.time * 8f);
			float num3 = ((!(timeLeft < 1f)) ? 1f : ((Mathf.Sin(Time.time * 40f) > 0f) ? 1f : 0.4f));
			float num4 = Plugin.ShieldOpacity.Value * num * num2 * num3;
			if (local)
			{
				num4 *= 0.5f;
			}
			Color shieldColor = ShieldColor;
			shieldColor.a = num4;
			material.color = shieldColor;
		}

		private void OnDestroy()
		{
			if ((Object)(object)material != (Object)null)
			{
				Object.Destroy((Object)(object)material);
			}
		}
	}
}
namespace Patpack.FasterStaminaRegen
{
	internal static class Plugin
	{
		public const string Guid = "FasterStaminaRegen";

		public const string Name = "Faster Stamina Regen";

		public const string Version = "1.0.0";

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<float> RegenMultiplier;

		internal static ConfigEntry<float> RegenDelay;

		internal static void Init(ModuleConfig Config, ManualLogSource Logger)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_007c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			Enabled = Config.Bind("General", "Enabled", defaultValue: true, "Faster stamina regen. Only affects your own player, so each player installs it for themselves.");
			RegenMultiplier = Config.Bind("General", "Regen Speed Multiplier", 2f, new ConfigDescription("How much faster stamina refills. 1 = vanilla, 2 = twice as fast.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(1f, 10f), Array.Empty<object>()));
			RegenDelay = Config.Bind("General", "Regen Delay Seconds", 0.5f, new ConfigDescription("Wait after you stop sprinting before stamina starts refilling. Vanilla is 1.", (AcceptableValueBase)(object)new AcceptableValueRange<float>(0f, 3f), Array.Empty<object>()));
			Logger.LogInfo((object)"Faster Stamina Regen 1.0.0 loaded.");
		}
	}
	[HarmonyPatch(typeof(PlayerController), "Update")]
	internal static class RegenPatch
	{
		private static readonly FieldRef<PlayerController, float> RechargeAmount = AccessTools.FieldRefAccess<PlayerController, float>("sprintRechargeAmount");

		private static readonly FieldRef<PlayerController, float> RechargeTime = AccessTools.FieldRefAccess<PlayerController, float>("sprintRechargeTime");

		private static PlayerController seen;

		private static float baseAmount;

		private static float baseTime;

		private static void Prefix(PlayerController __instance)
		{
			if ((Object)(object)__instance != (Object)(object)seen)
			{
				seen = __instance;
				baseAmount = RechargeAmount.Invoke(__instance);
				baseTime = RechargeTime.Invoke(__instance);
			}
			bool value = Plugin.Enabled.Value;
			RechargeAmount.Invoke(__instance) = (value ? (baseAmount * Plugin.RegenMultiplier.Value) : baseAmount);
			RechargeTime.Invoke(__instance) = (value ? Plugin.RegenDelay.Value : baseTime);
		}
	}
}
namespace Patpack.ExtractionNoHeightLimit
{
	internal static class Plugin
	{
		public const string Guid = "ExtractionNoHeightLimit";

		public const string Name = "Extraction No Height Limit";

		public const string Version = "1.0.0";

		internal static ManualLogSource Log;

		internal static ConfigEntry<bool> Enabled;

		internal static ConfigEntry<bool> StopAtCeiling;

		internal static ConfigEn