Decompiled source of OpenSling v1.1.1

Mods/OpenSling.dll

Decompiled 18 hours ago
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Numerics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using System.Text.Json;
using System.Text.Json.Serialization;
using BoneLib;
using BoneLib.BoneMenu;
using Il2CppInterop.Runtime.InteropTypes;
using Il2CppInterop.Runtime.InteropTypes.Arrays;
using Il2CppSLZ.Marrow;
using Il2CppSLZ.Marrow.Pool;
using Il2CppSLZ.Marrow.Warehouse;
using Il2CppSLZ.VRMK;
using Il2CppSystem.Collections.Generic;
using MelonLoader;
using MelonLoader.Preferences;
using MelonLoader.Utils;
using Microsoft.CodeAnalysis;
using OpenSling;
using UnityEngine;
using UnityEngine.Rendering;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Main), "OpenSling", "1.1.1", "Lack", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: MelonAdditionalDependencies(new string[] { "BoneLib" })]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("OpenSling")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("OpenSling")]
[assembly: AssemblyTitle("OpenSling")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[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 OpenSling
{
	internal enum SlingStyle
	{
		Default = -1,
		Black,
		Leather,
		BlackTightener,
		Green,
		Brown,
		LeatherPadded
	}
	internal enum SlingMode
	{
		Auto,
		Always,
		Never
	}
	internal enum SlingAttach
	{
		Both,
		FrontOnly,
		BackOnly
	}
	internal enum SwivelShow
	{
		Both,
		FrontOnly,
		BackOnly,
		None
	}
	internal sealed class GunConfig
	{
		public const float DefaultWidth = 0.032f;

		public SlingMode Mode { get; set; }

		public SlingStyle Style { get; set; } = SlingStyle.Default;

		public float FrontForward { get; set; }

		public float FrontUp { get; set; }

		public float BackForward { get; set; }

		public float BackUp { get; set; }

		public float Length { get; set; } = 1f;

		public float Width { get; set; } = 0.032f;

		public float RollFront { get; set; }

		public float RollBack { get; set; }

		public bool Swivels { get; set; } = true;

		public bool HideFront { get; set; }

		public bool HideBack { get; set; }

		public SlingAttach Attach { get; set; }

		[JsonIgnore]
		public bool ShowFront
		{
			get
			{
				if (Swivels && !HideFront)
				{
					return Attach != SlingAttach.BackOnly;
				}
				return false;
			}
		}

		[JsonIgnore]
		public bool ShowBack
		{
			get
			{
				if (Swivels && !HideBack)
				{
					return Attach != SlingAttach.FrontOnly;
				}
				return false;
			}
		}

		[JsonIgnore]
		public SwivelShow Show
		{
			get
			{
				if (Swivels && (!HideFront || !HideBack))
				{
					if (!HideFront)
					{
						if (!HideBack)
						{
							return SwivelShow.Both;
						}
						return SwivelShow.FrontOnly;
					}
					return SwivelShow.BackOnly;
				}
				return SwivelShow.None;
			}
			set
			{
				Swivels = value != SwivelShow.None;
				HideFront = value == SwivelShow.BackOnly;
				HideBack = value == SwivelShow.FrontOnly;
			}
		}

		public bool IsDefault
		{
			get
			{
				if (Mode == SlingMode.Auto && Style == SlingStyle.Default && FrontForward == 0f && FrontUp == 0f && BackForward == 0f && BackUp == 0f && Mathf.Abs(Length - 1f) < 0.0001f && Mathf.Abs(Width - 0.032f) < 0.0001f && RollFront == 0f && RollBack == 0f && Swivels && !HideFront && !HideBack)
				{
					return Attach == SlingAttach.Both;
				}
				return false;
			}
		}

		public GunConfig Clone()
		{
			return (GunConfig)MemberwiseClone();
		}

		public void Sanitize()
		{
			FrontForward = C(FrontForward, -0.5f, 0.5f, 0f);
			FrontUp = C(FrontUp, -0.3f, 0.3f, 0f);
			BackForward = C(BackForward, -0.5f, 0.5f, 0f);
			BackUp = C(BackUp, -0.3f, 0.3f, 0f);
			Length = C(Length, 0.3f, 4f, 1f);
			Width = C(Width, 0.012f, 0.07f, 0.032f);
			RollFront = C(RollFront, -180f, 180f, 0f);
			RollBack = C(RollBack, -180f, 180f, 0f);
			if (!Enum.IsDefined(typeof(SlingStyle), Style))
			{
				Style = SlingStyle.Default;
			}
			if (!Enum.IsDefined(typeof(SlingMode), Mode))
			{
				Mode = SlingMode.Auto;
			}
			if (!Enum.IsDefined(typeof(SlingAttach), Attach))
			{
				Attach = SlingAttach.Both;
			}
			static float C(float v, float lo, float hi, float d)
			{
				if (!float.IsFinite(v))
				{
					return d;
				}
				return Mathf.Clamp(v, lo, hi);
			}
		}
	}
	internal static class GunStore
	{
		private static readonly Dictionary<string, GunConfig> Guns = new Dictionary<string, GunConfig>();

		private static bool _dirty;

		private static float _saveAt;

		private static string PathName => Path.Combine(MelonEnvironment.UserDataDirectory, "OpenSling_Guns.json");

		internal static string FilePath => PathName;

		internal static GunConfig Get(string barcode)
		{
			if (string.IsNullOrEmpty(barcode) || !Guns.TryGetValue(barcode, out GunConfig value))
			{
				return new GunConfig();
			}
			return value;
		}

		internal static bool Has(string barcode)
		{
			return Guns.ContainsKey(barcode);
		}

		internal static void Set(string barcode, GunConfig config)
		{
			if (!string.IsNullOrEmpty(barcode))
			{
				config.Sanitize();
				if (config.IsDefault)
				{
					Guns.Remove(barcode);
				}
				else
				{
					Guns[barcode] = config.Clone();
				}
				_dirty = true;
				_saveAt = Time.unscaledTime + 0.75f;
			}
		}

		internal static void Reset(string barcode)
		{
			if (Guns.Remove(barcode))
			{
				_dirty = true;
				_saveAt = Time.unscaledTime + 0.25f;
			}
		}

		internal static void Load()
		{
			try
			{
				if (!File.Exists(PathName))
				{
					return;
				}
				Dictionary<string, GunConfig> dictionary = JsonSerializer.Deserialize<Dictionary<string, GunConfig>>(File.ReadAllText(PathName));
				if (dictionary == null)
				{
					return;
				}
				foreach (KeyValuePair<string, GunConfig> item in dictionary)
				{
					if (item.Value != null)
					{
						item.Value.Sanitize();
						Guns[item.Key] = item.Value;
					}
				}
				Main.Log.Msg($"Loaded sling settings for {Guns.Count} gun(s).");
			}
			catch (Exception ex)
			{
				Main.Log.Warning("Couldn't read " + PathName + ": " + ex.Message);
			}
		}

		internal static void SaveIfDirty()
		{
			if (_dirty && Time.unscaledTime >= _saveAt)
			{
				SaveNow();
			}
		}

		internal static void SaveNow()
		{
			if (!_dirty)
			{
				return;
			}
			_dirty = false;
			try
			{
				File.WriteAllText(PathName, JsonSerializer.Serialize(Guns, new JsonSerializerOptions
				{
					WriteIndented = true
				}));
			}
			catch (Exception e)
			{
				Main.LogOnce("save", e);
			}
		}
	}
	internal static class LitShader
	{
		private static Shader? _cached;

		private static readonly string[] Preferred = new string[5] { "Universal Render Pipeline/Lit", "Universal Render Pipeline/Lit (PBR Workflow)", "SLZ/LitMAS/LitMAS Opaque", "SLZ/LitMAS/LitMAS Standard", "Universal Render Pipeline/Simple Lit" };

		internal static string Info { get; private set; } = "";

		private static bool Ok(Shader? s)
		{
			try
			{
				return (Object)(object)s != (Object)null && !((Il2CppObjectBase)s).WasCollected && s.isSupported;
			}
			catch
			{
				return false;
			}
		}

		internal static Shader? Get()
		{
			if (Ok(_cached))
			{
				return _cached;
			}
			_cached = null;
			try
			{
				string[] preferred = Preferred;
				for (int i = 0; i < preferred.Length; i++)
				{
					Shader val = Shader.Find(preferred[i]);
					if (Ok(val))
					{
						return Pick(val, "found");
					}
				}
				Il2CppArrayBase<Shader> val2 = Resources.FindObjectsOfTypeAll<Shader>();
				preferred = Preferred;
				foreach (string text in preferred)
				{
					foreach (Shader item in val2)
					{
						if (Ok(item) && ((Object)item).name == text)
						{
							return Pick(item, "loaded");
						}
					}
				}
				foreach (Shader item2 in val2)
				{
					if (Ok(item2) && ((Object)item2).name.Contains("LitMAS") && !((Object)item2).name.Contains("Transparent"))
					{
						return Pick(item2, "loaded");
					}
				}
				RigManager rigManager = Player.RigManager;
				if ((Object)(object)rigManager != (Object)null)
				{
					foreach (Renderer componentsInChild in ((Component)rigManager).GetComponentsInChildren<Renderer>(true))
					{
						if ((Object)(object)componentsInChild == (Object)null)
						{
							continue;
						}
						foreach (Material item3 in (Il2CppArrayBase<Material>)(object)componentsInChild.sharedMaterials)
						{
							if ((Object)(object)item3 != (Object)null && Ok(item3.shader) && item3.renderQueue < 2500 && (item3.HasProperty("_BaseColor") || item3.HasProperty("_Color")))
							{
								return Pick(item3.shader, "player's");
							}
						}
					}
				}
			}
			catch (Exception e)
			{
				Main.LogOnce("lit-shader", e);
			}
			Info = "no lit shader found";
			return null;
		}

		private static Shader Pick(Shader sh, string how)
		{
			_cached = sh;
			Info = ((Object)sh).name + " (" + how + ")";
			Main.Log.Msg("Sling shader: " + Info);
			return sh;
		}
	}
	public sealed class Main : MelonMod
	{
		internal static Instance Log = null;

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

		public override void OnInitializeMelon()
		{
			Log = ((MelonBase)this).LoggerInstance;
			Settings.Create();
			GunStore.Load();
			Settings.BuildMenu();
			Hooking.OnLevelLoaded += delegate
			{
				SlingManager.Clear();
			};
			Hooking.OnLevelUnloaded += SlingManager.Clear;
			Log.Msg("Loaded. BoneMenu > OpenSling.");
		}

		public override void OnUpdate()
		{
			SlingManager.Update();
			GunStore.SaveIfDirty();
			Net.Tick();
		}

		public override void OnFixedUpdate()
		{
			SlingManager.FixedUpdate();
		}

		public override void OnLateUpdate()
		{
			SlingManager.LateUpdate();
		}

		public override void OnApplicationQuit()
		{
			GunStore.SaveNow();
		}

		internal static void LogOnce(string key, Exception e)
		{
			if (Logged.Add(key))
			{
				Log.Error($"[{key}] {e}");
			}
		}
	}
	internal static class Net
	{
		private static readonly Dictionary<ushort, GunConfig> RemoteConfigs = new Dictionary<ushort, GunConfig>();

		private static float _nextConfigResend;

		private static ISlingNetwork? Link => SlingNet.Network;

		internal static bool InServer
		{
			get
			{
				ISlingNetwork link = Link;
				if (link == null)
				{
					return false;
				}
				try
				{
					return link.InServer;
				}
				catch
				{
					return false;
				}
			}
		}

		internal static GunConfig? RemoteConfig(ushort id)
		{
			if (!RemoteConfigs.TryGetValue(id, out GunConfig value))
			{
				return null;
			}
			return value;
		}

		internal static void Attach(Sling s)
		{
			Refresh(s);
		}

		internal static void Refresh(Sling s)
		{
			ISlingNetwork link = Link;
			if (link == null)
			{
				s.Networked = false;
				s.IsOwner = true;
				return;
			}
			bool isOwner = s.IsOwner;
			bool networked = s.Networked;
			ushort entityId = s.EntityId;
			ushort id = 0;
			bool owner = true;
			bool flag;
			try
			{
				flag = link.TryEntity(s.Gun, out id, out owner);
			}
			catch
			{
				flag = false;
			}
			if (!flag)
			{
				s.Networked = false;
				s.IsOwner = true;
				return;
			}
			s.Networked = true;
			s.EntityId = id;
			s.IsOwner = owner;
			if (owner && (!isOwner || !networked || entityId != id))
			{
				ConfigChanged(s);
			}
			if (!owner && RemoteConfigs.TryGetValue(id, out GunConfig value) && !Same(value, s.Config))
			{
				s.Apply(value);
			}
		}

		internal static void ConfigChanged(Sling s)
		{
			if (!InServer || !s.Networked || !s.IsOwner)
			{
				return;
			}
			try
			{
				Link.SendConfig(s.EntityId, SlingSettings.From(GunStore.Get(s.Barcode)));
			}
			catch (Exception e)
			{
				Main.LogOnce("send-config", e);
			}
		}

		internal static void SendRope(Sling s)
		{
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: Unknown result type (might be due to invalid IL or missing references)
			//IL_005d: 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: 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_007a: Unknown result type (might be due to invalid IL or missing references)
			if (!s.Networked || !s.IsOwner || Time.time < s.NextSend || !InServer)
			{
				return;
			}
			s.NextSend = Time.time + 0.1f;
			bool flag = false;
			Vector3[] array = (Vector3[])(object)new Vector3[16];
			for (int i = 0; i < 16; i++)
			{
				array[i] = s.T.InverseTransformPoint(s.P[i]);
				Vector3 val = array[i] - s.SentLocal[i];
				if (((Vector3)(ref val)).sqrMagnitude > 4.0000004E-06f)
				{
					flag = true;
				}
			}
			if (!flag)
			{
				return;
			}
			Array.Copy(array, s.SentLocal, 16);
			try
			{
				Link.SendRope(s.EntityId, array);
			}
			catch (Exception e)
			{
				Main.LogOnce("send-rope", e);
			}
		}

		internal static void Tick()
		{
			if (Link == null)
			{
				return;
			}
			if (!InServer)
			{
				if (RemoteConfigs.Count > 0)
				{
					RemoteConfigs.Clear();
				}
				return;
			}
			SlingNet.Drain();
			if (!(Time.unscaledTime >= _nextConfigResend))
			{
				return;
			}
			_nextConfigResend = Time.unscaledTime + 10f;
			foreach (Sling item in SlingManager.All)
			{
				ConfigChanged(item);
			}
		}

		internal static void PlayerJoined()
		{
			_nextConfigResend = 0f;
		}

		internal static void OnConfig(ushort id, GunConfig c)
		{
			c.Sanitize();
			RemoteConfigs[id] = c;
			Sling sling = SlingManager.FindByEntity(id);
			if (sling != null && !sling.IsOwner)
			{
				if (c.Mode == SlingMode.Never)
				{
					SlingManager.Rescan();
				}
				else
				{
					sling.Apply(c);
				}
			}
		}

		internal static void OnRope(ushort id, Vector3[] local)
		{
			//IL_0021: 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_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_0041: Unknown result type (might be due to invalid IL or missing references)
			Sling sling = SlingManager.FindByEntity(id);
			if (sling == null || sling.IsOwner || local.Length < 16)
			{
				return;
			}
			for (int i = 0; i < 16; i++)
			{
				Vector3 val = local[i];
				if (!float.IsFinite(val.x) || !float.IsFinite(val.y) || !float.IsFinite(val.z) || ((Vector3)(ref val)).sqrMagnitude > 25f)
				{
					return;
				}
			}
			Array.Copy(local, sling.RemoteLocal, 16);
			sling.RemoteTime = Time.time;
		}

		private static bool Same(GunConfig a, GunConfig b)
		{
			if (a.Mode == b.Mode && a.Style == b.Style && a.FrontForward == b.FrontForward && a.FrontUp == b.FrontUp && a.BackForward == b.BackForward && a.BackUp == b.BackUp && a.Length == b.Length && a.Width == b.Width && a.RollFront == b.RollFront && a.RollBack == b.RollBack && a.Swivels == b.Swivels && a.HideFront == b.HideFront && a.HideBack == b.HideBack)
			{
				return a.Attach == b.Attach;
			}
			return false;
		}
	}
	internal static class Settings
	{
		private static MelonPreferences_Category _cat;

		internal static MelonPreferences_Entry<bool> Enabled;

		internal static MelonPreferences_Entry<bool> AutoSling;

		internal static MelonPreferences_Entry<int> Style;

		internal static MelonPreferences_Entry<float> HideAfterMinutes;

		internal static MelonPreferences_Entry<bool> WornOnBack;

		internal static MelonPreferences_Entry<bool> GrabStrap;

		internal static MelonPreferences_Entry<bool> Hooks;

		internal static float? TestHideAfterSeconds;

		private static MelonPreferences_Entry<int> _version;

		internal static SlingStyle DefaultStyle
		{
			get
			{
				SlingStyle value = (SlingStyle)Style.Value;
				if (!Enum.IsDefined(typeof(SlingStyle), value) || value == SlingStyle.Default)
				{
					return SlingStyle.Black;
				}
				return value;
			}
		}

		internal static float HideAfter => TestHideAfterSeconds ?? (Mathf.Max(0f, HideAfterMinutes.Value) * 60f);

		internal static void Create()
		{
			_cat = MelonPreferences.CreateCategory("OpenSling");
			Enabled = _cat.CreateEntry<bool>("Enabled", true, (string)null, (string)null, false, false, (ValueValidator)null, (string)null);
			AutoSling = _cat.CreateEntry<bool>("AutoSling", false, (string)null, "Every long gun gets a sling (pistols and utility tools never do). Off: add one per gun in Edit Mode.", false, false, (ValueValidator)null, (string)null);
			Style = _cat.CreateEntry<int>("DefaultStyle", 0, (string)null, "0 Black, 1 Leather, 2 Black with tightener, 3 Green, 4 Brown, 5 Leather with shoulder pad", false, false, (ValueValidator)null, (string)null);
			HideAfterMinutes = _cat.CreateEntry<float>("HideDroppedAfterMinutes", 20f, (string)null, "A gun nobody has held for this long (dropped, lying about) has its sling hidden to save performance; it comes back when the gun is picked up. 0 = never.", false, false, (ValueValidator)null, (string)null);
			GrabStrap = _cat.CreateEntry<bool>("GrabStrap", true, (string)null, "Grab the strap itself (grip with an empty hand by it) and carry the gun by its sling.", false, false, (ValueValidator)null, (string)null);
			WornOnBack = _cat.CreateEntry<bool>("WornOnBack", true, (string)null, "A gun in a back slot is worn: its strap goes over your shoulder and across your chest.", false, false, (ValueValidator)null, (string)null);
			Hooks = _cat.CreateEntry<bool>("Hooks", true, (string)null, "An end of the strap with its swivel hidden clips on with a snap hook instead (it swings on the gun).", false, false, (ValueValidator)null, (string)null);
			_version = _cat.CreateEntry<int>("SettingsVersion", 1, (string)null, (string)null, true, false, (ValueValidator)null, (string)null);
			if (_version.Value < 2)
			{
				AutoSling.Value = false;
				_version.Value = 2;
				_cat.SaveToFile(false);
			}
		}

		private static void Save()
		{
			_cat.SaveToFile(false);
		}

		internal static void BuildMenu()
		{
			//IL_0019: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0113: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			Page obj = Page.Root.CreatePage("OpenSling", new Color(0.55f, 0.35f, 0.2f), 0, true);
			obj.CreateBool("Enabled", Color.white, Enabled.Value, (Action<bool>)delegate(bool v)
			{
				Enabled.Value = v;
				Save();
				SlingManager.Rescan();
			});
			obj.CreateBool("Auto Sling Guns", Color.green, AutoSling.Value, (Action<bool>)delegate(bool v)
			{
				AutoSling.Value = v;
				Save();
				SlingManager.Rescan();
			});
			obj.CreateEnum("Default Style", Color.yellow, (Enum)DefaultStyle, (Action<Enum>)delegate(Enum v)
			{
				Style.Value = (int)(SlingStyle)(object)v;
				Save();
				SlingManager.Rescan();
			});
			obj.CreateBool("Grab The Strap", Color.white, GrabStrap.Value, (Action<bool>)delegate(bool v)
			{
				GrabStrap.Value = v;
				Save();
			});
			obj.CreateBool("Hooks (where a swivel is hidden)", Color.white, Hooks.Value, (Action<bool>)delegate(bool v)
			{
				Hooks.Value = v;
				Save();
				SlingManager.Rescan();
			});
			obj.CreateBool("Worn On Back (strap across chest)", Color.white, WornOnBack.Value, (Action<bool>)delegate(bool v)
			{
				WornOnBack.Value = v;
				Save();
			});
			obj.CreateFloat("Hide Dropped Slings After (min)", Color.white, HideAfterMinutes.Value, 5f, 0f, 120f, (Action<float>)delegate(float v)
			{
				HideAfterMinutes.Value = v;
				Save();
			});
			EditMode.Build(obj);
		}
	}
	internal static class EditMode
	{
		internal static bool On;

		internal static Sling? Held;

		private static Gun? _heldGun;

		private static string _heldBarcode = "";

		private static float _nextCheck;

		private static FunctionElement? _label;

		private static EnumElement? _mode;

		private static EnumElement? _style;

		private static EnumElement? _swivels;

		private static EnumElement? _attach;

		private static FloatElement? _ff;

		private static FloatElement? _fu;

		private static FloatElement? _bf;

		private static FloatElement? _bu;

		private static FloatElement? _len;

		private static FloatElement? _width;

		private static FloatElement? _rollF;

		private static FloatElement? _rollB;

		internal static void Build(Page root)
		{
			//IL_0006: 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_0049: 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_00b7: 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_0139: 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_01c9: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0259: Unknown result type (might be due to invalid IL or missing references)
			//IL_02a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_02db: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_035d: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			root.CreateBool("Edit Mode", Color.cyan, false, (Action<bool>)delegate(bool v)
			{
				On = v;
				_nextCheck = 0f;
			});
			Page obj = root.CreatePage("Edit Held Gun", Color.cyan, 0, true);
			_label = obj.CreateFunction("Gun: (hold one)", Color.white, (Action)delegate
			{
				_nextCheck = 0f;
			});
			_mode = obj.CreateEnum("Sling On This Gun", Color.green, (Enum)SlingMode.Auto, (Action<Enum>)delegate(Enum v)
			{
				Change(delegate(GunConfig c)
				{
					c.Mode = (SlingMode)(object)v;
				});
			});
			_style = obj.CreateEnum("Style", Color.yellow, (Enum)SlingStyle.Default, (Action<Enum>)delegate(Enum v)
			{
				Change(delegate(GunConfig c)
				{
					c.Style = (SlingStyle)(object)v;
				});
			});
			_ff = obj.CreateFloat("Front Forward/Back", Color.green, 0f, 0.01f, -0.5f, 0.5f, (Action<float>)delegate(float v)
			{
				Change(delegate(GunConfig c)
				{
					c.FrontForward = v;
				});
			});
			_fu = obj.CreateFloat("Front Up/Down", Color.green, 0f, 0.005f, -0.3f, 0.3f, (Action<float>)delegate(float v)
			{
				Change(delegate(GunConfig c)
				{
					c.FrontUp = v;
				});
			});
			_bf = obj.CreateFloat("Back Forward/Back", Color.red, 0f, 0.01f, -0.5f, 0.5f, (Action<float>)delegate(float v)
			{
				Change(delegate(GunConfig c)
				{
					c.BackForward = v;
				});
			});
			_bu = obj.CreateFloat("Back Up/Down", Color.red, 0f, 0.005f, -0.3f, 0.3f, (Action<float>)delegate(float v)
			{
				Change(delegate(GunConfig c)
				{
					c.BackUp = v;
				});
			});
			_len = obj.CreateFloat("Sling Length", Color.magenta, 1f, 0.05f, 0.3f, 4f, (Action<float>)delegate(float v)
			{
				Change(delegate(GunConfig c)
				{
					c.Length = v;
				});
			});
			_width = obj.CreateFloat("Sling Width (m)", Color.magenta, 0.032f, 0.002f, 0.012f, 0.07f, (Action<float>)delegate(float v)
			{
				Change(delegate(GunConfig c)
				{
					c.Width = v;
				});
			});
			_swivels = obj.CreateEnum("Swivels Shown", Color.gray, (Enum)SwivelShow.Both, (Action<Enum>)delegate(Enum v)
			{
				Change(delegate(GunConfig c)
				{
					c.Show = (SwivelShow)(object)v;
				});
			});
			_attach = obj.CreateEnum("Tied To", Color.gray, (Enum)SlingAttach.Both, (Action<Enum>)delegate(Enum v)
			{
				Change(delegate(GunConfig c)
				{
					c.Attach = (SlingAttach)(object)v;
				});
			});
			_rollF = obj.CreateFloat("Front Rotation (deg)", Color.green, 0f, 15f, -180f, 180f, (Action<float>)delegate(float v)
			{
				Change(delegate(GunConfig c)
				{
					c.RollFront = v;
				});
			});
			_rollB = obj.CreateFloat("Back Rotation (deg)", Color.red, 0f, 15f, -180f, 180f, (Action<float>)delegate(float v)
			{
				Change(delegate(GunConfig c)
				{
					c.RollBack = v;
				});
			});
			obj.CreateFunction("Reset This Gun", Color.red, (Action)ResetHeld);
		}

		private static Gun? HeldGun()
		{
			try
			{
				Gun componentInHand = Player.GetComponentInHand<Gun>(Player.RightHand);
				if ((Object)(object)componentInHand == (Object)null)
				{
					componentInHand = Player.GetComponentInHand<Gun>(Player.LeftHand);
				}
				return componentInHand;
			}
			catch
			{
				return null;
			}
		}

		internal static void Update()
		{
			if (Time.unscaledTime < _nextCheck)
			{
				return;
			}
			_nextCheck = Time.unscaledTime + 0.25f;
			Gun val = HeldGun();
			if ((Object)(object)val != (Object)null && (Object)(object)_heldGun != (Object)null && ((Il2CppObjectBase)val).Pointer == ((Il2CppObjectBase)_heldGun).Pointer)
			{
				Held = SlingManager.Find(val);
				return;
			}
			_heldGun = val;
			Held = (((Object)(object)val != (Object)null) ? SlingManager.Find(val) : null);
			_heldBarcode = "";
			if ((Object)(object)val != (Object)null && SlingManager.Describe(val, out string barcode, out string title, out List<string> _))
			{
				_heldBarcode = barcode;
				SetLabel("Gun: " + title);
				Show(GunStore.Get(barcode));
			}
			else
			{
				SetLabel("Gun: (hold one)");
			}
		}

		private static void SetLabel(string text)
		{
			try
			{
				if (_label != null)
				{
					((Element)_label).ElementName = text;
				}
			}
			catch
			{
			}
		}

		private static void Show(GunConfig c)
		{
			try
			{
				if (_mode != null)
				{
					_mode.Value = c.Mode;
				}
				if (_style != null)
				{
					_style.Value = c.Style;
				}
				if (_ff != null)
				{
					_ff.Value = c.FrontForward;
				}
				if (_fu != null)
				{
					_fu.Value = c.FrontUp;
				}
				if (_bf != null)
				{
					_bf.Value = c.BackForward;
				}
				if (_bu != null)
				{
					_bu.Value = c.BackUp;
				}
				if (_len != null)
				{
					_len.Value = c.Length;
				}
				if (_width != null)
				{
					_width.Value = c.Width;
				}
				if (_rollF != null)
				{
					_rollF.Value = c.RollFront;
				}
				if (_swivels != null)
				{
					_swivels.Value = c.Show;
				}
				if (_attach != null)
				{
					_attach.Value = c.Attach;
				}
				if (_rollB != null)
				{
					_rollB.Value = c.RollBack;
				}
			}
			catch (Exception e)
			{
				Main.LogOnce("edit-show", e);
			}
		}

		private static void Change(Action<GunConfig> edit)
		{
			if (On && !string.IsNullOrEmpty(_heldBarcode))
			{
				ApplyTo(_heldBarcode, edit);
			}
		}

		internal static void ApplyTo(string barcode, Action<GunConfig> edit)
		{
			GunConfig gunConfig = GunStore.Get(barcode).Clone();
			edit(gunConfig);
			GunStore.Set(barcode, gunConfig);
			Refresh(barcode);
		}

		private static void ResetHeld()
		{
			if (!string.IsNullOrEmpty(_heldBarcode))
			{
				GunStore.Reset(_heldBarcode);
				Show(new GunConfig());
				Refresh(_heldBarcode);
			}
		}

		internal static void Refresh(string barcode)
		{
			SlingManager.Rescan();
			foreach (Sling item in SlingManager.All)
			{
				if (item.Barcode == barcode)
				{
					Net.ConfigChanged(item);
				}
			}
			if ((Object)(object)_heldGun != (Object)null)
			{
				SlingManager.Ensure(_heldGun);
			}
		}
	}
	internal sealed class Sling
	{
		internal sealed class HookState
		{
			internal bool On;

			internal bool Ok;

			internal Vector3 Eye;

			internal Vector3 Prev;
		}

		internal const int N = 16;

		internal const float Radius = 0.012f;

		internal const float MaxStretch = 0.06f;

		private const float EndGive = 0.35f;

		public readonly Gun Gun;

		public readonly Rigidbody? Rb;

		public readonly Transform T;

		public readonly string Barcode;

		public readonly string Title;

		public readonly bool TooShort;

		public Vector3 FrontBase;

		public Vector3 BackBase;

		public Vector3 Fwd;

		public Vector3 Up;

		public float BaseLength;

		public float GunLength;

		public GunConfig Config = new GunConfig();

		public SlingStyle Style;

		public Vector3 FrontLocal;

		public Vector3 BackLocal;

		public float Rest;

		internal readonly Vector3[] P = (Vector3[])(object)new Vector3[16];

		internal readonly Vector3[] Prev = (Vector3[])(object)new Vector3[16];

		internal readonly Vector3[] Last = (Vector3[])(object)new Vector3[16];

		private readonly bool[] contact = new bool[16];

		internal readonly Vector3[] ContactNormal = (Vector3[])(object)new Vector3[16];

		private readonly bool[] contactSolid = new bool[16];

		private readonly string[] contactWhat = new string[16];

		internal string LastSupportBy = "";

		private readonly Vector3[] Mid = (Vector3[])(object)new Vector3[16];

		private readonly bool[] held = new bool[16];

		private float endGive = 0.35f;

		private bool placed;

		private bool visible;

		private int stillSteps;

		private bool asleep;

		private Vector3 sleepPos;

		private Quaternion sleepRot;

		private int sleepCheck;

		private int sleepHits;

		internal float Stretch;

		internal float LastForce;

		internal float LastSupport;

		internal bool Networked;

		internal bool IsOwner = true;

		internal ushort EntityId;

		internal readonly Vector3[] RemoteLocal = (Vector3[])(object)new Vector3[16];

		internal float RemoteTime = -10f;

		internal readonly Vector3[] SentLocal = (Vector3[])(object)new Vector3[16];

		internal float NextSend;

		private readonly HashSet<IntPtr> own = new HashSet<IntPtr>();

		private readonly Il2CppArrayBase<Grip> grips;

		private readonly Il2CppArrayBase<InteractableHost> hostsAll;

		internal const float StrapMass = 0.15f;

		internal float HeldForce;

		private readonly SlingView view;

		private static readonly Il2CppStructArray<RaycastHit> Hits = new Il2CppStructArray<RaycastHit>(8L);

		private static readonly Il2CppReferenceArray<Collider> Overlaps = new Il2CppReferenceArray<Collider>(16L);

		private static int _mask = -1;

		private List<Collider> fitCols = new List<Collider>();

		private Vector3 fitOrigin;

		private float fitMidU;

		private float fitReach;

		public float FrontF;

		public float BackF;

		internal readonly HookState HookF = new HookState();

		internal readonly HookState HookB = new HookState();

		internal const float HookLen = 0.058f;

		public Vector3 SocketFront;

		public Vector3 SocketBack;

		public Vector3 OutFront;

		public Vector3 OutBack;

		internal const float SwivelDrop = 0.03f;

		private Vector3 carryPos;

		private Quaternion carryRot;

		private bool carryOk;

		private float carryK;

		internal WornOn? Worn;

		internal bool Dormant;

		internal float LastUsedAt = Time.time;

		internal float NextDormantCheck;

		internal Transform? StrapHolder;

		internal int StrapIndex = -1;

		internal Rigidbody? StrapHandRb;

		internal float LastHoldBack;

		internal float StrapStretch;

		private float slipSince = -1f;

		private static SphereCollider? _probe;

		internal int SelfPushes;

		private readonly Vector3[] sp = new Vector3[16];

		public bool Pulling
		{
			get
			{
				try
				{
					foreach (InteractableHost item in hostsAll)
					{
						if ((Object)(object)item != (Object)null && item.IsPulling)
						{
							return true;
						}
					}
				}
				catch
				{
				}
				return false;
			}
		}

		internal float PadLength => view.PadLengthNow;

		internal int PadVerts => view.PadVerts;

		internal Vector3 PadMid => view.PadMid;

		internal Vector3 PadFace => view.PadFace;

		public Vector3 Front => T.TransformPoint(FrontLocal);

		public Vector3 Back => T.TransformPoint(BackLocal);

		internal bool HookFrontOn
		{
			get
			{
				if (Settings.Hooks.Value && Config.Attach != SlingAttach.BackOnly)
				{
					return !Config.ShowFront;
				}
				return false;
			}
		}

		internal bool HookBackOn
		{
			get
			{
				if (Settings.Hooks.Value && Config.Attach != SlingAttach.FrontOnly)
				{
					return !Config.ShowBack;
				}
				return false;
			}
		}

		public Vector3 EndFront
		{
			get
			{
				//IL_0030: 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_003c: Unknown result type (might be due to invalid IL or missing references)
				if (!HookF.On || !HookF.Ok)
				{
					if (Config.Attach != SlingAttach.BackOnly)
					{
						return Front;
					}
					return EndBackRaw;
				}
				return HookF.Eye;
			}
		}

		public Vector3 EndBack
		{
			get
			{
				//IL_0016: Unknown result type (might be due to invalid IL or missing references)
				//IL_000f: Unknown result type (might be due to invalid IL or missing references)
				if (Config.Attach != SlingAttach.FrontOnly)
				{
					return EndBackRaw;
				}
				return EndFront;
			}
		}

		private Vector3 EndBackRaw
		{
			get
			{
				//IL_001b: 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)
				if (!HookB.On || !HookB.Ok)
				{
					return Back;
				}
				return HookB.Eye;
			}
		}

		public Vector3 SocketFrontWorld => T.TransformPoint(SocketFront);

		public Vector3 SocketBackWorld => T.TransformPoint(SocketBack);

		public Vector3 OutFrontWorld => T.TransformDirection(OutFront);

		public Vector3 OutBackWorld => T.TransformDirection(OutBack);

		public bool Held
		{
			get
			{
				try
				{
					foreach (Grip grip in grips)
					{
						if ((Object)(object)grip != (Object)null && grip.attachedHands != null && grip.attachedHands.Count > 0)
						{
							return true;
						}
					}
				}
				catch
				{
				}
				return false;
			}
		}

		internal static int Mask
		{
			get
			{
				if (_mask == -1)
				{
					int num = -1;
					string[] array = new string[4] { "Ignore Raycast", "UI", "TransparentFX", "Water" };
					for (int i = 0; i < array.Length; i++)
					{
						int num2 = LayerMask.NameToLayer(array[i]);
						if (num2 >= 0)
						{
							num &= ~(1 << num2);
						}
					}
					_mask = num;
				}
				return _mask;
			}
		}

		public bool Active
		{
			get
			{
				if ((Object)(object)Gun != (Object)null && !((Il2CppObjectBase)Gun).WasCollected)
				{
					return ((Component)Gun).gameObject.activeInHierarchy;
				}
				return false;
			}
		}

		internal bool Visible => visible;

		private bool StrapHeld
		{
			get
			{
				if ((Object)(object)StrapHolder != (Object)null && StrapIndex > 0)
				{
					return !((Il2CppObjectBase)StrapHolder).WasCollected;
				}
				return false;
			}
		}

		private static SphereCollider Probe
		{
			get
			{
				//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_0029: Expected O, but got Unknown
				//IL_0034: Unknown result type (might be due to invalid IL or missing references)
				//IL_0042: Unknown result type (might be due to invalid IL or missing references)
				//IL_0057: Unknown result type (might be due to invalid IL or missing references)
				if ((Object)(object)_probe == (Object)null || ((Il2CppObjectBase)_probe).WasCollected)
				{
					GameObject val = new GameObject("OpenSling_Probe");
					Object.DontDestroyOnLoad((Object)val);
					int num = LayerMask.NameToLayer("Ignore Raycast");
					val.layer = ((num >= 0) ? num : 2);
					val.transform.position = new Vector3(0f, -10000f, 0f);
					_probe = val.AddComponent<SphereCollider>();
					((Collider)_probe).isTrigger = true;
					_probe.radius = 0.012f;
				}
				return _probe;
			}
		}

		private float SelfGap
		{
			get
			{
				if (Style != SlingStyle.LeatherPadded)
				{
					return 0.009f;
				}
				return 0.016f;
			}
		}

		internal GameObject? ViewRoot => view.Root;

		internal Vector3 HangFront => view.hangF;

		internal Vector3 HangBack => view.hangB;

		private bool Solid(Collider col)
		{
			try
			{
				Rigidbody attachedRigidbody = col.attachedRigidbody;
				if ((Object)(object)attachedRigidbody == (Object)null || attachedRigidbody.isKinematic)
				{
					return true;
				}
				if ((Object)(object)Rb != (Object)null && ((Il2CppObjectBase)attachedRigidbody).Pointer == ((Il2CppObjectBase)Rb).Pointer)
				{
					return false;
				}
				return (Object)(object)Rb == (Object)null || attachedRigidbody.mass >= Rb.mass * 2f;
			}
			catch
			{
				return false;
			}
		}

		internal bool Touching(int i)
		{
			return contact[i];
		}

		internal void Redraw()
		{
			view.Dirty();
		}

		internal static Transform? FirePoint(Gun gun)
		{
			try
			{
				return gun.firePointTransform;
			}
			catch
			{
				return null;
			}
		}

		public Sling(Gun gun, string barcode, string title, Rigidbody? rb)
		{
			Gun = gun;
			Barcode = barcode;
			Title = title;
			Rb = rb;
			T = (((Object)(object)rb != (Object)null) ? ((Component)rb).transform : ((Component)gun).transform);
			foreach (Collider componentsInChild in ((Component)T).GetComponentsInChildren<Collider>(true))
			{
				if ((Object)(object)componentsInChild != (Object)null)
				{
					own.Add(((Il2CppObjectBase)componentsInChild).Pointer);
				}
			}
			grips = ((Component)T).GetComponentsInChildren<Grip>(true);
			hostsAll = ((Component)T).GetComponentsInChildren<InteractableHost>(true);
			Fit();
			TooShort = GunLength < 0.32f;
			view = new SlingView(this);
		}

		private void Fit()
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0034: 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_003a: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_0063: Unknown result type (might be due to invalid IL or missing references)
			//IL_0064: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_01a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01df: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e0: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01e9: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0200: Unknown result type (might be due to invalid IL or missing references)
			//IL_0204: Unknown result type (might be due to invalid IL or missing references)
			//IL_0209: Unknown result type (might be due to invalid IL or missing references)
			//IL_0265: Unknown result type (might be due to invalid IL or missing references)
			//IL_026a: Unknown result type (might be due to invalid IL or missing references)
			//IL_027e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0283: Unknown result type (might be due to invalid IL or missing references)
			//IL_0289: Unknown result type (might be due to invalid IL or missing references)
			//IL_028f: Unknown result type (might be due to invalid IL or missing references)
			//IL_029f: 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_00f2: 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_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0100: Unknown result type (might be due to invalid IL or missing references)
			Transform val = (Transform)(((Object)(object)FirePoint(Gun) != (Object)null) ? ((object)FirePoint(Gun)) : ((object)T));
			Vector3 forward = val.forward;
			Vector3 val2 = Vector3.ProjectOnPlane(T.up, forward);
			if (((Vector3)(ref val2)).sqrMagnitude < 0.01f)
			{
				val2 = Vector3.ProjectOnPlane(val.up, forward);
			}
			((Vector3)(ref val2)).Normalize();
			Vector3.Cross(val2, forward);
			Vector3 position = val.position;
			float num = float.MaxValue;
			float num2 = float.MinValue;
			float num3 = float.MaxValue;
			float num4 = float.MinValue;
			List<Collider> list = new List<Collider>();
			foreach (Collider componentsInChild in ((Component)T).GetComponentsInChildren<Collider>(true))
			{
				if (!((Object)(object)componentsInChild == (Object)null) && !componentsInChild.isTrigger && Corners(componentsInChild, out Vector3[] world))
				{
					list.Add(componentsInChild);
					Vector3[] array = world;
					for (int i = 0; i < array.Length; i++)
					{
						Vector3 val3 = array[i] - position;
						float num5 = Vector3.Dot(val3, forward);
						float num6 = Vector3.Dot(val3, val2);
						num = Mathf.Min(num, num5);
						num2 = Mathf.Max(num2, num5);
						num3 = Mathf.Min(num3, num6);
						num4 = Mathf.Max(num4, num6);
					}
				}
			}
			if (list.Count == 0 || num > num2)
			{
				num = -0.5f;
				num2 = 0f;
				num3 = -0.08f;
				num4 = 0.04f;
			}
			GunLength = num2 - num;
			fitCols = list;
			fitOrigin = T.InverseTransformPoint(position);
			fitMidU = (num3 + num4) * 0.5f;
			fitReach = Mathf.Max(0.2f, num4 - num3 + 0.2f);
			Vector3 outward = T.InverseTransformDirection(forward);
			Fwd = ((Vector3)(ref outward)).normalized;
			outward = T.InverseTransformDirection(val2);
			Up = ((Vector3)(ref outward)).normalized;
			FrontF = num2 - Mathf.Clamp(GunLength * 0.22f, 0.06f, 0.3f);
			BackF = num + Mathf.Clamp(GunLength * 0.06f, 0.02f, 0.08f);
			FrontBase = Surface(FrontF, 0f, out outward);
			BackBase = Surface(BackF, 0f, out outward);
			float num7 = Vector3.Distance(FrontBase, BackBase) * T.lossyScale.x;
			BaseLength = Mathf.Max(num7 * 1.35f, 0.8f);
		}

		internal Vector3 Surface(float f, float rotation, out Vector3 outward)
		{
			//IL_0007: 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)
			//IL_0011: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0023: 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_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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			//IL_0036: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0048: 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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_005b: 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_0065: Unknown result type (might be due to invalid IL or missing references)
			//IL_0068: Unknown result type (might be due to invalid IL or missing references)
			//IL_0069: 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_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)
			//IL_008c: 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_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_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_011c: Unknown result type (might be due to invalid IL or missing references)
			//IL_011d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0122: Unknown result type (might be due to invalid IL or missing references)
			//IL_0126: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0136: 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_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)
			//IL_0148: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			Vector3 val = T.TransformDirection(Fwd);
			Vector3 val2 = T.TransformDirection(Up);
			Vector3 val3 = Quaternion.AngleAxis(rotation, val) * -val2;
			Vector3 val4 = T.TransformPoint(fitOrigin) + val * f + val2 * fitMidU;
			Ray val5 = default(Ray);
			((Ray)(ref val5))..ctor(val4 + val3 * fitReach, -val3);
			float num = float.MaxValue;
			Vector3 val6 = val4 + val3 * 0.02f;
			RaycastHit val7 = default(RaycastHit);
			foreach (Collider fitCol in fitCols)
			{
				try
				{
					if ((Object)(object)fitCol != (Object)null && fitCol.Raycast(val5, ref val7, fitReach * 2f) && ((RaycastHit)(ref val7)).distance < num)
					{
						num = ((RaycastHit)(ref val7)).distance;
						val6 = ((RaycastHit)(ref val7)).point;
					}
				}
				catch
				{
				}
			}
			Vector3 val8 = T.InverseTransformDirection(val3);
			outward = ((Vector3)(ref val8)).normalized;
			return T.InverseTransformPoint(val6 - val3 * 0.002f);
		}

		private static bool Corners(Collider c, out Vector3[] world)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0037: Unknown result type (might be due to invalid IL or missing references)
			//IL_0038: 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_004e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_006d: 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_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_00d4: 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_00dd: 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_00ef: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_0129: Unknown result type (might be due to invalid IL or missing references)
			//IL_012f: Unknown result type (might be due to invalid IL or missing references)
			//IL_013d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0142: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_014c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0151: Unknown result type (might be due to invalid IL or missing references)
			world = Array.Empty<Vector3>();
			BoxCollider val = ((Il2CppObjectBase)c).TryCast<BoxCollider>();
			Vector3 center;
			Vector3 val2;
			if (val != null)
			{
				center = val.center;
				val2 = val.size;
			}
			else
			{
				SphereCollider val3 = ((Il2CppObjectBase)c).TryCast<SphereCollider>();
				if (val3 != null)
				{
					center = val3.center;
					val2 = Vector3.one * val3.radius * 2f;
				}
				else
				{
					CapsuleCollider val4 = ((Il2CppObjectBase)c).TryCast<CapsuleCollider>();
					if (val4 != null)
					{
						center = val4.center;
						val2 = Vector3.one * val4.radius * 2f;
						((Vector3)(ref val2))[val4.direction] = Mathf.Max(val4.height, val4.radius * 2f);
					}
					else
					{
						MeshCollider val5 = ((Il2CppObjectBase)c).TryCast<MeshCollider>();
						if (val5 == null || !((Object)(object)val5.sharedMesh != (Object)null))
						{
							return false;
						}
						Bounds bounds = val5.sharedMesh.bounds;
						center = ((Bounds)(ref bounds)).center;
						bounds = val5.sharedMesh.bounds;
						val2 = ((Bounds)(ref bounds)).size;
					}
				}
			}
			Transform transform = ((Component)c).transform;
			world = (Vector3[])(object)new Vector3[8];
			int num = 0;
			for (int i = -1; i <= 1; i += 2)
			{
				for (int j = -1; j <= 1; j += 2)
				{
					for (int k = -1; k <= 1; k += 2)
					{
						world[num++] = transform.TransformPoint(center + Vector3.Scale(val2 * 0.5f, new Vector3((float)i, (float)j, (float)k)));
					}
				}
			}
			return true;
		}

		public void Apply(GunConfig config)
		{
			//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_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_007f: 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_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_009b: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ba: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bf: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d1: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00f4: 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_0109: Unknown result type (might be due to invalid IL or missing references)
			//IL_011b: 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)
			Config = config;
			Style = ((config.Style == SlingStyle.Default) ? Settings.DefaultStyle : config.Style);
			SocketFront = Surface(FrontF + config.FrontForward, config.RollFront, out OutFront) + Up * config.FrontUp;
			SocketBack = Surface(BackF + config.BackForward, config.RollBack, out OutBack) + Up * config.BackUp;
			FrontLocal = SocketFront + OutFront * (config.ShowFront ? 0.03f : 0.004f);
			BackLocal = SocketBack + OutBack * (config.ShowBack ? 0.03f : 0.004f);
			if (config.Attach == SlingAttach.FrontOnly)
			{
				BackLocal = FrontLocal;
			}
			else if (config.Attach == SlingAttach.BackOnly)
			{
				FrontLocal = BackLocal;
			}
			float num = BaseLength * config.Length;
			bool num2 = Mathf.Abs(num - Rest) > 0.001f;
			Rest = num;
			view.SetStyle(Style);
			if (num2)
			{
				Wake();
			}
		}

		private void StepHooks(float dt)
		{
			//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_002e: 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)
			StepHook(HookF, HookFrontOn, Front, OutFrontWorld, 1, dt);
			StepHook(HookB, HookBackOn, Back, OutBackWorld, 14, dt);
		}

		private void StepHook(HookState h, bool on, Vector3 pivot, Vector3 outward, int ropeIdx, float dt)
		{
			//IL_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0019: Unknown result type (might be due to invalid IL or missing references)
			//IL_001e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0032: Unknown result type (might be due to invalid IL or missing references)
			//IL_0041: 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_0074: 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_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_0085: Unknown result type (might be due to invalid IL or missing references)
			//IL_0086: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_008f: 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_0062: Unknown result type (might be due to invalid IL or missing references)
			//IL_009c: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_00b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b6: 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_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_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00da: Unknown result type (might be due to invalid IL or missing references)
			//IL_00df: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f1: 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)
			//IL_0101: 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_0155: Unknown result type (might be due to invalid IL or missing references)
			//IL_015a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0174: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: 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_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0128: Unknown result type (might be due to invalid IL or missing references)
			//IL_012d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0130: Unknown result type (might be due to invalid IL or missing references)
			//IL_013f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0144: Unknown result type (might be due to invalid IL or missing references)
			//IL_0149: Unknown result type (might be due to invalid IL or missing references)
			//IL_01aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b7: Unknown result type (might be due to invalid IL or missing references)
			//IL_01bc: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c2: 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)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: 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_018a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0194: Unknown result type (might be due to invalid IL or missing references)
			//IL_0199: Unknown result type (might be due to invalid IL or missing references)
			//IL_019e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a7: Unknown result type (might be due to invalid IL or missing references)
			h.On = on;
			if (!on)
			{
				h.Ok = false;
				return;
			}
			Vector3 val = outward * 0.5f + Vector3.down * 0.5f;
			if (((Vector3)(ref val)).sqrMagnitude < 0.0001f)
			{
				val = Vector3.down;
			}
			((Vector3)(ref val)).Normalize();
			Vector3 val2;
			if (h.Ok)
			{
				val2 = h.Eye - pivot;
				if (!(((Vector3)(ref val2)).sqrMagnitude > 0.25f))
				{
					goto IL_009b;
				}
			}
			val2 = (h.Eye = (h.Prev = pivot + val * 0.058f));
			h.Ok = true;
			goto IL_009b;
			IL_009b:
			Vector3 val3 = (h.Eye - h.Prev) * 0.975f;
			h.Prev = h.Eye;
			h.Eye += val3 + Physics.gravity * (dt * dt);
			Vector3 val4 = P[ropeIdx] - h.Eye;
			float num = Rest / 15f;
			float magnitude = ((Vector3)(ref val4)).magnitude;
			if (magnitude > num && magnitude > 1E-05f)
			{
				h.Eye += val4 / magnitude * ((magnitude - num) * 0.45f);
			}
			Vector3 val5 = h.Eye - pivot;
			if (((Vector3)(ref val5)).sqrMagnitude < 1E-10f)
			{
				val5 = val;
			}
			((Vector3)(ref val5)).Normalize();
			float num2 = Vector3.Dot(val5, outward);
			if (num2 < 0.15f)
			{
				val2 = val5 + outward * (0.15f - num2);
				val5 = ((Vector3)(ref val2)).normalized;
			}
			h.Eye = pivot + val5 * 0.058f;
			val2 = h.Eye - h.Prev;
			if (((Vector3)(ref val2)).sqrMagnitude > 1E-09f)
			{
				stillSteps = 0;
			}
		}

		internal float HookSpeed(bool front, float dt)
		{
			//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_002c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0031: Unknown result type (might be due to invalid IL or missing references)
			HookState hookState = (front ? HookF : HookB);
			if (!hookState.Ok)
			{
				return 0f;
			}
			Vector3 val = hookState.Eye - hookState.Prev;
			return ((Vector3)(ref val)).magnitude / Mathf.Max(0.0001f, dt);
		}

		public void Place()
		{
			//IL_0054: 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_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_009d: Unknown result type (might be due to invalid IL or missing references)
			//IL_009f: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a4: 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_00a6: 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_0086: 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_00f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f5: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ff: 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_0185: Unknown result type (might be due to invalid IL or missing references)
			//IL_0186: Unknown result type (might be due to invalid IL or missing references)
			//IL_0189: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ab: Unknown result type (might be due to invalid IL or missing references)
			//IL_01b0: 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_012e: Unknown result type (might be due to invalid IL or missing references)
			//IL_014d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0152: Unknown result type (might be due to invalid IL or missing references)
			//IL_0157: Unknown result type (might be due to invalid IL or missing references)
			//IL_016c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0171: Unknown result type (might be due to invalid IL or missing references)
			//IL_0176: Unknown result type (might be due to invalid IL or missing references)
			//IL_01cd: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d2: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01da: Unknown result type (might be due to invalid IL or missing references)
			//IL_01dc: Unknown result type (might be due to invalid IL or missing references)
			HookF.Ok = (HookB.Ok = false);
			HookF.On = HookFrontOn;
			HookB.On = HookBackOn;
			if (HookF.On)
			{
				StepHook(HookF, on: true, Front, OutFrontWorld, 1, 0f);
			}
			if (HookB.On)
			{
				StepHook(HookB, on: true, Back, OutBackWorld, 14, 0f);
			}
			Vector3 endFront = EndFront;
			Vector3 endBack = EndBack;
			float num = Vector3.Distance(endFront, endBack);
			float num2 = ((num < Rest) ? Mathf.Sqrt(3f * num * Mathf.Max(0f, Rest - num) / 8f) : 0f);
			Vector3 val = T.TransformDirection(Vector3.Cross(Up, Fwd));
			Vector3 normalized = ((Vector3)(ref val)).normalized;
			for (int i = 0; i < 16; i++)
			{
				float num3 = (float)i / 15f;
				if (num < 0.05f)
				{
					P[i] = endFront + Vector3.down * (Rest * 0.48f * Mathf.Sin((float)Math.PI * num3)) + normalized * (0.03f * Mathf.Sin((float)Math.PI * 2f * num3));
				}
				else
				{
					P[i] = Vector3.Lerp(endFront, endBack, num3) + Vector3.down * (num2 * 4f * num3 * (1f - num3));
				}
				val = (Prev[i] = (Last[i] = P[i]));
				contact[i] = false;
			}
			placed = true;
			Wake();
		}

		public void Wake()
		{
			asleep = false;
			stillSteps = 0;
		}

		internal void SetPoints(Vector3[] pts)
		{
			//IL_001b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0020: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0022: Unknown result type (might be due to invalid IL or missing references)
			//IL_0027: Unknown result type (might be due to invalid IL or missing references)
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_0029: 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_002f: 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)
			for (int i = 0; i < 16; i++)
			{
				P[i] = (Prev[i] = (Last[i] = pts[i]));
			}
			placed = true;
			Wake();
		}

		public void Step(float dt, bool nearPlayer)
		{
			//IL_003a: 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_0041: 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_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d5: 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_00ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f1: Unknown result type (might be due to invalid IL or missing references)
			//IL_01f6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01fb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0211: Unknown result type (might be due to invalid IL or missing references)
			//IL_0217: Unknown result type (might be due to invalid IL or missing references)
			//IL_02c3: 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_02ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_02cf: Unknown result type (might be due to invalid IL or missing references)
			//IL_0166: Unknown result type (might be due to invalid IL or missing references)
			//IL_016b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0170: Unknown result type (might be due to invalid IL or missing references)
			//IL_0182: Unknown result type (might be due to invalid IL or missing references)
			//IL_0187: Unknown result type (might be due to invalid IL or missing references)
			//IL_018e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0193: Unknown result type (might be due to invalid IL or missing references)
			//IL_01a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_01ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_01c6: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d3: Unknown result type (might be due to invalid IL or missing references)
			//IL_01d4: Unknown result type (might be due to invalid IL or missing references)
			//IL_02f7: Unknown result type (might be due to invalid IL or missing references)
			//IL_02ff: Unknown result type (might be due to invalid IL or missing references)
			//IL_0304: Unknown result type (might be due to invalid IL or missing references)
			//IL_0315: Unknown result type (might be due to invalid IL or missing references)
			//IL_0322: Unknown result type (might be due to invalid IL or missing references)
			//IL_0327: Unknown result type (might be due to invalid IL or missing references)
			//IL_032c: Unknown result type (might be due to invalid IL or missing references)
			//IL_032e: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a3: Unknown result type (might be due to invalid IL or missing references)
			//IL_03a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b1: Unknown result type (might be due to invalid IL or missing references)
			//IL_03b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_03c5: Unknown result type (might be due to invalid IL or missing references)
			//IL_03ca: Unknown result type (might be due to invalid IL or missing references)
			//IL_03df: Unknown result type (might be due to invalid IL or missing references)
			//IL_03e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0403: Unknown result type (might be due to invalid IL or missing references)
			//IL_0408: Unknown result type (might be due to invalid IL or missing references)
			//IL_0425: Unknown result type (might be due to invalid IL or missing references)
			//IL_042a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0347: Unknown result type (might be due to invalid IL or missing references)
			//IL_034c: Unknown result type (might be due to invalid IL or missing references)
			//IL_035e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0363: Unknown result type (might be due to invalid IL or missing references)
			//IL_0376: Unknown result type (might be due to invalid IL or missing references)
			//IL_037b: Unknown result type (might be due to invalid IL or missing references)
			//IL_037d: Unknown result type (might be due to invalid IL or missing references)
			//IL_037e: Unknown result type (might be due to invalid IL or missing references)
			//IL_0383: Unknown result type (might be due to invalid IL or missing references)
			//IL_0388: Unknown result type (might be due to invalid IL or missing references)
			//IL_05dc: Unknown result type (might be due to invalid IL or missing references)
			//IL_05e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_05eb: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f0: Unknown result type (might be due to invalid IL or missing references)
			//IL_05f9: Unknown result type (might be due to invalid IL or missing references)
			//IL_05fa: Unknown result type (might be due to invalid IL or missing references)
			//IL_0607: Unknown result type (might be due to invalid IL or missing references)
			//IL_0608: Unknown result type (might be due to invalid IL or missing references)
			//IL_0623: Unknown result type (might be due to invalid IL or missing references)
			//IL_0632: Unknown result type (might be due to invalid IL or missing references)
			//IL_069c: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a1: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a4: Unknown result type (might be due to invalid IL or missing references)
			//IL_06a6: Unknown result type (might be due to invalid IL or missing references)
			//IL_06b9: Unknown result type (might be due to invalid IL or missing references)
			//IL_06bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_0743: Unknown result type (might be due to invalid IL or missing references)
			//IL_0745: Unknown result type (might be due to invalid IL or missing references)
			//IL_0748: Unknown result type (might be due to invalid IL or missing references)
			//IL_07e1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07ee: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07f8: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c0: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c1: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_07c4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0831: Unknown result type (might be due to invalid IL or missing references)
			//IL_0836: Unknown result type (might be due to invalid IL or missing references)
			//IL_0875: Unknown result type (might be due to invalid IL or missing references)
			//IL_087a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0886: Unknown result type (might be due to invalid IL or missing references)
			//IL_088b: Unknown result type (might be due to invalid IL or missing references)
			if (!Active)
			{
				if (visible)
				{
					view.Show(on: false);
					visible = false;
				}
				placed = false;
				return;
			}
			if (!placed)
			{
				Place();
			}
			Vector3 endFront = EndFront;
			Vector3 endBack = EndBack;
			if (Worn != null)
			{
				Array.Copy(P, Last, 16);
				if (Worn.Path(this, P))
				{
					Array.Copy(P, Prev, 16);
					Array.Clear(contact, 0, 16);
					Stretch = 0f;
					LastForce = 0f;
					asleep = false;
					carryOk = false;
					return;
				}
			}
			Carry(dt);
			Vector3 val = endFront - P[0];
			if (!(((Vector3)(ref val)).sqrMagnitude > 0.25f))
			{
				val = endBack - P[15];
				if (!(((Vector3)(ref val)).sqrMagnitude > 0.25f))
				{
					goto IL_0114;
				}
			}
			ReleaseStrap();
			Place();
			goto IL_0114;
			IL_085d:
			if (stillSteps > 45)
			{
				asleep = true;
				sleepPos = T.position;
				sleepRot = T.rotation;
				sleepHits = NearbyCount();
				Array.Copy(P, Last, 16);
			}
			return;
			IL_0856:
			stillSteps = 0;
			goto IL_085d;
			IL_0114:
			Array.Copy(P, Last, 16);
			if (Networked && !IsOwner && Time.time - RemoteTime < 2f)
			{
				for (int i = 0; i < 16; i++)
				{
					Vector3 val2 = T.TransformPoint(RemoteLocal[i]);
					P[i] = Vector3.Lerp(P[i], val2, 0.35f);
					Prev[i] = P[i];
				}
				P[0] = endFront;
				P[15] = endBack;
				return;
			}
			if (asleep)
			{
				val = T.position - sleepPos;
				if (((Vector3)(ref val)).sqrMagnitude > 1E-06f || Quaternion.Angle(T.rotation, sleepRot) > 0.3f)
				{
					Wake();
				}
				else if (++sleepCheck % 10 == 0 && NearbyCount() != sleepHits)
				{
					Wake();
				}
				if (asleep)
				{
					return;
				}
			}
			if ((Object)(object)StrapHolder != (Object)null && !StrapHeld)
			{
				ReleaseStrap();
			}
			if (StrapHeld)
			{
				asleep = false;
			}
			if (HookF.On || HookB.On || HookFrontOn || HookBackOn)
			{
				StepHooks(dt);
				endFront = EndFront;
				endBack = EndBack;
			}
			float seg = Rest / 15f;
			endGive = (Held ? 0f : 0.35f);
			Vector3 val3 = Physics.gravity * (dt * dt);
			for (int j = 1; j < 15; j++)
			{
				Vector3 val4 = P[j] - Prev[j];
				val4 *= (contact[j] ? 0.55f : 0.995f);
				Prev[j] = P[j];
				ref Vector3 reference = ref P[j];
				reference += val4 + val3;
			}
			P[0] = endFront;
			P[15] = endBack;
			Prev[0] = Last[0];
			Prev[15] = Last[15];
			if (StrapHeld)
			{
				P[StrapIndex] = StrapHolder.position;
				Prev[StrapIndex] = Last[StrapIndex];
			}
			Array.Copy(contact, held, 16);
			Array.Clear(contact, 0, 16);
			Array.Clear(contactSolid, 0, 16);
			for (int k = 0; k < 4; k++)
			{
				Solve(seg);
			}
			if (nearPlayer)
			{
				Collide(Prev);
			}
			else
			{
				GroundOnly();
			}
			SelfCollide();
			for (int l = 0; l < 2; l++)
			{
				Array.Copy(P, Mid, 16);
				for (int m = 0; m < 3; m++)
				{
					Solve(seg);
				}
				SelfCollide();
				if (nearPlayer)
				{
					Collide(Mid);
				}
				else
				{
					GroundOnly();
				}
			}
			int num = ((endGive == 0f || carryK > 0.5f) ? 6 : 3);
			for (int n = 0; n < num; n++)
			{
				if (!(Length() > Rest * 1.01f))
				{
					break;
				}
				bool flag = Length() > Rest * (1f + ((endGive == 0f) ? 0.03f : 0.06f));
				if (flag || endGive == 0f)
				{
					Array.Clear(held, 0, 16);
				}
				Array.Copy(P, Mid, 16);
				for (int num2 = 0; num2 < 8; num2++)
				{
					Solve(seg);
				}
				if (!flag || endGive != 0f)
				{
					if (nearPlayer)
					{
						Collide(Mid);
					}
					else
					{
						GroundOnly();
					}
				}
			}
			Vector3 endA = P[0];
			Vector3 endB = P[15];
			P[0] = endFront;
			P[15] = endBack;
			float num3 = 0f;
			for (int num4 = 0; num4 < 15; num4++)
			{
				num3 += Vector3.Distance(P[num4], P[num4 + 1]);
			}
			Stretch = num3 / Mathf.Max(0.01f, Rest) - 1f;
			if (StrapHeld)
			{
				float num5 = Rest * (float)StrapIndex / 15f;
				float num6 = Rest - num5;
				Vector3 position = StrapHolder.position;
				StrapStretch = Mathf.Max(Vector3.Distance(position, endFront) / Mathf.Max(0.02f, num5), Vector3.Distance(position, endBack) / Mathf.Max(0.02f, num6)) - 1f;
				if (StrapStretch > 1f)
				{
					if (slipSince < 0f)
					{
						slipSince = Time.time;
					}
					if (Time.time - slipSince > 0.3f)
					{
						StrapGrab.Slips++;
						ReleaseStrap();
					}
				}
				else
				{
					slipSince = -1f;
					if (StrapStretch > 0f)
					{
						HoldBack(position, endFront, num5, endBack, num6);
					}
				}
			}
			if (Stretch > 0.35f && !StrapHeld && (!((Object)(object)Rb != (Object)null) || !Rb.isKinematic))
			{
				Place();
				Stretch = 0f;
			}
			LastForce = 0f;
			if (IsOwner && (Object)(object)Rb != (Object)null && !Rb.isKinematic)
			{
				Pull(endFront, endA, endBack, endB);
			}
			float num7 = 0f;
			for (int num8 = 1; num8 < 15; num8++)
			{
				float num9 = num7;
				val = P[num8] - Last[num8];
				num7 = Mathf.Max(num9, ((Vector3)(ref val)).sqrMagnitude);
			}
			if (!(num7 < 3.9999996E-08f))
			{
				goto IL_0856;
			}
			if (!((Object)(object)Rb == (Object)null))
			{
				val = Rb.velocity;
				if (!(((Vector3)(ref val)).sqrMagnitude < 0.0004f))
				{
					goto IL_0856;
				}
			}
			stillSteps++;
			goto IL_085d;
		}

		private void Carry(float dt)
		{
			//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_0012: Unknown result type (might be due to invalid IL or missing references)
			//IL_0017: Unknown result type (might be due to invalid IL or missing references)
			//IL_012a: Unknown result type (might be due to invalid IL or missing references)
			//IL_012b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0131: Unknown result type (might be due to invalid IL or missing references)
			//IL_0132: 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_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_002f: 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_0069: Unknown result type (might be due to invalid IL or missing references)
			//IL_006e: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_0092: Unknown result type (might be due to invalid IL or missing references)
			//IL_0097: Unknown result type (might be due to invalid IL or missing references)
			//IL_0098: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b2: Unknown result type (might be due to invalid IL or missing references)
			//IL_00b7: 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_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_00dd: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e7: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ed: Unknown result type (might be due to invalid IL or missing references)
			//IL_00f2: 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)
			//IL_0102: Unknown result type (might be due to invalid IL or missing references)
			//IL_0107: Unknown result type (might be due to invalid IL or missing references)
			Vector3 position = T.position;
			Quaternion rotation = T.rotation;
			if (carryOk)
			{
				Vector3 val = position - carryPos;
				float num = (carryK = Mathf.Clamp01((((Vector3)(ref val)).magnitude / Mathf.Max(0.0001f, dt) - 2.5f) / 3f));
				if (num > 0.001f)
				{
					Quaternion val2 = rotation * Quaternion.Inverse(carryRot);
					for (int i = 0; i < 16; i++)
					{
						P[i] = Vector3.LerpUnclamped(P[i], position + val2 * (P[i] - carryPos), num);
						Prev[i] = Vector3.LerpUnclamped(Prev[i], position + val2 * (Prev[i] - carryPos), num);
					}
					if (num > 0.5f)
					{
						Wake();
					}
				}
			}
			carryPos = position;
			carryRot = rotation;
			carryOk = true;
		}

		internal void Hide()
		{
			if (visible)
			{
				view.Show(on: false);
				visible = false;
			}
		}

		internal void GrabStrap(int index, Transform holder)
		{
			StrapHolder = holder;
			StrapIndex = Mathf.Clamp(index, 1, 14);
			StrapHandRb = null;
			try
			{
				StrapHandRb = ((Component)holder).GetComponentInParent<Rigidbody>();
			}
			catch
			{
			}
			Wake();
		}

		internal void ReleaseStrap()
		{
			StrapHolder = null;
			StrapIndex = -1;
			StrapHandRb = null;
			Wake();
		}

		private void HoldBack(Vector3 hp, Vector3 a, float la, Vector3 b, float lb)
		{
			//IL_0002: Unknown result type (might be due to invalid IL or missing references)
			//IL_0003: Unknown result type (might be due to invalid IL or missing references)
			//IL_0053: Unknown result type (might be due to invalid IL or missing references)
			//IL_0058: 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_0068: Unknown result type (might be due to invalid IL or missing references)
			LastHoldBack = 0f;
			Rigidbody hand = StrapHandRb;
			Vector3 total;
			if (!((Object)(object)hand == (Object)null) && !((Il2CppObjectBase)hand).WasCollected && !hand.isKinematic)
			{
				total = Vector3.zero;
				Side(a, la);
				Side(b, lb);
				LastHoldBack = ((Vector3)(ref total)).magnitude;
			}
			void Side(Vector3 end, float reach)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: 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)
				//IL_002a: Unknown result type (might be due to invalid IL or missing references)
				//IL_002c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0031: Unknown result type (might be due to invalid IL or missing references)
				//IL_0038: Unknown result type (might be due to invalid IL or missing references)
				//IL_0058: Unknown result type (might be due to invalid IL or missing references)
				//IL_0059: Unknown result type (might be due to invalid IL or missing references)
				//IL_004b: Unknown result type (might be due to invalid IL or missing references)
				//IL_005e: Unknown result type (might be due to invalid IL or missing references)
				//IL_0063: Unknown result type (might be due to invalid IL or missing references)
				//IL_006a: Unknown result type (might be due to invalid IL or missing references)
				//IL_006c: Unknown result type (might be due to invalid IL or missing references)
				//IL_0096: Unknown result type (might be due to invalid IL or missing references)
				//IL_0099: Unknown result type (might be due to invalid IL or missing references)
				//IL_009e: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a6: Unknown result type (might be due to invalid IL or missing references)
				//IL_00e9: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ee: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f0: Unknown result type (might be due to invalid IL or missing references)
				//IL_00f5: 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_00d1: Unknown result type (might be due to invalid IL or missing references)
				//IL_00db: 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)
				Vector3 val = end - hp;
				float magnitude = ((Vector3)(ref val)).magnitude;
				float num = magnitude - reach;
				if (!(num <= 0f) && !(magnitude < 0.0001f))
				{
					Vector3 val2 = val / magnitude;
					Vector3 val3 = hand.velocity - (((Object)(object)Rb != (Object)null) ? Rb.GetPointVelocity(end) : Vector3.zero);
					float num2 = Mathf.Max(0f, 0f - Vector3.Dot(val3, val2));
					float num3 = Mathf.Min(num * 9000f + num2 * 160f, 1400f);
					Vector3 val4 = val2 * num3;
					hand.AddForce(val4, (ForceMode)0);
					if ((Object)(object)Rb != (Object)null && !Rb.isKinematic)
					{
						Rb.AddForceAtPosition(-val4 * 0.6f, end, (ForceMode)0);
					}
					total += val4;
				}
			}
		}

		internal int OwnClips()
		{
			//IL_000d: Unknown result type (might be due to invalid IL or missing references)
			int num = 0;
			for (int i = 2; i < 14; i++)
			{
				int num2 = Physics.OverlapSphereNonAlloc(P[i], 0.006f, Overlaps, Mask, (QueryTriggerInteraction)1);
				for (int j = 0; j < num2; j++)
				{
					if ((Object)(object)((Il2CppArrayBase<Collider>)(object)Overlaps)[j] != (Object)null && !((Il2CppArrayBase<Collider>)(object)Overlaps)[j].isTrigger && own.Contains(((Il2CppObjectBase)((Il2CppArrayBase<Collider>)(object)Overlaps)[j]).Pointer))
					{
						num++;
						break;
					}
				}
			}
			return num;
		}

		private float Length()
		{
			//IL_0012: 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)
			float num = 0f;
			for (int i = 0; i < 15; i++)
			{
				num += Vector3.Distance(P[i], P[i + 1]);
			}
			return num;
		}

		private void Solve(float seg)
		{
			//IL_0010: Unknown result type (might be due to invalid IL or missing references)
			//IL_001c: Unknown result type (might be due to invalid IL or missing references)
			//IL_0021: Unknown result type (might be due to invalid IL or missing references)
			//IL_0026: Unknown result type (might be due to invalid IL or missing references)
			//IL_00cb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d0: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d8: Unknown result type (might be due to invalid IL or missing references)
			//IL_00dd: 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_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_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_010d: Unknown result type (might be due to invalid IL or missing references)
			for (int i = 0; i < 15; i++)
			{
				Vector3 val = P[i + 1] - P[i];
				float magnitude = ((Vector3)(ref val)).magnitude;
				if (!(magnitude < 1E-06f))
				{
					float num = (magnitude - seg) / magnitude;
					float num2 = ((i == 0) ? endGive : ((i == StrapIndex) ? 0f : (held[i] ? 0.12f : 1f)));
					float num3 = ((i + 1 == 15) ? endGive : ((i + 1 == StrapIndex) ? 0f : (held[i + 1] ? 0.12f : 1f)));
					float num4 = num2 + num3;
					if (!(num4 <= 0f))
					{
						ref Vector3 reference = ref P[i];
						reference += val * (num * num2 / num4);
						ref Vector3 reference2 = ref P[i + 1];
						reference2 -= val * (num * num3 / num4);
					}
				}
			}
		}

		private void Pull(Vector3 a, Vector3 endA, Vector3 b, Vector3 endB)
		{
			//IL_0019: 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_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_002f: Unknown result type (might be due to invalid IL or missing references)
			//IL_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_003e: Unknown result type (might be due to invalid IL or missing references)
			//IL_00fd: Unknown result type (might be due to invalid IL or missing references)
			//IL_011a: Unknown result type (might be due to invalid IL or missing references)
			//IL_0147: Unknown result type (might be due to invalid IL or missing references)
			//IL_0148: Unknown result type (might be due to invalid IL or missing references)
			//IL_015b: Unknown result type (might be due to invalid IL or missing references)
			//IL_015c: Unknown result type (might be due to invalid IL or missing references)
			float k;
			float c;
			float cap;
			float friction;
			float dt;
			if (!Held && !Pulling)
			{
				Vector3 val = Physics.gravity * 0.075f;
				Rb.AddForceAtPosition(val, a, (ForceMode)0);
				Rb.AddForceAtPosition(val, b, (ForceMode)0);
				float mass = Rb.mass;
				float num = Mathf.Max(0f, Stretch - 0.06f);
				k = mass * 1100f * (1f + Mathf.Min(num, 0.1f) * 60f) * (StrapHeld ? 3f : 1f);
				c = 2f * Mathf.Sqrt(k * mass) * 1f;
				cap = mass * 9.81f * (StrapHeld ? 12f : 8f);
				friction = 0.8829001f;
				float num2 = (StrapHeld ? 1f : Support(1, 1, a));
				float num3 = (StrapHeld ? 1f : Support(14, -1, b));
				LastSupport = Mathf.Max(num2, num3);
				dt = Time.fixedDeltaTime;
				At(a, endA, capFor(num2));
				At(b, endB, capFor(num3));
			}
			void At(Vector3 anchor, Vector3 dragged, float limit)
			{
				//IL_0000: Unknown result type (might be due to invalid IL or missing references)
				//IL_0001: Unknown result type (might be due to invalid IL or missing references)
				//IL_0002: Unknown result type (might be due to invalid IL or missing references)
				//IL_0007: 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_0026: 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_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_003b: 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_00a5: Unknown result type (might be due to invalid IL or missing references)
				//IL_00a8: Unknown result type (might be due to invalid IL or missing references)
				//IL_00ad: Unknown result type (might be due to invalid IL or missing references)
				Vector3 val2 = dragged - anchor;
				float num4 = ((Vector3)(ref val2)).magnitude - 0.004f;
				if (!(num4 <= 0f))
				{
					Vector3 normalized = ((Vector3)(ref val2)).normalized;
					float num5 = Vector3.Dot(Rb.GetPointVelocity(anchor), normalized);
					float num6 = EffectiveMass(anchor, normalized);
					float num7 = Mathf.Min(k, num6 * 1f / (dt * dt));
					float num8 = Mathf.Min(c, num6 * 0.8f / dt);
					float num9 = Mathf.Min(num7 * num4 - num8 * num5, limit);
					if (!(num9 <= 0f))
					{
						Rb.AddForceAtPosition(normalized * num9, anchor, (ForceMode)0);
						LastForce += num9;
					}
				}
			}
			float Support(int from, int step, Vector3 anchor)
			{
				//IL_0021: 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_004f: 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)
				float num4 = 0f;
				for (int i = from; i > 0 && i < 15; i += step)
				{
					if (contact[i] && contactSolid[i])
					{
						Vector3 val2 = anchor - P[i];
						if (((Vector3)(ref val2)).sqrMagnitude < 1E-06f)
						{
							return 1f;
						}
						float num5 = Mathf.Clamp01((0f - Vector3.Dot(ContactNormal[i], ((Vector3)(ref val2)).normalized)) * 1.6f);
						if (num5 > num4)
						{
							num4 = num5;
							if (num5 > 0.5f)
							{
								LastSupportBy = contactWhat[i] ?? "?";
							}
						}
					}
				}
				return num4;
			}
			float capFor(float support)
			{
				return Mathf.Max(friction, cap * support);
			}
		}

		private float EffectiveMass(Vector3 at, Vector3 dir)
		{
			//IL_0022: 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_002e: 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_0043: Unknown result type (might be due to invalid IL or missing references)
			//IL_0048: Unknown result type (might be due to invalid IL or missing references)
			//IL_004f: Unknown result type (might be due to invalid IL or missing references)
			//IL_0054: Unknown result type (might be due to invalid IL or missing references)
			//IL_0059: 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_0064: Unknown result type (might be due to invalid 

Mods/OpenSlingFusion.dll

Decompiled 18 hours ago
using System;
using System.Diagnostics;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.Versioning;
using System.Security;
using System.Security.Permissions;
using Il2CppSLZ.Marrow;
using LabFusion.Entities;
using LabFusion.Marrow.Extenders;
using LabFusion.Network;
using LabFusion.Network.Serialization;
using LabFusion.Player;
using LabFusion.SDK.Modules;
using LabFusion.Utilities;
using MelonLoader;
using Microsoft.CodeAnalysis;
using OpenSling;
using OpenSlingFusion;
using UnityEngine;

[assembly: CompilationRelaxations(8)]
[assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)]
[assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)]
[assembly: MelonInfo(typeof(Main), "OpenSling Fusion", "1.1.1", "Lack", null)]
[assembly: MelonGame("Stress Level Zero", "BONELAB")]
[assembly: MelonAdditionalDependencies(new string[] { "OpenSling", "LabFusion" })]
[assembly: TargetFramework(".NETCoreApp,Version=v6.0", FrameworkDisplayName = ".NET 6.0")]
[assembly: AssemblyCompany("OpenSlingFusion")]
[assembly: AssemblyConfiguration("Release")]
[assembly: AssemblyFileVersion("1.0.0.0")]
[assembly: AssemblyInformationalVersion("1.0.0")]
[assembly: AssemblyProduct("OpenSlingFusion")]
[assembly: AssemblyTitle("OpenSlingFusion")]
[assembly: SecurityPermission(SecurityAction.RequestMinimum, SkipVerification = true)]
[assembly: AssemblyVersion("1.0.0.0")]
[module: UnverifiableCode]
[module: RefSafetyRules(11)]
namespace Microsoft.CodeAnalysis
{
	[CompilerGenerated]
	[Embedded]
	internal sealed class EmbeddedAttribute : Attribute
	{
	}
}
namespace System.Runtime.CompilerServices
{
	[CompilerGenerated]
	[Embedded]
	[AttributeUsage(AttributeTargets.Class | AttributeTargets.Property | AttributeTargets.Field | AttributeTargets.Event | AttributeTargets.Parameter | AttributeTargets.ReturnValue | AttributeTargets.GenericParameter, AllowMultiple = false, Inherited = false)]
	internal sealed class NullableAttribute : Attribute
	{
		public readonly byte[] NullableFlags;

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

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

