Decompiled source of MEDVAC Healer Drone v1.8.68

MEDVAC.HealerDrone.dll

Decompiled a month ago
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text;
using BepInEx;
using BepInEx.Configuration;
using BepInEx.Logging;
using ExitGames.Client.Photon;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine;
using UnityEngine.Rendering;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("MEDVAC.HealerDrone")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("MEDVAC.HealerDrone")]
[assembly: AssemblyTitle("MEDVAC.HealerDrone")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.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 MEDVAC.HealerDrone
{
	internal static class Compat
	{
		private static bool _patched;

		private static float _lastForce;

		private static float _lastKick;

		internal static void PatchAll(Harmony harmony)
		{
			if (harmony != null && !_patched)
			{
				_patched = true;
				Plugin.Log.LogInfo((object)"Compat ready (no extra Harmony on More Shop Items / other mods).");
			}
		}

		private static void PatchAssembly(Harmony harmony, string asmHint, params string[] methodHints)
		{
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Expected O, but got Unknown
			try
			{
				Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
				foreach (Assembly assembly in assemblies)
				{
					string text = "";
					try
					{
						text = assembly.GetName().Name ?? "";
					}
					catch (Exception)
					{
						continue;
					}
					if (text.IndexOf(asmHint, StringComparison.OrdinalIgnoreCase) < 0)
					{
						continue;
					}
					Type[] types = assembly.GetTypes();
					for (int j = 0; j < types.Length; j++)
					{
						MethodInfo[] methods = types[j].GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
						foreach (MethodInfo methodInfo in methods)
						{
							if (methodInfo.IsAbstract || methodInfo.ContainsGenericParameters)
							{
								continue;
							}
							bool flag = false;
							foreach (string value in methodHints)
							{
								if (methodInfo.Name.IndexOf(value, StringComparison.OrdinalIgnoreCase) >= 0)
								{
									flag = true;
									break;
								}
							}
							if (flag)
							{
								try
								{
									harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(Compat), "AfterOtherMod", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
								}
								catch (Exception)
								{
								}
							}
						}
					}
				}
			}
			catch (Exception ex3)
			{
				Plugin.Log.LogDebug((object)("Compat " + asmHint + " skipped: " + ex3.Message));
			}
		}

		private static void AfterOtherMod()
		{
			ShopRegistry.ClampShopCaps();
		}
	}
	internal static class MedkitTable
	{
		internal static readonly int[] Packs;

		internal static int BestPackForRoom(int room)
		{
			if (room <= 0)
			{
				return 0;
			}
			int num = 0;
			for (int i = 0; i < Packs.Length; i++)
			{
				int num2 = Packs[i];
				if (num2 <= room && num2 > num)
				{
					num = num2;
				}
			}
			return num;
		}

		internal static bool CanSip(int tankHp, int tankMax, int packHp)
		{
			if (packHp <= 0 || tankMax <= 0)
			{
				return false;
			}
			int num = tankMax - tankHp;
			if (num <= 0)
			{
				return false;
			}
			return packHp <= num;
		}

		internal static bool IsPreferredPack(int tankHp, int tankMax, int packHp)
		{
			if (!CanSip(tankHp, tankMax, packHp))
			{
				return false;
			}
			return packHp == BestPackForRoom(tankMax - tankHp);
		}

		internal static int Give(int tankHp, int tankMax, int packHp)
		{
			if (!CanSip(tankHp, tankMax, packHp))
			{
				return 0;
			}
			return packHp;
		}

		internal static string BuildTableMarkdown()
		{
			StringBuilder stringBuilder = new StringBuilder();
			stringBuilder.AppendLine("# MEDVAC refill table (1.8.35)");
			stringBuilder.AppendLine();
			stringBuilder.AppendLine("Rule: auto-sip **ground** packs only. Never held/used by player.");
			stringBuilder.AppendLine("Pick the **largest** pack that fits wholly into free room (`pack <= room`).");
			stringBuilder.AppendLine("No ≤40% gate. No waste allowance (never eat a 100 into a 75 hole).");
			stringBuilder.AppendLine();
			stringBuilder.AppendLine("Packs: **25 / 50 / 100** HP.");
			stringBuilder.AppendLine();
			Tier[] tiers = Plugin.Tiers;
			foreach (Tier tier in tiers)
			{
				int tankHp = tier.TankHp;
				stringBuilder.Append("## ").Append(tier.Name).Append(" (tank ")
					.Append(tankHp)
					.Append(" HP)")
					.AppendLine();
				stringBuilder.AppendLine();
				stringBuilder.AppendLine("| tank now | room | takes | after |");
				stringBuilder.AppendLine("|---------:|-----:|------:|------:|");
				int[] obj = new int[12]
				{
					0, 10, 25, 40, 50, 75, 90, 100, 0, 0,
					0, 0
				};
				obj[8] = tankHp - 25;
				obj[9] = tankHp - 50;
				obj[10] = tankHp - 100;
				obj[11] = tankHp;
				int[] array = obj;
				HashSet<int> hashSet = new HashSet<int>();
				for (int j = 0; j < array.Length; j++)
				{
					int num = Mathf.Clamp(array[j], 0, tankHp);
					if (hashSet.Add(num))
					{
						int num2 = tankHp - num;
						int num3 = BestPackForRoom(num2);
						if (num3 <= 0)
						{
							stringBuilder.Append("| ").Append(num).Append('/')
								.Append(tankHp)
								.Append(" | ")
								.Append(num2)
								.Append(" | — | wait |")
								.AppendLine();
						}
						else
						{
							stringBuilder.Append("| ").Append(num).Append('/')
								.Append(tankHp)
								.Append(" | ")
								.Append(num2)
								.Append(" | ")
								.Append(num3)
								.Append(" | ")
								.Append(num + num3)
								.Append('/')
								.Append(tankHp)
								.Append(" |")
								.AppendLine();
						}
					}
				}
				stringBuilder.AppendLine();
				stringBuilder.AppendLine("Room bands:");
				stringBuilder.AppendLine("- room **1–24**: wait (no pack fits)");
				stringBuilder.AppendLine("- room **25–49**: take **25**");
				stringBuilder.AppendLine("- room **50–99**: take **50** (not 100)");
				stringBuilder.AppendLine("- room **100+**: take **100**");
				stringBuilder.AppendLine();
			}
			stringBuilder.AppendLine("Example (your case): MV-150 at **75/150** (room 75) → takes **50** → **125/150**. Does **not** take 100.");
			return stringBuilder.ToString();
		}

		internal static void LogOnce()
		{
			string text = BuildTableMarkdown();
			Plugin.Log.LogInfo((object)text.Replace("\r", ""));
			try
			{
				string text2 = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Personal), "MEDVAC");
				Directory.CreateDirectory(text2);
				File.WriteAllText(Path.Combine(text2, "REFILL-TABLE.md"), text);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("MEDVAC could not write REFILL-TABLE.md: " + ex.Message));
			}
		}

		static MedkitTable()
		{
			Packs = new int[3] { 25, 50, 100 };
		}
	}
	internal static class MedvacIcon
	{
		private static Sprite _sprite;

		private static Texture2D _tex;

		internal static Sprite Sprite
		{
			get
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Expected O, but got Unknown
				if ((Object)_sprite == (Object)null)
				{
					Build();
				}
				return _sprite;
			}
		}

		internal static Texture2D Texture
		{
			get
			{
				//IL_0005: Unknown result type (might be due to invalid IL or missing references)
				//IL_0010: Expected O, but got Unknown
				if ((Object)_tex == (Object)null)
				{
					Build();
				}
				return _tex;
			}
		}

		private static void Build()
		{
			//IL_0004: Unknown result type (might be due to invalid IL or missing references)
			//IL_000e: Expected O, but got Unknown
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c1: Unknown result type (might be due to invalid IL or missing references)
			_tex = new Texture2D(2, 2, (TextureFormat)4, false);
			((Texture)_tex).filterMode = (FilterMode)1;
			((Texture)_tex).wrapMode = (TextureWrapMode)1;
			byte[] array = null;
			using (Stream stream = Assembly.GetExecutingAssembly().GetManifestResourceStream("MEDVAC.icon.png"))
			{
				if (stream != null)
				{
					using MemoryStream memoryStream = new MemoryStream();
					stream.CopyTo(memoryStream);
					array = memoryStream.ToArray();
				}
			}
			if (array != null && array.Length != 0)
			{
				ImageConversion.LoadImage(_tex, array, false);
			}
			((Object)_tex).name = "MEDVAC Icon";
			_sprite = Sprite.Create(_tex, new Rect(0f, 0f, (float)((Texture)_tex).width, (float)((Texture)_tex).height), new Vector2(0.5f, 0.5f), 100f);
			((Object)_sprite).name = "MEDVAC Icon";
		}
	}
	internal static class MedvacNet
	{
		internal const byte ConvertEvent = 183;

		internal const byte TankEvent = 184;

		private static bool _hooked;

		private static bool _subscribed;

		private static float _roomStable;

		private static float _adoptTimer;

		private static float _tankTimer;

		internal static void Hook()
		{
			if (!_hooked)
			{
				_hooked = true;
				Plugin.Log.LogInfo((object)"MedvacNet 1.8.44: delayed EventReceived + poll-adopt (no InstantiationData).");
			}
		}

		internal static void Tick()
		{
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Expected O, but got Unknown
			//IL_00c7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Expected O, but got Unknown
			try
			{
				if (!IsMultiplayer())
				{
					_roomStable = 0f;
					_adoptTimer = 0f;
					_tankTimer = 0f;
					return;
				}
				_roomStable += Time.unscaledDeltaTime;
				if (!_subscribed && _roomStable >= 1.25f)
				{
					SubscribeEvents();
				}
				_adoptTimer += Time.unscaledDeltaTime;
				if (_adoptTimer >= 0.4f)
				{
					_adoptTimer = 0f;
					ShopRegistry.AdoptNetworkedHealers();
				}
				if (!IsMaster())
				{
					return;
				}
				_tankTimer += Time.unscaledDeltaTime;
				if (!(_tankTimer >= 2f))
				{
					return;
				}
				_tankTimer = 0f;
				MedvacRuntime[] array = Object.FindObjectsOfType<MedvacRuntime>();
				foreach (MedvacRuntime medvacRuntime in array)
				{
					if (!((Object)medvacRuntime == (Object)null) && !ShopRegistry.IsTemplate((Component)medvacRuntime))
					{
						BroadcastTank(medvacRuntime);
					}
				}
			}
			catch (Exception)
			{
			}
		}

		private static void SubscribeEvents()
		{
			if (_subscribed)
			{
				return;
			}
			try
			{
				object networkingClient = PhotonNetwork.NetworkingClient;
				if (networkingClient != null)
				{
					EventInfo eventInfo = networkingClient.GetType().GetEvent("EventReceived", BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);
					if (eventInfo == null)
					{
						Plugin.Log.LogDebug((object)"MedvacNet: EventReceived event not found.");
						return;
					}
					Delegate handler = Delegate.CreateDelegate(eventInfo.EventHandlerType, typeof(MedvacNet), "OnEvent");
					eventInfo.AddEventHandler(networkingClient, handler);
					_subscribed = true;
					Plugin.Log.LogInfo((object)"MedvacNet EventReceived subscribed (delayed, in-room).");
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogDebug((object)("MedvacNet subscribe: " + ex.Message));
			}
		}

		internal static bool IsMultiplayer()
		{
			try
			{
				return SemiFunc.IsMultiplayer() && PhotonNetwork.InRoom;
			}
			catch (Exception)
			{
				return PhotonNetwork.InRoom;
			}
		}

		internal static bool IsMaster()
		{
			try
			{
				return SemiFunc.IsMasterClientOrSingleplayer();
			}
			catch (Exception)
			{
				try
				{
					if (!IsMultiplayer())
					{
						return true;
					}
					return PhotonNetwork.IsMasterClient;
				}
				catch (Exception)
				{
					return true;
				}
			}
		}

		internal static GameObject Spawn(Item item, Vector3 pos, Quaternion rot)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Expected O, but got Unknown
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Expected O, but got Unknown
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Expected O, but got Unknown
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b1: Expected O, but got Unknown
			if ((Object)item == (Object)null)
			{
				return null;
			}
			GameObject val = null;
			if (IsMultiplayer() && IsMaster())
			{
				string text = (string.IsNullOrEmpty(((Object)item).name) ? null : ("Items/" + ((Object)item).name));
				string[] array = new string[6]
				{
					text,
					ShopRegistry.VanillaPhotonId,
					"Items/Item Drone Feather",
					"Items/Item Drone Heal",
					"Items/Item Drone Battery",
					"Items/Item Drone Indestructible"
				};
				foreach (string text2 in array)
				{
					if (string.IsNullOrEmpty(text2))
					{
						continue;
					}
					try
					{
						if (PhotonNetwork.InRoom)
						{
							val = PhotonNetwork.InstantiateRoomObject(text2, pos, rot, (byte)0, (object[])null);
							if (!((Object)val != (Object)null))
							{
								continue;
							}
						}
					}
					catch (Exception ex)
					{
						Plugin.Log.LogDebug((object)("Photon " + text2 + ": " + ex.Message));
						continue;
					}
					break;
				}
			}
			if ((Object)val == (Object)null && (!IsMultiplayer() || IsMaster()))
			{
				GameObject val2 = ShopRegistry.Alive(ShopRegistry.GetTemplate(item)) ?? ShopRegistry.Alive(ShopRegistry.VanillaPrefab);
				if ((Object)val2 != (Object)null)
				{
					val = Object.Instantiate<GameObject>(val2, pos, rot);
				}
			}
			if ((Object)val == (Object)null)
			{
				return null;
			}
			val.SetActive(true);
			ShopRegistry.ConvertToHealer(val, item);
			BroadcastConvert(val, item);
			return val;
		}

		internal static void BroadcastConvert(GameObject go, Item item)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			//IL_001a: Expected O, but got Unknown
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Expected O, but got Unknown
			//IL_008a: 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_0091: Unknown result type (might be due to invalid IL or missing references)
			//IL_0096: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009e: Expected O, but got Unknown
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)go == (Object)null || (Object)item == (Object)null || !IsMultiplayer() || !IsMaster())
			{
				return;
			}
			PhotonView val = go.GetComponent<PhotonView>() ?? go.GetComponentInChildren<PhotonView>();
			if ((Object)val == (Object)null)
			{
				return;
			}
			try
			{
				object[] array = new object[3]
				{
					val.ViewID,
					item.itemName ?? "",
					((Object)item).name ?? ""
				};
				RaiseEventOptions val2 = new RaiseEventOptions
				{
					Receivers = (ReceiverGroup)0,
					CachingOption = (EventCaching)4
				};
				PhotonNetwork.RaiseEvent((byte)183, (object)array, val2, SendOptions.SendReliable);
			}
			catch (Exception ex)
			{
				Plugin.Log.LogDebug((object)("BroadcastConvert: " + ex.Message));
			}
		}

		internal static void BroadcastTank(MedvacRuntime rt)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_003a: Expected O, but got Unknown
			//IL_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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)
			//IL_007f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0089: Expected O, but got Unknown
			if ((Object)rt == (Object)null || !IsMultiplayer() || !IsMaster())
			{
				return;
			}
			PhotonView val = ((Component)rt).GetComponent<PhotonView>() ?? ((Component)rt).GetComponentInChildren<PhotonView>();
			if ((Object)val == (Object)null)
			{
				return;
			}
			try
			{
				PhotonNetwork.RaiseEvent((byte)184, (object)new object[3] { val.ViewID, rt.tankHp, rt.tankMax }, new RaiseEventOptions
				{
					Receivers = (ReceiverGroup)0
				}, SendOptions.SendReliable);
			}
			catch (Exception)
			{
			}
		}

		private static void OnEvent(EventData e)
		{
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0101: Expected O, but got Unknown
			//IL_0119: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Expected O, but got Unknown
			//IL_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Expected O, but got Unknown
			try
			{
				if (e.Code == 183)
				{
					if (e.CustomData is object[] array && array.Length >= 3)
					{
						int viewId = Convert.ToInt32(array[0]);
						object obj = array[1];
						string itemName = (string)(((obj is string) ? obj : null) ?? "");
						object obj2 = array[2];
						string assetName = (string)(((obj2 is string) ? obj2 : null) ?? "");
						if ((Object)Plugin.Instance != (Object)null)
						{
							((MonoBehaviour)Plugin.Instance).StartCoroutine(ApplyConvert(viewId, itemName, assetName));
						}
					}
				}
				else
				{
					if (e.Code != 184 || !(e.CustomData is object[] array2) || array2.Length < 3)
					{
						return;
					}
					int num = Convert.ToInt32(array2[0]);
					int tankHp = Convert.ToInt32(array2[1]);
					int tankMax = Convert.ToInt32(array2[2]);
					PhotonView val = PhotonView.Find(num);
					if (!((Object)val == (Object)null))
					{
						MedvacRuntime medvacRuntime = ((Component)val).GetComponent<MedvacRuntime>() ?? ((Component)val).GetComponentInChildren<MedvacRuntime>();
						if (!((Object)medvacRuntime == (Object)null))
						{
							medvacRuntime.tankHp = tankHp;
							medvacRuntime.tankMax = tankMax;
							medvacRuntime.SyncBattery();
						}
					}
				}
			}
			catch (Exception ex)
			{
				Plugin.Log.LogDebug((object)("MedvacNet event: " + ex.Message));
			}
		}

		private static IEnumerator ApplyConvert(int viewId, string itemName, string assetName)
		{
			for (int i = 0; i < 60; i++)
			{
				PhotonView val = PhotonView.Find(viewId);
				if ((Object)val != (Object)null)
				{
					Item val2 = ShopRegistry.FindMedvacItem(itemName, assetName);
					if ((Object)val2 != (Object)null)
					{
						ShopRegistry.ConvertToHealer(((Component)val).gameObject, val2);
					}
					yield break;
				}
				yield return (object)new WaitForSeconds(0.1f);
			}
			Plugin.Log.LogWarning((object)("Client never saw PhotonView " + viewId + " for " + itemName));
		}
	}
	public class MedvacVisual : MonoBehaviour
	{
		private const float S = 0.24f;

		private const float SpinIdle = 720f;

		private const float SpinFast = 2000f;

		private const float HealGlowSeconds = 0.35f;

		private static bool _loggedGrabSetup;

		private Transform[] _rotors;

		private Light _plusLight;

		private Transform _bob;

		private float _t;

		private MeshRenderer[] _pips;

		private Material _pipOn;

		private Material _pipOff;

		private Material _plusMat;

		private int _lastLit = -1;

		private float _healGlowUntil;

		private Vector3 _lastPos;

		private bool _haveLastPos;

		private float _spinSmooth;

		private MedvacRuntime _cachedRuntime;

		private Rigidbody _cachedRb;

		private void Start()
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			if (((Component)this).transform.position.y < -500f)
			{
				((Behaviour)this).enabled = false;
				return;
			}
			HideVanilla();
			Build();
			SetupGrabVolume();
		}

		internal void NotifyHeal()
		{
			_healGlowUntil = Time.time + 0.35f;
		}

		private void Update()
		{
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			//IL_0045: Unknown result type (might be due to invalid IL or missing references)
			//IL_0050: Expected O, but got Unknown
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Expected O, but got Unknown
			//IL_017e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Expected O, but got Unknown
			//IL_0123: Unknown result type (might be due to invalid IL or missing references)
			//IL_012e: Expected O, but got Unknown
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			float deltaTime = Time.deltaTime;
			_t += deltaTime;
			if ((Object)_cachedRuntime == (Object)null)
			{
				_cachedRuntime = ((Component)this).GetComponent<MedvacRuntime>() ?? ((Component)this).GetComponentInParent<MedvacRuntime>();
			}
			MedvacRuntime cachedRuntime = _cachedRuntime;
			bool flag = (Object)cachedRuntime != (Object)null && cachedRuntime.IsActivated();
			bool healing = Time.time <= _healGlowUntil;
			float num = EstimateHorizontalSpeed(deltaTime);
			float num2 = 0f;
			if (flag)
			{
				float num3 = Mathf.Clamp01(num / 1.55f);
				float num4 = 0f;
				if ((Object)cachedRuntime != (Object)null)
				{
					num4 = Mathf.Clamp01((cachedRuntime.LastPlayerDist - 3.2f) / 4.5f) * 0.45f;
				}
				num2 = Mathf.Lerp(720f, 2000f, Mathf.Clamp01(num3 + num4));
			}
			_spinSmooth = Mathf.Lerp(_spinSmooth, num2, 1f - Mathf.Exp(-8f * deltaTime));
			if (_rotors != null)
			{
				float num5 = _spinSmooth * deltaTime;
				for (int i = 0; i < _rotors.Length; i++)
				{
					if (!((Object)_rotors[i] == (Object)null))
					{
						_rotors[i].Rotate(0f, num5 * ((i % 2 == 0) ? 1f : (-1f)), 0f, (Space)1);
					}
				}
			}
			UpdatePlusGlow(flag, healing);
			if ((Object)_bob != (Object)null)
			{
				float num6 = (flag ? (Mathf.Sin(_t * 2.4f) * 0.014f) : 0f);
				_bob.localPosition = new Vector3(0f, num6, 0f);
			}
		}

		private float EstimateHorizontalSpeed(float dt)
		{
			//IL_000c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			//IL_006f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			//IL_00b3: 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_0085: 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_008c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: Unknown result type (might be due to invalid IL or missing references)
			float num = 0f;
			if ((Object)_cachedRb == (Object)null)
			{
				_cachedRb = ((Component)this).GetComponent<Rigidbody>() ?? ((Component)this).GetComponentInParent<Rigidbody>() ?? ((Component)this).GetComponentInChildren<Rigidbody>();
			}
			Rigidbody cachedRb = _cachedRb;
			if ((Object)cachedRb != (Object)null)
			{
				Vector3 velocity = cachedRb.velocity;
				velocity.y = 0f;
				num = ((Vector3)(ref velocity)).magnitude;
			}
			Vector3 position = ((Component)this).transform.position;
			if (_haveLastPos && dt > 1E-05f)
			{
				Vector3 val = position - _lastPos;
				val.y = 0f;
				float num2 = ((Vector3)(ref val)).magnitude / dt;
				if (num2 > num)
				{
					num = num2;
				}
			}
			_lastPos = position;
			_haveLastPos = true;
			return num;
		}

		private void UpdatePlusGlow(bool on, bool healing)
		{
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Expected O, but got Unknown
			//IL_006c: 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_00ba: Unknown result type (might be due to invalid IL or missing references)
			float emission = 0.55f;
			float intensity = 0.45f;
			if (healing)
			{
				emission = 2.4f + Mathf.Sin(_t * 14f) * 0.35f;
				intensity = 1.55f;
			}
			else if (on)
			{
				emission = 1.05f;
				intensity = 0.75f;
			}
			if ((Object)_plusMat != (Object)null)
			{
				SetEmission(_plusMat, new Color(0.05f, 1f, 0.28f), emission);
			}
			if ((Object)_plusLight != (Object)null)
			{
				((Behaviour)_plusLight).enabled = true;
				_plusLight.intensity = intensity;
				_plusLight.color = (healing ? new Color(0.25f, 1f, 0.45f) : new Color(0.35f, 1f, 0.55f));
			}
		}

		internal void RefreshPips()
		{
			UpdatePips();
		}

		private void UpdatePips()
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Expected O, but got Unknown
			//IL_0076: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Expected O, but got Unknown
			if (_pips == null)
			{
				return;
			}
			MedvacRuntime medvacRuntime = ((Component)this).GetComponent<MedvacRuntime>() ?? ((Component)this).GetComponentInParent<MedvacRuntime>();
			int num = Mathf.Clamp(Mathf.CeilToInt((((Object)medvacRuntime != (Object)null) ? medvacRuntime.Fill01 : 1f) * (float)_pips.Length - 0.001f), 0, _pips.Length);
			if (num == _lastLit)
			{
				return;
			}
			_lastLit = num;
			for (int i = 0; i < _pips.Length; i++)
			{
				if (!((Object)_pips[i] == (Object)null))
				{
					((Renderer)_pips[i]).sharedMaterial = ((i < num) ? _pipOn : _pipOff);
				}
			}
		}

		private void SetupGrabVolume()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0076: Expected O, but got Unknown
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Expected O, but got Unknown
			//IL_015e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0169: Expected O, but got Unknown
			//IL_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_0114: Expected O, but got Unknown
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Expected O, but got Unknown
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Expected O, but got Unknown
			//IL_01e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Expected O, but got Unknown
			Transform val = ((Component)this).transform.Find("MV_Grab");
			if ((Object)val != (Object)null)
			{
				Object.Destroy((Object)((Component)val).gameObject);
			}
			PhysGrabObject val2 = ((Component)this).GetComponent<PhysGrabObject>() ?? ((Component)this).GetComponentInParent<PhysGrabObject>();
			if ((Object)val2 != (Object)null)
			{
				val2.grabDisableTimer = 0f;
			}
			ItemAttributes val3 = ((Component)this).GetComponent<ItemAttributes>() ?? ((Component)this).GetComponentInParent<ItemAttributes>();
			if ((Object)val3 != (Object)null)
			{
				val3.disableUI = false;
			}
			int num = -1;
			PhysGrabObjectCollider[] componentsInChildren = ((Component)this).GetComponentsInChildren<PhysGrabObjectCollider>(true);
			PhysGrabObjectCollider[] array = componentsInChildren;
			foreach (PhysGrabObjectCollider val4 in array)
			{
				if (!((Object)val4 == (Object)null) && !(((Object)((Component)val4).gameObject).name == "MV_Grab"))
				{
					num = ((Component)val4).gameObject.layer;
					Enlarge(((Component)val4).gameObject, ((Component)this).transform);
				}
			}
			if (num < 0)
			{
				Collider[] componentsInChildren2 = ((Component)this).GetComponentsInChildren<Collider>(true);
				foreach (Collider val5 in componentsInChildren2)
				{
					if (!((Object)val5 == (Object)null) && !((Object)((Component)val5).gameObject).name.StartsWith("MV_") && ((Component)val5).gameObject.layer != 0)
					{
						num = ((Component)val5).gameObject.layer;
						break;
					}
				}
			}
			if (num < 0 && (Object)val2 != (Object)null)
			{
				num = ((Component)val2).gameObject.layer;
			}
			if (num < 0)
			{
				num = ((Component)this).gameObject.layer;
			}
			if (componentsInChildren.Length == 0 && (Object)val2 != (Object)null)
			{
				GameObject gameObject = ((Component)val2).gameObject;
				gameObject.layer = num;
				BoxCollider val6 = gameObject.GetComponent<BoxCollider>();
				if ((Object)val6 == (Object)null)
				{
					val6 = gameObject.AddComponent<BoxCollider>();
				}
				val6.size = new Vector3(0.52f, 0.48f, 0.52f);
				val6.center = new Vector3(0f, 0.04f, 0f);
				((Collider)val6).isTrigger = false;
				((Collider)val6).enabled = true;
				PhysGrabObjectCollider val7 = gameObject.GetComponent<PhysGrabObjectCollider>();
				if ((Object)val7 == (Object)null)
				{
					val7 = gameObject.AddComponent<PhysGrabObjectCollider>();
				}
				val7.colliderID = 1;
				FieldInfo fieldInfo = AccessTools.Field(typeof(PhysGrabObjectCollider), "physGrabObject");
				if (fieldInfo != null)
				{
					fieldInfo.SetValue(val7, val2);
				}
				if (val2.colliders != null && !val2.colliders.Contains(gameObject.transform))
				{
					val2.colliders.Add(gameObject.transform);
				}
			}
			if (!_loggedGrabSetup)
			{
				_loggedGrabSetup = true;
				ManualLogSource log = Plugin.Log;
				string text = num.ToString();
				int i = ((Component)this).GetComponentsInChildren<PhysGrabObjectCollider>(true).Length;
				log.LogInfo((object)("Grab setup: layer=" + text + " markers=" + i + " (once)"));
			}
		}

		private static void Enlarge(GameObject host, Transform root)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: 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_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_0077: 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_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c8: Expected O, but got Unknown
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			//IL_010b: Expected O, but got Unknown
			//IL_00ce: 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_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_0190: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Expected O, but got Unknown
			//IL_011f: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_013b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0222: Unknown result type (might be due to invalid IL or missing references)
			//IL_022d: Expected O, but got Unknown
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0212: Unknown result type (might be due to invalid IL or missing references)
			//IL_0231: Unknown result type (might be due to invalid IL or missing references)
			//IL_023c: Expected O, but got Unknown
			//IL_0240: Unknown result type (might be due to invalid IL or missing references)
			//IL_024b: Expected O, but got Unknown
			//IL_0254: Unknown result type (might be due to invalid IL or missing references)
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = default(Vector3);
			((Vector3)(ref val))..ctor(0.58f, 0.54f, 0.56f);
			Vector3 lossyScale = host.transform.lossyScale;
			Vector3 val2 = default(Vector3);
			((Vector3)(ref val2))..ctor(val.x / Mathf.Max(0.001f, Mathf.Abs(lossyScale.x)), val.y / Mathf.Max(0.001f, Mathf.Abs(lossyScale.y)), val.z / Mathf.Max(0.001f, Mathf.Abs(lossyScale.z)));
			Vector3 center = host.transform.InverseTransformPoint(root.TransformPoint(new Vector3(0f, 0.04f, 0f)));
			BoxCollider component = host.GetComponent<BoxCollider>();
			if ((Object)component != (Object)null)
			{
				component.size = Vector3.Max(component.size, val2);
				component.center = center;
				((Collider)component).enabled = true;
				((Collider)component).isTrigger = false;
			}
			SphereCollider component2 = host.GetComponent<SphereCollider>();
			if ((Object)component2 != (Object)null)
			{
				float num = 0.34f / Mathf.Max(0.001f, Mathf.Max(new float[3]
				{
					Mathf.Abs(lossyScale.x),
					Mathf.Abs(lossyScale.y),
					Mathf.Abs(lossyScale.z)
				}));
				component2.radius = Mathf.Max(component2.radius, num);
				component2.center = center;
				((Collider)component2).enabled = true;
				((Collider)component2).isTrigger = false;
			}
			CapsuleCollider component3 = host.GetComponent<CapsuleCollider>();
			if ((Object)component3 != (Object)null)
			{
				float num2 = Mathf.Max(0.001f, Mathf.Max(Mathf.Abs(lossyScale.x), Mathf.Abs(lossyScale.z)));
				component3.radius = Mathf.Max(component3.radius, 0.28f / num2);
				component3.height = Mathf.Max(component3.height, 0.54f / Mathf.Max(0.001f, Mathf.Abs(lossyScale.y)));
				component3.center = center;
				((Collider)component3).enabled = true;
			}
			if ((Object)component == (Object)null && (Object)component2 == (Object)null && (Object)component3 == (Object)null)
			{
				BoxCollider obj = host.AddComponent<BoxCollider>();
				obj.size = val2;
				obj.center = center;
				((Collider)obj).isTrigger = false;
			}
		}

		private void HideVanilla()
		{
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Expected O, but got Unknown
			Renderer[] componentsInChildren = ((Component)this).GetComponentsInChildren<Renderer>(true);
			foreach (Renderer val in componentsInChildren)
			{
				if (!((Object)val == (Object)null) && !((Object)((Component)val).transform).name.StartsWith("MV_"))
				{
					val.enabled = false;
				}
			}
		}

		private void Build()
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: 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_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0124: Unknown result type (might be due to invalid IL or missing references)
			//IL_014f: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0225: 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_0287: Unknown result type (might be due to invalid IL or missing references)
			//IL_02bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_02d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_030c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0333: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_036e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0382: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_03bd: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fc: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Expected O, but got Unknown
			//IL_04d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_04e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_050f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0523: Unknown result type (might be due to invalid IL or missing references)
			//IL_0552: Unknown result type (might be due to invalid IL or missing references)
			//IL_0566: Unknown result type (might be due to invalid IL or missing references)
			//IL_0591: Unknown result type (might be due to invalid IL or missing references)
			//IL_05a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_05b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_05be: Expected O, but got Unknown
			//IL_05ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0622: Unknown result type (might be due to invalid IL or missing references)
			//IL_068e: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_06cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_06e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_0709: Unknown result type (might be due to invalid IL or missing references)
			//IL_071d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0745: Unknown result type (might be due to invalid IL or missing references)
			//IL_0759: Unknown result type (might be due to invalid IL or missing references)
			//IL_0781: Unknown result type (might be due to invalid IL or missing references)
			//IL_0795: Unknown result type (might be due to invalid IL or missing references)
			//IL_0475: Unknown result type (might be due to invalid IL or missing references)
			//IL_047a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0484: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_0812: Unknown result type (might be due to invalid IL or missing references)
			//IL_0837: Unknown result type (might be due to invalid IL or missing references)
			//IL_084b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0872: Unknown result type (might be due to invalid IL or missing references)
			//IL_0886: Unknown result type (might be due to invalid IL or missing references)
			//IL_0897: Unknown result type (might be due to invalid IL or missing references)
			//IL_08c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_08d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_08e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_090b: Unknown result type (might be due to invalid IL or missing references)
			//IL_091f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0930: Unknown result type (might be due to invalid IL or missing references)
			//IL_0957: Unknown result type (might be due to invalid IL or missing references)
			//IL_0969: Unknown result type (might be due to invalid IL or missing references)
			//IL_097d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0992: Unknown result type (might be due to invalid IL or missing references)
			//IL_09a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_09c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_09d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_09e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a23: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a37: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a5f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a64: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a6e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a96: Unknown result type (might be due to invalid IL or missing references)
			//IL_0a9b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0aa5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ab7: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ae2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b03: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b17: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b3b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b4f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b73: Unknown result type (might be due to invalid IL or missing references)
			//IL_0b87: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bab: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bbf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0bd4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0be8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c41: Unknown result type (might be due to invalid IL or missing references)
			//IL_0c55: Unknown result type (might be due to invalid IL or missing references)
			//IL_0ca5: Unknown result type (might be due to invalid IL or missing references)
			//IL_0cb9: Unknown result type (might be due to invalid IL or missing references)
			Transform val = ((Component)this).transform.Find("MV_Root");
			if ((Object)val != (Object)null)
			{
				Object.Destroy((Object)((Component)val).gameObject);
			}
			Transform transform = new GameObject("MV_Root").transform;
			transform.SetParent(((Component)this).transform, false);
			transform.localPosition = Vector3.zero;
			transform.localRotation = Quaternion.identity;
			transform.localScale = Vector3.one * 0.28f;
			_bob = new GameObject("MV_Bob").transform;
			_bob.SetParent(transform, false);
			Material mat = Mat(new Color(0.95f, 0.96f, 0.97f), 0f, 0.55f, 0.05f);
			Material mat2 = Mat(new Color(0.05f, 0.58f, 0.62f), 0.12f, 0.42f, 0.35f);
			Material mat3 = Mat(new Color(0.78f, 0.8f, 0.82f), 0f, 0.35f, 0.08f);
			Material mat4 = Mat(new Color(0.55f, 0.58f, 0.6f), 0f, 0.5f, 0.55f);
			_plusMat = Mat(new Color(0.15f, 1f, 0.38f), 1.4f, 0.15f, 0.02f);
			Material mat5 = Mat(new Color(0.9f, 0.08f, 0.08f), 0.35f, 0.3f, 0.05f);
			Material mat6 = Mat(new Color(0.05f, 0.05f, 0.06f), 0f, 0.25f, 0.15f);
			Material mat7 = Mat(new Color(0.08f, 0.09f, 0.1f), 0f, 0.3f, 0.4f);
			Material mat8 = Mat(new Color(0.02f, 0.03f, 0.04f), 0.05f, 0.9f, 0.95f);
			Material mat9 = (_pipOn = Mat(new Color(0.2f, 1f, 0.45f), 1.6f, 0.15f, 0.02f));
			_pipOff = Mat(new Color(0.06f, 0.12f, 0.1f), 0f, 0.35f, 0.05f);
			Material mat10 = Mat(new Color(0.1f, 0.55f, 0.28f), 0.8f, 0.2f, 0.05f);
			Prim((PrimitiveType)3, "MV_Body", _bob, new Vector3(0f, 0.12f, 0f), new Vector3(1.5f, 1.05f, 1.5f), mat);
			Prim((PrimitiveType)3, "MV_BevelT", _bob, new Vector3(0f, 0.62f, 0f), new Vector3(1.42f, 0.08f, 1.42f), mat);
			Prim((PrimitiveType)3, "MV_BevelB", _bob, new Vector3(0f, -0.38f, 0f), new Vector3(1.44f, 0.08f, 1.44f), mat);
			Prim((PrimitiveType)3, "MV_Skirt", _bob, new Vector3(0f, -0.62f, 0f), new Vector3(1.52f, 0.42f, 1.52f), mat2);
			Prim((PrimitiveType)3, "MV_SkirtLip", _bob, new Vector3(0f, -0.4f, 0f), new Vector3(1.54f, 0.06f, 1.54f), mat2);
			float num = 0.76f;
			Prim((PrimitiveType)3, "MV_Hatch", _bob, new Vector3(0f, 0.08f, num), new Vector3(1.15f, 1.05f, 0.035f), mat3);
			float num2 = 0.48f;
			float num3 = 0.42f;
			int[] array = new int[2] { -1, 1 };
			foreach (int num4 in array)
			{
				int[] array2 = new int[2] { -1, 1 };
				foreach (int num5 in array2)
				{
					Prim((PrimitiveType)0, "MV_Bolt", _bob, new Vector3((float)num4 * num2, 0.08f + (float)num5 * num3, num + 0.03f), Vector3.one * 0.07f, mat4);
				}
			}
			float num6 = num + 0.04f;
			Prim((PrimitiveType)3, "MV_PlusH", _bob, new Vector3(0f, 0.08f, num6), new Vector3(0.72f, 0.22f, 0.045f), _plusMat);
			Prim((PrimitiveType)3, "MV_PlusV", _bob, new Vector3(0f, 0.08f, num6), new Vector3(0.22f, 0.72f, 0.045f), _plusMat);
			Prim((PrimitiveType)3, "MV_RedPlusH", _bob, new Vector3(0.38f, 0.4f, num6 + 0.01f), new Vector3(0.16f, 0.045f, 0.03f), mat5);
			Prim((PrimitiveType)3, "MV_RedPlusV", _bob, new Vector3(0.38f, 0.4f, num6 + 0.01f), new Vector3(0.045f, 0.16f, 0.03f), mat5);
			GameObject val2 = new GameObject("MV_PlusLight");
			val2.transform.SetParent(_bob, false);
			val2.transform.localPosition = new Vector3(0f, 0.08f, num6 + 0.2f);
			_plusLight = val2.AddComponent<Light>();
			_plusLight.type = (LightType)2;
			_plusLight.color = new Color(0.25f, 1f, 0.45f);
			_plusLight.range = 1.2f;
			_plusLight.intensity = 0.55f;
			((Behaviour)_plusLight).enabled = true;
			_plusLight.shadows = (LightShadows)0;
			_plusLight.renderMode = (LightRenderMode)2;
			Prim((PrimitiveType)3, "MV_LatchL", _bob, new Vector3(-0.35f, -0.38f, num + 0.02f), new Vector3(0.18f, 0.06f, 0.04f), mat4);
			Prim((PrimitiveType)3, "MV_LatchR", _bob, new Vector3(0.35f, -0.38f, num + 0.02f), new Vector3(0.18f, 0.06f, 0.04f), mat4);
			Prim((PrimitiveType)2, "MV_TopNub", _bob, new Vector3(0f, 0.72f, 0f), new Vector3(0.14f, 0.08f, 0.14f), mat7);
			Prim((PrimitiveType)3, "MV_LineL", _bob, new Vector3(-0.76f, 0.15f, 0f), new Vector3(0.02f, 0.7f, 0.9f), mat3);
			Prim((PrimitiveType)3, "MV_LineR", _bob, new Vector3(0.76f, 0.15f, 0f), new Vector3(0.02f, 0.7f, 0.9f), mat3);
			_rotors = (Transform[])(object)new Transform[2];
			int[] array3 = new int[2] { -1, 1 };
			for (int k = 0; k < 2; k++)
			{
				int num7 = array3[k];
				Transform transform2 = new GameObject("MV_Arm" + k).transform;
				transform2.SetParent(_bob, false);
				transform2.localPosition = new Vector3((float)num7 * 0.7f, 0.45f, 0f);
				Prim((PrimitiveType)3, "MV_Shoulder", transform2, new Vector3((float)num7 * 0.12f, 0f, 0f), new Vector3(0.28f, 0.22f, 0.28f), mat);
				Prim((PrimitiveType)3, "MV_Boom", transform2, new Vector3((float)num7 * 0.38f, 0.02f, 0f), new Vector3(0.42f, 0.16f, 0.2f), mat);
				Transform transform3 = new GameObject("MV_Motor").transform;
				transform3.SetParent(transform2, false);
				transform3.localPosition = new Vector3((float)num7 * 0.68f, 0.08f, 0f);
				Prim((PrimitiveType)2, "MV_MotorBody", transform3, Vector3.zero, new Vector3(0.34f, 0.22f, 0.34f), mat2);
				Prim((PrimitiveType)3, "MV_MotorRing", transform3, new Vector3(0f, 0.2f, 0f), new Vector3(0.38f, 0.05f, 0.38f), mat2);
				Transform transform4 = new GameObject("MV_Rotor").transform;
				transform4.SetParent(transform3, false);
				transform4.localPosition = new Vector3(0f, 0.28f, 0f);
				Prim((PrimitiveType)3, "MV_BladeA", transform4, Vector3.zero, new Vector3(1.55f, 0.014f, 0.1f), mat6);
				Prim((PrimitiveType)3, "MV_BladeB", transform4, Vector3.zero, new Vector3(1.55f, 0.014f, 0.1f), mat6).localRotation = Quaternion.Euler(0f, 90f, 0f);
				Prim((PrimitiveType)0, "MV_Hub", transform4, Vector3.zero, Vector3.one * 0.1f, mat6);
				_rotors[k] = transform4;
			}
			Prim((PrimitiveType)2, "MV_CamRing", _bob, new Vector3(0f, -0.84f, 0f), new Vector3(0.36f, 0.04f, 0.36f), mat7);
			Prim((PrimitiveType)0, "MV_CamLens", _bob, new Vector3(0f, -0.9f, 0f), Vector3.one * 0.28f, mat8);
			Prim((PrimitiveType)0, "MV_CamGlass", _bob, new Vector3(0f, -0.92f, 0.02f), Vector3.one * 0.16f, mat8);
			Transform transform5 = new GameObject("MV_HUD").transform;
			transform5.SetParent(_bob, false);
			transform5.localPosition = new Vector3(0f, 1.28f, 0.05f);
			Prim((PrimitiveType)3, "MV_HudBL", transform5, new Vector3(-0.58f, 0f, 0f), new Vector3(0.05f, 0.2f, 0.03f), mat10);
			Prim((PrimitiveType)3, "MV_HudBR", transform5, new Vector3(0.58f, 0f, 0f), new Vector3(0.05f, 0.2f, 0.03f), mat10);
			Prim((PrimitiveType)3, "MV_HudBT", transform5, new Vector3(0f, 0.1f, 0f), new Vector3(1.16f, 0.035f, 0.03f), mat10);
			Prim((PrimitiveType)3, "MV_HudBB", transform5, new Vector3(0f, -0.1f, 0f), new Vector3(1.16f, 0.035f, 0.03f), mat10);
			Prim((PrimitiveType)3, "MV_HudBack", transform5, Vector3.zero, new Vector3(1.05f, 0.14f, 0.02f), mat7);
			_pips = (MeshRenderer[])(object)new MeshRenderer[10];
			for (int l = 0; l < 10; l++)
			{
				_pips[l] = ((Component)Prim((PrimitiveType)3, "MV_Pip" + l, transform5, new Vector3(-0.45f + (float)l * 0.09f, 0f, 0.025f), new Vector3(0.07f, 0.09f, 0.02f), mat9)).GetComponent<MeshRenderer>();
			}
			for (int m = 0; m < 4; m++)
			{
				Prim((PrimitiveType)3, "MV_Status" + m, transform5, new Vector3(-0.21f + (float)m * 0.14f, -0.22f, 0f), new Vector3(0.03f, 0.11f, 0.02f), mat9);
			}
		}

		private static void Corner(Material teal, Transform parent, float bw, float bh, float bd, int sx, int sy)
		{
			//IL_0037: 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)
			Prim((PrimitiveType)3, "MV_Corner", parent, new Vector3((float)sx * (bw / 2f - 0.12f), (float)sy * (bh / 2f - 0.12f), bd / 2f + 0.01f), new Vector3(0.2f, 0.2f, 0.03f), teal);
		}

		private static void Frame(Material mat, Transform parent, float w, float h, float z, float t)
		{
			//IL_0015: 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_0046: 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_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0081: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: Unknown result type (might be due to invalid IL or missing references)
			Prim((PrimitiveType)3, "MV_FrmT", parent, new Vector3(0f, h / 2f, z), new Vector3(w, t, t), mat);
			Prim((PrimitiveType)3, "MV_FrmB", parent, new Vector3(0f, (0f - h) / 2f, z), new Vector3(w, t, t), mat);
			Prim((PrimitiveType)3, "MV_FrmL", parent, new Vector3((0f - w) / 2f, 0f, z), new Vector3(t, h, t), mat);
			Prim((PrimitiveType)3, "MV_FrmR", parent, new Vector3(w / 2f, 0f, z), new Vector3(t, h, t), mat);
		}

		private static Transform Prim(PrimitiveType type, string name, Transform parent, Vector3 localPos, Vector3 scale, Material mat)
		{
			//IL_0000: 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_0026: Expected O, but got Unknown
			//IL_0043: 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)
			GameObject val = GameObject.CreatePrimitive(type);
			((Object)val).name = name;
			Collider[] components = val.GetComponents<Collider>();
			for (int i = 0; i < components.Length; i++)
			{
				Object.Destroy((Object)components[i]);
			}
			val.transform.SetParent(parent, false);
			val.transform.localPosition = localPos;
			val.transform.localScale = scale;
			MeshRenderer component = val.GetComponent<MeshRenderer>();
			((Renderer)component).sharedMaterial = mat;
			((Renderer)component).shadowCastingMode = (ShadowCastingMode)0;
			((Renderer)component).receiveShadows = false;
			((Renderer)component).lightProbeUsage = (LightProbeUsage)0;
			((Renderer)component).reflectionProbeUsage = (ReflectionProbeUsage)0;
			return val.transform;
		}

		private static Material Mat(Color color, float emission, float smoothness, float metallic)
		{
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_003f: 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_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d7: Unknown result type (might be due to invalid IL or missing references)
			Material val = new Material(Shader.Find("Universal Render Pipeline/Lit") ?? Shader.Find("Standard") ?? Shader.Find("Unlit/Color"));
			if (val.HasProperty("_BaseColor"))
			{
				val.SetColor("_BaseColor", color);
			}
			if (val.HasProperty("_Color"))
			{
				val.SetColor("_Color", color);
			}
			if (val.HasProperty("_Smoothness"))
			{
				val.SetFloat("_Smoothness", smoothness);
			}
			if (val.HasProperty("_Glossiness"))
			{
				val.SetFloat("_Glossiness", smoothness);
			}
			if (val.HasProperty("_Metallic"))
			{
				val.SetFloat("_Metallic", metallic);
			}
			if (emission > 0.01f)
			{
				Color val2 = color * emission;
				if (val.HasProperty("_EmissionColor"))
				{
					val.EnableKeyword("_EMISSION");
					val.SetColor("_EmissionColor", val2);
				}
			}
			return val;
		}

		private static void SetEmission(Material mat, Color color, float emission)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0022: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_006a: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)mat == (Object)null)
			{
				return;
			}
			if (mat.HasProperty("_BaseColor"))
			{
				mat.SetColor("_BaseColor", color);
			}
			if (mat.HasProperty("_Color"))
			{
				mat.SetColor("_Color", color);
			}
			if (mat.HasProperty("_EmissionColor"))
			{
				if (emission > 0.02f)
				{
					mat.EnableKeyword("_EMISSION");
					mat.SetColor("_EmissionColor", color * emission);
				}
				else
				{
					mat.SetColor("_EmissionColor", Color.black);
					mat.DisableKeyword("_EMISSION");
				}
			}
		}
	}
	internal static class PrefabRefLivePatch
	{
	}
	[HarmonyPatch(typeof(StatsManager), "Awake")]
	internal static class StatsManagerAwakePatch
	{
		[HarmonyPostfix]
		private static void Postfix(StatsManager __instance)
		{
			ShopRegistry.TryInject(__instance);
		}
	}
	[HarmonyPatch(typeof(StatsManager), "Start")]
	internal static class StatsManagerStartPatch
	{
		[HarmonyPostfix]
		private static void Postfix(StatsManager __instance)
		{
			ShopRegistry.TryInject(__instance);
		}
	}
	[HarmonyPatch(typeof(StatsManager), "LoadItemsFromFolder")]
	internal static class LoadItemsPatch
	{
		[HarmonyPostfix]
		private static void Postfix(StatsManager __instance)
		{
			ShopRegistry.TryInject(__instance);
		}
	}
	[HarmonyPatch(typeof(RunManager), "ChangeLevel")]
	internal static class ChangeLevelPatch
	{
		[HarmonyPrefix]
		private static void Prefix()
		{
			//IL_000a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0015: Expected O, but got Unknown
			ShopRegistry.ResetShopWait();
			if ((Object)StatsManager.instance != (Object)null)
			{
				ShopRegistry.TryInject(StatsManager.instance);
			}
		}

		[HarmonyPostfix]
		private static void Postfix()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			if ((Object)StatsManager.instance != (Object)null)
			{
				ShopRegistry.TryInject(StatsManager.instance);
			}
			ShopRegistry.RefreshRamCache();
		}
	}
	[HarmonyPatch(typeof(ShopManager), "ShopInitialize")]
	internal static class ShopInitializePatch
	{
		[HarmonyPrefix]
		private static void Prefix()
		{
			ShopRegistry.TryInject(StatsManager.instance);
		}

		[HarmonyPostfix]
		private static void Postfix(ShopManager __instance)
		{
			ShopRegistry.TryInject(StatsManager.instance);
			ShopRegistry.RefreshRamCache();
		}
	}
	[HarmonyPatch(typeof(ShopManager), "GetAllItemsFromStatsManager")]
	internal static class ShopCollectItemsPatch
	{
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void Postfix(ShopManager __instance)
		{
			ShopRegistry.AddToShop(__instance);
		}
	}
	[HarmonyPatch(typeof(PunManager), "ShopPopulateItemVolumes")]
	internal static class ShopPopulatePatch
	{
		[HarmonyPrefix]
		[HarmonyPriority(800)]
		private static void Prefix()
		{
			ShopRegistry.TryInject(StatsManager.instance);
		}

		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void Postfix()
		{
			ShopRegistry.AddToShop(ShopManager.instance);
			ShopRegistry.SnapshotVolumes();
			ShopRegistry.ArmShopPopulateWatch();
		}
	}
	[HarmonyPatch(typeof(ShopManager), "GetAllItemVolumesInScene")]
	internal static class ShopVolumesPatch
	{
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void Postfix(ShopManager __instance)
		{
			ShopRegistry.SnapshotFrom(__instance);
			ShopRegistry.ArmShopPopulateWatch();
			ShopRegistry.TryForceShelfNow("volumes");
		}
	}
	[HarmonyPatch(typeof(PunManager), "SpawnShopItem")]
	internal static class SpawnShopItemPatch
	{
		[HarmonyPrefix]
		[HarmonyPriority(800)]
		private static void Prefix(ItemVolume itemVolume, List<Item> itemList)
		{
			ShopRegistry.NoteVolume(itemVolume);
			itemList?.RemoveAll((Item it) => (Object)it != (Object)null && Plugin.IsMedvacItem(it));
			if (itemList != null)
			{
				ShopRegistry.BindLivePrefabs(itemList);
			}
		}

		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void Postfix(ItemVolume itemVolume)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0039: Expected O, but got Unknown
			if (!((Object)itemVolume == (Object)null) && !((Object)itemVolume.itemAttributes == (Object)null))
			{
				Item item = itemVolume.itemAttributes.item;
				if (!((Object)item == (Object)null) && Plugin.IsMedvacItem(item))
				{
					ShopRegistry.ConvertToHealer(((Component)itemVolume.itemAttributes).gameObject, item);
					ShopRegistry.ApplyTierPrice(itemVolume.itemAttributes);
					ShopRegistry.NoteTierPlaced(item);
				}
			}
		}
	}
	[HarmonyPatch(typeof(PunManager), "SpawnItem")]
	internal static class PunSpawnItemPatch
	{
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void Postfix(Item item, ItemVolume volume)
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Expected O, but got Unknown
			ShopRegistry.NoteVolume(volume);
			if (!((Object)item == (Object)null) && Plugin.IsMedvacItem(item))
			{
				ShopRegistry.BindSpawned(item, volume);
				if ((Object)Plugin.Instance != (Object)null)
				{
					((MonoBehaviour)Plugin.Instance).StartCoroutine(ShopRegistry.ConvertVolumeNextFrame(item, volume));
				}
			}
		}
	}
	[HarmonyPatch(typeof(StatsManager), "ItemFetchName")]
	internal static class ItemFetchNameGuard
	{
		[HarmonyPrefix]
		private static bool Prefix(ItemAttributes itemAttributes)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			if ((Object)itemAttributes == (Object)null)
			{
				return true;
			}
			if ((Object)((Component)itemAttributes).GetComponent<MedvacRuntime>() != (Object)null)
			{
				return false;
			}
			if (Plugin.IsMedvacItem(itemAttributes.item))
			{
				return false;
			}
			return true;
		}

		[HarmonyPostfix]
		private static void Postfix(ItemAttributes itemAttributes)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			if (!((Object)itemAttributes == (Object)null) && (Object)((Component)itemAttributes).GetComponent<MedvacRuntime>() != (Object)null)
			{
				ItemNamePatch.ForceName(itemAttributes);
			}
		}
	}
	[HarmonyPatch(typeof(PunManager), "SetItemName")]
	internal static class SetItemNameGuard
	{
		[HarmonyPrefix]
		private static bool Prefix(ItemAttributes itemAttributes)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			if (!((Object)itemAttributes == (Object)null))
			{
				return (Object)((Component)itemAttributes).GetComponent<MedvacRuntime>() == (Object)null;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(PunManager), "AddingItem")]
	internal static class PunAddingItemPatch
	{
		[HarmonyPostfix]
		private static void Postfix(string itemName, ItemAttributes itemAttributes)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0018: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Expected O, but got Unknown
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Expected O, but got Unknown
			//IL_002a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Expected O, but got Unknown
			if (!((Object)itemAttributes == (Object)null))
			{
				Item val = itemAttributes.item;
				Item value = null;
				if ((Object)val == (Object)null && (Object)StatsManager.instance != (Object)null && StatsManager.instance.itemDictionary.TryGetValue(itemName, out value))
				{
					val = value;
				}
				if (!((Object)val == (Object)null) && Plugin.IsMedvacItem(val))
				{
					ShopRegistry.ConvertToHealer(((Component)itemAttributes).gameObject, val);
				}
			}
		}
	}
	[HarmonyPatch(typeof(PunManager), "TruckPopulateItemVolumes")]
	internal static class TruckPopulatePatch
	{
		[HarmonyPostfix]
		private static void Postfix()
		{
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_0010: Expected O, but got Unknown
			if ((Object)Plugin.Instance != (Object)null)
			{
				((MonoBehaviour)Plugin.Instance).StartCoroutine(ShopRegistry.ConvertAllNextFrame());
			}
			else
			{
				ShopRegistry.ConvertAllMedvacInScene();
			}
		}
	}
	[HarmonyPatch(typeof(ItemAttributes), "LateStart")]
	internal static class ItemAttributesLateStartPatch
	{
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void Postfix(ItemAttributes __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			if (!((Object)__instance == (Object)null) && Plugin.IsMedvacItem(__instance.item))
			{
				ShopRegistry.ConvertToHealer(((Component)__instance).gameObject, __instance.item);
				ItemNamePatch.ForceName(__instance);
			}
		}
	}
	[HarmonyPatch(typeof(ItemManager), "ItemsInitialize")]
	internal static class ItemManagerInitPatch
	{
		[HarmonyPostfix]
		private static void Postfix()
		{
			ShopRegistry.TryInject(StatsManager.instance);
			ShopRegistry.RefreshRamCache();
		}
	}
	[HarmonyPatch(typeof(ItemAttributes), "GetValue")]
	internal static class ItemValuePatch
	{
		[HarmonyPrefix]
		[HarmonyPriority(800)]
		private static void Prefix(ItemAttributes __instance)
		{
			ShopRegistry.BindValueRange(__instance);
		}

		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void Postfix(ItemAttributes __instance)
		{
			ShopRegistry.ApplyTierPrice(__instance);
		}
	}
	[HarmonyPatch(typeof(ItemAttributes), "GetValueRPC")]
	internal static class ItemValueRpcPatch
	{
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void Postfix(ItemAttributes __instance)
		{
			ShopRegistry.ApplyTierPrice(__instance);
		}
	}
	[HarmonyPatch(typeof(SemiFunc), "ShopUpdateCost")]
	internal static class ShopCostPatch
	{
		[HarmonyPrefix]
		private static void Prefix()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			ShopManager instance = ShopManager.instance;
			if ((Object)instance == (Object)null || instance.shoppingList == null)
			{
				return;
			}
			foreach (ItemAttributes shopping in instance.shoppingList)
			{
				ShopRegistry.ApplyTierPrice(shopping, rollIfNeeded: false);
			}
		}

		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void Postfix()
		{
			//IL_0007: Unknown result type (might be due to invalid IL or missing references)
			//IL_0012: Expected O, but got Unknown
			//IL_0041: Unknown result type (might be due to invalid IL or missing references)
			//IL_004c: Expected O, but got Unknown
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Expected O, but got Unknown
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Expected O, but got Unknown
			ShopManager instance = ShopManager.instance;
			if ((Object)instance == (Object)null || instance.shoppingList == null)
			{
				return;
			}
			int num = 0;
			HashSet<string> hashSet = new HashSet<string>();
			foreach (ItemAttributes shopping in instance.shoppingList)
			{
				if ((Object)shopping == (Object)null)
				{
					continue;
				}
				if ((Object)((Component)shopping).GetComponent<MedvacRuntime>() == (Object)null && (Plugin.IsMedvacItem(shopping.item) || (shopping.itemName != null && shopping.itemName.IndexOf("MEDVAC", StringComparison.OrdinalIgnoreCase) >= 0)))
				{
					ShopRegistry.ConvertToHealer(((Component)shopping).gameObject, shopping.item);
				}
				ShopRegistry.ApplyTierPrice(shopping, rollIfNeeded: false);
				if (Plugin.IsMedvacItem(shopping.item) || (shopping.itemName != null && shopping.itemName.IndexOf("MEDVAC", StringComparison.OrdinalIgnoreCase) >= 0))
				{
					string text = (((Object)shopping.item != (Object)null) ? ((Object)shopping.item).name : shopping.itemName);
					if (!hashSet.Add(text ?? "MEDVAC"))
					{
						continue;
					}
				}
				num += Mathf.Max(0, shopping.value);
			}
			instance.totalCost = num;
		}
	}
	[HarmonyPatch(typeof(ItemAttributes), "Start")]
	internal static class ItemAttributesStartPatch
	{
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void Postfix(ItemAttributes __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			if (!((Object)__instance == (Object)null))
			{
				GameObject gameObject = ((Component)__instance).gameObject;
				if (Plugin.IsMedvacItem(__instance.item) || Plugin.LooksLikeMedvacName(((Object)gameObject).name) || Plugin.LooksLikeMedvacName(__instance.itemName))
				{
					ShopRegistry.ConvertToHealer(gameObject, __instance.item);
					ItemNamePatch.ForceName(__instance);
				}
			}
		}
	}
	[HarmonyPatch(typeof(ItemAttributes), "ShowInfo")]
	internal static class ItemNamePatch
	{
		[HarmonyPrefix]
		[HarmonyPriority(800)]
		private static void Prefix(ItemAttributes __instance)
		{
			ForceName(__instance);
		}

		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void Postfix(ItemAttributes __instance)
		{
			ForceName(__instance);
			if (Time.frameCount % 15 == 0)
			{
				RelabelWorld(__instance);
			}
		}

		internal static string Label(MedvacRuntime runtime)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_001a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0025: Expected O, but got Unknown
			if ((Object)runtime == (Object)null)
			{
				return "MEDVAC";
			}
			string text = (((Object)runtime.boundItem != (Object)null) ? runtime.boundItem.itemName : "MEDVAC");
			if (runtime.tankMax > 0)
			{
				return text + "  " + runtime.tankHp + "/" + runtime.tankMax + "HP";
			}
			return text;
		}

		internal static void ForceName(ItemAttributes attrs)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			//IL_0034: Unknown result type (might be due to invalid IL or missing references)
			//IL_003f: Expected O, but got Unknown
			if ((Object)attrs == (Object)null)
			{
				return;
			}
			MedvacRuntime medvacRuntime = ((Component)attrs).GetComponent<MedvacRuntime>() ?? ((Component)attrs).GetComponentInParent<MedvacRuntime>();
			if (!((Object)medvacRuntime == (Object)null))
			{
				if ((Object)medvacRuntime.boundItem != (Object)null)
				{
					attrs.item = medvacRuntime.boundItem;
				}
				attrs.instanceName = (attrs.promptName = (attrs.itemName = Label(medvacRuntime)));
				medvacRuntime.ApplyIdentity();
			}
		}

		internal static void RelabelWorld(ItemAttributes attrs)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_0024: Expected O, but got Unknown
			MedvacRuntime medvacRuntime = (((Object)attrs != (Object)null) ? ((Component)attrs).GetComponent<MedvacRuntime>() : null);
			if ((Object)medvacRuntime == (Object)null)
			{
				return;
			}
			string text = Label(medvacRuntime);
			Type type = AccessTools.TypeByName("TMPro.TMP_Text") ?? AccessTools.TypeByName("TMPro.TextMeshProUGUI");
			if (type == null)
			{
				return;
			}
			PropertyInfo propertyInfo = AccessTools.Property(type, "text");
			if (propertyInfo == null)
			{
				return;
			}
			Object[] array;
			try
			{
				array = Object.FindObjectsOfType(type);
			}
			catch (Exception)
			{
				return;
			}
			Object[] array2 = array;
			foreach (Object val in array2)
			{
				if (!(val == (Object)null))
				{
					object value = propertyInfo.GetValue(val);
					string text2 = (string)((value is string) ? value : null);
					if (!string.IsNullOrEmpty(text2) && (text2.IndexOf("MEDVAC", StringComparison.OrdinalIgnoreCase) < 0 || text2.IndexOf("HP", StringComparison.OrdinalIgnoreCase) < 0) && (text2.IndexOf("RECHARGE", StringComparison.OrdinalIgnoreCase) >= 0 || text2.IndexOf("ZERO GRAVITY", StringComparison.OrdinalIgnoreCase) >= 0 || text2.IndexOf("INDESTRUCTIBLE", StringComparison.OrdinalIgnoreCase) >= 0 || text2.IndexOf("FEATHER", StringComparison.OrdinalIgnoreCase) >= 0 || (text2.IndexOf("DRONE", StringComparison.OrdinalIgnoreCase) >= 0 && text2.IndexOf("[E]", StringComparison.OrdinalIgnoreCase) >= 0)))
					{
						bool flag = text2.IndexOf("[E]", StringComparison.OrdinalIgnoreCase) >= 0;
						propertyInfo.SetValue(val, flag ? (text + " [E]") : text);
					}
				}
			}
		}
	}
	[HarmonyPatch(typeof(ItemAttributes), "GetItemNameLocalized")]
	internal static class LocalizedNamePatch
	{
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void Postfix(ItemAttributes __instance, ref string __result)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			if (!((Object)__instance == (Object)null) && !((Object)((Component)__instance).GetComponent<MedvacRuntime>() == (Object)null))
			{
				__result = ItemNamePatch.Label(((Component)__instance).GetComponent<MedvacRuntime>());
			}
		}
	}
	[HarmonyPatch(typeof(ItemAttributes), "ShowingInfo")]
	internal static class ItemShowingInfoPatch
	{
		[HarmonyPrefix]
		[HarmonyPriority(800)]
		private static void Prefix(ItemAttributes __instance)
		{
			ItemNamePatch.ForceName(__instance);
		}

		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void Postfix(ItemAttributes __instance)
		{
			ItemNamePatch.ForceName(__instance);
		}
	}
	[HarmonyPatch(typeof(ItemAttributes), "Update")]
	internal static class ItemAttributesUpdatePatch
	{
		[HarmonyPostfix]
		[HarmonyPriority(0)]
		private static void Postfix(ItemAttributes __instance)
		{
			ItemNamePatch.ForceName(__instance);
		}
	}
	[HarmonyPatch(typeof(ItemDroneHeal), "Update")]
	internal static class ItemDroneHealUpdateGuard
	{
		[HarmonyPrefix]
		private static bool Prefix(ItemDroneHeal __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			if (!((Object)__instance == (Object)null))
			{
				return (Object)((Component)__instance).GetComponent<MedvacRuntime>() == (Object)null;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(ItemDrone), "DrawBeamLine")]
	internal static class BlockMedvacBeam
	{
		[HarmonyPrefix]
		private static bool Prefix(ItemDrone __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			if (!((Object)__instance == (Object)null))
			{
				return (Object)((Component)__instance).GetComponent<MedvacRuntime>() == (Object)null;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(ItemDrone), "StateBeamDeployed")]
	internal static class BlockMedvacBeamState
	{
		[HarmonyPrefix]
		private static bool Prefix(ItemDrone __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			if (!((Object)__instance == (Object)null))
			{
				return (Object)((Component)__instance).GetComponent<MedvacRuntime>() == (Object)null;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(ItemDrone), "StateAttached")]
	internal static class BlockMedvacAttach
	{
		[HarmonyPrefix]
		private static bool Prefix(ItemDrone __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			if (!((Object)__instance == (Object)null))
			{
				return (Object)((Component)__instance).GetComponent<MedvacRuntime>() == (Object)null;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(ItemDrone), "TargetFindPlayer")]
	internal static class BlockMedvacPlayerTarget
	{
		[HarmonyPrefix]
		private static bool Prefix(ItemDrone __instance, ref bool __result)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			if ((Object)__instance == (Object)null || (Object)((Component)__instance).GetComponent<MedvacRuntime>() == (Object)null)
			{
				return true;
			}
			__result = false;
			return false;
		}
	}
	[HarmonyPatch(typeof(ItemDrone), "ActivateMagnet")]
	internal static class BlockMedvacMagnet
	{
		[HarmonyPrefix]
		private static bool Prefix(ItemDrone __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			if (!((Object)__instance == (Object)null))
			{
				return (Object)((Component)__instance).GetComponent<MedvacRuntime>() == (Object)null;
			}
			return true;
		}
	}
	[HarmonyPatch(typeof(ItemToggle), "ToggleItemLogic")]
	internal static class MedvacItemToggleSync
	{
		private static void Postfix(ItemToggle __instance, bool toggle)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_002c: Expected O, but got Unknown
			if (!((Object)__instance == (Object)null))
			{
				MedvacRuntime medvacRuntime = ((Component)__instance).GetComponent<MedvacRuntime>() ?? ((Component)__instance).GetComponentInParent<MedvacRuntime>();
				if (!((Object)medvacRuntime == (Object)null))
				{
					medvacRuntime.OnItemToggleFromGame(toggle);
				}
			}
		}
	}
	[HarmonyPatch(typeof(ItemDrone), "ButtonToggle")]
	internal static class MedvacButtonToggleSync
	{
		private static void Postfix(ItemDrone __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Expected O, but got Unknown
			if (!((Object)__instance == (Object)null))
			{
				MedvacRuntime component = ((Component)__instance).GetComponent<MedvacRuntime>();
				if (!((Object)component == (Object)null))
				{
					component.OnButtonToggleFromGame();
				}
			}
		}
	}
	[HarmonyPatch(typeof(ItemDrone), "FixedUpdate")]
	internal static class BlockMedvacVanillaFlight
	{
		[HarmonyPrefix]
		private static bool Prefix(ItemDrone __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Expected O, but got Unknown
			if ((Object)__instance == (Object)null)
			{
				return true;
			}
			return (Object)((Component)__instance).GetComponent<MedvacRuntime>() == (Object)null;
		}
	}
	[HarmonyPatch(typeof(PhysGrabObject), "FixedUpdate")]
	internal static class MedvacPhysGrabFlightPost
	{
		[HarmonyPostfix]
		private static void Postfix(PhysGrabObject __instance)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Expected O, but got Unknown
			if ((Object)__instance == (Object)null || MedvacRuntime.LivePhysIds.Count == 0)
			{
				return;
			}
			int instanceID = ((Object)__instance).GetInstanceID();
			if (MedvacRuntime.LivePhysIds.Contains(instanceID))
			{
				MedvacRuntime medvacRuntime = ((Component)__instance).GetComponent<MedvacRuntime>() ?? ((Component)__instance).GetComponentInChildren<MedvacRuntime>();
				if ((Object)medvacRuntime == (Object)null)
				{
					MedvacRuntime.LivePhysIds.Remove(instanceID);
				}
				else
				{
					medvacRuntime.ApplyFlightAfterPhys();
				}
			}
		}
	}
	[HarmonyPatch(typeof(ItemAttributes), "GenerateIcon")]
	internal static class MedvacIconPatch
	{
		[HarmonyPrefix]
		private static bool Prefix(ItemAttributes __instance, ref IEnumerator __result)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			if ((Object)__instance == (Object)null || (Object)((Component)__instance).GetComponent<MedvacRuntime>() == (Object)null)
			{
				return true;
			}
			__instance.icon = MedvacIcon.Sprite;
			__instance.hasIcon = true;
			__result = Empty();
			return false;
		}

		private static IEnumerator Empty()
		{
			yield break;
		}
	}
	[HarmonyPatch(typeof(Inventory), "GetBatteryStateFromInventorySpot")]
	internal static class MedvacInventoryBatteryStatePatch
	{
		[HarmonyPostfix]
		private static void Postfix(int index, ref int __result)
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			//IL_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Expected O, but got Unknown
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Expected O, but got Unknown
			//IL_0075: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Expected O, but got Unknown
			if (__result < 0 || (Object)Inventory.instance == (Object)null)
			{
				return;
			}
			InventorySpot spotByIndex;
			try
			{
				spotByIndex = Inventory.instance.GetSpotByIndex(index);
			}
			catch (Exception)
			{
				return;
			}
			if ((Object)spotByIndex == (Object)null || !spotByIndex.IsOccupied())
			{
				return;
			}
			ItemEquippable currentItem = spotByIndex.CurrentItem;
			if (!((Object)currentItem == (Object)null))
			{
				MedvacRuntime medvacRuntime = ((Component)currentItem).GetComponent<MedvacRuntime>() ?? ((Component)currentItem).GetComponentInChildren<MedvacRuntime>(true) ?? ((Component)currentItem).GetComponentInParent<MedvacRuntime>();
				if (!((Object)medvacRuntime == (Object)null))
				{
					__result = Mathf.Clamp(Mathf.RoundToInt(medvacRuntime.Fill01 * 6f), 0, 6);
				}
			}
		}
	}
	[HarmonyPatch(typeof(ItemDroneHeal), "CustomTargetingCondition")]
	internal static class HealTouchPatch
	{
		[HarmonyPostfix]
		private static void Postfix(ItemDroneHeal __instance, GameObject target, ref bool __result)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			//IL_0014: Unknown result type (might be due to invalid IL or missing references)
			//IL_001f: Expected O, but got Unknown
			if (!((Object)__instance == (Object)null) && (Object)((Component)__instance).GetComponent<MedvacRuntime>() != (Object)null)
			{
				__result = false;
			}
		}
	}
	[HarmonyPatch(typeof(ItemHealthPack), "UsedRPC")]
	internal static class MedkitRefillPatch
	{
		[HarmonyPrefix]
		private static bool Prefix(ItemHealthPack __instance)
		{
			return true;
		}
	}
	internal static class RamSpawnPatch
	{
		private static bool _applied;

		internal static void TryApply(Harmony harmony)
		{
			//IL_019a: Unknown result type (might be due to invalid IL or missing references)
			//IL_019f: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b3: Expected O, but got Unknown
			if (_applied || harmony == null)
			{
				return;
			}
			try
			{
				Type type = null;
				Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
				foreach (Assembly assembly in assemblies)
				{
					try
					{
						type = assembly.GetType("RepoAdminMenu.Utils.ItemUtil");
						if (type == null)
						{
							Type[] types = assembly.GetTypes();
							foreach (Type type2 in types)
							{
								if (type2.Name == "ItemUtil" && type2.Namespace != null && type2.Namespace.IndexOf("RepoAdmin") >= 0)
								{
									type = type2;
									break;
								}
							}
						}
					}
					catch (Exception)
					{
					}
					if (type != null)
					{
						break;
					}
				}
				if (type == null)
				{
					return;
				}
				MethodInfo methodInfo = null;
				MethodInfo[] methods = type.GetMethods(BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
				foreach (MethodInfo methodInfo2 in methods)
				{
					if (methodInfo2.Name.IndexOf("spawn", StringComparison.OrdinalIgnoreCase) >= 0)
					{
						ParameterInfo[] parameters = methodInfo2.GetParameters();
						if (parameters.Length >= 1 && parameters[0].ParameterType.Name == "Item")
						{
							methodInfo = methodInfo2;
							break;
						}
					}
				}
				if (methodInfo == null)
				{
					List<string> list = new List<string>();
					methods = type.GetMethods();
					foreach (MethodInfo methodInfo3 in methods)
					{
						list.Add(methodInfo3.Name);
					}
					Plugin.Log.LogWarning((object)("R.A.M. ItemUtil found but no spawn method. Methods: " + string.Join(", ", list.ToArray())));
				}
				else
				{
					harmony.Patch((MethodBase)methodInfo, new HarmonyMethod(typeof(RamSpawnPatch), "Prefix", (Type[])null)
					{
						priority = 800
					}, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
					_applied = true;
					Plugin.Log.LogInfo((object)("Hooked R.A.M. " + type.FullName + "." + methodInfo.Name));
				}
			}
			catch (Exception ex2)
			{
				Plugin.Log.LogError((object)("R.A.M. hook failed: " + ex2));
			}
		}

		public static bool Prefix(Item item)
		{
			//IL_0001: Unknown result type (might be due to invalid IL or missing references)
			//IL_000c: Expected O, but got Unknown
			if ((Object)item == (Object)null)
			{
				return true;
			}
			if (!Plugin.IsMedvacItem(item))
			{
				return true;
			}
			Plugin.Log.LogInfo((object)("R.A.M. spawn intercepted for " + ((Object)item).name));
			ShopRegistry.SpawnInWorld(item);
			return false;
		}
	}
	internal static class ShopRegistry
	{
		internal static readonly Dictionary<string, GameObject> Templates = new Dictionary<string, GameObject>();

		internal static GameObject VanillaPrefab;

		internal static PrefabRef VanillaPrefabRef;

		internal static string VanillaPhotonId = "Items/Item Drone Feather";

		internal static bool Injected;

		internal static readonly Dictionary<string, PrefabRef> Prefabs = new Dictionary<string, PrefabRef>();

		internal static readonly HashSet<string> RepoLibOnce = new HashSet<string>();

		private static bool _limitPatched;

		private static bool _leftPool;

		private static Item _poolLog;

		private static readonly List<ItemVolume> SeenVolumes = new List<ItemVolume>();

		private static bool _waitRunning;

		private static bool _placedThisVisit;

		private static readonly HashSet<string> _placedTiersThisVisit = new HashSet<string>(StringComparer.OrdinalIgnoreCase);

		private static bool _madeOwnShelfThisVisit;

		private static bool _shopWatchArmed;

		private static long _shopWatchStartTicks;

		private static int _shopWatchTicks;

		private static bool _cullWatchArmed;

		private static long _cullWatchStartTicks;

		private static int _cullWatchTicks;

		private static readonly HashSet<string> PhotonRegisteredOnce = new HashSet<string>();

		private static bool _ramLookupDone;

		private static bool _ramAbsent;

		private static long _lastForceAttemptTicks;

		internal static void TryInject(StatsManager sm)
		{
			//IL_0177: Unknown result type (might be due to invalid IL or missing references)
			//IL_017c: Unknown result type (might be due to invalid IL or missing references)
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_018d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Expected O, but got Unknown
			//IL_025b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0263: Unknown result type (might be due to invalid IL or missing references)
			//IL_026b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_0043: Expected O, but got Unknown
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f0: Expected O, but got Unknown
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Expected O, but got Unknown
			//IL_013c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0164: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			if (!Plugin.InjectShop.Value || (Object)sm == (Object)null || sm.itemDictionary == null || sm.itemDictionary.Count == 0)
			{
				return;
			}
			Item val = FindDrone(sm);
			if ((Object)val == (Object)null)
			{
				Plugin.Log.LogWarning((object)"No drone item in dictionary yet.");
				return;
			}
			GameObject val2 = ResolvePrefab(val);
			if ((Object)val2 == (Object)null)
			{
				Plugin.Log.LogWarning((object)"Drone prefab missing, cannot bind MEDVAC yet — will retry when Item Drone Heal exists / lobby loads.");
				return;
			}
			VanillaPrefab = val2;
			VanillaPrefabRef = val.prefab;
			if (!string.IsNullOrEmpty(((Object)val).name))
			{
				VanillaPhotonId = "Items/" + ((Object)val).name;
			}
			Tier[] tiers = Plugin.Tiers;
			foreach (Tier tier in tiers)
			{
				string text = "Item Drone MEDVAC " + tier.Name;
				Item val3 = FindExisting(sm, text, tier.ItemName);
				if ((Object)val3 == (Object)null)
				{
					val3 = Object.Instantiate<Item>(val);
					((Object)val3).name = text;
					val3.itemName = tier.ItemName;
					val3.description = $"Healer drone {tier.TankHp} HP tank. Heals on hull contact. Activate to patrol. Refill with medkits.";
					val3.disabled = false;
					val3.itemType = (itemType)0;
					val3.maxAmount = 8;
					val3.maxAmountInShop = 1;
					val3.maxPurchase = false;
					val3.physicalItem = true;
					val3.itemSecretShopType = (itemSecretShopType)0;
					try
					{
						val3.emojiIcon = (emojiIcon)0;
					}
					catch (Exception)
					{
						val3.emojiIcon = val.emojiIcon;
					}
					val3.itemVolume = (itemVolume)0;
					val3.prefab = new PrefabRef();
					Value val4 = ScriptableObject.CreateInstance<Value>();
					((Object)val4).name = "Value MEDVAC " + tier.Name;
					val4.valueMin = tier.PriceMin;
					val4.valueMax = tier.PriceMax;
					val3.value = val4;
					sm.itemDictionary[text] = val3;
					EnsureDict(sm.itemStatBattery, text, tier.TankHp);
					EnsureDict(sm.itemsPurchased, text, 0);
					Plugin.Log.LogInfo((object)$"Registered {text} ({tier.TankHp} HP).");
				}
				BindHealerPrefab(val3, val2, tier);
				val3.maxAmount = 8;
				val3.maxAmountInShop = 1;
				val3.maxPurchase = false;
				val3.disabled = false;
				val3.itemType = (itemType)0;
				val3.itemVolume = (itemVolume)0;
				val3.itemSecretShopType = (itemSecretShopType)0;
			}
			Injected = true;
			ClampShopCaps(sm);
		}

		internal static void ClampShopCaps(StatsManager sm = null)
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0018: Expected O, but got Unknown
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Expected O, but got Unknown
			//IL_0132: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			sm = sm ?? StatsManager.instance;
			if ((Object)sm == (Object)null || sm.itemDictionary == null)
			{
				return;
			}
			foreach (KeyValuePair<string, Item> item in sm.itemDictionary)
			{
				if (!((Object)item.Value == (Object)null) && Plugin.IsMedvacItem(item.Value))
				{
					if (item.Value.maxAmountInShop != 1 || item.Value.maxAmount != 8)
					{
						Plugin.Log.LogInfo((object)("Shop cap " + item.Value.itemName + " " + item.Value.maxAmountInShop + "/" + item.Value.maxAmount + " -> 1/8"));
						item.Value.maxAmountInShop = 1;
						item.Value.maxAmount = 8;
					}
					item.Value.disabled = false;
					item.Value.maxPurchase = false;
					item.Value.itemType = (itemType)0;
					item.Value.itemVolume = (itemVolume)0;
					item.Value.itemSecretShopType = (itemSecretShopType)0;
				}
			}
		}

		internal static void ClampShopCapsNoArgs()
		{
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Expected O, but got Unknown
			ClampShopCaps();
			if ((Object)Plugin.Instance != (Object)null)
			{
				((MonoBehaviour)Plugin.Instance).StartCoroutine(ClampSoon());
			}
		}

		private static IEnumerator ClampSoon()
		{
			yield return null;
			ClampShopCaps();
			yield return (object)new WaitForSeconds(0.15f);
			ClampShopCaps();
		}

		internal static void PatchNoItemSpawnLimit(Harmony harmony)
		{
			//IL_00ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_010c: Expected O, but got Unknown
			if (harmony == null || _limitPatched)
			{
				return;
			}
			try
			{
				Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
				foreach (Assembly assembly in assemblies)
				{
					string text = "";
					try
					{
						text = assembly.GetName().Name ?? "";
					}
					catch (Exception)
					{
						continue;
					}
					if (text.IndexOf("NoItemSpawnLimit", StringComparison.OrdinalIgnoreCase) < 0)
					{
						continue;
					}
					Type[] types = assembly.GetTypes();
					foreach (Type type in types)
					{
						MethodInfo[] methods = type.GetMethods(BindingFlags.DeclaredOnly | BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic);
						foreach (MethodInfo methodInfo in methods)
						{
							if (methodInfo.IsAbstract || methodInfo.ContainsGenericParameters)
							{
								continue;
							}
							string name = methodInfo.Name;
							if (name.IndexOf("Apply", StringComparison.OrdinalIgnoreCase) >= 0 || name.IndexOf("Limit", StringComparison.OrdinalIgnoreCase) >= 0 || !(name != "Start") || !(name != "Awake"))
							{
								try
								{
									harmony.Patch((MethodBase)methodInfo, (HarmonyMethod)null, new HarmonyMethod(typeof(ShopRegistry), "ClampShopCapsNoArgs", (Type[])null), (HarmonyMethod)null, (HarmonyMethod)null, (HarmonyMethod)null);
									Plugin.Log.LogInfo((object)("Clamping MEDVAC shop cap after " + type.Name + "." + name));
								}
								catch (Exception)
								{
								}
							}
						}
					}
					_limitPatched = true;
				}
			}
			catch (Exception ex3)
			{
				Plugin.Log.LogDebug((object)("NoItemSpawnLimit patch skipped: " + ex3.Message));
			}
		}

		internal static void SpawnInWorld(Item item)
		{
			//IL_000f: 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_001e: 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_0024: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Expected O, but got Unknown
			//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_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0067: 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_0073: Unknown result type (might be due to invalid IL or missing references)
			//IL_0078: 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_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Expected O, but got Unknown
			//IL_00cc: Unknown result type (might be due to invalid IL or missing references)
			PlayerAvatar val = SemiFunc.PlayerGetLocal() ?? PlayerAvatar.instance;
			Vector3 val2 = Vector3.up * 1.2f;
			Quaternion rot = Quaternion.identity;
			if ((Object)val != (Object)null)
			{
				val2 = ((Component)val).transform.position + Vector3.up * 1.15f + ((Component)val).transform.forward * 1.2f;
				rot = ((Component)val).transform.rotation;
			}
			if (MedvacNet.IsMultiplayer() && !MedvacNet.IsMaster())
			{
				Plugin.Log.LogInfo((object)"Client asked host-