Decompiled source of MiniEepo v1.3.6

MiniEepo.dll

Decompiled 3 days ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using ScalerCore;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MiniEepo")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.3.6.0")]
[assembly: AssemblyInformationalVersion("1.3.6+97095ce6814b3dfcfca75c21d9fecb03562120ae")]
[assembly: AssemblyProduct("MiniEepo")]
[assembly: AssemblyTitle("MiniEepo")]
[assembly: AssemblyVersion("1.3.6.0")]
[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.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

		public NullableAttribute(byte P_0)
		{
			NullableFlags = new byte[1] { P_0 };
		}

		public NullableAttribute(byte[] P_0)
		{
			NullableFlags = P_0;
		}
	}
	[CompilerGenerated]
	[Microsoft.CodeAnalysis.Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Struct | AttributeTargets.Method | AttributeTargets.Interface | AttributeTargets.Delegate, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableContextAttribute : Attribute
	{
		public readonly byte Flag;

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[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 MiniEepo
{
	[BepInPlugin("darkharasho.MiniEepo", "MiniEepo", "1.3.6")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal static ManualLogSource Log = null;

		internal static ConfigEntry<float> PlayerScale = null;

		internal static ConfigEntry<float> ItemScale = null;

		internal static ConfigEntry<float> ValuableScale = null;

		internal static ConfigEntry<float> CartScale = null;

		internal static ConfigEntry<bool> VoiceMod = null;

		internal static ConfigEntry<bool> ShrinkInShop = null;

		internal static float ActivePlayerScale;

		internal static float ActiveItemScale;

		internal static float ActiveValuableScale;

		internal static float ActiveCartScale;

		internal static bool ActiveVoiceMod;

		internal static bool ActiveShrinkInShop;

		internal static readonly HashSet<int> ManagedObjects = new HashSet<int>();

		internal static bool IsApplying;

		private void Awake()
		{
			//IL_003b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Expected O, but got Unknown
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Expected O, but got Unknown
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Expected O, but got Unknown
			//IL_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Expected O, but got Unknown
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Expected O, but got Unknown
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Expected O, but got Unknown
			//IL_0239: Unknown result type (might be due to invalid IL or missing references)
			//IL_023f: Expected O, but got Unknown
			//IL_02fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Expected O, but got Unknown
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_0391: Expected O, but got Unknown
			//IL_0474: Unknown result type (might be due to invalid IL or missing references)
			//IL_0481: Expected O, but got Unknown
			//IL_0574: Unknown result type (might be due to invalid IL or missing references)
			//IL_0582: Expected O, but got Unknown
			//IL_0664: Unknown result type (might be due to invalid IL or missing references)
			//IL_0672: Expected O, but got Unknown
			//IL_06ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_06f7: Expected O, but got Unknown
			//IL_0774: Unknown result type (might be due to invalid IL or missing references)
			//IL_0781: Expected O, but got Unknown
			//IL_083c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0849: Expected O, but got Unknown
			Log = ((BaseUnityPlugin)this).Logger;
			AcceptableValueRange<float> val = new AcceptableValueRange<float>(0.1f, 1f);
			PlayerScale = ((BaseUnityPlugin)this).Config.Bind<float>("Scaling", "PlayerScale", 0.4f, new ConfigDescription("Scale multiplier for players (0.4 = 40%)", (AcceptableValueBase)(object)val, Array.Empty<object>()));
			ItemScale = ((BaseUnityPlugin)this).Config.Bind<float>("Scaling", "ItemScale", 0.4f, new ConfigDescription("Scale multiplier for items (0.4 = 40%)", (AcceptableValueBase)(object)val, Array.Empty<object>()));
			ValuableScale = ((BaseUnityPlugin)this).Config.Bind<float>("Scaling", "ValuableScale", 0.4f, new ConfigDescription("Scale multiplier for valuables (0.4 = 40%)", (AcceptableValueBase)(object)val, Array.Empty<object>()));
			CartScale = ((BaseUnityPlugin)this).Config.Bind<float>("Scaling", "CartScale", 1f, new ConfigDescription("Extra scale multiplier applied when a valuable is in the cart (1.0 = no change, 0.5 = half size)", (AcceptableValueBase)(object)val, Array.Empty<object>()));
			VoiceMod = ((BaseUnityPlugin)this).Config.Bind<bool>("Audio", "VoiceMod", true, new ConfigDescription("Enable voice pitch modulation when players are shrunk", (AcceptableValueBase)null, Array.Empty<object>()));
			ShrinkInShop = ((BaseUnityPlugin)this).Config.Bind<bool>("Scaling", "ShrinkInShop", false, new ConfigDescription("If true, shrinking applies in the shop level too. Default false — items stay normal size while shopping.", (AcceptableValueBase)null, Array.Empty<object>()));
			ResetToLocalConfig();
			VoiceMod.SettingChanged += delegate
			{
				ActiveVoiceMod = VoiceMod.Value;
			};
			PlayerScale.SettingChanged += delegate
			{
				OnHostScaleConfigChanged();
			};
			ItemScale.SettingChanged += delegate
			{
				OnHostScaleConfigChanged();
			};
			ValuableScale.SettingChanged += delegate
			{
				OnHostScaleConfigChanged();
			};
			CartScale.SettingChanged += delegate
			{
				OnHostScaleConfigChanged();
			};
			ShrinkInShop.SettingChanged += delegate
			{
				OnHostScaleConfigChanged();
			};
			((Component)this).gameObject.AddComponent<SettingsSyncer>();
			Harmony val2 = new Harmony("darkharasho.MiniEepo");
			val2.PatchAll();
			Type type = null;
			Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly in assemblies)
			{
				if (assembly.GetName().Name != "ScalerCore")
				{
					continue;
				}
				Type[] types = assembly.GetTypes();
				foreach (Type type2 in types)
				{
					if (type2.Name == "AudioPitchHelper")
					{
						type = type2;
						break;
					}
				}
				if (type != null)
				{
					break;
				}
			}
			MethodInfo methodInfo = ((type != null) ? AccessTools.Method(type, "ApplyPitch", (Type[])null, (Type[])null) : null);
			if (methodInfo != null)
			{
				val2.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(VoicePitchPatch), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				Log.LogInfo((object)("[Voice] Patched " + type.FullName + ".ApplyPitch (Sound pitch)"));
			}
			else
			{
				Log.LogWarning((object)"[Voice] AudioPitchHelper.ApplyPitch not found");
			}
			Type type3 = AccessTools.TypeByName("PlayerVoiceChat");
			MethodInfo methodInfo2 = ((type3 != null) ? AccessTools.Method(type3, "OverridePitch", (Type[])null, (Type[])null) : null);
			if (methodInfo2 != null)
			{
				val2.Patch((MethodBase)methodInfo2, new HarmonyMethod(typeof(VoicePitchPatch), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				Log.LogInfo((object)"[Voice] Patched PlayerVoiceChat.OverridePitch (Photon Voice pitch)");
			}
			else
			{
				Log.LogWarning((object)"[Voice] PlayerVoiceChat.OverridePitch not found");
			}
			Type type4 = null;
			assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly2 in assemblies)
			{
				if (assembly2.GetName().Name != "ScalerCore")
				{
					continue;
				}
				Type[] types = assembly2.GetTypes();
				foreach (Type type5 in types)
				{
					if (type5.Name == "PlayerHandler")
					{
						type4 = type5;
						break;
					}
				}
				if (type4 != null)
				{
					break;
				}
			}
			MethodInfo methodInfo3 = ((type4 != null) ? AccessTools.Method(type4, "OnUpdate", (Type[])null, (Type[])null) : null);
			if (methodInfo3 != null)
			{
				val2.Patch((MethodBase)methodInfo3, (HarmonyMethod)null, new HarmonyMethod(typeof(VoicePitchPatch), "PlayerHandlerOnUpdatePostfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				Log.LogInfo((object)("[Voice] Patched " + type4.FullName + ".OnUpdate (per-frame voice pitch fields)"));
			}
			else
			{
				Log.LogWarning((object)"[Voice] PlayerHandler.OnUpdate not found");
			}
			Type type6 = null;
			assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly3 in assemblies)
			{
				if (assembly3.GetName().Name != "ScalerCore")
				{
					continue;
				}
				Type[] types = assembly3.GetTypes();
				foreach (Type type7 in types)
				{
					if (type7.Name == "PlayerBonkPatch")
					{
						type6 = type7;
						break;
					}
				}
				if (type6 != null)
				{
					break;
				}
			}
			MethodInfo methodInfo4 = ((type6 != null) ? AccessTools.Method(type6, "Postfix", (Type[])null, (Type[])null) : null);
			if (methodInfo4 != null)
			{
				val2.Patch((MethodBase)methodInfo4, new HarmonyMethod(typeof(BonkBlocker), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				Log.LogInfo((object)"[BonkImmune] Disabled ScalerCore's damage-bonk-expand (damage no longer un-shrinks)");
			}
			else
			{
				Log.LogWarning((object)"[BonkImmune] PlayerBonkPatch.Postfix not found — damage may un-shrink");
			}
			Type type8 = null;
			assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly4 in assemblies)
			{
				if (assembly4.GetName().Name != "ScalerCore")
				{
					continue;
				}
				Type[] types = assembly4.GetTypes();
				foreach (Type type9 in types)
				{
					if (type9.Name == "PlayerDeathExpandPatch")
					{
						type8 = type9;
						break;
					}
				}
				if (type8 != null)
				{
					break;
				}
			}
			MethodInfo methodInfo5 = ((type8 != null) ? AccessTools.Method(type8, "Postfix", (Type[])null, (Type[])null) : null);
			if (methodInfo5 != null)
			{
				val2.Patch((MethodBase)methodInfo5, new HarmonyMethod(typeof(BonkBlocker), "Prefix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				Log.LogInfo((object)"[BonkImmune] Disabled ScalerCore's death-expand (dying no longer un-shrinks)");
			}
			else
			{
				Log.LogWarning((object)"[BonkImmune] PlayerDeathExpandPatch.Postfix not found — death may un-shrink");
			}
			string[] array = new string[2] { "ReviveRPC", "Revive" };
			foreach (string text in array)
			{
				MethodInfo methodInfo6 = AccessTools.Method(typeof(PlayerAvatar), text, (Type[])null, (Type[])null);
				if (!(methodInfo6 == null))
				{
					val2.Patch((MethodBase)methodInfo6, (HarmonyMethod)null, new HarmonyMethod(typeof(PlayerRevivePatch), "Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					Log.LogInfo((object)("[Revive] Patched " + text));
				}
			}
			if (Chainloader.PluginInfos.ContainsKey("Jangnana.SolidAim"))
			{
				Log.LogInfo((object)"[Stabilize] SolidAim detected — skipping built-in held-gun stabilization");
			}
			else
			{
				MethodInfo methodInfo7 = AccessTools.Method(typeof(PhysGrabObject), "FixedUpdate", (Type[])null, (Type[])null);
				if (methodInfo7 != null)
				{
					val2.Patch((MethodBase)methodInfo7, (HarmonyMethod)null, new HarmonyMethod(typeof(HeldGunStabilizationPatch), "Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				}
			}
			Type type10 = null;
			assemblies = AppDomain.CurrentDomain.GetAssemblies();
			foreach (Assembly assembly5 in assemblies)
			{
				if (assembly5.GetName().Name != "ScalerCore")
				{
					continue;
				}
				Type[] types = assembly5.GetTypes();
				foreach (Type type11 in types)
				{
					if (type11.Name == "CartHandledDistancePatch")
					{
						type10 = type11;
						break;
					}
				}
				break;
			}
			MethodInfo methodInfo8 = ((type10 != null) ? AccessTools.Method(type10, "ScalePullDist", (Type[])null, (Type[])null) : null);
			if (methodInfo8 != null)
			{
				val2.Patch((MethodBase)methodInfo8, (HarmonyMethod)null, new HarmonyMethod(typeof(CartStandoffShrinkPatch), "Postfix", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
				Log.LogInfo((object)"[Cart] Strengthened shrunk-grabber cart standoff (reduces cart recoil/shove on tiny players)");
			}
			else
			{
				Log.LogWarning((object)"[Cart] ScalerCore CartHandledDistancePatch.ScalePullDist not found — cart may shove shrunk players");
			}
			Log.LogInfo((object)"MiniEepo v1.3.6 loaded — everything is tiny now.");
		}

		internal static void ResetToLocalConfig()
		{
			ActivePlayerScale = PlayerScale.Value;
			ActiveItemScale = ItemScale.Value;
			ActiveValuableScale = ValuableScale.Value;
			ActiveCartScale = CartScale.Value;
			ActiveVoiceMod = VoiceMod.Value;
			ActiveShrinkInShop = ShrinkInShop.Value;
		}

		private static void OnHostScaleConfigChanged()
		{
			if (!PhotonNetwork.InRoom || PhotonNetwork.IsMasterClient)
			{
				ResetToLocalConfig();
				SettingsSyncer.Instance?.PushHostSettingsExternal();
			}
		}

		internal static bool IsInGameplay()
		{
			if (!PhotonNetwork.InRoom)
			{
				return false;
			}
			RunManager instance = RunManager.instance;
			if ((Object)(object)instance == (Object)null)
			{
				return false;
			}
			Level levelCurrent = instance.levelCurrent;
			if ((Object)(object)levelCurrent == (Object)null)
			{
				return false;
			}
			if ((Object)(object)levelCurrent == (Object)(object)instance.levelLobby || (Object)(object)levelCurrent == (Object)(object)instance.levelLobbyMenu)
			{
				return false;
			}
			if (SemiFunc.IsLevelShop(levelCurrent) && !ActiveShrinkInShop)
			{
				return false;
			}
			return true;
		}

		internal static void Shrink(GameObject go, float factor)
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			ManagedObjects.Add(((Object)go).GetInstanceID());
			ScaleOptions @default = ScaleOptions.Default;
			@default.Factor = factor;
			IsApplying = true;
			try
			{
				ScaleManager.ApplyIfNotScaled(go, @default);
			}
			finally
			{
				IsApplying = false;
			}
		}
	}
	internal class SettingsSyncer : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <RescaleAfterJoin>d__24 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

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

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

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

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

			private bool MoveNext()
			{
				//IL_001d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: Expected O, but got Unknown
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = (object)new WaitForSeconds(3f);
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					Plugin.Log.LogInfo((object)"[Sync] Running post-join rescale pass");
					PhysGrabObject[] array = Object.FindObjectsOfType<PhysGrabObject>();
					foreach (PhysGrabObject val in array)
					{
						ItemAttributes val2 = ((Component)val).GetComponentInParent<ItemAttributes>(true) ?? ((Component)val).GetComponentInChildren<ItemAttributes>(true);
						if ((Object)(object)val2 != (Object)null)
						{
							Plugin.Shrink(((Component)val2).gameObject, Plugin.ActiveItemScale);
						}
					}
					PlayerAvatar[] array2 = Object.FindObjectsOfType<PlayerAvatar>();
					for (int i = 0; i < array2.Length; i++)
					{
						Plugin.Shrink(((Component)array2[i]).gameObject, Plugin.ActivePlayerScale);
					}
					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 const string K_PLAYER = "ME_PS";

		private const string K_ITEM = "ME_IS";

		private const string K_VALUABLE = "ME_VS";

		private const string K_CART = "ME_CS";

		private const string K_SHOP = "ME_SS";

		internal static SettingsSyncer? Instance;

		private bool _wasInRoom;

		private bool _wasMaster;

		private float _pullPollDelay;

		private float _watcherTimer;

		private readonly Dictionary<int, Transform?> _visualsCache = new Dictionary<int, Transform>();

		private float _lastPushedPlayer = float.NaN;

		private float _lastPushedItem = float.NaN;

		private float _lastPushedValuable = float.NaN;

		private float _lastPushedCart = float.NaN;

		private bool? _lastPushedShop;

		private void Awake()
		{
			Instance = this;
		}

		private void Start()
		{
			Plugin.Log.LogInfo((object)"[Sync] SettingsSyncer ready (polling mode)");
		}

		internal void TriggerRescale()
		{
			((MonoBehaviour)this).StartCoroutine(RescaleAfterJoin());
		}

		private void Update()
		{
			bool inRoom = PhotonNetwork.InRoom;
			bool flag = inRoom && PhotonNetwork.IsMasterClient;
			if (inRoom && !_wasInRoom)
			{
				if (flag)
				{
					PushHostSettings();
				}
				else
				{
					PullHostSettings();
				}
			}
			else if (!inRoom && _wasInRoom)
			{
				Plugin.ResetToLocalConfig();
				Plugin.Log.LogInfo((object)"[Sync] Left room — reset to local config");
			}
			else if (inRoom && flag && !_wasMaster)
			{
				PushHostSettings();
			}
			else if (inRoom && !flag)
			{
				_pullPollDelay -= Time.unscaledDeltaTime;
				if (_pullPollDelay <= 0f)
				{
					_pullPollDelay = 1f;
					PullHostSettings();
				}
			}
			_wasInRoom = inRoom;
			_wasMaster = flag;
		}

		private void LateUpdate()
		{
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: 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_020d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: 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_0150: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.IsInGameplay())
			{
				return;
			}
			_watcherTimer -= Time.deltaTime;
			if (_watcherTimer > 0f)
			{
				return;
			}
			_watcherTimer = 0.25f;
			float activePlayerScale = Plugin.ActivePlayerScale;
			if (activePlayerScale < 0.99f && GameDirector.instance?.PlayerList != null)
			{
				foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
				{
					if (!((Object)(object)player == (Object)null))
					{
						Transform transform = ((Component)player).transform;
						if (transform.localScale.x > 0.9f && transform.localScale.x > activePlayerScale + 0.4f)
						{
							transform.localScale = new Vector3(activePlayerScale, activePlayerScale, activePlayerScale);
						}
						int instanceID = ((Object)player).GetInstanceID();
						if (!_visualsCache.TryGetValue(instanceID, out Transform value) || (Object)(object)value == (Object)null)
						{
							value = (((Object)(object)transform.parent != (Object)null) ? transform.parent.Find("Player Visuals") : null);
							_visualsCache[instanceID] = value;
						}
						if ((Object)(object)value != (Object)null && value.localScale.x > 0.9f && value.localScale.x > activePlayerScale + 0.4f)
						{
							value.localScale = new Vector3(activePlayerScale, activePlayerScale, activePlayerScale);
						}
					}
				}
			}
			float activeItemScale = Plugin.ActiveItemScale;
			if (!(activeItemScale < 0.99f) || PhysGrabObjectPatch.DirectScaledItems.Count <= 0)
			{
				return;
			}
			List<int> list = null;
			foreach (KeyValuePair<int, Transform> directScaledItem in PhysGrabObjectPatch.DirectScaledItems)
			{
				Transform value2 = directScaledItem.Value;
				if ((Object)(object)value2 == (Object)null)
				{
					(list ?? (list = new List<int>())).Add(directScaledItem.Key);
				}
				else if (value2.localScale.x > 0.9f && value2.localScale.x > activeItemScale + 0.4f)
				{
					value2.localScale = new Vector3(activeItemScale, activeItemScale, activeItemScale);
				}
			}
			if (list == null)
			{
				return;
			}
			foreach (int item in list)
			{
				PhysGrabObjectPatch.DirectScaledItems.Remove(item);
			}
		}

		private void PullHostSettings()
		{
			Room currentRoom = PhotonNetwork.CurrentRoom;
			Hashtable val = ((currentRoom != null) ? ((RoomInfo)currentRoom).CustomProperties : null);
			if (val == null)
			{
				return;
			}
			bool flag = false;
			if (((Dictionary<object, object>)(object)val).ContainsKey((object)"ME_PS"))
			{
				float num = (float)val[(object)"ME_PS"];
				if (Plugin.ActivePlayerScale != num)
				{
					Plugin.ActivePlayerScale = num;
					flag = true;
				}
			}
			if (((Dictionary<object, object>)(object)val).ContainsKey((object)"ME_IS"))
			{
				float num2 = (float)val[(object)"ME_IS"];
				if (Plugin.ActiveItemScale != num2)
				{
					Plugin.ActiveItemScale = num2;
					flag = true;
				}
			}
			if (((Dictionary<object, object>)(object)val).ContainsKey((object)"ME_VS"))
			{
				float num3 = (float)val[(object)"ME_VS"];
				if (Plugin.ActiveValuableScale != num3)
				{
					Plugin.ActiveValuableScale = num3;
					flag = true;
				}
			}
			if (((Dictionary<object, object>)(object)val).ContainsKey((object)"ME_CS"))
			{
				float num4 = (float)val[(object)"ME_CS"];
				if (Plugin.ActiveCartScale != num4)
				{
					Plugin.ActiveCartScale = num4;
					flag = true;
				}
			}
			if (((Dictionary<object, object>)(object)val).ContainsKey((object)"ME_SS"))
			{
				bool flag2 = (bool)val[(object)"ME_SS"];
				if (Plugin.ActiveShrinkInShop != flag2)
				{
					Plugin.ActiveShrinkInShop = flag2;
					flag = true;
				}
			}
			if (flag)
			{
				Plugin.Log.LogInfo((object)$"[Sync] Pulled host settings — player={Plugin.ActivePlayerScale} item={Plugin.ActiveItemScale} valuable={Plugin.ActiveValuableScale} cart={Plugin.ActiveCartScale} shrinkInShop={Plugin.ActiveShrinkInShop}");
			}
		}

		internal void PushHostSettingsExternal()
		{
			if (PhotonNetwork.InRoom && PhotonNetwork.IsMasterClient)
			{
				PushHostSettings();
			}
		}

		private void PushHostSettings()
		{
			//IL_00b0: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0110: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Expected O, but got Unknown
			if (PhotonNetwork.CurrentRoom != null)
			{
				float value = Plugin.PlayerScale.Value;
				float value2 = Plugin.ItemScale.Value;
				float value3 = Plugin.ValuableScale.Value;
				float value4 = Plugin.CartScale.Value;
				bool value5 = Plugin.ShrinkInShop.Value;
				if (value == _lastPushedPlayer && value2 == _lastPushedItem && value3 == _lastPushedValuable && value4 == _lastPushedCart && value5 == _lastPushedShop)
				{
					Plugin.ResetToLocalConfig();
					return;
				}
				_lastPushedPlayer = value;
				_lastPushedItem = value2;
				_lastPushedValuable = value3;
				_lastPushedCart = value4;
				_lastPushedShop = value5;
				Hashtable val = new Hashtable
				{
					[(object)"ME_PS"] = value,
					[(object)"ME_IS"] = value2,
					[(object)"ME_VS"] = value3,
					[(object)"ME_CS"] = value4,
					[(object)"ME_SS"] = value5
				};
				PhotonNetwork.CurrentRoom.SetCustomProperties(val, (Hashtable)null, (WebFlags)null);
				Plugin.ResetToLocalConfig();
				Plugin.Log.LogInfo((object)$"[Sync] Host pushed settings — player={value} item={value2} valuable={value3} cart={value4} shrinkInShop={value5}");
			}
		}

		[IteratorStateMachine(typeof(<RescaleAfterJoin>d__24))]
		private IEnumerator RescaleAfterJoin()
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <RescaleAfterJoin>d__24(0);
		}
	}
	[HarmonyPatch(typeof(PlayerAvatar), "Start")]
	internal static class PlayerAvatarPatch
	{
		[CompilerGenerated]
		private sealed class <ShrinkNextFrame>d__1 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public PlayerAvatar instance;

			private float <waited>5__2;

			private float <w>5__3;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0171: Unknown result type (might be due to invalid IL or missing references)
				//IL_0155: 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_01b7: Unknown result type (might be due to invalid IL or missing references)
				//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
				//IL_0204: 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)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
					<>1__state = -1;
					if (!Plugin.IsInGameplay())
					{
						return false;
					}
					if (PhotonNetwork.IsMasterClient || !PhotonNetwork.InRoom)
					{
						PhotonView component = ((Component)instance).GetComponent<PhotonView>();
						if ((Object)(object)component == (Object)null || component.IsMine)
						{
							<w>5__3 = 0f;
							goto IL_00ad;
						}
						goto IL_00f0;
					}
					<waited>5__2 = 0f;
					break;
				case 2:
					<>1__state = -1;
					goto IL_00ad;
				case 3:
					{
						<>1__state = -1;
						break;
					}
					IL_00f0:
					Plugin.Shrink(((Component)instance).gameObject, Plugin.ActivePlayerScale);
					return false;
					IL_00ad:
					if (<w>5__3 < 5f && ((Object)(object)PhysGrabber.instance == (Object)null || (Object)(object)((Component)instance).GetComponent<PlayerVisionTarget>() == (Object)null || (Object)(object)CameraPosition.instance == (Object)null))
					{
						<w>5__3 += Time.deltaTime;
						<>2__current = null;
						<>1__state = 2;
						return true;
					}
					if (!Plugin.IsInGameplay())
					{
						return false;
					}
					goto IL_00f0;
				}
				if (<waited>5__2 < 5f && ((Component)instance).transform.localScale.x > 0.99f)
				{
					<waited>5__2 += Time.deltaTime;
					<>2__current = null;
					<>1__state = 3;
					return true;
				}
				if (((Component)instance).transform.localScale.x > 0.99f && DirectScaledPlayers.Add(((Object)((Component)instance).gameObject).GetInstanceID()))
				{
					Transform transform = ((Component)instance).transform;
					transform.localScale *= Plugin.ActivePlayerScale;
					Transform parent = ((Component)instance).transform.parent;
					if ((Object)(object)parent != (Object)null)
					{
						Transform val = parent.Find("Player Visuals");
						if ((Object)(object)val != (Object)null && val.localScale.x > 0.99f)
						{
							val.localScale *= Plugin.ActivePlayerScale;
						}
					}
				}
				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();
			}
		}

		internal static readonly HashSet<int> DirectScaledPlayers = new HashSet<int>();

		[IteratorStateMachine(typeof(<ShrinkNextFrame>d__1))]
		private static IEnumerator ShrinkNextFrame(PlayerAvatar instance)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ShrinkNextFrame>d__1(0)
			{
				instance = instance
			};
		}

		private static void Postfix(PlayerAvatar __instance)
		{
			((MonoBehaviour)__instance).StartCoroutine(ShrinkNextFrame(__instance));
		}
	}
	[HarmonyPatch(typeof(RunManager), "UpdateLevel")]
	internal static class RunManagerUpdateLevelPatch
	{
		private static void Postfix(RunManager __instance)
		{
			if (Plugin.IsInGameplay())
			{
				SettingsSyncer.Instance?.TriggerRescale();
			}
		}
	}
	[HarmonyPatch(typeof(PhysGrabObject), "Start")]
	internal static class PhysGrabObjectPatch
	{
		internal static readonly Dictionary<int, Transform> DirectScaledItems = new Dictionary<int, Transform>();

		private static void Postfix(PhysGrabObject __instance)
		{
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.IsInGameplay())
			{
				return;
			}
			GameObject val = null;
			ItemAttributes componentInParent = ((Component)__instance).GetComponentInParent<ItemAttributes>(true);
			if ((Object)(object)componentInParent != (Object)null)
			{
				val = ((Component)componentInParent).gameObject;
			}
			else if ((Object)(object)((Component)__instance).GetComponentInChildren<ItemAttributes>(true) != (Object)null)
			{
				val = ((Component)__instance).gameObject;
			}
			if ((Object)(object)val == (Object)null)
			{
				return;
			}
			bool num = (Object)(object)val.GetComponentInChildren<ItemEquippable>(true) != (Object)null;
			bool flag = (Object)(object)val.GetComponentInChildren<ItemGun>(true) != (Object)null;
			if ((num && !flag) || (PhotonNetwork.InRoom && !PhotonNetwork.IsMasterClient))
			{
				int instanceID = ((Object)val).GetInstanceID();
				if (!DirectScaledItems.ContainsKey(instanceID))
				{
					DirectScaledItems[instanceID] = val.transform;
					Transform transform = val.transform;
					transform.localScale *= Plugin.ActiveItemScale;
				}
			}
			else
			{
				Plugin.Shrink(val, Plugin.ActiveItemScale);
			}
		}
	}
	[HarmonyPatch(typeof(ValuableObject), "Start")]
	internal static class ValuableObjectPatch
	{
		private static readonly HashSet<int> _scaled = new HashSet<int>();

		private static void Postfix(ValuableObject __instance)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			if (Plugin.IsInGameplay())
			{
				int instanceID = ((Object)((Component)__instance).gameObject).GetInstanceID();
				if (_scaled.Add(instanceID))
				{
					Transform transform = ((Component)__instance).transform;
					transform.localScale *= Plugin.ActiveValuableScale;
					PhysGrabObject val = ((Component)__instance).GetComponentInChildren<PhysGrabObject>(true) ?? ((Component)__instance).GetComponentInParent<PhysGrabObject>(true);
					(((Object)(object)val != (Object)null) ? ((Component)val).gameObject : ((Component)__instance).gameObject).AddComponent<ValuableCartTracker>().SetValuable(__instance);
				}
			}
		}
	}
	internal static class BonkBlocker
	{
		public static bool Prefix()
		{
			return false;
		}
	}
	internal static class VoicePitchPatch
	{
		private const BindingFlags BF = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic;

		private static FieldInfo? _handlerStateField;

		private static FieldInfo? _avatarField;

		private static FieldInfo? _voiceChatField;

		private static FieldInfo? _activeField;

		private static FieldInfo? _multField;

		private static readonly object _boxedFalse = false;

		private static readonly object _boxedOne = 1f;

		public static bool Prefix()
		{
			return Plugin.ActiveVoiceMod;
		}

		public static void PlayerHandlerOnUpdatePostfix(object ctrl)
		{
			if (Plugin.ActiveVoiceMod || ctrl == null)
			{
				return;
			}
			try
			{
				if ((object)_handlerStateField == null)
				{
					_handlerStateField = ctrl.GetType().GetField("HandlerState", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				}
				object obj = _handlerStateField?.GetValue(ctrl);
				if (obj == null)
				{
					return;
				}
				if ((object)_avatarField == null)
				{
					_avatarField = obj.GetType().GetField("PlayerAvatar", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				}
				object obj2 = _avatarField?.GetValue(obj);
				Object val = (Object)((obj2 is Object) ? obj2 : null);
				if ((val != null && val == (Object)null) || obj2 == null)
				{
					return;
				}
				if ((object)_voiceChatField == null)
				{
					_voiceChatField = obj2.GetType().GetField("voiceChat", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
				}
				object obj3 = _voiceChatField?.GetValue(obj2);
				Object val2 = (Object)((obj3 is Object) ? obj3 : null);
				if ((val2 == null || !(val2 == (Object)null)) && obj3 != null)
				{
					Type type = obj3.GetType();
					if ((object)_activeField == null)
					{
						_activeField = type.GetField("overridePitchIsActive", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					}
					if ((object)_multField == null)
					{
						_multField = type.GetField("overridePitchMultiplierTarget", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					}
					_activeField?.SetValue(obj3, _boxedFalse);
					_multField?.SetValue(obj3, _boxedOne);
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogDebug((object)("[Voice] OnUpdate postfix swallowed: " + ex.GetType().Name));
			}
		}
	}
	internal static class PlayerRevivePatch
	{
		internal static void Postfix(PlayerAvatar __instance)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			float activePlayerScale = Plugin.ActivePlayerScale;
			if (activePlayerScale < 0.99f)
			{
				((Component)__instance).transform.localScale = new Vector3(activePlayerScale, activePlayerScale, activePlayerScale);
			}
		}
	}
	[HarmonyPatch(typeof(ItemEquippable), "RPC_CompleteUnequip")]
	internal static class UnequipReshrinkPatch
	{
		[CompilerGenerated]
		private sealed class <Reshrink>d__1 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public ItemEquippable equip;

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

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

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

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

			private bool MoveNext()
			{
				//IL_0074: 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_00a7: Unknown result type (might be due to invalid IL or missing references)
				switch (<>1__state)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<>2__current = null;
					<>1__state = 1;
					return true;
				case 1:
				{
					<>1__state = -1;
					if ((Object)(object)equip == (Object)null)
					{
						return false;
					}
					ItemAttributes componentInParent = ((Component)equip).GetComponentInParent<ItemAttributes>(true);
					GameObject val = (((Object)(object)componentInParent != (Object)null) ? ((Component)componentInParent).gameObject : ((Component)equip).gameObject);
					float activeItemScale = Plugin.ActiveItemScale;
					if (val.transform.localScale.x > 0.9f && val.transform.localScale.x > activeItemScale + 0.4f)
					{
						val.transform.localScale = new Vector3(activeItemScale, activeItemScale, activeItemScale);
					}
					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 void Postfix(ItemEquippable __instance)
		{
			if (!(Plugin.ActiveItemScale >= 0.99f))
			{
				((MonoBehaviour)__instance).StartCoroutine(Reshrink(__instance));
			}
		}

		[IteratorStateMachine(typeof(<Reshrink>d__1))]
		private static IEnumerator Reshrink(ItemEquippable equip)
		{
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <Reshrink>d__1(0)
			{
				equip = equip
			};
		}
	}
	internal static class HeldGunStabilizationPatch
	{
		private static readonly Dictionary<int, ItemGun?> _gun = new Dictionary<int, ItemGun>();

		private static FieldInfo? _isCrouchingField;

		internal static void Postfix(PhysGrabObject __instance)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0159: Unknown result type (might be due to invalid IL or missing references)
			//IL_0165: Unknown result type (might be due to invalid IL or missing references)
			//IL_0175: Unknown result type (might be due to invalid IL or missing references)
			int instanceID = ((Object)__instance).GetInstanceID();
			if (!_gun.TryGetValue(instanceID, out ItemGun value))
			{
				value = ((Component)__instance).GetComponent<ItemGun>();
				_gun[instanceID] = value;
			}
			if ((Object)(object)value == (Object)null)
			{
				return;
			}
			PlayerAvatar val = SemiFunc.PlayerAvatarLocal();
			if (!((Object)(object)val == (Object)null) && !(((Component)val).transform.localScale.x > 0.99f) && __instance.playerGrabbing.Contains(val.physGrabber))
			{
				if ((object)_isCrouchingField == null)
				{
					_isCrouchingField = AccessTools.Field(typeof(PlayerAvatar), "isCrouching");
				}
				bool flag = _isCrouchingField != null && (bool)_isCrouchingField.GetValue(val);
				value.aimVerticalOffset = (flag ? (-1f) : (-3f));
				value.torqueMultiplier = 2f;
				__instance.OverrideMass(0.25f, 0.1f);
				__instance.OverrideGrabStrength(2f, 0.1f);
				__instance.OverrideTorqueStrength(5f, 0.1f);
				__instance.OverrideDrag(2f, 0.1f);
				if ((Object)(object)__instance.rb != (Object)null)
				{
					__instance.rb.angularDrag = 29f;
				}
				Camera main = Camera.main;
				if ((Object)(object)main != (Object)null && (Object)(object)__instance.rb != (Object)null)
				{
					__instance.rb.rotation = Quaternion.Slerp(__instance.rb.rotation, ((Component)main).transform.rotation, Time.fixedDeltaTime * 10f);
				}
			}
		}
	}
	[HarmonyPatch(typeof(PhysGrabObject), "OverrideGrabVerticalPosition")]
	internal static class GunGrabVerticalRestorePatch
	{
		private static readonly Dictionary<int, ItemGun?> _gun = new Dictionary<int, ItemGun>();

		private static readonly FieldRef<PhysGrabObject, float> _posRef = AccessTools.FieldRefAccess<PhysGrabObject, float>("overrideGrabRelativeVerticalPosition");

		private static readonly FieldRef<PhysGrabObject, float> _timerRef = AccessTools.FieldRefAccess<PhysGrabObject, float>("overrideGrabRelativeVerticalPositionTimer");

		private static void Postfix(PhysGrabObject __instance)
		{
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			int instanceID = ((Object)__instance).GetInstanceID();
			if (!_gun.TryGetValue(instanceID, out ItemGun value))
			{
				value = ((Component)__instance).GetComponent<ItemGun>();
				_gun[instanceID] = value;
			}
			if ((Object)(object)value == (Object)null || __instance.playerGrabbing == null)
			{
				return;
			}
			float num = 1f;
			foreach (PhysGrabber item in __instance.playerGrabbing)
			{
				PlayerAvatar val = (((Object)(object)item != (Object)null) ? item.playerAvatar : null);
				if ((Object)(object)val != (Object)null)
				{
					num = ((Component)val).transform.localScale.x;
					break;
				}
			}
			if (!(num >= 0.99f))
			{
				_posRef.Invoke(__instance) = value.grabVerticalOffset * num;
				_timerRef.Invoke(__instance) = 0.1f;
			}
		}
	}
	[HarmonyPatch(typeof(PhysGrabObjectImpactDetector), "FixedUpdate")]
	internal static class ShrunkWeaponWhipPatch
	{
		private static readonly Dictionary<int, (bool isWeapon, PhysGrabObject? pgo)> _cache = new Dictionary<int, (bool, PhysGrabObject)>();

		private static readonly FieldRef<PhysGrabObjectImpactDetector, Vector3> _ppvRef = AccessTools.FieldRefAccess<PhysGrabObjectImpactDetector, Vector3>("previousPreviousVelocityRaw");

		private static void Postfix(PhysGrabObjectImpactDetector __instance)
		{
			//IL_00ca: 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_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			int instanceID = ((Object)__instance).GetInstanceID();
			if (!_cache.TryGetValue(instanceID, out (bool, PhysGrabObject) value))
			{
				value = ((Object)(object)((Component)__instance).GetComponent<ItemGun>() != (Object)null || (Object)(object)((Component)__instance).GetComponentInParent<ItemEquippable>(true) != (Object)null || (Object)(object)((Component)__instance).GetComponentInChildren<ItemEquippable>(true) != (Object)null, ((Component)__instance).GetComponent<PhysGrabObject>());
				_cache[instanceID] = value;
			}
			if (!value.Item1 || (Object)(object)value.Item2 == (Object)null)
			{
				return;
			}
			List<PhysGrabber> playerGrabbing = value.Item2.playerGrabbing;
			if (playerGrabbing == null || playerGrabbing.Count == 0)
			{
				return;
			}
			float num = 1f;
			foreach (PhysGrabber item in playerGrabbing)
			{
				PlayerAvatar val = (((Object)(object)item != (Object)null) ? item.playerAvatar : null);
				if ((Object)(object)val != (Object)null)
				{
					num = ((Component)val).transform.localScale.x;
					break;
				}
			}
			if (!(num >= 0.99f) && !(num <= 0.05f))
			{
				ref Vector3 reference = ref _ppvRef.Invoke(__instance);
				reference *= Mathf.Min(1f / num, 3f);
			}
		}
	}
	internal static class CartStandoffShrinkPatch
	{
		private const float Strength = 0.5f;

		internal static void Postfix(ref float __result, float d, PhysGrabber grabber)
		{
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)grabber == (Object)null)
			{
				return;
			}
			PlayerAvatar playerAvatar = grabber.playerAvatar;
			if (!((Object)(object)playerAvatar == (Object)null))
			{
				float x = ((Component)playerAvatar).transform.localScale.x;
				if (!(x >= 0.99f))
				{
					__result = d * Mathf.Lerp(1f, x, 0.5f);
				}
			}
		}
	}
	[HarmonyPatch(typeof(ScaleManager), "Apply", new Type[]
	{
		typeof(GameObject),
		typeof(ScaleOptions)
	})]
	internal static class ScaleManagerApplyPatch
	{
		private static bool Prefix(GameObject target)
		{
			if (Plugin.IsApplying)
			{
				return true;
			}
			ScaleController controller = ScaleManager.GetController(target);
			int item = (((Object)(object)controller != (Object)null) ? ((Object)((Component)controller).gameObject).GetInstanceID() : ((Object)target).GetInstanceID());
			return !Plugin.ManagedObjects.Contains(item);
		}
	}
	internal class ValuableCartTracker : MonoBehaviour
	{
		[CompilerGenerated]
		private sealed class <ScaleTo>d__6 : IEnumerator<object>, IEnumerator, IDisposable
		{
			private int <>1__state;

			private object <>2__current;

			public ValuableCartTracker <>4__this;

			public Vector3 target;

			public float duration;

			private Vector3 <start>5__2;

			private float <t>5__3;

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

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

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

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

			private bool MoveNext()
			{
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_002f: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0053: Unknown result type (might be due to invalid IL or missing references)
				//IL_0065: Unknown result type (might be due to invalid IL or missing references)
				//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
				int num = <>1__state;
				ValuableCartTracker valuableCartTracker = <>4__this;
				switch (num)
				{
				default:
					return false;
				case 0:
					<>1__state = -1;
					<start>5__2 = ((Component)valuableCartTracker._vo).transform.localScale;
					<t>5__3 = 0f;
					break;
				case 1:
					<>1__state = -1;
					<t>5__3 += Time.deltaTime;
					break;
				}
				if (<t>5__3 < duration)
				{
					((Component)valuableCartTracker._vo).transform.localScale = Vector3.Lerp(<start>5__2, target, <t>5__3 / duration);
					<>2__current = null;
					<>1__state = 1;
					return true;
				}
				((Component)valuableCartTracker._vo).transform.localScale = target;
				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 ValuableObject? _vo;

		private bool _inCart;

		private Vector3 _preCartScale;

		internal void SetValuable(ValuableObject vo)
		{
			//IL_000e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0013: Unknown result type (might be due to invalid IL or missing references)
			_vo = vo;
			_preCartScale = ((Component)vo).transform.localScale;
		}

		private void OnTriggerEnter(Collider other)
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			if (!_inCart && !((Object)(object)_vo == (Object)null) && !((Object)(object)((Component)other).GetComponentInParent<PhysGrabInCart>() == (Object)null) && !(Plugin.ActiveCartScale >= 1f))
			{
				_inCart = true;
				((MonoBehaviour)this).StopAllCoroutines();
				((MonoBehaviour)this).StartCoroutine(ScaleTo(((Component)_vo).transform.localScale * Plugin.ActiveCartScale, 0.4f));
			}
		}

		private void OnTriggerExit(Collider other)
		{
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			if (_inCart && !((Object)(object)_vo == (Object)null) && !((Object)(object)((Component)other).GetComponentInParent<PhysGrabInCart>() == (Object)null))
			{
				_inCart = false;
				((MonoBehaviour)this).StopAllCoroutines();
				((MonoBehaviour)this).StartCoroutine(ScaleTo(_preCartScale, 0.3f));
			}
		}

		[IteratorStateMachine(typeof(<ScaleTo>d__6))]
		private IEnumerator ScaleTo(Vector3 target, float duration)
		{
			//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)
			//yield-return decompiler failed: Unexpected instruction in Iterator.Dispose()
			return new <ScaleTo>d__6(0)
			{
				<>4__this = this,
				target = target,
				duration = duration
			};
		}
	}
	public static class PluginInfo
	{
		public const string PLUGIN_GUID = "darkharasho.MiniEepo";

		public const string PLUGIN_NAME = "MiniEepo";

		public const string PLUGIN_VERSION = "1.3.6";
	}
}