Decompiled source of Shrinkinator v1.1.0

Shrinkinator.dll

Decompiled 2 months ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using REPOLib.Modules;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp-firstpass")]
[assembly: IgnoresAccessChecksTo("Assembly-CSharp")]
[assembly: IgnoresAccessChecksTo("Autodesk.Fbx")]
[assembly: IgnoresAccessChecksTo("Discord.Sdk")]
[assembly: IgnoresAccessChecksTo("Domain_Reload")]
[assembly: IgnoresAccessChecksTo("Facepunch.Steamworks.Win64")]
[assembly: IgnoresAccessChecksTo("FbxBuildTestAssets")]
[assembly: IgnoresAccessChecksTo("Klattersynth")]
[assembly: IgnoresAccessChecksTo("Photon3Unity3D")]
[assembly: IgnoresAccessChecksTo("PhotonChat")]
[assembly: IgnoresAccessChecksTo("PhotonRealtime")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking")]
[assembly: IgnoresAccessChecksTo("PhotonUnityNetworking.Utilities")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.API")]
[assembly: IgnoresAccessChecksTo("PhotonVoice")]
[assembly: IgnoresAccessChecksTo("PhotonVoice.PUN")]
[assembly: IgnoresAccessChecksTo("SingularityGroup.HotReload.Runtime.Public")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Attributes")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Modules.Unity.Addressables")]
[assembly: IgnoresAccessChecksTo("Sirenix.OdinInspector.Modules.UnityLocalization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization.Config")]
[assembly: IgnoresAccessChecksTo("Sirenix.Serialization")]
[assembly: IgnoresAccessChecksTo("Sirenix.Utilities")]
[assembly: IgnoresAccessChecksTo("Unity.Addressables")]
[assembly: IgnoresAccessChecksTo("Unity.AI.Navigation")]
[assembly: IgnoresAccessChecksTo("Unity.Burst")]
[assembly: IgnoresAccessChecksTo("Unity.Burst.Unsafe")]
[assembly: IgnoresAccessChecksTo("Unity.Collections")]
[assembly: IgnoresAccessChecksTo("Unity.Collections.LowLevel.ILSupport")]
[assembly: IgnoresAccessChecksTo("Unity.Formats.Fbx.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem")]
[assembly: IgnoresAccessChecksTo("Unity.InputSystem.ForUI")]
[assembly: IgnoresAccessChecksTo("Unity.InternalAPIEngineBridge.013")]
[assembly: IgnoresAccessChecksTo("Unity.Localization")]
[assembly: IgnoresAccessChecksTo("Unity.Mathematics")]
[assembly: IgnoresAccessChecksTo("Unity.MemoryProfiler")]
[assembly: IgnoresAccessChecksTo("Unity.Postprocessing.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.Profiling.Core")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.Core.ShaderLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.RenderPipelines.ShaderGraph.ShaderGraphLibrary")]
[assembly: IgnoresAccessChecksTo("Unity.ResourceManager")]
[assembly: IgnoresAccessChecksTo("Unity.ScriptableBuildPipeline")]
[assembly: IgnoresAccessChecksTo("Unity.Splines")]
[assembly: IgnoresAccessChecksTo("Unity.TextMeshPro")]
[assembly: IgnoresAccessChecksTo("Unity.Timeline")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Antlr3.Runtime")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Core")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.Flow")]
[assembly: IgnoresAccessChecksTo("Unity.VisualScripting.State")]
[assembly: IgnoresAccessChecksTo("UnityEngine.ARModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.NVIDIAModule")]
[assembly: IgnoresAccessChecksTo("UnityEngine.UI")]
[assembly: IgnoresAccessChecksTo("websocket-sharp")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("Shrinkinator")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.1.0.0")]
[assembly: AssemblyInformationalVersion("1.1.0+fd05f5c3079feb6eb5c5e9fdaea1872233358f08")]
[assembly: AssemblyProduct("Shrinkinator")]
[assembly: AssemblyTitle("Shrinkinator")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.1.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)]
	internal sealed class RefSafetyRulesAttribute : Attribute
	{
		public readonly int Version;

		public RefSafetyRulesAttribute(int P_0)
		{
			Version = P_0;
		}
	}
}
namespace Shrinkinator
{
	internal static class ShrinkinatorConfig
	{
		internal static ConfigEntry<float> ScaleFactor;

		internal static ConfigEntry<float> DurationSeconds;

		internal static ConfigEntry<float> CloudRadius;

		internal static ConfigEntry<float> MistRange;

		internal static ConfigEntry<int> Charges;

		internal static ConfigEntry<bool> ValueScalePrice;

		internal static ConfigEntry<float> ValuableMinScale;

		internal static ConfigEntry<string> ItemName;

		internal static ConfigEntry<float> PriceMultiplier;

		internal static ConfigEntry<float> ShootCooldown;

		internal static ConfigEntry<bool> UseCustomModel;

		internal static ConfigEntry<float> AimVerticalOffset;

		internal static ConfigEntry<float> GrabVerticalOffset;

		internal static ConfigEntry<bool> CenterOfMassInGrip;

		internal static ConfigEntry<bool> AimAssist;

		internal static ConfigEntry<float> GrabStrengthMultiplier;

		internal static ConfigEntry<float> TorqueMultiplier;

		internal static void Init(ConfigFile config)
		{
			ScaleFactor = config.Bind<float>("Общее", "ScaleFactor", 0.35f, "Множитель размера при уменьшении (0.35 = цель становится в ~3 раза меньше). Масса уменьшается пропорционально кубу множителя. Цена ценностей не меняется.");
			DurationSeconds = config.Bind<float>("Общее", "DurationSeconds", 20f, "Длительность уменьшения врагов и игроков в секундах. Ценности уменьшаются навсегда.");
			CloudRadius = config.Bind<float>("Туман", "CloudRadius", 2.5f, "Радиус облака тумана в метрах. Всё, что попало в облако, уменьшается.");
			MistRange = config.Bind<float>("Туман", "MistRange", 12f, "Дальность распыления тумана в метрах (если луч ни во что не попал, облако появляется на этом расстоянии).");
			Charges = config.Bind<int>("Пушка", "Charges", 6, "Количество выстрелов от полной батареи. Реализовано через ванильный расход батареи (100 / Charges за выстрел).");
			ValueScalePrice = config.Bind<bool>("Ценности", "ValueScalePrice", false, "Уменьшать ли стоимость ценности вместе с размером. По умолчанию false: цена остаётся прежней, уменьшается только размер и масса.");
			ValuableMinScale = config.Bind<float>("Ценности", "ValuableMinScale", 0.2f, "Минимальный размер ценности относительно исходного (0.2 = не меньше 20%). Повторные выстрелы стакаются, пока не упрётся в этот пол. Дальше выстрелы игнорируются.");
			ItemName = config.Bind<string>("Пушка", "ItemName", "Уменьшитель-инатор", "Отображаемое название предмета в магазине.");
			PriceMultiplier = config.Bind<float>("Пушка", "PriceMultiplier", 1.5f, "Множитель цены в магазине относительно ванильного пистолета.");
			ShootCooldown = config.Bind<float>("Пушка", "ShootCooldown", 0.8f, "Минимальная пауза между выстрелами в секундах.");
			UseCustomModel = config.Bind<bool>("Пушка", "UseCustomModel", true, "Заменять визуал пушки кастомной процедурной моделью «shrink ray gun» (собирается в коде из примитивов, без ассетов). false = ванильный внешний вид пистолета. Применяется при регистрации предмета — требует перезапуска.");
			AimVerticalOffset = config.Bind<float>("Хват", "AimVerticalOffset", 0f, "Вертикальный угол ствола относительно направления взгляда в градусах (поле ItemGun.aimVerticalOffset). Ванильный пистолет: -10 (бьёт ниже прицела). 0 = стреляет ровно туда, куда смотрит камера.");
			GrabVerticalOffset = config.Bind<float>("Хват", "GrabVerticalOffset", -0.15f, "Вертикальное смещение точки удержания пушки относительно линии взгляда в метрах (поле ItemGun.grabVerticalOffset). Ванильный пистолет: -0.2. Отрицательное = ниже центра экрана, не загораживает обзор.");
			CenterOfMassInGrip = config.Bind<bool>("Хват", "CenterOfMassInGrip", true, "Переносить центр масс (rb.centerOfMass, точка «Center of Mass») в рукоять. Убирает «маятниковое» болтание: сила захвата приложена к точке хвата, и если она совпадает с центром масс — паразитного крутящего момента нет. Работает только с кастомной моделью (позиция рукояти известна).");
			AimAssist = config.Bind<bool>("Хват", "AimAssist", true, "Выравнивать ось дула (gunMuzzle.forward) по оси transform.forward корня предмета — именно её физика удержания поворачивает по камере. Гарантирует, что луч идёт строго по направлению взгляда.");
			GrabStrengthMultiplier = config.Bind<float>("Хват", "GrabStrengthMultiplier", 1f, "Множитель силы пружины удержания (поле ItemGun.grabStrengthMultiplier, ваниль = 1). Больше = жёстче следует за рукой, но может дёргаться.");
			TorqueMultiplier = config.Bind<float>("Хват", "TorqueMultiplier", 1f, "Множитель крутящего момента доворота к камере (поле ItemGun.torqueMultiplier, ваниль = 1). Больше = быстрее доворачивается за взглядом, но возможна «рыскливость».");
		}
	}
	internal static class GunHandlingTuner
	{
		private const string ForceGrabPointName = "Force Grab Point";

		private const string CenterOfMassName = "Center of Mass";

		internal static void Apply(GameObject clone, ItemGun gun, bool gripKnown, Vector3 gripLocalPosition)
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)clone == (Object)null || (Object)(object)gun == (Object)null)
			{
				return;
			}
			try
			{
				ApplyInternal(clone, gun, gripKnown, gripLocalPosition);
			}
			catch (Exception ex)
			{
				Log.Warning("[Shrinkinator] Не удалось настроить хват пушки: " + ex);
			}
		}

		private static void ApplyInternal(GameObject clone, ItemGun gun, bool gripKnown, Vector3 gripLocalPosition)
		{
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			gun.aimVerticalOffset = ShrinkinatorConfig.AimVerticalOffset.Value;
			gun.grabVerticalOffset = ShrinkinatorConfig.GrabVerticalOffset.Value;
			gun.grabStrengthMultiplier = Mathf.Max(0.1f, ShrinkinatorConfig.GrabStrengthMultiplier.Value);
			gun.torqueMultiplier = Mathf.Max(0.1f, ShrinkinatorConfig.TorqueMultiplier.Value);
			if (!gripKnown)
			{
				return;
			}
			if ((Object)(object)EnsurePoint(clone.transform, "Force Grab Point", gripLocalPosition) != (Object)null)
			{
				Log.Info("[Shrinkinator] Точка хвата \"Force Grab Point\" перенесена в рукоять.");
			}
			if (ShrinkinatorConfig.CenterOfMassInGrip.Value)
			{
				if ((Object)(object)EnsurePoint(clone.transform, "Center of Mass", gripLocalPosition) != (Object)null)
				{
					Log.Info("[Shrinkinator] Центр масс \"Center of Mass\" перенесён в рукоять.");
				}
				Rigidbody component = clone.GetComponent<Rigidbody>();
				if ((Object)(object)component != (Object)null)
				{
					component.centerOfMass = gripLocalPosition;
				}
			}
		}

		public static void AlignMuzzleForward(GameObject clone, ItemGun gun)
		{
			//IL_003a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: 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_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)clone == (Object)null || (Object)(object)gun == (Object)null)
			{
				return;
			}
			try
			{
				if (!ShrinkinatorConfig.AimAssist.Value || !((Object)(object)gun.gunMuzzle != (Object)null))
				{
					return;
				}
				float num = Vector3.Angle(gun.gunMuzzle.forward, clone.transform.forward);
				if (num > 0.5f)
				{
					Vector3 forward = clone.transform.forward;
					Vector3 val = gun.gunMuzzle.up - forward * Vector3.Dot(gun.gunMuzzle.up, forward);
					if (((Vector3)(ref val)).sqrMagnitude < 1E-06f)
					{
						val = clone.transform.up - forward * Vector3.Dot(clone.transform.up, forward);
					}
					if (((Vector3)(ref val)).sqrMagnitude < 1E-06f)
					{
						val = Vector3.up;
					}
					gun.gunMuzzle.rotation = Quaternion.LookRotation(forward, ((Vector3)(ref val)).normalized);
					Log.Info("[Shrinkinator] AimAssist: ось дула выровнена по корпусу (было отклонение " + num.ToString("0.0") + "°).");
				}
			}
			catch (Exception ex)
			{
				Log.Warning("[Shrinkinator] Не удалось выровнять ось дула: " + ex);
			}
		}

		private static Transform EnsurePoint(Transform root, string name, Vector3 localPosition)
		{
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			Transform val = root.Find(name);
			if ((Object)(object)val == (Object)null)
			{
				val = new GameObject(name)
				{
					layer = ((Component)root).gameObject.layer
				}.transform;
				val.SetParent(root, false);
			}
			val.localPosition = localPosition;
			val.localRotation = Quaternion.identity;
			val.localScale = Vector3.one;
			return val;
		}
	}
	internal static class ItemRegistration
	{
		internal const string PrefabName = "Item Shrinkinator";

		private static GameObject _template;

		private static bool _registered;

		internal static Item ShrinkinatorItem { get; private set; }

		internal static string NetworkPrefabPath => "Items/Item Shrinkinator";

		internal static GameObject Template => _template;

		internal static void TryRegister()
		{
			if (_registered)
			{
				return;
			}
			try
			{
				RegisterInternal();
			}
			catch (Exception exception)
			{
				Log.Error("[Shrinkinator] Ошибка регистрации предмета", exception);
			}
		}

		private static void RegisterInternal()
		{
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Invalid comparison between Unknown and I4
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0106: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_02e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0302: Unknown result type (might be due to invalid IL or missing references)
			Item val = null;
			GameObject val2 = null;
			foreach (Item allItem in Items.AllItems)
			{
				if (!((Object)(object)allItem == (Object)null) && (int)allItem.itemType == 9)
				{
					GameObject prefabSafe = GetPrefabSafe(allItem);
					if (!((Object)(object)prefabSafe == (Object)null) && !((Object)(object)prefabSafe.GetComponent<ItemGun>() == (Object)null))
					{
						val = allItem;
						val2 = prefabSafe;
						break;
					}
				}
			}
			if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
			{
				Log.Warning("[Shrinkinator] Ванильная пушка не найдена в StatsManager — регистрация отложена.");
				return;
			}
			Log.Info("[Shrinkinator] Клонируем ванильный предмет \"" + val.itemName + "\".");
			GameObject val3 = InstantiateInactive(val2);
			if ((Object)(object)val3 == (Object)null)
			{
				Log.Error("[Shrinkinator] Не удалось клонировать префаб пушки.");
				return;
			}
			((Object)val3).name = "Item Shrinkinator";
			Object.DontDestroyOnLoad((Object)(object)val3);
			_template = val3;
			Item val4 = Object.Instantiate<Item>(val);
			((Object)val4).name = "Item Shrinkinator";
			val4.itemName = ShrinkinatorConfig.ItemName.Value;
			val4.itemType = (itemType)9;
			val4.itemVolume = (itemVolume)1;
			val4.maxAmountInShop = 1;
			val4.maxAmount = 1;
			val4.emojiIcon = (emojiIcon)25;
			if ((Object)(object)val4.value != (Object)null)
			{
				Value val5 = Object.Instantiate<Value>(val4.value);
				float num = Mathf.Max(0.1f, ShrinkinatorConfig.PriceMultiplier.Value);
				val5.valueMin *= num;
				val5.valueMax *= num;
				val4.value = val5;
			}
			if ((Object)(object)val4.colorPreset != (Object)null)
			{
				ColorPresets val6 = Object.Instantiate<ColorPresets>(val4.colorPreset);
				val6.colorMain = new Color(0.25f, 0.9f, 0.35f);
				val6.colorLight = new Color(0.55f, 1f, 0.6f);
				val6.colorDark = new Color(0.08f, 0.45f, 0.15f);
				val4.colorPreset = val6;
			}
			ItemGun component = val3.GetComponent<ItemGun>();
			if ((Object)(object)component == (Object)null)
			{
				Log.Error("[Shrinkinator] На клоне префаба нет ItemGun — регистрация отменена.");
				Object.Destroy((Object)(object)val3);
				return;
			}
			component.gunRandomSpread = 0f;
			component.shootCooldown = Mathf.Max(0.1f, ShrinkinatorConfig.ShootCooldown.Value);
			component.misfirePercentageChange = 0f;
			component.numberOfBullets = 1;
			component.hasOneShot = true;
			component.hasBuildUp = false;
			component.batteryDrainFullBar = true;
			component.batteryDrainFullBars = 1;
			component.batteryDrain = 100f / (float)Mathf.Max(1, ShrinkinatorConfig.Charges.Value);
			ItemBattery component2 = val3.GetComponent<ItemBattery>();
			if ((Object)(object)component2 != (Object)null)
			{
				int batteryLifeInt = (component2.batteryBars = Mathf.Max(1, ShrinkinatorConfig.Charges.Value));
				component2.batteryLife = 100f;
				component2.batteryLifeInt = batteryLifeInt;
			}
			RecolorBullet(component);
			GunHandlingTuner.AlignMuzzleForward(val3, component);
			Vector3 gripLocalPosition = Vector3.zero;
			bool gripKnown = false;
			if (ShrinkinatorConfig.UseCustomModel.Value)
			{
				gripKnown = ShrinkinatorModelBuilder.Apply(val3, component, out gripLocalPosition);
			}
			GunHandlingTuner.Apply(val3, component, gripKnown, gripLocalPosition);
			ItemAttributes component3 = val3.GetComponent<ItemAttributes>();
			if ((Object)(object)component3 == (Object)null)
			{
				Log.Error("[Shrinkinator] На клоне префаба нет ItemAttributes — регистрация отменена.");
				Object.Destroy((Object)(object)val3);
				return;
			}
			component3.item = val4;
			Items.RegisterItem(component3);
			val3.SetActive(false);
			NetworkPrefabResolverPatch.CacheRuntimePrefab();
			ShrinkinatorItem = val4;
			_registered = true;
			Log.Info("[Shrinkinator] Предмет \"" + val4.itemName + "\" зарегистрирован (prefab \"Item Shrinkinator\").");
		}

		private static void RecolorBullet(ItemGun gun)
		{
			//IL_00ab: 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)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)gun.bulletPrefab == (Object)null)
				{
					return;
				}
				GameObject val = InstantiateInactive(gun.bulletPrefab);
				if ((Object)(object)val == (Object)null)
				{
					return;
				}
				((Object)val).name = "Item Shrinkinator Bullet";
				Object.DontDestroyOnLoad((Object)(object)val);
				HurtCollider[] componentsInChildren = val.GetComponentsInChildren<HurtCollider>(true);
				foreach (HurtCollider obj in componentsInChildren)
				{
					((Behaviour)obj).enabled = false;
					((Component)obj).gameObject.SetActive(false);
				}
				ItemGunBullet component = val.GetComponent<ItemGunBullet>();
				Color val2 = default(Color);
				((Color)(ref val2))..ctor(0.35f, 1f, 0.45f);
				if ((Object)(object)component != (Object)null)
				{
					if ((Object)(object)component.shootLine != (Object)null)
					{
						component.shootLine.startColor = val2;
						component.shootLine.endColor = val2;
					}
					ParticleSystem val3 = (((Object)(object)component.particleSmoke != (Object)null) ? component.particleSmoke : component.particleImpact);
					if ((Object)(object)val3 != (Object)null)
					{
						MainModule main = val3.main;
						((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(val2);
						ParticleSystemRenderer component2 = ((Component)val3).GetComponent<ParticleSystemRenderer>();
						if ((Object)(object)component2 != (Object)null)
						{
							MistVfx.Init(((Renderer)component2).sharedMaterial);
						}
					}
				}
				gun.bulletPrefab = val;
			}
			catch (Exception ex)
			{
				Log.Warning("[Shrinkinator] Не удалось перекрасить пулю: " + ex.Message);
			}
		}

		private static GameObject GetPrefabSafe(Item item)
		{
			try
			{
				if (item.prefab == null || !((PrefabRef<GameObject>)(object)item.prefab).IsValid())
				{
					return null;
				}
				return ((PrefabRef<GameObject>)(object)item.prefab).Prefab;
			}
			catch (Exception)
			{
				return null;
			}
		}

		private static GameObject InstantiateInactive(GameObject prefab)
		{
			bool activeSelf = prefab.activeSelf;
			try
			{
				if (activeSelf)
				{
					prefab.SetActive(false);
				}
				return Object.Instantiate<GameObject>(prefab);
			}
			finally
			{
				if (activeSelf)
				{
					prefab.SetActive(true);
				}
			}
		}

		internal static bool IsOurGun(ItemGun gun)
		{
			if ((Object)(object)gun == (Object)null)
			{
				return false;
			}
			ItemAttributes component = ((Component)gun).GetComponent<ItemAttributes>();
			if ((Object)(object)component == (Object)null || (Object)(object)component.item == (Object)null)
			{
				return false;
			}
			if ((Object)(object)ShrinkinatorItem != (Object)null && (Object)(object)component.item == (Object)(object)ShrinkinatorItem)
			{
				return true;
			}
			return ((Object)component.item).name == "Item Shrinkinator";
		}

		internal static bool IsTemplate(GameObject gameObject)
		{
			if ((Object)(object)gameObject != (Object)null && (Object)(object)_template != (Object)null)
			{
				return (Object)(object)gameObject == (Object)(object)_template;
			}
			return false;
		}
	}
	internal static class Log
	{
		private static ManualLogSource _logger;

		internal static void Init(ManualLogSource logger)
		{
			_logger = logger;
		}

		internal static void Info(string message)
		{
			ManualLogSource logger = _logger;
			if (logger != null)
			{
				logger.LogInfo((object)message);
			}
		}

		internal static void Warning(string message)
		{
			ManualLogSource logger = _logger;
			if (logger != null)
			{
				logger.LogWarning((object)message);
			}
		}

		internal static void Error(string message)
		{
			ManualLogSource logger = _logger;
			if (logger != null)
			{
				logger.LogError((object)message);
			}
		}

		internal static void Error(string message, Exception exception)
		{
			ManualLogSource logger = _logger;
			if (logger != null)
			{
				logger.LogError((object)(message + "\n" + exception));
			}
		}
	}
	internal static class MistVfx
	{
		private static Material _material;

		private static bool _materialReady;

		internal static void Init(Material baseMaterial)
		{
			EnsureMaterial(baseMaterial);
		}

		private static Material EnsureMaterial(Material fallback = null)
		{
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Expected O, but got Unknown
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			if (_materialReady)
			{
				return _material;
			}
			_materialReady = true;
			try
			{
				Shader val = Shader.Find("Legacy Shaders/Particles/Alpha Blended") ?? Shader.Find("Particles/Standard Unlit") ?? Shader.Find("Sprites/Default") ?? (((Object)(object)fallback != (Object)null) ? fallback.shader : null);
				if ((Object)(object)val == (Object)null)
				{
					_material = fallback;
					return _material;
				}
				_material = new Material(val)
				{
					color = new Color(0.4f, 1f, 0.5f, 0.18f),
					renderQueue = 3000
				};
				if (_material.HasProperty("_TintColor"))
				{
					_material.SetColor("_TintColor", new Color(0.35f, 1f, 0.45f, 0.12f));
				}
			}
			catch (Exception ex)
			{
				Log.Warning("[Shrinkinator] Не удалось подготовить материал тумана: " + ex.Message);
				_material = fallback;
			}
			return _material;
		}

		internal static void Spawn(Vector3 position, float radius)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0160: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Expected O, but got Unknown
			//IL_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: 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_01b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01be: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0201: Unknown result type (might be due to invalid IL or missing references)
			//IL_0206: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_021f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Unknown result type (might be due to invalid IL or missing references)
			//IL_024e: 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_025e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0288: Unknown result type (might be due to invalid IL or missing references)
			//IL_0293: Unknown result type (might be due to invalid IL or missing references)
			//IL_0298: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				GameObject val = new GameObject("ShrinkinatorMist");
				val.transform.position = position;
				Object.Destroy((Object)val, 3.5f);
				ParticleSystem val2 = val.AddComponent<ParticleSystem>();
				MainModule main = val2.main;
				((MainModule)(ref main)).playOnAwake = false;
				((MainModule)(ref main)).loop = false;
				((MainModule)(ref main)).duration = 0.35f;
				((MainModule)(ref main)).startLifetime = new MinMaxCurve(0.8f, 1.4f);
				((MainModule)(ref main)).startSpeed = new MinMaxCurve(0.15f, 0.45f);
				((MainModule)(ref main)).startSize = new MinMaxCurve(Mathf.Max(0.25f, radius * 0.18f), Mathf.Max(0.4f, radius * 0.35f));
				((MainModule)(ref main)).startColor = MinMaxGradient.op_Implicit(new Color(0.4f, 1f, 0.5f, 0.2f));
				((MainModule)(ref main)).maxParticles = 24;
				((MainModule)(ref main)).simulationSpace = (ParticleSystemSimulationSpace)1;
				((MainModule)(ref main)).stopAction = (ParticleSystemStopAction)2;
				((MainModule)(ref main)).gravityModifier = MinMaxCurve.op_Implicit(-0.05f);
				EmissionModule emission = val2.emission;
				((EmissionModule)(ref emission)).rateOverTime = MinMaxCurve.op_Implicit(0f);
				((EmissionModule)(ref emission)).SetBursts((Burst[])(object)new Burst[1]
				{
					new Burst(0f, (short)14)
				});
				ShapeModule shape = val2.shape;
				((ShapeModule)(ref shape)).enabled = true;
				((ShapeModule)(ref shape)).shapeType = (ParticleSystemShapeType)0;
				((ShapeModule)(ref shape)).radius = Mathf.Max(0.15f, radius * 0.35f);
				ColorOverLifetimeModule colorOverLifetime = val2.colorOverLifetime;
				((ColorOverLifetimeModule)(ref colorOverLifetime)).enabled = true;
				Gradient val3 = new Gradient();
				val3.SetKeys((GradientColorKey[])(object)new GradientColorKey[2]
				{
					new GradientColorKey(new Color(0.45f, 1f, 0.55f), 0f),
					new GradientColorKey(new Color(0.2f, 0.8f, 0.3f), 1f)
				}, (GradientAlphaKey[])(object)new GradientAlphaKey[3]
				{
					new GradientAlphaKey(0.22f, 0f),
					new GradientAlphaKey(0.12f, 0.35f),
					new GradientAlphaKey(0f, 1f)
				});
				((ColorOverLifetimeModule)(ref colorOverLifetime)).color = MinMaxGradient.op_Implicit(val3);
				SizeOverLifetimeModule sizeOverLifetime = val2.sizeOverLifetime;
				((SizeOverLifetimeModule)(ref sizeOverLifetime)).enabled = true;
				((SizeOverLifetimeModule)(ref sizeOverLifetime)).size = new MinMaxCurve(1f, AnimationCurve.EaseInOut(0f, 0.7f, 1f, 1.6f));
				VelocityOverLifetimeModule velocityOverLifetime = val2.velocityOverLifetime;
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).enabled = true;
				((VelocityOverLifetimeModule)(ref velocityOverLifetime)).speedModifier = new MinMaxCurve(1f, AnimationCurve.Linear(0f, 1f, 1f, 0.15f));
				CollisionModule collision = val2.collision;
				((CollisionModule)(ref collision)).enabled = false;
				ParticleSystemRenderer component = ((Component)val2).GetComponent<ParticleSystemRenderer>();
				component.renderMode = (ParticleSystemRenderMode)0;
				Material val4 = EnsureMaterial();
				if ((Object)(object)val4 != (Object)null)
				{
					((Renderer)component).sharedMaterial = val4;
				}
				val2.Play();
			}
			catch (Exception exception)
			{
				Log.Error("[Shrinkinator] Ошибка создания VFX тумана", exception);
			}
		}
	}
	[HarmonyPatch(typeof(StatsManager), "RunStartStats")]
	internal static class StatsManagerPatch
	{
		private static void Postfix()
		{
			try
			{
				ItemRegistration.TryRegister();
			}
			catch (Exception exception)
			{
				Log.Error("[Shrinkinator] Ошибка в постфиксе RunStartStats", exception);
			}
		}
	}
	[HarmonyPatch(typeof(ItemGun), "ShootBulletRPC")]
	internal static class ItemGunShootPatch
	{
		private static float _lastCloudTime;

		private static int _lastCloudGun;

		private static void Postfix(ItemGun __instance, Vector3 _endPosition, bool _hit)
		{
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if (!ItemRegistration.IsOurGun(__instance))
				{
					return;
				}
				if ((Object)(object)__instance.hurtCollider != (Object)null)
				{
					((Behaviour)__instance.hurtCollider).enabled = false;
					((Component)__instance.hurtCollider).gameObject.SetActive(false);
				}
				int instanceID = ((Object)__instance).GetInstanceID();
				float unscaledTime = Time.unscaledTime;
				if (instanceID != _lastCloudGun || !(unscaledTime - _lastCloudTime < 0.08f))
				{
					_lastCloudGun = instanceID;
					_lastCloudTime = unscaledTime;
					Vector3 val = ComputeCloudCenter(__instance, _endPosition, _hit);
					float radius = Mathf.Max(0.3f, ShrinkinatorConfig.CloudRadius.Value);
					MistVfx.Spawn(val, radius);
					if (SemiFunc.IsMasterClientOrSingleplayer())
					{
						ApplyCloud(__instance, val, radius);
					}
				}
			}
			catch (Exception exception)
			{
				Log.Error("[Shrinkinator] Ошибка в обработчике выстрела", exception);
			}
		}

		private static Vector3 ComputeCloudCenter(ItemGun gun, Vector3 endPosition, bool hit)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0042: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			Transform gunMuzzle = gun.gunMuzzle;
			float num = Mathf.Max(1f, ShrinkinatorConfig.MistRange.Value);
			if ((Object)(object)gunMuzzle == (Object)null)
			{
				return endPosition;
			}
			if (hit)
			{
				Vector3 val = endPosition - gunMuzzle.position;
				if (((Vector3)(ref val)).magnitude > num)
				{
					return gunMuzzle.position + ((Vector3)(ref val)).normalized * num;
				}
				return endPosition;
			}
			return gunMuzzle.position + gunMuzzle.forward * num;
		}

		private static void ApplyCloud(ItemGun gun, Vector3 center, float radius)
		{
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_008b: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			Transform gunMuzzle = gun.gunMuzzle;
			Vector3 val = (((Object)(object)gunMuzzle != (Object)null) ? gunMuzzle.position : center);
			LayerMask val2 = SemiFunc.LayerMaskGetPhysGrabObject();
			int num = ((LayerMask)(ref val2)).value | LayerMask.GetMask(new string[2] { "Enemy", "Player" });
			HashSet<ValuableObject> handledValuables = new HashSet<ValuableObject>();
			HashSet<EnemyRigidbody> handledEnemies = new HashSet<EnemyRigidbody>();
			HashSet<PlayerAvatar> handledPlayers = new HashSet<PlayerAvatar>();
			Dictionary<PlayerAvatar, PlayerAvatarCollision> playerCollisions = CollectPlayerCollisions();
			float[] array = new float[3] { 1f, 0.5f, 0.25f };
			foreach (float num2 in array)
			{
				Vector3 val3 = Vector3.Lerp(val, center, num2);
				Collider[] array2;
				try
				{
					array2 = Physics.OverlapSphere(val3, radius, num, (QueryTriggerInteraction)2);
				}
				catch (Exception ex)
				{
					Log.Warning("[Shrinkinator] OverlapSphere не удался: " + ex.Message);
					continue;
				}
				Collider[] array3 = array2;
				foreach (Collider val4 in array3)
				{
					if (!((Object)(object)val4 == (Object)null))
					{
						try
						{
							HandleCollider(val4, gun, handledValuables, handledEnemies, handledPlayers, playerCollisions);
						}
						catch (Exception exception)
						{
							Log.Error("[Shrinkinator] Ошибка обработки цели в облаке", exception);
						}
					}
				}
			}
		}

		private static void HandleCollider(Collider collider, ItemGun gun, HashSet<ValuableObject> handledValuables, HashSet<EnemyRigidbody> handledEnemies, HashSet<PlayerAvatar> handledPlayers, Dictionary<PlayerAvatar, PlayerAvatarCollision> playerCollisions)
		{
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			float scale = Mathf.Clamp(ShrinkinatorConfig.ScaleFactor.Value, 0.05f, 1f);
			float duration = Mathf.Max(1f, ShrinkinatorConfig.DurationSeconds.Value);
			ValuableObject componentInParent = ((Component)collider).GetComponentInParent<ValuableObject>();
			if ((Object)(object)componentInParent != (Object)null)
			{
				if (handledValuables.Add(componentInParent))
				{
					ValuableShrinkController valuableShrinkController = AttachPatches.EnsureValuableController(((Component)componentInParent).gameObject);
					if ((Object)(object)valuableShrinkController != (Object)null)
					{
						valuableShrinkController.ApplyFromHost(scale, ShrinkinatorConfig.ValueScalePrice.Value);
					}
				}
			}
			else
			{
				if ((Object)(object)((Component)collider).GetComponentInParent<ItemAttributes>() != (Object)null)
				{
					return;
				}
				EnemyRigidbody componentInParent2 = ((Component)collider).GetComponentInParent<EnemyRigidbody>();
				if ((Object)(object)componentInParent2 != (Object)null)
				{
					if (handledEnemies.Add(componentInParent2))
					{
						EnemyShrinkController enemyShrinkController = AttachPatches.EnsureEnemyController(((Component)componentInParent2).gameObject);
						if ((Object)(object)enemyShrinkController != (Object)null)
						{
							enemyShrinkController.ApplyFromHost(scale, duration);
						}
					}
				}
				else
				{
					if (((Component)collider).gameObject.layer != LayerMask.NameToLayer("Player"))
					{
						return;
					}
					PlayerAvatar val = FindNearestPlayer(((Component)collider).transform.position, playerCollisions, 2f);
					if ((Object)(object)val != (Object)null && handledPlayers.Add(val))
					{
						PlayerShrinkController playerShrinkController = AttachPatches.EnsurePlayerController(((Component)val).gameObject);
						if ((Object)(object)playerShrinkController != (Object)null)
						{
							playerShrinkController.ApplyFromHost(scale, duration);
						}
					}
				}
			}
		}

		private static Dictionary<PlayerAvatar, PlayerAvatarCollision> CollectPlayerCollisions()
		{
			Dictionary<PlayerAvatar, PlayerAvatarCollision> dictionary = new Dictionary<PlayerAvatar, PlayerAvatarCollision>();
			PlayerAvatarCollision[] array = Object.FindObjectsOfType<PlayerAvatarCollision>();
			foreach (PlayerAvatarCollision val in array)
			{
				if ((Object)(object)val != (Object)null && (Object)(object)val.PlayerAvatar != (Object)null && !dictionary.ContainsKey(val.PlayerAvatar))
				{
					dictionary[val.PlayerAvatar] = val;
				}
			}
			return dictionary;
		}

		private static PlayerAvatar FindNearestPlayer(Vector3 point, Dictionary<PlayerAvatar, PlayerAvatarCollision> playerCollisions, float maxDistance)
		{
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			//IL_0095: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)GameDirector.instance == (Object)null)
			{
				return null;
			}
			PlayerAvatar result = null;
			float num = maxDistance * maxDistance;
			foreach (PlayerAvatar player in GameDirector.instance.PlayerList)
			{
				if (!((Object)(object)player == (Object)null) && !player.isDisabled)
				{
					PlayerAvatarCollision value;
					Vector3 val = ((playerCollisions == null || !playerCollisions.TryGetValue(player, out value) || !((Object)(object)value != (Object)null)) ? ((Component)player).transform.position : (((Object)(object)value.CollisionTransform != (Object)null) ? value.CollisionTransform.position : ((Component)value).transform.position));
					Vector3 val2 = val - point;
					float sqrMagnitude = ((Vector3)(ref val2)).sqrMagnitude;
					if (sqrMagnitude <= num)
					{
						num = sqrMagnitude;
						result = player;
					}
				}
			}
			return result;
		}
	}
	internal static class NetworkPrefabResolverPatch
	{
		[HarmonyPatch(typeof(RunManager), "Awake")]
		[HarmonyPriority(0)]
		internal static class RunManagerAwakeCachePatch
		{
			private static void Postfix(RunManager __instance)
			{
				try
				{
					if ((Object)(object)ItemRegistration.Template != (Object)null)
					{
						CacheRuntimePrefab(((Object)(object)__instance != (Object)null) ? __instance.multiplayerPool : null);
					}
				}
				catch (Exception ex)
				{
					Log.Warning("[Shrinkinator] Не удалось обновить кэш префаба в RunManager.Awake: " + ex.Message);
				}
			}
		}

		[HarmonyPatch(/*Could not decode attribute arguments.*/)]
		internal static class PrefabRefGetPrefabPatch
		{
			private static bool Prefix(PrefabRef<GameObject> __instance, ref GameObject __result)
			{
				try
				{
					GameObject template = ItemRegistration.Template;
					if ((Object)(object)template == (Object)null || __instance == null)
					{
						return true;
					}
					if (__instance.ResourcePath != ItemRegistration.NetworkPrefabPath)
					{
						return true;
					}
					CacheRuntimePrefab();
					__result = template;
					return false;
				}
				catch (Exception exception)
				{
					Log.Error("[Shrinkinator] Ошибка в PrefabRef.Prefab", exception);
					return true;
				}
			}
		}

		[HarmonyPatch(typeof(MultiplayerPool), "Instantiate")]
		internal static class MultiplayerPoolInstantiatePatch
		{
			private static bool Prefix(MultiplayerPool __instance, string prefabId, Vector3 position, Quaternion rotation, ref GameObject __result)
			{
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_002d: Unknown result type (might be due to invalid IL or missing references)
				try
				{
					if ((Object)(object)ItemRegistration.Template == (Object)null || prefabId != ItemRegistration.NetworkPrefabPath)
					{
						return true;
					}
					CacheRuntimePrefab(__instance);
					SuppressCloneActivation = true;
					try
					{
						__result = InstantiateTemplate(position, rotation);
					}
					finally
					{
						SuppressCloneActivation = false;
					}
					Log.Info("[Shrinkinator] Спавн предмета через MultiplayerPool: " + prefabId);
					return false;
				}
				catch (Exception exception)
				{
					Log.Error("[Shrinkinator] Ошибка в MultiplayerPool.Instantiate", exception);
					return true;
				}
			}
		}

		private static bool _cacheLogged;

		internal static bool SuppressCloneActivation;

		internal static void CacheRuntimePrefab(MultiplayerPool preferredPool = null)
		{
			GameObject template = ItemRegistration.Template;
			if ((Object)(object)template == (Object)null)
			{
				return;
			}
			try
			{
				bool flag = false;
				RunManager instance = RunManager.instance;
				if ((Object)(object)instance != (Object)null)
				{
					if (instance.singleplayerPool != null)
					{
						instance.singleplayerPool[ItemRegistration.NetworkPrefabPath] = (Object)(object)template;
						flag = true;
					}
					preferredPool = preferredPool ?? instance.multiplayerPool;
				}
				if (preferredPool != null && preferredPool.ResourceCache != null)
				{
					preferredPool.ResourceCache[ItemRegistration.NetworkPrefabPath] = template;
					flag = true;
				}
				if (flag && !_cacheLogged)
				{
					_cacheLogged = true;
					Log.Info("[Shrinkinator] Runtime-префаб добавлен в кэши одиночного и сетевого спавна.");
				}
			}
			catch (Exception ex)
			{
				Log.Warning("[Shrinkinator] Не удалось заполнить кэш runtime-префаба: " + ex.Message);
			}
		}

		internal static GameObject InstantiateTemplate(Vector3 position, Quaternion rotation)
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			return Object.Instantiate<GameObject>(ItemRegistration.Template, position, rotation);
		}
	}
	[HarmonyPatch(typeof(ItemAttributes))]
	internal static class TemplateItemAttributesLifecyclePatch
	{
		private static bool ShouldRunVanilla(ItemAttributes instance)
		{
			if (!((Object)(object)instance == (Object)null))
			{
				return !ItemRegistration.IsTemplate(((Component)instance).gameObject);
			}
			return true;
		}

		[HarmonyPatch("Start")]
		[HarmonyPrefix]
		private static bool StartPrefix(ItemAttributes __instance)
		{
			return ShouldRunVanilla(__instance);
		}

		[HarmonyPatch("Update")]
		[HarmonyPrefix]
		private static bool UpdatePrefix(ItemAttributes __instance)
		{
			return ShouldRunVanilla(__instance);
		}
	}
	[HarmonyPatch(typeof(Object), "Instantiate", new Type[]
	{
		typeof(Object),
		typeof(Vector3),
		typeof(Quaternion)
	})]
	internal static class ActivateSpawnedTemplateClonePatch
	{
		private static void Postfix(Object original, Object __result)
		{
			try
			{
				if (!NetworkPrefabResolverPatch.SuppressCloneActivation)
				{
					GameObject gameObject = (GameObject)(object)((original is GameObject) ? original : null);
					GameObject val = (GameObject)(object)((__result is GameObject) ? __result : null);
					if (!((Object)(object)val == (Object)null) && ItemRegistration.IsTemplate(gameObject) && !val.activeSelf)
					{
						val.SetActive(true);
					}
				}
			}
			catch (Exception ex)
			{
				Log.Warning("[Shrinkinator] Не удалось активировать заспавненный предмет: " + ex.Message);
			}
		}
	}
	internal static class AttachPatches
	{
		[HarmonyPatch(typeof(PhysGrabObject), "Awake")]
		internal static class PhysGrabObjectAwakePatch
		{
			private static void Postfix(PhysGrabObject __instance)
			{
				try
				{
					if ((Object)(object)__instance != (Object)null && (Object)(object)((Component)__instance).GetComponent<ValuableObject>() != (Object)null)
					{
						EnsureValuableController(((Component)__instance).gameObject);
					}
				}
				catch (Exception exception)
				{
					Log.Error("[Shrinkinator] Ошибка патча PhysGrabObject.Awake", exception);
				}
			}
		}

		[HarmonyPatch(typeof(EnemyRigidbody), "Awake")]
		internal static class EnemyRigidbodyAwakePatch
		{
			private static void Postfix(EnemyRigidbody __instance)
			{
				try
				{
					if ((Object)(object)__instance != (Object)null)
					{
						EnsureEnemyController(((Component)__instance).gameObject);
					}
				}
				catch (Exception exception)
				{
					Log.Error("[Shrinkinator] Ошибка патча EnemyRigidbody.Awake", exception);
				}
			}
		}

		[HarmonyPatch(typeof(PlayerAvatar), "Start")]
		internal static class PlayerAvatarStartPatch
		{
			private static void Postfix(PlayerAvatar __instance)
			{
				try
				{
					if ((Object)(object)__instance != (Object)null)
					{
						EnsurePlayerController(((Component)__instance).gameObject);
					}
				}
				catch (Exception exception)
				{
					Log.Error("[Shrinkinator] Ошибка патча PlayerAvatar.Start", exception);
				}
			}
		}

		internal static ValuableShrinkController EnsureValuableController(GameObject target)
		{
			return EnsureController<ValuableShrinkController>(target);
		}

		internal static EnemyShrinkController EnsureEnemyController(GameObject target)
		{
			return EnsureController<EnemyShrinkController>(target);
		}

		internal static PlayerShrinkController EnsurePlayerController(GameObject target)
		{
			return EnsureController<PlayerShrinkController>(target);
		}

		private static T EnsureController<T>(GameObject target) where T : Component
		{
			if ((Object)(object)target == (Object)null)
			{
				return default(T);
			}
			T component = target.GetComponent<T>();
			if ((Object)(object)component != (Object)null)
			{
				return component;
			}
			component = target.AddComponent<T>();
			PhotonView componentInParent = target.GetComponentInParent<PhotonView>();
			if ((Object)(object)componentInParent != (Object)null)
			{
				componentInParent.RefreshRpcMonoBehaviourCache();
			}
			return component;
		}
	}
	[BepInPlugin("com.kimi.shrinkinator", "Shrinkinator", "1.1.0")]
	[BepInDependency(/*Could not decode attribute arguments.*/)]
	public class Plugin : BaseUnityPlugin
	{
		internal const string PluginGuid = "com.kimi.shrinkinator";

		internal const string PluginName = "Shrinkinator";

		internal const string PluginVersion = "1.1.0";

		private void Awake()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			Log.Init(((BaseUnityPlugin)this).Logger);
			ShrinkinatorConfig.Init(((BaseUnityPlugin)this).Config);
			Harmony val = new Harmony("com.kimi.shrinkinator");
			try
			{
				val.PatchAll();
			}
			catch (Exception exception)
			{
				Log.Error("[Shrinkinator] Ошибка применения Harmony-патчей", exception);
			}
			Log.Info("Shrinkinator v1.1.0 загружен.");
		}
	}
	internal static class ShrinkRpc
	{
		internal static void SendToAll(PhotonView photonView, string method, Action directCall, params object[] args)
		{
			if ((Object)(object)photonView == (Object)null)
			{
				Log.Warning("[Shrinkinator] Нет PhotonView для RPC " + method + " — применяем локально.");
				directCall();
			}
			else if (SemiFunc.IsMultiplayer())
			{
				photonView.RPC(method, (RpcTarget)0, args);
			}
			else
			{
				directCall();
			}
		}
	}
	public class ValuableShrinkController : MonoBehaviour
	{
		private Vector3 _baseScale;

		private bool _hasBase;

		internal void ApplyFromHost(float scale, bool scalePrice)
		{
			if (TryGetAppliedScale(scale, out var applied))
			{
				ShrinkRpc.SendToAll(((Component)this).GetComponent<PhotonView>(), "RPC_ApplyShrink", delegate
				{
					ApplyLocal(applied, scalePrice);
				}, applied, scalePrice);
			}
		}

		[PunRPC]
		private void RPC_ApplyShrink(float scale, bool scalePrice)
		{
			ApplyLocal(scale, scalePrice);
		}

		private bool TryGetAppliedScale(float requested, out float applied)
		{
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			applied = requested;
			CaptureBaseScale();
			float num = Mathf.Clamp(ShrinkinatorConfig.ValuableMinScale.Value, 0.05f, 1f);
			float num2 = Mathf.Max(Mathf.Abs(_baseScale.x), 0.0001f);
			float num3 = Mathf.Abs(((Component)this).transform.localScale.x) / num2;
			if (num3 <= num * 1.001f)
			{
				return false;
			}
			if (num3 * requested < num)
			{
				applied = num / num3;
			}
			return applied < 0.999f;
		}

		private void CaptureBaseScale()
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			if (!_hasBase)
			{
				_baseScale = ((Component)this).transform.localScale;
				_hasBase = true;
			}
		}

		private void ApplyLocal(float scale, bool scalePrice)
		{
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0183: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				CaptureBaseScale();
				float num = Mathf.Clamp(ShrinkinatorConfig.ValuableMinScale.Value, 0.05f, 1f);
				float num2 = Mathf.Max(Mathf.Abs(_baseScale.x), 0.0001f);
				float num3 = Mathf.Abs(((Component)this).transform.localScale.x) / num2;
				if (num3 <= num * 1.001f)
				{
					return;
				}
				float num4 = scale;
				if (num3 * scale < num)
				{
					num4 = num / num3;
				}
				if (num4 >= 0.999f)
				{
					return;
				}
				float num5 = num4 * num4 * num4;
				((Component)this).transform.localScale = ((Component)this).transform.localScale * num4;
				Rigidbody component = ((Component)this).GetComponent<Rigidbody>();
				PhysGrabObject component2 = ((Component)this).GetComponent<PhysGrabObject>();
				if ((Object)(object)component != (Object)null)
				{
					float massOriginal = (component.mass = Mathf.Max(0.05f, component.mass * num5));
					if ((Object)(object)component2 != (Object)null)
					{
						component2.massOriginal = massOriginal;
					}
				}
				if (!scalePrice)
				{
					return;
				}
				ValuableObject component3 = ((Component)this).GetComponent<ValuableObject>();
				if (!((Object)(object)component3 != (Object)null))
				{
					return;
				}
				float num7 = Mathf.Max(1f, Mathf.Round(component3.dollarValueCurrent * num5));
				if (SemiFunc.IsMasterClientOrSingleplayer())
				{
					PhotonView val = (((Object)(object)component3.photonView != (Object)null) ? component3.photonView : ((Component)this).GetComponent<PhotonView>());
					if (SemiFunc.IsMultiplayer() && (Object)(object)val != (Object)null)
					{
						val.RPC("DollarValueSetRPC", (RpcTarget)0, new object[1] { num7 });
					}
					else
					{
						component3.DollarValueSetRPC(num7, default(PhotonMessageInfo));
					}
				}
			}
			catch (Exception exception)
			{
				Log.Error("[Shrinkinator] Ошибка уменьшения ценности", exception);
			}
		}
	}
	[DefaultExecutionOrder(20000)]
	public class EnemyShrinkController : MonoBehaviour
	{
		private static int _effectCounter;

		private bool _active;

		private int _effectId;

		private float _scale = 1f;

		private float _timer;

		private float _failsafeTimer;

		private Transform _visualRoot;

		private Vector3 _visualOriginalScale = Vector3.one;

		private Transform _follow;

		private bool _followUnderVisual;

		private float _massOriginal = -1f;

		private float _shrunkMass;

		private float _grabTimeNeededOriginal = -1f;

		private bool _grabOverrideOriginal;

		private bool _grabStunOriginal;

		private bool _grabSettingsStored;

		internal void ApplyFromHost(float scale, float duration)
		{
			int effectId = ++_effectCounter;
			ShrinkRpc.SendToAll(((Component)this).GetComponent<PhotonView>(), "RPC_ApplyShrink", delegate
			{
				RPC_ApplyShrink(scale, duration, effectId);
			}, scale, duration, effectId);
		}

		[PunRPC]
		private void RPC_ApplyShrink(float scale, float duration, int effectId)
		{
			try
			{
				if (_active)
				{
					if (Mathf.Approximately(_scale, scale))
					{
						_timer = duration;
						_failsafeTimer = duration + 5f;
						_effectId = effectId;
						return;
					}
					RevertLocal();
				}
				CacheTargets();
				_active = true;
				_scale = scale;
				_effectId = effectId;
				_timer = duration;
				_failsafeTimer = duration + 5f;
				ApplyVisual();
				PhysGrabObject component = ((Component)this).GetComponent<PhysGrabObject>();
				Rigidbody component2 = ((Component)this).GetComponent<Rigidbody>();
				float num = (((Object)(object)component != (Object)null) ? component.massOriginal : (((Object)(object)component2 != (Object)null) ? component2.mass : 1f));
				if (num <= 0f)
				{
					num = 1f;
				}
				_massOriginal = num;
				_shrunkMass = Mathf.Max(0.5f, num * scale);
				ApplyEnemyMass(_shrunkMass);
				EnemyRigidbody component3 = ((Component)this).GetComponent<EnemyRigidbody>();
				if ((Object)(object)component3 != (Object)null && !_grabSettingsStored)
				{
					_grabTimeNeededOriginal = component3.grabTimeNeeded;
					_grabOverrideOriginal = component3.grabOverride;
					_grabStunOriginal = component3.grabStun;
					_grabSettingsStored = true;
					component3.grabTimeNeeded = Mathf.Min(component3.grabTimeNeeded, 0.12f);
					component3.grabOverride = true;
					component3.grabStun = true;
				}
			}
			catch (Exception exception)
			{
				Log.Error("[Shrinkinator] Ошибка уменьшения врага", exception);
			}
		}

		[PunRPC]
		private void RPC_Expand(int effectId)
		{
			if (_active && effectId == _effectId)
			{
				RevertLocal();
			}
		}

		private void CacheTargets()
		{
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_007a: Unknown result type (might be due to invalid IL or missing references)
			_visualRoot = null;
			_follow = null;
			_followUnderVisual = false;
			EnemyRigidbody component = ((Component)this).GetComponent<EnemyRigidbody>();
			EnemyParent componentInParent = ((Component)this).GetComponentInParent<EnemyParent>();
			_follow = (((Object)(object)component != (Object)null) ? component.followTarget : null);
			if ((Object)(object)componentInParent != (Object)null)
			{
				Animator componentInChildren = ((Component)componentInParent).GetComponentInChildren<Animator>();
				if ((Object)(object)componentInChildren != (Object)null)
				{
					_visualRoot = ((Component)componentInChildren).transform;
				}
			}
			if ((Object)(object)_visualRoot != (Object)null)
			{
				_visualOriginalScale = _visualRoot.localScale;
			}
			_followUnderVisual = (Object)(object)_visualRoot != (Object)null && (Object)(object)_follow != (Object)null && ((Object)(object)_follow == (Object)(object)_visualRoot || _follow.IsChildOf(_visualRoot));
		}

		private void ApplyVisual()
		{
			//IL_0016: 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 (!((Object)(object)_visualRoot == (Object)null))
			{
				_visualRoot.localScale = _visualOriginalScale * _scale;
				if (!IsBeingGrabbed())
				{
					StabilizeFollowTarget();
				}
			}
		}

		private bool IsBeingGrabbed()
		{
			PhysGrabObject component = ((Component)this).GetComponent<PhysGrabObject>();
			if ((Object)(object)component != (Object)null && component.playerGrabbing != null && component.playerGrabbing.Count > 0)
			{
				return true;
			}
			EnemyRigidbody component2 = ((Component)this).GetComponent<EnemyRigidbody>();
			if ((Object)(object)component2 != (Object)null)
			{
				return component2.grabbed;
			}
			return false;
		}

		private void StabilizeFollowTarget()
		{
			//IL_0039: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: 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)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			if (_followUnderVisual && !((Object)(object)_follow == (Object)null) && !((Object)(object)_visualRoot == (Object)null) && !(_scale < 0.0001f))
			{
				Vector3 position = _visualRoot.position;
				Vector3 val = _follow.position - position;
				_follow.position = position + val / _scale;
			}
		}

		private void ApplyEnemyMass(float mass)
		{
			PhysGrabObject component = ((Component)this).GetComponent<PhysGrabObject>();
			Rigidbody component2 = ((Component)this).GetComponent<Rigidbody>();
			if ((Object)(object)component != (Object)null)
			{
				component.massOriginal = mass;
			}
			if ((Object)(object)component2 != (Object)null)
			{
				component2.mass = mass;
			}
		}

		private void FixedUpdate()
		{
			if (!_active)
			{
				return;
			}
			ApplyEnemyMass(_shrunkMass);
			PhysGrabObject component = ((Component)this).GetComponent<PhysGrabObject>();
			if ((Object)(object)component != (Object)null)
			{
				component.OverrideGrabStrength(12f, 0.2f);
				component.OverrideMinGrabStrength(8f, 0.2f);
			}
			if (IsBeingGrabbed())
			{
				EnemyRigidbody component2 = ((Component)this).GetComponent<EnemyRigidbody>();
				if ((Object)(object)component2 != (Object)null)
				{
					component2.DisableFollowPosition(0.2f, 2f);
					component2.DisableFollowRotation(0.2f, 2f);
				}
			}
		}

		private void Update()
		{
			if (!_active)
			{
				return;
			}
			float deltaTime = Time.deltaTime;
			_failsafeTimer -= deltaTime;
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				_timer -= deltaTime;
				if (_timer <= 0f)
				{
					int effectId = _effectId;
					ShrinkRpc.SendToAll(((Component)this).GetComponent<PhotonView>(), "RPC_Expand", delegate
					{
						RPC_Expand(effectId);
					}, effectId);
				}
			}
			if (_failsafeTimer <= 0f)
			{
				RevertLocal();
			}
		}

		private void LateUpdate()
		{
			if (_active)
			{
				ApplyVisual();
			}
		}

		private void RevertLocal()
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				if ((Object)(object)_visualRoot != (Object)null)
				{
					_visualRoot.localScale = _visualOriginalScale;
				}
				if (_massOriginal > 0f)
				{
					ApplyEnemyMass(_massOriginal);
				}
				EnemyRigidbody component = ((Component)this).GetComponent<EnemyRigidbody>();
				if ((Object)(object)component != (Object)null && _grabSettingsStored)
				{
					component.grabTimeNeeded = _grabTimeNeededOriginal;
					component.grabOverride = _grabOverrideOriginal;
					component.grabStun = _grabStunOriginal;
				}
			}
			catch (Exception exception)
			{
				Log.Error("[Shrinkinator] Ошибка возврата размера врага", exception);
			}
			finally
			{
				_active = false;
				_visualRoot = null;
				_follow = null;
				_followUnderVisual = false;
				_massOriginal = -1f;
				_grabSettingsStored = false;
			}
		}

		private void OnDisable()
		{
			if (_active)
			{
				RevertLocal();
			}
		}
	}
	[DefaultExecutionOrder(20000)]
	public class PlayerShrinkController : MonoBehaviour
	{
		private static int _effectCounter;

		private bool _active;

		private int _effectId;

		private float _scale = 1f;

		private float _timer;

		private float _failsafeTimer;

		private PlayerAvatarCollision _collision;

		private Vector3 _collisionOriginalScale;

		private Vector3 _collisionShrunkScale;

		private Transform _visual;

		private Vector3 _visualOriginalScale;

		private bool _warnedCollisionScale;

		private bool _localFeel;

		private Vector3 _camOffsetOriginal;

		private float _crouchPosOriginal;

		private float _crawlPosOriginal;

		private float _visionStandOriginal;

		private float _visionCrouchOriginal;

		private float _visionCrawlOriginal;

		private float _visionHeadStandOriginal;

		private float _visionHeadCrouchOriginal;

		private float _visionHeadCrawlOriginal;

		private PlayerVisionTarget _vision;

		private Vector3 _standCollisionOriginal;

		private Vector3 _crouchCollisionOriginal;

		private CapsuleCollider _standCheckCollider;

		private float _standCheckHeightOriginal;

		private float _standCheckRadiusOriginal;

		private Vector3 _standCheckOffsetOriginal;

		private float _fovOriginal;

		private float _nearClipOriginal;

		private bool _hasNearClip;

		private float _grabMinOriginal;

		private float _grabMaxOriginal;

		private float _grabMinOriginalOriginal;

		private float _grabRangeOriginal;

		private bool _hasGrabDistances;

		private float _speedMult = 1f;

		internal void ApplyFromHost(float scale, float duration)
		{
			PlayerAvatar component = ((Component)this).GetComponent<PlayerAvatar>();
			PhotonView photonView = (((Object)(object)component != (Object)null) ? component.photonView : ((Component)this).GetComponent<PhotonView>());
			int effectId = ++_effectCounter;
			ShrinkRpc.SendToAll(photonView, "RPC_ApplyShrink", delegate
			{
				RPC_ApplyShrink(scale, duration, effectId);
			}, scale, duration, effectId);
		}

		[PunRPC]
		private void RPC_ApplyShrink(float scale, float duration, int effectId)
		{
			//IL_0086: 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_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: 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_00c8: 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)
			try
			{
				if (_active)
				{
					if (Mathf.Approximately(_scale, scale))
					{
						_timer = duration;
						_failsafeTimer = duration + 5f;
						_effectId = effectId;
						RefreshLocalFeelTimers();
						return;
					}
					RevertLocal();
				}
				CacheTargets();
				_active = true;
				_scale = scale;
				_effectId = effectId;
				_timer = duration;
				_failsafeTimer = duration + 5f;
				if ((Object)(object)_collision != (Object)null)
				{
					_collisionOriginalScale = _collision.Scale;
					_collisionShrunkScale = _collisionOriginalScale * scale;
				}
				if ((Object)(object)_visual != (Object)null)
				{
					_visualOriginalScale = _visual.localScale;
					_visual.localScale = _visualOriginalScale * scale;
				}
				ApplyLocalFeel();
			}
			catch (Exception exception)
			{
				Log.Error("[Shrinkinator] Ошибка уменьшения игрока", exception);
			}
		}

		[PunRPC]
		private void RPC_Expand(int effectId)
		{
			if (_active && effectId == _effectId)
			{
				RevertLocal();
			}
		}

		private void CacheTargets()
		{
			_collision = null;
			_visual = null;
			PlayerAvatar component = ((Component)this).GetComponent<PlayerAvatar>();
			if ((Object)(object)component == (Object)null)
			{
				return;
			}
			PlayerAvatarCollision[] array = Object.FindObjectsOfType<PlayerAvatarCollision>();
			foreach (PlayerAvatarCollision val in array)
			{
				if ((Object)(object)val != (Object)null && (Object)(object)val.PlayerAvatar == (Object)(object)component)
				{
					_collision = val;
					break;
				}
			}
			if ((Object)(object)component.playerAvatarVisuals != (Object)null && (Object)(object)component.playerAvatarVisuals.meshParent != (Object)null)
			{
				_visual = component.playerAvatarVisuals.meshParent.transform;
			}
		}

		private void Update()
		{
			if (!_active)
			{
				return;
			}
			PlayerAvatar component = ((Component)this).GetComponent<PlayerAvatar>();
			if ((Object)(object)component == (Object)null || component.isDisabled)
			{
				RevertLocal();
				return;
			}
			float deltaTime = Time.deltaTime;
			_failsafeTimer -= deltaTime;
			if (SemiFunc.IsMasterClientOrSingleplayer())
			{
				_timer -= deltaTime;
				if (_timer <= 0f)
				{
					int effectId = _effectId;
					ShrinkRpc.SendToAll(((Object)(object)component.photonView != (Object)null) ? component.photonView : ((Component)this).GetComponent<PhotonView>(), "RPC_Expand", delegate
					{
						RPC_Expand(effectId);
					}, effectId);
				}
			}
			if (_failsafeTimer <= 0f)
			{
				RevertLocal();
			}
		}

		private void LateUpdate()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			if (_active)
			{
				if ((Object)(object)_visual != (Object)null)
				{
					_visual.localScale = _visualOriginalScale * _scale;
				}
				if (!IsLocalAvatar())
				{
					ReinforceCollisionScale();
				}
				ReinforceLocalFeel();
			}
		}

		private void ReinforceCollisionScale()
		{
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0040: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)_collision == (Object)null)
			{
				return;
			}
			try
			{
				_collision.Scale = _collisionShrunkScale;
				if ((Object)(object)_collision.CollisionTransform != (Object)null)
				{
					_collision.CollisionTransform.localScale = _collisionShrunkScale;
				}
			}
			catch (Exception ex)
			{
				if (!_warnedCollisionScale)
				{
					_warnedCollisionScale = true;
					Log.Warning("[Shrinkinator] Не удалось подкрепить масштаб коллизии игрока (дальше предупреждения подавляются): " + ex.Message);
				}
			}
		}

		private bool IsLocalAvatar()
		{
			PlayerAvatar component = ((Component)this).GetComponent<PlayerAvatar>();
			if ((Object)(object)component != (Object)null)
			{
				return component.isLocal;
			}
			return false;
		}

		private void ApplyLocalFeel()
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: 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_014d: 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)
			if (_localFeel || !IsLocalAvatar())
			{
				return;
			}
			try
			{
				if ((Object)(object)CameraPosition.instance != (Object)null)
				{
					_camOffsetOriginal = CameraPosition.instance.playerOffset;
				}
				if ((Object)(object)CameraCrouchPosition.instance != (Object)null)
				{
					_crouchPosOriginal = CameraCrouchPosition.instance.Position;
				}
				if ((Object)(object)CameraCrawlPosition.instance != (Object)null)
				{
					_crawlPosOriginal = CameraCrawlPosition.instance.Position;
				}
				PlayerAvatar component = ((Component)this).GetComponent<PlayerAvatar>();
				_vision = (((Object)(object)component != (Object)null) ? component.PlayerVisionTarget : null);
				if ((Object)(object)_vision != (Object)null)
				{
					_visionStandOriginal = _vision.StandPosition;
					_visionCrouchOriginal = _vision.CrouchPosition;
					_visionCrawlOriginal = _vision.CrawlPosition;
					_visionHeadStandOriginal = _vision.HeadStandPosition;
					_visionHeadCrouchOriginal = _vision.HeadCrouchPosition;
					_visionHeadCrawlOriginal = _vision.HeadCrawlPosition;
				}
				if ((Object)(object)PlayerCollision.instance != (Object)null)
				{
					if ((Object)(object)PlayerCollision.instance.StandCollision != (Object)null)
					{
						_standCollisionOriginal = PlayerCollision.instance.StandCollision.localScale;
					}
					if ((Object)(object)PlayerCollision.instance.CrouchCollision != (Object)null)
					{
						_crouchCollisionOriginal = PlayerCollision.instance.CrouchCollision.localScale;
					}
				}
				if ((Object)(object)PlayerCollisionStand.instance != (Object)null)
				{
					_standCheckCollider = ((Component)PlayerCollisionStand.instance).GetComponent<CapsuleCollider>();
					if ((Object)(object)_standCheckCollider != (Object)null)
					{
						_standCheckHeightOriginal = _standCheckCollider.height;
						_standCheckRadiusOriginal = _standCheckCollider.radius;
					}
					_standCheckOffsetOriginal = PlayerCollisionStand.instance.Offset;
				}
				if ((Object)(object)CameraZoom.Instance != (Object)null)
				{
					_fovOriginal = CameraZoom.Instance.playerZoomDefault;
				}
				if ((Object)(object)AssetManager.instance != (Object)null && (Object)(object)AssetManager.instance.mainCamera != (Object)null)
				{
					_nearClipOriginal = AssetManager.instance.mainCamera.nearClipPlane;
					_hasNearClip = true;
				}
				PhysGrabber instance = PhysGrabber.instance;
				if ((Object)(object)instance != (Object)null)
				{
					_grabMinOriginal = instance.minDistanceFromPlayer;
					_grabMaxOriginal = instance.maxDistanceFromPlayer;
					_grabMinOriginalOriginal = instance.minDistanceFromPlayerOriginal;
					_grabRangeOriginal = instance.grabRange;
					_hasGrabDistances = true;
				}
				_speedMult = Mathf.Lerp(1f, _scale, 0.5f);
				_localFeel = true;
				if (_hasNearClip && (Object)(object)AssetManager.instance != (Object)null && (Object)(object)AssetManager.instance.mainCamera != (Object)null)
				{
					AssetManager.instance.mainCamera.nearClipPlane = Mathf.Max(0.01f, _nearClipOriginal * _scale * 0.5f);
				}
				if ((Object)(object)CameraZoom.Instance != (Object)null)
				{
					CameraZoom.Instance.playerZoomDefault = _fovOriginal + 20f * (1f - _scale);
				}
				ReinforceLocalFeel();
				RefreshLocalFeelTimers();
			}
			catch (Exception exception)
			{
				Log.Error("[Shrinkinator] Ошибка локальной камеры/хитбокса игрока", exception);
			}
		}

		private void RefreshLocalFeelTimers()
		{
			if (!_localFeel)
			{
				return;
			}
			try
			{
				if ((Object)(object)CameraZoom.Instance != (Object)null)
				{
					float playerZoomDefault = CameraZoom.Instance.playerZoomDefault;
					CameraZoom.Instance.OverrideZoomSet(playerZoomDefault, 9999f, 3f, 3f, ((Component)this).gameObject, 999);
				}
				if ((Object)(object)PlayerController.instance != (Object)null)
				{
					PlayerController.instance.OverrideSpeed(_speedMult, 9999f);
				}
			}
			catch (Exception ex)
			{
				Log.Warning("[Shrinkinator] Не удалось продлить локальный эффект уменьшения: " + ex.Message);
			}
		}

		private void ReinforceLocalFeel()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0145: 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)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			if (!_localFeel)
			{
				return;
			}
			try
			{
				if ((Object)(object)CameraPosition.instance != (Object)null)
				{
					CameraPosition.instance.playerOffset = _camOffsetOriginal * _scale;
				}
				if ((Object)(object)CameraCrouchPosition.instance != (Object)null)
				{
					CameraCrouchPosition.instance.Position = _crouchPosOriginal * _scale;
				}
				if ((Object)(object)CameraCrawlPosition.instance != (Object)null)
				{
					CameraCrawlPosition.instance.Position = _crawlPosOriginal * _scale;
				}
				if ((Object)(object)_vision != (Object)null)
				{
					_vision.StandPosition = _visionStandOriginal * _scale;
					_vision.CrouchPosition = _visionCrouchOriginal * _scale;
					_vision.CrawlPosition = _visionCrawlOriginal * _scale;
					_vision.HeadStandPosition = _visionHeadStandOriginal * _scale;
					_vision.HeadCrouchPosition = _visionHeadCrouchOriginal * _scale;
					_vision.HeadCrawlPosition = _visionHeadCrawlOriginal * _scale;
				}
				if ((Object)(object)PlayerCollision.instance != (Object)null)
				{
					if ((Object)(object)PlayerCollision.instance.StandCollision != (Object)null)
					{
						PlayerCollision.instance.StandCollision.localScale = _standCollisionOriginal * _scale;
					}
					if ((Object)(object)PlayerCollision.instance.CrouchCollision != (Object)null)
					{
						PlayerCollision.instance.CrouchCollision.localScale = _crouchCollisionOriginal * _scale;
					}
				}
				if ((Object)(object)_standCheckCollider != (Object)null)
				{
					_standCheckCollider.height = _standCheckHeightOriginal * _scale;
					_standCheckCollider.radius = _standCheckRadiusOriginal * _scale;
				}
				if ((Object)(object)PlayerCollisionStand.instance != (Object)null)
				{
					PlayerCollisionStand.instance.Offset = _standCheckOffsetOriginal * _scale;
				}
				if (_hasGrabDistances && (Object)(object)PhysGrabber.instance != (Object)null)
				{
					PhysGrabber.instance.minDistanceFromPlayer = _grabMinOriginal * _scale;
					PhysGrabber.instance.maxDistanceFromPlayer = _grabMaxOriginal * _scale;
					PhysGrabber.instance.minDistanceFromPlayerOriginal = _grabMinOriginalOriginal * _scale;
					PhysGrabber.instance.grabRange = _grabRangeOriginal * _scale;
				}
			}
			catch (Exception ex)
			{
				Log.Warning("[Shrinkinator] Не удалось подкрепить локальный эффект уменьшения: " + ex.Message);
			}
		}

		private void RestoreLocalFeel()
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0173: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			if (!_localFeel)
			{
				return;
			}
			try
			{
				if ((Object)(object)CameraPosition.instance != (Object)null)
				{
					CameraPosition.instance.playerOffset = _camOffsetOriginal;
				}
				if ((Object)(object)CameraCrouchPosition.instance != (Object)null)
				{
					CameraCrouchPosition.instance.Position = _crouchPosOriginal;
				}
				if ((Object)(object)CameraCrawlPosition.instance != (Object)null)
				{
					CameraCrawlPosition.instance.Position = _crawlPosOriginal;
				}
				if ((Object)(object)_vision != (Object)null)
				{
					_vision.StandPosition = _visionStandOriginal;
					_vision.CrouchPosition = _visionCrouchOriginal;
					_vision.CrawlPosition = _visionCrawlOriginal;
					_vision.HeadStandPosition = _visionHeadStandOriginal;
					_vision.HeadCrouchPosition = _visionHeadCrouchOriginal;
					_vision.HeadCrawlPosition = _visionHeadCrawlOriginal;
				}
				if ((Object)(object)PlayerCollision.instance != (Object)null)
				{
					if ((Object)(object)PlayerCollision.instance.StandCollision != (Object)null)
					{
						PlayerCollision.instance.StandCollision.localScale = _standCollisionOriginal;
					}
					if ((Object)(object)PlayerCollision.instance.CrouchCollision != (Object)null)
					{
						PlayerCollision.instance.CrouchCollision.localScale = _crouchCollisionOriginal;
					}
				}
				if ((Object)(object)_standCheckCollider != (Object)null)
				{
					_standCheckCollider.height = _standCheckHeightOriginal;
					_standCheckCollider.radius = _standCheckRadiusOriginal;
				}
				if ((Object)(object)PlayerCollisionStand.instance != (Object)null)
				{
					PlayerCollisionStand.instance.Offset = _standCheckOffsetOriginal;
				}
				if ((Object)(object)CameraZoom.Instance != (Object)null)
				{
					CameraZoom.Instance.playerZoomDefault = _fovOriginal;
					CameraZoom.Instance.OverrideZoomSet(_fovOriginal, 0.5f, 3f, 3f, ((Component)this).gameObject, 999);
				}
				if (_hasNearClip && (Object)(object)AssetManager.instance != (Object)null && (Object)(object)AssetManager.instance.mainCamera != (Object)null)
				{
					AssetManager.instance.mainCamera.nearClipPlane = _nearClipOriginal;
				}
				if (_hasGrabDistances && (Object)(object)PhysGrabber.instance != (Object)null)
				{
					PhysGrabber.instance.minDistanceFromPlayer = _grabMinOriginal;
					PhysGrabber.instance.maxDistanceFromPlayer = _grabMaxOriginal;
					PhysGrabber.instance.minDistanceFromPlayerOriginal = _grabMinOriginalOriginal;
					PhysGrabber.instance.grabRange = _grabRangeOriginal;
				}
				if ((Object)(object)PlayerController.instance != (Object)null)
				{
					PlayerController.instance.OverrideSpeed(1f, 0.1f);
				}
			}
			catch (Exception exception)
			{
				Log.Error("[Shrinkinator] Ошибка возврата камеры/хитбокса игрока", exception);
			}
			finally
			{
				_localFeel = false;
				_vision = null;
				_standCheckCollider = null;
				_hasNearClip = false;
				_hasGrabDistances = false;
			}
		}

		private void RevertLocal()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			try
			{
				RestoreLocalFeel();
				if ((Object)(object)_collision != (Object)null)
				{
					_collision.Scale = _collisionOriginalScale;
					if ((Object)(object)_collision.CollisionTransform != (Object)null)
					{
						_collision.CollisionTransform.localScale = _collisionOriginalScale;
					}
				}
				if ((Object)(object)_visual != (Object)null)
				{
					_visual.localScale = _visualOriginalScale;
				}
			}
			catch (Exception exception)
			{
				Log.Error("[Shrinkinator] Ошибка возврата размера игрока", exception);
			}
			finally
			{
				_active = false;
				_collision = null;
				_visual = null;
				_warnedCollisionScale = false;
			}
		}

		private void OnDisable()
		{
			if (_active)
			{
				RevertLocal();
			}
		}
	}
	internal static class ShrinkinatorModelBuilder
	{
		internal const string VisualRootName = "ShrinkinatorVisual";

		private const float BaseLength = 0.4f;

		internal static readonly Vector3 GripOffsetBase = new Vector3(0f, -0.058f, 0.045f);

		private static Material _metalMaterial;

		private static Material _greenMaterial;

		private static readonly Color MetalColor = new Color(0.16f, 0.17f, 0.19f);

		private static readonly Color GreenColor = new Color(0.2f, 1f, 0.35f);

		private static readonly string[] ExcludedNameFragments = new string[8] { "muzzle", "flash", "bullet", "shell", "casing", "sound", "laser", "beam" };

		internal static bool Apply(GameObject clone, ItemGun gun, out Vector3 gripLocalPosition)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			gripLocalPosition = Vector3.zero;
			if ((Object)(object)clone == (Object)null || (Object)(object)gun == (Object)null)
			{
				return false;
			}
			List<Renderer> visualRenderers = null;
			GameObject visualRoot = null;
			try
			{
				return ApplyInternal(clone, gun, out gripLocalPosition, out visualRenderers, out visualRoot);
			}
			catch (Exception ex)
			{
				RollbackToVanilla(visualRenderers, visualRoot);
				Log.Warning("[Shrinkinator] Не удалось построить кастомную модель, откат к ванильному визуалу: " + ex);
				return false;
			}
		}

		private static void RollbackToVanilla(List<Renderer> visualRenderers, GameObject visualRoot)
		{
			if ((Object)(object)visualRoot != (Object)null)
			{
				Object.Destroy((Object)(object)visualRoot);
			}
			if (visualRenderers == null)
			{
				return;
			}
			foreach (Renderer visualRenderer in visualRenderers)
			{
				if ((Object)(object)visualRenderer != (Object)null)
				{
					visualRenderer.enabled = true;
				}
			}
		}

		private static bool ApplyInternal(GameObject clone, ItemGun gun, out Vector3 gripLocalPosition, out List<Renderer> visualRenderers, out GameObject visualRoot)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: 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_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: 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_0107: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0111: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Unknown result type (might be due to invalid IL or missing references)
			//IL_0127: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Expected O, but got Unknown
			//IL_01b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c4: 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_01d6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0208: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0214: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_021a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0232: Unknown result type (might be due to invalid IL or missing references)
			//IL_0234: Unknown result type (might be due to invalid IL or missing references)
			//IL_0245: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0250: Unknown result type (might be due to invalid IL or missing references)
			//IL_0255: Unknown result type (might be due to invalid IL or missing references)
			//IL_025a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0268: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0280: Unknown result type (might be due to invalid IL or missing references)
			//IL_0281: Unknown result type (might be due to invalid IL or missing references)
			//IL_028c: Unknown result type (might be due to invalid IL or missing references)
			//IL_028d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0292: Unknown result type (might be due to invalid IL or missing references)
			gripLocalPosition = Vector3.zero;
			visualRenderers = null;
			visualRoot = null;
			if ((Object)(object)gun.gunMuzzle == (Object)null)
			{
				Log.Warning("[Shrinkinator] У клона нет gunMuzzle — кастомную модель не строим.");
				return false;
			}
			visualRenderers = CollectVisualRenderers(clone, gun);
			if (visualRenderers.Count == 0)
			{
				Log.Warning("[Shrinkinator] На клоне не найдено визуальных MeshRenderer/SkinnedMeshRenderer — модель не строим (иерархия изменилась?).");
				return false;
			}
			Vector3 val = clone.transform.InverseTransformPoint(gun.gunMuzzle.position);
			Vector3 val2 = clone.transform.InverseTransformDirection(gun.gunMuzzle.forward);
			if (((Vector3)(ref val2)).sqrMagnitude < 1E-08f)
			{
				val2 = Vector3.forward;
			}
			((Vector3)(ref val2)).Normalize();
			Vector3 val3 = clone.transform.InverseTransformDirection(gun.gunMuzzle.up);
			if (((Vector3)(ref val3)).sqrMagnitude < 1E-08f || Vector3.Dot(((Vector3)(ref val3)).normalized, val2) > 0.95f)
			{
				val3 = Vector3.up;
			}
			Vector3 val4 = val3 - val2 * Vector3.Dot(val3, val2);
			val3 = ((Vector3)(ref val4)).normalized;
			float num = MeasureLengthAlongAxis(clone.transform, visualRenderers, val2);
			float num2 = num / 0.4f;
			Vector3 val5 = val - val2 * num;
			Quaternion val6 = Quaternion.LookRotation(val2, val3);
			gripLocalPosition = val5 + val6 * (GripOffsetBase * num2);
			foreach (Renderer visualRenderer in visualRenderers)
			{
				if ((Object)(object)visualRenderer != (Object)null)
				{
					visualRenderer.enabled = false;
				}
			}
			EnsureMaterials(visualRenderers);
			GameObject val7 = (visualRoot = new GameObject("ShrinkinatorVisual"));
			val7.layer = clone.layer;
			Transform transform = val7.transform;
			transform.SetParent(clone.transform, false);
			transform.localPosition = val5;
			transform.localRotation = val6;
			transform.localScale = Vector3.one;
			BuildModel(transform, num2);
			Vector3 val8 = val5 + val2 * num;
			gun.gunMuzzle.position = clone.transform.TransformPoint(val8);
			gun.gunMuzzle.rotation = Quaternion.LookRotation(clone.transform.TransformDirection(val2), clone.transform.TransformDirection(val3));
			if ((Object)(object)gun.gunTrigger != (Object)null)
			{
				Vector3 val9 = val5 + val6 * (new Vector3(0f, -0.03f, 0.078f) * num2);
				gun.gunTrigger.position = clone.transform.TransformPoint(val9);
				gun.gunTrigger.rotation = Quaternion.LookRotation(clone.transform.TransformDirection(val2), clone.transform.TransformDirection(val3));
			}
			Log.Info("[Shrinkinator] Кастомная модель \"ShrinkinatorVisual\" построена (длина " + num.ToString("0.00") + " м, скрыто renderer'ов: " + visualRenderers.Count + ").");
			return true;
		}

		private static List<Renderer> CollectVisualRenderers(GameObject clone, ItemGun gun)
		{
			List<Renderer> list = new List<Renderer>();
			Renderer[] componentsInChildren = clone.GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				if (!((Object)(object)val == (Object)null) && (val is MeshRenderer || val is SkinnedMeshRenderer) && !IsExcludedBranch(((Component)val).transform, gun))
				{
					list.Add(val);
				}
			}
			return list;
		}

		private static bool IsExcludedBranch(Transform transform, ItemGun gun)
		{
			Transform val = transform;
			while ((Object)(object)val != (Object)null)
			{
				if ((Object)(object)gun.muzzleFlashPrefab != (Object)null && (Object)(object)((Component)val).gameObject == (Object)(object)gun.muzzleFlashPrefab)
				{
					return true;
				}
				if ((Object)(object)gun.bulletPrefab != (Object)null && (Object)(object)((Component)val).gameObject == (Object)(object)gun.bulletPrefab)
				{
					return true;
				}
				string text = ((Object)val).name.ToLowerInvariant();
				string[] excludedNameFragments = ExcludedNameFragments;
				foreach (string value in excludedNameFragments)
				{
					if (text.Contains(value))
					{
						return true;
					}
				}
				val = val.parent;
			}
			return false;
		}

		private static float MeasureLengthAlongAxis(Transform root, List<Renderer> renderers, Vector3 axisLocal)
		{
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003b: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing reference