Decompiled source of UnofficialPatch v1.2.0

BepInEx/plugins/UnofficialPatch.dll

Decompiled a week ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using AK.Wwise;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Pigeon;
using Pigeon.Math;
using Pigeon.Movement;
using Pigeon.UI;
using TMPro;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")]
[assembly: AssemblyCompany("UnofficialPatch")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.0.0.0")]
[assembly: AssemblyInformationalVersion("0.0.0-alpha.0.10+d42a84c0a1c438cfe022b9bc1173c531c5c2aefd")]
[assembly: AssemblyProduct("UnofficialPatch")]
[assembly: AssemblyTitle("UnofficialPatch")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("0.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
[HarmonyPatch(typeof(Player), "set_AutoSprint")]
public static class Player_AutoSprint_Patch
{
	public static void Postfix(Player __instance, bool value)
	{
		if (SparrohPlugin.EnableAutoSprintFix.Value && !__instance.ToggleSprint)
		{
			((object)__instance).GetType().GetField("wantsToSprint", BindingFlags.Instance | BindingFlags.NonPublic)?.SetValue(__instance, value);
		}
	}
}
[HarmonyPatch(typeof(FlatTundraObjective), "PlayLastIntroDialogue")]
public static class FlatTundraObjective_PlayLastIntroDialogue_Patch
{
	[HarmonyPrefix]
	public static bool Prefix(FlatTundraObjective __instance)
	{
		if (!SparrohPlugin.EnableCraniusDialogueFix.Value)
		{
			return true;
		}
		try
		{
			if ((Object)(object)__instance == (Object)null || !((Component)__instance).gameObject.activeInHierarchy || !((Behaviour)__instance).enabled)
			{
				return false;
			}
			return true;
		}
		catch (Exception ex)
		{
			SparrohPlugin.Logger.LogError((object)("[CraniusDialogueFix] Error in FlatTundraObjective_PlayLastIntroDialogue_Patch: " + ex.Message + "\n" + ex.StackTrace));
			return true;
		}
	}
}
[HarmonyPatch]
public class CartridgeSMGFixes
{
	[HarmonyPatch(typeof(CartridgeSMG), "OnUpgradesDisabled")]
	[HarmonyPrefix]
	public static bool OnUpgradesDisabledPrefix(CartridgeSMG __instance)
	{
		//IL_002b: Unknown result type (might be due to invalid IL or missing references)
		//IL_01c9: Unknown result type (might be due to invalid IL or missing references)
		if (!SparrohPlugin.EnableCyclerDestructionFix.Value)
		{
			return true;
		}
		object value = Traverse.Create((object)__instance).Field("player").GetValue();
		if (value != null)
		{
			if (UpgradeFlagsExtensions.IsEnabled(((Gun)__instance).UpgradeFlags, (SMGUpgradeFlags)512))
			{
				object value2 = Traverse.Create((object)__instance).Field("NetworkManager").GetValue();
				if (value2 != null)
				{
					object value3 = Traverse.Create(value2).Property("NetworkTickSystem", (object[])null).GetValue();
					if (value3 != null)
					{
						Action value4 = Traverse.Create(value3).Field("Tick").GetValue<Action>();
						value4 = (Action)Delegate.Remove(value4, Traverse.Create((object)__instance).Method("OnTick", Array.Empty<object>()).GetValue<Action>());
						Traverse.Create(value3).Field("Tick").SetValue((object)value4);
					}
				}
				Traverse.Create((object)__instance).Field("gunData").Property("useAmmoOnFire", (object[])null)
					.SetValue((object)1);
				int value5 = Traverse.Create(Traverse.Create((object)__instance).Field("gunData").GetValue()).Field("magazineSize").GetValue<int>();
				Traverse.Create((object)__instance).Property("RemainingAmmo", (object[])null).SetValue((object)(float)value5);
			}
			if (Traverse.Create(Traverse.Create((object)__instance).Field("data").GetValue()).Field("returnEnergyOnCorrodeDOTAmount").GetValue<int>() > 0)
			{
				object value6 = Traverse.Create(value).Field("OnDamageTarget").GetValue();
				if (value6 != null)
				{
					object value7 = Traverse.Create((object)__instance).Method("ReturnEnergyOnCorrodeDOT", Array.Empty<object>()).GetValue();
					Delegate value8 = Delegate.Remove((Delegate)value6, (Delegate)value7);
					Traverse.Create(value).Field("OnDamageTarget").SetValue((object)value8);
				}
			}
			if (!UpgradeFlagsExtensions.IsEnabled(((Gun)__instance).UpgradeFlags, (SMGUpgradeFlags)1))
			{
				return false;
			}
			Traverse.Create((object)__instance).Field("forceEnableFire").SetValue((object)false);
		}
		return false;
	}

	[HarmonyPatch(typeof(CartridgeSMG), "OnTick")]
	[HarmonyPrefix]
	public static bool OnTickPrefix(CartridgeSMG __instance)
	{
		if (!SparrohPlugin.EnableCyclerDestructionFix.Value)
		{
			return true;
		}
		if (((Gun)__instance).SkinRenderers == null || ((Gun)__instance).SkinRenderers.Length == 0 || (Object)(object)((Gun)__instance).SkinRenderers[0] == (Object)null)
		{
			return false;
		}
		return true;
	}
}
[HarmonyPatch(typeof(ScoutLaserHUD), "OnLaserChargeChanged")]
public class ScoutLaserHUD_OnLaserChargeChanged_Patch
{
	[HarmonyPrefix]
	public static bool Prefix(ScoutLaserHUD __instance, float charge, float capacity)
	{
		if (!SparrohPlugin.EnableDMLRBatteryFix.Value)
		{
			return true;
		}
		try
		{
			Traverse val = Traverse.Create((object)__instance);
			if (!(val.Field("batterySegments").GetValue() is List<Graphic> list) || list.Count == 0)
			{
				return false;
			}
			if (!(val.Field("gear").GetValue() is IGear))
			{
				return false;
			}
			return true;
		}
		catch (Exception ex)
		{
			SparrohPlugin.Logger.LogError((object)("[DMLRBatteryFix] Error in ScoutLaserHUD_OnLaserChargeChanged_Patch: " + ex.Message + "\n" + ex.StackTrace));
			return true;
		}
	}
}
[HarmonyPatch(typeof(GlobblerBullet), "Detonate")]
public static class GlobblerBullet_Detonate_Patch
{
	public static bool Prefix(GlobblerBullet __instance)
	{
		//IL_0020: Unknown result type (might be due to invalid IL or missing references)
		//IL_0025: Unknown result type (might be due to invalid IL or missing references)
		//IL_00cf: Unknown result type (might be due to invalid IL or missing references)
		//IL_00d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_0100: Unknown result type (might be due to invalid IL or missing references)
		//IL_0105: Unknown result type (might be due to invalid IL or missing references)
		//IL_0109: Unknown result type (might be due to invalid IL or missing references)
		//IL_0110: Unknown result type (might be due to invalid IL or missing references)
		//IL_0139: Unknown result type (might be due to invalid IL or missing references)
		//IL_014a: Unknown result type (might be due to invalid IL or missing references)
		//IL_014e: Unknown result type (might be due to invalid IL or missing references)
		//IL_0152: 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_01b6: Expected O, but got Unknown
		//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
		//IL_01d9: 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_018a: Unknown result type (might be due to invalid IL or missing references)
		//IL_0272: Unknown result type (might be due to invalid IL or missing references)
		//IL_0277: Unknown result type (might be due to invalid IL or missing references)
		//IL_0254: Unknown result type (might be due to invalid IL or missing references)
		//IL_0259: Unknown result type (might be due to invalid IL or missing references)
		//IL_021b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0220: Unknown result type (might be due to invalid IL or missing references)
		//IL_0208: Unknown result type (might be due to invalid IL or missing references)
		//IL_020d: Unknown result type (might be due to invalid IL or missing references)
		if (!SparrohPlugin.EnableGlobblerFriendFireFix.Value)
		{
			return true;
		}
		try
		{
			Traverse obj = Traverse.Create((object)__instance);
			Vector3 value = obj.Field("positionNext").GetValue<Vector3>();
			Event value2 = obj.Field("explosionSound").GetValue<Event>();
			float value3 = obj.Property("ExplosionShake", (object[])null).GetValue<float>();
			float value4 = obj.Field("explosionVisualSizeMultiplier").GetValue<float>();
			object value5 = obj.Field("data").GetValue();
			Type type = value5.GetType();
			int num = (int)type.GetField("targetCollisionMask").GetValue(value5);
			float num2 = (float)type.GetField("force").GetValue(value5);
			float num3 = (float)type.GetField("damage").GetValue(value5);
			EffectType val = (EffectType)type.GetField("damageEffect").GetValue(value5);
			float num4 = (float)type.GetField("damageEffectAmount").GetValue(value5);
			DamageFlags val2 = (DamageFlags)type.GetField("damageFlags").GetValue(value5);
			TargetEnumerator val3 = default(TargetEnumerator);
			try
			{
				int num5 = (BulletFlagsExtensions.OnlyDamageLocalPlayer(((SimpleProjectileBullet)__instance).Flags) ? 1024 : ((((uint)num & 8u) != 0) ? (num | 0x400) : num));
				if (((TargetEnumerator)(ref val3)).GetTargetsInSphere(value, num2, num5, (TargetType)5))
				{
					DamageData val4 = default(DamageData);
					((DamageData)(ref val4))..ctor(num3, val, num4, (DamageFlags)(val2 | 0x10));
					while (((TargetEnumerator)(ref val3)).MoveNext())
					{
						if (((TargetEnumerator)(ref val3)).Current == Player.LocalPlayer)
						{
							val4.effectAmount *= ((GrenadeBullet)__instance).SelfEffectMultiplier;
						}
						IDamageSource.DamageTarget((IDamageSource)(object)__instance, ((TargetEnumerator)(ref val3)).Current, val4, ((IFollowable)((TargetEnumerator)(ref val3)).Current).GetHealthbarPosition(), (Collider)null);
					}
				}
			}
			finally
			{
				((TargetEnumerator)(ref val3)).Dispose();
			}
			Globbler val5 = (Globbler)((SimpleProjectileBullet)__instance).ParentSource;
			ref Data globblerData = ref val5.GlobblerData;
			if (globblerData.acidPuddleDuration > 0f)
			{
				GameManager.Instance.SpawnAcidPuddle_Rpc(NetworkBehaviourReference.op_Implicit((NetworkBehaviour)(object)val5), value, globblerData.acidPuddleDuration, (TargetType)5, globblerData.acidPuddleSize);
			}
			if (BulletFlagsExtensions.OnlyDamageLocalPlayer(((SimpleProjectileBullet)__instance).Flags))
			{
				if (((BaseType)value2).Id == 0)
				{
					GameManager.Instance.SpawnExplosionVisual(value, num2 * value4, val);
				}
				else
				{
					GameManager.Instance.SpawnExplosionVisual(value, num2 * value4, val, ((BaseType)value2).Id, Mathf.InverseLerp(0.9f, 3f, num2), false);
				}
				return false;
			}
			if (((BaseType)value2).Id == 0)
			{
				GameManager.Instance.SpawnExplosionVisualObserverSeeThrough_Rpc(value, num2 * value4, val, (uint)NetworkManager.Singleton.LocalClientId);
			}
			else
			{
				GameManager.Instance.SpawnExplosionVisual_Rpc(value, num2 * value4, val, ((BaseType)value2).Id, Mathf.InverseLerp(0.9f, 3f, num2), NetworkManager.Singleton.LocalClientId);
			}
			IDamageSource.ApplyExplosionScreenshake(ref value, num2, value3);
			return false;
		}
		catch (Exception ex)
		{
			SparrohPlugin.Logger.LogError((object)("[GlobblerFriendFireFix] Error in Detonate patch: " + ex.Message + "\n" + ex.StackTrace));
			return true;
		}
	}
}
public static class HoverLobbyModifierFix
{
	public static void ApplyPatches(Harmony harmony)
	{
		harmony.PatchAll(typeof(PopupInfoOnReleasePopupPatch));
		harmony.PatchAll(typeof(PopupInfoGetPopupPatch));
		harmony.PatchAll(typeof(HoverInfoDisplayActivatePatch));
	}
}
[HarmonyPatch(typeof(PopupInfo), "CreatePopup")]
public static class PopupInfoCreatePopupPatch
{
	public static bool Prefix(ref PopupInfo __result)
	{
		if (!SparrohPlugin.EnableHoverLobbyModifierFix.Value)
		{
			return true;
		}
		if ((Object)(object)Global.Instance == (Object)null)
		{
			__result = null;
			return false;
		}
		if ((Object)(object)Global.Instance.PopupInfoPrefab == (Object)null)
		{
			__result = null;
			return false;
		}
		if ((Object)(object)GameManager.Instance == (Object)null)
		{
			__result = null;
			return false;
		}
		WindowSystem windowSystem = GameManager.Instance.WindowSystem;
		Transform val = ((windowSystem != null) ? ((Component)windowSystem).transform : null) ?? ((Component)GameManager.Instance).transform;
		__result = Object.Instantiate<PopupInfo>(Global.Instance.PopupInfoPrefab, val);
		return false;
	}
}
[HarmonyPatch(typeof(PopupInfo), "OnReleasePopup")]
public static class PopupInfoOnReleasePopupPatch
{
	public static void Postfix(PopupInfo popup)
	{
		if (SparrohPlugin.EnableHoverLobbyModifierFix.Value && !((Object)(object)popup == (Object)null) && !((Object)(object)GameManager.Instance == (Object)null))
		{
			WindowSystem windowSystem = GameManager.Instance.WindowSystem;
			Transform val = ((windowSystem != null) ? ((Component)windowSystem).transform : null) ?? ((Component)GameManager.Instance).transform;
			((Component)popup).transform.SetParent(val, false);
		}
	}
}
[HarmonyPatch(typeof(PopupInfo), "GetPopup")]
public static class PopupInfoGetPopupPatch
{
	public static bool Prefix(ref PopupInfo __result)
	{
		if (!SparrohPlugin.EnableHoverLobbyModifierFix.Value)
		{
			return true;
		}
		if ((Object)(object)GameManager.Instance == (Object)null)
		{
			__result = null;
			return false;
		}
		if ((Object)(object)GameManager.Instance.WindowSystem == (Object)null)
		{
			__result = null;
			return false;
		}
		return true;
	}
}
[HarmonyPatch(typeof(HoverInfoDisplay), "Activate", new Type[]
{
	typeof(HoverInfo),
	typeof(bool)
})]
public static class HoverInfoDisplayActivatePatch
{
	public static bool Prefix(HoverInfo info, bool resetPosition)
	{
		if (!SparrohPlugin.EnableHoverLobbyModifierFix.Value)
		{
			return true;
		}
		if ((Object)(object)GameManager.Instance == (Object)null)
		{
			return false;
		}
		return true;
	}
}
[HarmonyPatch(typeof(VoltaicGrenade), "OverrideActivate")]
public class LivewireVoltaicGrenade_OverrideActivate_Patch
{
	private static bool Prefix(VoltaicGrenade __instance, ref bool __result)
	{
		if (!SparrohPlugin.EnableLivewireFix.Value)
		{
			return true;
		}
		try
		{
			Traverse val = Traverse.Create((object)__instance);
			Traverse val2 = val.Field("grenadeData");
			float value = val2.Field("selfGrenadeDuration").GetValue<float>();
			float value2 = val.Field("selfGrenadeTimer").GetValue<float>();
			float value3 = val.Field("cooldownData").Field("charge").GetValue<float>();
			if (value > 0f && value2 < 0f)
			{
				if (value3 >= 1f)
				{
					val.Field("selfGrenadeTimer").SetValue((object)0f);
					float value4 = val2.Field("selfGrenadeExplodeInterval").GetValue<float>();
					val.Field("selfGrenadeExplosionTimer").SetValue((object)value4);
					Player value5 = val.Field("player").GetValue<Player>();
					Sprite value6 = val.Field("livewireIcon").GetValue<Sprite>();
					value5.UpdateStackDisplay((object)typeof(UpgradeProperty_VoltaicGrenade_Livewire), TextBlocks.GetString("Livewire", 0), value6, 1, value);
					float num = value3;
					val.Field("cooldownData").Field("charge").SetValue((object)(num - 1f));
					val.Method("InvokeOnCooldownChanged", new object[1] { num - 1f }).GetValue();
					__result = true;
					return false;
				}
				__result = false;
				return false;
			}
			return true;
		}
		catch (Exception ex)
		{
			SparrohPlugin.Logger.LogError((object)("[LivewireFix] Error in LivewireVoltaicGrenade_OverrideActivate_Patch: " + ex.Message + "\n" + ex.StackTrace));
			return true;
		}
	}
}
[HarmonyPatch(typeof(Player), "TryThrow")]
public class Player_TryThrow_Patch
{
	[CompilerGenerated]
	private sealed class <RechargeVoltaicGrenade>d__1 : IEnumerator<object>, IDisposable, IEnumerator
	{
		private int <>1__state;

		private object <>2__current;

		public VoltaicGrenade grenade;

		public float duration;

		private float <time>5__2;

		private Traverse <traverse>5__3;

		object IEnumerator<object>.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		object IEnumerator.Current
		{
			[DebuggerHidden]
			get
			{
				return <>2__current;
			}
		}

		[DebuggerHidden]
		public <RechargeVoltaicGrenade>d__1(int <>1__state)
		{
			this.<>1__state = <>1__state;
		}

		[DebuggerHidden]
		void IDisposable.Dispose()
		{
			<traverse>5__3 = null;
			<>1__state = -2;
		}

		private bool MoveNext()
		{
			switch (<>1__state)
			{
			default:
				return false;
			case 0:
				<>1__state = -1;
				<time>5__2 = 0f;
				<traverse>5__3 = Traverse.Create((object)grenade);
				break;
			case 1:
				<>1__state = -1;
				break;
			}
			if (<time>5__2 < duration)
			{
				<time>5__2 += Time.deltaTime;
				float num = Mathf.Min(<time>5__2 / duration, 1f);
				<traverse>5__3.Field("cooldownData").Field("charge").SetValue((object)num);
				<traverse>5__3.Method("InvokeOnCooldownChanged", new object[1] { num }).GetValue();
				<>2__current = null;
				<>1__state = 1;
				return true;
			}
			return false;
		}

		bool IEnumerator.MoveNext()
		{
			//ILSpy generated this explicit interface implementation from .override directive in MoveNext
			return this.MoveNext();
		}

		[DebuggerHidden]
		void IEnumerator.Reset()
		{
			throw new NotSupportedException();
		}
	}

	private static bool Prefix(Player __instance)
	{
		//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
		if (!SparrohPlugin.EnableLivewireFix.Value)
		{
			return true;
		}
		try
		{
			IGear throwableGear = __instance.ThrowableGear;
			VoltaicGrenade val = (VoltaicGrenade)(object)((throwableGear is VoltaicGrenade) ? throwableGear : null);
			if ((Object)(object)val != (Object)null)
			{
				Traverse val2 = Traverse.Create((object)val);
				if (val2.Field("grenadeData").Field("selfGrenadeDuration").GetValue<float>() <= 0f)
				{
					return true;
				}
				if (val2.Field("selfGrenadeTimer").GetValue<float>() < 0f)
				{
					if (val2.Field("cooldownData").Field("charge").GetValue<float>() >= 1f)
					{
						((Throwable)val).OverrideActivate();
						CooldownData value = val2.Field("cooldownData").GetValue<CooldownData>();
						((MonoBehaviour)__instance).StartCoroutine(RechargeVoltaicGrenade(val, value.rechargeDuration));
						AbilityRechargeUI rechargeUI = __instance.PlayerLook.GetRechargeUI((IActivatedAbility)(object)val);
						if ((Object)(object)rechargeUI != (Object)null)
						{
							((Component)rechargeUI).gameObject.SetActive(true);
						}
						return false;
					}
					return false;
				}
				return false;
			}
			return true;
		}
		catch (Exception ex)
		{
			SparrohPlugin.Logger.LogError((object)("[LivewireFix] Error in Player_TryThrow_Patch: " + ex.Message + "\n" + ex.StackTrace));
			return true;
		}
	}

	[IteratorStateMachine(typeof(<RechargeVoltaicGrenade>d__1))]
	private static IEnumerator RechargeVoltaicGrenade(VoltaicGrenade grenade, float duration)
	{
		//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
		return new <RechargeVoltaicGrenade>d__1(0)
		{
			grenade = grenade,
			duration = duration
		};
	}
}
[HarmonyPatch(typeof(Throwable), "Fire")]
public class Throwable_Fire_Patch
{
	private static bool Prefix(Throwable __instance)
	{
		if (!SparrohPlugin.EnableLivewireFix.Value)
		{
			return true;
		}
		try
		{
			if (__instance is VoltaicGrenade)
			{
				if (Traverse.Create((object)__instance).Field("grenadeData").Field("selfGrenadeDuration")
					.GetValue<float>() <= 0f)
				{
					return true;
				}
				if (Traverse.Create((object)__instance).Field("selfGrenadeTimer").GetValue<float>() >= 0f)
				{
					return false;
				}
			}
			return true;
		}
		catch (Exception ex)
		{
			SparrohPlugin.Logger.LogError((object)("[LivewireFix] Error in Throwable_Fire_Patch: " + ex.Message + "\n" + ex.StackTrace));
			return true;
		}
	}
}
[HarmonyPatch(typeof(Throwable))]
[HarmonyPatch("get_CanEquipWhenUncharged")]
public class Throwable_CanEquipWhenUncharged_Patch
{
	private static void Postfix(ref bool __result, Throwable __instance)
	{
		if (!SparrohPlugin.EnableLivewireFix.Value)
		{
			return;
		}
		try
		{
			if (__instance is VoltaicGrenade && Traverse.Create((object)__instance).Field("grenadeData").Field("selfGrenadeDuration")
				.GetValue<float>() > 0f)
			{
				__result = true;
			}
		}
		catch (Exception ex)
		{
			SparrohPlugin.Logger.LogError((object)("[LivewireFix] Error in Throwable_CanEquipWhenUncharged_Patch: " + ex.Message + "\n" + ex.StackTrace));
		}
	}
}
[HarmonyPatch(typeof(AbilityRechargeUI), "OnCooldownChanged")]
public class AbilityRechargeUI_OnCooldownChanged_Patch
{
	private static void Postfix(AbilityRechargeUI __instance, float charge)
	{
		try
		{
			if (__instance.Ability is VoltaicGrenade)
			{
				((Component)__instance).gameObject.SetActive(true);
			}
		}
		catch (Exception ex)
		{
			SparrohPlugin.Logger.LogError((object)("[LivewireFix] Error in AbilityRechargeUI_OnCooldownChanged_Patch: " + ex.Message + "\n" + ex.StackTrace));
		}
	}
}
[HarmonyPatch(typeof(AbilityRechargeUI), "OnCooldownChanged")]
public class AbilityRechargeUI_OnCooldownChanged_Livewire_Patch
{
	private static void Postfix(AbilityRechargeUI __instance, float charge)
	{
		try
		{
			if (SparrohPlugin.EnableLivewireFix.Value && ((object)__instance.Ability).GetType().Name == "VoltaicGrenade")
			{
				((Component)__instance).gameObject.SetActive(true);
				if ((Object)(object)PlayerLook.Instance.GetRechargeUI(__instance.Ability) == (Object)null)
				{
					PlayerLook.Instance.AddRechargeUI(__instance);
				}
			}
		}
		catch (Exception ex)
		{
			SparrohPlugin.Logger.LogError((object)("[LivewireFix] Error in AbilityRechargeUI_OnCooldownChanged_Livewire_Patch: " + ex.Message + "\n" + ex.StackTrace));
		}
	}
}
[HarmonyPatch(typeof(AbilityRechargeUI), "Setup")]
public class AbilityRechargeUI_Setup_Patch
{
	private static void Postfix(AbilityRechargeUI __instance, IActivatedAbility ability, Vector2 position, AbilityRechargeUI prefab, int priority)
	{
		try
		{
			if (ability is VoltaicGrenade)
			{
				((Component)__instance).gameObject.SetActive(true);
			}
		}
		catch (Exception ex)
		{
			SparrohPlugin.Logger.LogError((object)("[LivewireFix] Error in AbilityRechargeUI_Setup_Patch: " + ex.Message + "\n" + ex.StackTrace));
		}
	}
}
[HarmonyPatch(typeof(AbilityRechargeUI), "Setup")]
public class AbilityRechargeUI_Setup_Livewire_Patch
{
	private static void Postfix(AbilityRechargeUI __instance, IActivatedAbility ability, Vector2 position, AbilityRechargeUI prefab, int priority)
	{
		try
		{
			if (SparrohPlugin.EnableLivewireFix.Value && ((object)ability).GetType().Name == "VoltaicGrenade")
			{
				((Component)__instance).gameObject.SetActive(true);
				if ((Object)(object)PlayerLook.Instance.GetRechargeUI(ability) == (Object)null)
				{
					PlayerLook.Instance.AddRechargeUI(__instance);
				}
			}
		}
		catch (Exception ex)
		{
			SparrohPlugin.Logger.LogError((object)("[LivewireFix] Error in AbilityRechargeUI_Setup_Livewire_Patch: " + ex.Message + "\n" + ex.StackTrace));
		}
	}
}
[HarmonyPatch(typeof(Throwable), "DisableHUD")]
public class Throwable_DisableHUD_Livewire_Patch
{
	private static void Postfix(Throwable __instance)
	{
		try
		{
			if (SparrohPlugin.EnableLivewireFix.Value && __instance is VoltaicGrenade)
			{
				AbilityRechargeUI rechargeUI = PlayerLook.Instance.GetRechargeUI((IActivatedAbility)(object)__instance);
				if ((Object)(object)rechargeUI != (Object)null)
				{
					((Component)rechargeUI).gameObject.SetActive(true);
				}
			}
		}
		catch (Exception ex)
		{
			SparrohPlugin.Logger.LogError((object)("[LivewireFix] Error in Throwable_DisableHUD_Livewire_Patch: " + ex.Message + "\n" + ex.StackTrace));
		}
	}
}
public static class LobbyStatusFix
{
	internal static int currentLobbyVisibility = 2;

	public static void ApplyPatches(Harmony harmony)
	{
		harmony.PatchAll(typeof(LobbyStatusFix));
	}

	[HarmonyPatch(typeof(StartMenu), "UpdateVisibilityButton")]
	[HarmonyPostfix]
	private static void UpdateVisibilityButton_Postfix(StartMenu __instance)
	{
		//IL_0035: Unknown result type (might be due to invalid IL or missing references)
		//IL_003b: Expected O, but got Unknown
		if (!SparrohPlugin.EnableLobbyStatusFix.Value)
		{
			return;
		}
		FieldInfo field = typeof(StartMenu).GetField("visibilityText", BindingFlags.Instance | BindingFlags.NonPublic);
		if (field == null)
		{
			return;
		}
		TextMeshProUGUI val = (TextMeshProUGUI)field.GetValue(__instance);
		if (!((Object)(object)val == (Object)null))
		{
			ulong lobbyID = Online.LobbyID;
			int num = currentLobbyVisibility;
			if (lobbyID == 0L)
			{
				float num2 = default(float);
				num = (PlayerOptions.TryGetConfig<float>("LobbyType", ref num2) ? Mathf.RoundToInt(num2) : 2);
			}
			((TMP_Text)val).text = TextBlocks.GetString(num switch
			{
				0 => "private", 
				1 => "friendonly", 
				2 => "public", 
				_ => "invisible", 
			});
		}
	}

	[HarmonyPatch(typeof(Online), "SetLobbyVisibility", new Type[] { typeof(int) })]
	[HarmonyPrefix]
	private static void SetLobbyVisibility_Prefix(int visibility)
	{
		if (SparrohPlugin.EnableLobbyStatusFix.Value)
		{
			currentLobbyVisibility = visibility;
		}
	}

	[HarmonyPatch(typeof(Online), "SetLobbyVisibility", new Type[] { typeof(int) })]
	[HarmonyPostfix]
	private static void SetLobbyVisibility_Postfix()
	{
		if (SparrohPlugin.EnableLobbyStatusFix.Value && (Object)(object)StartMenu.Instance != (Object)null)
		{
			MethodInfo method = typeof(StartMenu).GetMethod("UpdateVisibilityButton", BindingFlags.Instance | BindingFlags.NonPublic);
			if (method != null)
			{
				method.Invoke(StartMenu.Instance, null);
			}
		}
	}
}
public static class LookRotationFix
{
	public static void ApplyPatches(Harmony harmony)
	{
		harmony.PatchAll(typeof(Quaternion_LookRotation_Patch));
	}
}
[HarmonyPatch(typeof(Quaternion), "LookRotation", new Type[] { typeof(Vector3) })]
public class Quaternion_LookRotation_Patch
{
	private static bool Prefix(Vector3 forward, ref Quaternion __result)
	{
		//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_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)
		if (!SparrohPlugin.EnableLookRotationFix.Value)
		{
			return true;
		}
		if (forward == Vector3.zero)
		{
			__result = Quaternion.identity;
			return false;
		}
		return true;
	}
}
[BepInPlugin("sparroh.unofficialpatch", "UnofficialPatch", "1.2.0")]
[MycoMod(/*Could not decode attribute arguments.*/)]
public class SparrohPlugin : BaseUnityPlugin
{
	public const string PluginGUID = "sparroh.unofficialpatch";

	public const string PluginName = "UnofficialPatch";

	public const string PluginVersion = "1.2.0";

	internal static ManualLogSource Logger;

	public static ConfigFile Config { get; private set; }

	public static ConfigEntry<bool> EnableGlobblerFriendFireFix { get; private set; }

	public static ConfigEntry<bool> EnableLivewireFix { get; private set; }

	public static ConfigEntry<bool> EnablePressureCookerFix { get; private set; }

	public static ConfigEntry<bool> EnablePrismDetailsFix { get; private set; }

	public static ConfigEntry<bool> EnableCraniusDialogueFix { get; private set; }

	public static ConfigEntry<bool> EnableDMLRBatteryFix { get; private set; }

	public static ConfigEntry<bool> EnableRoachardSleepFix { get; private set; }

	public static ConfigEntry<bool> EnableSetDestinationFix { get; private set; }

	public static ConfigEntry<bool> EnableStartupSuppression { get; private set; }

	public static ConfigEntry<bool> EnableThrilloftheFightFix { get; private set; }

	public static ConfigEntry<bool> EnableSelfDestructFix { get; private set; }

	public static ConfigEntry<bool> EnableAutoSprintFix { get; private set; }

	public static ConfigEntry<bool> EnableCyclerDestructionFix { get; private set; }

	public static ConfigEntry<bool> EnableHoverLobbyModifierFix { get; private set; }

	public static ConfigEntry<bool> EnableLookRotationFix { get; private set; }

	public static ConfigEntry<bool> EnableLobbyStatusFix { get; private set; }

	public static ConfigEntry<bool> EnableUnicodeFix { get; private set; }

	public static ConfigEntry<bool> EnableSatelliteSalvageFix { get; private set; }

	public static ConfigEntry<bool> EnableTempStorageFix { get; private set; }

	private void Awake()
	{
		//IL_029c: Unknown result type (might be due to invalid IL or missing references)
		//IL_02a2: Expected O, but got Unknown
		Logger = ((BaseUnityPlugin)this).Logger;
		Config = ((BaseUnityPlugin)this).Config;
		EnableGlobblerFriendFireFix = Config.Bind<bool>("Modules", "Enable Globbler Friend Fire Fix", false, "Enable/disable the Globbler friend fire fix module.");
		EnableLivewireFix = Config.Bind<bool>("Modules", "Enable Livewire Fix", true, "Enable/disable the Livewire fix module.");
		EnablePressureCookerFix = Config.Bind<bool>("Modules", "Enable Pressure Cooker Fix", true, "Enable/disable the Pressure Cooker fix module.");
		GlobblerPatches.IsEnabled = EnablePressureCookerFix.Value;
		EnablePrismDetailsFix = Config.Bind<bool>("Modules", "Enable Prism Details Fix", true, "Enable/disable the Prism Details fix module.");
		EnableCraniusDialogueFix = Config.Bind<bool>("Modules", "Enable Cranius Dialogue Fix", true, "Enable/disable the Cranius Dialogue fix module.");
		EnableDMLRBatteryFix = Config.Bind<bool>("Modules", "Enable DMLR Battery Fix", true, "Enable/disable the DMLR Battery fix module.");
		EnableRoachardSleepFix = Config.Bind<bool>("Modules", "Enable Roachard Sleep Fix", true, "Enable/disable the Roachard Sleep fix module.");
		EnableSetDestinationFix = Config.Bind<bool>("Modules", "Enable Set Destination Fix", true, "Enable/disable the Set Destination fix module.");
		EnableStartupSuppression = Config.Bind<bool>("Modules", "Enable Startup Suppression", true, "Enable/disable the Startup Suppression module.");
		EnableThrilloftheFightFix = Config.Bind<bool>("Modules", "Enable Thrill of the Fight Fix", true, "Enable/disable the Thrill of the Fight fix module.");
		EnableSelfDestructFix = Config.Bind<bool>("Modules", "Enable Self Destruct Fix", true, "Enable/disable the Self Destruct fix module.");
		EnableAutoSprintFix = Config.Bind<bool>("Modules", "Enable Auto Sprint Fix", true, "Enable/disable the Auto Sprint fix module.");
		EnableCyclerDestructionFix = Config.Bind<bool>("Modules", "Enable Cycler Destruction Fix", true, "Enable/disable the Cycler Destruction fix module.");
		EnableHoverLobbyModifierFix = Config.Bind<bool>("Modules", "Enable Hover Lobby Modifier Fix", true, "Enable/disable the Hover Lobby Modifier fix module.");
		EnableLookRotationFix = Config.Bind<bool>("Modules", "Enable Look Rotation Fix", true, "Enable/disable the Look Rotation fix module.");
		EnableLobbyStatusFix = Config.Bind<bool>("Modules", "Enable Lobby Status Fix", true, "Enable/disable the Lobby Status fix module.");
		EnableUnicodeFix = Config.Bind<bool>("Modules", "Enable Unicode Fix", true, "Enable/disable the Unicode fix module.");
		EnableSatelliteSalvageFix = Config.Bind<bool>("Modules", "Enable Satellite Salvage Fix", true, "Enable/disable the Satellite Salvage fix module.");
		EnableTempStorageFix = Config.Bind<bool>("Modules", "Enable Temp Storage Fix", true, "Enable/disable the Temp Storage fix module.");
		if (EnableStartupSuppression.Value)
		{
			Debug.logger.logHandler = (ILogHandler)(object)new FilteredLogHandler(Debug.logger.logHandler);
		}
		Harmony val = new Harmony("sparroh.unofficialpatch");
		val.PatchAll();
		val.PatchAll(typeof(GlobblerPatches));
		if (EnableHoverLobbyModifierFix.Value)
		{
			HoverLobbyModifierFix.ApplyPatches(val);
		}
		if (EnableLookRotationFix.Value)
		{
			LookRotationFix.ApplyPatches(val);
		}
		if (EnableLobbyStatusFix.Value)
		{
			LobbyStatusFix.ApplyPatches(val);
		}
		if (EnableUnicodeFix.Value)
		{
			UnicodeFix.ApplyPatches(val);
		}
		Logger.LogInfo((object)"UnofficialPatch loaded successfully.");
	}
}
public static class GlobblerPatches
{
	public static bool IsEnabled = true;

	[HarmonyPatch(typeof(Globbler), "OverrideHoldReload")]
	[HarmonyPrefix]
	public static void OverrideHoldReload_Prefix(Globbler __instance, ref bool __result)
	{
		if (!IsEnabled)
		{
			return;
		}
		try
		{
			if (__instance.GlobblerData.chargeTimePerAmmo > 0f && ((Gun)__instance).WantsToFire)
			{
				__result = true;
			}
		}
		catch (Exception ex)
		{
			SparrohPlugin.Logger.LogError((object)("[PressureCookerFix] Error in OverrideHoldReload_Prefix: " + ex.Message + "\n" + ex.StackTrace));
		}
	}

	[HarmonyPatch(typeof(Gun), "OnReloadPerformed")]
	[HarmonyPrefix]
	public static bool OnReloadPerformed_Prefix(Gun __instance, object context)
	{
		if (!IsEnabled)
		{
			return true;
		}
		try
		{
			Globbler val = (Globbler)(object)((__instance is Globbler) ? __instance : null);
			if (val != null && val.GlobblerData.chargeTimePerAmmo > 0f && ((Gun)val).WantsToFire)
			{
				return false;
			}
			return true;
		}
		catch (Exception ex)
		{
			SparrohPlugin.Logger.LogError((object)("[PressureCookerFix] Error in OnReloadPerformed_Prefix: " + ex.Message + "\n" + ex.StackTrace));
			return true;
		}
	}

	[HarmonyPatch(typeof(Globbler), "OnFire")]
	[HarmonyPrefix]
	public static bool OnFire_Prefix(Globbler __instance, int numBullets)
	{
		if (!IsEnabled)
		{
			return true;
		}
		try
		{
			Traverse.Create((object)__instance).Field<float>("globChargeTimer").Value = 0f;
			Traverse.Create((object)__instance).Field<int>("globChargeAmmo").Value = 0;
			if (__instance.GlobblerData.chargeTimePerAmmo <= 0f)
			{
				return true;
			}
			return false;
		}
		catch (Exception ex)
		{
			SparrohPlugin.Logger.LogError((object)("[PressureCookerFix] Error in OnFire_Prefix: " + ex.Message + "\n" + ex.StackTrace));
			return true;
		}
	}
}
[HarmonyPatch(typeof(Upgrade), "GetStatList")]
public static class Upgrade_GetStatList_Patch
{
	private static bool ShowExtraInfo()
	{
		Type type = Type.GetType("Pigeon.HoverInfo, Assembly-CSharp");
		if (type != null)
		{
			MethodInfo method = type.GetMethod("ShowExtraInfo", BindingFlags.Static | BindingFlags.Public);
			if (method != null)
			{
				return (bool)method.Invoke(null, null);
			}
		}
		return false;
	}

	[HarmonyPostfix]
	public static void Postfix(ref string __result, Upgrade __instance, int seed, UpgradeInstance instance)
	{
		//IL_0018: Unknown result type (might be due to invalid IL or missing references)
		//IL_001d: Unknown result type (might be due to invalid IL or missing references)
		if (!SparrohPlugin.EnablePrismDetailsFix.Value)
		{
			return;
		}
		try
		{
			if (__result == null)
			{
				return;
			}
			UpgradePropertyList properties = __instance.Properties;
			if (!((UpgradePropertyList)(ref properties)).HasProperties)
			{
				return;
			}
			bool flag = false;
			foreach (UpgradeProperty item in (UpgradePropertyList)(ref properties))
			{
				if (item is UpgradeProperty_MiniCannon_Prism)
				{
					flag = true;
					break;
				}
			}
			if (flag && ShowExtraInfo())
			{
				string[] array = __result.Split(new char[1] { '\n' });
				if (array.Length != 0 && array[0].Contains("Efficiency"))
				{
					array[0] += " [50% - 150%]";
					__result = string.Join("\n", array);
				}
			}
		}
		catch (Exception ex)
		{
			SparrohPlugin.Logger.LogError((object)("[PrismDetailsFix] Error in Upgrade_GetStatList_Patch: " + ex.Message + "\n" + ex.StackTrace));
		}
	}
}
[HarmonyPatch(typeof(SatelliteDecommissioner), "GetLaserTargetRotation")]
public static class SatelliteDecommissioner_GetLaserTargetRotation_Patch
{
	[HarmonyPrefix]
	public static bool Prefix(SatelliteDecommissioner __instance, int masterIndex, ref Quaternion __result)
	{
		//IL_0048: Unknown result type (might be due to invalid IL or missing references)
		//IL_004d: Unknown result type (might be due to invalid IL or missing references)
		if (!SparrohPlugin.EnableSatelliteSalvageFix.Value)
		{
			return true;
		}
		Random val = default(Random);
		((Random)(ref val))..ctor(MissionManager.MissionSeed + masterIndex);
		float num = ((Random)(ref val)).NextFloat(0f, 360f);
		float num2 = ((Random)(ref val)).NextFloat(270f, 360f);
		__result = Quaternion.Euler(num2, num, 0f);
		return false;
	}
}
[HarmonyPatch(typeof(DecommissionerControllerWindow), "UpdateDiskMarker")]
public static class DecommissionerControllerWindow_UpdateDiskMarker_Patch
{
	[HarmonyPostfix]
	public static void Postfix(DecommissionerControllerWindow __instance)
	{
		//IL_0082: Unknown result type (might be due to invalid IL or missing references)
		//IL_0087: Unknown result type (might be due to invalid IL or missing references)
		//IL_008b: Unknown result type (might be due to invalid IL or missing references)
		//IL_0090: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b0: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b5: Unknown result type (might be due to invalid IL or missing references)
		//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
		//IL_00be: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
		//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
		//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
		if (!SparrohPlugin.EnableSatelliteSalvageFix.Value)
		{
			return;
		}
		Traverse obj = Traverse.Create((object)__instance);
		RectTransform value = obj.Field<RectTransform>("diskContainer").Value;
		DotMatrix value2 = obj.Field<DotMatrix>("targetMarker").Value;
		SatelliteDecommissioner value3 = obj.Field<SatelliteDecommissioner>("Decommissioner").Value;
		DecommissionerControllerInteractable value4 = obj.Field<DecommissionerControllerInteractable>("Interactable").Value;
		if (!((Object)(object)value3 == (Object)null) && !((Object)(object)value4 == (Object)null) && !((Object)(object)value == (Object)null) && !((Object)(object)value2 == (Object)null))
		{
			Quaternion laserTargetRotation = value3.GetLaserTargetRotation(value4.MasterDecomIndex);
			Vector3 eulerAngles = ((Quaternion)(ref laserTargetRotation)).eulerAngles;
			float y = eulerAngles.y;
			float num = eulerAngles.x;
			if (num < 270f)
			{
				num = 360f;
			}
			Rect rect = value.rect;
			Vector2 size = ((Rect)(ref rect)).size;
			((Graphic)value2).rectTransform.anchoredPosition = new Vector2(y / 360f * size.x, Mathf.InverseLerp(270f, 360f, num) * size.y);
		}
	}
}
[HarmonyPatch(typeof(EnemyCore), "RushPlayerWhenTooWeak")]
public class EnemyCore_RushPlayerWhenTooWeak_Patch
{
	[HarmonyPrefix]
	public static bool Prefix()
	{
		if (!SparrohPlugin.EnableSelfDestructFix.Value)
		{
			return true;
		}
		try
		{
			return false;
		}
		catch (Exception ex)
		{
			SparrohPlugin.Logger.LogError((object)("[SelfDestructFix] Error in EnemyCore_RushPlayerWhenTooWeak_Patch: " + ex.Message + "\n" + ex.StackTrace));
			return true;
		}
	}
}
public class FilteredLogHandler : ILogHandler
{
	private ILogHandler originalHandler;

	public FilteredLogHandler(ILogHandler original)
	{
		originalHandler = original;
	}

	public void LogFormat(LogType logType, Object context, string format, params object[] args)
	{
		//IL_0019: Unknown result type (might be due to invalid IL or missing references)
		string message = string.Format(format, args);
		if (!ShouldSuppress(message))
		{
			originalHandler.LogFormat(logType, context, format, args);
		}
	}

	public void LogException(Exception exception, Object context)
	{
		string message = exception?.ToString() ?? "";
		if (!ShouldSuppress(message))
		{
			originalHandler.LogException(exception, context);
		}
	}

	private bool ShouldSuppress(string message)
	{
		if (!message.Contains("missing") && !message.Contains("Missing") && !message.Contains("Convex Mesh") && !message.Contains("NetworkPrefab") && !message.Contains("Removing invalid prefabs") && !message.Contains("Post Event failed") && !message.Contains("render texture"))
		{
			return message.Contains("Event System");
		}
		return true;
	}
}
[HarmonyPatch(typeof(NetworkManager), "Awake")]
public class NetworkManager_Awake_Patch
{
	[HarmonyPostfix]
	public static void Postfix(NetworkManager __instance)
	{
		if (!SparrohPlugin.EnableStartupSuppression.Value)
		{
			return;
		}
		try
		{
			foreach (NetworkPrefab prefab in __instance.NetworkConfig.Prefabs.Prefabs)
			{
				if ((Object)(object)prefab.Prefab != (Object)null && !Object.op_Implicit((Object)(object)prefab.Prefab.GetComponent<NetworkObject>()))
				{
					prefab.Prefab.AddComponent<NetworkObject>();
				}
			}
		}
		catch (Exception ex)
		{
			SparrohPlugin.Logger.LogError((object)("[StartupSuppression] Error in NetworkManager_Awake_Patch: " + ex.Message + "\n" + ex.StackTrace));
		}
	}
}
[HarmonyPatch(typeof(TempUpgradeStorage), "OnPointerDown")]
public static class TempUpgradeStorage_OnPointerDown_Patch
{
	private static readonly FieldInfo backgroundField = AccessTools.Field(typeof(TempUpgradeStorage), "background");

	private static readonly FieldInfo windowField = AccessTools.Field(typeof(TempUpgradeStorage), "window");

	public static bool Prefix(TempUpgradeStorage __instance, PointerEventData eventData)
	{
		//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_0040: Unknown result type (might be due to invalid IL or missing references)
		//IL_0046: Expected O, but got Unknown
		if (!SparrohPlugin.EnableTempStorageFix.Value)
		{
			return true;
		}
		if ((Object)(object)GearDetailsWindow.SelectedUpgrade != (Object)null)
		{
			((Graphic)backgroundField.GetValue(__instance)).color = Color.white;
			GearDetailsWindow val = (GearDetailsWindow)windowField.GetValue(__instance);
			if (val.AddUpgradeToTempStorage(((HoverInfoUpgrade)GearDetailsWindow.SelectedUpgrade).Upgrade))
			{
				val.SelectUpgrade((GearUpgradeUI)null);
				GearDetailsWindow.DisableTempStorageClick = true;
			}
			return false;
		}
		return true;
	}
}
[HarmonyPatch(typeof(GearDetailsWindow), "AddUpgradeToTempStorage")]
public static class GearDetailsWindow_AddUpgradeToTempStorage_Patch
{
	private static readonly FieldInfo tempStoredUpgradesField = AccessTools.Field(typeof(GearDetailsWindow), "tempStoredUpgrades");

	private static readonly FieldInfo upgradeUIPrefabField = AccessTools.Field(typeof(GearDetailsWindow), "upgradeUIPrefab");

	private static readonly FieldInfo tempStorageParentField = AccessTools.Field(typeof(GearDetailsWindow), "tempStorageParent");

	public static bool Prefix(GearDetailsWindow __instance, UpgradeInstance upgrade, ref bool __result)
	{
		//IL_0106: Unknown result type (might be due to invalid IL or missing references)
		//IL_0116: Unknown result type (might be due to invalid IL or missing references)
		//IL_011c: Expected O, but got Unknown
		//IL_0122: Expected O, but got Unknown
		if (!SparrohPlugin.EnableTempStorageFix.Value)
		{
			return true;
		}
		List<GearUpgradeUI> list = (List<GearUpgradeUI>)tempStoredUpgradesField.GetValue(__instance);
		if (list == null)
		{
			list = new List<GearUpgradeUI>();
			tempStoredUpgradesField.SetValue(__instance, list);
		}
		int num = 0;
		for (int i = 0; i < list.Count; i++)
		{
			if (((Component)list[i]).gameObject.activeSelf)
			{
				num++;
			}
		}
		if (num >= 12)
		{
			__result = false;
			return false;
		}
		for (int j = 0; j < list.Count; j++)
		{
			if (((HoverInfoUpgrade)list[j]).Upgrade == upgrade && ((Component)list[j]).gameObject.activeSelf)
			{
				__result = false;
				return false;
			}
		}
		for (int k = 0; k < list.Count; k++)
		{
			if (!((Component)list[k]).gameObject.activeSelf)
			{
				list[k].SetUpgrade(upgrade, false);
				((Component)list[k]).gameObject.SetActive(true);
				__result = true;
				return false;
			}
		}
		GearUpgradeUI val = (GearUpgradeUI)upgradeUIPrefabField.GetValue(__instance);
		RectTransform val2 = (RectTransform)tempStorageParentField.GetValue(__instance);
		GearUpgradeUI val3 = Object.Instantiate<GearUpgradeUI>(val, (Transform)(object)val2);
		val3.IsTempStorage = true;
		list.Add(val3);
		val3.SetUpgrade(upgrade, false);
		val3.EnableGridView(true);
		__result = true;
		return false;
	}
}
public static class UnicodeFix
{
	internal static ManualLogSource Logger => SparrohPlugin.Logger;

	public static void ApplyPatches(Harmony harmony)
	{
		harmony.PatchAll(typeof(UnicodeFix));
	}

	[HarmonyPatch(typeof(Global), "Initialize")]
	[HarmonyPostfix]
	private static void AddUnicodeFallbacks()
	{
		if (!SparrohPlugin.EnableUnicodeFix.Value || (Object)(object)Global.Instance == (Object)null)
		{
			return;
		}
		Font val = Font.CreateDynamicFontFromOSFont(new string[4] { "Segoe UI", "Arial Unicode MS", "Arial", "Microsoft Sans Serif" }, 12);
		if ((Object)(object)val == (Object)null)
		{
			return;
		}
		TMP_FontAsset val2 = TMP_FontAsset.CreateFontAsset(val);
		if (!((Object)(object)val2 == (Object)null))
		{
			if ((Object)(object)Global.Instance.NormalFont != (Object)null && !Global.Instance.NormalFont.fallbackFontAssetTable.Contains(val2))
			{
				Global.Instance.NormalFont.fallbackFontAssetTable.Add(val2);
			}
			if ((Object)(object)Global.Instance.BoldFont != (Object)null && !Global.Instance.BoldFont.fallbackFontAssetTable.Contains(val2))
			{
				Global.Instance.BoldFont.fallbackFontAssetTable.Add(val2);
			}
			if ((Object)(object)TMP_Settings.defaultFontAsset != (Object)null && ((Object)TMP_Settings.defaultFontAsset).name.Contains("Antikor") && !TMP_Settings.defaultFontAsset.fallbackFontAssetTable.Contains(val2))
			{
				TMP_Settings.defaultFontAsset.fallbackFontAssetTable.Add(val2);
			}
		}
	}
}
[CompilerGenerated]
[ExcludeFromCodeCoverage]
internal static class GitVersionInformation
{
	public const string AssemblySemFileVer = "0.0.1.0";

	public const string AssemblySemVer = "0.0.1.0";

	public const string BranchName = "master";

	public const string BuildMetaData = "";

	public const string CommitDate = "2026-01-02";

	public const string CommitsSinceVersionSource = "11";

	public const string EscapedBranchName = "master";

	public const string FullBuildMetaData = "Branch.master.Sha.d42a84c0a1c438cfe022b9bc1173c531c5c2aefd";

	public const string FullSemVer = "0.0.1-11";

	public const string InformationalVersion = "0.0.1-11+Branch.master.Sha.d42a84c0a1c438cfe022b9bc1173c531c5c2aefd";

	public const string Major = "0";

	public const string MajorMinorPatch = "0.0.1";

	public const string Minor = "0";

	public const string Patch = "1";

	public const string PreReleaseLabel = "";

	public const string PreReleaseLabelWithDash = "";

	public const string PreReleaseNumber = "11";

	public const string PreReleaseTag = "11";

	public const string PreReleaseTagWithDash = "-11";

	public const string SemVer = "0.0.1-11";

	public const string Sha = "d42a84c0a1c438cfe022b9bc1173c531c5c2aefd";

	public const string ShortSha = "d42a84c";

	public const string UncommittedChanges = "4";

	public const string VersionSourceSha = "";

	public const string WeightedPreReleaseNumber = "55011";
}
namespace UnofficialPatch
{
	public static class MyPluginInfo
	{
		public const string PLUGIN_GUID = "UnofficialPatch";

		public const string PLUGIN_NAME = "UnofficialPatch";

		public const string PLUGIN_VERSION = "1.0.0";
	}
}
namespace System.Runtime.CompilerServices
{
	[AttributeUsage(AttributeTargets.Assembly, AllowMultiple = true)]
	internal sealed class IgnoresAccessChecksToAttribute : Attribute
	{
		public IgnoresAccessChecksToAttribute(string assemblyName)
		{
		}
	}
}