Decompiled source of HeavyScrap v0.2.0

HeavyScrap.dll

Decompiled 2 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security.Cryptography;
using System.Text;
using BepInEx;
using BepInEx.Bootstrap;
using BepInEx.Configuration;
using BepInEx.Logging;
using GameNetcodeStuff;
using HarmonyLib;
using Microsoft.CodeAnalysis;
using ModMenu;
using Unity.Collections;
using Unity.Netcode;
using UnityEngine;
using UnityEngine.AI;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: InternalsVisibleTo("HeavyScrapTest")]
[assembly: TargetFramework(".NETStandard,Version=v2.1", FrameworkDisplayName = ".NET Standard 2.1")]
[assembly: AssemblyCompany("HeavyScrap")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("0.2.0.0")]
[assembly: AssemblyInformationalVersion("0.2.0+ad4f9557048ac9a499b6f9ab649782c47b7aa9d2")]
[assembly: AssemblyProduct("HeavyScrap")]
[assembly: AssemblyTitle("HeavyScrap")]
[assembly: AssemblyVersion("0.2.0.0")]
[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 HeavyScrap
{
	internal static class Assets
	{
		private static AssetBundle _bundle;

		internal static readonly Dictionary<string, List<AudioClip>> Sounds = new Dictionary<string, List<AudioClip>>();

		private static readonly Random Rng = new Random();

		private static bool _loaded;

		internal static void Load()
		{
			if (_loaded)
			{
				return;
			}
			_loaded = true;
			try
			{
				using (Stream stream = Res("heavyscrap"))
				{
					_bundle = ((stream != null) ? AssetBundle.LoadFromStream(stream) : null);
					if ((Object)(object)_bundle == (Object)null)
					{
						Plugin.Log.LogError((object)"HeavyScrap: the embedded bundle is missing; using grey boxes.");
					}
				}
				string[] manifestResourceNames = Assembly.GetExecutingAssembly().GetManifestResourceNames();
				foreach (string text in manifestResourceNames)
				{
					if (!text.EndsWith(".wav"))
					{
						continue;
					}
					string text2 = text.Substring("HeavyScrap.".Length, text.Length - "HeavyScrap.".Length - 4);
					string key = text2.TrimEnd('0', '1', '2', '3', '4', '5', '6', '7', '8', '9').TrimEnd('_');
					AudioClip val = Wav.Load(Res(text2 + ".wav"), "HeavyScrap_" + text2);
					if (!((Object)(object)val == (Object)null))
					{
						if (!Sounds.TryGetValue(key, out var value))
						{
							value = (Sounds[key] = new List<AudioClip>());
						}
						value.Add(val);
					}
				}
				Plugin.Log.LogInfo((object)string.Format("HeavyScrap: assets loaded (bundle {0}, sounds: {1}).", (Object)(object)_bundle != (Object)null, string.Join(", ", Sounds.Keys)));
			}
			catch (Exception arg)
			{
				Plugin.Log.LogError((object)$"HeavyScrap: assets failed to load: {arg}");
			}
		}

		internal static GameObject Model(string name)
		{
			if (!((Object)(object)_bundle != (Object)null))
			{
				return null;
			}
			return _bundle.LoadAsset<GameObject>(name);
		}

		internal static AudioClip Sound(string word)
		{
			if (!Sounds.TryGetValue(word, out var value) || value.Count == 0)
			{
				return null;
			}
			return value[Rng.Next(value.Count)];
		}

		private static Stream Res(string name)
		{
			return Assembly.GetExecutingAssembly().GetManifestResourceStream("HeavyScrap." + name);
		}
	}
	internal static class Wav
	{
		public static AudioClip Load(Stream s, string name)
		{
			if (s == null)
			{
				Plugin.Log.LogError((object)("HeavyScrap: sound " + name + " is missing."));
				return null;
			}
			using (s)
			{
				using BinaryReader binaryReader = new BinaryReader(s);
				binaryReader.ReadBytes(12);
				int num = 1;
				int num2 = 44100;
				int num3 = 16;
				byte[] array = null;
				while (binaryReader.BaseStream.Position < binaryReader.BaseStream.Length - 8)
				{
					string text = Encoding.ASCII.GetString(binaryReader.ReadBytes(4));
					int num4 = binaryReader.ReadInt32();
					if (text == "fmt ")
					{
						binaryReader.ReadInt16();
						num = binaryReader.ReadInt16();
						num2 = binaryReader.ReadInt32();
						binaryReader.ReadInt32();
						binaryReader.ReadInt16();
						num3 = binaryReader.ReadInt16();
						if (num4 > 16)
						{
							binaryReader.ReadBytes(num4 - 16);
						}
					}
					else
					{
						if (text == "data")
						{
							array = binaryReader.ReadBytes(num4);
							break;
						}
						binaryReader.ReadBytes(num4);
					}
				}
				if (array == null || num3 != 16)
				{
					Plugin.Log.LogError((object)("HeavyScrap: sound " + name + " isn't 16-bit PCM."));
					return null;
				}
				int num5 = array.Length / 2;
				float[] array2 = new float[num5];
				for (int i = 0; i < num5; i++)
				{
					array2[i] = (float)BitConverter.ToInt16(array, i * 2) / 32768f;
				}
				AudioClip obj = AudioClip.Create(name, num5 / num, num, num2, false);
				obj.SetData(array2, 0);
				return obj;
			}
		}
	}
	internal static class Carry
	{
		internal class Kin
		{
			public Vector3 Pos;

			public Vector3 Vel;

			public float At;
		}

		internal class Claim
		{
			public int Player;

			public byte Side;

			public float At;

			public bool Solo;
		}

		internal class Side
		{
			public int Idx;

			public Vector3 Pos;

			public Vector3 Vel;

			public byte Flags;

			public float Rtt;

			public float RecvAt = -1f;
		}

		internal class HostCarry
		{
			public HeavyCargo Cargo;

			public float NextScrape;

			public Side B = new Side();

			public Side F = new Side();

			public float Tilt;

			public float NextTick;

			public float NextLog;

			public float GraceUntil;

			public float StopFor;

			public float WallFor;

			public float AirFor;

			public float CrouchFor;

			public int ApartTicks;

			public float StartedAt;

			public float TiltMax;

			public float GapMin = 99f;

			public float GapMax;

			public float GapSum;

			public float LastGap;

			public float LastSlack;

			public int Ticks;

			public readonly Dictionary<string, float> RuleTime = new Dictionary<string, float>();

			public string LastRules = "";

			public bool Solo => B.Idx == F.Idx;
		}

		internal static HeavyCargo LocalCargo;

		internal static int LocalSide;

		private static float _addedWeight;

		private static float _nextState;

		private static float _nextPing;

		internal static float Rtt = 0f;

		private static readonly Dictionary<HeavyCargo, float> ShownTilt = new Dictionary<HeavyCargo, float>();

		private static string _tip;

		private static float _tipUntil;

		private static bool _posed;

		internal static bool BypassDoor;

		private static DepositItemsDesk _desk;

		private static readonly Dictionary<int, Kin> Kins = new Dictionary<int, Kin>();

		internal static readonly Dictionary<(ulong, int), float> SlammedAt = new Dictionary<(ulong, int), float>();

		internal static int DragNoises;

		internal static readonly Dictionary<ulong, Claim> Claims = new Dictionary<ulong, Claim>();

		internal static readonly Dictionary<ulong, HostCarry> Active = new Dictionary<ulong, HostCarry>();

		internal static readonly Dictionary<ulong, int> FirstValue = new Dictionary<ulong, int>();

		internal static readonly List<string> DropLog = new List<string>();

		private static readonly HashSet<ulong> PendingNoise = new HashSet<ulong>();

		private static Vector3? _floorOverride;

		private static readonly Dictionary<HeavyCargo, float> NextScrapeSound = new Dictionary<HeavyCargo, float>();

		private static float _nextCreak;

		private static GUIStyle _title;

		private static GUIStyle _small;

		private static GUIStyle _tipStyle;

		private static Texture2D _px;

		private static readonly Color Orange = new Color(1f, 0.55f, 0.2f);

		internal static bool LocalSolo
		{
			get
			{
				if ((Object)(object)LocalCargo != (Object)null)
				{
					return LocalCargo.Solo;
				}
				return false;
			}
		}

		internal static bool LocalCarrying => (Object)(object)LocalCargo != (Object)null;

		private static PlayerControllerB Me => GameNetworkManager.Instance?.localPlayerController;

		internal static float TiltFor(HeavyCargo c)
		{
			if (!((Object)(object)c != (Object)null) || !ShownTilt.TryGetValue(c, out var value))
			{
				return 0f;
			}
			return value;
		}

		internal static void Tip(string s, float secs = 2.5f)
		{
			_tip = s;
			_tipUntil = Time.realtimeSinceStartup + secs;
			Plugin.Log.LogInfo((object)("HeavyScrap tip: " + s));
		}

		internal static void LocalTryLift(HeavyCargo c)
		{
			//IL_006b: 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_0087: Unknown result type (might be due to invalid IL or missing references)
			//IL_0093: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB me = Me;
			if (!((Object)(object)me == (Object)null) && !((Object)(object)c == (Object)null) && !LocalCarrying && (!c.Carried || (c.Solo && (Object)(object)c.Back != (Object)(object)me)))
			{
				if ((Object)(object)me.currentlyHeldObjectServer != (Object)null && me.isHoldingObject)
				{
					Tip("Hands full. Pocket what you're holding first.");
					return;
				}
				int num = ((!(Vector3.Distance(((Component)me).transform.position, c.StandPoint(0)) <= Vector3.Distance(((Component)me).transform.position, c.StandPoint(1)))) ? 1 : 0);
				Tip("Lifting... it needs someone on the other handle [E]", 1.5f);
				Net.SendLiftReq(((NetworkBehaviour)c).NetworkObjectId, (byte)num);
			}
		}

		internal static void ApplyLift(ulong id, int back, int front, int value)
		{
			HeavyCargo heavyCargo = Find(id);
			if ((Object)(object)heavyCargo == (Object)null)
			{
				return;
			}
			heavyCargo.BackIdx = back;
			heavyCargo.FrontIdx = front;
			heavyCargo.LiftedAt = Time.time;
			((GrabbableObject)heavyCargo).SetScrapValue(value);
			LeaveShip(heavyCargo, HeavyCargo.Player(back));
			ShownTilt[heavyCargo] = 0f;
			Sfx.Play(heavyCargo, "grunt", 0.9f);
			PlayerControllerB me = Me;
			if ((Object)(object)me == (Object)null)
			{
				return;
			}
			int num = (int)me.playerClientId;
			if ((Object)(object)LocalCargo == (Object)(object)heavyCargo)
			{
				LocalRelease();
			}
			if (num == back || num == front)
			{
				LocalCargo = heavyCargo;
				LocalSide = ((num == front && back != front) ? 1 : 0);
				float carryWeight = me.carryWeight;
				if (back == front)
				{
					float num2 = Mathf.Max(carryWeight + (((GrabbableObject)heavyCargo).itemProperties.weight - 1f) / 2f, carryWeight / Mathf.Max(0.1f, Plugin.SoloSpeed.Value));
					me.carryWeight = Mathf.Clamp(num2, 1f, 10f);
					Tip("Dragging it alone: slow and loud. [G] let go", 3f);
				}
				else
				{
					me.carryWeight = Mathf.Clamp(me.carryWeight + (((GrabbableObject)heavyCargo).itemProperties.weight - 1f) / 2f, 1f, 10f);
				}
				_addedWeight = me.carryWeight - carryWeight;
				SetPose(me, back != front);
				Plugin.Log.LogInfo((object)("HeavyScrap: lifted " + ((GrabbableObject)heavyCargo).itemProperties.itemName + " as " + ((LocalSide == 1) ? "front" : "back") + " with " + Partner()?.playerUsername + "; " + $"carryWeight {carryWeight:F2} -> {me.carryWeight:F2}"));
			}
		}

		internal static void ApplySlam(ulong id, int player)
		{
			HeavyCargo heavyCargo = Find(id);
			if (!((Object)(object)heavyCargo == (Object)null))
			{
				if ((Object)(object)Me != (Object)null && (int)Me.playerClientId == player)
				{
					Tip(Plugin.SoloDrag.Value ? "Too heavy to lift alone. [E] again to drag it (slow and loud)." : "Too heavy. It needs a second person on the other handle.", 4f);
				}
				Sfx.Play(heavyCargo, "grunt", 0.6f);
				Sfx.Play(heavyCargo, "thunk", 0.8f);
			}
		}

		internal static void ApplyTilt(ulong id, float t)
		{
			HeavyCargo heavyCargo = Find(id);
			if ((Object)(object)heavyCargo != (Object)null)
			{
				ShownTilt[heavyCargo] = t;
			}
		}

		internal static void ApplyDrop(ulong id, Vector3 floor, float yaw, int value, DropReason reason)
		{
			//IL_00bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			HeavyCargo heavyCargo = Find(id);
			if (!((Object)(object)heavyCargo == (Object)null))
			{
				bool num = (Object)(object)LocalCargo == (Object)(object)heavyCargo;
				heavyCargo.CrashPending = reason != DropReason.RoundOver && reason != DropReason.SetDown && reason != DropReason.Sold && !heavyCargo.Solo;
				heavyCargo.LastBack = ((heavyCargo.BackIdx >= 0) ? heavyCargo.BackIdx : heavyCargo.LastBack);
				heavyCargo.BackIdx = (heavyCargo.FrontIdx = -1);
				ShownTilt.Remove(heavyCargo);
				((GrabbableObject)heavyCargo).SetScrapValue(value);
				PlayerControllerB val = HeavyCargo.Player(heavyCargo.LastBack);
				DepositItemsDesk val2 = ((reason == DropReason.Sold) ? Object.FindObjectOfType<DepositItemsDesk>() : null);
				if ((Object)(object)val2 != (Object)null)
				{
					((Component)heavyCargo).transform.SetParent(((Component)val2.deskObjectsContainer).transform, true);
				}
				else
				{
					EnterShip(heavyCargo, floor, val);
				}
				heavyCargo.FallTo(floor, yaw);
				if (num)
				{
					LocalRelease();
					Tip(ReasonText(reason), 3.5f);
				}
				Plugin.Log.LogInfo((object)$"HeavyScrap: {((GrabbableObject)heavyCargo).itemProperties.itemName} dropped ({reason}), now ${value}.");
			}
		}

		internal static string ReasonText(DropReason r)
		{
			return r switch
			{
				DropReason.Tilt => "You lost your grip on it: walk steady together.", 
				DropReason.PulledApart => "You pulled it out of your partner's hands.", 
				DropReason.Jumped => "You can't jump with it. It crashed to the floor.", 
				DropReason.LetGo => "Let go.", 
				DropReason.CarrierDown => "Your partner went down. It crashed to the floor.", 
				DropReason.CarrierLeft => "Your partner left. It crashed to the floor.", 
				DropReason.RoundOver => "The ship is leaving.", 
				DropReason.SetDown => "Set down.", 
				DropReason.Sold => "On the counter.", 
				DropReason.Grabbed => "Something grabbed one of you. It crashed to the floor.", 
				_ => "You split up. It crashed to the floor.", 
			};
		}

		private static void EnterShip(HeavyCargo c, Vector3 floor, PlayerControllerB by)
		{
			//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_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_003c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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)
			//IL_0074: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			StartOfRound instance = StartOfRound.Instance;
			if ((Object)(object)instance == (Object)null)
			{
				return;
			}
			Bounds bounds;
			int num;
			if ((Object)(object)instance.shipInnerRoomBounds != (Object)null)
			{
				bounds = instance.shipInnerRoomBounds.bounds;
				num = (((Bounds)(ref bounds)).Contains(floor + Vector3.up * 0.3f) ? 1 : 0);
			}
			else
			{
				num = 0;
			}
			bool flag = (byte)num != 0;
			int num2;
			if (!flag)
			{
				if ((Object)(object)instance.shipBounds != (Object)null)
				{
					bounds = instance.shipBounds.bounds;
					num2 = (((Bounds)(ref bounds)).Contains(floor + Vector3.up * 0.3f) ? 1 : 0);
				}
				else
				{
					num2 = 0;
				}
			}
			else
			{
				num2 = 1;
			}
			bool flag2 = (byte)num2 != 0;
			((Component)c).transform.SetParent(flag2 ? instance.elevatorTransform : null, true);
			if ((Object)(object)by != (Object)null)
			{
				by.SetItemInElevator(flag, flag2, (GrabbableObject)(object)c);
			}
			else
			{
				((GrabbableObject)c).isInShipRoom = flag;
				((GrabbableObject)c).isInElevator = flag2;
			}
			if (flag)
			{
				RoundManager instance2 = RoundManager.Instance;
				if (instance2 != null)
				{
					instance2.CollectNewScrapForThisRound((GrabbableObject)(object)c);
				}
			}
		}

		private static void LeaveShip(HeavyCargo c, PlayerControllerB by)
		{
			if ((Object)(object)((Component)c).transform.parent != (Object)null)
			{
				((Component)c).transform.SetParent((Transform)null, true);
			}
			if (((GrabbableObject)c).isInShipRoom && (Object)(object)by != (Object)null)
			{
				by.SetItemInElevator(false, false, (GrabbableObject)(object)c);
			}
			((GrabbableObject)c).isInElevator = false;
		}

		internal static void LocalRelease()
		{
			PlayerControllerB me = Me;
			if ((Object)(object)me != (Object)null && _addedWeight > 0f)
			{
				me.carryWeight = Mathf.Clamp(me.carryWeight - _addedWeight, 1f, 10f);
			}
			_addedWeight = 0f;
			if ((Object)(object)LocalCargo != (Object)null && (Object)(object)me != (Object)null)
			{
				SetPose(me, on: false);
			}
			LocalCargo = null;
		}

		private static void KeepPose(PlayerControllerB me)
		{
			Animator playerBodyAnimator = me.playerBodyAnimator;
			if (!((Object)(object)playerBodyAnimator == (Object)null) && _posed && (!playerBodyAnimator.GetBool("GrabValidated") || playerBodyAnimator.GetBool("cancelHolding") || !playerBodyAnimator.GetBool("Grab")))
			{
				_posed = false;
				SetPose(me, on: true);
			}
		}

		private static void SetPose(PlayerControllerB me, bool on)
		{
			if (on == _posed && on)
			{
				return;
			}
			Animator playerBodyAnimator = me.playerBodyAnimator;
			if ((Object)(object)playerBodyAnimator == (Object)null)
			{
				return;
			}
			try
			{
				playerBodyAnimator.SetBool("Grab", on);
				if (!string.IsNullOrEmpty(Registry.HoldAnim))
				{
					playerBodyAnimator.SetBool(Registry.HoldAnim, on);
				}
				if (on)
				{
					playerBodyAnimator.SetBool("GrabValidated", true);
					playerBodyAnimator.SetBool("cancelHolding", false);
				}
				else if (!me.isHoldingObject)
				{
					playerBodyAnimator.SetBool("cancelHolding", true);
				}
				_posed = on;
			}
			catch (Exception ex)
			{
				Plugin.Log.LogWarning((object)("HeavyScrap: carry pose failed: " + ex.Message));
			}
		}

		internal static PlayerControllerB Partner()
		{
			HeavyCargo localCargo = LocalCargo;
			if ((Object)(object)localCargo == (Object)null || localCargo.Solo)
			{
				return null;
			}
			if (LocalSide != 1)
			{
				return localCargo.Front;
			}
			return localCargo.Back;
		}

		internal static bool LocalUseDoor(EntranceTeleport door)
		{
			//IL_005c: 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)
			if ((Object)(object)LocalCargo == (Object)null || BypassDoor)
			{
				return true;
			}
			PlayerControllerB me = Me;
			PlayerControllerB val = Partner();
			if ((Object)(object)me == (Object)null)
			{
				return false;
			}
			if (LocalSolo)
			{
				Net.SendDoor(((NetworkBehaviour)LocalCargo).NetworkObjectId, ((NetworkBehaviour)door).NetworkObjectId);
				return false;
			}
			if ((Object)(object)val == (Object)null)
			{
				return false;
			}
			if (Vector3.Distance(((Component)me).transform.position, ((Component)val).transform.position) > 3f)
			{
				Tip("Your partner needs to be with you.");
				return false;
			}
			Net.SendDoor(((NetworkBehaviour)LocalCargo).NetworkObjectId, ((NetworkBehaviour)door).NetworkObjectId);
			return false;
		}

		internal static void HostDoor(int player, ulong id, ulong doorId)
		{
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			if (!Active.TryGetValue(id, out var value) || (value.B.Idx != player && value.F.Idx != player))
			{
				return;
			}
			EntranceTeleport val = FindDoor(doorId);
			PlayerControllerB val2 = HeavyCargo.Player(value.B.Idx);
			PlayerControllerB val3 = HeavyCargo.Player(value.F.Idx);
			if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null || (Object)(object)val3 == (Object)null)
			{
				Plugin.Log.LogInfo((object)$"HeavyScrap host: door refused (door {(Object)(object)val != (Object)null}, carriers {(Object)(object)val2 != (Object)null}/{(Object)(object)val3 != (Object)null})");
				return;
			}
			Vector3 position = ((Component)HeavyCargo.Player(player)).transform.position;
			float num = Mathf.Min(Vector3.Distance(position, ((Component)val).transform.position), ((Object)(object)val.entrancePoint != (Object)null) ? Vector3.Distance(position, val.entrancePoint.position) : float.MaxValue);
			if (num > 6f)
			{
				Plugin.Log.LogInfo((object)$"HeavyScrap host: door refused, user {num:F1} m from it");
				return;
			}
			float num2 = Vector3.Distance(((Component)val2).transform.position, ((Component)val3).transform.position);
			if ((Object)(object)val2 != (Object)(object)val3 && num2 > 3.6f)
			{
				Plugin.Log.LogInfo((object)$"HeavyScrap host: door refused, carriers {num2:F1} m apart");
				return;
			}
			value.GraceUntil = Time.realtimeSinceStartup + 2.5f;
			value.B.RecvAt = (value.F.RecvAt = -1f);
			Net.BroadcastDoorGo(id, doorId);
			ApplyDoorGo(id, doorId);
		}

		internal static void ApplyDoorGo(ulong id, ulong doorId)
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: 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_00c2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0115: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			HeavyCargo heavyCargo = Find(id);
			EntranceTeleport val = FindDoor(doorId);
			if ((Object)(object)heavyCargo == (Object)null || (Object)(object)val == (Object)null)
			{
				return;
			}
			((GrabbableObject)heavyCargo).isInFactory = val.isEntranceToBuilding;
			PlayerControllerB me = Me;
			if ((Object)(object)LocalCargo != (Object)(object)heavyCargo || (Object)(object)me == (Object)null)
			{
				return;
			}
			BypassDoor = true;
			try
			{
				val.TeleportPlayer();
			}
			finally
			{
				BypassDoor = false;
			}
			if (LocalSide != 1 || (Object)(object)val.exitScript == (Object)null)
			{
				return;
			}
			Transform entrancePoint = val.exitScript.entrancePoint;
			Vector3 forward = entrancePoint.forward;
			forward.y = 0f;
			((Vector3)(ref forward)).Normalize();
			float[] array = new float[3] { 2.2f, 1.6f, 1.1f };
			NavMeshHit val2 = default(NavMeshHit);
			foreach (float num in array)
			{
				if (NavMesh.SamplePosition(entrancePoint.position + forward * num, ref val2, 0.6f, -1) && !Physics.Linecast(entrancePoint.position + Vector3.up, ((NavMeshHit)(ref val2)).position + Vector3.up, StartOfRound.Instance.collidersAndRoomMask, (QueryTriggerInteraction)1))
				{
					me.TeleportPlayer(((NavMeshHit)(ref val2)).position, true, entrancePoint.eulerAngles.y, false, true);
					break;
				}
			}
		}

		private static EntranceTeleport FindDoor(ulong id)
		{
			NetworkManager nM = Net.NM;
			if (((nM != null) ? nM.SpawnManager : null) == null || !nM.SpawnManager.SpawnedObjects.TryGetValue(id, out var value) || !((Object)(object)value != (Object)null))
			{
				return null;
			}
			return ((Component)value).GetComponent<EntranceTeleport>();
		}

		internal static bool LocalDesk(DepositItemsDesk desk)
		{
			if ((Object)(object)LocalCargo == (Object)null)
			{
				return true;
			}
			Net.SendDesk(((NetworkBehaviour)LocalCargo).NetworkObjectId);
			return false;
		}

		internal static DepositItemsDesk DeskOf(InteractTrigger t)
		{
			if ((Object)(object)t == (Object)null)
			{
				return null;
			}
			if ((Object)(object)_desk == (Object)null)
			{
				_desk = Object.FindObjectOfType<DepositItemsDesk>();
			}
			if (!((Object)(object)_desk != (Object)null) || !((Object)(object)_desk.triggerScript == (Object)(object)t))
			{
				return null;
			}
			return _desk;
		}

		private static bool NearDesk(Vector3 at)
		{
			//IL_0067: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			SelectableLevel val = StartOfRound.Instance?.currentLevel;
			if ((Object)(object)val == (Object)null || val.sceneName != "CompanyBuilding")
			{
				return false;
			}
			if ((Object)(object)_desk == (Object)null)
			{
				_desk = Object.FindObjectOfType<DepositItemsDesk>();
			}
			if ((Object)(object)_desk == (Object)null || (Object)(object)_desk.triggerCollider == (Object)null)
			{
				return false;
			}
			Bounds bounds = ((Collider)_desk.triggerCollider).bounds;
			return Vector3.Distance(at, ((Bounds)(ref bounds)).ClosestPoint(at)) < 3f;
		}

		internal static void HostDesk(int player, ulong id)
		{
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_006c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0079: Unknown result type (might be due to invalid IL or missing references)
			//IL_007e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: 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)
			//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)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d2: 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)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_011e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fc: Unknown result type (might be due to invalid IL or missing references)
			if (!Active.TryGetValue(id, out var value) || (value.B.Idx != player && value.F.Idx != player))
			{
				return;
			}
			DepositItemsDesk val = Object.FindObjectOfType<DepositItemsDesk>();
			PlayerControllerB val2 = HeavyCargo.Player(player);
			if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null || (Object)(object)val.triggerCollider == (Object)null)
			{
				return;
			}
			Bounds bounds = ((Collider)val.triggerCollider).bounds;
			if (!(Vector3.Distance(((Component)val2).transform.position, ((Bounds)(ref bounds)).ClosestPoint(((Component)val2).transform.position)) > 4f) && ((Component)val.deskObjectsContainer).GetComponentsInChildren<GrabbableObject>().Length < 150)
			{
				Vector3 val3 = ((Bounds)(ref bounds)).center;
				val3.y = ((Bounds)(ref bounds)).min.y;
				RaycastHit val4 = default(RaycastHit);
				if (Physics.Raycast(new Ray(val3 + Vector3.up * 3f, Vector3.down), ref val4, 8f, 1048640, (QueryTriggerInteraction)2))
				{
					val3 = ((RaycastHit)(ref val4)).point;
				}
				_floorOverride = val3;
				HostDrop(value, DropReason.Sold);
				val.AddObjectToDeskServerRpc(NetworkObjectReference.op_Implicit(((NetworkBehaviour)value.Cargo).NetworkObject));
				Plugin.Log.LogInfo((object)$"HeavyScrap host: {((GrabbableObject)value.Cargo).itemProperties.itemName} on the Company counter (${((GrabbableObject)value.Cargo).scrapValue})");
			}
		}

		internal static void LocalJumped()
		{
			if ((Object)(object)LocalCargo != (Object)null)
			{
				Net.SendJump(((NetworkBehaviour)LocalCargo).NetworkObjectId);
			}
		}

		internal static void LocalLetGo()
		{
			if ((Object)(object)LocalCargo != (Object)null)
			{
				Net.SendLetGo(((NetworkBehaviour)LocalCargo).NetworkObjectId);
			}
		}

		internal static void OnPong(float t)
		{
			float num = Time.realtimeSinceStartup - t;
			if (!(num < 0f) && !(num > 3f))
			{
				Rtt = ((Rtt <= 0f) ? num : Mathf.Lerp(Rtt, num, 0.25f));
			}
		}

		internal static Kin KinOf(PlayerControllerB p)
		{
			//IL_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			int key = (int)p.playerClientId;
			if (!Kins.TryGetValue(key, out var value))
			{
				Dictionary<int, Kin> kins = Kins;
				Kin obj = new Kin
				{
					Pos = ((Component)p).transform.position,
					At = Time.time
				};
				value = obj;
				kins[key] = obj;
			}
			return value;
		}

		private static void TrackKin(PlayerControllerB p)
		{
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: 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_007b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0080: Unknown result type (might be due to invalid IL or missing references)
			//IL_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)
			if ((Object)(object)p == (Object)null)
			{
				return;
			}
			Kin kin = KinOf(p);
			float num = Time.time - kin.At;
			if (!(num <= 0f))
			{
				Vector3 val = (((Component)p).transform.position - kin.Pos) / num;
				if (num > 0.5f || ((Vector3)(ref val)).sqrMagnitude > 400f)
				{
					val = Vector3.zero;
				}
				kin.Vel = Vector3.Lerp(kin.Vel, val, 1f - Mathf.Exp((0f - num) / 0.15f));
				kin.Pos = ((Component)p).transform.position;
				kin.At = Time.time;
			}
		}

		internal static void HostLiftRequest(int player, ulong id, byte side)
		{
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			HeavyCargo heavyCargo = Find(id);
			PlayerControllerB val = HeavyCargo.Player(player);
			if ((Object)(object)heavyCargo == (Object)null || (Object)(object)val == (Object)null || side > 1 || !val.isPlayerControlled || val.isPlayerDead || Vector3.Distance(((Component)val).transform.position, ((Component)heavyCargo).transform.position) > 3.5f)
			{
				return;
			}
			float realtimeSinceStartup = Time.realtimeSinceStartup;
			if (Active.TryGetValue(id, out var value))
			{
				if (value.Solo && value.B.Idx != player && !Active.Values.Any((HostCarry h) => h.B.Idx == player || h.F.Idx == player))
				{
					Active.Remove(id);
					if (side == 0)
					{
						StartCarry(heavyCargo, player, value.B.Idx);
					}
					else
					{
						StartCarry(heavyCargo, value.B.Idx, player);
					}
				}
			}
			else
			{
				if (heavyCargo.Carried || Active.Values.Any((HostCarry h) => h.B.Idx == player || h.F.Idx == player))
				{
					return;
				}
				float value2;
				bool flag = Plugin.SoloDrag.Value && SlammedAt.TryGetValue((id, player), out value2) && realtimeSinceStartup - value2 <= 4f;
				Claim value4;
				if (Claims.TryGetValue(id, out var value3) && value3.Player != player && realtimeSinceStartup - value3.At <= 0.75f)
				{
					int back = ((value3.Side == 0) ? value3.Player : player);
					int front = ((value3.Side == 0) ? player : value3.Player);
					Claims.Remove(id);
					StartCarry(heavyCargo, back, front);
				}
				else if (!Claims.TryGetValue(id, out value4) || value4.Player != player)
				{
					if (flag)
					{
						SlammedAt.Remove((id, player));
					}
					Claims[id] = new Claim
					{
						Player = player,
						Side = side,
						At = realtimeSinceStartup,
						Solo = flag
					};
				}
			}
		}

		private static void StartCarry(HeavyCargo c, int back, int front)
		{
			ulong networkObjectId = ((NetworkBehaviour)c).NetworkObjectId;
			if (!FirstValue.ContainsKey(networkObjectId))
			{
				FirstValue[networkObjectId] = ((GrabbableObject)c).scrapValue;
			}
			HostCarry hostCarry = new HostCarry
			{
				Cargo = c,
				StartedAt = Time.realtimeSinceStartup,
				NextTick = Time.realtimeSinceStartup + 0.1f
			};
			hostCarry.B.Idx = back;
			hostCarry.F.Idx = front;
			Active[networkObjectId] = hostCarry;
			Net.BroadcastLift(networkObjectId, back, front, ((GrabbableObject)c).scrapValue);
			ApplyLift(networkObjectId, back, front, ((GrabbableObject)c).scrapValue);
			Plugin.Log.LogInfo((object)("HeavyScrap host: lift " + ((GrabbableObject)c).itemProperties.itemName + " back=" + HeavyCargo.Player(back)?.playerUsername + " front=" + HeavyCargo.Player(front)?.playerUsername));
		}

		internal static void HostState(int player, ulong id, Vector3 pos, Vector3 vel, byte flags, float rtt)
		{
			//IL_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_004a: Unknown result type (might be due to invalid IL or missing references)
			//IL_004b: Unknown result type (might be due to invalid IL or missing references)
			if (Active.TryGetValue(id, out var value))
			{
				Side side = ((value.B.Idx == player) ? value.B : ((value.F.Idx == player) ? value.F : null));
				if (side != null)
				{
					side.Pos = pos;
					side.Vel = vel;
					side.Flags = flags;
					side.Rtt = rtt;
					side.RecvAt = Time.realtimeSinceStartup;
				}
			}
		}

		internal static void HostJumped(int player, ulong id)
		{
			if (Active.TryGetValue(id, out var value) && (value.B.Idx == player || value.F.Idx == player))
			{
				HostDrop(value, DropReason.Jumped);
			}
		}

		internal static void HostLetGo(int player, ulong id)
		{
			if (Active.TryGetValue(id, out var value) && (value.B.Idx == player || value.F.Idx == player))
			{
				HostDrop(value, DropReason.LetGo);
			}
		}

		internal static void HostDropAll(DropReason r)
		{
			foreach (HostCarry item in Active.Values.ToList())
			{
				HostDrop(item, r);
			}
		}

		internal static void HostDrop(HeavyCargo c, DropReason r)
		{
			if ((Object)(object)c != (Object)null && Active.TryGetValue(((NetworkBehaviour)c).NetworkObjectId, out var value))
			{
				HostDrop(value, r);
			}
		}

		private static void HostDrop(HostCarry hc, DropReason reason)
		{
			//IL_0093: 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_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ac: 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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0104: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ec: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c8: Unknown result type (might be due to invalid IL or missing references)
			HeavyCargo cargo = hc.Cargo;
			ulong networkObjectId = ((NetworkBehaviour)cargo).NetworkObjectId;
			Active.Remove(networkObjectId);
			int value;
			int num = (FirstValue.TryGetValue(networkObjectId, out value) ? value : ((GrabbableObject)cargo).scrapValue);
			int num2 = Mathf.RoundToInt((float)num * Plugin.ValueFloor.Value);
			int num3 = ((GrabbableObject)cargo).scrapValue;
			int num4;
			if (reason != DropReason.RoundOver && reason != DropReason.SetDown && reason != DropReason.Sold)
			{
				num4 = (hc.Solo ? 1 : 0);
				if (num4 == 0)
				{
					num3 = Mathf.Max(Mathf.Min(num3, num2), num3 - Mathf.RoundToInt((float)num * Plugin.DropPenalty.Value));
				}
			}
			else
			{
				num4 = 1;
			}
			RaycastHit val = default(RaycastHit);
			Vector3 floor = (Physics.Raycast(((Component)cargo).transform.position + Vector3.up * 0.5f, Vector3.down, ref val, 30f, 268437760, (QueryTriggerInteraction)1) ? ((RaycastHit)(ref val)).point : ((Component)cargo).transform.position);
			if (_floorOverride.HasValue)
			{
				floor = _floorOverride.Value;
				_floorOverride = null;
			}
			float y = ((Component)cargo).transform.eulerAngles.y;
			if (num4 == 0)
			{
				PendingNoise.Add(networkObjectId);
			}
			string text = $"{reason} after {Time.realtimeSinceStartup - hc.StartedAt:F1} s, tilt {hc.Tilt:F2}, gap {hc.LastGap:F2} (slack {hc.LastSlack:F2}), rules [{hc.LastRules}], value {((GrabbableObject)cargo).scrapValue} -> {num3}";
			DropLog.Add(text);
			Plugin.Log.LogInfo((object)("HeavyScrap host: drop " + text));
			Net.BroadcastDrop(networkObjectId, floor, y, num3, reason);
			ApplyDrop(networkObjectId, floor, y, num3, reason);
		}

		internal static void OnCargoHitGround(HeavyCargo c)
		{
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			if ((Object)(object)c != (Object)null && c.CrashPending)
			{
				c.CrashPending = false;
				Sfx.Play(c, Registry.Def(c.Kind)?.Crash ?? "crash_metal", 1f);
			}
			if ((Object)(object)c == (Object)null || !Net.IsHost || !PendingNoise.Remove(((NetworkBehaviour)c).NetworkObjectId))
			{
				return;
			}
			float value = Plugin.DropNoiseRange.Value;
			if (value > 0f)
			{
				RoundManager instance = RoundManager.Instance;
				if (instance != null)
				{
					instance.PlayAudibleNoise(((Component)c).transform.position, value, 1f, 0, ((GrabbableObject)c).isInShipRoom && StartOfRound.Instance.hangarDoorsClosed, 0);
				}
			}
		}

		internal static void OnCargoGone(HeavyCargo c)
		{
			if (!((Object)(object)c == (Object)null))
			{
				if ((Object)(object)LocalCargo == (Object)(object)c)
				{
					LocalRelease();
				}
				ShownTilt.Remove(c);
				if (Net.IsHost)
				{
					Active.Remove(((NetworkBehaviour)c).NetworkObjectId);
					Claims.Remove(((NetworkBehaviour)c).NetworkObjectId);
				}
			}
		}

		internal static void ResetAll()
		{
			LocalRelease();
			ShownTilt.Clear();
			Claims.Clear();
			SlammedAt.Clear();
			NextScrapeSound.Clear();
			Active.Clear();
			FirstValue.Clear();
			PendingNoise.Clear();
			Kins.Clear();
			Rtt = 0f;
		}

		private static void Estimate(Side s, out Vector3 pos, out Vector3 vel, out bool sprint, out bool grounded)
		{
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0055: Unknown result type (might be due to invalid IL or missing references)
			//IL_005a: 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_00c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB val = HeavyCargo.Player(s.Idx);
			PlayerControllerB me = Me;
			if ((Object)(object)val == (Object)(object)me || s.RecvAt < 0f || Time.realtimeSinceStartup - s.RecvAt > 1f)
			{
				Kin kin = KinOf(val);
				pos = ((Component)val).transform.position;
				vel = kin.Vel;
				sprint = val.isSprinting;
				grounded = !((Object)(object)val == (Object)(object)me) || val.thisController.isGrounded;
			}
			else
			{
				float num = Mathf.Min(0.35f, s.Rtt * 0.5f + (Time.realtimeSinceStartup - s.RecvAt));
				pos = s.Pos + new Vector3(s.Vel.x, 0f, s.Vel.z) * num;
				vel = s.Vel;
				sprint = (s.Flags & 1) != 0;
				grounded = (s.Flags & 2) != 0;
			}
		}

		private static void HostTick(HostCarry hc)
		{
			//IL_014b: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_014e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0153: Unknown result type (might be due to invalid IL or missing references)
			//IL_016a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0178: Unknown result type (might be due to invalid IL or missing references)
			//IL_017d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0188: Unknown result type (might be due to invalid IL or missing references)
			//IL_018f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0196: Unknown result type (might be due to invalid IL or missing references)
			//IL_019b: Unknown result type (might be due to invalid IL or missing references)
			//IL_032d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0334: Unknown result type (might be due to invalid IL or missing references)
			//IL_0339: Unknown result type (might be due to invalid IL or missing references)
			//IL_033b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0357: Unknown result type (might be due to invalid IL or missing references)
			//IL_0396: Unknown result type (might be due to invalid IL or missing references)
			HeavyCargo cargo = hc.Cargo;
			PlayerControllerB val = HeavyCargo.Player(hc.B.Idx);
			PlayerControllerB val2 = HeavyCargo.Player(hc.F.Idx);
			if ((Object)(object)cargo == (Object)null)
			{
				return;
			}
			if ((Object)(object)val == (Object)null || (Object)(object)val2 == (Object)null)
			{
				HostDrop(hc, DropReason.CarrierLeft);
				return;
			}
			PlayerControllerB[] array = (PlayerControllerB[])(object)new PlayerControllerB[2] { val, val2 };
			foreach (PlayerControllerB val3 in array)
			{
				if (val3.isPlayerDead)
				{
					HostDrop(hc, DropReason.CarrierDown);
					return;
				}
				if ((Object)(object)val3.inAnimationWithEnemy != (Object)null)
				{
					HostDrop(hc, DropReason.Grabbed);
					return;
				}
				if (!val3.isPlayerControlled || !Net.NM.ConnectedClientsIds.Contains(val3.actualClientId))
				{
					HostDrop(hc, DropReason.CarrierLeft);
					return;
				}
			}
			if (hc.Solo)
			{
				HostDragTick(hc, val);
				return;
			}
			if (Time.realtimeSinceStartup < hc.GraceUntil)
			{
				hc.StopFor = (hc.WallFor = (hc.AirFor = 0f));
				hc.ApartTicks = 0;
				return;
			}
			if (val.isInsideFactory != val2.isInsideFactory)
			{
				HostDrop(hc, DropReason.SplitUp);
				return;
			}
			Estimate(hc.B, out var pos, out var vel, out var sprint, out var grounded);
			Estimate(hc.F, out var pos2, out var vel2, out var sprint2, out var grounded2);
			Vector3 val4 = pos2 - pos;
			val4.y = 0f;
			float magnitude = ((Vector3)(ref val4)).magnitude;
			Vector2 val5 = new Vector2(vel.x, vel.z);
			float magnitude2 = ((Vector2)(ref val5)).magnitude;
			val5 = new Vector2(vel2.x, vel2.z);
			float magnitude3 = ((Vector2)(ref val5)).magnitude;
			float num = Mathf.Max(hc.B.Rtt, hc.F.Rtt);
			float num2 = 0.25f + 0.5f * Mathf.Max(magnitude2, magnitude3) * (num * 0.5f + 0.1f);
			hc.LastGap = magnitude;
			hc.LastSlack = num2;
			if (magnitude > 3.4f + num2)
			{
				if (++hc.ApartTicks >= 2)
				{
					hc.LastRules = "apart";
					HostDrop(hc, DropReason.PulledApart);
					return;
				}
			}
			else
			{
				hc.ApartTicks = 0;
			}
			float num3 = 0f;
			List<string> list = new List<string>();
			float num4 = magnitude - (3f + num2);
			if (num4 > 0f)
			{
				num3 += 1.5f * num4;
				list.Add("far");
			}
			float num5 = 1.4f - num2 - magnitude;
			if (num5 > 0f)
			{
				num3 += 1.5f * num5;
				list.Add("close");
			}
			if (sprint || sprint2)
			{
				num3 += 0.6f;
				list.Add("sprint");
			}
			bool flag = (magnitude2 < 0.35f && magnitude3 > 1.3f) || (magnitude3 < 0.35f && magnitude2 > 1.3f);
			hc.StopFor = (flag ? (hc.StopFor + 0.1f) : 0f);
			if (hc.StopFor > 0.4f)
			{
				num3 += 0.7f;
				list.Add("stop");
			}
			Vector3 val6 = cargo.HandlePoint(0);
			Vector3 val7 = cargo.HandlePoint(1);
			RaycastHit val8 = default(RaycastHit);
			bool flag2 = Physics.Linecast(val6, val7, ref val8, StartOfRound.Instance.collidersAndRoomMask, (QueryTriggerInteraction)1);
			if (flag2 && NearDesk(((RaycastHit)(ref val8)).point))
			{
				flag2 = false;
			}
			if (flag2 && hc.WallFor == 0f)
			{
				ManualLogSource log = Plugin.Log;
				Collider collider = ((RaycastHit)(ref val8)).collider;
				log.LogInfo((object)$"HeavyScrap host: handle line hits {((collider != null) ? ((Object)collider).name : null)} at {((RaycastHit)(ref val8)).point}");
			}
			hc.WallFor = (flag2 ? (hc.WallFor + 0.1f) : 0f);
			if (hc.WallFor > 0.3f)
			{
				num3 += 0.9f;
				list.Add("wall");
			}
			bool flag3 = (((Object)(object)val == (Object)(object)Me) ? val.isCrouching : ((hc.B.Flags & 4) != 0));
			bool flag4 = (((Object)(object)val2 == (Object)(object)Me) ? val2.isCrouching : ((hc.F.Flags & 4) != 0));
			hc.CrouchFor = ((flag3 && flag4) ? (hc.CrouchFor + 0.1f) : 0f);
			if (hc.CrouchFor >= 1f)
			{
				hc.LastRules = "crouch";
				HostDrop(hc, DropReason.SetDown);
				return;
			}
			bool flag5 = !grounded || !grounded2;
			hc.AirFor = (flag5 ? (hc.AirFor + 0.1f) : 0f);
			if (hc.AirFor > 0.6f)
			{
				num3 += 0.8f;
				list.Add("air");
			}
			hc.Tilt = Mathf.Clamp01(hc.Tilt + ((num3 > 0f) ? num3 : (-0.35f)) * 0.1f);
			hc.LastRules = string.Join(",", list);
			foreach (string item in list)
			{
				hc.RuleTime[item] = (hc.RuleTime.TryGetValue(item, out var value) ? value : 0f) + 0.1f;
			}
			hc.Ticks++;
			hc.GapSum += magnitude;
			hc.GapMin = Mathf.Min(hc.GapMin, magnitude);
			hc.GapMax = Mathf.Max(hc.GapMax, magnitude);
			hc.TiltMax = Mathf.Max(hc.TiltMax, hc.Tilt);
			if (Plugin.VerboseLog.Value && Time.realtimeSinceStartup >= hc.NextLog)
			{
				hc.NextLog = Time.realtimeSinceStartup + 1f;
				Plugin.Log.LogInfo((object)$"HeavyScrap host: tilt {hc.Tilt:F2} gap {magnitude:F2} slack {num2:F2} speed {magnitude2:F1}/{magnitude3:F1} rtt {num * 1000f:F0} ms [{hc.LastRules}]");
			}
			if (hc.Tilt >= 1f)
			{
				HostDrop(hc, DropReason.Tilt);
				return;
			}
			ShownTilt[cargo] = hc.Tilt;
			Net.SendTilt(((NetworkBehaviour)cargo).NetworkObjectId, hc.Tilt, hc.B.Idx);
			Net.SendTilt(((NetworkBehaviour)cargo).NetworkObjectId, hc.Tilt, hc.F.Idx);
		}

		private static void HostDragTick(HostCarry hc, PlayerControllerB p)
		{
			//IL_0025: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = (((Object)(object)p != (Object)(object)Me && hc.B.RecvAt > 0f) ? hc.B.Vel : KinOf(p).Vel);
			Vector2 val2 = new Vector2(val.x, val.z);
			bool num = ((Vector2)(ref val2)).magnitude > 0.3f;
			float realtimeSinceStartup = Time.realtimeSinceStartup;
			if (num && realtimeSinceStartup >= hc.NextScrape)
			{
				hc.NextScrape = realtimeSinceStartup + 2f;
				DragNoises++;
				RoundManager instance = RoundManager.Instance;
				if (instance != null)
				{
					instance.PlayAudibleNoise(((Component)hc.Cargo).transform.position, 15f, 0.6f, 0, false, 0);
				}
			}
		}

		internal static void Tick()
		{
			//IL_034f: Unknown result type (might be due to invalid IL or missing references)
			//IL_035a: Unknown result type (might be due to invalid IL or missing references)
			if (!Net.Online)
			{
				if ((Object)(object)LocalCargo != (Object)null || Active.Count > 0)
				{
					ResetAll();
				}
				return;
			}
			float realtimeSinceStartup = Time.realtimeSinceStartup;
			PlayerControllerB me = Me;
			HeavyCargo[] array = Object.FindObjectsOfType<HeavyCargo>();
			foreach (HeavyCargo heavyCargo in array)
			{
				if (heavyCargo.Carried)
				{
					TrackKin(heavyCargo.Back);
					TrackKin(heavyCargo.Front);
				}
			}
			if ((Object)(object)me != (Object)null)
			{
				TrackKin(me);
			}
			ScrapeSounds();
			if (Net.IsHost)
			{
				foreach (KeyValuePair<ulong, Claim> kv in Claims.ToList())
				{
					if (!(realtimeSinceStartup - kv.Value.At > 0.75f))
					{
						continue;
					}
					Claims.Remove(kv.Key);
					if (kv.Value.Solo)
					{
						HeavyCargo heavyCargo2 = Find(kv.Key);
						PlayerControllerB val = HeavyCargo.Player(kv.Value.Player);
						if ((Object)(object)heavyCargo2 != (Object)null && !heavyCargo2.Carried && (Object)(object)val != (Object)null && val.isPlayerControlled && !val.isPlayerDead && !Active.Values.Any((HostCarry h) => h.B.Idx == kv.Value.Player || h.F.Idx == kv.Value.Player))
						{
							StartCarry(heavyCargo2, kv.Value.Player, kv.Value.Player);
						}
					}
					else
					{
						SlammedAt[(kv.Key, kv.Value.Player)] = realtimeSinceStartup;
						Net.BroadcastSlam(kv.Key, kv.Value.Player);
						ApplySlam(kv.Key, kv.Value.Player);
					}
				}
				foreach (HostCarry item in Active.Values.ToList())
				{
					if (realtimeSinceStartup >= item.NextTick)
					{
						item.NextTick = realtimeSinceStartup + 0.1f;
						HostTick(item);
					}
				}
			}
			else if (realtimeSinceStartup >= _nextPing)
			{
				_nextPing = realtimeSinceStartup + 0.5f;
				Net.SendPing(realtimeSinceStartup);
			}
			if ((Object)(object)LocalCargo == (Object)null || (Object)(object)me == (Object)null)
			{
				return;
			}
			if ((Object)(object)LocalCargo == (Object)null || !LocalCargo.Carried)
			{
				LocalRelease();
				return;
			}
			if (me.isPlayerDead)
			{
				LocalRelease();
				return;
			}
			if (!Net.IsHost && realtimeSinceStartup >= _nextState)
			{
				_nextState = realtimeSinceStartup + 0.05f;
				byte flags = (byte)((me.isSprinting ? 1u : 0u) | (uint)(me.thisController.isGrounded ? 2 : 0) | (uint)(me.isCrouching ? 4 : 0));
				Net.SendState(((NetworkBehaviour)LocalCargo).NetworkObjectId, ((Component)me).transform.position, KinOf(me).Vel, flags, Rtt);
			}
			if (!LocalSolo)
			{
				KeepPose(me);
			}
			if (!LocalSolo)
			{
				Tether(me);
			}
		}

		private static void ScrapeSounds()
		{
			//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)
			HeavyCargo[] array = Object.FindObjectsOfType<HeavyCargo>();
			foreach (HeavyCargo heavyCargo in array)
			{
				bool flag = false;
				if (heavyCargo.Solo && (Object)(object)heavyCargo.Back != (Object)null)
				{
					Kin kin = KinOf(heavyCargo.Back);
					Vector2 val = new Vector2(kin.Vel.x, kin.Vel.z);
					flag = ((Vector2)(ref val)).magnitude >= 0.3f;
				}
				if (flag)
				{
					NextScrapeSound[heavyCargo] = Time.time + 0.35f;
				}
				float value;
				bool flag2 = heavyCargo.Solo && NextScrapeSound.TryGetValue(heavyCargo, out value) && Time.time < value;
				AudioSource loopSource = heavyCargo.LoopSource;
				if ((Object)(object)loopSource == (Object)null)
				{
					continue;
				}
				if (flag2 && !loopSource.isPlaying)
				{
					loopSource.clip = Assets.Sound("scrape");
					if ((Object)(object)loopSource.clip != (Object)null)
					{
						loopSource.volume = 0.8f;
						loopSource.Play();
					}
				}
				else if (!flag2 && loopSource.isPlaying)
				{
					loopSource.Stop();
				}
			}
			HeavyCargo localCargo = LocalCargo;
			if ((Object)(object)localCargo != (Object)null && !localCargo.Solo && TiltFor(localCargo) >= 0.7f && Time.time >= _nextCreak)
			{
				_nextCreak = Time.time + Random.Range(1.1f, 1.8f);
				Sfx.Play(localCargo, "creak", 0.9f);
			}
		}

		private static void Tether(PlayerControllerB me)
		{
			//IL_0083: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cf: 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_00d7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: 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_0134: Unknown result type (might be due to invalid IL or missing references)
			//IL_013e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0143: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB val = Partner();
			if (!((Object)(object)val == (Object)null) && !me.inSpecialInteractAnimation && ((Collider)me.thisController).enabled)
			{
				Vector3 pos;
				if (Net.IsHost && Active.TryGetValue(((NetworkBehaviour)LocalCargo).NetworkObjectId, out var value))
				{
					Estimate((value.B.Idx == (int)val.playerClientId) ? value.B : value.F, out pos, out var _, out var _, out var _);
				}
				else
				{
					Kin kin = KinOf(val);
					pos = ((Component)val).transform.position + new Vector3(kin.Vel.x, 0f, kin.Vel.z) * Mathf.Min(0.35f, Rtt * 0.5f + 0.1f);
				}
				Vector3 val2 = pos - ((Component)me).transform.position;
				val2.y = 0f;
				float magnitude = ((Vector3)(ref val2)).magnitude;
				if (!(magnitude <= 2.8f) && !(magnitude < 0.01f))
				{
					float num = Mathf.Min(0.9f, 1.5f * (magnitude - 2.8f));
					me.thisController.Move(val2 / magnitude * num * Time.deltaTime);
				}
			}
		}

		internal static HeavyCargo Find(ulong id)
		{
			NetworkManager nM = Net.NM;
			if (((nM != null) ? nM.SpawnManager : null) == null)
			{
				return null;
			}
			if (!nM.SpawnManager.SpawnedObjects.TryGetValue(id, out var value) || !((Object)(object)value != (Object)null))
			{
				return null;
			}
			return ((Component)value).GetComponent<HeavyCargo>();
		}

		private static void Rect(Rect r, Color c)
		{
			//IL_0000: Unknown result type (might be due to invalid IL or missing references)
			//IL_0005: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			Color color = GUI.color;
			GUI.color = c;
			GUI.DrawTexture(r, (Texture)(object)_px);
			GUI.color = color;
		}

		internal static void DrawHud()
		{
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_003e: Expected O, but got Unknown
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Expected O, but got Unknown
			//IL_0089: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: Expected O, but got Unknown
			//IL_00c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_04b3: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0140: 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_0169: Unknown result type (might be due to invalid IL or missing references)
			//IL_0215: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c8: Unknown result type (might be due to invalid IL or missing references)
			//IL_02dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f2: Unknown result type (might be due to invalid IL or missing references)
			//IL_0349: Unknown result type (might be due to invalid IL or missing references)
			//IL_034e: 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_031d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03fe: Unknown result type (might be due to invalid IL or missing references)
			//IL_0427: Unknown result type (might be due to invalid IL or missing references)
			//IL_045e: Unknown result type (might be due to invalid IL or missing references)
			if (_title == null)
			{
				_px = Texture2D.whiteTexture;
				_title = new GUIStyle(GUI.skin.label)
				{
					fontSize = 17,
					alignment = (TextAnchor)3,
					fontStyle = (FontStyle)1
				};
				_title.normal.textColor = Orange;
				_small = new GUIStyle(_title)
				{
					fontSize = 14,
					fontStyle = (FontStyle)0
				};
				_small.normal.textColor = new Color(1f, 0.75f, 0.5f);
				_tipStyle = new GUIStyle(GUI.skin.label)
				{
					fontSize = 16,
					alignment = (TextAnchor)4
				};
				_tipStyle.normal.textColor = Orange;
			}
			float num = Screen.width;
			float num2 = Screen.height;
			HeavyCargo localCargo = LocalCargo;
			if ((Object)(object)localCargo != (Object)null)
			{
				bool solo = localCargo.Solo;
				Rect r = default(Rect);
				((Rect)(ref r))..ctor(num / 2f - 270f, num2 - (solo ? 140f : 168f), 540f, solo ? 62f : 90f);
				Rect(r, new Color(0.05f, 0.03f, 0.02f, 0.72f));
				Rect(new Rect(((Rect)(ref r)).x, ((Rect)(ref r)).y, ((Rect)(ref r)).width, 2f), Orange);
				float num3 = ((Rect)(ref r)).x + 14f;
				float num4 = ((Rect)(ref r)).y + 6f;
				float num5 = ((Rect)(ref r)).width - 28f;
				string text = ((GrabbableObject)localCargo).itemProperties.itemName.ToUpperInvariant();
				if (solo)
				{
					GUI.Label(new Rect(num3, num4, num5, 24f), "DRAGGING " + text + " ALONE", _title);
					GUI.Label(new Rect(num3, num4 + 26f, num5, 22f), "slow and loud: monsters hear the scrape      [G] let go", _small);
				}
				else
				{
					GUI.Label(new Rect(num3, num4, num5, 24f), "CARRYING " + text + " with " + (Partner()?.playerUsername ?? "?") + " (" + ((LocalSide == 1) ? "you: front" : "you: back") + ")", _title);
					float num6 = TiltFor(localCargo);
					Rect r2 = default(Rect);
					((Rect)(ref r2))..ctor(num3 + 46f, num4 + 32f, num5 - 100f, 14f);
					GUI.Label(new Rect(num3, num4 + 28f, 46f, 22f), "TILT", _small);
					Rect(r2, new Color(1f, 1f, 1f, 0.12f));
					Color c = ((num6 < 0.4f) ? new Color(0.45f, 0.8f, 0.35f) : ((num6 < 0.7f) ? new Color(1f, 0.75f, 0.2f) : new Color(1f, 0.25f, 0.15f)));
					if (num6 >= 0.7f)
					{
						c.a = 0.65f + 0.35f * Mathf.Abs(Mathf.Sin(Time.time * 8f));
					}
					Rect(new Rect(((Rect)(ref r2)).x, ((Rect)(ref r2)).y, ((Rect)(ref r2)).width * Mathf.Clamp01(num6), ((Rect)(ref r2)).height), c);
					Rect(new Rect(((Rect)(ref r2)).x + ((Rect)(ref r2)).width * 0.7f, ((Rect)(ref r2)).y - 2f, 2f, ((Rect)(ref r2)).height + 4f), new Color(1f, 0.25f, 0.15f, 0.8f));
					GUI.Label(new Rect(((Rect)(ref r2)).xMax + 8f, num4 + 28f, 50f, 22f), $"{num6 * 100f:F0}%", _small);
					GUI.Label(new Rect(num3, num4 + 54f, num5, 22f), "both crouch 1 s: set down      [G] let go      walk in step, no jumping", _small);
				}
			}
			if (_tip != null && Time.realtimeSinceStartup < _tipUntil)
			{
				GUI.Label(new Rect(num / 2f - 350f, num2 - (((Object)(object)localCargo != (Object)null) ? 200f : 96f), 700f, 26f), _tip, _tipStyle);
			}
		}
	}
	internal static class Sfx
	{
		internal static readonly Dictionary<string, int> Played = new Dictionary<string, int>();

		internal static void Play(HeavyCargo c, string word, float volume)
		{
			if (!((Object)(object)c == (Object)null))
			{
				AudioClip val = Assets.Sound(word);
				AudioSource component = ((Component)c).GetComponent<AudioSource>();
				if (!((Object)(object)val == (Object)null) && !((Object)(object)component == (Object)null))
				{
					Played[word] = (Played.TryGetValue(word, out var value) ? value : 0) + 1;
					component.PlayOneShot(val, volume);
					WalkieTalkie.TransmitOneShotAudio(component, val, volume);
				}
			}
		}
	}
	internal class Runner : MonoBehaviour
	{
		private void Update()
		{
			try
			{
				Carry.Tick();
			}
			catch (Exception ex)
			{
				Plugin.Log.LogError((object)("HeavyScrap tick: " + ex));
			}
		}

		private void OnGUI()
		{
			Carry.DrawHud();
		}
	}
	internal static class DebugSpawn
	{
		internal static HeavyCargo SpawnInFront(string key = "Safe")
		{
			//IL_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0075: 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_0084: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			PlayerControllerB val = GameNetworkManager.Instance?.localPlayerController;
			CargoDef cargoDef = Registry.Def(key);
			if ((Object)(object)val == (Object)null || !Net.IsHost || (Object)(object)cargoDef?.Prefab == (Object)null)
			{
				return null;
			}
			int value = Mathf.RoundToInt((float)Random.Range(cargoDef.MinValue, cargoDef.MaxValue + 1) * 0.4f);
			return Spawn(((Component)val).transform.position + Flat(((Component)val).transform.forward) * 2.5f, Quaternion.LookRotation(Flat(((Component)val).transform.right)), value, cargoDef);
		}

		internal static HeavyCargo Spawn(Vector3 near, Quaternion rot, int value, CargoDef def = null)
		{
			//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_0029: Unknown result type (might be due to invalid IL or missing references)
			//IL_002e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: 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_0035: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			//IL_0049: Unknown result type (might be due to invalid IL or missing references)
			//IL_0084: 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_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_007d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			def = def ?? Registry.Defs[0];
			if ((Object)(object)def.Prefab == (Object)null)
			{
				return null;
			}
			Vector3 val = near + Vector3.up * 0.5f;
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(near + Vector3.up * 1.5f, Vector3.down, ref val2, 6f, 268437760, (QueryTriggerInteraction)1))
			{
				val = ((RaycastHit)(ref val2)).point + Vector3.up * 0.3f;
			}
			GameObject obj = Object.Instantiate<GameObject>(def.Prefab, val, rot);
			NetworkObject component = obj.GetComponent<NetworkObject>();
			component.Spawn(false);
			HeavyCargo component2 = obj.GetComponent<HeavyCargo>();
			((GrabbableObject)component2).SetScrapValue(value);
			RoundManager instance = RoundManager.Instance;
			if (instance != null)
			{
				instance.SyncScrapValuesClientRpc((NetworkObjectReference[])(object)new NetworkObjectReference[1] { NetworkObjectReference.op_Implicit(component) }, new int[1] { value });
			}
			Carry.Tip($"Spawned a test {def.Name.ToLowerInvariant()} (${value}).");
			Plugin.Log.LogInfo((object)$"HeavyScrap: debug spawn {((GrabbableObject)component2).itemProperties.itemName} ${value} at {val}");
			return component2;
		}

		private static Vector3 Flat(Vector3 v)
		{
			//IL_0022: 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)
			v.y = 0f;
			if (!(((Vector3)(ref v)).sqrMagnitude < 0.001f))
			{
				return ((Vector3)(ref v)).normalized;
			}
			return Vector3.forward;
		}
	}
	public class HeavyCargo : PhysicsProp
	{
		public string Kind = "Safe";

		public float Pounds = 160f;

		public float HalfLength = 0.4f;

		public float HandleHeight = 0.56f;

		public float Height = 0.9f;

		internal bool CrashPending;

		private AudioSource _loop;

		internal int BackIdx = -1;

		internal int FrontIdx = -1;

		internal int LastBack = -1;

		internal float LiftedAt;

		internal Vector3 SmoothedMid;

		private bool _hasSmoothed;

		internal const float CarryHeight = 0.62f;

		internal AudioSource LoopSource
		{
			get
			{
				if ((Object)(object)_loop == (Object)null)
				{
					AudioSource[] components = ((Component)this).GetComponents<AudioSource>();
					_loop = ((components.Length > 1) ? components[1] : null);
				}
				return _loop;
			}
		}

		internal bool Carried
		{
			get
			{
				if (BackIdx >= 0)
				{
					return FrontIdx >= 0;
				}
				return false;
			}
		}

		internal bool Solo
		{
			get
			{
				if (Carried)
				{
					return BackIdx == FrontIdx;
				}
				return false;
			}
		}

		internal PlayerControllerB Back
		{
			get
			{
				if (!Carried)
				{
					return null;
				}
				return Player(BackIdx);
			}
		}

		internal PlayerControllerB Front
		{
			get
			{
				if (!Carried)
				{
					return null;
				}
				return Player(FrontIdx);
			}
		}

		internal static PlayerControllerB Player(int i)
		{
			PlayerControllerB[] array = StartOfRound.Instance?.allPlayerScripts;
			if (array == null || i < 0 || i >= array.Length)
			{
				return null;
			}
			return array[i];
		}

		public override void InteractItem()
		{
			((GrabbableObject)this).InteractItem();
			Carry.LocalTryLift(this);
		}

		public override void Update()
		{
			if (!Carried)
			{
				((GrabbableObject)this).Update();
			}
		}

		public override void LateUpdate()
		{
			//IL_004d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: Unknown result type (might be due to invalid IL or missing references)
			//IL_005e: Unknown result type (might be due to invalid IL or missing references)
			//IL_005f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0060: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Unknown result type (might be due to invalid IL or missing references)
			//IL_0066: Unknown result type (might be due to invalid IL or missing references)
			//IL_008f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Unknown result type (might be due to invalid IL or missing references)
			//IL_0091: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0088: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e6: Unknown result type (might be due to invalid IL or missing references)
			//IL_0120: Unknown result type (might be due to invalid IL or missing references)
			//IL_0125: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0138: Unknown result type (might be due to invalid IL or missing references)
			//IL_014a: 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_0154: 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_0181: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a5: Unknown result type (might be due to invalid IL or missing references)
			if (!Carried)
			{
				_hasSmoothed = false;
				((GrabbableObject)this).LateUpdate();
				return;
			}
			PlayerControllerB back = Back;
			PlayerControllerB front = Front;
			if ((Object)(object)back == (Object)null || (Object)(object)front == (Object)null)
			{
				return;
			}
			if (Solo)
			{
				PlaceDragged(back);
				return;
			}
			Vector3 position = ((Component)back).transform.position;
			Vector3 position2 = ((Component)front).transform.position;
			Vector3 val = position2 - position;
			val.y = 0f;
			if (((Vector3)(ref val)).sqrMagnitude < 0.01f)
			{
				val = ((Component)back).transform.forward;
			}
			Vector3 val2 = (position + position2) * 0.5f + Vector3.up * 0.62f;
			SmoothedMid = (_hasSmoothed ? Vector3.Lerp(SmoothedMid, val2, 1f - Mathf.Exp(-18f * Time.deltaTime)) : val2);
			_hasSmoothed = true;
			float num = Mathf.Sin((Time.time - LiftedAt) * 6.5f) * 0.02f;
			float num2 = Carry.TiltFor(this);
			((Component)this).transform.position = SmoothedMid + Vector3.up * (num - HangDepth());
			((Component)this).transform.rotation = Quaternion.LookRotation(((Vector3)(ref val)).normalized, Vector3.up) * Quaternion.Euler(0f, 0f, num2 * 12f * Mathf.Sin(Time.time * 9f));
			if ((Object)(object)((GrabbableObject)this).radarIcon != (Object)null)
			{
				((GrabbableObject)this).radarIcon.position = ((Component)this).transform.position;
			}
		}

		private void PlaceDragged(PlayerControllerB p)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: Unknown result type (might be due to invalid IL or missing references)
			//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_0051: Unknown result type (might be due to invalid IL or missing references)
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_002b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ae: Unknown result type (might be due to invalid IL or missing references)
			//IL_00af: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00be: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_0103: Unknown result type (might be due to invalid IL or missing references)
			//IL_0108: Unknown result type (might be due to invalid IL or missing references)
			//IL_008e: Unknown result type (might be due to invalid IL or missing references)
			//IL_012c: Unknown result type (might be due to invalid IL or missing references)
			Vector3 forward = ((Component)p).transform.forward;
			forward.y = 0f;
			if (((Vector3)(ref forward)).sqrMagnitude < 0.01f)
			{
				forward = Vector3.forward;
			}
			((Vector3)(ref forward)).Normalize();
			Vector3 val = ((Component)p).transform.position - forward * (0.55f + HalfLength + 0.15f);
			RaycastHit val2 = default(RaycastHit);
			if (Physics.Raycast(val + Vector3.up * 1.2f, Vector3.down, ref val2, 3f, 268437760, (QueryTriggerInteraction)1))
			{
				val.y = ((RaycastHit)(ref val2)).point.y;
			}
			((Component)this).transform.position = Vector3.Lerp(((Component)this).transform.position, val + Vector3.up * 0.02f, 1f - Mathf.Exp(-14f * Time.deltaTime));
			((Component)this).transform.rotation = Quaternion.LookRotation(forward, Vector3.up) * Quaternion.Euler(-6f, 0f, 0f);
			if ((Object)(object)((GrabbableObject)this).radarIcon != (Object)null)
			{
				((GrabbableObject)this).radarIcon.position = ((Component)this).transform.position;
			}
		}

		private float HangDepth()
		{
			return Mathf.Min(HandleHeight, 0.5f);
		}

		internal Vector3 HandlePoint(int side)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0033: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: Unknown result type (might be due to invalid IL or missing references)
			//IL_003d: Unknown result type (might be due to invalid IL or missing references)
			return ((Component)this).transform.position + ((Component)this).transform.rotation * new Vector3(0f, HandleHeight, (side == 0) ? (0f - HalfLength) : HalfLength);
		}

		internal Vector3 StandPoint(int side, float gap = 2.2f)
		{
			//IL_0006: Unknown result type (might be due to invalid IL or missing references)
			//IL_000b: 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_002a: 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_0044: Unknown result type (might be due to invalid IL or missing references)
			Vector3 forward = ((Component)this).transform.forward;
			forward.y = 0f;
			((Vector3)(ref forward)).Normalize();
			return ((Component)this).transform.position + forward * ((side == 0) ? ((0f - gap) / 2f) : (gap / 2f));
		}

		internal void FallTo(Vector3 floorPoint, float yaw)
		{
			//IL_0011: 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_0052: Unknown result type (might be due to invalid IL or missing references)
			//IL_0035: Unknown result type (might be due to invalid IL or missing references)
			//IL_0057: Unknown result type (might be due to invalid IL or missing references)
			//IL_005c: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: Unknown result type (might be due to invalid IL or missing references)
			//IL_006d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0072: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_009a: Unknown result type (might be due to invalid IL or missing references)
			//IL_009b: 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_00a0: Unknown result type (might be due to invalid IL or missing references)
			((Component)this).transform.rotation = Quaternion.Euler(0f, yaw, 0f);
			((GrabbableObject)this).startFallingPosition = (((Object)(object)((Component)this).transform.parent != (Object)null) ? ((Component)this).transform.parent.InverseTransformPoint(((Component)this).transform.position) : ((Component)this).transform.position);
			Vector3 val = floorPoint + Vector3.up * ((GrabbableObject)this).itemProperties.verticalOffset;
			((GrabbableObject)this).targetFloorPosition = (((Object)(object)((Component)this).transform.parent != (Object)null) ? ((Component)this).transform.parent.InverseTransformPoint(val) : val);
			((GrabbableObject)this).floorYRot = -1;
			((GrabbableObject)this).fallTime = 0f;
			((GrabbableObject)this).hasHitGround = false;
			((GrabbableObject)this).reachedFloorTarget = false;
		}

		public override void OnHitGround()
		{
			((GrabbableObject)this).OnHitGround();
			Carry.OnCargoHitGround(this);
		}

		public override void OnNetworkDespawn()
		{
			Carry.OnCargoGone(this);
			((NetworkBehaviour)this).OnNetworkDespawn();
		}

		public override void OnDestroy()
		{
			Carry.OnCargoGone(this);
			((GrabbableObject)this).OnDestroy();
		}
	}
	internal static class MenuHooks
	{
		internal const string ModMenuGuid = "daniel.lethalcompany.modmenu";

		[MethodImpl(MethodImplOptions.NoInlining)]
		internal static void Register()
		{
			CargoDef[] defs = Registry.Defs;
			foreach (CargoDef cargoDef in defs)
			{
				CargoDef d = cargoDef;
				string noun = d.Key.ToLowerInvariant();
				MenuApi.Button("Heavy Scrap", "Spawn " + noun, (Func<string>)delegate
				{
					HeavyCargo heavyCargo = DebugSpawn.SpawnInFront(d.Key);
					return (!((Object)(object)heavyCargo != (Object)null)) ? null : $"spawned a {noun} (${((GrabbableObject)heavyCargo).scrapValue})";
				}, true, true, (Func<string>)(() => (!((Object)(object)d.Prefab == (Object)null)) ? ((!((Object)(object)GameNetworkManager.Instance?.localPlayerController == (Object)null)) ? null : "not in a game") : (noun + " not built")), (string)null);
			}
		}
	}
	internal static class Net
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static HandleNamedMessageDelegate <>9__20_0;

			public static HandleNamedMessageDelegate <>9__20_1;

			public static HandleNamedMessageDelegate <>9__20_2;

			public static HandleNamedMessageDelegate <>9__20_3;

			public static HandleNamedMessageDelegate <>9__20_5;

			public static HandleNamedMessageDelegate <>9__20_6;

			public static HandleNamedMessageDelegate <>9__20_7;

			public static HandleNamedMessageDelegate <>9__20_8;

			public static HandleNamedMessageDelegate <>9__20_9;

			public static HandleNamedMessageDelegate <>9__20_10;

			public static HandleNamedMessageDelegate <>9__20_11;

			public static HandleNamedMessageDelegate <>9__20_12;

			internal void <Register>b__20_0(ulong s, FastBufferReader r)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: 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)
				if (IsHost)
				{
					ulong id = default(ulong);
					((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref id, default(ForPrimitives));
					byte side = default(byte);
					((FastBufferReader)(ref r)).ReadValueSafe<byte>(ref side, default(ForPrimitives));
					Carry.HostLiftRequest(PlayerOf(s), id, side);
				}
			}

			internal void <Register>b__20_1(ulong s, FastBufferReader r)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0033: Unknown result type (might be due to invalid IL or missing references)
				//IL_0039: 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_004c: Unknown result type (might be due to invalid IL or missing references)
				//IL_005a: Unknown result type (might be due to invalid IL or missing references)
				//IL_005b: Unknown result type (might be due to invalid IL or missing references)
				if (IsHost)
				{
					ulong id = default(ulong);
					((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref id, default(ForPrimitives));
					Vector3 pos = default(Vector3);
					((FastBufferReader)(ref r)).ReadValueSafe(ref pos);
					Vector3 vel = default(Vector3);
					((FastBufferReader)(ref r)).ReadValueSafe(ref vel);
					byte flags = default(byte);
					((FastBufferReader)(ref r)).ReadValueSafe<byte>(ref flags, default(ForPrimitives));
					ushort num = default(ushort);
					((FastBufferReader)(ref r)).ReadValueSafe<ushort>(ref num, default(ForPrimitives));
					Carry.HostState(PlayerOf(s), id, pos, vel, flags, (float)(int)num / 1000f);
				}
			}

			internal void <Register>b__20_2(ulong s, FastBufferReader r)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				if (IsHost)
				{
					ulong id = default(ulong);
					((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref id, default(ForPrimitives));
					Carry.HostJumped(PlayerOf(s), id);
				}
			}

			internal void <Register>b__20_3(ulong s, FastBufferReader r)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				if (IsHost)
				{
					ulong id = default(ulong);
					((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref id, default(ForPrimitives));
					Carry.HostLetGo(PlayerOf(s), id);
				}
			}

			internal void <Register>b__20_5(ulong s, FastBufferReader r)
			{
				//IL_0006: Unknown result type (might be due to invalid IL or missing references)
				//IL_000c: Unknown result type (might be due to invalid IL or missing references)
				float t = default(float);
				((FastBufferReader)(ref r)).ReadValueSafe<float>(ref t, default(ForPrimitives));
				Carry.OnPong(t);
			}

			internal void <Register>b__20_6(ulong s, FastBufferReader r)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0021: Unknown result type (might be due to invalid IL or missing references)
				//IL_0027: 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_003a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0047: Unknown result type (might be due to invalid IL or missing references)
				//IL_004d: Unknown result type (might be due to invalid IL or missing references)
				if (!IsHost)
				{
					ulong id = default(ulong);
					((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref id, default(ForPrimitives));
					int back = default(int);
					((FastBufferReader)(ref r)).ReadValueSafe<int>(ref back, default(ForPrimitives));
					int front = default(int);
					((FastBufferReader)(ref r)).ReadValueSafe<int>(ref front, default(ForPrimitives));
					int value = default(int);
					((FastBufferReader)(ref r)).ReadValueSafe<int>(ref value, default(ForPrimitives));
					Carry.ApplyLift(id, back, front, value);
				}
			}

			internal void <Register>b__20_7(ulong s, FastBufferReader r)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: 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)
				if (!IsHost)
				{
					ulong id = default(ulong);
					((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref id, default(ForPrimitives));
					int player = default(int);
					((FastBufferReader)(ref r)).ReadValueSafe<int>(ref player, default(ForPrimitives));
					Carry.ApplySlam(id, player);
				}
			}

			internal void <Register>b__20_8(ulong s, FastBufferReader r)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: 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)
				if (!IsHost)
				{
					ulong id = default(ulong);
					((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref id, default(ForPrimitives));
					byte b = default(byte);
					((FastBufferReader)(ref r)).ReadValueSafe<byte>(ref b, default(ForPrimitives));
					Carry.ApplyTilt(id, (float)(int)b / 255f);
				}
			}

			internal void <Register>b__20_9(ulong s, FastBufferReader r)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_0030: Unknown result type (might be due to invalid IL or missing references)
				//IL_003d: Unknown result type (might be due to invalid IL or missing references)
				//IL_0043: 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_0056: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				if (!IsHost)
				{
					ulong id = default(ulong);
					((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref id, default(ForPrimitives));
					Vector3 floor = default(Vector3);
					((FastBufferReader)(ref r)).ReadValueSafe(ref floor);
					float yaw = default(float);
					((FastBufferReader)(ref r)).ReadValueSafe<float>(ref yaw, default(ForPrimitives));
					int value = default(int);
					((FastBufferReader)(ref r)).ReadValueSafe<int>(ref value, default(ForPrimitives));
					byte reason = default(byte);
					((FastBufferReader)(ref r)).ReadValueSafe<byte>(ref reason, default(ForPrimitives));
					Carry.ApplyDrop(id, floor, yaw, value, (DropReason)reason);
				}
			}

			internal void <Register>b__20_10(ulong s, FastBufferReader r)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: 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)
				if (IsHost)
				{
					ulong id = default(ulong);
					((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref id, default(ForPrimitives));
					ulong doorId = default(ulong);
					((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref doorId, default(ForPrimitives));
					Carry.HostDoor(PlayerOf(s), id, doorId);
				}
			}

			internal void <Register>b__20_11(ulong s, FastBufferReader r)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				//IL_0020: 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)
				if (!IsHost)
				{
					ulong id = default(ulong);
					((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref id, default(ForPrimitives));
					ulong doorId = default(ulong);
					((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref doorId, default(ForPrimitives));
					Carry.ApplyDoorGo(id, doorId);
				}
			}

			internal void <Register>b__20_12(ulong s, FastBufferReader r)
			{
				//IL_000e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0014: Unknown result type (might be due to invalid IL or missing references)
				if (IsHost)
				{
					ulong id = default(ulong);
					((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref id, default(ForPrimitives));
					Carry.HostDesk(PlayerOf(s), id);
				}
			}
		}

		internal const string LiftReq = "HeavyScrap.LiftReq";

		internal const string Lift = "HeavyScrap.Lift";

		internal const string Slam = "HeavyScrap.Slam";

		internal const string State = "HeavyScrap.State";

		internal const string Jump = "HeavyScrap.Jump";

		internal const string LetGo = "HeavyScrap.LetGo";

		internal const string Tilt = "HeavyScrap.Tilt";

		internal const string Drop = "HeavyScrap.Drop";

		internal const string Door = "HeavyScrap.Door";

		internal const string Desk = "HeavyScrap.Desk";

		internal const string DoorGo = "HeavyScrap.DoorGo";

		internal const string Ping = "HeavyScrap.Ping";

		internal const string Pong = "HeavyScrap.Pong";

		private static CustomMessagingManager _registeredOn;

		internal static NetworkManager NM => NetworkManager.Singleton;

		internal static bool Online
		{
			get
			{
				if ((Object)(object)NM != (Object)null && NM.IsListening)
				{
					return NM.CustomMessagingManager != null;
				}
				return false;
			}
		}

		internal static bool IsHost
		{
			get
			{
				if (Online)
				{
					return NM.IsServer;
				}
				return false;
			}
		}

		internal static int LocalIdx => (int)(GameNetworkManager.Instance?.localPlayerController?.playerClientId).GetValueOrDefault();

		internal unsafe static void Register()
		{
			//IL_0056: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0061: Expected O, but got Unknown
			//IL_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_008a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0090: Expected O, but got Unknown
			//IL_00b4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Expected O, but got Unknown
			//IL_0105: Unknown result type (might be due to invalid IL or missing references)
			//IL_010f: Expected O, but got Unknown
			//IL_00e3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ee: Expected O, but got Unknown
			//IL_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0133: Unknown result type (might be due to invalid IL or missing references)
			//IL_0139: Expected O, but got Unknown
			//IL_015d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0162: Unknown result type (might be due to invalid IL or missing references)
			//IL_0168: Expected O, but got Unknown
			//IL_018c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0191: Unknown result type (might be due to invalid IL or missing references)
			//IL_0197: Expected O, but got Unknown
			//IL_01bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Expected O, but got Unknown
			//IL_01ea: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f5: Expected O, but got Unknown
			//IL_0219: Unknown result type (might be due to invalid IL or missing references)
			//IL_021e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0224: Expected O, but got Unknown
			//IL_0248: Unknown result type (might be due to invalid IL or missing references)
			//IL_024d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0253: Expected O, but got Unknown
			//IL_0277: Unknown result type (might be due to invalid IL or missing references)
			//IL_027c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0282: Expected O, but got Unknown
			NetworkManager nM = NM;
			if ((Object)(object)nM == (Object)null || nM.CustomMessagingManager == null || _registeredOn == nM.CustomMessagingManager)
			{
				return;
			}
			CustomMessagingManager c = nM.CustomMessagingManager;
			CustomMessagingManager obj = c;
			object obj2 = <>c.<>9__20_0;
			if (obj2 == null)
			{
				HandleNamedMessageDelegate val = delegate(ulong s, FastBufferReader r)
				{
					//IL_000e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0014: Unknown result type (might be due to invalid IL or missing references)
					//IL_0020: 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)
					if (IsHost)
					{
						ulong id = default(ulong);
						((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref id, default(ForPrimitives));
						byte side = default(byte);
						((FastBufferReader)(ref r)).ReadValueSafe<byte>(ref side, default(ForPrimitives));
						Carry.HostLiftRequest(PlayerOf(s), id, side);
					}
				};
				<>c.<>9__20_0 = val;
				obj2 = (object)val;
			}
			obj.RegisterNamedMessageHandler("HeavyScrap.LiftReq", (HandleNamedMessageDelegate)obj2);
			CustomMessagingManager obj3 = c;
			object obj4 = <>c.<>9__20_1;
			if (obj4 == null)
			{
				HandleNamedMessageDelegate val2 = delegate(ulong s, FastBufferReader r)
				{
					//IL_000e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0014: Unknown result type (might be due to invalid IL or missing references)
					//IL_0033: Unknown result type (might be due to invalid IL or missing references)
					//IL_0039: 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_004c: Unknown result type (might be due to invalid IL or missing references)
					//IL_005a: Unknown result type (might be due to invalid IL or missing references)
					//IL_005b: Unknown result type (might be due to invalid IL or missing references)
					if (IsHost)
					{
						ulong id = default(ulong);
						((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref id, default(ForPrimitives));
						Vector3 pos = default(Vector3);
						((FastBufferReader)(ref r)).ReadValueSafe(ref pos);
						Vector3 vel = default(Vector3);
						((FastBufferReader)(ref r)).ReadValueSafe(ref vel);
						byte flags = default(byte);
						((FastBufferReader)(ref r)).ReadValueSafe<byte>(ref flags, default(ForPrimitives));
						ushort num = default(ushort);
						((FastBufferReader)(ref r)).ReadValueSafe<ushort>(ref num, default(ForPrimitives));
						Carry.HostState(PlayerOf(s), id, pos, vel, flags, (float)(int)num / 1000f);
					}
				};
				<>c.<>9__20_1 = val2;
				obj4 = (object)val2;
			}
			obj3.RegisterNamedMessageHandler("HeavyScrap.State", (HandleNamedMessageDelegate)obj4);
			CustomMessagingManager obj5 = c;
			object obj6 = <>c.<>9__20_2;
			if (obj6 == null)
			{
				HandleNamedMessageDelegate val3 = delegate(ulong s, FastBufferReader r)
				{
					//IL_000e: Unknown result type (might be due to invalid IL or missing references)
					//IL_0014: Unknown result type (might be due to invalid IL or missing references)
					if (IsHost)
					{
						ulong id = default(ulong);
						((FastBufferReader)(ref r)).ReadValueSafe<ulong>(ref id, default(ForPrimitives));
						Carry.HostJumped(PlayerOf(s), id);
					}
				};
				<>c.<>9__20_2 = val3;
				obj6 = (object)val3;
			}
			obj5.RegisterNamedMessageHandler("HeavyScrap.Jump", (HandleNamedMessageDelegate)obj6);
			CustomMessagingManager obj7 = c;
			object obj8 = <>c.<>9__20_3;
			if