		public NullableContextAttribute(byte P_0)
		{
			Flag = P_0;
		}
	}
	[CompilerGenerated]
	[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 OpenSlingFusion
{
	public sealed class Main : MelonMod
	{
		[Serializable]
		[CompilerGenerated]
		private sealed class <>c
		{
			public static readonly <>c <>9 = new <>c();

			public static PlayerUpdate <>9__0_0;

			internal void <OnInitializeMelon>b__0_0(PlayerID _)
			{
				SlingNet.PlayerJoined();
			}
		}

		public override void OnInitializeMelon()
		{
			//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_0029: Expected O, but got Unknown
			ModuleMessageManager.RegisterHandler<SlingConfigMessage>();
			ModuleMessageManager.RegisterHandler<SlingRopeMessage>();
			object obj = <>c.<>9__0_0;
			if (obj == null)
			{
				PlayerUpdate val = delegate
				{
					SlingNet.PlayerJoined();
				};
				<>c.<>9__0_0 = val;
				obj = (object)val;
			}
			MultiplayerHooking.OnPlayerJoined += (PlayerUpdate)obj;
			SlingNet.Network = (ISlingNetwork)(object)new FusionLink();
			((MelonBase)this).LoggerInstance.Msg("Slings are synced in Fusion servers.");
		}
	}
	internal sealed class FusionLink : ISlingNetwork
	{
		public bool InServer => NetworkInfo.HasServer;

		public bool TryEntity(Gun gun, out ushort id, out bool owner)
		{
			id = 0;
			owner = true;
			if (!NetworkInfo.HasServer || (Object)(object)gun == (Object)null)
			{
				return false;
			}
			NetworkEntity val = default(NetworkEntity);
			if (!GunExtender.Cache.TryGet(gun, ref val) || val == null)
			{
				return false;
			}
			id = val.ID;
			owner = !val.HasOwner || val.IsOwner;
			return true;
		}

		public void SendConfig(ushort id, SlingSettings s)
		{
			//IL_0015: Unknown result type (might be due to invalid IL or missing references)
			//IL_0016: Unknown result type (might be due to invalid IL or missing references)
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (PlayerIDManager.HasOtherPlayers)
			{
				MessageRelay.RelayModule<SlingConfigMessage, SlingConfigData>(new SlingConfigData
				{
					Entity = id,
					Settings = s
				}, new MessageRoute((RelayType)3, (NetworkChannel)0));
			}
		}

		public void SendRope(ushort id, Vector3[] local)
		{
			//IL_001d: Unknown result type (might be due to invalid IL or missing references)
			if (PlayerIDManager.HasOtherPlayers)
			{
				MessageRelay.RelayModule<SlingRopeMessage, SlingRopeData>(new SlingRopeData
				{
					Entity = id,
					Points = local
				}, new MessageRoute((RelayType)3, (NetworkChannel)1));
			}
		}
	}
	internal sealed class SlingConfigData : INetSerializable
	{
		public ushort Entity;

		public SlingSettings Settings;

		public int? GetSize()
		{
			return 38;
		}

		public void Serialize(INetSerializer s)
		{
			byte mode = Settings.Mode;
			byte b = (byte)(Settings.Style + 1);
			s.SerializeValue(ref Entity);
			s.SerializeValue(ref mode);
			s.SerializeValue(ref b);
			s.SerializeValue(ref Settings.FrontForward);
			s.SerializeValue(ref Settings.FrontUp);
			s.SerializeValue(ref Settings.BackForward);
			s.SerializeValue(ref Settings.BackUp);
			s.SerializeValue(ref Settings.Length);
			s.SerializeValue(ref Settings.Width);
			s.SerializeValue(ref Settings.RollFront);
			s.SerializeValue(ref Settings.RollBack);
			s.SerializeValue(ref Settings.Swivels);
			byte b2 = (byte)((Settings.HideFront ? 1u : 0u) | (uint)(Settings.HideBack ? 2 : 0) | (uint)((Settings.Attach & 3) << 2));
			s.SerializeValue(ref b2);
			Settings.HideFront = (b2 & 1) != 0;
			Settings.HideBack = (b2 & 2) != 0;
			Settings.Attach = (byte)((b2 >> 2) & 3);
			Settings.Mode = mode;
			Settings.Style = (sbyte)(b - 1);
		}
	}
	internal sealed class SlingRopeData : INetSerializable
	{
		public ushort Entity;

		public Vector3[] Points = (Vector3[])(object)new Vector3[16];

		public int? GetSize()
		{
			return 194;
		}

		public void Serialize(INetSerializer s)
		{
			s.SerializeValue(ref Entity);
			if (Points == null || Points.Length != 16)
			{
				Points = (Vector3[])(object)new Vector3[16];
			}
			for (int i = 0; i < 16; i++)
			{
				NetSerializerUnityExtensions.SerializeValue(s, ref Points[i]);
			}
		}
	}
	[SkipHandleWhileLoading]
	internal sealed class SlingConfigMessage : ModuleMessageHandler
	{
		protected override void OnHandleMessage(ReceivedMessage received)
		{
			//IL_000f: Unknown result type (might be due to invalid IL or missing references)
			SlingConfigData slingConfigData = ((ReceivedMessage)(ref received)).ReadData<SlingConfigData>();
			SlingNet.ReceiveConfig(slingConfigData.Entity, slingConfigData.Settings);
		}
	}
	[SkipHandleWhileLoading]
	internal sealed class SlingRopeMessage : ModuleMessageHandler
	{
		protected override void OnHandleMessage(ReceivedMessage received)
		{
			SlingRopeData slingRopeData = ((ReceivedMessage)(ref received)).ReadData<SlingRopeData>();
			SlingNet.ReceiveRope(slingRopeData.Entity, slingRopeData.Points);
		}
	}
}