Decompiled source of MiscFixes v1.5.0

MiscFixes.dll

Decompiled 31 minutes ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using EntityStates;
using EntityStates.BrotherMonster;
using EntityStates.ChildMonster;
using EntityStates.Duplicator;
using EntityStates.FalseSon;
using EntityStates.Halcyonite;
using EntityStates.Huntress.Weapon;
using EntityStates.LunarExploderMonster;
using EntityStates.MinorConstruct;
using EntityStates.Scrapper;
using EntityStates.VoidCamp;
using Facepunch.Steamworks;
using HG;
using HG.GeneralSerializer;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using MiscFixes.ErrorPolice;
using MiscFixes.ErrorPolice.Harmony;
using MiscFixes.Modules;
using Mono.Cecil;
using Mono.Cecil.Cil;
using MonoMod.Cil;
using Rewired;
using RiskOfOptions;
using RiskOfOptions.OptionConfigs;
using RiskOfOptions.Options;
using RoR2;
using RoR2.Achievements;
using RoR2.CharacterAI;
using RoR2.ContentManagement;
using RoR2.Items;
using RoR2.Navigation;
using RoR2.Orbs;
using RoR2.Projectile;
using RoR2.Stats;
using RoR2.UI;
using RoR2BepInExPack.GameAssetPaths;
using TMPro;
using UnityEngine;
using UnityEngine.AddressableAssets;
using UnityEngine.EventSystems;
using UnityEngine.Networking;
using UnityEngine.Rendering;
using UnityEngine.ResourceManagement.AsyncOperations;

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

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace MiscFixes
{
	[BepInPlugin("_score.MiscFixes", "MiscFixes", "1.5.0")]
	public class MiscFixesPlugin : BaseUnityPlugin
	{
		public const string PluginGUID = "_score.MiscFixes";

		public const string PluginAuthor = "score";

		public const string PluginName = "MiscFixes";

		public const string PluginVersion = "1.5.0";

		private Harmony harmonyPatcher;

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

		private void Awake()
		{
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			AssetFixes.Init();
			harmonyPatcher = new Harmony("_score.MiscFixes");
			harmonyPatcher.CreateClassProcessor(typeof(MemOpFixes)).Patch();
			harmonyPatcher.CreateClassProcessor(typeof(PermanentFixes)).Patch();
			harmonyPatcher.CreateClassProcessor(typeof(ServerCommandsOnClient)).Patch();
			harmonyPatcher.CreateClassProcessor(typeof(VanillaFixes)).Patch();
		}

		private void OnDestroy()
		{
			Harmony obj = harmonyPatcher;
			if (obj != null)
			{
				obj.UnpatchSelf();
			}
		}
	}
}
namespace MiscFixes.Modules
{
	public static class Extensions
	{
		[Flags]
		public enum ConfigFlags : byte
		{
			None = 0,
			RestartRequired = 1,
			ClientSided = 2,
			ServerSided = 4
		}

		private static readonly StringBuilder _sb = new StringBuilder();

		public static void EmitNetworkServerActive(this ILCursor cursor)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			cursor.Emit<NetworkServer>(OpCodes.Call, "get_active");
		}

		public static void EmitOpImplicit(this ILCursor c)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			c.Emit<Object>(OpCodes.Call, "op_Implicit");
		}

		public static bool MatchNetworkServerActive(this Instruction instr)
		{
			return ILPatternMatchingExt.MatchCallOrCallvirt<NetworkServer>(instr, "get_active");
		}

		public static bool MatchOpImplicit(this Instruction instr)
		{
			return ILPatternMatchingExt.MatchCallOrCallvirt<Object>(instr, "op_Implicit");
		}

		public static bool MatchAny(this Instruction instr, out Instruction instruction)
		{
			instruction = instr;
			return true;
		}

		private static string BuildDescription(string name, string description, string defaultValue, ConfigFlags flags)
		{
			if (string.IsNullOrEmpty(description))
			{
				description = name;
			}
			_sb.Append(description + " (Default: " + defaultValue + ")");
			if ((flags & ConfigFlags.RestartRequired) != 0)
			{
				_sb.Append(" (Restart Required)");
			}
			if ((flags & ConfigFlags.ClientSided) != 0)
			{
				_sb.Append(" (Client-Sided)");
			}
			if ((flags & ConfigFlags.ServerSided) != 0)
			{
				_sb.Append(" (Server-Sided)");
			}
			return StringBuilderExtensions.Take(_sb).Replace("'", string.Empty);
		}

		public static void WipeConfig(this ConfigFile cfg)
		{
			if (typeof(ConfigFile).GetProperty("OrphanedEntries", (BindingFlags)(-1))?.GetValue(cfg) is Dictionary<ConfigDefinition, string> dictionary)
			{
				dictionary.Clear();
			}
			cfg.Save();
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static ConfigEntry<T> BindOption<T>(this ConfigFile myConfig, string section, string name, string description, T defaultValue, ConfigFlags flags = ConfigFlags.None)
		{
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Expected O, but got Unknown
			description = BuildDescription(name, description, defaultValue?.ToString(), flags);
			ConfigEntry<T> val = myConfig.Bind<T>(section, name, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()));
			try
			{
				if (MiscFixesPlugin.RooInstalled)
				{
					Assembly.GetCallingAssembly().GetModMetaDataSafe(out var guid, out var name2);
					val.TryRegisterOption<T>((flags & ConfigFlags.RestartRequired) != 0, guid, name2);
				}
			}
			catch (Exception data)
			{
				Log.Error(data);
			}
			return val;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static ConfigEntry<T> BindOption<T>(this ConfigFile myConfig, string section, string name, string description, T defaultValue, T[] acceptableValues, ConfigFlags flags = ConfigFlags.None) where T : IEquatable<T>
		{
			//IL_0046: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			description = BuildDescription(name, description, defaultValue?.ToString(), flags);
			AcceptableValueBase val = null;
			if (acceptableValues != null && acceptableValues.Length != 0)
			{
				val = (AcceptableValueBase)(object)new AcceptableValueList<T>(Array.Empty<T>());
			}
			ConfigEntry<T> val2 = myConfig.Bind<T>(section, name, defaultValue, new ConfigDescription(description, val, Array.Empty<object>()));
			try
			{
				if (MiscFixesPlugin.RooInstalled)
				{
					Assembly.GetCallingAssembly().GetModMetaDataSafe(out var guid, out var name2);
					val2.TryRegisterOption<T>((flags & ConfigFlags.RestartRequired) != 0, guid, name2);
				}
			}
			catch (Exception data)
			{
				Log.Error(data);
			}
			return val2;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static ConfigEntry<T> BindOptionSlider<T>(this ConfigFile myConfig, string section, string name, string description, T defaultValue, ConfigFlags flags = ConfigFlags.None)
		{
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Expected O, but got Unknown
			description = BuildDescription(name, description, defaultValue.ToString(), flags);
			ConfigEntry<T> val = myConfig.Bind<T>(section, name, defaultValue, new ConfigDescription(description, (AcceptableValueBase)null, Array.Empty<object>()));
			try
			{
				if (MiscFixesPlugin.RooInstalled)
				{
					Assembly.GetCallingAssembly().GetModMetaDataSafe(out var guid, out var name2);
					val.TryRegisterOptionSlider<T>((flags & ConfigFlags.RestartRequired) != 0, guid, name2);
				}
			}
			catch (Exception data)
			{
				Log.Error(data);
			}
			return val;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static ConfigEntry<T> BindOptionSlider<T>(this ConfigFile myConfig, string section, string name, string description, T defaultValue, T min, T max, ConfigFlags flags = ConfigFlags.None) where T : IComparable
		{
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			description = BuildDescription(name, description, defaultValue.ToString(), flags);
			ConfigEntry<T> val = myConfig.Bind<T>(section, name, defaultValue, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<T>(min, max), Array.Empty<object>()));
			try
			{
				if (MiscFixesPlugin.RooInstalled)
				{
					Assembly.GetCallingAssembly().GetModMetaDataSafe(out var guid, out var name2);
					val.TryRegisterOptionSlider<T>((flags & ConfigFlags.RestartRequired) != 0, guid, name2);
				}
			}
			catch (Exception data)
			{
				Log.Error(data);
			}
			return val;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static ConfigEntry<float> BindOptionSteppedSlider(this ConfigFile myConfig, string section, string name, string description, float defaultValue, float increment, float min = 0f, float max = 100f, ConfigFlags flags = ConfigFlags.None)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0030: Expected O, but got Unknown
			description = BuildDescription(name, description, defaultValue.ToString(), flags);
			ConfigEntry<float> val = myConfig.Bind<float>(section, name, defaultValue, new ConfigDescription(description, (AcceptableValueBase)(object)new AcceptableValueRange<float>(min, max), Array.Empty<object>()));
			try
			{
				if (MiscFixesPlugin.RooInstalled)
				{
					Assembly.GetCallingAssembly().GetModMetaDataSafe(out var guid, out var name2);
					val.TryRegisterOptionSteppedSlider(increment, min, max, (flags & ConfigFlags.RestartRequired) != 0, guid, name2);
				}
			}
			catch (Exception data)
			{
				Log.Error(data);
			}
			return val;
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void TryRegisterOption<T>(this ConfigEntry<T> entry, bool restartRequired = false, string modGuid = null, string modName = null)
		{
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Expected O, but got Unknown
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Expected O, but got Unknown
			if (modGuid == null && modName == null)
			{
				Assembly.GetCallingAssembly().GetModMetaDataSafe(out modGuid, out modName);
			}
			if (entry is ConfigEntry<string> val)
			{
				ModSettingsManager.AddOption((BaseOption)new StringInputFieldOption(val, new InputFieldConfig
				{
					lineType = (LineType)0,
					submitOn = (SubmitEnum)6,
					restartRequired = restartRequired
				}), modGuid, modName);
				return;
			}
			if (entry is ConfigEntry<bool> val2)
			{
				ModSettingsManager.AddOption((BaseOption)new CheckBoxOption(val2, restartRequired), modGuid, modName);
				return;
			}
			if (entry is ConfigEntry<KeyboardShortcut> val3)
			{
				ModSettingsManager.AddOption((BaseOption)new KeyBindOption(val3, restartRequired), modGuid, modName);
				return;
			}
			if (typeof(T).IsEnum)
			{
				ModSettingsManager.AddOption((BaseOption)new ChoiceOption((ConfigEntryBase)(object)entry, restartRequired), modGuid, modName);
				return;
			}
			Log.Error("Config entry " + ((ConfigEntryBase)entry).Definition.Key + " in section " + ((ConfigEntryBase)entry).Definition.Section + " with type " + typeof(T).Name + " could not be registered in Risk Of Options using TryRegisterOption.");
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void TryRegisterOptionSlider<T>(this ConfigEntry<T> entry, bool restartRequired = false, string modGuid = null, string modName = null)
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Expected O, but got Unknown
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Expected O, but got Unknown
			if (modGuid == null && modName == null)
			{
				Assembly.GetCallingAssembly().GetModMetaDataSafe(out modGuid, out modName);
			}
			if (entry is ConfigEntry<int> val)
			{
				IntSliderConfig val2 = new IntSliderConfig
				{
					formatString = "{0:0.00}",
					restartRequired = restartRequired
				};
				if (((ConfigEntryBase)entry).Description.AcceptableValues is AcceptableValueRange<int> val3)
				{
					val2.min = val3.MinValue;
					val2.max = val3.MaxValue;
				}
				ModSettingsManager.AddOption((BaseOption)new IntSliderOption(val, val2), modGuid, modName);
			}
			else if (entry is ConfigEntry<float> val4)
			{
				SliderConfig val5 = new SliderConfig
				{
					FormatString = "{0:0.00}",
					restartRequired = restartRequired
				};
				if (((ConfigEntryBase)entry).Description.AcceptableValues is AcceptableValueRange<float> val6)
				{
					val5.min = val6.MinValue;
					val5.max = val6.MaxValue;
				}
				ModSettingsManager.AddOption((BaseOption)new SliderOption(val4, val5), modGuid, modName);
			}
			else
			{
				Log.Error("Config entry " + ((ConfigEntryBase)entry).Definition.Key + " in section " + ((ConfigEntryBase)entry).Definition.Section + " with type " + typeof(T).Name + " could not be registered in Risk Of Options using TryRegisterOptionSlider.");
			}
		}

		[MethodImpl(MethodImplOptions.NoInlining | MethodImplOptions.NoOptimization)]
		public static void TryRegisterOptionSteppedSlider(this ConfigEntry<float> entry, float increment, float min, float max, bool restartRequired = false, string modGuid = null, string modName = null)
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: 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_004e: Expected O, but got Unknown
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Expected O, but got Unknown
			if (entry != null)
			{
				if (modGuid == null && modName == null)
				{
					Assembly.GetCallingAssembly().GetModMetaDataSafe(out modGuid, out modName);
				}
				ModSettingsManager.AddOption((BaseOption)new StepSliderOption(entry, new StepSliderConfig
				{
					increment = increment,
					min = min,
					max = max,
					FormatString = "{0:0.00}",
					restartRequired = restartRequired
				}), modGuid, modName);
			}
			else
			{
				Log.Error("Config entry " + ((ConfigEntryBase)entry).Definition.Key + " in section " + ((ConfigEntryBase)entry).Definition.Section + " with type " + typeof(float).Name + " could not be registered in Risk Of Options using TryRegisterOptionSteppedSlider.");
			}
		}

		public static T GetOrAddComponent<T>(this Component obj) where T : Component
		{
			T result = default(T);
			if (Object.op_Implicit((Object)(object)obj) && !obj.TryGetComponent<T>(ref result))
			{
				return obj.gameObject.AddComponent<T>();
			}
			return result;
		}

		public static T GetOrAddComponent<T>(this GameObject obj) where T : Component
		{
			T result = default(T);
			if (Object.op_Implicit((Object)(object)obj) && !obj.TryGetComponent<T>(ref result))
			{
				return obj.AddComponent<T>();
			}
			return result;
		}

		public static void TryDestroyComponent<T>(this GameObject obj) where T : Component
		{
			T val = default(T);
			if (Object.op_Implicit((Object)(object)obj) && obj.TryGetComponent<T>(ref val))
			{
				Object.Destroy((Object)(object)val);
			}
		}

		public static void TryDestroyComponent<T>(this Component obj) where T : Component
		{
			T val = default(T);
			if (Object.op_Implicit((Object)(object)obj) && obj.TryGetComponent<T>(ref val))
			{
				Object.Destroy((Object)(object)val);
			}
		}

		public static void TryDestroyAllComponents<T>(this GameObject obj) where T : Component
		{
			if (Object.op_Implicit((Object)(object)obj))
			{
				T[] components = obj.GetComponents<T>();
				for (int i = 0; i < components.Length; i++)
				{
					Object.Destroy((Object)(object)components[i]);
				}
			}
		}

		public static void TryDestroyAllComponents<T>(this Component obj) where T : Component
		{
			if (Object.op_Implicit((Object)(object)obj))
			{
				T[] components = obj.GetComponents<T>();
				for (int num = components.Length - 1; num >= 0; num--)
				{
					Object.Destroy((Object)(object)components[num]);
				}
			}
		}

		public static T CloneComponent<T>(this GameObject go, T src) where T : Component
		{
			return go.AddComponent<T>().CloneFrom<T>(src);
		}

		public static T CloneFrom<T>(this T obj, T other) where T : Object
		{
			Type type = ((object)obj).GetType();
			if (type != ((object)other).GetType())
			{
				throw new TypeAccessException($"Type mismatch of {((object)obj)?.GetType()} and {((object)other)?.GetType()}");
			}
			BindingFlags bindingAttr = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;
			FieldInfo[] fields = type.GetFields(bindingAttr);
			foreach (FieldInfo fieldInfo in fields)
			{
				if (!(fieldInfo.DeclaringType == typeof(Object)) && !(fieldInfo.DeclaringType == typeof(Component)))
				{
					try
					{
						fieldInfo.SetValue(obj, fieldInfo.GetValue(other));
						Log.Debug($"Set field {fieldInfo.Name} to value of {fieldInfo.GetValue(obj)}");
					}
					catch (Exception data)
					{
						Log.Debug(data);
					}
				}
			}
			PropertyInfo[] properties = type.GetProperties(bindingAttr);
			foreach (PropertyInfo propertyInfo in properties)
			{
				if (!(propertyInfo.DeclaringType == typeof(Object)) && !(propertyInfo.DeclaringType == typeof(Component)) && propertyInfo.CanWrite && !(propertyInfo.DeclaringType == typeof(Object)))
				{
					try
					{
						propertyInfo.SetValue(obj, propertyInfo.GetValue(other));
						Log.Debug($"Set property {propertyInfo.Name} to value of {propertyInfo.GetValue(obj)}");
					}
					catch (Exception data2)
					{
						Log.Debug(data2);
					}
				}
			}
			return obj;
		}

		public static bool TryModifyFieldValue<T>(this EntityStateConfiguration entityStateConfiguration, string fieldName, T value)
		{
			ref SerializedField orCreateField = ref ((SerializedFieldCollection)(ref entityStateConfiguration.serializedFieldsCollection)).GetOrCreateField(fieldName);
			if (Object.op_Implicit(orCreateField.fieldValue.objectValue) && typeof(Object).IsAssignableFrom(typeof(T)))
			{
				ref Object objectValue = ref orCreateField.fieldValue.objectValue;
				object obj = value;
				objectValue = (Object)((obj is Object) ? obj : null);
				return true;
			}
			if (orCreateField.fieldValue.stringValue != null && StringSerializer.CanSerializeType(typeof(T)))
			{
				orCreateField.fieldValue.stringValue = StringSerializer.Serialize(typeof(T), (object)value);
				return true;
			}
			Log.Error("Failed to modify field " + fieldName);
			return false;
		}

		public static bool TryGetFieldValue<T>(this EntityStateConfiguration entityStateConfiguration, string fieldName, out T value) where T : Object
		{
			ref SerializedField orCreateField = ref ((SerializedFieldCollection)(ref entityStateConfiguration.serializedFieldsCollection)).GetOrCreateField(fieldName);
			if (Object.op_Implicit(orCreateField.fieldValue.objectValue) && typeof(Object).IsAssignableFrom(typeof(T)))
			{
				Object objectValue = orCreateField.fieldValue.objectValue;
				value = (T)(object)((objectValue is T) ? objectValue : null);
				return true;
			}
			if (!string.IsNullOrEmpty(orCreateField.fieldValue.stringValue))
			{
				Log.Error("Failed to return " + fieldName + " as an Object, try getting the string value instead.");
			}
			else
			{
				Log.Error("Field is null " + fieldName);
			}
			value = default(T);
			return false;
		}

		public static bool TryGetFieldValueString<T>(this EntityStateConfiguration entityStateConfiguration, string fieldName, out T value) where T : IEquatable<T>
		{
			ref SerializedField orCreateField = ref ((SerializedFieldCollection)(ref entityStateConfiguration.serializedFieldsCollection)).GetOrCreateField(fieldName);
			if (orCreateField.fieldValue.stringValue != null && StringSerializer.CanSerializeType(typeof(T)))
			{
				value = (T)StringSerializer.Deserialize(typeof(T), orCreateField.fieldValue.stringValue);
				return true;
			}
			if (Object.op_Implicit(orCreateField.fieldValue.objectValue))
			{
				Log.Error("Failed to return " + fieldName + " as a string, try getting the Object value instead.");
			}
			else
			{
				Log.Error("Field is null " + fieldName);
			}
			value = default(T);
			return false;
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logSource;

		internal static void Init(ManualLogSource logSource)
		{
			_logSource = logSource;
		}

		internal static void Debug(object data)
		{
		}

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

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

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

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

		internal static void Warning(object data)
		{
			_logSource.LogWarning(data);
		}

		internal static void PatchFail(string method)
		{
			_logSource.LogWarning((object)("Failed to patch " + method));
		}

		internal static void PatchFail(ILContext il)
		{
			PatchFail(((MemberReference)il.Method).Name);
		}
	}
	internal static class Utils
	{
		internal static AsyncOperationHandle<T> PreloadAsset<T>(AssetReferenceT<T> reference) where T : Object
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			return AssetAsyncReferenceManager<T>.LoadAsset(reference, (AsyncReferenceHandleUnloadType)0);
		}

		internal static void UnloadAsset<T>(AssetReferenceT<T> reference) where T : Object
		{
			AssetAsyncReferenceManager<T>.UnloadAsset(reference);
		}

		internal static void GetModMetaDataSafe(this Assembly assembly, out string guid, out string name)
		{
			guid = "";
			name = "";
			Type[] types = assembly.GetTypes();
			for (int i = 0; i < types.Length; i++)
			{
				BepInPlugin customAttribute = ((MemberInfo)types[i]).GetCustomAttribute<BepInPlugin>();
				if (customAttribute != null)
				{
					guid = customAttribute.GUID;
					name = customAttribute.Name;
				}
			}
		}
	}
}
namespace MiscFixes.ErrorPolice
{
	internal static class AssetFixes
	{
		internal static void Init()
		{
			FixElderLemurianFootstepEvents();
			FixSaleStarCollider();
			MoreHudChildLocEntries();
			FixHenry();
			FixScrapper();
			FixVermin();
		}

		private static void FixVermin()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			AssetReferenceGameObject ref1 = new AssetReferenceGameObject(RoR2_DLC1_Vermin.VerminSpawn_prefab);
			AsyncOperationHandle<GameObject> val = Utils.PreloadAsset<GameObject>((AssetReferenceT<GameObject>)(object)ref1);
			val.Completed += delegate(AsyncOperationHandle<GameObject> obj)
			{
				obj.Result.GetComponent<EffectComponent>().positionAtReferencedTransform = true;
				Utils.UnloadAsset<GameObject>((AssetReferenceT<GameObject>)(object)ref1);
			};
		}

		private static void FixScrapper()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			AssetReferenceGameObject bodyRef = new AssetReferenceGameObject(RoR2_Base_Toolbot.ToolbotBody_prefab);
			AssetReferenceGameObject scrapRef = new AssetReferenceGameObject(RoR2_Base_Scrapper.Scrapper_prefab);
			AsyncOperationHandle<GameObject> val = Utils.PreloadAsset<GameObject>((AssetReferenceT<GameObject>)(object)bodyRef);
			val.Completed += delegate(AsyncOperationHandle<GameObject> toolbotBody)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_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)
				AsyncOperationHandle<GameObject> val2 = Utils.PreloadAsset<GameObject>((AssetReferenceT<GameObject>)(object)scrapRef);
				val2.Completed += delegate(AsyncOperationHandle<GameObject> scrapper)
				{
					scrapper.Result.CloneComponent<AkBank>(toolbotBody.Result.GetComponent<AkBank>());
					Log.Debug("Added AkBank to scrapper");
					Utils.UnloadAsset<GameObject>((AssetReferenceT<GameObject>)(object)bodyRef);
					Utils.UnloadAsset<GameObject>((AssetReferenceT<GameObject>)(object)scrapRef);
				};
			};
		}

		private static void FixHenry()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			AssetReferenceGameObject bodyRef = new AssetReferenceGameObject(RoR2_Base_Commando.CommandoBody_prefab);
			AssetReferenceT<Material> matRef = new AssetReferenceT<Material>(RoR2_Base_Commando.matCommandoDualies_mat);
			AsyncOperationHandle<GameObject> val = Utils.PreloadAsset<GameObject>((AssetReferenceT<GameObject>)(object)bodyRef);
			val.Completed += delegate(AsyncOperationHandle<GameObject> bodyHandle)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				//IL_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)
				AsyncOperationHandle<Material> val2 = Utils.PreloadAsset<Material>(matRef);
				val2.Completed += delegate(AsyncOperationHandle<Material> matHandle)
				{
					//IL_003a: Unknown result type (might be due to invalid IL or missing references)
					//IL_005d: Unknown result type (might be due to invalid IL or missing references)
					//IL_0062: Unknown result type (might be due to invalid IL or missing references)
					//IL_0063: Unknown result type (might be due to invalid IL or missing references)
					//IL_006c: Unknown result type (might be due to invalid IL or missing references)
					//IL_008f: Unknown result type (might be due to invalid IL or missing references)
					//IL_0094: Unknown result type (might be due to invalid IL or missing references)
					//IL_0095: Unknown result type (might be due to invalid IL or missing references)
					//IL_009e: Unknown result type (might be due to invalid IL or missing references)
					//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
					//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
					//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
					ModelLocator component = bodyHandle.Result.GetComponent<ModelLocator>();
					ChildLocator component2 = ((Component)component.modelTransform).GetComponent<ChildLocator>();
					Material result = matHandle.Result;
					((Component)component.modelTransform).GetComponent<CharacterModel>().baseRendererInfos = (RendererInfo[])(object)new RendererInfo[3]
					{
						new RendererInfo
						{
							renderer = (Renderer)(object)component2.FindChildComponent<MeshRenderer>("GunMeshL"),
							defaultMaterial = result,
							defaultShadowCastingMode = (ShadowCastingMode)1
						},
						new RendererInfo
						{
							renderer = (Renderer)(object)component2.FindChildComponent<MeshRenderer>("GunMeshR"),
							defaultMaterial = result,
							defaultShadowCastingMode = (ShadowCastingMode)1
						},
						new RendererInfo
						{
							renderer = (Renderer)(object)((Component)component.modelTransform.Find("CommandoMesh")).GetComponent<SkinnedMeshRenderer>(),
							defaultMaterial = result,
							defaultShadowCastingMode = (ShadowCastingMode)1
						}
					};
					Log.Debug("Commando baseRendererInfos done");
					Utils.UnloadAsset<GameObject>((AssetReferenceT<GameObject>)(object)bodyRef);
					Utils.UnloadAsset<Material>(matRef);
				};
			};
		}

		public static void FixElderLemurianFootstepEvents()
		{
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			AssetReferenceT<RuntimeAnimatorController> animRef = new AssetReferenceT<RuntimeAnimatorController>(RoR2_Base_Lemurian.animLemurianBruiser_controller);
			AsyncOperationHandle<RuntimeAnimatorController> val = Utils.PreloadAsset<RuntimeAnimatorController>(animRef);
			val.Completed += delegate(AsyncOperationHandle<RuntimeAnimatorController> animHandle)
			{
				RuntimeAnimatorController anim = animHandle.Result;
				PatchClip(4, "LemurianBruiserArmature|RunRight", 1, "", "FootR");
				PatchClip(12, "LemurianBruiserArmature|Death", 2, "MouthMuzzle", "MuzzleMouth");
				Log.Debug("Elder lemurian footsteps done");
				Utils.UnloadAsset<RuntimeAnimatorController>(animRef);
				void PatchClip(int clipIndex, string clipName, int eventIndex, string oldEventString, string newEventString)
				{
					if (anim.animationClips.Length > clipIndex && ((Object)anim.animationClips[clipIndex]).name == clipName)
					{
						AnimationClip val2 = anim.animationClips[clipIndex];
						if (val2.events.Length > eventIndex && val2.events[eventIndex].stringParameter == oldEventString)
						{
							AnimationEvent[] events = val2.events;
							events[eventIndex].stringParameter = newEventString;
							val2.events = events;
							return;
						}
					}
					Log.PatchFail(((Object)anim).name + " - " + clipName);
				}
			};
		}

		public static void FixSaleStarCollider()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			AssetReferenceGameObject objRef = new AssetReferenceGameObject(RoR2_DLC2_Items_LowerPricedChests.PickupSaleStar_prefab);
			AsyncOperationHandle<GameObject> val = Utils.PreloadAsset<GameObject>((AssetReferenceT<GameObject>)(object)objRef);
			val.Completed += delegate(AsyncOperationHandle<GameObject> objHandle)
			{
				Transform obj = objHandle.Result.transform.Find("SaleStar");
				MeshCollider val2 = ((obj != null) ? ((Component)obj).GetComponent<MeshCollider>() : null);
				if ((Object)(object)val2 == (Object)null || val2.convex)
				{
					Log.PatchFail("collider of SaleStar");
				}
				else
				{
					val2.convex = true;
					Log.Debug("SaleStar Collider done");
					Utils.UnloadAsset<GameObject>((AssetReferenceT<GameObject>)(object)objRef);
				}
			};
		}

		public static void MoreHudChildLocEntries()
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			AssetReferenceGameObject objRef = new AssetReferenceGameObject(RoR2_Base_UI.HUDSimple_prefab);
			AsyncOperationHandle<GameObject> val = Utils.PreloadAsset<GameObject>((AssetReferenceT<GameObject>)(object)objRef);
			val.Completed += delegate(AsyncOperationHandle<GameObject> objHandle)
			{
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_005c: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0067: Unknown result type (might be due to invalid IL or missing references)
				//IL_008b: Unknown result type (might be due to invalid IL or missing references)
				//IL_008d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0096: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
				//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00eb: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
				//IL_0118: Unknown result type (might be due to invalid IL or missing references)
				//IL_011a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0123: Unknown result type (might be due to invalid IL or missing references)
				//IL_0147: Unknown result type (might be due to invalid IL or missing references)
				//IL_0149: Unknown result type (might be due to invalid IL or missing references)
				//IL_0152: Unknown result type (might be due to invalid IL or missing references)
				//IL_0176: Unknown result type (might be due to invalid IL or missing references)
				//IL_0178: Unknown result type (might be due to invalid IL or missing references)
				//IL_0181: Unknown result type (might be due to invalid IL or missing references)
				//IL_01af: Unknown result type (might be due to invalid IL or missing references)
				//IL_01b1: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
				//IL_01de: Unknown result type (might be due to invalid IL or missing references)
				//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
				//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
				//IL_020e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0210: Unknown result type (might be due to invalid IL or missing references)
				//IL_021a: Unknown result type (might be due to invalid IL or missing references)
				//IL_023e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0240: Unknown result type (might be due to invalid IL or missing references)
				//IL_024a: Unknown result type (might be due to invalid IL or missing references)
				//IL_026e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0270: Unknown result type (might be due to invalid IL or missing references)
				HUD component = objHandle.Result.GetComponent<HUD>();
				ChildLocator component2 = ((Component)component).GetComponent<ChildLocator>();
				Transform val2 = component.mainUIPanel.transform.Find("SpringCanvas");
				List<NameTransformPair> list = component2.transformPairs.ToList();
				list.AddRange(new <>z__ReadOnlyArray<NameTransformPair>((NameTransformPair[])(object)new NameTransformPair[12]
				{
					new NameTransformPair
					{
						name = "SpringCanvas",
						transform = val2
					},
					new NameTransformPair
					{
						name = "UpperRightCluster",
						transform = val2.Find("UpperRightCluster")
					},
					new NameTransformPair
					{
						name = "BottomRightCluster",
						transform = val2.Find("BottomRightCluster")
					},
					new NameTransformPair
					{
						name = "UpperLeftCluster",
						transform = val2.Find("UpperLeftCluster")
					},
					new NameTransformPair
					{
						name = "BottomCenterCluster",
						transform = val2.Find("BottomCenterCluster")
					},
					new NameTransformPair
					{
						name = "LeftCluster",
						transform = val2.Find("LeftCluster")
					},
					new NameTransformPair
					{
						name = "RightCluster",
						transform = val2.Find("RightCluster")
					},
					new NameTransformPair
					{
						name = "NotificationArea",
						transform = component.mainContainer.transform.Find("NotificationArea")
					},
					new NameTransformPair
					{
						name = "ScoreboardPanel",
						transform = val2.Find("ScoreboardPanel")
					},
					new NameTransformPair
					{
						name = "SkillDisplayRoot",
						transform = val2.Find("BottomRightCluster/Scaler")
					},
					new NameTransformPair
					{
						name = "BuffDisplayRoot",
						transform = val2.Find("BottomLeftCluster/BarRoots/LevelDisplayCluster/BuffDisplayRoot")
					},
					new NameTransformPair
					{
						name = "InventoryDisplayRoot",
						transform = val2.Find("TopCenterCluster/ItemInventoryDisplayRoot")
					}
				}));
				List<NameTransformPair> list2 = new List<NameTransformPair>();
				list2.AddRange(from pair in list
					group pair by pair.name into @group
					select @group.First());
				component2.transformPairs = list2.ToArray();
				Log.Debug("HUD Childlocator updated");
				Utils.UnloadAsset<GameObject>((AssetReferenceT<GameObject>)(object)objRef);
			};
		}
	}
}
namespace MiscFixes.ErrorPolice.Harmony
{
	[HarmonyPatch]
	public class MemOpFixes
	{
		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyILManipulator]
		public static void AssetOrDirectReference_Result(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			Instruction ret = null;
			int num = default(int);
			if (!val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloca(x, ref num),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(AsyncOperationHandle<Object>), "Result")),
				(Instruction x) => x.MatchAny(out ret)
			}))
			{
				Log.PatchFail(il);
				return;
			}
			int index = val.Index;
			val.Index = index + 1;
			ILLabel val2 = val.DefineLabel();
			val.Emit(OpCodes.Dup);
			val.Emit(OpCodes.Call, (MethodBase)AccessTools.Method(typeof(AsyncOperationHandle<Object>), "IsValid", (Type[])null, (Type[])null));
			val.Emit(OpCodes.Brtrue, (object)val2);
			val.Emit(OpCodes.Pop);
			val.Emit(OpCodes.Ldnull);
			val.Emit(OpCodes.Br, ret);
			val.MarkLabel(val2);
		}

		[HarmonyPatch(typeof(AssetAsyncReferenceManager<Object>), "OnSceneChanged")]
		[HarmonyILManipulator]
		public static void AssetAsyncReferenceManager_OnSceneChanged(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_007f: 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)
			ILCursor val = new ILCursor(il)
			{
				Index = il.Instrs.Count - 1
			};
			ILLabel leave = null;
			ILCursor[] array = default(ILCursor[]);
			if (!val.TryGotoPrev((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchEndfinally(x)
			}) || !val.TryFindPrev(ref array, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLeaveS(x, ref leave)
			}))
			{
				Log.PatchFail(il);
				return;
			}
			val.Emit(OpCodes.Ldsfld, AccessTools.Field(typeof(AssetAsyncReferenceManager<Object>), "PreloadedInMenuReferences"));
			val.Emit<List<string>>(OpCodes.Callvirt, "Clear");
			val.Index -= 2;
			val.MarkLabel(leave);
			((IEnumerable<ExceptionHandler>)il.Body.ExceptionHandlers).Last().HandlerEnd = leave.Target;
		}

		[HarmonyPatch(typeof(CharacterModel), "InstantiateDisplayRuleGroup")]
		[HarmonyILManipulator]
		public static void CharacterModel_InstantiateDisplayRuleGroup(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel label = null;
			if (!val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<ItemDisplayRule>(x, "followerPrefabAddress"),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<AssetReference>(x, "RuntimeKeyIsValid"),
				(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref label)
			}))
			{
				Log.PatchFail(il);
				return;
			}
			int index = val.Index;
			val.Index = index + 1;
			Instruction next = val.Next;
			val.Emit(OpCodes.Dup);
			val.Emit(OpCodes.Brtrue_S, next);
			val.Emit(OpCodes.Pop);
			val.Emit(OpCodes.Br, (object)label);
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		[HarmonyILManipulator]
		public static void ItemDisplayRuleSet_GenerateRuntimeValuesAsync(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			Instruction instr = null;
			FieldReference val6 = default(FieldReference);
			MethodReference val5 = default(MethodReference);
			ILLabel val4 = default(ILLabel);
			if (val.TryGotoNext((MoveType)1, new Func<Instruction, bool>[5]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld(x, ref val6),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, ref val5),
				(Instruction x) => ILPatternMatchingExt.MatchBrtrue(x, ref val4),
				(Instruction x) => x.MatchAny(out instr)
			}))
			{
				val.Emit(OpCodes.Br, instr);
			}
			FieldReference val3 = default(FieldReference);
			ILLabel val2 = default(ILLabel);
			if (!val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[5]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdflda(x, ref val3),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<KeyAssetRuleGroup>(x, "keyAssetAddress"),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<AssetReference>(x, "RuntimeKeyIsValid"),
				(Instruction x) => ILPatternMatchingExt.MatchBrtrue(x, ref val2),
				(Instruction x) => x.MatchAny(out instr)
			}))
			{
				Log.PatchFail(il);
				return;
			}
			int index = val.Index;
			val.Index = index + 1;
			index = val.Index;
			val.Index = index + 1;
			Instruction next = val.Next;
			val.Emit(OpCodes.Dup);
			val.Emit(OpCodes.Brtrue_S, next);
			val.Emit(OpCodes.Pop);
			val.Emit(OpCodes.Br, instr);
		}
	}
	[HarmonyPatch]
	public class PermanentFixes
	{
		[HarmonyPatch("RoR2.Stats.PlayerStatsComponent+<>c, RoR2, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null", "<Init>b__18_0")]
		[HarmonyPrefix]
		public static bool PlayerStatsComponent_Init(DamageReport damageReport)
		{
			return Object.op_Implicit((Object)(object)damageReport.victim);
		}

		[HarmonyPatch(typeof(InspectPanelController), "Show")]
		[HarmonyPrefix]
		public static bool InspectPanelController_Show(InspectPanelController __instance)
		{
			if (Object.op_Implicit((Object)(object)__instance.eventSystem))
			{
				LocalUser localUser = __instance.eventSystem.localUser;
				return ((localUser != null) ? localUser.userProfile : null) != null;
			}
			return false;
		}

		[HarmonyPatch(typeof(NormalizeParticleScale), "OnEnable")]
		[HarmonyPrefix]
		public static bool NormalizeParticleScale_OnEnable(NormalizeParticleScale __instance)
		{
			return !Object.op_Implicit((Object)(object)__instance.particleSystem);
		}

		[HarmonyPatch(typeof(BurnEffectController), "AddFireParticles")]
		[HarmonyPostfix]
		public static void BurnEffectController_AddFireParticles(NormalizeParticleScale __instance, ref BurnEffectControllerHelper __result, Renderer modelRenderer)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			if (Object.op_Implicit((Object)(object)__result) && Object.op_Implicit((Object)(object)modelRenderer))
			{
				Vector3 localScale = ((Component)modelRenderer).transform.localScale;
				float num = Vector3Utils.ComponentMax(ref localScale);
				if (num > 1f && Object.op_Implicit((Object)(object)__result.normalizeParticleScale) && Object.op_Implicit((Object)(object)__result.burnParticleSystem))
				{
					MainModule main = __result.burnParticleSystem.main;
					MinMaxCurve startSize = ((MainModule)(ref main)).startSize;
					((MinMaxCurve)(ref startSize)).constantMin = ((MinMaxCurve)(ref startSize)).constantMin / num;
					((MinMaxCurve)(ref startSize)).constantMax = ((MinMaxCurve)(ref startSize)).constantMax / num;
					((MainModule)(ref main)).startSize = startSize;
				}
			}
		}

		[HarmonyPatch(typeof(SurvivorIconController), "GetLocalUser")]
		[HarmonyPrefix]
		public static bool SurvivorIconController_GetLocalUser(SurvivorIconController __instance, ref LocalUser __result)
		{
			if (EventSystem.current is MPEventSystem)
			{
				return true;
			}
			__result = LocalUserManager.GetFirstLocalUser();
			return false;
		}

		[HarmonyPatch(typeof(TemporaryOverlayInstance), "SetupMaterial")]
		[HarmonyPrefix]
		public static void TemporaryOverlayInstance_SetupMaterial(TemporaryOverlayInstance __instance)
		{
			if (!Object.op_Implicit((Object)(object)__instance.originalMaterial) && Object.op_Implicit((Object)(object)__instance.componentReference) && __instance.ValidateOverlay())
			{
				__instance.componentReference.CopyDataFromPrefabToInstance();
			}
		}

		[HarmonyPatch(typeof(HalcyoniteShrineInteractable), "Awake")]
		[HarmonyPostfix]
		public static void HalcyoniteShrineInteractable_Awake(HalcyoniteShrineInteractable __instance)
		{
			__instance.goldDrainValue = Math.Max(1, __instance.goldDrainValue);
		}

		[HarmonyPatch(typeof(BaseSteamworks), "RunUpdateCallbacks")]
		[HarmonyFinalizer]
		public static Exception FixFacepunch()
		{
			return null;
		}

		[HarmonyPatch(typeof(FlickerLight), "OnEnable")]
		[HarmonyPrefix]
		public static void Ugh(FlickerLight __instance)
		{
			if (!Object.op_Implicit((Object)(object)__instance.light))
			{
				((Behaviour)__instance).enabled = false;
			}
		}

		[HarmonyPatch(typeof(MPEventSystem), "Update")]
		[HarmonyILManipulator]
		public static void FixThisFuckingBullshitGearbox(ILContext il)
		{
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			ILCursor[] array = null;
			if (new ILCursor(il).TryFindNext(ref array, new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCall(x, (MethodBase)AccessTools.PropertyGetter(typeof(EventSystem), "current")),
				(Instruction x) => ILPatternMatchingExt.MatchCall(x, (MethodBase)AccessTools.PropertySetter(typeof(EventSystem), "current"))
			}))
			{
				array[0].Remove();
				array[1].Remove();
			}
			else
			{
				Log.PatchFail(il);
			}
		}

		[HarmonyPatch(typeof(Idle), "FixedUpdate")]
		[HarmonyPatch(typeof(VoidCampObjectiveTracker), "GenerateString")]
		[HarmonyILManipulator]
		public static void FixVoidSeed(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			if (val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(ReadOnlyCollection<TeamComponent>), "Count"))
			}))
			{
				val.Remove();
				val.EmitDelegate<Func<ReadOnlyCollection<TeamComponent>, int>>((Func<ReadOnlyCollection<TeamComponent>, int>)GetValidTeamCount);
			}
			else
			{
				Log.PatchFail(il);
			}
		}

		private static int GetValidTeamCount(ReadOnlyCollection<TeamComponent> teamMembers)
		{
			return teamMembers.Count((TeamComponent t) => Object.op_Implicit((Object)(object)((t != null) ? t.body : null)) && Object.op_Implicit((Object)(object)t.body.master) && Object.op_Implicit((Object)(object)t.body.healthComponent));
		}
	}
	[HarmonyPatch]
	public class ServerCommandsOnClient
	{
		[HarmonyPatch(typeof(EnterSkyLeap), "OnEnter")]
		[HarmonyILManipulator]
		public static void FixEnterSkyLeapOnEnter(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			Instruction nextInstr = null;
			if (!val.TryGotoNext(new Func<Instruction, bool>[6]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(EntityState), "characterBody")),
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Buffs), "ArmorBoost"),
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld<EnterSkyLeap>(x, "baseDuration"),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(x, "AddTimedBuff"),
				(Instruction x) => x.MatchAny(out nextInstr)
			}))
			{
				Log.PatchFail(il);
				return;
			}
			val.EmitNetworkServerActive();
			val.Emit(OpCodes.Brfalse_S, nextInstr);
		}

		[HarmonyPatch(typeof(ExitSkyLeap), "OnEnter")]
		[HarmonyILManipulator]
		public static void FixExitSkyLeapOnEnter(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			Instruction nextInstr = null;
			if (!val.TryGotoNext(new Func<Instruction, bool>[6]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(EntityState), "characterBody")),
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Buffs), "ArmorBoost"),
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld<ExitSkyLeap>(x, "baseDuration"),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(x, "AddTimedBuff"),
				(Instruction x) => x.MatchAny(out nextInstr)
			}))
			{
				Log.PatchFail(il);
				return;
			}
			val.EmitNetworkServerActive();
			val.Emit(OpCodes.Brfalse_S, nextInstr);
		}

		[HarmonyPatch(typeof(HoldSkyLeap), "OnEnter")]
		[HarmonyILManipulator]
		public static void FixHoldSkyLeapOnEnter(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			Instruction nextInstr = null;
			if (!val.TryGotoNext(new Func<Instruction, bool>[5]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(EntityState), "characterBody")),
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Buffs), "HiddenInvincibility"),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(x, "AddBuff"),
				(Instruction x) => x.MatchAny(out nextInstr)
			}))
			{
				Log.PatchFail(((MemberReference)il.Method).Name + " #1");
				return;
			}
			val.EmitNetworkServerActive();
			Instruction prev = val.Prev;
			val.Emit(OpCodes.Brfalse_S, nextInstr);
			if (!val.TryGotoPrev((MoveType)2, new Func<Instruction, bool>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<HoldSkyLeap>(x, "hurtboxGroup"),
				(Instruction x) => x.MatchOpImplicit()
			}))
			{
				Log.PatchFail(((MemberReference)il.Method).Name + " #2");
				return;
			}
			val.Remove();
			val.Emit(OpCodes.Brfalse_S, prev);
		}

		[HarmonyPatch(typeof(HoldSkyLeap), "OnExit")]
		[HarmonyILManipulator]
		public static void FixHoldSkyLeapOnExit(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			Instruction nextInstr = null;
			if (!val.TryGotoNext(new Func<Instruction, bool>[5]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(EntityState), "characterBody")),
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Buffs), "HiddenInvincibility"),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(x, "RemoveBuff"),
				(Instruction x) => x.MatchAny(out nextInstr)
			}))
			{
				Log.PatchFail(((MemberReference)il.Method).Name + " #1");
				return;
			}
			val.EmitNetworkServerActive();
			Instruction prev = val.Prev;
			val.Emit(OpCodes.Brfalse_S, nextInstr);
			if (!val.TryGotoPrev((MoveType)2, new Func<Instruction, bool>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<HoldSkyLeap>(x, "hurtboxGroup"),
				(Instruction x) => x.MatchOpImplicit()
			}))
			{
				Log.PatchFail(((MemberReference)il.Method).Name + " #2");
				return;
			}
			val.Remove();
			val.Emit(OpCodes.Brfalse_S, prev);
		}

		[HarmonyPatch(typeof(SpellChannelState), "OnEnter")]
		[HarmonyILManipulator]
		public static void FixSpellChannelStateOnEnter(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_018b: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			Instruction nextInstr = null;
			if (!val.TryGotoNext(new Func<Instruction, bool>[5]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(EntityState), "characterBody")),
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Buffs), "Immune"),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(x, "AddBuff"),
				(Instruction x) => x.MatchAny(out nextInstr)
			}))
			{
				Log.PatchFail(((MemberReference)il.Method).Name + " #1");
				return;
			}
			val.EmitNetworkServerActive();
			Instruction prev = val.Prev;
			val.Emit(OpCodes.Brfalse_S, nextInstr);
			if (!val.TryGotoPrev((MoveType)2, new Func<Instruction, bool>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<SpellChannelState>(x, "spellChannelChildTransform"),
				(Instruction x) => x.MatchOpImplicit()
			}))
			{
				Log.PatchFail(((MemberReference)il.Method).Name + " #2");
				return;
			}
			val.Remove();
			val.Emit(OpCodes.Brfalse_S, prev);
		}

		[HarmonyPatch(typeof(SpellChannelState), "OnExit")]
		[HarmonyILManipulator]
		public static void SpellChannelState_OnExit(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			Instruction nextInstr = null;
			if (!val.TryGotoNext(new Func<Instruction, bool>[5]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(EntityState), "characterBody")),
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Buffs), "Immune"),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<CharacterBody>(x, "RemoveBuff"),
				(Instruction x) => x.MatchAny(out nextInstr)
			}))
			{
				Log.PatchFail(il);
				return;
			}
			val.EmitNetworkServerActive();
			val.Emit(OpCodes.Brfalse_S, nextInstr);
		}

		[HarmonyPatch(typeof(Duplicating), "DropDroplet")]
		[HarmonyILManipulator]
		public static void FixDuplicatingDropDroplet(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			Instruction nextInstr = null;
			if (!val.TryGotoNext(new Func<Instruction, bool>[4]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<EntityState>(x, "GetComponent"),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<ShopTerminalBehavior>(x, "DropPickup"),
				(Instruction x) => x.MatchAny(out nextInstr)
			}))
			{
				Log.PatchFail(il);
				return;
			}
			val.EmitNetworkServerActive();
			val.Emit(OpCodes.Brfalse_S, nextInstr);
		}

		[HarmonyPatch(typeof(FireArrowSnipe), "FireBullet")]
		[HarmonyILManipulator]
		public static void FixFireArrowSnipeFireBullet(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			Instruction nextInstr = null;
			float num = default(float);
			if (!val.TryGotoNext(new Func<Instruction, bool>[10]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(EntityState), "healthComponent")),
				(Instruction x) => ILPatternMatchingExt.MatchLdarga(x, 1),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(Ray), "direction")),
				(Instruction x) => ILPatternMatchingExt.MatchLdcR4(x, ref num),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Vector3>(x, "op_Multiply"),
				(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 1),
				(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<HealthComponent>(x, "TakeDamageForce"),
				(Instruction x) => x.MatchAny(out nextInstr)
			}))
			{
				Log.PatchFail(il);
				return;
			}
			val.EmitNetworkServerActive();
			val.Emit(OpCodes.Brfalse_S, nextInstr);
		}

		[HarmonyPatch(typeof(Hidden), "OnEnter")]
		[HarmonyILManipulator]
		public static void FixHiddenOnEnter(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel nextLabel = null;
			if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[4]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<Hidden>(x, "buffDef"),
				(Instruction x) => x.MatchOpImplicit(),
				(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref nextLabel)
			}))
			{
				Log.PatchFail(il);
				return;
			}
			val.EmitNetworkServerActive();
			val.Emit(OpCodes.Brfalse_S, (object)nextLabel);
		}

		[HarmonyPatch(typeof(Hidden), "OnExit")]
		[HarmonyILManipulator]
		public static void FixHiddenOnExit(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel nextLabel = null;
			if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[4]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<Hidden>(x, "buffDef"),
				(Instruction x) => x.MatchOpImplicit(),
				(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref nextLabel)
			}))
			{
				Log.PatchFail(il);
				return;
			}
			val.EmitNetworkServerActive();
			val.Emit(OpCodes.Brfalse_S, (object)nextLabel);
		}

		[HarmonyPatch(typeof(ScrapperBaseState), "OnEnter")]
		[HarmonyILManipulator]
		public static void FixScrapperBaseStateOnEnter(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			Instruction nextInstr = null;
			if (!val.TryGotoNext(new Func<Instruction, bool>[6]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<ScrapperBaseState>(x, "pickupPickerController"),
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(ScrapperBaseState), "enableInteraction")),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<PickupPickerController>(x, "SetAvailable"),
				(Instruction x) => x.MatchAny(out nextInstr)
			}))
			{
				Log.PatchFail(il);
				return;
			}
			val.EmitNetworkServerActive();
			val.Emit(OpCodes.Brfalse_S, nextInstr);
		}

		[HarmonyPatch(typeof(BuffPassengerWhileSeated), "OnDisable")]
		[HarmonyILManipulator]
		public static void FixBuffPassengerWhileSeatedOnDisable(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel nextLabel = null;
			if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[4]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<BuffPassengerWhileSeated>(x, "vehicleSeat"),
				(Instruction x) => x.MatchOpImplicit(),
				(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref nextLabel)
			}))
			{
				Log.PatchFail(il);
				return;
			}
			val.EmitNetworkServerActive();
			val.Emit(OpCodes.Brfalse_S, (object)nextLabel);
		}

		[HarmonyPatch(typeof(BuffPassengerWhileSeated), "OnEnable")]
		[HarmonyILManipulator]
		public static void FixBuffPassengerWhileSeatedOnEnable(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel nextLabel = null;
			if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[4]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<BuffPassengerWhileSeated>(x, "vehicleSeat"),
				(Instruction x) => x.MatchOpImplicit(),
				(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref nextLabel)
			}))
			{
				Log.PatchFail(il);
				return;
			}
			val.EmitNetworkServerActive();
			val.Emit(OpCodes.Brfalse_S, (object)nextLabel);
		}

		[HarmonyPatch(typeof(DelusionChestController), "ResetChestForDelusion")]
		[HarmonyILManipulator]
		public static void FixDelusionChestControllerResetChestForDelusion(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			Instruction nextInstr = null;
			int num = default(int);
			if (!val.TryGotoNext(new Func<Instruction, bool>[5]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<DelusionChestController>(x, "_pickupPickerController"),
				(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, ref num),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<PickupPickerController>(x, "SetAvailable"),
				(Instruction x) => x.MatchAny(out nextInstr)
			}))
			{
				Log.PatchFail(il);
				return;
			}
			val.EmitNetworkServerActive();
			val.Emit(OpCodes.Brfalse_S, nextInstr);
		}

		[HarmonyPatch(typeof(DelusionChestController), "Start")]
		[HarmonyILManipulator]
		public static void FixDelusionChestControllerStart(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			Instruction nextInstr = null;
			int num = default(int);
			if (!val.TryGotoNext(new Func<Instruction, bool>[5]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<DelusionChestController>(x, "_pickupPickerController"),
				(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, ref num),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<PickupPickerController>(x, "SetAvailable"),
				(Instruction x) => x.MatchAny(out nextInstr)
			}))
			{
				Log.PatchFail(il);
				return;
			}
			val.EmitNetworkServerActive();
			val.Emit(OpCodes.Brfalse_S, nextInstr);
		}

		[HarmonyPatch(typeof(DevotionInventoryController), "Awake")]
		[HarmonyILManipulator]
		public static void FixDevotionInventoryControllerAwake(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			Instruction nextInstr = null;
			int num = default(int);
			if (!val.TryGotoNext(new Func<Instruction, bool>[6]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<DevotionInventoryController>(x, "_devotionMinionInventory"),
				(Instruction x) => ILPatternMatchingExt.MatchLdsfld(x, typeof(Items), "LemurianHarness"),
				(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, ref num),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Inventory>(x, "GiveItem"),
				(Instruction x) => x.MatchAny(out nextInstr)
			}))
			{
				Log.PatchFail(il);
				return;
			}
			val.EmitNetworkServerActive();
			val.Emit(OpCodes.Brfalse_S, nextInstr);
		}

		[HarmonyPatch(typeof(MasterDropDroplet), "DropItems")]
		[HarmonyILManipulator]
		public static void FixMasterDropDropletDropItems(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			Instruction val2 = val.Instrs[val.Instrs.Count - 1];
			val.EmitNetworkServerActive();
			val.Emit(OpCodes.Brfalse_S, val2);
		}

		[HarmonyPatch(typeof(MinionGroup), "AddMinion")]
		[HarmonyILManipulator]
		public static void FixMinionGroupAddMinion(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel nextLabel = null;
			if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 1),
				(Instruction x) => x.MatchOpImplicit(),
				(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref nextLabel)
			}))
			{
				Log.PatchFail(il);
				return;
			}
			val.EmitNetworkServerActive();
			val.Emit(OpCodes.Brfalse_S, (object)nextLabel);
		}

		[HarmonyPatch(typeof(MinionGroup), "RemoveMinion")]
		[HarmonyILManipulator]
		public static void FixMinionGroupRemoveMinion(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel nextLabel = null;
			if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, 0),
				(Instruction x) => x.MatchOpImplicit(),
				(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref nextLabel)
			}))
			{
				Log.PatchFail(il);
				return;
			}
			val.EmitNetworkServerActive();
			val.Emit(OpCodes.Brfalse_S, (object)nextLabel);
		}
	}
	[HarmonyPatch]
	public class VanillaFixes
	{
		[HarmonyPatch(typeof(TemporaryVisualEffect), "RebuildVisualComponents")]
		[HarmonyILManipulator]
		public static void TemporaryVisualEffect_RebuildVisualComponents(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_002e: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			Instruction instr = null;
			int num = default(int);
			while (val.TryGotoNext((MoveType)0, new Func<Instruction, bool>[4]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdelemRef(x),
				(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, ref num),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(Behaviour), "enabled")),
				(Instruction x) => x.MatchAny(out instr)
			}))
			{
				ILLabel val2 = val.DefineLabel();
				int index = val.Index;
				val.Index = index + 1;
				val.Emit(OpCodes.Dup);
				val.EmitOpImplicit();
				val.Emit(OpCodes.Brfalse_S, instr);
				val.Emit(OpCodes.Pop);
				val.Emit(OpCodes.Br_S, (object)val2);
				val.MarkLabel(val2);
			}
		}

		[HarmonyPatch(typeof(RolyPolyHitFiveAirEnemiesServerAchievement), "GetCharacterMotor")]
		[HarmonyILManipulator]
		public static void RolyPolyHitFiveAirEnemiesServerAchievement_GetCharacterMotor(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: 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)
			ILCursor val = new ILCursor(il);
			if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<BaseServerAchievement>(x, "GetCurrentBody"),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Component>(x, "GetComponent")
			}))
			{
				Log.PatchFail(il);
				return;
			}
			int index = val.Index;
			val.Index = index - 1;
			ILLabel val2 = val.DefineLabel();
			ILLabel val3 = val.DefineLabel();
			val.Emit(OpCodes.Dup);
			val.EmitOpImplicit();
			val.Emit(OpCodes.Brtrue_S, (object)val2);
			val.Emit(OpCodes.Pop);
			val.Emit(OpCodes.Ldnull);
			val.Emit(OpCodes.Br_S, (object)val3);
			val.MarkLabel(val2);
			index = val.Index;
			val.Index = index + 1;
			val.MarkLabel(val3);
		}

		[HarmonyPatch(typeof(AffixAurelioniteBehavior), "Update")]
		[HarmonyPrefix]
		public static bool AffixAurelioniteBehavior_Update(AffixAurelioniteBehavior __instance)
		{
			CharacterBody body = ((ItemBehavior)__instance).body;
			return Object.op_Implicit((Object)(object)((body != null) ? body.coreTransform : null));
		}

		[HarmonyPatch(typeof(CharacterBody), "<HandleDisableAllSkillsDebuff>g__HandleSkillDisableState|389_0")]
		[HarmonyILManipulator]
		public static void CharacterBody_HandleDisableAllSkillsDebuff(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Expected O, but got Unknown
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_010a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il)
			{
				Index = il.Instrs.Count - 1
			};
			ILLabel retLabel = null;
			int num = default(int);
			if (val.TryGotoPrev((MoveType)0, new Func<Instruction, bool>[6]
			{
				(Instruction x) => x.MatchNetworkServerActive(),
				(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref retLabel),
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(CharacterBody), "inventory")),
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, ref num),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Inventory>(x, "SetEquipmentDisabled")
			}))
			{
				val.Index += 2;
				val.Emit(OpCodes.Ldarg_0);
				val.Emit(OpCodes.Call, (MethodBase)AccessTools.PropertyGetter(typeof(CharacterBody), "inventory"));
				val.EmitOpImplicit();
				val.Emit(OpCodes.Brfalse, (object)retLabel);
			}
			else
			{
				Log.PatchFail(il);
			}
		}

		[HarmonyPatch(typeof(CharacterBody), "TryGiveFreeUnlockWhenLevelUp")]
		[HarmonyILManipulator]
		public static void CharacterBody_FreeFortniteCard(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel retLabel = null;
			ILCursor[] array = default(ILCursor[]);
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(CharacterBody), "inventory"))
			}) && val.TryFindNext(ref array, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchBle(x, ref retLabel)
			}))
			{
				ILLabel val2 = val.DefineLabel();
				val.Emit(OpCodes.Dup);
				val.EmitOpImplicit();
				val.Emit(OpCodes.Brtrue, (object)val2);
				val.Emit(OpCodes.Pop);
				val.Emit(OpCodes.Br, (object)retLabel);
				val.MarkLabel(val2);
			}
			else
			{
				Log.PatchFail(il);
			}
		}

		[HarmonyPatch(typeof(VineOrb), "OnArrival")]
		[HarmonyILManipulator]
		public static void VineOrb_OnArrival(ILContext il, ILLabel retLabel)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: 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_00df: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			val.Emit(OpCodes.Ldarg_0);
			val.Emit<Orb>(OpCodes.Ldfld, "target");
			val.EmitOpImplicit();
			val.Emit(OpCodes.Brfalse_S, (object)retLabel);
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<GlobalEventManager>(x, "ProcDeathMark")
			}))
			{
				ILLabel val2 = val.DefineLabel();
				val.MarkLabel(val2);
				int dotLoc = 0;
				if (val.TryGotoPrev((MoveType)2, new Func<Instruction, bool>[2]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<DotController>(x, "GetDotDef"),
					(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref dotLoc)
				}))
				{
					val.Emit(OpCodes.Ldloc, dotLoc);
					val.EmitOpImplicit();
					val.Emit(OpCodes.Brfalse_S, (object)val2);
				}
				else
				{
					Log.PatchFail(((MemberReference)il.Method).Name + " #2");
				}
			}
			else
			{
				Log.PatchFail(((MemberReference)il.Method).Name + " #1");
			}
		}

		[HarmonyPatch(typeof(ProjectileController), "Start")]
		[HarmonyILManipulator]
		public static void ProjectileController_Start(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0110: 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_0142: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel label = null;
			int num = default(int);
			ILLabel val2 = default(ILLabel);
			if (val.TryGotoNext(new Func<Instruction, bool>[4]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertySetter(typeof(ProjectileController), "shouldPlaySounds")),
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref num),
				(Instruction x) => x.MatchOpImplicit(),
				(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref label)
			}) && val.TryGotoNext((MoveType)1, new Func<Instruction, bool>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(ProjectileController), "isPrediction")),
				(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref val2)
			}))
			{
				val.Emit(OpCodes.Ldarg_0);
				val.Emit(OpCodes.Call, (MethodBase)AccessTools.PropertyGetter(typeof(ProjectileController), "ghost"));
				val.EmitOpImplicit();
				val.Emit(OpCodes.Brfalse, (object)label);
			}
			else
			{
				Log.PatchFail(il);
			}
		}

		[HarmonyPatch(typeof(StatManager), "ProcessGoldEvents")]
		[HarmonyILManipulator]
		public static void StatManager_ProcessGoldEvents(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			ILLabel val3 = default(ILLabel);
			if (val.TryGotoNext(new Func<Instruction, bool>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<GoldEvent>(x, "characterMaster"),
				(Instruction x) => ILPatternMatchingExt.MatchDup(x),
				(Instruction x) => ILPatternMatchingExt.MatchBrtrue(x, ref val3)
			}))
			{
				val.GotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchDup(x)
				});
				val.EmitOpImplicit();
			}
			else
			{
				Log.PatchFail(((MemberReference)il.Method).Name + " 1");
			}
			ILLabel val2 = default(ILLabel);
			if (val.TryGotoNext(new Func<Instruction, bool>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Component>(x, "GetComponent"),
				(Instruction x) => ILPatternMatchingExt.MatchDup(x),
				(Instruction x) => ILPatternMatchingExt.MatchBrtrue(x, ref val2)
			}))
			{
				val.GotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchDup(x)
				});
				val.EmitOpImplicit();
			}
			else
			{
				Log.PatchFail(((MemberReference)il.Method).Name + " 2");
			}
		}

		[HarmonyPatch(typeof(MinionLeashBodyBehavior), "OnDisable")]
		[HarmonyILManipulator]
		private static void MinionLeashBodyBehavior_OnDisable(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_0008: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			if (new ILCursor(il).TryGotoNext(new Func<Instruction, bool>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(SceneInfo), "instance")),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(SceneInfo), "sceneDef")),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(SceneDef), "cachedName"))
			}))
			{
				int index = val.Index;
				val.Index = index + 1;
				ILLabel val2 = val.DefineLabel();
				ILLabel val3 = val.DefineLabel();
				ILLabel val4 = val.DefineLabel();
				val.Emit(OpCodes.Dup);
				val.EmitOpImplicit();
				val.Emit(OpCodes.Brtrue, (object)val3);
				val.Emit(OpCodes.Pop);
				val.Emit<string>(OpCodes.Ldsfld, "Empty");
				val.Emit(OpCodes.Br, (object)val2);
				val.MarkLabel(val3);
				index = val.Index;
				val.Index = index + 1;
				val.Emit(OpCodes.Dup);
				val.EmitOpImplicit();
				val.Emit(OpCodes.Brtrue, (object)val4);
				val.Emit(OpCodes.Pop);
				val.Emit<string>(OpCodes.Ldsfld, "Empty");
				val.Emit(OpCodes.Br, (object)val2);
				val.MarkLabel(val4);
				index = val.Index;
				val.Index = index + 1;
				val.MarkLabel(val2);
			}
			else
			{
				Log.PatchFail(il);
			}
		}

		[HarmonyPatch(typeof(ElusiveAntlersPickup), "FixedUpdate")]
		[HarmonyILManipulator]
		private static void ElusiveAntlersPickup_FixedUpdate(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_00e1: 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_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			int num2 = default(int);
			if (val.TryGotoNext(new Func<Instruction, bool>[5]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<ElusiveAntlersPickup>(x, "ownerBody"),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(Component), "gameObject")),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(GameObject), "transform")),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(Transform), "position")),
				(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref num2)
			}))
			{
				int index = val.Index;
				val.Index = index + 1;
				ILLabel val2 = val.DefineLabel();
				ILLabel val3 = val.DefineLabel();
				val.Emit(OpCodes.Dup);
				val.EmitOpImplicit();
				val.Emit(OpCodes.Brtrue, (object)val3);
				val.Emit(OpCodes.Pop);
				val.Emit<Vector3>(OpCodes.Ldsfld, "zeroVector");
				val.Emit(OpCodes.Br, (object)val2);
				val.MarkLabel(val3);
				int num = default(int);
				val.GotoNext(new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref num)
				});
				val.MarkLabel(val2);
			}
			else
			{
				Log.PatchFail(il);
			}
		}

		[HarmonyPatch(typeof(ElusiveAntlersPickup), "OnShardDestroyed")]
		[HarmonyILManipulator]
		private static void ElusiveAntlersPickup_OnShardDestroyed(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			ILLabel val2 = default(ILLabel);
			if (val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<Component>(x, "GetComponent")
			}) && val.TryGotoPrev(new Func<Instruction, bool>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<ElusiveAntlersPickup>(x, "ownerBody"),
				(Instruction x) => ILPatternMatchingExt.MatchDup(x),
				(Instruction x) => ILPatternMatchingExt.MatchBrtrue(x, ref val2)
			}))
			{
				val.Index += 2;
				val.EmitOpImplicit();
			}
			else
			{
				Log.PatchFail(il);
			}
		}

		[HarmonyPatch(typeof(FogDamageController), "EvaluateTeam")]
		[HarmonyILManipulator]
		public static void FogDamageController_EvaluateTeam(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			int locTC = 0;
			int locBody = 0;
			ILLabel label = null;
			ILCursor[] array = default(ILCursor[]);
			if (val.TryGotoNext(new Func<Instruction, bool>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloc(x, ref locTC),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(TeamComponent), "body")),
				(Instruction x) => ILPatternMatchingExt.MatchStloc(x, ref locBody)
			}) && val.TryFindPrev(ref array, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchBr(x, ref label)
			}))
			{
				val.Emit(OpCodes.Ldloc, locTC);
				val.EmitOpImplicit();
				val.Emit(OpCodes.Brfalse, (object)label);
				val.GotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchStloc(x, locBody)
				});
				val.Emit(OpCodes.Ldloc, locBody);
				val.EmitOpImplicit();
				val.Emit(OpCodes.Brfalse, (object)label);
			}
			else
			{
				Log.PatchFail(il);
			}
		}

		[HarmonyPatch(typeof(DeathState), "FixedUpdate")]
		[HarmonyILManipulator]
		public static void DeathState_FixedUpdate(ILContext il)
		{
			//IL_0001: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			ILCursor[] array = default(ILCursor[]);
			if (new ILCursor(il).TryFindNext(ref array, new Func<Instruction, bool>[2]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<DeathState>(x, "FireExplosion"),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<GameObject>(x, "SetActive")
			}))
			{
				ILCursor obj = array[0];
				ILCursor val = array[1];
				int index = obj.Index;
				obj.Index = index + 1;
				obj.MoveAfterLabels();
				index = val.Index;
				val.Index = index + 1;
				obj.Emit(OpCodes.Br, (object)val.MarkLabel());
				val.Emit(OpCodes.Ldarg_0);
				val.EmitDelegate<Action<DeathState>>((Action<DeathState>)delegate(DeathState self)
				{
					if (Object.op_Implicit((Object)(object)((EntityState)self).modelLocator) && Object.op_Implicit((Object)(object)((EntityState)self).modelLocator.modelTransform))
					{
						((Component)((EntityState)self).modelLocator.modelTransform).gameObject.SetActive(false);
					}
				});
			}
			else
			{
				Log.PatchFail(il);
			}
		}

		[HarmonyPatch(typeof(Idle), "OnEnter")]
		[HarmonyILManipulator]
		public static void RouletteChestController_Idle_OnEnter(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			int num = default(int);
			if (val.TryGotoNext(new Func<Instruction, bool>[5]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertyGetter(typeof(RouletteChestControllerBaseState), "rouletteChestController")),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<RouletteChestController>(x, "purchaseInteraction"),
				(Instruction x) => ILPatternMatchingExt.MatchLdcI4(x, ref num),
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertySetter(typeof(PurchaseInteraction), "Networkavailable"))
			}))
			{
				ILLabel val2 = val.DefineLabel();
				val.Emit(OpCodes.Br, (object)val2);
				val.GotoNext((MoveType)2, new Func<Instruction, bool>[1]
				{
					(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, (MethodBase)AccessTools.PropertySetter(typeof(PurchaseInteraction), "Networkavailable"))
				});
				val.MarkLabel(val2);
				val.Emit(OpCodes.Ldarg_0);
				val.EmitDelegate<Action<RouletteChestControllerBaseState>>((Action<RouletteChestControllerBaseState>)delegate(RouletteChestControllerBaseState ctrl)
				{
					if (Object.op_Implicit((Object)(object)ctrl.rouletteChestController) && Object.op_Implicit((Object)(object)ctrl.rouletteChestController.purchaseInteraction))
					{
						ctrl.rouletteChestController.purchaseInteraction.Networkavailable = true;
					}
				});
			}
			else
			{
				Log.PatchFail(il);
			}
		}

		[HarmonyPatch(typeof(Interactor), "FindBestInteractableObject")]
		[HarmonyILManipulator]
		public static void Interactor_FindBestInteractableObject(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: 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_0148: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			int loc = 0;
			ILLabel label = null;
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloca(x, ref loc),
				(Instruction x) => ILPatternMatchingExt.MatchCall<EntityLocator>(x, "HasEntityLocator"),
				(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref label)
			}))
			{
				val.Emit(OpCodes.Ldloc, loc);
				val.Emit<EntityLocator>(OpCodes.Ldfld, "entity");
				val.EmitOpImplicit();
				val.Emit(OpCodes.Brfalse, (object)label);
			}
			else
			{
				Log.PatchFail(((MemberReference)il.Method).Name + " 1");
			}
			int loc2 = 0;
			ILLabel label2 = null;
			if (val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[3]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdloca(x, ref loc2),
				(Instruction x) => ILPatternMatchingExt.MatchCall<EntityLocator>(x, "HasEntityLocator"),
				(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref label2)
			}))
			{
				val.Emit(OpCodes.Ldloc, loc2);
				val.Emit<EntityLocator>(OpCodes.Ldfld, "entity");
				val.EmitOpImplicit();
				val.Emit(OpCodes.Brfalse, (object)label2);
			}
			else
			{
				Log.PatchFail(((MemberReference)il.Method).Name + " 2");
			}
		}

		[HarmonyPatch(typeof(Duplicating), "DropDroplet")]
		[HarmonyILManipulator]
		public static void Duplicating_DropDroplet(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			if (!val.TryGotoNext(new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt(x, typeof(EffectManager), "SimpleMuzzleFlash")
			}))
			{
				Log.PatchFail(il);
				return;
			}
			val.Remove();
			val.EmitDelegate<Action<GameObject, GameObject, string, bool>>((Action<GameObject, GameObject, string, bool>)delegate(GameObject effectPrefab, GameObject obj, string muzzleName, bool _)
			{
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0052: Unknown result type (might be due to invalid IL or missing references)
				ModelLocator val2 = default(ModelLocator);
				if (Object.op_Implicit((Object)(object)obj) && obj.TryGetComponent<ModelLocator>(ref val2) && Object.op_Implicit((Object)(object)val2.modelTransform))
				{
					ChildLocator component = ((Component)val2.modelTransform).GetComponent<ChildLocator>();
					if (Object.op_Implicit((Object)(object)component))
					{
						int num = component.FindChildIndex(muzzleName);
						Transform val3 = component.FindChild(num);
						if (Object.op_Implicit((Object)(object)val3))
						{
							Object.Instantiate<GameObject>(effectPrefab, val3.position, Quaternion.identity, val3);
						}
					}
				}
			});
		}

		[HarmonyPatch(typeof(DetachParticleOnDestroyAndEndEmission), "OnDisable")]
		[HarmonyILManipulator]
		public static void DetachParticleOnDestroyAndEndEmission_OnDisable(ILContext il)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Expected O, but got Unknown
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_010d: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			ILCursor val = new ILCursor(il);
			ILLabel returnLabel = null;
			if (!val.TryGotoNext(new Func<Instruction, bool>[4]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdarg(x, 0),
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<DetachParticleOnDestroyAndEndEmission>(x, "particleSystem"),
				(Instruction x) => x.MatchOpImplicit(),
				(Instruction x) => ILPatternMatchingExt.MatchBrfalse(x, ref returnLabel)
			}) || !val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchCallOrCallvirt<ParticleSystem>(x, "Stop")
			}))
			{
				Log.PatchFail(il);
				return;
			}
			val.Emit(OpCodes.Ldarg_0);
			val.Emit<DetachParticleOnDestroyAndEndEmission>(OpCodes.Ldfld, "particleSystem");
			val.Emit(OpCodes.Callvirt, (MethodBase)AccessTools.PropertyGetter(typeof(Component), "gameObject"));
			val.Emit(OpCodes.Callvirt, (MethodBase)AccessTools.PropertyGetter(typeof(GameObject), "activeInHierarchy"));
			val.Emit(OpCodes.Brfalse, (object)returnLabel);
		}

		[HarmonyPatch(typeof(CharacterModel), "Awake")]
		[HarmonyILManipulator]
		public static void CharacterModel_Awake(ILContext il)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0007: Expected O, but got Unknown
			ILCursor val = new ILCursor(il);
			if (!val.TryGotoNext((MoveType)2, new Func<Instruction, bool>[1]
			{
				(Instruction x) => ILPatternMatchingExt.MatchLdfld<HurtBoxGroup>(x, "hurtBoxes")
			}))
			{
				Log.PatchFail(il);
				return;
			}
			val.EmitDelegate<Func<HurtBox[], HurtBox[]>>((Func<HurtBox[], HurtBox[]>)delegate(HurtBox[] hurtBoxes)
			{
				int num = hurtBoxes.Length - 1;
				while (0 <= num)
				{
					if (!Object.op_Implicit((Object)(object)hurtBoxes[num]))
					{
						ArrayUtils.ArrayRemoveAtAndResize<HurtBox>(ref hurtBoxes, num, 1);
					}
					num--;
				}
				return hurtBoxes;